device-add: decline-and-resume — Clean decline teardown and crash-safe resume #68

Closed
opened 2026-07-25 04:57:38 +00:00 by ben · 1 comment
Owner

Parent

Feature spec: #13 (device-add).

What to build

The two ways a join can end without enrolling — an operator changing their mind, and a machine that crashed mid-join — both left honest. On decline (P2-S4 decline / P3-S4x) the request goes terminal, the code is consumed, and the agent is informed so the device holds nothing of the community: a VM-mode join removes its local VM; a full-install join has no VM and the agent removes itself. The declined device's owner (P3-S4x) lands back at Welcome once teardown completes — or, with a fresh code from the operator, joins again as a new request. The decline reaches the owner as an outcome, not an error: when the agent polls it receives the Closure (reason + self-removal directive) and the screen states plainly what happened and what was removed.

Resume makes a crash or reboot mid-join safe. When the agent restarts with its persisted device key and re-redeems the same code, it rejoins its existing request rather than opening a second one — the (code, KeyID) idempotency anchor — so the operator never sees two pending cards for one machine. A re-pair returns the existing Pending, and an approval that was lost in the crash is re-delivered verbatim.

Acceptance criteria

  • (story 21) Given a Pending request, When the operator declines, Then the request is terminal, the code is consumed, and the agent is informed — a VM-mode join removes its local VM; a full-install join has no VM and the agent removes itself.
  • (story 21) Given the declined device's owner (P3-S4x), When teardown completes, Then they land back at Welcome — or, with a fresh code from the operator, join again as a new request.
  • (story 22) Given Declined, When the agent polls, Then it receives the closure (reason + self-removal directive) and the screen states the outcome plainly — a decline is a successful poll with a Closure, never a transport error.
  • (story 24) Given the agent restarts with its persisted device key, When it re-redeems the same code, Then it rejoins its existing request ((code, KeyID) idempotency anchor) — a re-pair returns the existing Pending and a lost approval is re-delivered verbatim, so the operator never sees two pending cards for one machine.

Blocked by

  • #60 — the approve/decline gate + Enrolled path

Task manifest

task: device-add:decline-and-resume
implements_flow: p3-device-add-app
implements_edge: P2-S4→P2-S1 (decline), P3-S4→P3-S4x, P3-S4x→SHW, P3-S4x→P3-S2
wireframe:
  - docs/ux/wireframes/p3-device-add-app/p3-s4x-declined.html
  - docs/ux/wireframes/p2-device-add-cli/p2-s4-pending-device.html
interface: "`enroll` seam Operator face Decline → terminal Closure (code consumed, teardown directive: VM removal or agent self-removal); (code, KeyID) idempotency on Redeem/Pair; verbatim re-delivery of a lost approval"
seam: "`join`-orchestrator seam tests (ADR 0057) — real `enroll` control-plane face + in-memory ledger/clock; fake VM-manager / self-removal; assert teardown residue, closure-not-error, and idempotent resume across a simulated restart"
acceptance:
  - given: a Pending request
    when: the operator declines
    then: the request is terminal, the code is consumed, and the agent tears down — VM-mode removes the VM, full-install self-removes
  - given: the declined owner (P3-S4x)
    when: teardown completes
    then: they land back at Welcome, or rejoin as a new request with a fresh code
  - given: Declined
    when: the agent polls
    then: it receives the closure (reason + self-removal directive) and the screen states the outcome plainly — never a transport error
  - given: the agent restarts with its persisted device key
    when: it re-redeems the same code
    then: it rejoins its existing request ((code, KeyID) anchor); a re-pair returns the existing Pending; a lost approval is re-delivered verbatim
depends_on: [approve-enroll-land]
out_of_scope:
  - "story 3 operator RevokeCode + in-flight closure — code-lifecycle-and-errors's"
  - "the full-install wipe/takeover execution — provisioning's"
