device-add: vm-and-state-fixes — VM lifecycle ordering, OS install-mode policy, watcher call-in state (#48/#50/#68/#40) #114

Closed
opened 2026-07-26 19:40:57 +00:00 by ben · 1 comment
Owner

Parent

Feature spec: #13 (device-add). Follow-up filed by the 2026-07-26 review sweep (code-review Standards/Spec + design-verify Design axes over 6596977..9e946b7). Three defects, all device-add, none needing new screens:

  1. VM lifecycle ordering — the VM guest is created before Pair, but teardown infers mode from View.Mode (set only at Pair): RevokeCode on a still-Redeemed VM request skips VM.Remove, orphaning the guest on the member's machine ("the device holds nothing of the community" is violated); and VM.Create runs before the spec gate, so a host failing vmHostFloor leaves a doomed guest running (internal/enroll/ledger.go:649, internal/join/app.go:150).
  2. OS→install-modes policy in production — ADR 0030 (Windows/Mac = VM-only) lives only in a test helper (internal/join/app_test.go:22-24); production default InstallModes: nil resolves to {full, vm} for every OS — a real Mac would be offered a full install.
  3. Watcher call-in state — dashboard/src/lib/deviceAdd.ts:210-230 stores called-in state nowhere; a watcher subscribing after the device calls in sees "Waiting…" forever, violating #40's "leaving the page loses nothing". The inline comment claims the behaviour; the code doesn't do it; no test.

Acceptance criteria

  • Given a VM-mode join that is revoked or fails the spec gate at any point after guest creation, then the guest is removed — teardown derives from actual VM state, not View.Mode; and VM.Create runs only after the spec gate passes.
  • Given a macOS or Windows host in production wiring, then only the VM install mode is offered (ADR 0030), with a production-side test.
  • Given a device that has called in, when a watcher subscribes afterwards, then it sees the called-in state (state survives page leave/rejoin), with a test.

Blocked by

None.

Task manifest

task: device-add:vm-and-state-fixes
implements_flow: p3-device-add-app
implements_edge: "S4x/revoke → clean teardown; spec gate before guest creation; watcher resubscribe sees called-in"
wireframe: docs/ux/wireframes/p3-device-add-app/p3-s4-joining.html
interface: "ordering + teardown fixes in internal/enroll + internal/join; ADR 0030 OS→install-modes policy promoted to production wiring; durable called-in state in the dashboard deviceAdd client"
seam: "Go tests for orphaned-guest and gate-before-create; production-side install-modes test; dashboard test for late-subscriber state"
acceptance: "see Acceptance criteria above"
depends_on: []
out_of_scope: [new screens (P3-S2 is its own slice), enrolment code minting rules]
needs_human_decision: []
## Parent Feature spec: #13 (device-add). Follow-up filed by the 2026-07-26 review sweep (code-review Standards/Spec + design-verify Design axes over `6596977..9e946b7`). Three defects, all device-add, none needing new screens: 1. **VM lifecycle ordering** — the VM guest is created before `Pair`, but teardown infers mode from `View.Mode` (set only at Pair): `RevokeCode` on a still-`Redeemed` VM request skips `VM.Remove`, orphaning the guest on the member's machine ("the device holds nothing of the community" is violated); and `VM.Create` runs before the spec gate, so a host failing `vmHostFloor` leaves a doomed guest running (`internal/enroll/ledger.go:649`, `internal/join/app.go:150`). 2. **OS→install-modes policy in production** — ADR 0030 (Windows/Mac = VM-only) lives only in a test helper (`internal/join/app_test.go:22-24`); production default `InstallModes: nil` resolves to {full, vm} for every OS — a real Mac would be offered a full install. 3. **Watcher call-in state** — `dashboard/src/lib/deviceAdd.ts:210-230` stores called-in state nowhere; a watcher subscribing after the device calls in sees "Waiting…" forever, violating #40's "leaving the page loses nothing". The inline comment claims the behaviour; the code doesn't do it; no test. ## Acceptance criteria - [ ] Given a VM-mode join that is revoked or fails the spec gate at any point after guest creation, then the guest is removed — teardown derives from actual VM state, not `View.Mode`; and `VM.Create` runs only after the spec gate passes. - [ ] Given a macOS or Windows host in production wiring, then only the VM install mode is offered (ADR 0030), with a production-side test. - [ ] Given a device that has called in, when a watcher subscribes afterwards, then it sees the called-in state (state survives page leave/rejoin), with a test. ## Blocked by None. ## Task manifest ```yaml task: device-add:vm-and-state-fixes implements_flow: p3-device-add-app implements_edge: "S4x/revoke → clean teardown; spec gate before guest creation; watcher resubscribe sees called-in" wireframe: docs/ux/wireframes/p3-device-add-app/p3-s4-joining.html interface: "ordering + teardown fixes in internal/enroll + internal/join; ADR 0030 OS→install-modes policy promoted to production wiring; durable called-in state in the dashboard deviceAdd client" seam: "Go tests for orphaned-guest and gate-before-create; production-side install-modes test; dashboard test for late-subscriber state" acceptance: "see Acceptance criteria above" depends_on: [] out_of_scope: [new screens (P3-S2 is its own slice), enrolment code minting rules] needs_human_decision: [] ```
Author
Owner

Done in 942ac22 (on origin/main).

1. VM lifecycle ordering — Orchestrator.Consent (internal/join/app.go) now runs Pair (the spec gate, ADR 0030 vmHostFloor) before VM.Create, so a host that fails the gate is left Redeemed with a rejection and never gets a doomed guest. Orchestrator.tearDown (internal/join/join.go) derives the teardown from the host's actual guest state via a new VMManager.Exists face, not View.Mode/Closure.SelfRemove — a revoked or declined VM-mode join removes its guest wherever it closed, and it survives a reboot (a fresh agent introspects the autostarted guest). Tests: TestConsent_SpecGateBeforeGuestCreation (gate fail → no guest), TestConsent_VMCreateFailsAfterGate, TestRevoke_InFlightTearsDown_VMMode (now drives Consent, asserts the created guest is removed), resume-teardown models the persisted guest.

2. OS→install-modes policy in production — enroll.DefaultInstallModes (internal/enroll/ledger.go) is ADR 0030's policy (Windows/Mac VM-only, Linux both) and is now the nil-InstallModes default, so the agent's production wiring no longer offers a Mac a full install. The test-only installModesFor helper is removed; the seam tests exercise the real default. Production-side test: TestDefaultInstallModes_ProductionOSPolicy.

3. Watcher call-in state — FakeDeviceAddSource (dashboard/src/lib/deviceAdd.ts) stores called-in state durably, so a watcher subscribing after the device called in re-reads it instead of showing "Waiting…" forever (#40). Tests: two late/early-subscriber cases in dashboard/tests/unit/deviceAdd.test.ts.

Full Go suite + 416 dashboard tests green; vue-tsc clean. STATUS.md updated.

Done in `942ac22` (on `origin/main`). **1. VM lifecycle ordering** — `Orchestrator.Consent` (`internal/join/app.go`) now runs `Pair` (the spec gate, ADR 0030 `vmHostFloor`) **before** `VM.Create`, so a host that fails the gate is left Redeemed with a rejection and never gets a doomed guest. `Orchestrator.tearDown` (`internal/join/join.go`) derives the teardown from the host's **actual** guest state via a new `VMManager.Exists` face, not `View.Mode`/`Closure.SelfRemove` — a revoked or declined VM-mode join removes its guest wherever it closed, and it survives a reboot (a fresh agent introspects the autostarted guest). Tests: `TestConsent_SpecGateBeforeGuestCreation` (gate fail → no guest), `TestConsent_VMCreateFailsAfterGate`, `TestRevoke_InFlightTearsDown_VMMode` (now drives `Consent`, asserts the created guest is removed), resume-teardown models the persisted guest. **2. OS→install-modes policy in production** — `enroll.DefaultInstallModes` (`internal/enroll/ledger.go`) is ADR 0030's policy (Windows/Mac VM-only, Linux both) and is now the nil-`InstallModes` default, so the agent's production wiring no longer offers a Mac a full install. The test-only `installModesFor` helper is removed; the seam tests exercise the real default. Production-side test: `TestDefaultInstallModes_ProductionOSPolicy`. **3. Watcher call-in state** — `FakeDeviceAddSource` (`dashboard/src/lib/deviceAdd.ts`) stores called-in state durably, so a watcher subscribing after the device called in re-reads it instead of showing "Waiting…" forever (#40). Tests: two late/early-subscriber cases in `dashboard/tests/unit/deviceAdd.test.ts`. Full Go suite + 416 dashboard tests green; `vue-tsc` clean. `STATUS.md` updated.
ben closed this issue 2026-07-26 21:36:22 +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.

Dependencies

No dependencies set.

Reference
Matou/idss#114
No description provided.