Review
One scripted Full Code Review Pass by one fresh Reviewer, ending in one Pass Report and a returned route
$review-phase runs one Full Code Review Pass over a committed Git change. The script
scripts/review.mjs does the mechanics. One fresh Reviewer subagent finds and verifies its own
findings. retain writes and commits one Pass Report and returns one route. Delivery owns every
repair, debugging, debt, documentation, and closeout transition. Terms follow the
Review Phase Token Rebuild Glossary.
- Use this when: a delivery reaches
review_due, or an operator wants a standalone review of a commit or commit range. - It gives you: at most five verified P0–P2 findings with stable IDs, one committed Pass Report, and one route.
- It ends with: a returned route, or a one-sentence
blockerthat the agent relays unchanged. - Wrapped skills: none. The reviewer brief
references/reviewer.mdholds the whole lens.
review-phase is explicit-only (disable-model-invocation: true). Delivery reaches the skill by
path; an operator names it for a standalone review. External GitHub and Codex pull-request reviewer
integration is out of scope.
Invocation Boundary
Every delivery goes through review, whatever its size. No delivery reaches docs ingest or closeout without a valid Pass Report.
- Full delivery:
delivery-phasepersistsreview_dueand starts$review-phasewithout an operator stop. - Other delivery modes: delivery persists
review_dueand the invocation context, names$review-phasewith that context as the next phase in its stop report, and stops. The operator invokes$review-phasewith that context and later resumes delivery explicitly. - Standalone: the operator commits the plan, spec, docs, or code first, then passes a commit or
<base>..<head>range. The run reads and writes no delivery counter.
The phase-handoff reference
maps the invocation context to the prepare options --goal, --base, --spec,
--accepted-risk, and --human-direction.
Pass Flow
The root agent makes three script calls and starts one subagent. Each review.mjs call prints one
JSON line.
- Status.
review.mjs status --goal <delivery-dir>returnsnext,run_dir, andpass_count. Delivery enters here and continues at the stepnextnames (prepare,review,retain, ordone). Standalone review starts at step 2. - Prepare.
review.mjs prepare --goal <delivery-dir> --base <sha>, orprepare --standalone <commit-or-range>. It freezes the target, checks the pass budget, and writespacket.jsonwithbase,head,changed_paths, andcontext: theAGENTS.mdchain, the matched Codebase Rules (rows whose path trigger matches a changed path, plus rows with no path glob but a task trigger; a Markdown-link File cell names the file by its target), and the spec folder'sSPEC.md,ARCHITECTURE.md, andPLAN.md. - Review. The agent starts one fresh general-purpose subagent in the foreground: a new agent,
never a fork or an earlier agent. Its whole prompt is the path of
references/reviewer.mdand therun_dir; it gets no summary or view of the change. The step completes when the Reviewer's one-line result and token total are in context. - Retain.
review.mjs retain --run-dir <run_dir> --subagent-tokens <n>, with<n>the Reviewer's token total, validatesfindings.json, derives the route, and writes and commits the Pass Report. Ifretainrefusesfindings.json, the same Reviewer rewrites the file and the agent retains again. The line carriespass_report,run_id,commit,route, andfindings. - Return. The agent returns
pass_report,review_run_id(therun_id),route.primary,route.secondary_debt, and thefindingslist (id,priority,kind,location,return_route). The retain line is the presentation source; the Pass Report stays the review authority.
The reviewed change stays readonly. The Pass Report commit is the only write of a pass.
Prepare Blockers
prepare returns a blocker before the Reviewer starts when:
- the target has no reviewable Git change outside Pass Reports;
- the standalone locator is not a commit or a
<base>..<head>range; - the pass budget is spent (see Pass Budget);
- the change touches several spec folders and no
--specnames one; - a delivery, or a run with
--spec, has no spec source: the spec folder holds noSPEC.md,ARCHITECTURE.md, orPLAN.mdat the reviewed head.
The agent relays each blocker unchanged to the caller and stops.
Reviewer
The Reviewer reads the diff and each context file at head, hunts the changed code inside the
lens, and verifies each candidate itself. Its only write is <run_dir>/findings.json.
kind | Defect |
|---|---|
security | A risk the change introduces: injection, secret exposure, a missing authorization check, unsafe input handling |
performance | A cost that grows with input or load: an N+1 query, an unbounded read, repeated work on a hot path |
contract | Drift: a changed producer (schema, contract, client, env, config, callback) leaves consumers that did not move |
unrequested | Behavior that no SPEC.md, ARCHITECTURE.md, or PLAN.md line asks for |
smell | A Fowler smell whose cost already shows in the changed code; a documented standard in context that endorses the pattern drops it |
Out of the lens: style, naming-only, nitpick and "consider X" remarks, architecture placement, skill-guidance adherence, test evidence, and anything a linter, type checker, test, or verifier owns.
- Verify: a candidate becomes a finding only with a traced
failure_scenario: concrete inputs or state that reach the changed line and produce a wrong result. Zero findings is the expected result of a clean change. - Rank:
P0data loss, a security breach, or an outage on a main path;P1a wrong result or broken contract on a reachable path;P2a real defect with narrow reach. A smell qualifies only atP2. The Reviewer keeps the first five by priority, smells last. - Finding keys:
id,priority,kind,location(path:lineathead),failure_scenario,action, and onereturn_route. A finding getshuman_steering_requiredwhen its repair exceeds accepted bounds, changes a requirement, weakens a gate, or substantially redesigns the implementation.
Why One Reviewer
Verification owns correctness evidence, so review hunts only what tests cannot catch. The two
retained passes of the earlier two-axis design showed the cost of a wider lens: 15 of 19 rejected
candidates were false positives from the mechanical acceptance-criterion check, no P3 smell was ever
accepted, the only finding tests could not catch was a security issue, and the second engine and
its fallback never ran. The fresh-reviewer rework (skills commit ecf11426c095) removed the axes,
the vendored engine, the background step, the separate verifying subagent, and the mechanical
candidates.
implement-spec finalize owns acceptance-criterion and skill-evidence records.
Pass Report
A delivery Pass Report lives at .devpunks/delivery/<goal>/reviews/pass-<n>.json. A standalone
Pass Report lives at .devpunks/delivery/standalone/reviews/<base12>-<head12>-<run_id>.json.
- Schema:
pass-report-v2withrun_id,ordinal(null for standalone),mode,base,head,reviewer.subagent_tokens,findings, and the derivedroute. - Write:
retainvalidates the report, creates the file exclusively, and commits only that path. A second writer for the same ordinal fails and never overwrites. AHEADchange sinceprepareinvalidates the run. - Pass count: the completed pass count of a delivery is the number of valid Pass Reports in its
reviews/folder; legacypass-report-v1reports still count. No handoff field stores it. - Scope: Pass Reports stay out of the wiki and out of every review target. Legacy wiki review reports under Project Review Reports count no pass.
The run directory $TMPDIR/hi-review/<run-id>/ holds packet.json and findings.json. retain
removes it after the commit.
Routing
retain derives route.primary from the findings' return_route values, in the order
human_steering_required > debugging > implementation > debt_follow_up > docs_ingest. No
findings give closeout. route.secondary_debt is true when a debt finding sits beside a primary
debugging or implementation.
human_steering_required: standalone review returns the blocking findings, their evidence, and the exact decision needed to the operator. Inside AFKdelivery-phase, delivery takes one out-of-bounds Autonomous Decision per blocking finding and posts it to the thread at once. A decision that needs a code change follows theimplementationroute; any other follows thedebt_follow_uproute.debugging: delivery opens scoped Debugging.implementation: delivery opens the implementation repair.debt_follow_up: delivery captures each debt finding once, keyed by Pass Report path and findingid. Withsecondary_debt, capture runs first and then the recorded repair.docs_ingest: delivery opens Docs Update.
Delivery opens a repair in one handoff write of the state, the route, pass_report, and
review_run_id. A later write for the same review_run_id resumes that transition. Standalone
review returns the route to the operator.
Pass Budget
prepare enforces the budget from the recovered pass count:
- Default: one pass. An ordinary accepted repair gets Focused Repair Validation. It reruns only the Verification scenarios the repair invalidated and opens no new pass.
- Second pass: risk trigger only. The repair must change architecture, security or
authorization, a public contract, runtime or deployment topology, or accepted scope. Delivery
passes
--accepted-risk <kind>:<evidence>. - Further pass: human direction only. After two passes,
prepareneeds--human-direction <evidence>. That evidence quotes only words the human already wrote in the goal or thread, so delivery asks for none. Without it, delivery takes an out-of-bounds Autonomous Decision onreview_budget_exhausted: it captures the open findings as debt, keeps the Pass Reports, and continues to docs ingest or closeout. - No consumption: an incomplete, interrupted, or invalidated run writes no Pass Report and counts no pass.
Resume, rebase, retry, and handoff keep the count. Only an explicitly new delivery goal with new
accepted bounds starts a new reviews/ folder and count. Standalone review has no budget.
Resume
status names the next step from the latest run directory of the goal: review without
findings.json, retain with it, and prepare when HEAD moved since prepare or the run
directory comes from an older review-phase. Without a run directory, status returns done when
the latest Pass Report covers HEAD, otherwise prepare. A new delivery prepare removes older run
directories of the same goal.
Review And Verification
Verification proves behavior by driving the real product through verify-behavior. Review inspects
the committed change.
- Verification runs during
implement-spec, before review.implement-specfinalize owns the acceptance-criterion status rows and their Verification records. review-phasenever runs the Project Verifier, never checks test evidence, and never owns evidence freshness.
See Project Verification Flow and Project Verifier.
Adjacent Entrypoints
review-phase does not load these skills. Use them as separate, explicit runs:
improve-codebase-architecture: module deepening and seam redesign, which sit outside the review lens.make-tsuite: audit or reorganize a test portfolio without production changes, for example when test evidence looks weak.security-best-practices: a full language- and framework-specific security report, on explicit request. The Reviewer covers only concrete security risks in the change.audit-cicd-security: a readonly CI/CD pipeline security audit. It applies fixes only after explicit approval.architect-pipeline: design or change CI/CD pipelines.- Tech Debt: resolve one captured debt item later through
$resolve-debt-phase.