Skip to content

Lead honesty before step 4 (T289) - #140

Merged
erickb336 merged 18 commits into
mainfrom
sage/t289-lead-honesty
Oct 16, 2026
Merged

erickb336 merged 18 commits into
mainfrom
sage/t289-lead-honesty

Conversation

@erickb336

@erickb336 erickb336 commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Current result — owner-authorized Codex takeover

Sage must not call a review clean when its child reported a blocking finding or reviewed another commit. This PR binds lead verdicts to their actual child reports and reviewed commits. It also blocks merging while review or QA runs remain active.

The owner transferred PR #140 from Claude to Codex. The branch now includes main at a0ba97a and the final repair at 583cd64aecbb93a40b2039950ed5f6e50c1ab763.

  • Preserve lead ownership across restarts and prevent reuse of another lead's child runs.
  • Keep findings visible until the lead records and repairs them.
  • Retire the old lead logbook row when a held or replanned task receives a new brief.
  • Keep Claude's strict line-based report rules in Claude bindings. Give Codex native reviewers an explicit JSON report contract.
  • Keep the two snapshot-race tests focused on concurrent publication. Their injected run is now a lead; all existing assertions remain unchanged.

The detailed original review and repair history is retained below. Historical counts and probe results there belong to their named commits.

Current verification

  • npm run build: built 311 files.
  • npm run check: passed, including all 5 marked timing bounds.
  • Focused report and snapshot checks: tests 7; pass 7; fail 0.
  • npm test: tests 1479; pass 1479; fail 0; cancelled 0; skipped 0 (307.95 seconds).
  • git diff --check: passed; final worktree clean.
  • GitHub CI run 38980245653: passed on this exact head, with all 1,479 tests passing.

Local tests used fake ps, pgrep, and kill first on PATH. The initial merged candidate had two snapshot-fixture failures (1,476 passed, 2 failed). The fixture repair above resolved their conflict with the intentional new live-review merge gate; the suite then passed.

Two independent code, security, and QA review cycles are clean on the unchanged final head. These reviews inspect code and workflow behavior; they do not establish live Claude event ordering.

Regression proof

On detached main a0ba97a, the selected F-T289/F-T286 cases report tests 58; pass 4; fail 54. Four control cases already pass on main; this is not a claim that every selected case fails.

The new T289: native reviewer instructions deliver one parseable findings contract test fails with an assertion on both detached main and the pre-repair integration head 17bff9d. It passes on the final candidate. It checks the actual rendered reviewer message and parses both clean and blocking JSON reports. Initial baseline attempts lacked a test dependency; those setup failures are excluded from the proof.

Remaining verification boundary

Original implementation and repair history through 89ac13f

What this is

The lead-honesty follow-up to PR #139, before step 4 (#119) adds the lead agent. It makes a lead's review and QA verdicts match what its real children reported, on the commit that they saw. It also closes the smaller lead gaps that the last reviews of #139 found. Each item has a test that fails on b4db88c (the head of #139, the same tree as main's 801434a) and passes on this branch. Repair rounds 1 to 5 below fix the findings of the reviews of this PR.

Each item and its test

