Plan: plan-review cases at production scale, with two known-bad arms that prove they bite

Closes: #999. Relates to: #996, #911, #886, #878, #86. Branches: test/battery-plan-deep, test/battery-plan-deep-cases, test/battery-plan-deep-records. Status: Done (2026-12-01) — 120 records across all three arms ($94.00 actual); full D9 scorecard reported on #999 and #996

Erratum (2026-12-01): after the 20-call D9 pilot (claude-fable-5-2 23/24 recall, gemini-4-carbon 22/24, both fp=1 on ruff/config-option), fixed four real defects in control ruff/config-option and executed D9’s single hardening round across the five cases both subjects caught 3/3 (pi/config-unknown-keys, pi/memory-pool-key, pi/phone-shell-escape, pi/ssh-host-down, ruff/server-republish-scope), shifting corpus reach from 4/4/8/8 to 1/2/3/18 (surface/supplied/held-back/unnamed) and reducing the inherently plan-only class "two sections that contradict each other more than 60 lines apart" from 2 instances to 1 (the other seven D8.3 classes remain at ≥ 2 instances each).

Context

#996 fixed two regressions found in production’s own records, not by the battery: round two anchored on round one’s review (Carbon’s catches on plans round one called CLEAN fell from 10 of 13 to 1 of 17), and the 12-call read budget starved reviewers (42 % of 194 plan reviews hit it). The operator’s ruling (2026-12-01): the test plans must be complex enough to test these limits. Approach agreed in conversation the same day: real pinned repositories, and the old round-two arm replaced by two known-bad arms on the new cases. What the tree says, by reading:

  • Every plan case (tools/model-battery/cases/planning, planning-hard, planning-round-two) is 44 to 77 lines over a context/ tree of at most 16 files and 10.7 KB: the whole tree is smaller than the 80 KB cap on one read result.

  • The review driver (tools/model-battery/drivers/review.mjs, subjectFor) hands a plan case every key.context file. Production instead resolves the plan’s reviewPaths with resolvePlanContext (packages/pi-workflow/review-context.ts): at most 12 files, 80 KB each, 200 KB in all, the rest listed as NOT SUPPLIED. No battery case has ever produced that list.

  • planning-hard and planning-round-two hold different cases, so no pipeline setting was ever measured against another on the same plans; all six earlier-review.txt files say VERDICT: FLAGS.

  • Production no longer sends an earlier review (#996), yet packages/pi-workflow/plan-review.ts still carries EarlierReview, EARLIER_REVIEW_FRAMING, renderEarlier and the second parameter of planReviewSystemPrompt, used only by the battery’s "round": 2 task.

  • The explore task already pins real repositories (tools/model-battery/lib/corpora.mjs): this repository as a detached worktree of a commit (checkoutFor), and ruff 0.16.6 as a shallow clone under ~/.cache/gadhs-battery/repos/ruff (11,108 files, 1,983 of them Rust). CI clones with full history (GIT_DEPTH: "0"), so a pin of this repository is checkable there; a ruff check skips visibly when the clone is absent (tools/model-battery/test/explore.test.mjs).

  • The battery’s review call has no wall-time bound (callModel, tools/model-battery/lib/catalog.mjs); production ends a review at reviewTimeoutMs, 600 s.

Design

D1. Two pinned corpora, nothing large committed

tools/model-battery/cases/planning-deep/ holds one directory per corpus, each with a pin.json in the form cases/explore/*/pin.json has:

  • pi/pin.json: { "name": "pi", "commit": "24843db472254cd340c976bc5ec70e93b37d36bc" } (v0.190.0), no repo.

  • ruff/pin.json: the name, repo (url, tag 0.16.6) and commit of cases/explore/ruff/pin.json, so both tasks share one clone.

A case is a directory under its corpus (pi/<case>/), named <corpus>/<case>, holding plan.adoc, key.json and round-one-clean.txt. The reviewer’s tree is the corpus checkout: checkoutFor(corpus).

D2. The driver sends a deep case as production sends a plan

New tools/model-battery/lib/plan-corpus.mjs:

  • planCorpusCases(casesDir, { provision, cache }): for each corpus of loadCorpora(casesDir), each subdirectory holding a key.json is a case { name, dir, key, sha: treeDigest(dir), pin: pin.commit, corpus }, corpus carrying cache when one is given. When the corpus’s git directory is present (this repository always; a foreign clone when it exists, or after cloning when provision is true) it calls checkPlanCorpus; when a foreign clone is absent and provision is false, the cases are listed unchecked.

  • checkPlanCorpus(cases, gitDir): for every case, every reviewPaths path (its :START-END suffix removed) and every proof and claims path exists at the pin; every has literal occurs in git show <pin>:<path> and no lacks literal does. It throws naming the case and the entry. It is synchronous (git plumbing through execFileSync), because cases() is read synchronously by tools/model-battery/cli.mjs and tools/model-battery/lib/run.mjs, and stays so.

  • suppliedFor(kase, cwd), async: resolvePlanContext(localWorkspace(cwd), key.reviewPaths, cwd, contextLimits(DEFAULT_WORKFLOW_CONFIG)), imported from pi-workflow; a non-empty problems throws.

  • reachProblems(kase, context), pure: each defect’s reach derived from that answer (D3), and every one that differs from the key’s, named.

  • declaredTree(kase, gitDir): a temporary directory holding only the case’s declared files (git archive <pin> — <paths>). resolvePlanContext reads there the same files it would read in the full checkout, so the corpus test derives reach for pi without a worktree.

In corpora.mjs, checkoutFor(corpus, cache = REPO_CACHE) gains the optional cache, passes it to corpusGitDir, and keys its memo on the corpus’s name, its pinned commit and the cache (checkoutKey(corpus, cache), exported). Today the key is the name alone: cases/explore/pi/pin.json pins pi at 003d8cb and D1 pins it at 24843db, and runners/agent-loop.mjs calls the same function, so one process running both tasks would hand the second the first one’s worktree. In drivers/review.mjs:

  • cases(casesDir, spec, options): isCorpora(casesDir) gives planCorpusCases(casesDir, options); loadTask (tools/model-battery/lib/task.mjs) passes { provision }. battery rescore (tools/model-battery/cli.mjs) loads its tasks with provision: false.

  • subjectFor, for a case with a corpus: the tree is checkoutFor(kase.corpus, kase.corpus.cache); files and notSupplied come from suppliedFor and go to buildPlanReviewPrompt as plan-pause.ts passes them (notSupplied only when non-empty); a non-empty reachProblems over the same answer throws before the case’s call; the snapshot is createSnapshot(localWorkspace(cwd), cwd, "disk", budget); dispose does nothing.

  • The budget is snapshotBudget(DEFAULT_WORKFLOW_CONFIG, "plan"), its maxCalls and maxBytes replaced by the task’s snapshotBudget when the spec has one.

  • The lane’s recorded snapshot gains maxCalls and maxBytes.

  • MODULE_URLS gains packages/pi-workflow/review-context.ts.

checkSpec accepts "snapshotBudget": { "maxCalls": n, "maxBytes": n } (two positive integers) and "earlier": { "reviewer": "…​", "file": "…​" } (two non-empty strings), each on a review task only. round and the key-level earlier go (D5).

D3. A case’s key

As cases/planning-hard/hard-requeue/key.json, with these differences:

  • reviewPaths replaces context: every file the plan names, in the order the plan first names it; an entry may be path:START-END.

  • A defect carries reach and, unless its reach is surface, proof: a list of { "path", "has" } or { "path", "lacks" }. Its tier is surface for reach surface and cross-file otherwise, so the existing columns still read it.

  • Reach is what the reviewer must do to see the defect, derived from production’s own answer at the pin. A proof is settled by the supplied text when a supplied file of that path contains its has literal, or is the whole file for a lacks. surface: no proof, the plan contradicts itself. supplied: every proof is settled by the supplied text. unnamed: some proof’s path is not in reviewPaths and does not occur in plan.adoc. held-back: anything else.

  • A decoy carries justification (a path at the pin) and a proof.

  • A control (no defects) carries claims: at least ten { "path", "has" }, one for each seam its plan describes.

D4. The ten cases

Each plan proposes work that is not done at its pin. "Home" files exist at the pin and are where the case’s plan says its change lands; this plan edits none of them. S, Su, H, U are the planted defects by reach (surface, supplied, held-back, unnamed).

Case The plan proposes Home files S Su H U Decoys

pi/memory-pool-key

one memory pool for a project however it was cloned

packages/pi-modes/memory.ts (computeScopeKeys, repoKeyOf), memory-wiring.ts, memory-remote.ts

0

1

1

1

1

pi/ssh-host-down

/ssh tells a host that is down from a name that does not resolve

packages/pi-ssh/connection.ts, session-live.ts, commands.ts, test/resilience.test.ts

1

0

1

1

1

pi/prepush-pushed-commits

the pre-push hook checks the commits pushed, not the working tree

.githooks/pre-push, tools/task.mjs

0

1

1

1

0

pi/config-unknown-keys

the modes overlay refuses an unknown top-level key by name

packages/pi-modes/config.ts, tools/lib/public-surface.mjs, docs/modules/ROOT/pages/public-surface.adoc

1

0

1

1

1

pi/plan-approval-record

several approved plans recorded per commit

packages/pi-modes/plan-tools.ts, plan-mode.ts, packages/pi-workflow/approved-plan.ts, commit-pause.ts

0

1

1

1

1

pi/phone-shell-escape

the paired phone’s ! escape: its bash and abort_bash commands are answered

packages/pi-remote/mirror.ts, wire.ts, index.ts

1

0

1

1

1

pi/ssh-resume-filter

a text filter and paging for the /ssh --resume picker

packages/pi-ssh/session-open.ts, commands.ts, anchor.ts

control

ruff/cache-retention

the lint cache’s 30-day retention (MAX_LAST_SEEN) becomes a setting

crates/ruff/src/cache.rs, crates/ruff_workspace/src/options.rs, configuration.rs, settings.rs

1

0

1

1

1

ruff/server-republish-scope

after a configuration file changes, the server republishes diagnostics only for documents under the reloaded roots

crates/ruff_server/src/server/api/notifications/did_change_watched_files.rs, crates/ruff_server/src/session/index.rs (reload_settings), crates/ruff_server/src/session.rs

0

1

1

1

0

ruff/config-option

a new top-level option, read through options, configuration and settings

crates/ruff_workspace/src/options.rs, configuration.rs, settings.rs

control

Totals: 24 scored defects (4 surface, 4 supplied, 8 held-back, 8 unnamed), 6 decoys, 2 controls.

D5. Three arms on the same cases

Task file (tools/model-battery/tasks/) What differs Subjects, 3 runs each Role

planning-deep.json

nothing: production’s caps and 48 calls, 800 KB

Fable 5.2, Carbon

the shipped pipeline

planning-deep-12.json

"snapshotBudget": { "maxCalls": 12, "maxBytes": 200000 }

Fable 5.2, Carbon

known bad: the budget before #996

planning-deep-anchored.json

"earlier": { "reviewer": "vertex-anthropic/claude-fable-5-2", "file": "round-one-clean.txt" }

Carbon

known bad: round two as 0.173.0 to 0.189.0 sent it

All three: "path": "single-call", "driver": "review", "cases": "cases/planning-deep", "scorer": "anchors", "experiment": "planning", "typicalTokens": 350000, and a // saying what the arm is. Subjects are bare refs (vertex-anthropic/claude-fable-5-2, vertex-gemini/gemini-4-carbon), so levelFor sends production’s plan levels. battery.json gains one permutation entry per task; RESCORABLE gains the three names.

Under earlier, every case must hold the named file, non-empty, or cases() refuses it by name; the system prompt is production’s with the frozen framing inserted, and the user prompt ends with the frozen rendering of the file (D6). promptText(spec) appends snapshotBudget=<calls>/<bytes> for a task with one, and for a task with earlier the framed system prompt and renderEarlier.toString().

planning-round-two is retired: its task file, its six case directories, its manifest entry and its RESCORABLE entry are deleted. Its records stay under tools/model-battery/store/planning-round-two, as verify’s did (#898). `planning and planning-hard are not changed.

D6. The earlier-review path leaves pi-workflow

packages/pi-workflow/plan-review.ts loses EarlierReview, PlanReviewInput.earlier, EARLIER_REVIEW_FRAMING, renderEarlier and the second parameter of planReviewSystemPrompt; buildPlanReviewPrompt and runPlanReview no longer mention them. The cold prompts do not change (pinned by digest in packages/pi-workflow/test/review-snapshot-loop.test.ts).

New tools/model-battery/lib/earlier-review.mjs holds what production sent from 0.173.0 to 0.189.0, word for word from plan-review.ts at v0.189.0: EARLIER_REVIEW_FRAMING, renderEarlier({ reviewer, text }), and withEarlierFraming(systemPrompt), which inserts the framing before the one occurrence of Answer each of P1-P4 and throws when there is not exactly one. Checked on 2026-12-01 against main: that insertion into planReviewSystemPrompt(budget) gives planReviewSystemPrompt(budget, true) character for character. MR 1’s test commit comes first and records, in its test, the sha256 of the framing as production’s round-two prompt holds it (the text that prompt has and the cold one lacks), while pi-workflow can still build it; the refactor commit then removes the parameter.

D7. Scoring by reach, the read budget, and the wall

tools/model-battery/scorers/anchors.mjs:

  • REACHES and reachCounts(key, caught), as positionCounts: scoreReview and erroredScore add byReach for a key whose defects carry reach.

  • aggregate pools byReach, and for records whose snapshot carries maxCalls adds hitCallCap (the share with snapshot.calls > snapshot.maxCalls: a call was refused), callsMedian, and overTimeout (the share whose wallMs exceeds DEFAULT_WORKFLOW_CONFIG.reviewTimeoutMs: production would have ended that review unreviewed).

tools/model-battery/render.mjs gains reachTable, placed after a role’s experiments table: one row per summary permutation of the role’s arms whose cell has byReach, with caught over planted per reach, hitCallCap, callsMedian and overTimeout. With no such cell it returns the empty string, so the page does not change until the arms are measured.

D8. Authoring rules

  1. Form. Each plan.adoc is written as this repository’s own plans are (header line, Context, a Design of numbered decisions, Scope, a Tests table, a Risks table with a Mode column, Delivery), in 180 to 280 lines, passes planShapeProblems (packages/pi-workflow/plan-shape.ts), and cites an issue number above #1200, so no real issue is cited.

  2. Size. It names 18 to 35 files that exist at the pin, all in reviewPaths; production’s caps at the pin hold at least six of them back.

  3. Planted. Each defect is one of these classes, named in its source, each class used at least twice: a caller or test the plan says does not exist; a signature, return or visibility misdescribed; two sections that contradict each other more than 60 lines apart; a step that needs what a later step builds; a behaviour the plan says is unchanged that its own change alters; a count the tree contradicts; a mechanism said to cover a case it does not; a cited test that asserts something else. A planted claim is written once, as the author’s plain statement. A decoy looks wrong and is right, for a reason in a file at the pin.

  4. Nothing else. A case plants what its key lists; every other seam the plan describes is as the tree has it. A control’s seams are its claims, so the check reads them.

  5. Round one’s review. round-one-clean.txt is in production’s answer form: VERDICT: CLEAN, P1 to P4 each PASS with a sentence, then the Beyond the declared context the reviewer read …​ line naming three to five files, none of them a proof path of that case.

  6. No preview. No plan with planted defects is shown to a model before the run. A helper may read a control’s plan against its pin and report contradictions, which are fixed before the case lands.

  7. cases/planning-deep/README.adoc says the plans misdescribe their trees on purpose.

D9. The run, and the rule that reads it

The run is the operator’s. First a pilot: node tools/task.mjs battery fill --task planning-deep --runs 1, 20 calls, after its --dry-run. It gives the measured cost per call, and stops the work when either subject catches 23 or more of the 24 defects: the cases are then hardened (below) before anything else is spent. Then the full fill of the three tasks, 150 calls less the pilot’s 20, projected from the pilot’s cost; by typicalTokens and the catalog’s rates it is about $620, over the battery’s $300 gate, so the operator names --budget. One --retry-errors --jobs 1 pass follows.

The rule, fixed here. Per subject, pooled over its three runs: R is recall over all defects; D is recall over held-back and unnamed defects; S is the highest per-run value minus the lowest, the larger of the two arms compared.

# The suite bites when

a

D on planning-deep-12 is below D on planning-deep by more than S for at least one subject, and at least half of that arm’s reviews hit the call cap

b

Carbon’s R on planning-deep-anchored is below its R on planning-deep by more than S

c

R on planning-deep is below 0.95 for both subjects

  • All hold: the result goes on the issue and the page; whether planning-deep becomes the planning role’s task, and any change to a budget or to reviewTimeoutMs (from overTimeout), are the operator’s decisions and their own issues.

  • a or c fails: one hardening round is in scope. Every case that all runs of both subjects caught whole on planning-deep is rewritten with its evidence in unnamed files, the arms are run again on those cases with the operator’s go, and the rule is read once more. A second failure is reported as the result.

  • b fails: anchoring did not reproduce on hand-written CLEAN reviews. That is a finding about #996’s cause, reported on #996 and on the issue, and not a reason to rewrite cases.

Scoring protocol. A prediction goes on the issue before the pilot. After each run every miss and every false flag is read. An anchor changes only to credit a FAIL block that plainly names the defect in other words, or to stop a decoy matching a block about a real defect; every change is applied to every subject by battery rescore and listed on the issue. A control that turns out to hold a real defect is reported with the result and stays as measured.

Scope

  1. MR 1 (Relates to the issue), branch test/battery-plan-deep, two commits, the test one first. refactor(pi-workflow): D6’s removal, with its CHANGELOG line. test: plan-corpus.mjs, earlier-review.mjs, checkoutFor’s parameter and memo key, the driver, `checkSpec, loadTask, rescore’s `provision: false, the scorer, reachTable, the retirement of planning-round-two, the tests below that need no deep case, battery render, page-head.adoc, and one sentence in battery.json’s `defaultsNote: reviewer and planning rows dated before 2026-12-01 were measured under the 12-call, 200 KB read budget (#996).

  2. MR 2 (Relates to the issue), branch test/battery-plan-deep-cases: the two pins, the ten cases, the README, the three task files, the manifest entries, RESCORABLE, the corpus tests, battery render.

  3. The pilot and the run, each with the operator’s go; the prediction first.

  4. MR 3 (Closes the issue), branch test/battery-plan-deep-records: the records, battery summarise and battery render, any key change the protocol made, the result by the rule.

Not in scope: moving the planning role to the deep task; any production budget or timeout; planning and planning-hard; a signal in production when a review hits its budget (#1000).

Tests

vitest, in tools/model-battery/test/. New plan-deep.test.mjs replaces plan-round-two.test.mjs (its planning-hard checks move across unchanged). "Temp corpus" is a small git repository built in a temporary cache directory and pinned as a foreign corpus, as explore.test.mjs builds one for corpusGitDir.

Category Test Pins

contract

temp corpus, 14 declared files: subjectFor’s user prompt equals `buildPlanReviewPrompt over `resolvePlanContext’s own answer, with 12 FILE blocks and a NOT SUPPLIED block naming the other two

a deep case is sent as production sends a plan

contract

the three arms on one temp case: the system prompt says 48 calls and 800 KB, 12 calls and 200 KB, and 48 and 800 with the frozen framing before Answer each of P1-P4; only the anchored user prompt ends with renderEarlier of the file; the cold arms hold no EARLIER REVIEW

each arm differs from the shipped pipeline in one thing

contract

promptTextForFingerprint differs pairwise across the three arms; for planning, planning-hard and reviewer it equals promptText()

no other task’s fingerprint carries an arm’s text

contract

checkSpec accepts both new fields on a review task; refuses a zero, a fraction, a missing half, an empty string, and either field on a judge task

the spec’s shape

contract

EARLIER_REVIEW_FRAMING has the sha256 recorded from production before its removal; withEarlierFraming puts it directly before Answer each of P1-P4, and throws on a prompt with no marker and on one with two

the old prompt is rebuilt exactly or refused, fail-closed

contract

the manifest lists the three tasks with 3 runs and the subjects of D5

the permutations

regression

temp corpus: a reviewPaths path missing at the pin, an absent has and a present lacks are each refused by cases(), naming the case; an authored reach that differs from the derived one is refused by subjectFor before the call; under earlier, a case with no file or an empty one is refused by cases()

a stale or mislabelled case is not measured

regression

checkoutKey differs for one name at two pins and for one pin under two caches, and is equal for the same three; two temp corpora of one name under two caches get two checkouts

a task is not handed another task’s tree

regression

loadTask(name, { provision: false }) over a temp corpus whose clone is absent lists the cases and clones nothing

rescore reads keys without the tree

regression

git cat-file -e <pi pin>:tools/model-battery/cases/planning-deep fails

the pinned tree does not hold the keys

regression

corpus: every deep plan passes planShapeProblems, is 180 to 280 lines, names 18 to 35 files and has six or more held back at the pin; D4’s totals equal the keys' counts; checkPlanCorpus passes and reachProblems over declaredTree is empty, for pi against this repository and for ruff under describe.skipIf when the clone is absent

the corpus is what D4 and D8 say

regression

for every defect and decoy, a FAIL block whose text is its what is credited by blockNamesDefect; a decoy’s block names no defect; each round-one-clean.txt opens VERDICT: CLEAN, reads as four PASS blocks through reviewBlocks, and names no proof path of its case

anchors match their own words; round one’s review misses what is planted

regression

score.test.mjs: a review naming one defect of each reach gives byReach one of each; an errored call misses every reach; aggregate over records with calls 13 of 12 and 5 of 12 gives hitCallCap 0.5, and a wallMs over 600,000 counts in overTimeout

the three new numbers

regression

render.test.mjs: a summary with a byReach cell renders reachTable after planning’s experiments; without one the page is byte for byte what it was

the page moves only when measured

regression

run.test.mjs, cli.test.mjs, score.test.mjs, cases.test.mjs, review-driver.test.mjs: their task and directory lists lose planning-round-two (MR 1) and gain the three deep names (MR 2)

the lists that name every task

Mutants, each to fail its test: subjectFor handing every declared file; the spec’s budget ignored; the framing appended instead of inserted; checkPlanCorpus skipping lacks; the memo keyed on the name alone.

Risks

Risk Mode Mitigation

A planted defect the tree does not support, or a control that is not clean

silent

every proof and claim is checked at the pin by test and again when the cases are listed; D8.4; the protocol reads every false flag

Reach mislabelled, so recall by reach misleads

fail-closed

derived from resolvePlanContext and compared with the key before that case’s call, and for the whole corpus by test

Two tasks pin one corpus name at different commits and share a checkout

silent

the memo is keyed on name, commit and cache (regression test)

The keys reach the reviewer through the tree

silent

the pin predates the cases (regression test)

The ruff clone is absent in CI, so its keys are unchecked there

loud

the test skips visibly; listing the cases checks them on the box that runs

A cold case run anchored, or the reverse

fail-closed

the task names the earlier file and the loader refuses a case without it

An anchor misses a finding worded another way

silent

the what self-check; the protocol reads every miss and rescores every subject

Hand-written CLEAN reviews differ from real ones

silent

production’s answer form is pinned by test; stated as a limit in the result

The cases are written by a model of a reviewed family

silent

defect classes come from production’s own catches; outcome b and c are read per subject

The suite does not bite

loud

the rule’s second and third outcomes; one hardening round, then reported

A review outlives production’s 600 s bound and is scored as if it had happened

silent

overTimeout is reported beside every deep row and read with the result

Cost above the projection

fail-closed

the pilot measures first; the battery refuses over its budget before any call

battery render moves cells this plan did not touch

loud

rendered in MR 1 first; a diff outside planning’s experiments and the notes is reported and left out

Delivery

  • Canonical page: docs/modules/ROOT/pages/model-battery.adoc, generated by battery render; its source tools/model-battery/page-head.adoc names the three arms in the Experiments bullet in place of planning-round-two, and reach in the Scores bullet.

  • CHANGELOG.adoc == Unreleased: a Changed line for D6 (@gadhs/pi-workflow), and a "Repo only" line with each MR.

  • This plan committed as docs/modules/ROOT/pages/plans/battery-plan-deep.adoc, listed in docs/modules/ROOT/nav.adoc; Status In progress at start, Done at MR 3’s merge.

  • Validate before each push; MRs merged through the train with squash off; the issue is closed by MR 3, with its merge SHA and the result noted on it.

Edit this page · latest