agent-patterns

typed-evidence-chain

flowchart TD
    Router[Router agent] -- BUG --> BugBuilder[Bug builder]
    Router[Router agent] -- REFACTOR --> RefactorBuilder[Refactor builder]
    Router[Router agent] -- FEATURE --> FeatureBuilder[Feature builder]
    BugBuilder --> BugEvidence[Patch plus Reproduction block]
    RefactorBuilder --> RefactorEvidence[Patch plus Non-regression evidence]
    FeatureBuilder --> FeatureEvidence[Patch plus AC coverage]
    BugEvidence --> Reviewer[Reviewer agent]
    RefactorEvidence --> Reviewer
    FeatureEvidence --> Reviewer
    Reviewer --> Done([DONE or NEEDS REVIEW])

Specialized builders share a common output interface but append a type-specific evidence block. The reviewer receives patch + AC + the evidence block appropriate for what it needs to validate — it never re-derives the change type or reconstructs what the builder was trying to prove.

How it works

  1. The router classifies the task (BUG, REFACTOR, FEATURE) and dispatches to the matching builder.
  2. Each builder produces a patch block and an AC coverage block (shared interface), plus a type-specific evidence block:
    • BUG → Reproduction block: a test or steps that reproduce the defect before the fix, proving the fix is targeted.
    • REFACTOR → Non-regression evidence: confirmation that pre-existing tests pass after the change.
    • FEATURE → no additional block (AC coverage is sufficient).
  3. The reviewer receives all three artifacts. Its validation strategy differs by type:
    • BUG review: does the reproduction test fail on the original code? Does the fix make it pass?
    • REFACTOR review: are there pre-existing tests? Do they still pass?
    • FEATURE review: is every AC item checked with a code location?

Where it came from

When to use

When not to use

Trade-offs

   
Pro Reviewer receives exactly the evidence it needs — no prompt engineering to handle all cases
Pro Bug fixes must include a reproduction test by construction — not optional
Pro Refactor builders cannot claim success without running existing tests
Con Adds a per-type output contract; new change types require a new builder and a new evidence block format
Con Misclassification by the router produces the wrong evidence block; reviewer may not catch the mismatch
Con Reproduction blocks require the builder to reason about pre-fix behavior — harder than just writing the fix

Failure modes

Implementation reference

ai-dev-tools: