Skip to content

The sage:lead agent file, with a test that plays it through the hook (T301) - #269

Merged
erickb336 merged 13 commits into
mainfrom
sage/t301-lead-agent
Oct 18, 2026
Merged

erickb336 merged 13 commits into
mainfrom
sage/t301-lead-agent

Conversation

@erickb336

@erickb336 erickb336 commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Closes #119. Step 4 of the lead build (parent task T181): the sage:lead agent file and the docs, so that the sage (the main session) can give one pull request to one background lead, and the lead runs it from the build to verifying.

What changes

  • New agent packages/sage-claude/agents/lead.md (built to plugins/sage/agents/lead.md). It teaches only what the hook on main allows:
    • who starts a lead (only the main session, in the background, as lead-T<n>, for a task with a running lead run);
    • the five helper roles, at most 3 at once, each named by its run id R<n>;
    • the state tool commands that a lead may run, as plain commands from the project's folder, with no --project, no quotes and one-word summaries and reasons;
    • each helper's run in its order: run add, the helper with a full brief, its stop, finding add for each medium or high finding (same source and severity), run done, then the verdict with --run and --pr;
    • the cycle's state moves, the repair round, a helper with no report (--status failed), and what stays the sage's (finding move, a dismissal of a medium or high finding, triage ask, gates, the merge);
    • SendMessage only to main; one report with the seven report fields.
    • It ends with a worked example: one lead's whole life, with a findings cycle, a repair round, a helper that the sage stops, and a clean cycle.
  • The lever: scripts/lead-agent.test.mjs (in npm test). It plays the worked example through the built hook as hook JSON, from the main session's start of lead-T1 to a passing merge-check --sha <sha> --pr 12. Each $ line goes through PreToolUse as the lead's Bash; each state tool command also runs and its PostToolUse goes back to the hook; each → line must match what the tool printed; each helper start, stop and the sage's TaskStop are events too. A second check fails when a code span in the file teaches a sage ... command that the example never runs. A third test shows that the hook refuses what the file says is the sage's (so the passes are not empty).
    • Mutation probe (scratch script, not committed): 8 edits of the built file that disagree with the hook, each killed by the test. For example, a verdict before run done, a quoted summary, checks-pass --run R7 (which takes R7's one verdict), the old draft's "close a dead lead's run", a lead dismissing a medium finding, a wrong printed line, and a taught command that the example never runs.
  • The chief's instructions (Claude bindings only, packages/sage-claude/chief-bindings.json): a sage:lead row in the team, and "One lead for each pull request" in the dispatch step. The chief moves the task to briefed, records the lead run, starts the lead with the state tool's path, the branch, the pages folder and the target, waits for its one report, and keeps the questions, finding moves, ending the runs that the lead names, pages records and the merge. Tiny tasks go through a lead too; investigations get none. The shared core text and the Codex files are unchanged.
  • README (team table, a short lead paragraph, "What's new") and design page (team row, and a new section "One lead for each pull request").

Where the hook differs from the issue 62 draft (the hook wins; no hook rule changed)

  • A fresh lead does not close an earlier lead's open runs: the hook refuses that (F-T289-8). The file says to list them for the sage.
  • A lead cannot run pages: the sage gives the pages folder in the brief and records the pages.
  • checks-pass takes no --run, because a run backs only one verdict.
  • A summary or reason is one word: the hook allows only plain commands.

No normal lead flow is impossible under the hook: the worked example reaches a passing merge check with the default caps (max_agents 4).

Checks

  • npm run build, npm run check: pass.
  • npm test with a fake ps, pgrep, kill and gh first on PATH, in a temp HOME: 1646 of 1647 pass. The one failure is T51 ("PS"), the known limit T299 (T51 fails with a fake ps first on PATH). CI runs without that fake.

What the live check after the merge must still show (from #119)

These need a real Claude Code session; this PR uses hook JSON only and starts no real agent.

  1. A lead's child that tries to start an agent is refused.
  2. A grandchild's hook events carry its own agent_id and agent_type, and the main session's session_id.
  3. The PostToolUse Bash event shape for run add and finding add (the test sends tool_response as { stdout, stderr, interrupted }).
  4. The task_id of TaskStop, for a lead and for a helper.
  5. One small real task runs end to end through a lead.

Known limits, not fixed here: T290, T291 to T297, T299, F-T289-70, F-T289-73.

Repair round 1 (R999)

Head: 52334790e9b520c22af401d939082871dedca478. This round changes one hook rule (F-T301-14) and supersedes the line "no hook rule changed" above. The lead now ends at verifying; the sage records checks-pass after gh pr checks, moves the task to verified and merges.

Finding What changed Test that fails on 481dbde
F-T301-1 medium The example re-runs code-reviewer and QA after round, and has a → line under round. The test records the roles that round names and fails a finding close before each of them re-checked. lead-agent test: "round named a role that has not re-checked" on the old file
F-T301-2 medium lead.md helper step 4, steps 5 and 6, and "When you end blocked": a low finding is dismissed, joins a round, or the lead ends blocked; a re-check's new finding ends it blocked with Left: verifying. Chief bindings step 6: move the findings, set the state, new lead run, fresh lead. A second example plays the blocked path to a passing merge check. mutant "the sage does not move the low finding" killed
F-T301-3 low The test plays the file's state table (every pair of 15 states), verdict table (8 report cases) and helper cap against the hook. README now names these checks. old file: state table differs; mutants on each table killed
F-T301-4 low Bindings step 1: move a held task first, then record the lead run, with the reason. text only
F-T301-5 low "When you end blocked": an unreadable report, failing or running checks, the cap with runs added and not started. text only
F-T301-6 low checks-pass is the sage's: removed from the lead's commands and example; the example has the sage's ! sage verdict ... checks-pass. The test fails a $ line with a checks verdict until T302 makes the hook refuse it. mutant "the lead records checks-pass" killed
F-T301-7 low tools: Bash, Read, Grep, Glob, Agent, SendMessage replaces disallowedTools; check and build accept it. lead-agent test "only the tools that a lead needs" fails on the old file
F-T301-8 low Step 1: sage logbook, then cat <logbook>/runs.tsv, findings.tsv, ledger.tsv; the blocked example's fresh lead runs them for real. mutant with a missing file killed
F-T301-9 low Step 3: a large task starts 3, then the fourth; helper step 1: add a run only when its helper can start now. helper cap test
F-T301-10 low Wait for every helper before the next step; cycle 2 on the same SHA; CI failing or running ends blocked. text only
F-T301-11 medium Bindings step 3 and lead.md: each lead and helper takes a slot of max_agents (4 by default, sage config); with the default cap one lead at a time. test: a second lead is refused under the default cap
F-T301-12 low Bindings: no other agent for a task with a running lead; check the report against sage status and the logbook; after stopping a lead, end its helper runs. text only
F-T301-13 low README's two stale "comes later" lines removed; README and lead.md describe the tiny route and a re-check that does not confirm a fix. text only
F-T301-14 medium Hook: a sage:lead's TaskStop is refused ("a lead stops no agent: only the main session does ..."); the main session's TaskStop is unchanged. hook test F-T301-14 fails on the old hook
F-T301-15 Taught forms now include git, gh, cat and node <path to skills/sage/sage.mjs> ... spans. mutants with a git and a node form killed
F-T301-16 A form must match a whole command the lead ran (not a prefix, and not a command that only the sage ran). mutant with a prefix form killed
F-T301-17 git, gh and cat lines run (gh against a fake that knows only gh pr checks <n>); each → line compares only with the line just before it. 4 mutants killed
F-T301-18 README and design page say what the lead does with each low finding. text only

Mutation probe (scratch, not committed): 22 edits of the built lead.md, all killed.

Checks: npm run build and npm run check pass. npm test on this head with fake ps, pgrep, kill and gh first on PATH, in a temp HOME: 1651 of 1652 pass. The one failure is T51, the known limit T299.

Repair round 2 (R1007)

Head: 63da787873b332ba18588f5e1d2aac6cdec71e7a. One hook rule widens (F-T301-27); the rest is text in the lead file, the chief bindings, the README and the design page, and tighter checks in scripts/lead-agent.test.mjs.

Finding What changed Evidence
F-T301-19 medium (D1) lead.md step 5 and "When you end blocked", bindings step 6: the sage moves only a low finding or a new one from a re-check, never a high one, and never a finding in the round's fix keys. When such a fix is still open and the task is repairing, the sage moves the task back to reviewing, so the fresh lead's sage round <T> gives the next round, replan or held. New test "T301 D1": the path ends in replan, no merge. Probe S1 with the new sage steps: T1 replan: round 1 did not fix F-T1-1. A state tool backstop comes in T302.
F-T301-20 low, F-T301-23 medium (D2) "set the state that its RESULT names" is gone from the bindings and the docs. Left: only describes. The blocked example says that the sage sets no state and the fresh lead goes on to step 6. The test fails a sage state move after a blocked report, except repairing to reviewing (mutant M6 now killed by this check). Probes s1 and s3 with the new sage steps reach a passing merge check, s3 with a cycle on the repair's head.
F-T301-24 medium (D3) Bindings step 6: the CI failure finding is sage finding add <T> --source qa --severity medium, so round names QA, which re-checks it on the repair's head. New test "T301 D3" plays the path to a passing merge check (fake gh: fail, then pass). Probes s9 and CF1 with the new step: re-run qa on the repair's diff.
F-T301-30 medium lead.md step 1 and the blocked example: cat <logbook>/tasks.tsv for the state, branch, PR, round and fix keys; where to go on from each state; take --pr from tasks.tsv. Bindings step 2: the brief gives the task's state, branch and PR (from sage task <T>). The taught-form check runs the new cat line through the hook. Probe l3n with the new step 1 reaches a passing merge check.
F-T301-21 low Bindings step 5: the head SHA comes from gh pr view <n> --json headRefOid (or git rev-parse <branch>), compared with the report; a difference starts a fresh lead. text only
F-T301-22 low lead.md step 6: end ready only when no helper runs. Bindings steps 4 and 5: end only a run with no live helper; after a ready report with a running run of the task, record no verdict. text only (the hook backstop is T302)
F-T301-25 low The → check compares word by word. Mutant M1 (→ R1 for R10) killed; it survived on 5233479.
F-T301-26 low The test checks the run add line that the file states, the default cap from sage config (not a literal), every kind that a verdict row names, and the lead's RESULT words. Mutants M2, M3, M5, M7 killed; all survived on 5233479.
F-T301-27 low Hook: an agent's TaskStop is refused when its target is an agent (R<n>, lead-T<n>, main, or an agent id that a slot holds). A shell task id still passes. Hook test F-T301-27 fails on 5233479 (actual undefined) and passes now. Probe I: all five agent targets refused on the new head, all allowed on 5233479; the shell id passes on both.
F-T301-28 low Bindings step 6: while the checks run, wait and check again; when they pass, set verifying if the task is at reviewing, then checks-pass and verified. Probe CP1 with the new steps: T1 may merge.
F-T301-29 low Team row: the lead works to verifying. Bindings: check the cap before run add of a lead run; after a TaskStop of a lead, end its own lead run. Probe CAP1 with the new step: no stray lead run, no refusal.
F-T301-31 low One rule for a low finding, also from a re-check: dismiss it, let it join a round, or list it and end blocked. No CI checks: the lead says so and ends blocked with Left: the checks; the sage decides and logs it. text only
F-T301-32 low lead.md names the rules that the hook holds, and marks three as text only until T302: the checks verdict, a re-check gets no verdict, no end while a helper runs. text only

Mutation probe (scratch): M1 to M7 all killed on this head; M1, M2, M3, M5 and M7 survived on 5233479.

Checks: npm run build and npm run check pass. npm test with fake ps, pgrep, kill and gh first on PATH and a temp HOME: 1654 of 1655 pass on this head. The one failure is T51, the known limit T299.

Repair after replan (R1014)

Head: 014efdb5b402ae1ec1cb91e6098dc7cdfcd17ac5.

The new premise. Two repair rounds each found one more task state that the lead file did not route. So this round stops adding states:

  1. One catch-all rule in lead.md. Step 1 routes only the common states: building, reviewing (open fix, cycles to run, cycles done), repairing with an open fix key, and verifying with the clean cycles on the head. In any other state, or after any answer that the file does not name, the lead ends at once with STATUS blocked, RESULT blocked, its task row from tasks.tsv and what it saw. It does not work around it. The sage decides from the logbook.
  2. The safety rules in code. The TaskStop rule reads shell_id too and any letter case; the state tool refuses a move of an open fix of the round. The sage's only state moves from the logbook after a blocked report are repairing to reviewing (an unconfirmed fix) and reviewing to verifying (the checks passed). The test reads these moves and the sage's commands from the chief bindings.
Finding What changed Evidence
F-T301-33 medium Hook: the agent TaskStop rule trims and lower-cases the id before the name test (r<n>, lead-t<n>, main) and the slot test. Hook test "F-T301-33, F-T301-34" fails on 63da787 (task_id "r6"), passes now. Probe I: r4, R04, R4, Lead-T1, LEAD-T1, Main, main, lead-T01 allowed on 63da787, refused now; b7k2x9 passes on both.
F-T301-34 medium Hook: the rule reads task_id ?? shell_id, refuses both with different values, and a lead's TaskStop by either field. The main session's stop by shell_id frees the slot. Same hook test (shell_id forms, both fields, main session's shell_id stop then run done --status failed). Probe J: four shell_id targets allowed on 63da787, refused now.
F-T301-36 medium Catch-all. The sage triages its CI finding fix, so the fresh lead sees "reviewing with an open fix" and goes to step 5. Test D3 now follows step 1 (no lead triage): fails on 63da787, passes now.
F-T301-43 medium Step 5: once every fix key is closed, move to reviewing before anything else, also before ending blocked. The catch-all covers the rest. Story ln2bB-N: lead moves to reviewing, ends blocked; fresh lead's round gives round 2.
F-T301-47 medium Catch-all: verifying with no clean cycle on the head is not a named state. Story BR2a-N: the fresh lead ends blocked; the stop gate passes the report.
F-T301-40 low State tool: finding move refuses an open finding in the task's round keys, at any severity. lead.md says the state tool holds it. sage.test "F-T301-40" fails on 63da787, passes now. Stories ln5-N and BR1c-N: the sage's move of F-T1-1 is refused.
F-T301-44 medium (decision) The lead records the repeat and names it repeat of F-x; the sage dismisses it with "duplicate of F-x" and keeps F-x. An unconfirmed fix gets the next round, or a replan when no key of the round was fixed. Test D1 plays it to replan: fails on 63da787, passes now. Stories ln5-N, BR1c-N: replan.
F-T301-37 low Bindings: before moving a new finding, check that the round closed no fix key with the same source; if it did, triage it fix, do not move it. Story ln2bB-N. Text.
F-T301-38 low Bindings step 5: the PR number comes from tasks.tsv, never from the report. Text.
F-T301-39 low The test takes the sage's commands after each blocked report (CI failure, duplicate, the two moves) from the chief bindings' code spans, and the guard allows only the moves that the bindings list. Mutants of the built bindings, all killed: --source qa changed (D3), a move dropped, changed or added (relation test, checks-still-run test), the duplicate reason (D1), the CI triage removed (D3).
F-T301-41 low README and the refusal: a helper stops its own shell tasks; a lead stops none ("a lead stops no task, also no shell task"). Hook tests F-T301-14 and F-T301-33/34.
F-T301-42 low Settled by the two named moves; the checks-still-run step uses the reviewing-to-verifying move. New test "T301 checks still run" plays it to a passing merge check.
F-T301-45 low (decision) No CI: the sage logs the decision with a why, records checks-pass itself, then verifying and verified. Story CP2-N: T1 may merge.
F-T301-46 low The sage's own multi-word values are quoted (--summary "<words>", --reason "duplicate of F-<x>", --to "<title>", sage log). The test reads a quoted value as one word. Tests D3 and D1 play quoted values.
F-T301-35 medium (decision, follow-on d5c0c8c) An unconfirmed low fix key: the lead ends blocked and lists it, and never dismisses a fix key (lead.md step 5). Bindings step 6: after the move from repairing to reviewing, the sage frames the follow-up with sage task add and dismisses the key with "unconfirmed low fix, carried by follow-up T". The hook backstop for a lead's dismissal is T302. New test "T301 F-T301-35" plays the path to the fresh lead at verifying, with the sage's commands read from the bindings: fails on 014efdb ("step 6 has no sage task add ..."), passes on d5c0c8c.

F-T301-35 is fixed in the follow-on commit d5c0c8c (the row above).

Checks: npm run build and npm run check pass. npm test (alarm 900) with fake ps, pgrep, kill and gh first on PATH and a temp HOME: 1658 of 1659 pass. The one failure is T51, the known limit T299.

Repair round 3 (R1025)

Head: eb81fe55de0dee6e5a7c7731d06a3f89a726dd19. The replan premise stays: step 1 routes the common states, any other state ends the lead blocked, and the sage decides from the logbook. This round supersedes the decision of F-T301-44 above: the sage never dismisses a finding because the lead calls it a repeat.

Finding What changed Test that fails on d5c0c8c
F-T301-55 high (also -52, -56) Bindings step 6: a finding that the lead names repeat of F-<x> is triaged fix, at any severity, and joins the next round with F- (or the replan). The duplicate dismissal is gone from the bindings, lead.md, the README and the design page. In lead.md, repeat of F-<x> is only information for the sage. lead-agent "F-T301-55: a high finding ... stays open": the repeat stays open, set state=verifying and the merge check refuse, round 2 fixes it. D1 and "F-T301-56, F-T301-59" too.
F-T301-48 medium lead.md step 2: at building, skip the move to building; with a done implementer run and the PR, go on to set state=reviewing pr=<n> (no pr= when tasks.tsv has it). lead-agent "F-T301-48"
F-T301-49 medium State tool: verifying may go back to reviewing. Hook: a lead makes that move only when the branch head has no clean verdict. lead.md step 1 and the state table route "verifying or verified, clean cycles not on the head". Bindings step 5: a moved head gets no verdict and a fresh lead. lead-agent "F-T301-49" (refused on the clean head, passes after a commit, merges after a new cycle); sage.test "F-T301-49"; hook test F-T273-7
F-T301-59 medium Bindings step 6 and the state tool: a low fix key of the round is not dismissed while a medium or high fix finding of the task is open; it joins the next round. Round still re-plans when the round fixed nothing. sage.test "F-T301-59" (R1020 A refused, then replan); lead-agent "F-T301-59" and "F-T301-56, F-T301-59"
F-T301-50 low lead.md step 1: repairing with every fix key closed: set state=reviewing, then the list again. lead-agent "F-T301-50"
F-T301-51 low The relation test compares the moves that the tests play with the bindings' moves (no list of test names). lead-agent "F-T301-51"
F-T301-53 low Hook: TaskStop names go through NFKC, lose format characters, are trimmed and lower-cased; slot ids compare case-folded. hook test "F-T301-53"
F-T301-54 low Hook: the main session's stop of a look-alike of lead-T<n> stops that lead. hook test "F-T301-54"
F-T301-57 low Hook: a lead's helper name must be its run id R<n>. The hook test fixtures name their leads' children by a run. hook test "F-T301-57"
F-T301-58 low Bindings step 5: a failed, running or missing check goes the way of step 6's checks. lead.md step 1: verifying with an open fix goes to step 5 (round). lead-agent "F-T301-58"
F-T301-60 low Hook: a lead's dismissal of a fix key of the round is refused. hook test "F-T301-60"
F-T301-61 low State tool: the move refusal does not apply while the task is held or in replan; its text no longer promises a next round. sage.test "F-T301-61"; "F-T301-40" (new text)
F-T301-62 low SKILL.md: the finding move row and the triage row give the new rules. text

Probes re-run on this head (scratch R1025): R1021 P1 to P3 (the old dismissal step no longer exists; with the new step each repeat stays open and round 2 fixes it; P3's merge check refuses), R1020 A (dismissal refused, then replan), A0 (replan), B (move passes while held), C (refused with the new text), R1017 P1 to P3, R1018 runK and runL, R1022 BLD2, HELD2, STALE1 and BR1c2: each gives the expected answer.

Checks: npm run build and npm run check pass. npm test (alarm 900) with fake ps, pgrep, kill and gh first on PATH and a temp HOME: 1673 of 1674 pass. The one failure is T51, the known limit T299; it fails the same way on d5c0c8c.

Repair round 4 (R1032)

Head: 6b9e166. The premise stays. This round puts the owner's answer in front of a fix key's move, in code, and supersedes F-T301-61 above (no more held or replan exception).

Finding What changed Test that fails on eb81fe5
F-T301-65 medium State tool: finding move of a fix key of the round, in any state, needs an answered gate of the task whose question names the key as a word and whose answer is its first option. The held or replan exception is gone. Bindings step 6: ask with sage gate add <T> --question "Move <K> to a follow-up task?" --options "move|keep", move after the answer. The stale sentence "the state tool never moves a fix key" is fixed in the bindings and lead.md. sage.test "F-T301-65" (no gate, unanswered gate, a gate of another task, of another key, answered with a later option: refused; answer move: moved; in repairing, held and replan); lead-agent "F-T301-65" plays the bindings' gate. R1030 probe A: moved on eb81fe5, refused now until the answer.
F-T301-69 medium Bindings step 5: the head comes from gh pr view <n> --json headRefOid; when it differs, the sage runs git fetch origin <branch>, then git -C <folder> merge --ff-only origin/<branch> (branch in a worktree) or git fetch origin <branch>:<branch>, and asks the user with a gate when git refuses. The hook already allows these to the main session: no hook change. lead-agent two "F-T301-69" tests (a bare remote, a GitHub-only commit, the fake gh's pr view): the step's commands pass the hook, the fresh lead sees the new head and the task merges; the worktree form; a non-fast-forward is refused. R1026 P1: the fresh lead loops on the old head on eb81fe5; now it moves back to reviewing.
F-T301-66 low The low key's dismissal waits for any open medium or high finding of the task, in any triage and any state. sage.test "F-T301-59, F-T301-66" (untriaged, ask, high, replan). R1027 runX-none and runX-ask: dismissed on eb81fe5, refused now.
F-T301-67 low, F-T301-75 low Hook: the lead's move back to reviewing, from verifying or verified, is refused only when the head has a full clean cycle, counted by the state tool's own cleanCycles (the merge check's count, now one function). lead-agent "F-T301-67, F-T301-75". R1028 m_verified_same_probe: allowed on eb81fe5, refused now.
F-T301-68 low, F-T301-70 low Bindings: a low repeat is triaged fix like any repeat, never dismissed with the key; with no round, the sage moves it. lead-agent "F-T301-35, F-T301-68". R1030 C2: bindings text.
F-T301-71 low Hook: the main session stops a lead only by lead-T<n> exactly, letter case folded. hook "F-T301-54, F-T301-71". R1027 runL-d: the look-alike no longer frees lead-T1's slot.
F-T301-72 low Hook: a lead does not dismiss a finding triaged fix that is older than the round (a key of an earlier round, also after a replan). hook "F-T301-72". R1027 runY: allowed on eb81fe5, refused now.
F-T301-73 low Hook: repairing to reviewing needs every fix key closed, also a low one. hook "F-T301-73". R1028 x_med_fixed_low_unconf_move: allowed on eb81fe5, refused now.
F-T301-74 low Design page and README: the real path of an unconfirmed low fix. text
F-T301-76 low New tests kill R1029's D2 to D5, HV3, HV4 and HT4 (as rewritten for the new code). Mutation run (scratch R1032 drive3.py): 23 of 23 mutants killed.

Checks: npm run build and npm run check pass. npm test (alarm 900) with fake ps, pgrep, kill and gh first on PATH and a temp HOME: 1680 of 1681 pass. The one failure is T51, the known limit T299.

🤖 Generated with Claude Code

erickb336 and others added 4 commits October 17, 2026 18:33
…le through the hook (T301)

The lead's file teaches only what the hook allows: each helper's run in its
order, one-word summaries, the cycle's state moves, and the sage's own steps.
scripts/lead-agent.test.mjs plays the file's worked example as hook events,
from the main session's start of lead-T1 to a passing merge check, and checks
that every state tool command that the file teaches runs in that example.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The chief records a lead run, starts lead-T<n> in the background with the
state tool's path, the branch, the pages folder and the target, waits for its
one report, and keeps the questions, the follow-up tasks and the merge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd, for the sage to move (T301)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@erickb336 erickb336 changed the title T301-lead-agent The sage:lead agent file, with a test that plays it through the hook (T301) Oct 18, 2026
erickb336 and others added 9 commits October 17, 2026 20:18
…ist; the test plays both examples and the tables against the hook (T301 repair round 1)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… report, the agent cap and the order of a held task's moves (T301 repair round 1)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…k (F-T301-27)

A helper's TaskStop of a sibling, its lead or main passed the hook. Now an
agent's TaskStop is refused when its target is an agent: R<n>, lead-T<n>,
main, or an agent id that a slot of the session holds. Shell task ids pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rmed fix, CI failure for QA, tasks.tsv; tighter test (T301 repair round 2)

- D1 (F-T301-19): a fix of the round that the re-check did not confirm is
  never moved; the sage moves the task back to reviewing and round decides.
- D2 (F-T301-20, F-T301-23): the sage takes no state from a lead report.
- D3 (F-T301-24): a CI failure finding has the source qa.
- F-T301-21, -22, -28 to -32: head SHA from gh pr view, no live helper,
  running checks, no CI, cap before a lead run, tasks.tsv and the PR in the
  brief, one low rule, the narrowed hook claim.
- Test (F-T301-25, -26): arrow lines word by word, the run add format, the
  default cap from sage config, each verdict row kind, the RESULT words, and
  the D1 and D3 paths through the hook.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e (T301 repair after replan)

The new premise: stop adding task states to the lead file. Step 1 routes the
common states only, and any other state or answer ends the lead blocked at
once; the sage decides from the logbook. Its only state moves there are
repairing to reviewing and reviewing to verifying, and the test reads them
and the sage's commands from the chief bindings.

- Hook: an agent's TaskStop reads task_id or shell_id, refuses both with
  different values, and matches names in any case and with spaces; a lead
  stops no task; the main session's stop by shell_id frees the slot
  (F-T301-33, F-T301-34, F-T301-41).
- State tool: finding move refuses an open fix of the round (F-T301-40).
- Text: catch-all, reviewing before ending once every fix key is closed,
  repeat of a fix dismissed as a duplicate, CI finding triaged fix, PR from
  tasks.tsv, no-CI checks-pass, quoted values (F-T301-36 to F-T301-47).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y (T301, F-T301-35)

A low fix key that the re-check did not confirm had no path: a round with
only low fixes is refused, verifying is refused while it is open, and the
state tool refuses its move. Step 6 of the chief bindings now has the sage
frame the follow-up with sage task add, then dismiss the key with the reason
"unconfirmed low fix, carried by follow-up T<n>". The lead file says that a
lead ends blocked and never dismisses a fix key. A new test plays the path
from the chief bindings' own commands to the fresh lead at verifying.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ack to reviewing, look-alike stops (T301)

- F-T301-55, -52, -56: the sage never dismisses a finding because the lead calls it a repeat of a fix key; it triages it fix, and it joins the next round. The duplicate dismissal is gone from the chief bindings, lead.md, the README and the design page.
- F-T301-59: a low fix key of the round is not dismissed while a medium or high fix finding of the task is open (state tool and chief bindings); round still re-plans when the round fixed nothing.
- F-T301-48, -50: lead.md step 1 and step 2 route a fresh lead at building and at repairing with every key closed.
- F-T301-49: verifying goes back to reviewing (state tool); a lead makes that move only when the head has no clean verdict (hook); lead.md and the chief's step 5 route a moved head there.
- F-T301-58: the chief's step 5 sends a failed check to step 6's way.
- F-T301-53, -54: TaskStop names go through NFKC, lose format characters, are trimmed and lower-cased; slot ids compare case-folded; the main session's stop of a lead-T<n> look-alike stops that lead.
- F-T301-57: a lead's helper name must be its run id.
- F-T301-60: a lead never dismisses a fix key of the round.
- F-T301-61, -62: finding move of a round key passes while the task is held or in replan, and its refusal no longer promises a next round; SKILL.md says so.
- F-T301-51: the move relation test compares the moves that the tests play with the bindings' moves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…heads come in, exact lead stops (T301)

- State tool: finding move of a round's fix key needs an answered gate that names it (first option), in any state;
  a low key's dismissal waits for any open medium or high finding, any triage, any state (F-T301-65, -66).
- Hook: the lead's move back to reviewing from verifying or verified needs a head without a full clean cycle, as
  the merge check counts it; repairing to reviewing needs every key closed, also a low one; a lead does not
  dismiss a key of an earlier round; the main session stops a lead only by its exact name (F-T301-67, -71 to -75).
- Chief bindings: step 5 brings GitHub's head into the local branch before a fresh lead; a low repeat is triaged
  fix and moved, never dismissed with the key; the gate before a key's move (F-T301-65, -68 to -70).
- Docs: lead file, SKILL.md, README, design page (F-T301-74). Tests for each.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@erickb336
erickb336 merged commit 194b7c8 into main Oct 18, 2026
1 check passed
@erickb336
erickb336 deleted the sage/t301-lead-agent branch October 18, 2026 12:30
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.

Lead build step 4: the sage:lead agent file and the docs (T181)

1 participant