Repository navigation
The sage:lead agent file, with a test that plays it through the hook (T301) - #269
Merged
Merged
Conversation
…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]>
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]>
… helper (F-T301-14) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #119. Step 4 of the lead build (parent task T181): the
sage:leadagent 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
packages/sage-claude/agents/lead.md(built toplugins/sage/agents/lead.md). It teaches only what the hook on main allows:lead-T<n>, for a task with a running lead run);R<n>;--project, no quotes and one-word summaries and reasons;run add, the helper with a full brief, its stop,finding addfor each medium or high finding (same source and severity),run done, then the verdict with--runand--pr;--status failed), and what stays the sage's (finding move, a dismissal of a medium or high finding, triage ask, gates, the merge);main; one report with the seven report fields.scripts/lead-agent.test.mjs(innpm test). It plays the worked example through the built hook as hook JSON, from the main session's start oflead-T1to a passingmerge-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 asage ...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).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.packages/sage-claude/chief-bindings.json): asage:leadrow 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.Where the hook differs from the issue 62 draft (the hook wins; no hook rule changed)
pages: the sage gives the pages folder in the brief and records the pages.checks-passtakes no--run, because a run backs only one verdict.No normal lead flow is impossible under the hook: the worked example reaches a passing merge check with the default caps (
max_agents4).Checks
npm run build,npm run check: pass.npm testwith a fakeps,pgrep,killandghfirst 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.
agent_idandagent_type, and the main session'ssession_id.run addandfinding add(the test sendstool_responseas{ stdout, stderr, interrupted }).task_idof TaskStop, for a lead and for a helper.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 aftergh pr checks, moves the task to verified and merges.round, and has a→line underround. The test records the roles thatroundnames and fails afinding closebefore each of them re-checked.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.! sage verdict ... checks-pass. The test fails a$line with a checks verdict until T302 makes the hook refuse it.tools: Bash, Read, Grep, Glob, Agent, SendMessagereplacesdisallowedTools; check and build accept it.sage logbook, thencat <logbook>/runs.tsv,findings.tsv,ledger.tsv; the blocked example's fresh lead runs them for real.max_agents(4 by default,sage config); with the default cap one lead at a time.sage statusand the logbook; after stopping a lead, end its helper runs.sage:lead's TaskStop is refused ("a lead stops no agent: only the main session does ..."); the main session's TaskStop is unchanged.git,gh,catandnode <path to skills/sage/sage.mjs> ...spans.gh pr checks <n>); each→line compares only with the line just before it.Mutation probe (scratch, not committed): 22 edits of the built lead.md, all killed.
Checks:
npm run buildandnpm run checkpass.npm teston 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 inscripts/lead-agent.test.mjs.sage round <T>gives the next round, replan or held.T1 replan: round 1 did not fix F-T1-1. A state tool backstop comes in T302.Left:only describes. The blocked example says that the sage sets no state and the fresh lead goes on to step 6.sage finding add <T> --source qa --severity medium, soroundnames QA, which re-checks it on the repair's head.re-run qa on the repair's diff.cat <logbook>/tasks.tsvfor the state, branch, PR, round and fix keys; where to go on from each state; take--prfrom tasks.tsv. Bindings step 2: the brief gives the task's state, branch and PR (fromsage task <T>).catline through the hook. Probe l3n with the new step 1 reaches a passing merge check.gh pr view <n> --json headRefOid(orgit rev-parse <branch>), compared with the report; a difference starts a fresh lead.→check compares word by word.→ R1for R10) killed; it survived on 5233479.run addline that the file states, the default cap fromsage config(not a literal), every kind that a verdict row names, and the lead's RESULT words.R<n>,lead-T<n>,main, or an agent id that a slot holds). A shell task id still passes.actualundefined) and passes now. Probe I: all five agent targets refused on the new head, all allowed on 5233479; the shell id passes on both.T1 may merge.run addof a lead run; after a TaskStop of a lead, end its own lead run.Left: the checks; the sage decides and logs it.Mutation probe (scratch): M1 to M7 all killed on this head; M1, M2, M3, M5 and M7 survived on 5233479.
Checks:
npm run buildandnpm run checkpass.npm testwith 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:
blocked, its task row from tasks.tsv and what it saw. It does not work around it. The sage decides from the logbook.shell_idtoo 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.r<n>,lead-t<n>,main) and the slot test.task_id "r6"), passes now. Probe I:r4,R04,R4,Lead-T1,LEAD-T1,Main,main,lead-T01allowed on 63da787, refused now;b7k2x9passes on both.task_id ?? shell_id, refuses both with different values, and a lead's TaskStop by either field. The main session's stop byshell_idfrees the slot.shell_idstop thenrun done --status failed). Probe J: fourshell_idtargets allowed on 63da787, refused now.roundgives round 2.finding moverefuses an open finding in the task's round keys, at any severity. lead.md says the state tool holds 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.--source qachanged (D3), a move dropped, changed or added (relation test, checks-still-run test), the duplicate reason (D1), the CI triage removed (D3).T1 may merge.--summary "<words>",--reason "duplicate of F-<x>",--to "<title>",sage log). The test reads a quoted value as one word.d5c0c8c)sage task addand dismisses the key with "unconfirmed low fix, carried by follow-up T". The hook backstop for a lead's dismissal is T302.sage task add ..."), passes on d5c0c8c.F-T301-35 is fixed in the follow-on commit
d5c0c8c(the row above).Checks:
npm run buildandnpm run checkpass.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.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.set state=verifyingand the merge check refuse, round 2 fixes it. D1 and "F-T301-56, F-T301-59" too.set state=reviewing pr=<n>(nopr=when tasks.tsv has it).set state=reviewing, then the list again.lead-T<n>stops that lead.R<n>. The hook test fixtures name their leads' children by a run.finding moverow and the triage row give the new rules.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 buildandnpm run checkpass.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 moveof 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 withsage 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.gh pr view <n> --json headRefOid; when it differs, the sage runsgit fetch origin <branch>, thengit -C <folder> merge --ff-only origin/<branch>(branch in a worktree) orgit 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.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.cleanCycles(the merge check's count, now one function).lead-T<n>exactly, letter case folded.Checks:
npm run buildandnpm run checkpass.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