device-add: code-lifecycle-and-errors — Redeem, revoke, and the code error taxonomy #48

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

Parent

Feature spec: #13 (device-add).

What to build

Everything that makes a code honest before a device ever pairs. The operator can revoke an unspent code (the RevokeCode seam amendment) so a code that leaked or went stale stops working — and when a request is already in flight on that code, revoking closes it (Closure: Revoked) and the agent performs the same teardown a decline would. On the code screen (P2-S2) the revoke affordance is the operator's control; on the app's Join with a code screen (P3-S2) redemption is where the device owner meets the error taxonomy.

Redeem is non-consuming: reading a code to see what you're joining never spends it. Each typed outcome maps to its own device-end message — a mistyped code says "no such code — retype" and the same code can be tried again; an expired code says "was valid, past expiry — get a fresh code" (distinct from a typo); a consumed code gives the already-spent outcome; and a code already bound to a different device gives the in-use outcome. A revoked code returns the "contact the operator" outcome, distinct from both expiry and typo.

This slice implements the enroll seam's device-facing Redeem (returning the typed outcome) and the Operator face's RevokeCode, plus the in-flight Closure delivery. It carries the non-consuming and typo behaviour of story 8; the branded display of a valid redemption is app-join-happy's.

Acceptance criteria

  • (story 3) Given an unspent code, When the operator revokes it, Then redeeming it returns the revoked outcome ("contact the operator"), distinct from expiry and typo.
  • (story 3) Given a request in flight on that code, When the operator revokes, Then the agent learns the request is closed (Closure: Revoked) and performs the same teardown as a decline.
  • (story 23) Given an expired code, When it is redeemed, Then the outcome is "was valid, past expiry — get a fresh code", distinct from a typo.
  • (story 23) Given a consumed code, When it is redeemed, Then the already-spent outcome shows.
  • (story 23) Given a code bound to a different device, When mine redeems it, Then the in-use outcome shows.
  • (story 8, partial) Given a valid code, When it is redeemed, Then redeeming does not consume the code (Redeem is non-consuming).
  • (story 8, partial) Given the owner mistypes the code, When redemption fails, Then the "no such code — retype" outcome shows and the same code can be retried.

Blocked by

  • #40 — codes must be mintable first

Task manifest

task: device-add:code-lifecycle-and-errors
implements_flow: p3-device-add-app
implements_edge: P3-S2 self (validate/typo/expired/revoked), P2-S2 revoke affordance
wireframe:
  - docs/ux/wireframes/p2-device-add-cli/p2-s2-code-and-install-command.html
  - docs/ux/wireframes/p3-device-add-app/p3-s2-join-with-a-code.html
interface: "`enroll` seam device face Redeem(code) → typed outcome {valid, unknown, expired, revoked, consumed, in-use} (non-consuming); Operator face RevokeCode(code); in-flight Closure(Revoked) delivery to the agent"
seam: "`join`-orchestrator seam tests (ADR 0057) — real `enroll` control-plane face + in-memory code ledger/clock; teardown asserted via VM-manager / self-removal fakes"
acceptance:
  - given: an unspent code
    when: the operator revokes it
    then: redeeming returns the revoked outcome, distinct from expiry and typo
  - given: a request in flight on that code
    when: the operator revokes
    then: the agent receives Closure Revoked and tears down as for a decline
  - given: an expired code
    when: redeemed
    then: "\"was valid, past expiry \u2014 get a fresh code\", distinct from a typo"
  - given: a consumed code
    when: redeemed
    then: the already-spent outcome
  - given: a code bound to a different device
    when: mine redeems it
    then: the in-use outcome
  - given: a valid code
    when: redeemed
    then: the code is not consumed (Redeem is non-consuming)
  - given: a mistyped code
    when: redemption fails
    then: "\"no such code \u2014 retype\", and the same code can be retried"
depends_on: [mint-code]
out_of_scope:
  - "story 8 branded valid-redemption display (community, hint, floor, modes, expiry) — app-join-happy's"
  - "story 21–22 decline teardown/closure — decline-and-resume's"
  - "the standing enrollment-codes ledger UI — shell's"
