Repository navigation
Commit 399fb59
authored
Supervise Sasu runs through hcoord (#8)
* Start the hcoord daemon after a manual stop by converging its LaunchAgent
launchd refuses to bootstrap a label it already has loaded with
'5: Input/output error', and a stopped hcoord daemon keeps its label
loaded, so 'hcoord daemon start' after 'hcoord daemon stop' failed with
start_failed. The supervisor's LaunchAgent convergence already reads the
loaded state first; it moves to cli/src/support/launchd.ts and the hcoord
start converges on its plist and then kickstarts. The fake launchctl now
answers a second bootstrap of a loaded label the way launchd does.
* Check hcoord registration before dispatch creates a pane
An hcoord-supervised dispatch now refuses before any pane or agent exists
when the coordinator cannot take the run: a stopped daemon, an Observer
pane without a Herdr agent name (dispatch used to invent the name
'observer', which hcoord refused after the implementor had started), or an
Observer the coordinator cannot deliver to. 'hcoord sasu preflight' runs
those checks without saving anything.
The implementor's exact identity is recorded before registration, so a
refusal that can only happen after start leaves a started record that
--resume-handoff registers and hands off. Resume also stopped demanding a
legacy supervisor enrollment, which refused every hcoord resume.
Registration now carries the patrol interval as the watch interval, the
recovery owner, slug, state path, and the replaced dispatch, and the run
binding is readable with 'hcoord sasu show/list'. The Observer registers
without a project so one Observer can supervise runs in several trees.
Dispatch appends the hcoord notice forewarning to the handoff, status shows
the coordinator registration, notify-only requests arrive as HCOORD_NOTICE,
and a Sasu watch check names the run's digest command.
* Send plan, block, and report to the Observer through hcoord
On an hcoord-supervised run 'sasu implement plan' records its event and
then sends the Observer an HCOORD_NOTICE naming the plan file. The new
'sasu implement block' carries the OBSERVER_BLOCK fields as a waiting
hcoord question; the Observer answers it, or escalates and records a
person's words as the human answer with itself as recorder and relays
them, and the implementor acknowledges the delivery. The new
'sasu implement report' tells the Observer the current verification verdict
right before the final report and declares nothing complete.
Each notice's intent is fixed by the run, the event kind and the body, and
the same content reuses its Sasu event, so a rerun sends nothing twice. A
stopped daemon keeps the letter for later; a refusal fails the command with
its reason and retry while the Sasu record stays. Legacy runs keep
OBSERVER_BLOCK and their tick wake.
Test children no longer inherit the developer's SASU_RUN_INSTANCE_ID.
* Move, end, and show hcoord supervision through the run lifecycle
'sasu supervisor handover' on an hcoord run first asks the coordinator to
move the watch to the new Observer's exact execution, together with the
questions the implementor still waits on; until then the old Observer's
place receives nothing. A replacement dispatch names the dispatch it
replaces so the coordinator stops watching the gone implementor in the same
save. 'sasu implement retire' and a completed ship delivery end the run's
watch and cancel what it left open; a refusal names its retry.
'status --digest' adds the supervision owner and the coordinator's own
record of the watch: participants, interval, open cycle, and last closed
cycle. 'sasu supervisor status' lists hcoord-owned runs by slug from the
coordinator, and flags a stopped daemon while any is active.
* Document hcoord supervision for the Observer and the Implementor
The Observer reference gains an hcoord Supervision section: how dispatch
pins the owner and checks the coordinator before any pane, which notices
arrive and what each asks, how a block is answered by the Observer or by a
person recorded verbatim and relayed, and how recovery, handover, retire,
and delivery work on an hcoord run. The legacy supervisor tick is labeled
as applying to legacy runs only. The skill entrypoint names block and
report, and docs/hcoord.md lists the Sasu subcommands.
* Keep a person's unrelayed answer and a stopped cycle consistent across Sasu handover and end
Review of 1027cf8 found two ledger gaps. A handover moved only open
questions, so an answer a person had recorded through the old Observer
but not yet relayed stayed owed to a session that had left; the new
Observer now becomes its intermediary and receives the answer to relay.
Ending a run whose watch a person had already stopped mid-cycle canceled
the cycle's request but left the watch pointing at it; the watch's cycle
is now cleared whenever the run ends.
* Deliver to an idle or done execution when Herdr reports no readiness flag
Herdr 0.9.1 reports interactive_ready only for agents it started, so a
hand-started Observer never received hcoord deliveries. One readiness rule
now covers delivery and preflight: a missing flag with idle or done state
delivers, an explicit false holds, and busy states hold. Spawn paths keep
waiting for an explicit true. The Sasu e2e fixture defaults to a
hand-started Observer so the common live shape is the tested one.
* Wait for launchd to release a booted-out label before bootstrapping it again
launchctl bootout returns while the job is still exiting, and a bootstrap
sent right after it fails with 5: Input/output error. The live hcoord daemon
start that reloaded a changed plist stopped the daemon that way. Every
bootout now waits, up to 30 s, for the label to read unloaded; a label that
does not settle is reported instead of bootstrapped into a failure.
* Identify hcoord participants by machine, pane, and session
A Herdr restart gave every pane a new terminal id and cleared agent names
while panes and sessions stayed, and matching the terminal made 7 of 12
live participants undeliverable. One predicate now decides whether two
bindings are the same execution: machine, host scope, pane, and session,
with the terminal compared only for an agent Herdr reports without a
session. Delivery, preflight, registration, Sasu registration, handover,
discovery, and spawn completion all use it. Registering the same pane and
session again returns the same participant and records its current
terminal and name; another session in the pane, or the same session in
another pane, is still held.
* Register an unnamed Observer under a name derived from its session
Hand-started Observers carry no Herdr agent name, and since hcoord stopped
matching names, refusing them only added a rename step to the normal
setup. Dispatch and handover now record such an Observer as
observer-<session prefix>, which stays the same across the runs it
dispatches and across Herdr restarts; the pane is never renamed.
* Run the daemon start tests only on macOS and guard the bootout settle on every platform
hcoord daemon start refuses off macOS by design, so its two end-to-end
tests failed on the Linux CI runner. They now skip there, and a unit test
drives the shared LaunchAgent convergence through an injected launchctl
whose bootout settles late, so CI still catches the bootstrap race.
* Give hcoord generic end, check, brief, quiet patrol, and short messages
- agent register --check answers what registration would decide (execution
in its pane, no conflict, official delivery) and saves nothing.
- agent end stops the participant's watch, drops its open cycle, and
cancels its open questions; a second end changes nothing.
- watch assign to another observer moves the target's open questions and
unrelayed answers with the watch.
- watch start/assign --brief carries the watcher's note on every watch check.
- Quiet patrol: when a watched target is not working, its observer gets one
check for that change; later cycles, reminders and escalation are skipped
until the target works again.
- Every HCOORD_* message is an identifier line, the command that closes it,
and the carried content; handling steps leave the message.
The Sasu e2e fixtures now keep the daemon socket path under the macOS
104-byte limit, which failed every coordinator call as a transport error.
* Record a run's hcoord participants in state.json and call only generic hcoord commands
- sasu supervisor use hcoord|legacy selects who supervises new dispatches,
stored under ~/.sasu/supervisor/; retire-legacy writes its marker there.
- Dispatch checks the Observer with agent register --check before any pane,
then registers the Observer, the implementor as its child, and the
implementor's watch with the patrol interval and a brief naming the
digest, the retire step, and the recovery owner; the participant IDs go
to state.json supervision.hcoord. A replacement ends the gone implementor.
- plan, block and report send by those IDs; handover registers the new
Observer and runs watch assign; retire and ship delivery or merge run
agent end for the implementor.
- The supervisor index lists hcoord runs apart from the tick's entries, so
supervisor status shows them and the tick never wakes them.
- status and the digest read the watch through agent show by the recorded
IDs, and show when patrol is quiet.
- sasu supervisor migrate-hcoord records IDs for older hcoord runs from
hcoord agent list by pane and session, and reports runs it cannot match.
* Remove every Sasu concept from hcoord
hcoord now knows participants and the relations between them (parent,
watch, request) and nothing about Sasu. The Sasu-specific subcommands and
their daemon operations, the ledger's table of Sasu runs, the enable and
legacy-retired markers under ~/.hcoord, the run line in delivered
messages, and the run decoration on watch list are gone. The ledger loader
keeps only the fields it knows, so an older ledger's run table is dropped on
the next save. A client-specific hcoord subcommand is a usage error.
The dispatch message tells the Observer that patrol stops after one check
once the implementor stops working.
* Document hcoord notice handling in the implement skill and the hcoord guide
Messages now carry only an identifier, the closing command, and content, so
the Observer reference explains each notice: the watch check and its brief
(retire once verify passes and the PR is merged, otherwise close the
cycle), quiet patrol, plan, block, answer, relay and delivery problems.
It also covers sasu supervisor use, participant IDs in state.json,
migrate-hcoord, handover through watch assign, and agent end on retire and
delivery. The hcoord guide describes the generic register --check,
agent end, watch brief and assign, quiet patrol, and message format.
* Migrate a run whose Observer has duplicate records or a watch moved outside Sasu
migrate-hcoord matched participants by bare pane and session, so the live
ledger's two records of one Observer execution left this run unmatched,
and a watch assigned to a new Observer outside Sasu went unnoticed. It now
uses hcoord's own identity rule, keeps the record the implementor's watch
points at (else the latest), and when the watch moved to another Observer
records the run and names the handover to run from that pane.1 parent ebbc3f1 commit 399fb59
35 files changed
Lines changed: 2073 additions & 384 deletions
File tree
- cli
- src
- hcoord
- implement
- supervisor
- support
- test
- e2e
- helpers
- unit
- docs
- scripts
- skills
- implement
- references
- ship/scripts
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
59 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
60 | 65 | | |
61 | 66 | | |
62 | 67 | | |
| |||
78 | 83 | | |
79 | 84 | | |
80 | 85 | | |
81 | | - | |
| 86 | + | |
82 | 87 | | |
83 | 88 | | |
84 | 89 | | |
85 | 90 | | |
| 91 | + | |
| 92 | + | |
86 | 93 | | |
87 | 94 | | |
88 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | | - | |
| 12 | + | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
42 | | - | |
| 41 | + | |
43 | 42 | | |
44 | 43 | | |
45 | 44 | | |
46 | | - | |
47 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
| 61 | + | |
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
| |||
177 | 176 | | |
178 | 177 | | |
179 | 178 | | |
180 | | - | |
| 179 | + | |
181 | 180 | | |
182 | 181 | | |
183 | 182 | | |
184 | 183 | | |
185 | 184 | | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | 185 | | |
202 | 186 | | |
203 | 187 | | |
| |||
0 commit comments