Skip to content

Lead build step 2: the state tool learns the lead role (T266) - #123

Merged
erickb336 merged 5 commits into
mainfrom
sage/t266-lead-role
Oct 12, 2026
Merged

erickb336 merged 5 commits into
mainfrom
sage/t266-lead-role

Conversation

@erickb336

@erickb336 erickb336 commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Closes #117

Step 2 of the lead build. The state tool records lead runs and holds their limits. The hook (step 3, #118) and the lead agent (step 4, #119) are not in this PR.

Items and their tests (scripts/sage.test.mjs)

Item Test Fails on main
run add --role lead records a lead run; a second running lead on the task is refused, and the refusal names it T266-LEAD-ONE yes: the second add passes (R2 running)
At most 3 running lead runs per project; the refusal names the 3 T266-LEAD-THREE yes: the 4th add passes (R4 running)
An investigation takes no lead run, with a reason T266-LEAD-INVESTIGATE yes: the add passes
A concluded, merged or abandoned task takes no lead run, and the refusal names the state; a verified task takes one, for its remaining cycles (#62, section 7); other roles keep today's behaviour (chief's decisions on Q1 and Q2) T266-LEAD-STATE yes: the lead on the merged task passes (R1 running)
status counts a lead run; the chat board shows it with its role T266-LEAD-SHOWN yes: the board shows T1 ?
Default max_agents is 4; a config value still wins T266-MAX-AGENTS yes: 3, not 4
taskFor(id, project, env): the task of R or F-T-; undefined for an unknown id, another form, an id on two tasks, or no logbook; a damaged logbook throws (the logbook check) T266-TASK-FOR yes: taskFor is not a function

The default change also updates the default pins in sage.test.mjs and three cap tests in sage-hook.test.mjs (now 4 of 5 spawns pass).

Docs: README rule row, the default in the nested-spawn rule, and a What's new entry; the sage skill's run add and config rows.

Checks

npm run build, npm run check and npm test pass: 859 tests, 0 fail. Tests ran with a fake ps, pgrep and kill first on PATH; the fakes logged no call.

Not verified live

  • No live Claude Code session: the hook does not call taskFor yet (step 3).
  • The rich browser board was not opened; it prints the role string as it is, and the chat board was the one that showed ?.

🤖 Generated with Claude Code

erickb336 and others added 3 commits October 11, 2026 19:50
- run add <T> --role lead: one running lead run per task, at most 3 per
  project, none for an investigation; each refusal names the running leads.
- taskFor(id, project, env): the task of a run id or a finding key, through
  the logbook check; undefined for an unknown id. For the hook's step 3.
- The chat board shows the lead role instead of "?".
- Default max_agents 3 -> 4, so one lead and its 3 children fit.
- README usage guide, sage skill docs and tests updated.

Closes #117

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The chief's decision on Q1. The refusal names the task's state. Other
roles keep today's behaviour. Test T266-LEAD-STATE.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The chief's decision on Q2: a verified task takes a lead for its remaining
cycles (#62, section 7). Concluded, merged and abandoned tasks are refused,
and the refusal names the state. T266-LEAD-STATE covers both sides.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- F-T266-3: run add reads --role as the table stores it (cell() and lower
  case) before the lead checks, and refuses a role that is not a child role
  of roles.mjs or an investigation step.
- F-T266-2: taskFor throws the logbook check's refusal when tasks.tsv is
  lost but other tables have rows (hasRows, shared with ready()).
- F-T266-1: the design page gives the default cap of 4.
- T266-LEAD-RACE: separate processes keep the lead limits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@erickb336

Copy link
Copy Markdown
Owner Author

Repair round 1 (3c082a8):

  • F-T266-3: run add normalizes --role (cell() plus lower case) before the lead checks, and refuses an unknown role with the list. Test: F-T266-3. Note: the list is the roles.mjs child roles plus the two investigation steps (investigate, evidence-review), because the board reads an investigation's runs by those step names.
  • F-T266-2: taskFor throws when tasks.tsv is lost but other tables have rows. Test: F-T266-2.
  • F-T266-1: docs/design/sage-mode.html gives default 4.
  • New: T266-LEAD-RACE, 10 lead run adds at once on 10 tasks (exactly 3 pass) and 2 at once on one task (exactly 1 passes), with separate CLI processes.

npm run build, check and test: 862 tests, 0 fail, fakes first on PATH.

CI saw 130 writes in 3,130 tries, so the 3,000-refusal ceiling failed a
correct run. The ceiling now only stops a run where no write can pass.
The check that the victim file is unchanged stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@erickb336

Copy link
Copy Markdown
Owner Author

CI on 3c082a8 failed in an existing test, F-T42-2: 300 config writes needed fewer than 3,000 refusals, and CI got 130 writes in 3,130 tries. The test raced against a process that swaps config.json, so its pass depended on scheduling. c53be30 raises only the refusal ceiling, to 200,000. The check that the victim file stays unchanged is the same. CI on c53be30 passes.

@erickb336
erickb336 merged commit 69cb227 into main Oct 12, 2026
1 check passed
@erickb336
erickb336 deleted the sage/t266-lead-role branch October 12, 2026 04:16
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 2: the state tool learns the lead role (T181)

1 participant