Repository navigation
Review and Triage
LEAN review runs blind lenses in parallel, then one orchestrator verifies every finding and routes it back to where the problem came from.
Invoke it with lean-review; build acts on the result in lean-build.
diff or planning doc, staged as a file
▼
adversarial · edge-case · verification-gap · [security] all at once, blind
▼ every reviewer has reported
orchestrator: verify ─► grade ─► group ─► route ─► act and log
| Lens | Applies to | Hunts |
|---|---|---|
adversarial |
anything | what is wrong, what is missing, over-engineering |
edge-case |
code | unhandled paths, behavior lost in deletions, false spec claims |
verification-gap |
code that changes behavior | changed behavior no running test would catch |
security |
code at a trust boundary | untrusted input reaching a dangerous sink; missing access checks |
doc-rubric |
planning docs | decision-readiness, coverage, traceability |
adversarial. Two passes: what is wrong, then what is missing. It always also hunts over-engineering: (single-use abstractions, config for constants); the fix is a deletion. No quota: No findings is valid.
edge-case. A pure path tracer: it lists missing handling, never quality. It walks every branch in the diff, including the untouched members of a changed enum, then runs a deletion check (a removed contract nobody re-established) and a claims check. It reads the claims file (the build spec) only after tracing, as testimony, and tries to falsify each claim. Output is a JSON array.
verification-gap. One question: if the behavior this change produces broke where it is used, would a test fail? Three shapes: regression gap, missing-adoption gap (a sibling site should use the new rule and nothing checks it), broken-verification gap (test skipped, flaky or too weak). A test counts only if it runs normally and asserts the changed result. Each gap ends in patch (the test to add) or defer.
security. Traces untrusted input (requests, files, environment, third-party responses, agent output) to sinks (queries, shell, paths, templates, deserializers, server-side fetches, eval). Also checks ownership and authorization on new endpoints, secrets and personal data in logs, crypto, new dependencies and fail-open errors. It needs a concrete path; generic advice is not a finding.
doc-rubric. Four rubrics: SPEC (SPEC.md, UX.md), ARCHITECTURE, EPICS & STORIES, CONTRACTS. It judges substance, not formatting (for example: does every cross-lane seam have an owner?). It opens with ready, ready with fixes or not ready, then lines tagged blocker/high/medium/low. lean-intent, lean-architecture and lean-plan also run it, scaled to stakes.
- A reviewer gets its lens file, the content path, optional
also_considerareas and the paths of the recorded decisions (SPEC Assumptions and Decision Log, epic and story decisions), which it must not re-argue as preferences. Story lines tagged[ASSUMPTION]are open to challenge, and a decision that produces a concrete wrong result is reported asdecision-conflict:with the input and the wrong output. It never sees the build conversation, the implementer's report or other reviewers' findings. Edge-case also gets the claims path, unread until its instructions call for it. - All lenses launch in one turn. Triage starts only after all have reported.
- Reviewers' severity labels are ignored: they lack the context to grade. A cheaper tier works because the orchestrator verifies each finding (tiers).
- No subagents:
lean-reviewruns the lenses one after another in one session.lean-buildwrites the prompts toplan/adhoc/review-prompts/and halts so you can run them in separate sessions.
- Build: the spec has
security: true(set in planning when the story touches auth, personal data, money, secrets, external input, files, shell or query construction), or the diff crosses a trust boundary. On a feature review, any story of the epic withsecurity: trueis enough; an earlier story of a multi-story epic gets this lens alone, on its own diff. - Standalone: the diff touches one of those. Never on documents.
A finding without evidence is a hunch, and a hunch costs the judge a check.
- Code findings cite
file:lineand the input or state that triggers the problem. Document findings cite the section and the downstream decision it breaks. - Adversarial may add at most 3
Unverified hunches; the judge may ignore them. Verification-gap must read a test before saying what it covers. - Each log row carries evidence in one or two sentences.
falsesays what disproves the claim.maybe-falsesays what would settle it.
Triage is the orchestrator's job, never a worker's. Settled decisions first. A decision is settled when a human has seen it: the SPEC's Assumptions and Decision Log, the epic's decisions, a story's frozen block. Not settled: the [ASSUMPTION] lines of a story frozen with approved_via: plan, which the orchestrator wrote during the build and no human saw (Frozen Intent and Guards).
- A finding that only re-argues a settled decision takes verdict
false, routereject, evidencedecided: <where it is recorded>, with no code reading. - A
decision-conflict:finding, or one that names a concrete bad outcome the record does not mention: verify it like any other; if it is real, route itintent_gap, because the decision may be what is wrong. - A finding against an unsettled
[ASSUMPTION]line: verify it on the merits; if it is real, routeamend(the orchestrator corrects its own line and freezes again) orbad_specwhen the approach rests on it.
For every other finding:
- Check the claim. Open the location and read past the changed lines (callers, upstream guards) until you know whether the bad outcome happens. Code that fails loudly on a state nobody showed to be reachable is correct.
- Give one verdict.
| Verdict | Meaning |
|---|---|
high / medium / low
|
Real. Graded by harm to users or developers; unsure means the higher grade. |
false |
Checked; it does not happen. |
maybe-false |
Code and diff cannot settle it. |
-
Reject
falsefindings, rarelowfindings whose fix adds complexity, findings whose only fix edits the build spec, and out-of-scope findings only when the intent excludes them. - Group by shared root cause (same file or same fix is not enough). A group takes its worst verdict.
Verification-gap findings are trusted as filed only when that reviewer ran at the top tier; otherwise they are re-verified. over-engineering: findings are patch unless removal changes behavior the spec asks for. On a loopback, a finding that matches an existing row (same location, same claim) is marked carried and not redone.
| Route | Use when | Build does |
|---|---|---|
intent_gap |
The frozen intent is incomplete; the spec cannot settle it. | Revert code, ask the human, renegotiate the frozen block, re-plan. |
bad_spec |
The spec's approach was wrong; patching leaves incoherent code. | Write KEEP notes, revert, amend non-frozen sections, re-implement (one tier up on the first loopback). |
amend |
The spec missed a case or rule; the approach holds. | Log it, add the rule, patch the code. No revert. |
patch |
Trivial fix, no new public surface, no spec change. | One message to the implementer, then re-verify. |
defer |
Not this change's problem: pre-existing, serious but unverified, or fixable only in an agent-context file. | Append to deferred.md. |
reject |
Filtered out by the rules above. | Logged, nothing else. |
Tie-breaks: ask "if I add this to the spec, does the existing code keep the right shape?" Yes is amend, no is bad_spec. Torn between patch and a spec route: take the spec route. Torn between amend and bad_spec: take amend, unless two or more findings share one approach-level cause. An all-maybe-false group is deferred only if it would be medium or high if true; if only low, reject.
Deferred entries (source, summary, evidence) are append-only and never deduplicated. A summary starts with agent-context: when the fix would edit CLAUDE.md, AGENTS.md or rules; lean-change retro turns those into proposed pitfalls.
- Order:
intent_gapandbad_specfirst, thenamend, thenpatch. Patches wait until no loopback is pending. - Each loopback increments
review_loopsin the spec. Past 3, build halts and escalates to the human.amendandpatchdo not count. -
--auto: a halt becomesstatus: blockedplusblocked_reason. - Small route has no spec to loop through:
intent_gaporbad_spechalts and asks;amendswitches the story toroute: full. - Worker tier escalation is in Orchestrator and Cost Tiers.
Every finding is one row of ## Review Triage Log in the story spec. Never drop or merge a row. lens is the reviewer's lens name; verdict is one of the five above; route is one of patch | amend | bad_spec | intent_gap | defer | reject.
| # | lens | verdict | route | evidence |
|---|---|---|---|---|
| 1 | adversarial | false | reject | `parse()` runs only after `validate()` rejects empty input (`api.ts:41`). |
| 2 | edge-case | high | patch | `limit=0` returns every row; no guard at `list.ts:18`. |
| 3 | verification-gap | medium | amend | Spec has no row for expired tokens; no test hits `auth.ts:77`. |
| 4 | security | medium | bad_spec | `search.ts:30` builds SQL by concatenation; the spec chose raw queries. |
| 5 | adversarial | maybe-false | defer | Cache refill may race; medium if real. A concurrent-load run would settle it. |(Illustrative.)
node _lean/bin/lean.js metrics [--epic E1] [--json]- It counts log rows, never numbers the agent wrote about itself. Only
donestories count. - A verdict or route outside the vocabulary is counted as
unparsedorother. - It reports findings by verdict, routes taken, false rate, and findings and false rate per lens and per reviewer model (
metrics.models.reviewin the spec frontmatter), plus loops and escalations. For the log above: 5 findings, 20% false,adversarial50% false. That shows whether a cheaper reviewer tier is noisy. -
checkwarns, without failing, onstory/no-triage-log(a story with aroutethat isin-reviewordonebut has no log) andstory/triage-vocab(verdict or route outside the vocabulary).
- lean-review: run a review on a diff, branch or planning doc.
- lean-build: where the lenses run per story and routes are acted on.
-
Frozen Intent and Guards: why
intent_gapreopens the frozen block. - Orchestrator and Cost Tiers: reviewer tiers and escalation.
-
CLI Plan Tooling:
checkandmetricsin full.
LEAN 0.10.2 · Repository