needs_human_decision: []
## Parent Feature spec: #13 (device-add). ## What to build The two ways a join can end without enrolling — an operator changing their mind, and a machine that crashed mid-join — both left honest. On **decline** (P2-S4 decline / P3-S4x) the request goes terminal, the code is consumed, and the agent is informed so the device holds nothing of the community: a VM-mode join removes its local VM; a full-install join has no VM and the agent removes itself. The declined device's owner (P3-S4x) lands back at Welcome once teardown completes — or, with a fresh code from the operator, joins again as a new request. The decline reaches the owner as an **outcome, not an error**: when the agent polls it receives the Closure (reason + self-removal directive) and the screen states plainly what happened and what was removed. **Resume** makes a crash or reboot mid-join safe. When the agent restarts with its persisted device key and re-redeems the same code, it rejoins its existing request rather than opening a second one — the **(code, KeyID) idempotency anchor** — so the operator never sees two pending cards for one machine. A re-pair returns the existing Pending, and an approval that was lost in the crash is **re-delivered verbatim**. ## Acceptance criteria - [ ] (story 21) Given a Pending request, When the operator declines, Then the request is terminal, the code is consumed, and the agent is informed — a VM-mode join removes its local VM; a full-install join has no VM and the agent removes itself. - [ ] (story 21) Given the declined device's owner (P3-S4x), When teardown completes, Then they land back at Welcome — or, with a fresh code from the operator, join again as a new request. - [ ] (story 22) Given Declined, When the agent polls, Then it receives the closure (reason + self-removal directive) and the screen states the outcome plainly — a decline is a successful poll with a Closure, never a transport error. - [ ] (story 24) Given the agent restarts with its persisted device key, When it re-redeems the same code, Then it rejoins its existing request ((code, KeyID) idempotency anchor) — a re-pair returns the existing Pending and a lost approval is re-delivered verbatim, so the operator never sees two pending cards for one machine. ## Blocked by - #60 — the approve/decline gate + Enrolled path ## Task manifest ```yaml task: device-add:decline-and-resume implements_flow: p3-device-add-app implements_edge: P2-S4→P2-S1 (decline), P3-S4→P3-S4x, P3-S4x→SHW, P3-S4x→P3-S2 wireframe: - docs/ux/wireframes/p3-device-add-app/p3-s4x-declined.html - docs/ux/wireframes/p2-device-add-cli/p2-s4-pending-device.html interface: "`enroll` seam Operator face Decline → terminal Closure (code consumed, teardown directive: VM removal or agent self-removal); (code, KeyID) idempotency on Redeem/Pair; verbatim re-delivery of a lost approval" seam: "`join`-orchestrator seam tests (ADR 0057) — real `enroll` control-plane face + in-memory ledger/clock; fake VM-manager / self-removal; assert teardown residue, closure-not-error, and idempotent resume across a simulated restart" acceptance: - given: a Pending request when: the operator declines then: the request is terminal, the code is consumed, and the agent tears down — VM-mode removes the VM, full-install self-removes - given: the declined owner (P3-S4x) when: teardown completes then: they land back at Welcome, or rejoin as a new request with a fresh code - given: Declined when: the agent polls then: it receives the closure (reason + self-removal directive) and the screen states the outcome plainly — never a transport error - given: the agent restarts with its persisted device key when: it re-redeems the same code then: it rejoins its existing request ((code, KeyID) anchor); a re-pair returns the existing Pending; a lost approval is re-delivered verbatim depends_on: [approve-enroll-land] out_of_scope: - "story 3 operator RevokeCode + in-flight closure — code-lifecycle-and-errors's" - "the full-install wipe/takeover execution — provisioning's" needs_human_decision: [] ```
Author
Owner

Done in commit 136a094 (sandcastle: device-add:decline-and-resume #68).

Decline (stories 21/22) — proven at the ADR 0057 seam (internal/join/resume_test.go, real enroll ledger + clock, fake VM manager / self-remover): the operator's Decline goes terminal, consumes the code, and the agent's poll succeeds carrying the Closure — never a transport error — then runs the directed teardown itself (VM mode removes its local guest; a full install self-removes). The card leaves the pending list; a fresh code joins again as a NEW request; re-typing the spent code shows the honest used-up screen.

Resume (story 24) — enroll.Redeem's (code, KeyID) anchor now outranks the code taxonomy for the bound key (internal/enroll/ledger.go): a code bound to THIS key always rejoins its own request, even after being spent by that request's own approval or decline (other keys still get consumed/revoked/expired). New join.Resume (internal/join/resume.go): a fresh orchestrator over the persisted key + code rejoins the existing request, a re-pair returns the existing Pending (never two pending cards for one machine), a lost approval is re-delivered verbatim (same setup key/cert) and completes to Enrolled, a lost decline delivers its Closure and tears down on restart.

Screens — app/src/components/device-add/DeclinedScreen.vue ships P3-S4x to the wireframe contract (checklist ✓/✕, warn copy, data-action="remove-the-vm" → Welcome, data-action="join-with-a-new-code" → P3-S2, LOGGED chip), rendered by JoinProgressSurface at phase declined, plus a teardown line naming exactly what was removed once it ran. The P2-S4 dashboard decline shipped with #60 and needed nothing new.

Evidence: 6 new Go seam tests + TestCrashResend_SpentCodeStillRejoins (enroll) + 6 Vue tests; full Go suite, all four TS workspaces (386 vitest tests), vue-tsc and eslint green.

Done in commit `136a094` (`sandcastle: device-add:decline-and-resume #68`). **Decline (stories 21/22)** — proven at the ADR 0057 seam (`internal/join/resume_test.go`, real enroll ledger + clock, fake VM manager / self-remover): the operator's Decline goes terminal, consumes the code, and the agent's poll succeeds carrying the Closure — never a transport error — then runs the directed teardown itself (VM mode removes its local guest; a full install self-removes). The card leaves the pending list; a fresh code joins again as a NEW request; re-typing the spent code shows the honest used-up screen. **Resume (story 24)** — `enroll.Redeem`'s (code, KeyID) anchor now outranks the code taxonomy for the bound key (`internal/enroll/ledger.go`): a code bound to THIS key always rejoins its own request, even after being spent by that request's own approval or decline (other keys still get consumed/revoked/expired). New `join.Resume` (`internal/join/resume.go`): a fresh orchestrator over the persisted key + code rejoins the existing request, a re-pair returns the existing Pending (never two pending cards for one machine), a lost approval is re-delivered verbatim (same setup key/cert) and completes to Enrolled, a lost decline delivers its Closure and tears down on restart. **Screens** — `app/src/components/device-add/DeclinedScreen.vue` ships P3-S4x to the wireframe contract (checklist ✓/✕, warn copy, `data-action="remove-the-vm"` → Welcome, `data-action="join-with-a-new-code"` → P3-S2, LOGGED chip), rendered by `JoinProgressSurface` at phase `declined`, plus a teardown line naming exactly what was removed once it ran. The P2-S4 dashboard decline shipped with #60 and needed nothing new. **Evidence**: 6 new Go seam tests + `TestCrashResend_SpentCodeStillRejoins` (enroll) + 6 Vue tests; full Go suite, all four TS workspaces (386 vitest tests), vue-tsc and eslint green.
ben closed this issue 2026-07-25 16:10:36 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/idss#68
No description provided.