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 medium unless the operator or the session says otherwise (reflection-review.ts wantedThinking), so no reviewer cell is a production cell

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_file or grep (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 test runs 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

rs-config-merge (workspace: core, cli)

core gains layered config; cli reads it

parse returns Default on a malformed layer instead of Err (buried; fail-open, 418); cli/src/main.rs still reads a field the merge renamed (cross-file, J3); a [allow(unused_must_use)] on the write (surface, J7). Decoy: a pub → pub(crate) the workspace’s only user is inside

rs-ingest-lock (single crate)

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 worker.rs, #424); the lock is released before the index write it guards (buried, J3); the stale sweep’s "stale" reads a count anywhere in the lock text instead of its first line (surface, #422). Decoy: a Drop impl that ignores an io::Error, justified in DESIGN.md

rs-path-rules (single crate)

A deny-list of paths gains glob support

Patterns anchored at both ends miss a relative or ~ form (surface, #415); the check is applied on the read path and not the new write path (cross-file: write.rs is not in the diff, #414); a test for the tilde form is renamed and its assertion weakened in the same hunk (buried, J2). Decoy: an unanchored pattern in tests/fixtures/, explained there

rs-wire-v2 (workspace: proto, agent)

proto adds a version field and renames ts to sent_at

agent/src/report.rs builds the old field name by hand (cross-file, J3); the version check uses >= where the comment says exact (surface, J5); an error on a short frame is mapped to an empty frame (buried, J3). Decoy: the reader accepting both names during the change, per proto/COMPAT.md

rs-token-compare (single crate)

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 admin.rs, still uses == (cross-file, J4); the "rejects a truncated token" test is deleted inside a module move (buried, J2). Decoy: a #[cfg(test)] helper that prints the token, test-only

rs-unsafe-bounds (single crate)

A parser’s hot loop takes get_unchecked under a safety comment

The comment says callers pass validated offsets; scan.rs (not in the diff) passes an offset it computed with a + 1 past the end (cross-file, J5 and memory safety); a u64 byte count cast as u32 (buried, J3); a loop bound off by one at the final chunk (surface, J3). Decoy: a debug_assert! where a release-mode check looks missing, justified by the caller’s validation in lib.rs

rs-cli-capability (single crate)

A new export subcommand is added

The dispatcher in main.rs runs the new arm before the capability check the others go through (surface, J4); the new arm’s writer takes a path from the argument unsanitised where the others call safe_path in fs.rs (cross-file, J4); the help text claims --dry-run is honoured and the arm ignores it (buried, J5). Decoy: a capability name string that differs from the enum variant, mapped in caps.rs

rs-retry-budget (single crate)

Retries gain a per-process budget and jitter

The budget is a static per process but the doc and callers treat it per client (cross-file: client.rs constructs several, J3); ? replaced by .ok() on the budget persist (buried; swallowed error); jitter applied to the exponent (surface, the existing retry class). Decoy: a thread_local! that looks like per-thread state and is correct, per the comment in budget.rs

ts-event-schema (workspace: schema, consumer)

The event envelope’s kind becomes an enum string and gains v

consumer/src/route.ts switches on the old string values (cross-file, J3); a parser throws on unknown v where the message says it ignores (surface, J5); a test’s expected list is edited to match the new wrong output (buried, J1). Decoy: a Record<string, unknown> at the boundary, parsed two lines later

ts-session-reset (single package)

An extension’s session state is restructured

Looks like state outlives the session (module-level Map) - the decoy, justified by the factory in index.ts (the #416 finding, which was false); the real defects: a listener registered twice across session_start (cross-file: the second registration is in hooks.ts, J3); the clear() added to one of two caches (surface, J3); a --no-verify-shaped test skip (it.skip) inside a rename hunk (buried, J2)

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 "reuse core::parse_layer, which merges"; the tree’s parse_layer parses 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; Closes two 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’s DESIGN.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

vertex-anthropic/claude-fable-5-1

low, high

the shipped reviewer, either side of medium

vertex-anthropic/claude-opus-5-5

low, high

the next Claude down

vertex-anthropic/claude-sonnet-5-5

high

the reviewer floor: does thinking lift it

vertex-gemini/gemini-4-argon

low, high

the strongest non-Claude, either side of medium

vertex-gemini/gemini-3.8-flash

high

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 tier is one of the three; a cross-file defect’s evidence paths exist in after/ and none appears in the case’s diff; a buried defect’s case diff has ≥ 150 changed lines; a decoy’s justification exists and is not in the diff. The diff is the driver’s own: stageCase is module-private today, so U2 exports a caseDiff(caseDir) from drivers/review.mjs that stages and disposes, and both the driver and the test call it;

  • for each Rust case, cargo test --offline --quiet passes in before/ and in after/ (describe.skipIf when cargo is not on the path, with the reason; a shared CARGO_TARGET_DIR under ~/.cache/gadhs-battery/ so the suite costs seconds after the first run); for each TS case, the existing rule holds the same way with vitest;

  • 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 no (a missing recallCrossFile fails checkRule)

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

cargo absent on a box or in CI

Visible skip

describe.skipIf(cargoMissing) with the reason in the title; CI’s image is checked for cargo in U2, and the MR says whether the suite ran there

Anthropic’s usage policy refuses a security-shaped case (rs-token-compare, rs-cli-capability), as it refused judge cases on 2026-10-23

Visible

Cases are plainly defensive code with no attack tooling; a refusal records stopReason: error, scores every defect missed, and shows in the Errors column, never as a silent pass

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

fill --budget refuses before any call; the operator sets it from `--budget 0’s projection

Units

Unit Work Files

U1 scorer, driver, page

Key fields (tier required, source, evidence, decoys) and the nine existing keys stamped; scoreReview by tier and decoy false flags; FILE_REF with rs and toml; aggregate; the driver sends production’s level and its stale comments go; the two new columns and the renamed one; page-head prose; unit tests for each (a key with decoys, a Rust file reference, the driver’s level from a scripted call)

tools/model-battery/scorers/anchors.mjs, drivers/review.mjs, tasks/reviewer.json, tasks/planning.json, render.mjs, page-head.adoc, cases/{reviewer,planning}/*/key.json, test/score.test.mjs, test/render.test.mjs, test/review-driver.test.mjs

U2 commit cases

The ten cases above as plain before/ and after/ trees with message.txt and key.json (no generator: cases/make-cases.py keeps owning the eight it made); caseDiff exported from the driver; test/cases.test.mjs

tools/model-battery/cases/reviewer/<ten dirs>/, drivers/review.mjs, tools/model-battery/test/cases.test.mjs

U3 plan cases

The four plan cases with plan.adoc, context/, key.json; the plan arm of cases.test.mjs

tools/model-battery/cases/planning/<four dirs>/

U4 manifest, matrix, store

runs: 3 on the reviewer and planning entries; the two thinking-arm entries; the matrix thresholds, with a render test of a cell at each verdict under them; typicalTokens on both task files raised to what the new subjects measure (the budget projection reads it); store/reviewer/ and store/planning/ removed

tools/model-battery/battery.json, tasks/reviewer.json, tasks/planning.json, test/render.test.mjs, store/

U5 fill, calibration, docs

battery fill --budget 0 and the operator’s go; the fill, --retry-errors --jobs 1; hand-scoring, the second calibration source and CALIBRATION.md; summarise, render; local-dev.adoc’s battery section (tiers, decoys, the arm, the level the driver sends, the cargo check); reviewer-eval.adoc’s "Limits" pointing here; CHANGELOG == Unreleased

cases/reviewer/CALIBRATION.md, cases/reviewer/calibration/2026-11/scores.json, scorers/anchors.mjs, test/score.test.mjs, docs/modules/ROOT/pages/{model-battery,local-dev,reviewer-eval}.adoc, CHANGELOG.adoc, the store

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_effort first).

  • 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 test green 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.

Edit this page · latest