needs_human_decision: []
## Parent Feature spec: #13 (device-add). ## What to build Everything that makes a code honest before a device ever pairs. The operator can **revoke** an unspent code (the `RevokeCode` seam amendment) so a code that leaked or went stale stops working — and when a request is already in flight on that code, revoking closes it (Closure: Revoked) and the agent performs the same teardown a decline would. On the code screen (P2-S2) the revoke affordance is the operator's control; on the app's **Join with a code** screen (P3-S2) redemption is where the device owner meets the error taxonomy. Redeem is **non-consuming**: reading a code to see what you're joining never spends it. Each typed outcome maps to its own device-end message — a mistyped code says "no such code — retype" and the same code can be tried again; an expired code says "was valid, past expiry — get a fresh code" (distinct from a typo); a consumed code gives the already-spent outcome; and a code already bound to a different device gives the in-use outcome. A revoked code returns the "contact the operator" outcome, distinct from both expiry and typo. This slice implements the `enroll` seam's device-facing `Redeem` (returning the typed outcome) and the Operator face's `RevokeCode`, plus the in-flight Closure delivery. It carries the non-consuming and typo behaviour of story 8; the branded display of a valid redemption is app-join-happy's. ## Acceptance criteria - [ ] (story 3) Given an unspent code, When the operator revokes it, Then redeeming it returns the revoked outcome ("contact the operator"), distinct from expiry and typo. - [ ] (story 3) Given a request in flight on that code, When the operator revokes, Then the agent learns the request is closed (Closure: Revoked) and performs the same teardown as a decline. - [ ] (story 23) Given an expired code, When it is redeemed, Then the outcome is "was valid, past expiry — get a fresh code", distinct from a typo. - [ ] (story 23) Given a consumed code, When it is redeemed, Then the already-spent outcome shows. - [ ] (story 23) Given a code bound to a different device, When mine redeems it, Then the in-use outcome shows. - [ ] (story 8, partial) Given a valid code, When it is redeemed, Then redeeming does not consume the code (Redeem is non-consuming). - [ ] (story 8, partial) Given the owner mistypes the code, When redemption fails, Then the "no such code — retype" outcome shows and the same code can be retried. ## Blocked by - #40 — codes must be mintable first ## Task manifest ```yaml task: device-add:code-lifecycle-and-errors implements_flow: p3-device-add-app implements_edge: P3-S2 self (validate/typo/expired/revoked), P2-S2 revoke affordance wireframe: - docs/ux/wireframes/p2-device-add-cli/p2-s2-code-and-install-command.html - docs/ux/wireframes/p3-device-add-app/p3-s2-join-with-a-code.html interface: "`enroll` seam device face Redeem(code) → typed outcome {valid, unknown, expired, revoked, consumed, in-use} (non-consuming); Operator face RevokeCode(code); in-flight Closure(Revoked) delivery to the agent" seam: "`join`-orchestrator seam tests (ADR 0057) — real `enroll` control-plane face + in-memory code ledger/clock; teardown asserted via VM-manager / self-removal fakes" acceptance: - given: an unspent code when: the operator revokes it then: redeeming returns the revoked outcome, distinct from expiry and typo - given: a request in flight on that code when: the operator revokes then: the agent receives Closure Revoked and tears down as for a decline - given: an expired code when: redeemed then: "\"was valid, past expiry \u2014 get a fresh code\", distinct from a typo" - given: a consumed code when: redeemed then: the already-spent outcome - given: a code bound to a different device when: mine redeems it then: the in-use outcome - given: a valid code when: redeemed then: the code is not consumed (Redeem is non-consuming) - given: a mistyped code when: redemption fails then: "\"no such code \u2014 retype\", and the same code can be retried" depends_on: [mint-code] out_of_scope: - "story 8 branded valid-redemption display (community, hint, floor, modes, expiry) — app-join-happy's" - "story 21–22 decline teardown/closure — decline-and-resume's" - "the standing enrollment-codes ledger UI — shell's" needs_human_decision: [] ```
Author
Owner

