factory design: cancel a live run — new AbortSignal kill-path design + TUI wiring (#607 follow-up) #612
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Matou/idss#612
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
#607 ("the factory TUI — fleet/live-run/incident/ask screens + engage side")
named cancelling a live run as "the one genuinely new mechanism" in its
engage-side scope, and its own Suggested-next-slice section called it out to
split into its own ticket "given the new-mechanism design work it needs
before any TUI wiring." #607 closed on its delivered read-side slice (a Run
tab); the rest of #607's engage scope (answer-asks, arm/park/prioritise,
re-arm) moved to a sibling follow-up ticket. This ticket is that carve-out.
Why this is different from the rest of engage
Every other engage action is composition of an existing protocol the factory
already runs unattended: label writes via the tracker's
/labelssub-endpoint,
rearm_dispatch, theask-human.shthread protocol. Cancel-a-run has no existing protocol to compose:
RunOptions.signal(AbortSignal) exists in the Sandcastle runner'soptions shape today but is unused — nothing ever passes or triggers it.
SIGTERMon the host process cannot interrupt anin-flight agent turn inside the sandboxed container the way it can a plain
shell script —
run-swarm.sh's own EXIT/SIGTERM/SIGINT traps write averdict on the orchestrator's death, not proof the in-flight Claude Code
turn inside the container stopped cleanly.
(contrast: droplet vhosts/units and org-secret rotation, which ADR 0174
explicitly names as having one).
Scope — design pass first, then TUI wiring
main.mts's Sandcastleinvocation, the Docker container lifecycle, or both. Read
main.mts,run-swarm.sh's trap handling, andclose-report-lib.sh's gates beforeproposing a mechanism.
swarm.db'sruns/attempts/processesrows (an aborted run must not read as asilent success, and must not leave a wedge the janitor sweep can't
recognise), and the runlog.
report's envelope-then-post sequence may have a window where killing
mid-write is worse than letting it finish; the design should say so
explicitly rather than leave it implicit.
(
.sandcastle/tui/app.py), gated the same two-way-door way as the rest ofengage (ADR 0174 ruling posted to whichever ticket lands it).
This is real new-mechanism design work, not a slice-sized TUI addition —
expect it to need its own design note (an ADR, or at minimum a
## Designsection on this ticket) before code, the same bar #574's data-layer work and
#573's original scope ruling both cite for "materially bigger and riskier."
Ruled by agent under ADR 0174 (scope split, revertible/provable, no
one-way-door — filing itself is reversible; the actual kill-path mechanism
this ticket describes is NOT pre-authorized by this ruling and needs its own
design-time ruling when picked up): filed
ready-for-sessionto match#573/#607's own label — this is factory/dev tooling requiring the session's
host standing, not Ben.
Triage
Category:
enhancement. State:ready-for-session.The issue body already carries a ruling ("Ruled by agent under ADR 0174 ...
filed
ready-for-session") from filing time, but the label was neveractually applied via the
/labelssub-endpoint (only the body text statedit) — closing that gap now.
Confirming the ruling holds: checked
.sandcastle/tui/app.pyfor anyexisting Cancel/AbortSignal wiring — none found, matching the ticket's claim
that
RunOptions.signalis unused. No.out-of-scope/entry matches thisrequest; not already implemented.
ready-for-session(notready-for-agent)is correct per
docs/agents/triage-labels.md: this is factory/dev toolingneeding the session's host standing, matching the
#573/#607precedent —not a swarm-worker-pickable task, and not one of Ben's one-way doors
(no personal credentials, security-posture widening, member-facing trust
accept, data destruction, or non-routine spend involved in the design pass
itself).
Note per the ticket's own scope: the design of the kill-path mechanism
itself is explicitly not pre-authorized by this triage ruling — the
ticket says so, and that stands. This ruling only concerns the ticket's
routing (category + state), which is a two-way door (a relabel).
Design
Full design write-up:
docs/adr/0186-a-cancelled-live-run-is-a-log-marker-run-swarm-detects-not-a-hard-kill-guarantee.md.Summary of the four questions this ticket asked:
main.mtsholds anAbortController, wired into Sandcastle's own (previously unused)RunOptions.signal. It polls a host-local marker file ($HOME/swarm/state/cancel-request/<run_id>, the same homeswarm.dbuses) that a separate process — the TUI — writes. A marker file, not new IPC: it followslimit-lib.sh's existing marker-file convention (CLAUDE_LIMIT_MARKER/CLAUDE_ACTIVE_MARKER).swarmdb_run_end, called on every exit path) already closes therunsrow (verdict=cancelled:operator, distinct fromcompleted) and every openattemptsrow correctly. The Forgejo-side claim (not a swarm.db row) is what the janitor sweep actually watches, and cancellation makesrun-swarm.shexit promptly like any other path, so the existing sweep re-arms the ticket with no new code. Named, accepted gap: an aborted run loses the swarm.db mirror of any iteration that fully succeeded before the cancel landed (record-run-result.shonly runs onrun()'s resolved path) — architecturally fine perswarm-db.py's own "this is a MIRROR, losing it loses nothing authoritative" posture, since the real Forgejo close is unaffected.close-report.sh's own comment-then-close ordering (post the envelope in every outcome, close only after) means there is no window where a kill can produce a falsely-closed ticket. No code change needed toclose-report-lib.sh/close-report.sh.cto arm,cagain within 5s to confirm) Cancel action, deliberately not a modal (cheaper to build/test, and the marker stays deletable up tomain.mts's next ~2s poll — a real undo window).Ruling (ADR 0174)
This is a two-way door: revertible (a commit — marker file,
main.mts/run-swarm.shwiring, TUI action — no schema migration, no tracker-state mutation by the mechanism itself) and provable (26 new offline tests across both repos, all green;check-harness-drift.shgreen against the real remote). Not on the one-way-door list: no personal credential, no security-posture widening, no public trust-surface decision, and no data destroyed — nothing this mechanism can kill is the durable record of anything (the Forgejo close, if any, already landed before a kill could matter;swarm.dbis an explicitly-documented mirror).Ruled by agent under ADR 0174 — veto anytime.
What landed
Matou/dev-factory@9324ef1a650656ac80a0143078d440afaec4fe0c—cancel-lib.sh(new) +tests/cancel-lib-test.sh(12 groups),main.mts(AbortController + marker poll),run-swarm.sh(swarm_cancel_hitretry-loop branch). Full dev-factory suite green (41/41).Matou/ourcloud@a4772a58088e4a5b586cc1315f5a4e1e775ad6d0— design (docs/adr/0186-*.md),FACTORY_REFbump0e536e4→9324ef1, re-vendor.Matou/ourcloud@c0da88a3e69bd89466a156332a1d38cd2f62e983— TUI wiring:.sandcastle/tui/app.py's Run tab Cancel action,data/cancel.py(new),data/swarmdb.py'srunning_run. 14 new offline tests, full TUI suite green (65/65).Closing — design done, mechanism landed and vendored, TUI wired, all tests green.
matou-build-agent referenced this issue2026-08-20 05:45:13 +00:00