Skip to content

Lead rules follow-up before step 4 (T284) - #139

Merged
erickb336 merged 5 commits into
mainfrom
sage/t284-lead-followups
Oct 12, 2026
Merged

erickb336 merged 5 commits into
mainfrom
sage/t284-lead-followups

Conversation

@erickb336

@erickb336 erickb336 commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

What this is

The owner's follow-up to PR #124 (lead build step 3). It must merge before step 4 (#119) adds the lead agent. It fixes the findings of PR #124's last review cycles. Each fix has a test; the table says which test fails on main (d6414fa).

Each finding and its test

Finding Fix Test On main
F-T284-5 A lead repairs only through round. While its task has an open medium or high finding triaged fix and the task is not repairing, the hook refuses the lead's finding close and its verdict on a new SHA (one that the task's ledger does not have). "F-T284-5: a lead repairs only through round: no finding close and no verdict on a new SHA while a fix is due" fails
F-T284-6 A lead's verdict needs --run R<n>: a run of its task with status done, whose role gives that kind. code-reviewer gives review-clean, security-reviewer gives security-clean, ux-reviewer gives ux-clean, qa gives qa-pass and qa-fail, and the three reviewer roles give findings. checks-pass and checks-fail need no run. evidence-clean is not a lead's. "F-T284-6: a lead's verdict names a finished run of its task whose role gives that kind; a check needs no run" fails
F-T284-3 The state tool's task set refuses pr= and branch= on a held task, as it refuses the other writes. The chief's state moves stay. "F-T284-3 and F-T284-1: …" (scripts/sage.test.mjs) fails
F-T284-1 While held, the sage may still triage a finding as ask, or dismiss it with a reason. Fix triage, finding close, run add and verdict stay refused. same test fails
F-T284-7 The refusal of a lead spawn no longer suggests --project <session folder>. It names run add T<n> --role lead, and says that a lead starts only from a session opened in the project's folder or one of its worktrees. "F-T284-7: the refusal of a lead spawn names no --project, and says where leads start"; the "#118 point 4" test now expects the new sentence fails
F-T284-2 A test reads scripts/sage-hook.test.mjs and finds no static import of a raw spawnSync, execFileSync or execSync from child_process, and no use of the raw calls outside bounded(). The test also proves that the check finds each kind of violation. "F-T284-2: this file calls spawnSync and execFileSync only through bounded()" passes: main's file already complies; this is the guard that keeps it so
F-T284-4 An agent of type sage:lead with no bound lead slot starts no child: "this lead holds no bound lead slot, so it starts no agent. Report to the sage." "F-T284-4: an agent of type sage:lead with no bound lead slot starts no child"; F-T273-14 and F-T273-17 now expect this sentence for a stopped lead fails

Test fixture change

