Repository navigation
Description
Task: T181, step 2 of 4 (the lead build) · small · risk flag: auth · waits for #102 (step 1 follow-ups). Start after #102 merges.
Where this fits
Design: the lead-per-PR loop, in the comments on #62 (sections 6 and 8). Step 1 (#62) put the nested spawn rules in the hook. #102 fixes its follow-ups. This step (#117) teaches the state tool the lead role. Step 3 (#118) adds the hook's write list for leads. Step 4 (#119) adds the sage:lead agent file.
Live check result (#68, run R844)
In a real Claude Code session with sage mode on, a general-purpose child tried to start a grandchild (general-purpose, then sage:implementer). The hook refused both with "only a lead may start an agent", before any agent started. So a direct child's events carry agent_id, and they carry the main session's session_id (the hook loaded the main session's sage state for them). A grandchild's events could not be checked, because no lead exists yet. Step 4 checks them.
Goal
run add <T> --role leadrecords a lead run. One running lead run per task. A lead run counts toward the limits in T181 step 1: Lead build: the hook applies the spawn rules to nested agents #62 section 6 (at most 3 leads per project).- The state tool can say which task a run id or a finding key belongs to, so the hook (step 3) can check "own task only" for each command. Give one function in
packages/sage-core/state.mjs, exported through the publicsage-coreentry point. statusand the board show a lead run like any other run, with its role.
Not in scope
The hook's write list (step 3). The agent file and the docs (step 4). The hook itself.
Acceptance
- A test for each goal item, which fails on main and passes on the branch.
- The existing state tool tests still pass.
Rules for every sage task
- Edit the sources only (
packages/,principles/,writing/,preferences/). Never edit build output. Runnpm run build,npm run checkandnpm test. - Tests that touch processes use a fake
ps,pgrepandkillfirst on PATH. No flaky tests. Never pass a test string to a real shell. - Use repo paths only in the PR: the repo is public. Commit with your no-reply identity.
- Branch
codex/t181-step2. The PR title ends with "(T181)", and the body has "Closes Lead build step 2: the state tool learns the lead role (T181) #117". - Risk flag: auth. The sage runs 2 clean review cycles before it lands the PR.
Activity
erickb336 commentedon Oct 12, 2026
Note from the sage (Claude), for Codex: the sage builds this step itself, after PR #121 (#102) merges, because each step needs a live check in Claude Code. Please do not start it.