Plan: a hard tier for the reviewer and planning battery - Rust-first, cross-file, with decoys and thinking levels
Closes: #429. Branch: test/reviewer-hard-tier, one MR per unit below (U1 lands before any case, so a case’s honesty tests exist when the case does). Status: Done (2026-10-24) — fill, calibration and docs landed; the per-role reading is on #429
Erratum (2026-10-24): U1 also edits cases/make-cases.py, which generates the nine stamped keys, so a regeneration keeps tier, source and decoys; and decoys is required like tier (the existing keys carry []), not defaulted.
Erratum (2026-10-24): store/reviewer/ and store/planning/ are removed in U1, not U4: every battery run re-summarises the store, and the aggregate reads byTier and falseFlags from every record, so an old record would end the next run of any task. The committed page and summary.json are left as they are until U5 renders.
Erratum (2026-10-24): the driver keeps stageCase for its own run (its snapshot reads the staged repository during the call); caseDiff wraps it for the honesty tests, so both read the same staged diff. The Rust trees build with one target directory each: before/ and after/ share a package name, and one shared directory reused the other tree’s build.
Erratum (2026-10-24): the second calibration source is cases/calibration/2026-10.json, read by calibrateStored() beside calibrate(): under cases/reviewer/ the driver and the honesty suite would read the directory as a case.
Erratum (2026-10-24): tuning anchors after the fill needs the stored scores recomputed, so U5 adds battery rescore (review tasks only; it re-scores a record from its output against the current key and leaves the measurement as recorded).
Erratum (2026-10-24): the hand scores were made by independent readers (a fresh model per two cases, given each defect’s description and never its anchors), every reader/scorer disagreement adjudicated by hand; a held-out sample of three more subjects, scored the same way after the tuning, measures the scorer’s error out of sample.
Erratum (2026-10-24): seven errors --retry-errors does not match (5xx, fetch failures and fetch header timeouts) were removed by hand and gap-filled; #430 widens the match.
TL;DR
| Today | After |
|---|---|
8 commit cases, 1 module + test each, 3-8 KB; 29 defects, all in the diff; 1 control |
+10 commit cases (8 Rust, 2 TS), 6-15 files each, diffs over 3-6 files; 2-4 defects a case, at least one cross-file and one buried; 1-2 decoys a case |
1 plan case, 7 defects, no control |
+3 plan cases and 1 plan control over Rust context trees of 8-10 files |
Recall pooled over every defect; false flags counted on the control only |
Recall per tier (surface, cross-file, buried); false flags counted on decoys too, every case |
Matrix: reviewer fit = recall ≥ 0.9 |
fit = recall ≥ 0.9 and cross-file recall ≥ 0.8 and false flags ≤ 3; usable = 0.75 / 0.5 / ≤ 6 |
The driver sends no thinking level; production sends |
The driver sends what production sends; an experiment arm beside each table: the Claudes and Argon at low and high, Sonnet 5.5 and 3.8 Flash at high |
2 runs a case |
3 runs a case, both tasks (top-of-field gaps are 1-3 defects) |
Cost: the first fill is projected at US$150-250 (larger subjects, three runs, nine thinking arms). battery fill --budget 0 prints the exact figure before any call; the operator decides.
Design
What the hard tier measures that the current corpus cannot
The three strongest models miss one defect between them, a non-blocking biome-ignore (store/reviewer/none//config-loader-.json). Production hands the reviewer three read-only tools over the staged index (packages/pi-workflow/review-snapshot.ts: 12 calls, 200 KB), and J3 asks whether consumers were updated; no case today needs a read. A review that flags everything scores perfectly on recall and shows one number on one control. The plan task has 14 chances a model, so 13 against 12 is one defect.
A hard-tier case therefore has, by construction:
-
a cross-file defect: invisible in the diff; a caller, consumer or invariant elsewhere in the tree breaks, found only by
read_fileorgrep(the key names the evidence file, and a test proves it is not in the diff); -
a buried defect: one to three lines inside a legitimate change of at least 150 changed lines (a test counts them);
-
one or two decoys: a hunk that looks wrong and is right, with the reason in a file outside the diff (a test proves that too). A FAIL block that names a decoy is a false flag;
-
tests that pass against the case’s own code, before and after (the existing rule; for Rust,
cargo testruns in the honesty suite).
The corpus
Rust is the agency’s main language, so eight of the ten commit cases are Rust and all four plan cases are plans over Rust trees. Two TypeScript cases stay, because the reviewer reads this repository daily and a reviewer strong in one language and weak in another is worth seeing. Rust crates are std-only (no [dependencies]): the honesty suite runs cargo test --offline on each tree and a registry fetch would make it network-dependent and slow. Wire formats are hand-rolled (line protocols, manual JSON builders), which many agency tools have.
Defect classes come from this repository’s own fix history, not from what an author knows to plant; each defect’s key cites its source. The ten cases, each a crate (or a two-crate workspace where the consumer is the second crate):
| Case | Shape of the change | Planted (tier) and decoys |
|---|---|---|
|
|
|
|
A file-backed queue gains a lock file and a sweep of stale locks |
The pid check treats a child’s pid as the owner’s (cross-file: the spawner in |
|
A deny-list of paths gains glob support |
Patterns anchored at both ends miss a relative or |
|
|
|
|
An HMAC check moves to a shared helper |
Constant-time compare kept, but an early return on length leaks it (surface, J4); the new helper is used by one of two callers; the other, in |
|
A parser’s hot loop takes |
The comment says callers pass validated offsets; |
|
A new |
The dispatcher in |
|
Retries gain a per-process budget and jitter |
The budget is a |
|
The event envelope’s |
|
|
An extension’s session state is restructured |
Looks like state outlives the session (module-level |
The existing eight cases stay as they are: their defects are all tier surface by definition, their keys are not edited, and their records are kept (the fingerprint is provenance, not a to-do).
Plan cases, each a plan.adoc over a context/ Rust tree of 8-10 files and an AGENTS.md:
-
plan-rs-helper-claim: the plan says "reusecore::parse_layer, which merges"; the tree’sparse_layerparses one layer and the merge is elsewhere (P2); step 4 consumes a file step 2 never writes (P2); a compatibility re-export "until callers move" (P3). -
plan-rs-conventions: Status outside the vocabulary;Closestwo issues; a squash merge named as the landing; a crate path that does not exist in the tree (P1 ×3, P2). -
plan-rs-decoy: an unusual step (vendoring a module instead of depending on it) justified in the tree’sDESIGN.md; one real P2 (an undefined trait method named as "existing"). -
plan-rs-control: a correct plan. The planning task has no control today.
Keys, scorer, aggregate, page, matrix
key.json (tools/model-battery/cases/{reviewer,planning}/<case>/key.json) gains, per defect, a required tier: "surface" | "cross-file" | "buried", source (an issue reference or a class name), and for a cross-file defect evidence: [paths] outside the diff; and a top-level decoys: [{ id, what, justification: path, anchors }] (default []) with the same anchor shape as a defect. The nine existing keys are stamped tier: "surface" and source in U1 (a key edit changes the case’s digest, which is provenance only). No optional-with-default: the format has never shipped.
scorers/anchors.mjs: scoreReview adds byTier: { surface: {planted, caught}, "cross-file": {…}, buried: {…} }, moves a FAIL block that names a decoy from extras to falseFlags (today falseFlags is set only on a control; it becomes the count of decoy hits plus, on a control, every FAIL), and keeps extras for blocks naming neither. FILE_REF (line 127) gains rs and toml: today a review’s main.rs:14 is not a file reference, so no Rust line anchor could ever be cited. aggregate adds recallCrossFile, recallBuried (pooled, as recall is) and sums falseFlags over every record. No record without byTier survives: every reviewer and planning record is remade (below), so the aggregate carries no fallback.
render.mjs: the reviewer and planning columns gain Cross-file recall and Buried recall; False flags (control) becomes False flags (control + decoys); the preamble under "How to read it" (page-head.adoc) explains the tiers and decoys in one paragraph each.
battery.json (in U4, with the manifest, so the rules never run over a store that lacks the metric): the reviewer role’s fit becomes { recall: 0.9, recallCrossFile: 0.8, falseFlagsMax: 3, integrity: 0.98 } and usable { recall: 0.75, recallCrossFile: 0.5, falseFlagsMax: 6, integrity: 0.98 }; planning the same without integrity. checkRule (render.mjs) already reads a …Max key as an upper bound, so falseFlagsMax needs no renderer change. These are starting thresholds, argued here: ten cross-file defects at three runs are 30 chances, and 0.8 forgives one miss in five; decoys give about 45 chances a model plus the controls, and three false flags over them is one in fifteen. A later change is an issue citing the page, as every threshold change has been.
The driver sends production’s level; the arm varies it
The battery’s drivers/review.mjs and tasks/reviewer.json say production sends no reasoning level and send none. That stopped being true at #192: packages/pi-workflow/reflection-review.ts sends wantedThinking(config.reviewThinking, session level) - the operator’s reviewThinking, else the session’s own level, else DEFAULT_REVIEW_THINKING = "medium" - clamped to the model by reviewerLevel. So the page’s "off requested; thinks at its own discretion" footnotes describe a configuration production never runs, and a session at high reviews at high.
U1 makes the driver’s production cell send what production sends with nothing configured: reviewerLevel(model, wantedThinking(undefined, undefined).wanted), imported from pi-workflow, never copied, logged in the record’s effective.thinking as today. A subject’s knob still overrides, as it does for every task. The existing reviewer and planning records were measured under the old contract and are no longer production cells: U4 removes store/reviewer/ and store/planning/ (git history keeps them; the eight old cases are remade in the fill at about US$10 over every model), and the fingerprint’s promptSha gains the level source so a later change here reads as one.
Whether a level above or below medium helps, and what it costs, decides production’s configuration, so the arm runs both tasks over the whole corpus:
| Subject | Levels | Why |
|---|---|---|
|
|
the shipped reviewer, either side of |
|
|
the next Claude down |
|
|
the reviewer floor: does thinking lift it |
|
|
the strongest non-Claude, either side of |
|
|
the cheap option |
Two manifest entries (task: reviewer and task: planning, runs: 3, the nine subjects listed). A knobbed subject is an experiment by the renderer’s rule (isProduction: no knobs), so each lands in the task’s experiments table beside the production cells, with wall and cost columns; the matrix does not read it. Grok 4.7 has no arm: it exposes no reasoning block, so pi sends it no level (packages/pi-vertex/models.json, reasoning: false); whether Vertex honours reasoning_effort for it is a pi-vertex question, out of scope.
A production change that follows from the arm - another DEFAULT_REVIEW_THINKING, a level per model, or no longer following the session’s level - is its own issue citing the page.
Honesty tests and calibration
A new tools/model-battery/test/cases.test.mjs, run by task test:
-
every defect has at least one anchor; every
tieris one of the three; a cross-file defect’sevidencepaths exist inafter/and none appears in the case’s diff; a buried defect’s case diff has ≥ 150 changed lines; a decoy’sjustificationexists and is not in the diff. The diff is the driver’s own:stageCaseis module-private today, so U2 exports acaseDiff(caseDir)fromdrivers/review.mjsthat stages and disposes, and both the driver and the test call it; -
for each Rust case,
cargo test --offline --quietpasses inbefore/and inafter/(describe.skipIfwhencargois not on the path, with the reason; a sharedCARGO_TARGET_DIRunder~/.cache/gadhs-battery/so the suite costs seconds after the first run); for each TS case, the existing rule holds the same way withvitest; -
a plan case’s context tree holds every path its key’s anchors name.
Calibration keeps the existing discipline (cases/reviewer/CALIBRATION.md, pinned by test/score.test.mjs) and gains a second source. calibrate() in anchors.mjs is hard-wired to tools/reviewer-eval/results/2026-09-07T15-55-01/ and its HAND_MODEL_DIRS; it stays for that run. A new cases/reviewer/calibration/2026-11/scores.json names store records by (task, subject, case, run) and gives the hand verdict per defect and decoy; calibrate() reads each named record’s output from the committed store and scores it against the current key, so the second source needs no copied reviews. After the first fill, the reviews of three subjects over the new cases (Fable and Argon at their production cells, 3.8 Flash) are hand-scored by the rule "a defect is caught when a FAIL block names it; a decoy is flagged when a FAIL block names it", the anchors are tuned until the remaining disagreements are explainable, CALIBRATION.md’s new section records them, and score.test.mjs pins the second source’s bound beside the first. Anchors are written before any model sees a case; tuning afterwards is the calibration, as it was in 2026-09-07.
What the first fill answers
For each model, on the page: recall overall and per tier, false flags, cost and wall per review, at production’s level and at the arm’s. The questions the operator can then settle, each as its own issue: which model is the reviewer and at what level; whether the floor (REVIEW_FLOOR) and TIERS in reflection-review.ts should move; whether #70’s second-vendor plan review is Argon. This plan changes no default and no production code.
Risks
| Risk | Direction | Mitigation |
|---|---|---|
Removing the reviewer and planning records loses their numbers |
Fail-safe |
git history keeps them; the page’s old reviewer tables are in the previous rendered page; the fill remakes the eight cases first (they are cheap) so the page is never empty for the role |
Between U1 and U5 the matrix reads every reviewer cell as |
Silent |
The thresholds land in U4 with the manifest, and the page is rendered only in U5 after the fill; the committed page does not change until then |
|
Visible skip |
|
Anthropic’s usage policy refuses a security-shaped case ( |
Visible |
Cases are plainly defensive code with no attack tooling; a refusal records |
The top models still saturate the hard tier |
Visible |
Per-tier recall and the spread show it; the next set is the 200 KB tier under "Out of scope" |
Cost runs past the projection |
Fail-closed |
|
Units
| Unit | Work | Files |
|---|---|---|
U1 scorer, driver, page |
Key fields ( |
|
U2 commit cases |
The ten cases above as plain |
|
U3 plan cases |
The four plan cases with |
|
U4 manifest, matrix, store |
|
|
U5 fill, calibration, docs |
|
|
U1 first; U2 and U3 may land in either order after it; U4 after U2 and U3 (the thresholds and the store removal belong with the cases they measure); U5 last. Each unit is one MR, reviewed as any commit; the case trees carry planted defects on purpose, as the existing ones do (biome.json already ignores tools/model-battery/cases), and each MR’s commit message says so.
Out of scope
-
Changing the reviewer, the floor,
TIERS, or the level production sends: issues after the fill, citing the page. -
A Grok 4.7 thinking arm (needs a pi-vertex answer on
reasoning_effortfirst). -
Measuring the session-level source: the arm varies the level directly; whether production should keep following the session’s level is argued from the arm’s numbers.
-
Regenerating or re-tiering the eight existing cases.
-
A fourth tier for subjects at production’s 200 KB ceiling: the hard tier’s subjects are 20-80 KB; the ceiling is a later case set if these separate the field.
Acceptance
-
task testgreen with the honesty suite running (cargo present) and the calibration bound extended. -
model-battery.adoc shows per-tier recall, false flags including decoys, and an experiments table under reviewer and planning with the nine arms.
-
Every shipped default’s cell is re-derived under the new rules and the page says what it reads; no default is changed by this plan.