Skip to content

feat(coordinate): compact in place and hand over only when a session can't continue - #2326

Merged
dangazineu merged 6 commits into
mainfrom
ul3-p2-handover-rule
Dec 1, 2026
Merged

dangazineu merged 6 commits into
mainfrom
ul3-p2-handover-rule

Conversation

@dangazineu

Copy link
Copy Markdown
Contributor

Phase 2 of docs/designs/DESIGN-compaction-default-dispatch.md: shirabe's handover rule. Sessions compact in place, and none hands over at a context size below its hard stop. Every worker brief now carries a fixed "Context and handover" section that says when the worker hands over and how. A coordinator gets the matching rule from the coordinate skill itself. When a worker reports cant_continue, its coordinator sends the unit straight to a redispatch that starts from the stopped worker's handoff brief.

This changes nothing about what a session launches with. The window still comes from the dispatch profile, and the section's window: unset branch covers a worker launched before the workspace default exists.


The worker section. render-brief.sh writes the design's section text word for word into every brief whose entry point isn't coordinate, after Workspace rules (or Reporting, when there are none) and before Keep-alive. No input field removes or changes it, and it carries no session id. A coordinate brief, a lane's or a successor's, gets no such heading. The section puts its four command lines in a sh fence, so the brief renders them as code. render-brief_test.sh checks the section word for word in the base, min and leg briefs, where it sits, that it appears once, that it holds no UUID-shaped token, that a size line in the standing rules leaves it unchanged, and that both coordinate briefs lack it. The section order assertion now includes the heading, and the three goldens are regenerated.

The template-heading check. The check that keeps brief-template.md's headings in step with the rendered ones now compares the rendered headings minus Workspace rules and Keep-alive, instead of the first seven. Its illustrative block gains the new heading, so the template file lands in the same commit as the renderer.

Fixture counts. The goldens double as brief-intake fixtures, so the counts derived from them move. The counts in this list are all confirmed by the suites:

  • kept candidates go from 7/11/11 to 17/21/21, and sentences from 56/66/68 to 67/77/79;
  • min's last candidate becomes "Never dispatch your own continuation.";
  • the first intake of each golden writes 17/21/21 rows;
  • the 120-rule-cap case goes from 2 to 12 lines, and its briefs-read row from 5/7 to 5/17;
  • the capped-run gap goes from 7 to 17;
  • brief-kept.json gains the section's 10 sentences in each list.

The intake's excluded-section list doesn't change.

Where the coordinator rule lives. The design names the Roles list in SKILL.md and the wait state's "Handing over" paragraph. Both are held to byte budgets: the skill entry, and the hub state shown at every arrival. Neither has room for the whole rule, so the full rule is a new "Handing over" section in skills/coordinate/references/loop.md. That section covers:

  • the check, and when to run it;
  • the five reasons to hand over;
  • both ways to start a successor (dispatch-worker.sh --successor, or by hand with niwa dispatch --profile coordinator);
  • the message to held workers that size lines no longer apply;
  • the cant_continue route.

SKILL.md and wait each carry a pointer that states the default in its own words: compact in place, hand over only as the rule says. SKILL.md measures 8217 of its 8218 bytes and wait 10794 of its 10802. The design records the placement in one added line.

The cant_continue route. It's prose only, through the existing redispatch event from wait to failure. There's no new event, edge or compatibility change. The failure state says the redispatch input's read_first names handoff-brief.sh read --session <the worker's koto session>.

The rest.

  • dispatch-worker.sh changes comments only: the two that say a worker asks for no profile now add that niwa then applies the workspace's default_dispatch_profile.
  • brief-template.md's profile paragraph says where each role's window comes from, and that a brief states no context size.
  • references/handoff-brief.md gives every role one window and stop (280K and 350K), and records the measured cut point. It corrects the reader's first-read wording: a figure taken on the turn of a cut can be the pre-cut one. Its Workers paragraph now cites the design.
  • PLAN-handoff-brief.md's step 7 and step 8 amendments cite the design. A failing coordinator now sends only itself back to handing over.

…ker briefs

render-brief.sh writes the section from the compaction-default-dispatch
design word for word into every brief whose entry point isn't coordinate,
after Workspace rules (or Reporting) and before Keep-alive. No input field
removes or changes it, and it carries no session id. A coordinate brief gets
none.

The goldens double as brief-intake fixtures, so the kept-sentence counts,
brief-kept.json and the intake cases fed by min.txt move with them.
brief-template.md's illustrative block gains the heading, and its profile
paragraph says where each role's window comes from.
… cant_continue route

A coordinator compacts in place and hands over only when thrash-check.sh
prints cant_continue or for one of the design's other reasons. The full rule
is a new "Handing over" section in references/loop.md: when to run the
check, the reasons, both ways to start a successor, the message to held
workers, and the route for a worker that reports cant_continue (redispatch
at once, its read_first naming the stopped worker's handoff brief). The
Roles list in SKILL.md and the wait state each carry a pointer that states
the default, since both are held to byte budgets. The failure state says how
to redispatch such a unit. The design records the placement.

dispatch-worker.sh's two "no profile" comments now say niwa then applies the
workspace's default_dispatch_profile.
…ult worker profile

references/handoff-brief.md gives every role the same 280K window and 350K
hard stop, records the measured cut point (about 88% to 90% of the window),
says a context-size figure taken on the turn of a compaction can be the
pre-cut one, and has the Workers paragraph cite the compaction-default-dispatch
design: workers take the window from the workspace's default_dispatch_profile.

PLAN-handoff-brief.md's step 7 and step 8 amendments cite the same design:
coordinators take the window from the named coordinator profile, never from
the default, a failing session sends back only itself, and the coordinator
identity read is recorded.
@dangazineu
dangazineu marked this pull request as ready for review December 1, 2026 05:42
@dangazineu
dangazineu merged commit 5656ce0 into main Dec 1, 2026
122 of 127 checks passed
@dangazineu
dangazineu deleted the ul3-p2-handover-rule branch December 1, 2026 07:14
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