Item Fix Test
1. F-T289-4 (medium) At a helper's stop, the hook keeps the first word of its RESULT and the severity of each line of its FINDINGS. A clean verdict (review-clean, security-clean, ux-clean, qa-pass) needs a clean report: CLEAN or PASS, or FINDINGS or FAIL with only low findings. findings and qa-fail need a report that is not clean, and the task's open findings of the round from that role must hold each medium and high finding of the report at its severity or above. An unreadable report, or a stop with no report, is not clean. A lead still dismisses only low findings. "F-T289-4: a lead's verdict says what its helper reported, and records each medium or high finding at its severity"
2. F-T289-5 (medium) At the helper's stop, the hook reads the head of the task's branch with git (rev-parse --verify refs/heads/<branch>^{commit}, an argument array, a 3 s timeout, no shell) in the lead's folder. A lead's verdict --sha must equal it. No branch, or a failed read, gives no commit, and the verdict is refused. "F-T289-5: a lead's verdict names the commit that its helper saw at its stop"
3. F-T289-8 (medium) The helper note is keyed by the logbook, the lead run and the run id. A run belongs to the lead run that was running when it was added (run ids only grow, and a task has one running lead run). A new lead cannot start a child for, end or use an old lead's run; the sage ends those. "F-T289-8: a new lead never uses or ends an old lead's runs; the sage ends them"
4. F-T289-1 (medium) A lead's finding triage of a finding triaged ask is refused. Only the sage changes it. "F-T289-1: a lead never re-triages a finding triaged ask"
5. F-T289-2 (low) The state tool refuses a review or QA verdict whose --run already backs a review or QA verdict of the task. Check verdicts are exempt, because the chief's logbooks name one run on both checks-pass and qa-pass. "F-T289-2: a run backs one review or QA verdict of its task; a check verdict may name it too" (scripts/sage.test.mjs)
6. F-T289-3 (low) A lead may end a run whose helper never started with --status failed or blocked. Such a run backs no verdict. A helper that started must stop first. "F-T289-3: a lead ends a run whose helper never started as failed or blocked, and that run backs no verdict"
7. F-T289-9 (low), option b task set state=briefed from held or replan ends the task's running lead run as blocked, with a decision row. The hook's existing checks then refuse the old lead's writes and child starts. The chief starts a new lead with the new brief. "F-T289-9: a re-plan back to briefed ends the task's running lead run, with a decision" (scripts/sage.test.mjs); "F-T289-9: after the sage moves the task back to briefed, the running lead writes nothing and starts no child"
8. F-T289-6 (low) While repairing, a lead closes a round's finding only when the head of the task's branch is not a commit on which one of its review or QA children found problems. So a lead cannot close the round's keys on an unchanged commit and re-add the problem under a new key; with all keys still open, the existing replan rule applies. "F-T289-6: a lead closes a round's finding only on a new commit, not on the one where its helper found the problem"
9. F-T289-7 (low) Lead writes and child starts are refused on a merged, concluded or abandoned task, as on a held one. "F-T289-7: a lead writes nothing and starts no child on an abandoned, merged or concluded task"
10. F-T289-10 (low) The README and the design page say "clears the old round's keys". The design page's diagram shows held and replan from verifying too, and held to briefed. The README rules row, what's new and the chief's instructions describe items 1 to 9. none (wording)
F-T286-1, F-T286-7 The helper notes live in one folder that every session shares: started when the child's slot is taken, stopped with the report at its stop. A second child for the same run is refused across sessions and after the first one's lease ends. A failed spawn removes its started note. "F-T286-1: one child backs one run also after its slot's lease ends" (F-T286-7 is held by the same note and by item 3's test)
F-T286-2, F-T286-3 A non-whole extra cell counts as 0. A move from a round hold to abandoned adds no extra round and no decision. "F-T286-2 and F-T286-3: a non-whole extra counts as 0; a move from a round hold to abandoned gives no round" (scripts/sage.test.mjs)

Test fixture changes

leadSession makes its project folder a git repository with the branch claude/t1 for T1, and gives head() and commit(). helpRun stops the child with a clean report of its role. The older lead verdict tests name s.head(), the commit that the helper saw, in place of a made-up SHA. In the F-T284-5 and F-T284-6 tests, the verdicts that only checked "a new SHA" now use checks-pass, and qa-fail and findings moved to the F-T289-4 test, because a clean helper report no longer backs them.

Proof on old code

A detached worktree of b4db88c with this branch's two test files: all 12 new tests fail, each at its first assertion on the new rule (the old hook or state tool allowed the command). The combined F-T286-2 and F-T286-3 test fails at its F-T286-2 assertion.

Repair round 1 (R947)

A detached worktree of e86f146 with this branch's scripts/sage-hook.test.mjs fails all 7 new tests (fail 7, pass 0), each at its first assertion on the new rule. They pass on the branch. Round 2 replaces parts of F-T289-11 (none with words after it), F-T289-15 and F-T289-17 (the findings count); see below.

Finding Fix Test
F-T289-11 (medium) A report gives FINDINGS as none (words after it are allowed) or one line per finding in the form - <key> <severity> <summary>, with the severity in lower case right after the key. The hook reads severities only from such lines under FINDINGS. Any other non-empty line there, or an empty FINDINGS, makes the report unreadable, so it is not clean. The report skill gives the form, and npm run check fails when the template's FINDINGS line does not give the hook's FINDING_FORM. "F-T289-11: a report's findings count only in the form - , under FINDINGS; any other line there is not clean"
F-T289-14 (medium) The started note keeps the branch tip at the helper's start. At its stop, the hook records that commit only when the tip did not move. Otherwise it records no commit, and the run backs no verdict. "F-T289-14: a helper reviewed a commit only when the branch did not move between its start and its stop"
F-T289-15 (medium) A lead's run done (any status) of a review or QA run whose report was not clean is refused until the task holds each medium and high finding at its severity from that role, or a findings or qa-fail verdict names the run. An unreadable report has no findings to record, so the sage ends that run. "F-T289-15: a lead ends a review run whose report was not clean only after it records each medium or high finding"
F-T289-12 (medium) The close rule compares the branch head only with the commits where review or QA runs of an earlier round found problems. A re-review in this round that finds a new problem does not block the close. "F-T289-12: a lead closes a round's finding on the repair's commit, also when the re-review of that commit finds a new problem"
F-T289-13 (low) A helper whose slot left with no stop (lease ended, or freed) lets its lead end the run as failed or blocked. Such a run backs no verdict. A new lead's spawn removes the helper notes of the logbook's ended lead runs. "F-T289-13: a helper that left with no stop lets its lead end the run as failed or blocked; a new lead prunes the old notes"
F-T289-16 (low) replan is in LEAD_STOPS. A lead uses only runs that it added itself: the hook now also runs at PostToolUse of Bash (claude.json), and when a lead's own run add printed R<n> running · <role> on <its task>, it notes that run as the lead's. The id-order rule is gone. "F-T289-16: a lead uses only the runs that it added itself, and writes nothing in replan"
F-T289-17 (low) The findings check counts the medium and high findings of this run plus those of every other run of the same role in the round that backs a findings or qa-fail verdict. Each one needs its own open recorded finding. "F-T289-17: two runs' findings need two recorded findings"

Fixture change: leadAdd runs the lead's own run add and sends its PostToolUse event. leadSession and the lead tests add the lead's runs through it, and the test reports give findings in the new form.

Repair round 2 (R954)

The main change: the hook reads a report with one strict reader, reportOf, which the stop gate and the lead rules both use. One field rule (fieldsOf) serves the brief gate, the report gate, RESULT and FINDINGS. The clean-verdict rule now looks at every stopped child of a role in the round, not only the run that the lead names (gap). The old covered check and the live lease check are gone.

The reader:

  • A field starts at a line that is not indented, whose text after Markdown marks (*, _, #, |, >, -) and spaces starts with the field's name. The field's text drops a colon, bold marks and table bars around it. An indented line never starts a field.
  • Each line break ends a line: LF, CRLF, CR, VT, FF, NEL, U+2028 and U+2029.
  • FINDINGS is none alone (an optional full stop), or finding lines - <key> <severity> <summary>, each with any detail on indented lines under it. A finding line counts also when it is indented.
  • A field given twice, a missing RESULT or FINDINGS, an empty FINDINGS, none with findings, or any other line under FINDINGS makes the report unreadable. The stop gate then stops the agent once and says why.

A detached worktree of d1e8e14 with this branch's scripts/sage-hook.test.mjs fails all 11 new tests (tests 11, pass 0, fail 11), each at its first assertion on the new rule: the old hook allowed the command, or gave only the general refusal (F-T289-31). They pass on the branch.

Finding Fix Test
F-T289-18 (medium) While the medium and high findings of a role's stopped children in the round are not all recorded (each run's own, at its severity or above), the lead's run add of that role, any verdict of that role (clean, findings or qa-fail) and any task set state= are refused. An unreadable report of a run that still runs holds the role until the sage ends the run. Second guard, in the state tool: merge-check refuses a task that would pass while one of its review or QA runs still runs (an open finding is still named first). I added it because it holds without the hook too (for example a session without the plugin), it needs no new tool or dependency, and a running review is an unfinished cycle in any case. "F-T289-18: while a run's high is not recorded, the lead adds no run of that role, records no verdict of it and makes no move; merge-check waits for running reviews"
F-T289-22 (medium) gap counts the findings of every stopped child of the role in the round, run by run, against the open recorded findings of that source. One recorded finding no longer covers two runs, also before any verdict. "F-T289-22: each run's findings need their own recorded findings, also before any verdict"
F-T289-25 (medium) The strict reader: an indented line under a finding is detail and never starts a field; a field word at the start of a line starts a field, and a second STATUS or EVIDENCE makes the report unreadable. "F-T289-25: a line under FINDINGS that starts with a field word does not hide a later high"
F-T289-24 (medium) One field rule for the brief gate, the report gate, RESULT and FINDINGS. FINDINGS: none, **FINDINGS** none, | FINDINGS | none | and FINDINGS: with finding lines under it now read as the gate takes them. The stop gate also stops a report that the reader cannot read. "F-T289-24: the stop gate and the reader take the same field forms: colon, bold, table, and FINDINGS: with lines under it"
F-T289-20 (low) A run whose child gave no report (never started, left with no stop, or stopped by the main session's TaskStop) ends only as failed or blocked, and backs no verdict. A field counts only at the start of a line, and FINDINGS given twice makes the report unreadable. "F-T289-20: a helper that the sage stopped gave no report, so its run ends only as failed or blocked; FINDINGS counts only as a field of its own"
F-T289-21 (low) none alone, with at most a full stop, is the only clean form. "F-T289-21: FINDINGS none is clean only alone, with at most a full stop"
F-T289-23 (low) A lead's verdict on a run whose report is unreadable, or that has no report, is refused, also after the sage ends the run: the sage reads it. "F-T289-23: a lead records no verdict on a run whose report the hook cannot read, also after the sage ends the run"
F-T289-26 (low) Every line break, not only LF and CRLF, ends a line. "F-T289-26: a line separator inside a finding line ends the line, so a later finding counts"
F-T289-27 (low) The lead owns a printed run only when the command's one --role equals the printed role. "F-T289-27: a lead owns a run only when the printed role is the role that its run add asked for"
F-T289-29 (low) Option chosen: indented detail lines under a finding line (simpler for agents than a second place for detail). The report skill and the security reviewer say so; npm run check fails when the report skill, or an agent that asks for detail for each finding, does not say "on indented lines under". The design page shows the new FINDINGS form. "F-T289-29: a finding's detail on indented lines under it is part of that finding, and the roles say so"
F-T289-31 (low) While a started helper has no stop and its slot holds its lease, run done says to wait for its stop, with the minutes left, or to ask the sage to end the run. "F-T289-31: while a helper's lease is live, run done says to wait for it, with the time left, or to ask the sage"

Changed tests: the older T284 and T289 tests now match the new refusal texts (no report, lease, unreadable report, the gap text). F-T289-11 now expects none with words after it to be unreadable (F-T289-21). F-T289-17 now expects the first run's findings verdict to wait for the second run's finding (F-T289-22). In scripts/sage.test.mjs, the T40 test ends its running QA run before its last merge-check.

The earlier attack probes, run again on this head (hook events to the built hook, fake ps, pgrep, kill and gh first on PATH):

Probe Before (d1e8e14) Now
R952 K1: a high left on a running run, then a clean re-roll review-clean, qa-pass and merge-check passed the re-roll's run add, the state move and the verdict are refused; merge-check refuses, because review-clean was never recorded
R949 P1: - EVIDENCE for F0 hides a later high review-clean passed the high counts: run done and the move wait for it, review-clean is refused, and merge-check refuses
R949 P1b: STATUS of F0 under FINDINGS review-clean passed the stop gate stops the child ("STATUS is given twice"); review-clean is refused
R949 N7c: a not-clean run left running, then a clean re-roll landed the re-roll's run add and the move are refused; merge-check refuses, because review-clean was never recorded
R953 D1: two qa runs, one recorded finding both runs ended with one recorded finding for two runs the second qa run add is refused while the first run's medium is not recorded. A variant with both runs added first: both run done are refused until the second finding is recorded
R950 D1: FINDINGS: none, bold, table, FINDINGS: with lines unreadable, so no clean verdict the gate and the reader take all five forms; run done and qa-pass pass

Repair round 3 (R961)

Two themes. The findings rule (gap) now holds across a round and does not hold a lead after the sage's own dismissal or move. The report reader rejects fewer honest reports and never reads an unclear line as "no finding".

A detached worktree of fa50ee0 with the 8 new tests of scripts/sage-hook.test.mjs fails all 8 (tests 8, pass 0, fail 8), each on the new rule. They pass on this branch.

Finding Fix Test
F-T289-32 (medium) gap counts the findings of every round, not only the current one. So round no longer drops an earlier round's report: run done of the high run, a new run of the role, its verdicts and every state move wait until the high is recorded. round itself needs no gate. "F-T289-32: a round does not drop the findings of an earlier round: the high run still needs its finding to end"
F-T289-37 (medium) A recorded finding counts in any status (open, closed, dismissed) and also after finding move (the logbook view finds it by the move's decision row: everFindings). Only findings that the task got after the lead started count: each lead slot keeps a floor, the highest finding number of the task at the lead's start. So a new lead gets no credit for an old lead's closed findings. A lead cannot dismiss or move a medium or high finding, so a re-roll still needs one finding per report. "F-T289-37: after the sage dismisses or moves the lead's recorded medium, the lead goes on; findings from before the lead do not count"
F-T289-34 (medium) The field rule trims the end of a line with a loop, not with `/[\s*_ ]+$/` (quadratic). The reader reads at most 4096 characters of a line after its indent. The other patterns of the reader and the brief gate are anchored, with classes that do not overlap. A 200,000-space field line now takes milliseconds at the stop gate and the brief gate (it took about 30 s on fa50ee0).
F-T289-39 (medium) One reader (reportOf): RESULT must start with CLEAN, PASS, FINDINGS or FAIL; with no word on its line, the first word of the next line counts (## RESULT, then PASS). Any other word makes the report unreadable, so the stop gate stops the agent once and lists the four words. "F-T289-39: the stop gate blocks a RESULT that is not CLEAN, PASS, FINDINGS or FAIL once, and lists the four; RESULT on the next line counts"
F-T289-33 (low) A line in the shape of a finding is a finding, also when it is indented: a list mark (-, *, +, 1.), at most one key word, then a severity word in any case. An indented list item with a severity word anywhere counts too, at its highest severity. "F-T289-33: an indented line in the shape of a finding is a finding, not detail"
F-T289-38 (low) The reader takes - K1 medium:, - K1 (medium), - K1 - medium -, - K1 [MEDIUM], * K1 Medium, 1. K1 medium; none found, none (see EVIDENCE), - none (none with words counts only when no severity word is among them); a field word in a list item or a code block is not a field. A line under FINDINGS that is neither none, a finding nor indented detail under a finding still makes the report unreadable. "F-T289-38: honest forms of a finding, of none and of EVIDENCE read as their writer meant; any other line under FINDINGS stays unreadable"
F-T289-40 (low) The stop gate applies the reader only to a review or QA (code, security, UX review, QA): the lead rules read no other role's report, so an implementer, designer, pe or arena judge may list what it fixed under FINDINGS. The report skill says to write none there and to list fixes in EVIDENCE. The gate's message quotes the repeated field line and names the severity words. "F-T289-40: the stop gate reads the FINDINGS of a review or QA only, and quotes the repeated field line with the severity words"
F-T289-36 (low) A lead's verdict on a run that still runs says "end it with run done R first"; on a run that ended failed or blocked, "add a new run, or ask the sage"; on a run whose helper gave no report, "ask the sage". A state move out of order says which moves there are ("T1 is briefed: a lead moves it only to building"), and a move out of repairing with an open fix finding says to close it after the repair's commit. "F-T289-36: a lead's refused verdict or move says the way out"

Changed tests: the older tests match the new gap text and the new refusals. F-T289-11 and F-T289-21 now expect none with words but no severity word to be clean, - Y1 High to be a high finding, and none of Medium risk to be unreadable. F-T289-4 records the qa medium of its FAIL run, because the fixture's older qa finding no longer counts for the lead.

Honest reports (R957's 28 cases H1 to H28, read by the stop gate and the reader; a case counts as rejected when the gate stops it or the reader reads it otherwise than its writer meant): 18 on fa50ee0, 7 now. The 7: a field word at the start of an unindented line (H4, H24: still a second field, by F-T289-25), a finding wrapped onto an unindented line (H10), an indented note under none (H12), none (see EVIDENCE for the low notes) (H27: a severity word, so unclear), and RESULT PASSED or Verdict: PASS (H17, H18: the gate stops these once by F-T289-39).

The earlier probes, run again on this head (hook events to the built hook, fake ps, pgrep, kill and gh first on PATH):

Probe Before (fa50ee0) Now
R959 s1, R956 A1: a high, a decoy round, then run done allowed refused with the findings text
R959 s2: the same, through to merge-check merge-check passed with the high never recorded refused at run done; merge-check refuses (review-clean never recorded)
R959 s5: a padded brief and report 12.8 s and 25.8 s 0.1 s and 0.0 s
R959 s6: padded spawns that Claude Code kills at 10 s killed, so the spawn went through without its caps answered in 0.1 s; a second child for the same run is refused
R955 P2 and P5 (the sage dismisses or moves the round's medium) the lead was held for the rest of the round the lead goes on (the F-T289-37 test)
R957 role: implementer, pe, designer, arena judge with a list under FINDINGS the gate stopped them the gate lets them through

Repair round 4 (R968)

Two themes, as the owner chose. The report reader is narrow: it never lowers a severity and never reads a real finding as none; a line that it cannot read makes the report unreadable, and the sage reads it. The findings rule (gap) counts only the findings that the lead run recorded itself.

A detached worktree of 96063f5 with this branch's hook tests fails all 15 new tests (tests 15, pass 0, fail 15), each on the new rule. They pass on this branch.

Finding Fix Test
F-T289-42 (medium) The floor is gone. At the PostToolUse of a lead's own finding add (the printed key, of its task, with the source and severity that the command asked for), the hook notes the key under the lead run's key. A lead started again on the same lead run reads the same notes, so it keeps them. "F-T289-42: a lead started again on the same lead run keeps the findings that the lead run recorded"
F-T289-43 (medium) gap counts only those noted keys. A finding that the sage added never counts, also when the sage adds an old key again (decision: the key counts only if this lead run recorded it; fails closed). "F-T289-43: a finding that the sage added, also on an old key, never covers a lead helper's finding"
F-T289-44 (low) everFindings is replaced by traced(key) in the logbook view: it follows one key. The decision trail is read only to follow a lead's own key that has no row, and only a decision in the form that finding move writes, on the key's task, with the new key on the target task and the same summary as the row at the end. "F-T289-44: a decision in the shape of a move counts only when it is the state tool's own move of this lead's finding"
F-T289-49 (low) traced follows the key through every move, with a loop guard; two decisions for one key fail closed. "F-T289-49: the lead's finding counts after the sage moves it twice"
F-T289-50 (low) With no floor, a lead slot of the old form has no noted keys, so it counts no finding (fail closed). The test writes an old floor-0 mark into the slot; changing the rule to count all of the task's findings fails it, and F-T289-43's test too. "F-T289-50: a lead slot of the old form, with a floor and no recorded keys, counts no finding (fail closed)"
F-T289-47 (medium) A finding line is a list item whose first word is a key with a digit and whose second word is the severity (marks around it only: colon, brackets, parentheses, bold, a dash). A line whose first or second word is or starts with a severity word but does not fit (- High: low-privilege, - high K1, - K1 low-level) is unreadable. "F-T289-47: a severity word as the key, or before the key, makes the report unreadable, never a lower finding"
F-T289-48 (low) RESULT FINDINGS or FAIL with FINDINGS none is unreadable. A line under FINDINGS longer than 4096 characters is unreadable, never cut. "F-T289-48: RESULT FINDINGS or FAIL with FINDINGS none, and a line under FINDINGS longer than 4096 characters, are unreadable"
F-T289-51 (low) none alone (an optional full stop, an optional list mark) is the only clean form; none with any words after it is unreadable. The stop gate's one-time block stays, so an honest helper can fix it. "F-T289-51: none with words after it is unreadable, also when the words hold no severity word or a look-alike one"
F-T289-52 (low) A fence counts only at 0 to 3 spaces of indent, and closes only with the same character, at least as long (CommonMark). A second FINDINGS line anywhere outside a code block, also indented or as a list item, makes the report unreadable. "F-T289-52: an indented fence line and a FINDINGS list item do not hide a FINDINGS field"
F-T289-54 (low) An indented line under a finding is detail only when its first and second words are not severity words and it has no severity label (high:). A finding line with a severity label in its summary is unreadable. "F-T289-54: a high under a low on an unmarked or severity-first line, or as a label after the low's summary, makes the report unreadable"
F-T289-46 (low) Severity words elsewhere in a detail line no longer count: "a high row count" in a step line is detail. "F-T289-46: an indented step line with a severity word in its prose is detail of its finding"
F-T289-58 (low) A key has a digit, so a prose bullet (- Confirmed medium load handled) is unreadable, not a medium finding. The stop gate stops it once and says that a key has a digit, so the helper has a clean way out; a second stop goes to the sage. "F-T289-58: a prose bullet with a severity word as its second word is unreadable, not a finding; a key has a digit"
F-T289-55 (low) A verdict on a run that still runs asks what run done would say; when it would refuse too, the verdict refusal gives that reason and its way out ("R5 still runs, and run done R5 is refused now too: R5's helper has not stopped ...: wait for its stop, or ask the sage to end R5"). "F-T289-55: a verdict refused on a run that still runs gives the reason that run done would give, with its way out"
F-T289-59 (low) The repair refusal names round only from reviewing or verifying. From building or verified it names the move to reviewing first (task T1 set state=reviewing); from briefed, building then reviewing. "F-T289-59: after the sage releases a held task to building, a refused repair names the move to reviewing, not round"
F-T289-53 (low) The hook tests run in 6 parts that node runs in parallel: scripts/sage-hook-tests.mjs holds every test, and each scripts/sage-hook-<k>.test.mjs runs every 6th test. Each test runs in exactly one part, so no test is dropped (335 tests). On the same machine: the old file alone took 456 s; the 6 parts take 114 s. "F-T289-53: npm test runs each part of the hook tests once, so node runs them in parallel"

Changed tests: the lead tests record their findings through the lead (leadFind, the lead's own finding add with its PostToolUse event), because a finding that the sage adds no longer counts. F-T289-21, F-T289-33 and F-T289-38 now expect none with words and an indented finding line to be unreadable. F-T289-20 now expects an indented quote of FINDINGS to be a second FINDINGS line. F-T289-36 and F-T284-5 match the new refusals.

Honest reports (the stop gate and the reader on each case; a misread is a readable report read otherwise than its writer meant; an unreadable one blocks once and goes to the sage):

Set First-stop blocks on 96063f5 Misreads on 96063f5 First-stop blocks now Misreads now
R957's 28 (H1 to H28) 7 0 8 (H14, none with an explanation, is now unreadable) 0
R964's 10 (N1 to N10) 2 0 2 0
R964 hon5 (Q1 to Q8, without Q6, which repeats Q2) 3 3 (Q1 read as medium, Q2 and Q7 read as clean) 6 0

The probes, run again on this head (hook events to the built hook, fake ps, pgrep, kill and gh first on PATH):

Probe 96063f5 Now
R963 B1: a keyless or severity-first high (3 forms), and the control line the 3 forms read as low or clean; run done and review-clean passed the stop gate blocks once; run done and review-clean are refused; the control needs its finding
R962 reader probe (A to N), with R963's look-alike and fence cases and R965's step line: 19 cases 13 not as the narrow rule wants 0
R966 P1 (a restarted lead) its new floor dropped the recorded finding: held goes on
R966 P2 (a sage finding, closed) covered the helper's high refused until the lead records it
R966 P3 (a move-shaped log line) counted another task's high refused
R966 P4 (a finding moved twice) held goes on
R967 B3 (10 forms of a high under or after a low) the stop gate passed all 10; 4 forms read as low only 9 forms unreadable (the gate blocks once, run done is refused); "steps: found a High problem" stays detail, by F-T289-46

Repair round 5 (R975)

The owner chose to stop patching line forms and add one global rule to the report reader. After the reader reads FINDINGS as before, it compares two levels:

  • read: the highest severity among the findings that it counted (none for none);
  • seen: the highest severity word anywhere in the FINDINGS field (finding lines, detail lines, indented items and prose), as a whole word in any case, after NFKC, with common Cyrillic and Greek look-alike letters read as Latin, and with zero-width and other format characters removed. The words are high, medium and low; critical, severe and blocker count as high.

When seen is above read, the report is unreadable: the stop gate blocks once and quotes the line, and says to write that finding as its own line - <key> <severity> <summary>; a second unreadable stop goes to the sage. The narrow finding form and none alone stay as they were. No per-form code became dead: the first-or-second-word rule and the high: label rule also stop two findings of one level from reading as one, so the lead's count of findings stays right.

Detached worktrees of 91b1bf9 with this branch's tests: the 6 changed or new hook tests fail 5 of 6 (F-T289-46 passes there, because it now uses a word that is not higher), and the check test fails (tests 1, fail 1). All pass on this branch.

Finding Fix Test
F-T289-60 (medium) The global rule: a higher word later on a finding line (- K1 Low entropy ... (high), - K1 low ..., K2 high ..., low (raise to high)) or in its detail (Correction, this one is HIGH) makes the report unreadable. "F-T289-60: a higher severity word later on a finding line or in its detail makes the report unreadable, never a lower finding"
F-T289-62 (medium) The global rule: an indented item or prose line with a higher word anywhere ( - K2 [security] high, K2 severity: high, steps: found a High problem) makes the report unreadable. "F-T289-62: an indented item or prose line with a higher severity word anywhere in it makes the report unreadable"
F-T289-63 (low) The global rule folds look-alikes (en dash, bullet, a) and U+2212 items; Cyrillic, Greek, full-width and zero-width forms of a severity word). A code fence opens or closes only at a line that starts after LF, CR or CRLF, as in Markdown, so U+2028 cannot open a fence that hides a second FINDINGS; every Unicode line break still ends a line for the field split. "F-T289-63: a look-alike or hidden severity word counts, and U+2028 before a fence does not hide a second FINDINGS"
F-T289-64 (low) At the lead's own finding add, the hook keeps the row that it printed (task, round, source, severity, summary). A key counts for the lead only while its row now has the same source, severity and summary, and, on its own task, the same round. The sage's raise, new source, new summary or new round makes it the sage's; a move keeps it (F-T289-49). A note of the old form has no row and counts nothing (fail closed). "F-T289-64: a lead's finding that the sage raises, or adds again with another source, no longer counts for the lead"
F-T289-61 (medium) The order-26 timing check reads each *.test.mjs file and each scripts/ file that a test file imports, so it reads sage-hook-tests.mjs again. npm run check counts 5 timing bounds again (0 on 91b1bf9). "F-T289-61: the timing check reads each file that a test file imports, such as sage-hook-tests.mjs, and counts its marks" (in scripts/dictionary.test.mjs)

Changed tests: F-T289-46 now puts its step line ("a high row count") under a high finding, because under a medium one the global rule now blocks it. F-T289-54 now expects "steps: found a High problem" under a low to be unreadable.

The trade-off, measured: an honest detail line with a higher word now blocks once, and the helper writes it again.

Honest set First-stop blocks on 91b1bf9 Misreads on 91b1bf9 First-stop blocks now Misreads now
R968's 45 16 0 16 0
R971's 10 1 0 2 (M8, "the high-risk path" in a medium's summary) 0

The attack probes, run again (the reader of the built hook; the stories as hook events to the built hook, with fake ps, pgrep, kill and gh first on PATH). "Lower" is a readable report whose highest finding is below a severity word in the report.

Probe Lower on 91b1bf9 Lower now
R970 v970 (111 variants) 48 2, both in a real code block outside FINDINGS (a tilde fence with a backtick in its info string, an unclosed fence)
R973 cases (42) 10 2, both outside FINDINGS (a finding under QUESTIONS, a "Findings:" heading in EVIDENCE)
R969 probe (30) 10 0
R974 B3 (10 forms, end to end) 1 unexpected (run done passed on "steps: found a High problem") 0 unexpected: all 10 refused
R970 E1 (4 stories, end to end) E1a to E1c: the stop gate passed and review-clean was recorded with the high unrecorded the stop gate blocks all 4 and quotes the line

Checks

npm run build, npm run check (5 timing bounds carry their mark) and npm test (982 tests, 213 s, with fake ps, pgrep, kill and gh first on PATH) pass on the head commit 89ac13f.

Not verified live

  • A real sage:lead agent in Claude Code: the agent file comes in step 4 (Lead build step 4: the sage:lead agent file and the docs (T181) #119). All tests use hook events and fakes.
  • The order of a real foreground child's SubagentStop and its Agent tool result: the hook keeps the report at SubagentStop, which I expect to come first. If the result came first, the stop has no report, and the run ends only as failed or blocked (fail closed).
  • The shape of a real Bash PostToolUse event (tool_response.stdout, or a string). If it differs, the hook notes no run as the lead's, and the lead can use no run. That fails closed, but it would stop leads, so step 4's live run must check it. The added PostToolUse matcher also starts the hook once more after each Bash call.
  • A lead that started before round 4 has no noted findings, so none of its findings count and a medium report holds it until the sage acts (fail closed). Start leads again after the update.
  • How often honest agents now hit the one-time stop for none with words, or for a key without a digit: the honest sets above show 16 of 45 first-stop blocks, none misread.
  • How often real agents write a report that the reader cannot read. The stop gate now stops such a report once with the reason, so the agent can fix it; a second unreadable stop goes to the sage. Step 4's live run should count these.

🤖 Generated with Claude Code

  • How often honest agents hit the one-time stop for a higher severity word in detail or prose (round 5): the honest sets show 18 of 55 first-stop blocks, none misread.

erickb336 and others added 16 commits October 12, 2026 07:21
F-T284-5: a lead repairs only through round. F-T284-6: a lead verdict names a
finished run of its task whose role gives that kind. F-T284-3: a held task
takes no pr= or branch=. F-T284-1: while held, the sage may still triage ask or
dismiss with a reason. F-T284-7: the lead spawn refusal names no --project.
F-T284-2: a guard test that the hook tests call spawnSync and execFileSync only
through bounded(). F-T284-4: a sage:lead with no bound lead slot starts no
child; the hook tests give such leads a fixture slot.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…T284 round 1)

F-T284-9/8: a lead's child named by its run id (R<n>) is that run's helper; a
team run ends, and backs one verdict of its round, only after its child
stopped. F-T284-14: a move out of held gives one more repair round.
F-T284-12/8: while repairing, a lead closes only the round's fix findings and
leaves repairing after them. F-T284-10: no close of an ask finding.
F-T284-11: a lead whose task is held or whose lead run ended starts no child.
F-T284-13: the README says a lead started outside sage mode has no slot.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s (T284 round 2)

F-T284-15: tasks.tsv gains hold and extra, written only by the state tool; a
move out of a hold that round set gives one more round, once per hold; a hold
by task set gives none. F-T284-16: round counts max_rounds plus extra, never
decision text, and shows the real limit. F-T284-17: a round that fixed none
of the last round's findings re-plans, also on the retry after a hold; the
README says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
F-T284-19: a move out of replan clears the round keys, so the first round of
the new plan never compares with the old plan's findings and replans again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
README and the F-T284-19 test title: leaving replan clears the old round's
findings, and the round number goes on, capped by max_rounds plus the extra
rounds. The design page's state diagram and rules table: replan when the last
round's fix findings are all still open, one more round after a hold by round.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e lead run (T289)

- verdict refuses a --run that already backs a review or QA verdict of the
  task (F-T289-2); check verdicts may still name the run.
- task set from held or replan to briefed ends the task's running lead run
  as blocked, with a decision (F-T289-9).
- a non-whole extra counts as 0 (F-T286-2); a move from a round hold to
  abandoned gives no extra round (F-T286-3).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- At a helper's stop, the hook keeps its RESULT, the severities of its
  findings and the head of the task's branch, in a helper note that every
  session shares. A lead's review or QA verdict must match the report, name
  that commit, and record each medium or high finding at its severity
  (F-T289-4, F-T289-5).
- A helper note is keyed by the lead run too, and a run belongs to the lead
  run that was running when it was added: a new lead never uses an old
  lead's runs (F-T289-8). One child per run holds across sessions and after
  a lease ends (F-T286-1, F-T286-7).
- A lead never re-triages a finding triaged ask (F-T289-1); ends a run whose
  helper never started as failed or blocked (F-T289-3); closes a round's
  finding only on a commit where its helpers found no problem (F-T289-6);
  writes nothing and starts no child on a merged, concluded or abandoned
  task (F-T289-7).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
README rules rows and what's new, the design page's task life diagram
(round results from verifying, held to briefed) and rules row, and the
chief's note that a re-plan ends the lead run (F-T289-10).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…(T289)

- A report gives each finding as "- <key> <severity> <summary>" under
  FINDINGS, or "none"; any other line there makes it unreadable, and the
  report skill and npm run check carry the same form (F-T289-11).
- A helper's reviewed commit is the branch tip at its start, only when the
  tip did not move before its stop (F-T289-14).
- A review or QA run whose report was not clean ends only after its medium
  and high findings are recorded, or after its findings verdict (F-T289-15).
- A round's finding closes on the repair's commit even when the re-review
  finds a new problem (F-T289-12).
- A helper that left with no stop lets its run end as failed or blocked; a
  new lead prunes the notes of ended lead runs (F-T289-13).
- A lead uses only runs it added itself, seen at PostToolUse of its own
  run add; replan stops a lead's writes (F-T289-16).
- Each finding of each run needs its own recorded finding (F-T289-17).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… role (T289)

The stop gate and the lead rules now read a report with one reader. One
field rule serves the brief gate, the report gate, RESULT and FINDINGS:
a field starts a line that is not indented, Markdown around its name is
fine, each line break ends a line, and a field given twice makes the
report unreadable. FINDINGS is none alone, or finding lines with any
detail on indented lines under them (F-T289-20, -21, -24, -25, -26, -29).

The findings rule looks at every stopped child of a role in the round:
until each medium and high finding is recorded, the lead adds no run of
that role, records no verdict of it and makes no state move (F-T289-18,
F-T289-22). A run with no report or an unreadable one backs no lead
verdict (F-T289-20, F-T289-23). The lead owns a run only when the
printed role is the one it asked for (F-T289-27). run done says to wait
for a live lease (F-T289-31). merge-check refuses a task that would
pass while one of its review or QA runs still runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eader (T289)

- gap counts each report's findings in every round, against the role's
  findings in any status (also moved ones) added since the lead started
  (F-T289-32, F-T289-37). Each lead slot keeps its findings floor.
- The field rule trims a line end with a loop, not a quadratic pattern;
  the reader reads at most 4096 characters of a line (F-T289-34).
- One reader: RESULT starts with CLEAN, PASS, FINDINGS or FAIL, also on
  the next line; the stop gate stops other words once (F-T289-39).
- Finding lines: any list mark, a severity in any case, after a colon or
  in brackets, also indented; none with words but no severity word; a
  field word in a list item or a code block is no field (F-T289-33, -38).
- The stop gate reads FINDINGS only for a review or QA, quotes a repeated
  field line and names the severities (F-T289-40).
- A refused verdict or state move says the way out (F-T289-36).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gs (T289)

The reader never lowers a severity and never reads a finding as none:
a finding is a list item with a key that has a digit, then the severity;
any other line whose first or second word is a severity word, a severity
label, none with words, a second FINDINGS (also indented or a list item),
a line over 4096 characters, or FINDINGS or FAIL with none makes the
report unreadable. A fence counts only at 0 to 3 spaces (CommonMark).

gap counts only the findings that the lead run recorded itself (noted at
the PostToolUse of its own finding add), followed through the sage's
moves by the state tool's own move rows (traced). The floor is gone.
The verdict and repair refusals name the real next step. The hook tests
run in 6 parallel parts: 456 s alone before, 114 s now on one machine.

Fixes F-T289-42 to -44, -46 to -55, -58, -59.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
….mjs (T289, F-T289-61)

The round 4 split moved the hook tests into scripts/sage-hook-tests.mjs, which the
six sage-hook-<n>.test.mjs parts import. The order-26 timing check read only
*.test.mjs files, so it counted none of that file's bounds. It now reads each test
file and each scripts file that a test file imports.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eader (T289)

- F-T289-60, F-T289-62, F-T289-63: a severity word anywhere under FINDINGS (a
  finding, detail or prose; high, medium, low, and critical, severe or blocker as
  high; after NFKC, look-alike Cyrillic and Greek letters and no format characters)
  above the highest finding that the reader counted makes the report unreadable.
  The stop gate quotes the line and says to write it as its own finding line.
- F-T289-63: a code fence opens or closes only at a line that starts after LF, CR
  or CRLF, so U+2028 cannot open a fence that hides a second FINDINGS.
- F-T289-64: a lead's recorded finding counts only while its row keeps the source,
  severity and summary that the lead recorded, and its round on its own task; the
  sage's raise or new source makes it the sage's (fail closed).
- The report skill, README and design page describe the global rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 14, 2026
@erickb336
erickb336 marked this pull request as draft October 16, 2026 23:13
@erickb336
erickb336 marked this pull request as ready for review October 16, 2026 23:26
@erickb336
erickb336 merged commit b5889f6 into main Oct 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing feature: automatic Sage workflows and gated autopilot in Codex

1 participant