Done in def5a9c. Built the device-end join orchestrator's first slice (ADR 0057) — the join state machine that lives in the agent and only there (internal/join/), driven at its single test seam against the real enroll control-plane ledger + clock (#26) with faked VM-manager / self-remover teardown below.

What shipped

  • Orchestrator.Redeem(code) — non-consuming read mapping enroll's error taxonomy to one typed RedeemOutcome each: valid / unknown (retype) / expired / revoked / consumed / in-use. A taxonomy error is a typed outcome (nil error); only a transport/programming fault returns an error. Valid carries the raw P3-S2 material — its branded render is app-join-happy's.
  • AwaitDecision(id) — the in-flight watcher: long-polls a paired request and, when the operator's RevokeCode (enroll's Operator face) closes it with Closure{Revoked}, runs the same teardown a decline runs — full install self-removes (SelfRemover), VM-mode guest removed (VMManager, ADR 0056) — chosen by Closure.SelfRemove.

Acceptance → tests (internal/join/join_test.go, 8 seam tests, all green):

  • story 3: unspent revoke → revoked outcome distinct from expiry+typo; revoke-in-flight → Closure Revoked + same-as-decline teardown (full and VM modes).
  • story 23: expired distinct from typo; consumed; bound-to-another-device → in-use.
  • story 8 (partial): valid Redeem is non-consuming (code stays bound, re-read rejoins same request); typo → "no such code — retype", same code retried successfully.

go / vet / gofmt / golangci-lint clean. STATUS.md + docs/slices/device-add.yaml (status: done) updated in the same commit.

Out of scope (their own slices): branded valid screen + pair/approve/confirm continuation (app-join-happy), decline entry point (decline-and-resume), standing codes-ledger UI (shell), thin P3-S2 socket UI (its own layer — ADR 0053/0057: Vue renders states, it does not decide them).

Done in `def5a9c`. Built the device-end **`join` orchestrator's** first slice (ADR 0057) — the join state machine that lives in the agent and only there (`internal/join/`), driven at its single test seam against the **real `enroll` control-plane ledger + clock** (#26) with faked VM-manager / self-remover teardown below. **What shipped** - `Orchestrator.Redeem(code)` — **non-consuming** read mapping `enroll`'s error taxonomy to one typed `RedeemOutcome` each: `valid` / `unknown` (retype) / `expired` / `revoked` / `consumed` / `in-use`. A taxonomy error is a typed outcome (nil error); only a transport/programming fault returns an error. Valid carries the raw P3-S2 material — its branded render is app-join-happy's. - `AwaitDecision(id)` — the in-flight watcher: long-polls a paired request and, when the operator's `RevokeCode` (enroll's Operator face) closes it with `Closure{Revoked}`, runs the **same teardown a decline runs** — full install self-removes (`SelfRemover`), VM-mode guest removed (`VMManager`, ADR 0056) — chosen by `Closure.SelfRemove`. **Acceptance → tests** (`internal/join/join_test.go`, 8 seam tests, all green): - story 3: unspent revoke → `revoked` outcome distinct from expiry+typo; revoke-in-flight → Closure Revoked + same-as-decline teardown (full **and** VM modes). - story 23: expired distinct from typo; consumed; bound-to-another-device → in-use. - story 8 (partial): valid Redeem is non-consuming (code stays `bound`, re-read rejoins same request); typo → "no such code — retype", same code retried successfully. `go` / `vet` / `gofmt` / `golangci-lint` clean. STATUS.md + `docs/slices/device-add.yaml` (status: done) updated in the same commit. **Out of scope (their own slices):** branded valid screen + pair/approve/confirm continuation (app-join-happy), decline entry point (decline-and-resume), standing codes-ledger UI (shell), thin P3-S2 socket UI (its own layer — ADR 0053/0057: Vue renders states, it does not decide them).
ben closed this issue 2026-07-25 10:38:33 +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#48
No description provided.