Many older child-spawn tests use a lead id that no lead spawn bound. With F-T284-4, each of them needs a bound lead slot. session() in scripts/sage-hook.test.mjs now gives one: the first spawn by a sage:lead id that no main result bound gets a fixture lead slot of its own project (through the hook's own slotsFor). An id that a main result bound, or that stopped, keeps what the hook made of it. sendRaw skips the fixture, for the tests of the rule itself. leadSession gains a finished qa run (R4), for the lead's verdicts.

T282: not folded in

  • Moving the "no other task holds or held this PR" check into setPr: setPr serves every caller, the chief too. The chief may legitimately give a PR to a second task: a task framed again, or the merge-check history tests (S1, F2, F-T273-8). The state tool cannot tell a lead from the chief, so the move would change the chief's behaviour. It is not small. I recommend keeping the check in the hook (as now), and asking the owner if the chief should lose that move too.
  • A lead verdict's --sha must be the head of its task's PR: this needs a network read of GitHub at every lead verdict, so I skipped it, as the brief allows.

Repair round 1 (R921)

A detached worktree of f46692b with this branch's two test files gives 5 failures, exactly the 5 new tests below.

Finding Fix Test
F-T284-9, F-T284-8 (owner: tie runs to real helpers) The binding I chose: the child's name is its run id. A lead runs run add <T> --role <r>, then starts the child of role r with the name R<n>. At that spawn the hook checks that R is a running run of the lead's task, in the task's current round, of the child's role, and records it in the child's slot. One run has one child: a second child of the same run is refused, also after the first one stopped. When that child stops (SubagentStop, a completed foreground result, or the main session's TaskStop), the hook notes the run as helped. A lead's run done of a team run (the implementer too) is refused until then. A lead's verdict needs --run of such a run: done, helped, of the task's current round, and in no earlier verdict row. run add itself stays allowed, because the run's id must exist before the child can carry it; a run with no child can never end or back a verdict. "F-T284-9: a lead's run counts only with a real child of its role, named by the run, that started and stopped"
F-T284-14 (owner: one more round) A move out of held (task set state=building or briefed) writes the decision row "held → : one more repair round". round allows max_rounds plus one round for each such row, so the next round runs once, and the one after holds again. "F-T284-14: a move out of held gives the task exactly one more repair round" (scripts/sage.test.mjs)
F-T284-12 (option A), F-T284-8 While repairing, a lead closes only a fix finding of the round (its key is in the task's round keys). The lead's move from repairing to reviewing is refused while a fix-triaged medium or high finding of the round is open. A medium or high finding that is added during the round is not in its keys: it cannot be closed in this round, and it does not block the move, so the next round takes it. "F-T284-12 and F-T284-8: while repairing, the lead closes only the round's fix findings, and leaves repairing after them"
F-T284-10 A lead's finding close needs a finding triaged fix: never one triaged ask. "F-T284-10: a lead never closes a finding triaged ask"
F-T284-11 At each child spawn, the hook reads the lead's logbook from the folder that its slot recorded at the chief's spawn. A lead whose task is held, or whose lead run ended, starts no child. "F-T284-11: a bound lead starts no child after its task is held, or after its lead run ended"
F-T284-13 No code change. The README now says that a lead started outside sage mode gets no slot, so it starts no children, and that this is intended. none

Test fixtures: the fixture leads now have a real logbook: a side project in each session's sage home, with a building task and a running lead run. The leads of the LEAD_DIR fixture get their tasks too. leadSession gives R2 and R4 their real children, and triages F-T1-1 (low) as fix. A new helper, helpRun, starts, binds and stops a run's child.

Repair round 2 (R925)

A detached worktree of d563ef4 with this branch's scripts/sage.test.mjs gives 6 failures: the 3 new tests below, and 3 older header tests (unknown-columns, F-R65-2, F-R65-3) that now expect the two new columns of tasks.tsv.

Finding Fix Test
F-T284-15 (medium) tasks.tsv has two new columns that only the state tool writes. hold is set to round when round holds the task, and is cleared at any move into or out of held. extra counts the extra rounds. A move out of a hold that round set adds one to extra, once for that hold. A hold by task set (for example for a product question) adds nothing. Both columns are in ADDED, so an older tasks.tsv still reads, and its next write adds them. "F-T284-15: only a hold that round set gives one more round; a hold by task set gives none"
F-T284-16 (low) round counts max_rounds plus extra, never decision text: a log row with the same words adds no round. The round message shows the real limit, for example "round 2 of 2". "F-T284-16: the extra rounds come only from the state tool's own field, and the round message shows the real limit"
F-T284-17 (low), option a The README's what's-new list names children named by their run id, and one more round after a hold by round. Next to that rule, it says that a retry whose last round's findings are still open goes to replan. To make that true, round now re-plans when the new round's fix keys still hold every key of the last round, not only when they are equal: a round that fixed none of the last round's findings re-plans, also when new findings join them. "F-T284-17: a retry whose last round's findings are still open goes to replan"

Repair round 3 (R929)

Finding Fix Test
F-T284-19 (medium), option a A move out of replan clears the task's round keys, so the new premise starts its own count. Before, the first round after a re-brief compared its keys with the old plan's, and replanned again while those findings stayed open. The README rules row says so. "F-T284-19: a task that leaves replan starts its own round count, so an old finding that is still open does not replan it again" (scripts/sage.test.mjs): it fails on f6a88ec, the only failure of that file there, and passes now

Not verified live

Checks

npm run build, npm run check and npm test (with fake ps, pgrep, kill and gh first on PATH) pass on the head commit.

🤖 Generated with Claude Code

erickb336 and others added 2 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]>
erickb336 and others added 3 commits October 12, 2026 09:25
…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]>
@erickb336
erickb336 merged commit 801434a into main Oct 12, 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.

1 participant