device-add: wire join.Orchestrator.Resume into the standing agent — a join whose terminal truly dies must be picked back up, not stranded #953
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Matou/idss#953
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?
Split from #952 (the causative await-hardening landed there; this is the remaining defense-in-depth).
The gap
join.Orchestrator.Resume(internal/join/resume.go) was written for exactly this — "a crash or reboot mid-join must never … strand the device" (#68) — but has no production caller:grep -rn '\.Resume(' --include=*.gooutside_test.gohitsfounding,clan,backup,monitorand neverinternal/join. The standingidss-agent.service(join socket listening) does nothing when the foregroundinstall/enrollterminal that owns a Pending join goes away (a real crash, reboot, or lost SSH). So once the terminal is gone, an operator's approval is stranded permanently: the grant is minted, the code is spent, and the strip sits atapproved-joiningforever with no path toEnrolledand no error.#952 hardened
AwaitDecisionso a transient poll blip no longer ends the join (the proximate cause of drive20260828T185311Z). This ticket closes the other half: when the terminal genuinely dies, nothing resumes.The main.go comments already PROMISE this behaviour —
runEnroll/runInstallsay SIGINT "leaves the request Pending for the standingagent joinservice to resume (ADR 0209)" — but that service/loop does not exist. The promise is currently false.Why it's blocked on a ruling
Resume(code)needs the code (and the request id) after the foreground process is gone. Deciding what the agent persists about an in-flight request, and where is the ruling this needs (ADR 0209 territory).Proposed default ruling (adoptable by a session under ADR 0174 — revertible + provable offline)
{code, requestID}— to a root-owned file under the agent's existing durable state home (beside the device key / SSH host key thatdeviceKey()/sshHostKey()already persist), mode 0600, written the moment Pair reaches Pending, and cleared at any terminal outcome (Enrolled, Declined, or a teardown).idss-agent.serviceruns a resume loop at startup: if the anchor exists, callOrchestrator.Resume(code)and continue the sameAwaitAndLandwalk the foreground terminal would have — so a join whose terminal died is picked back up by the standing agent, landed or torn down, never stranded.Proof (offline seam): persist the anchor → drop the orchestrator → a fresh orchestrator resumes from the file and lands a since-approved request; and assert the anchor is gone after a terminal outcome. No live drive needed to prove the mechanism.
Rejected alternatives to name in the ruling
Refs: ADR 0209 (device-add landing goes live), ADR 0100 (fail-loud), #68 (crash-safe resume), #952 (the transient-blip half, landed).
approve, sig c1ac37bc5a0d) #952Ruled by agent under ADR 0174 — veto anytime.
Adopting the ticket's proposed default ruling verbatim (ADR 0209 territory), which qualifies under ADR 0174 rule 1: it is (a) revertible — a commit adding a durable-state file + wiring, nothing widened; (b) provable offline — a join-seam test persists an anchor, drops the orchestrator, and a fresh orchestrator resumes from the file and lands a since-approved request, plus asserts the anchor is gone after any terminal outcome; (c) not on the one-way-door list — the
{code, requestID}anchor lives in the SAME root-owned durable-state home (0600) the device key and SSH host key already occupy (deviceKey()/sshHostKey()), same trust domain, no new surface, no auth loosened, no data destroyed.The ruling (DDR-shaped, under ADR 0209):
{code, requestID}— beside the device key, mode 0600, written the moment Pair reaches Pending (Consent), and cleared at any terminal outcome (Enrolled viaEnroll, or a teardown viatearDown— Declined/Expired/Revoked).agent joinservice runs a resume check at startup: if the anchor exists, it callsOrchestrator.Resume(code)and continues the same await-and-land walk the foreground terminal would have — so a join whose terminal died is picked back up, landed or torn down, never stranded.Resumealready surfaces, logged, never a silent spin.Rejected alternatives (as the ticket names them): re-deriving from the dashboard (the device is the only holder of its own code); a second request on restart (breaks the (code, KeyID) idempotency anchor #68 protects).
Named residue (honest scope): the startup check covers crash + reboot definitively (a reboot restarts the service; a service crash is systemd-restarted). A lost-SSH-without-reboot death — where the foreground
enrolldies but the already-running standing service does not restart — is only picked up at the next service restart. Widening to a continuous watch is deliberately out of scope here (it races the live foreground landing on the same request); filing a follow-up rather than expanding this two-way door.Close report — landed & proven (ADR 0174)
What landed (commit
17ccb4c9, onorigin/main):internal/resumeanchor— a file-backedjoin.AnchorStorepersisting the minimal durable resume anchor{code, requestID}to a 0600 file beside the device key (IDSS_RESUME_ANCHOR//var/lib/idss/resume.json): atomic write (temp+rename), absent →ok:false, corrupt → a loud read error (never a silent "no join in flight", ADR 0100).internal/join—Config.Anchor+ theResumeAnchor/AnchorStoretypes;saveAnchorthe momentPairreaches Pending (Consent, before the VM guest stands up),clearAnchorat any terminal outcome (Enrollon Enrolled,tearDownon Declined/Expired/Revoked). NewOrchestrator.ResumeAndLanddrives a resumed join to a terminal outcome via the sharedlandwalk extracted fromAwaitAndLand(lost approval → land now; still Pending → resume the same long-poll; already terminal → the teardownResumealready ran). A nilAnchor(app socket path, seam tests) is a no-op — only the standing agent wires the store.agent/cmd/agent/main.go—resumeStrandedJoinruns atagent joinstartup: if the anchor holds an in-flight join itResumeAndLands it in a goroutine (so a still-Pending long-poll never blocks the socket coming up), logging a landed join, a torn-down decline, or a fail-loud resume error (LOGGED, not fatal — the socket must still serve fresh joins). The anchor store is wired intorunJoin/runEnroll/runInstall. TherunEnroll/runInstallcomments that promised "the standingagent joinservice to resume (ADR 0209)" are now true.Proof — red-first, entirely offline (no live drive), exactly the seam the ticket specified:
internal/join/resume_anchor_test.go—TestAnchor_FileStore_DropAndResume: persist the anchor → drop the orchestrator → a fresh orchestrator resumes from the file store and lands a since-approved request to Enrolled; plus lost-approval, declined-while-down (teardown ran,ErrDeclined), still-Pending-waits-then-lands, and anchor gone after every terminal outcome.internal/resumeanchor/resumeanchor_test.go— store round-trip, 0600, overwrite, idempotent Clear, corrupt-file rejection.go build(+-tags dev) /go vet/ fullgo test ./...— green.Ruling: the ticket's proposed default, adopted under ADR 0174 (see the ruling comment above) — a two-way door: revertible, offline-provable, same trust domain as the device key, no surface widened, no auth loosened.
Named residue → follow-up #958: a lost-SSH death where the box stays up and the standing service never restarts is only resumed at the next service restart (a continuous watch races the live foreground landing on the same request — out of scope for this door). Crash + reboot are covered definitively.
Closing: work is done and proven. Advances #953.