an enrolled device vanishes from the operator's Fleet — the pending projection never returns Enrolled, so P2-S5 "Connected — not yet set up" can never render live #979

Closed
opened 2026-08-29 09:25:06 +00:00 by matou-build-agent · 1 comment

The failure

Drive 20260829T085335Z (target device, commit e1a8cdcb) went red at the approve leg (sig c1ac37bc5a0d), the 24th of 24 legs, after burning the full 300 s ceiling:

Locator: locator('[data-field="connected-device"]').or(locator('[data-status="pending-device-error"]')).first()
Expected: visible
Error: element(s) not found

artifacts/legs.json — approve, red, 300679 ms; every other leg green (artifacts/verdict.json: 23 green / 1 red).

The device side succeeded. artifacts/join-transcript.txt walks the whole landing and ends ✓ joined the community network / ✓ community trust installed / ✓ takeover staged / ✓ this machine is enrolled; artifacts/join-exit.txt reads exited 0 (approve red). Those ✓ lines are only printed after Enroll returns success — internal/join/cli.go:258-272 (land: "It prints only after Enroll returns success, so every ✓ names a fact that provably happened (ADR 0100)"), which includes ConfirmEnrolled. logs/device-journal.txt:1667 shows netbird.service started at 09:14:08 and logs/device-stall.txt shows the box holding mesh address 100.74.5.74. The device really joined; the control plane really recorded StatusEnrolled.

What the operator saw is in artifacts/legs/approve-dash.png: the Fleet tab at 09:19 with no pending strip at all and a resting list holding only gateway. The row did not sit at "approved — joining now", and no error state was raised — it simply left.

The defect

The pending projection deliberately excludes Enrolled:

  • internal/controlapi/enroll.go:184-186 — svc.ListPending(..., enroll.Query{Status: []enroll.Status{enroll.StatusPending, enroll.StatusApproved}}), with the comment at internal/controlapi/enroll.go:177-181: "Enrolled devices leave the strip and join the resting Fleet list (story 26), so they are not read here."

The dashboard holds the opposite contract:

  • dashboard/src/lib/pending.ts:27-31 — "pending and approved are the in-flight card states; enrolled is the landing; declined/expired are terminal — those rows leave the pending list."
  • dashboard/src/components/device-add/PendingDevicesSurface.vue:43-47 renders ConnectedScreen for row.phase === 'enrolled'; dashboard/src/components/device-add/ConnectedScreen.vue:7 is the only place in the tree that emits data-field="connected-device".
  • dashboard/src/lib/api/enrollClient.ts:362 maps phase: w.request.status as RequestPhase straight off the wire — so enrolled is a phase the transport can never deliver.
  • dashboard/src/components/device-add/PendingDevicesSurface.vue:95-99 filters visible to pending|approved|enrolled, and the strip is v-if="visible.length" (line 9) — an empty read removes the strip entirely, exactly as the screenshot shows.

The derived architecture view agrees with the dashboard, not with the projection: docs/architecture/15-device-node-lifecycle.md:74 — "Enrolled = P2-S5 / P3-S5" — and docs/ux/flows/p2-device-add-cli.mermaid:18-19 — S4 --"approves — device enrolled in the mesh"--> S5, S5 --"provision"--> P4S1. The P2-S5 wireframe (docs/ux/wireframes/p2-device-add-cli/p2-s5-connected.html:18) stands on admin.example.nz/fleet.

The divergence survived because the seam test drives a fake that CAN emit enrolled: dashboard/tests/unit/pendingDevices.test.ts:126-135 calls source.deviceEnrolled('req-0001') on FakePendingSource and asserts connected-device renders. Nothing tests the live projection against that phase — internal/controlapi/enroll_integration_test.go:262-268 only asserts the honest story-20 split (approve lands on approved, not enrolled).

The story-26 alternative — the enrolled device joining the resting Fleet list instead — is not wired either, so the device currently vanishes from BOTH surfaces:

  • dashboard/src/lib/pending.ts:146 enrolledFleetNode() has no caller anywhere in dashboard/src or app/ (dead except for dashboard/tests/unit/pendingDevices.test.ts:185-188);
  • dashboard/src/components/shell/FleetSurface.vue:186 loads the fleet composition once on onMounted with no poll, so even a server-side admission would not appear without a reload. internal/enroll/ledger.go:544-556 does fire the OnEnrolled admission hook, but the operator's page never re-reads it.

Suspected layer

The control-plane HTTP projection (internal/controlapi), against the device-add dashboard contract. Not the mesh, not the agent, not the drive fixture: app/tests/e2e/fixtures/deviceAdd.ts:206-214 is asking for exactly what docs/architecture/15-device-node-lifecycle.md:74 promises.

What plugging it needs

A ruling on where P2-S5 lives, then the wiring:

  1. Recommended (matches the flow, the lifecycle doc, the wireframe and the surface): add enroll.StatusEnrolled to the query at internal/controlapi/enroll.go:185 and correct the comment at lines 177-181, so the landed request renders as the P2-S5 Connected card on the strip.
  2. The open question this needs a human on: when does the Connected card LEAVE. internal/enroll/ledger.go:621-648 (ListPending) never prunes; enrolled requests live in the ledger forever. A bare status-list change means a standing community accumulates one permanent Connected card per device ever enrolled — the flow's S5 --provision--> P4S1 edge implies it should leave once the device is set up, but no rule exists for that today. Candidates: filter out enrolled requests whose node is already provisioned; bound by a recency window; or an explicit operator acknowledgement.
  3. Either way, close the fake/production gap: an integration test at internal/controlapi/enroll_integration_test.go that confirms enrolled and asserts what GET /api/v1/enroll/pending returns — the existing test only covers the approve step, which is why this shipped.
  4. If the ruling instead keeps the strip pending/approved-only, then story 26 must actually be built: wire enrolledFleetNode (dashboard/src/lib/pending.ts:146) into the fleet composition and give FleetSurface.vue a live re-read, or the device stays invisible to the operator after it joins.

Until one of those lands, the approve leg re-fires straight into the same 300 s blind timeout on every drive, at the cost of standing the droplet up again.

drive 20260829T085335Z red at approve: expect(locator).toBeVisible() failed Locator: locator('[data-field="connected-device"]').or(locator('[data-status="pending-device-error"]')).first() Expected: visible Timeout: 300000ms Error: element(
evidence: /home/swarm/swarm/Matou/idss/test-results/drive-device/20260829T085335Z on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured

## The failure Drive `20260829T085335Z` (target `device`, commit `e1a8cdcb`) went red at the `approve` leg (sig `c1ac37bc5a0d`), the 24th of 24 legs, after burning the full 300 s ceiling: ``` Locator: locator('[data-field="connected-device"]').or(locator('[data-status="pending-device-error"]')).first() Expected: visible Error: element(s) not found ``` `artifacts/legs.json` — `approve`, `red`, 300679 ms; every other leg green (`artifacts/verdict.json`: 23 green / 1 red). The device side succeeded. `artifacts/join-transcript.txt` walks the whole landing and ends `✓ joined the community network` / `✓ community trust installed` / `✓ takeover staged` / `✓ this machine is enrolled`; `artifacts/join-exit.txt` reads `exited 0 (approve red)`. Those ✓ lines are only printed after `Enroll` returns success — `internal/join/cli.go:258-272` (`land`: "It prints only after Enroll returns success, so every ✓ names a fact that provably happened (ADR 0100)"), which includes `ConfirmEnrolled`. `logs/device-journal.txt:1667` shows `netbird.service` started at 09:14:08 and `logs/device-stall.txt` shows the box holding mesh address `100.74.5.74`. The device really joined; the control plane really recorded `StatusEnrolled`. What the operator saw is in `artifacts/legs/approve-dash.png`: the Fleet tab at 09:19 with **no pending strip at all** and a resting list holding only `gateway`. The row did not sit at "approved — joining now", and no error state was raised — it simply left. ## The defect The pending projection deliberately excludes `Enrolled`: - `internal/controlapi/enroll.go:184-186` — `svc.ListPending(..., enroll.Query{Status: []enroll.Status{enroll.StatusPending, enroll.StatusApproved}})`, with the comment at `internal/controlapi/enroll.go:177-181`: *"Enrolled devices leave the strip and join the resting Fleet list (story 26), so they are not read here."* The dashboard holds the opposite contract: - `dashboard/src/lib/pending.ts:27-31` — *"`pending` and `approved` are the in-flight card states; `enrolled` is the landing; `declined`/`expired` are terminal — those rows leave the pending list."* - `dashboard/src/components/device-add/PendingDevicesSurface.vue:43-47` renders `ConnectedScreen` for `row.phase === 'enrolled'`; `dashboard/src/components/device-add/ConnectedScreen.vue:7` is the only place in the tree that emits `data-field="connected-device"`. - `dashboard/src/lib/api/enrollClient.ts:362` maps `phase: w.request.status as RequestPhase` straight off the wire — so `enrolled` is a phase the transport can never deliver. - `dashboard/src/components/device-add/PendingDevicesSurface.vue:95-99` filters `visible` to pending|approved|enrolled, and the strip is `v-if="visible.length"` (line 9) — an empty read removes the strip entirely, exactly as the screenshot shows. The derived architecture view agrees with the dashboard, not with the projection: `docs/architecture/15-device-node-lifecycle.md:74` — *"`Enrolled` = P2-S5 / P3-S5"* — and `docs/ux/flows/p2-device-add-cli.mermaid:18-19` — `S4 --"approves — device enrolled in the mesh"--> S5`, `S5 --"provision"--> P4S1`. The P2-S5 wireframe (`docs/ux/wireframes/p2-device-add-cli/p2-s5-connected.html:18`) stands on `admin.example.nz/fleet`. The divergence survived because the seam test drives a fake that CAN emit `enrolled`: `dashboard/tests/unit/pendingDevices.test.ts:126-135` calls `source.deviceEnrolled('req-0001')` on `FakePendingSource` and asserts `connected-device` renders. Nothing tests the live projection against that phase — `internal/controlapi/enroll_integration_test.go:262-268` only asserts the honest story-20 split (approve lands on `approved`, *not* `enrolled`). The story-26 alternative — the enrolled device joining the resting Fleet list instead — is not wired either, so the device currently vanishes from BOTH surfaces: - `dashboard/src/lib/pending.ts:146` `enrolledFleetNode()` has no caller anywhere in `dashboard/src` or `app/` (dead except for `dashboard/tests/unit/pendingDevices.test.ts:185-188`); - `dashboard/src/components/shell/FleetSurface.vue:186` loads the fleet composition once on `onMounted` with no poll, so even a server-side admission would not appear without a reload. `internal/enroll/ledger.go:544-556` does fire the `OnEnrolled` admission hook, but the operator's page never re-reads it. ## Suspected layer The control-plane HTTP projection (`internal/controlapi`), against the device-add dashboard contract. Not the mesh, not the agent, not the drive fixture: `app/tests/e2e/fixtures/deviceAdd.ts:206-214` is asking for exactly what `docs/architecture/15-device-node-lifecycle.md:74` promises. ## What plugging it needs A ruling on where P2-S5 lives, then the wiring: 1. **Recommended (matches the flow, the lifecycle doc, the wireframe and the surface):** add `enroll.StatusEnrolled` to the query at `internal/controlapi/enroll.go:185` and correct the comment at lines 177-181, so the landed request renders as the P2-S5 Connected card on the strip. 2. **The open question this needs a human on: when does the Connected card LEAVE.** `internal/enroll/ledger.go:621-648` (`ListPending`) never prunes; enrolled requests live in the ledger forever. A bare status-list change means a standing community accumulates one permanent Connected card per device ever enrolled — the flow's `S5 --provision--> P4S1` edge implies it should leave once the device is set up, but no rule exists for that today. Candidates: filter out enrolled requests whose node is already provisioned; bound by a recency window; or an explicit operator acknowledgement. 3. Either way, close the fake/production gap: an integration test at `internal/controlapi/enroll_integration_test.go` that confirms enrolled and asserts what `GET /api/v1/enroll/pending` returns — the existing test only covers the approve step, which is why this shipped. 4. If the ruling instead keeps the strip pending/approved-only, then story 26 must actually be built: wire `enrolledFleetNode` (`dashboard/src/lib/pending.ts:146`) into the fleet composition and give `FleetSurface.vue` a live re-read, or the device stays invisible to the operator after it joins. Until one of those lands, the `approve` leg re-fires straight into the same 300 s blind timeout on every drive, at the cost of standing the droplet up again. drive `20260829T085335Z` red at `approve`: `expect(locator).toBeVisible() failed Locator: locator('[data-field="connected-device"]').or(locator('[data-status="pending-device-error"]')).first() Expected: visible Timeout: 300000ms Error: element(` evidence: `/home/swarm/swarm/Matou/idss/test-results/drive-device/20260829T085335Z` on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured <!-- rehearsal-sig: c1ac37bc5a0d -->
Author
Member

Ruled by agent under ADR 0174 — veto anytime

The ruling: option 1 (recommended). P2-S5 lives ON the pending strip. Added
enroll.StatusEnrolled to the pending projection query so a landed request
renders as the "Connected — not yet set up" card, instead of leaving the strip
the instant it enrolls and vanishing from the operator's Fleet.

Why this is a two-way door I can rule. It is (a) revertible — a one-line
query change plus comment/spec/derived-client updates; (b) provable — a new
red-first integration test; (c) not on the one-way-door list. And it is the
ruling all four design contracts already agree on:

  • flow — docs/ux/flows/p2-device-add-cli.mermaid:18 S4 --approves — device enrolled in the mesh--> S5
  • lifecycle doc — docs/architecture/15-device-node-lifecycle.md:74 "Enrolled = P2-S5 / P3-S5"
  • wireframe — docs/ux/wireframes/p2-device-add-cli/p2-s5-connected.html stands on /fleet
  • surface — PendingDevicesSurface.vue renders ConnectedScreen (the only data-field="connected-device") for phase === 'enrolled'.

The projection excluding Enrolled was the sole divergence, and it survived
because the seam test drives a fake (FakePendingSource.deviceEnrolled) that
can emit enrolled while nothing tested the LIVE projection against that phase.

What landed — c7eef7e2

  • internal/controlapi/enroll.go — query {Pending, Approved} → {Pending, Approved, Enrolled}; projection comment corrected (Enrolled = P2-S5 on the strip, not "leaves the strip").
  • packages/openapi-spec/openapi.yaml — /enroll/pending summary + RequestView.status description updated to name the P2-S5 enrolled card; typed client regenerated (dashboard/src/lib/api/generated.ts, ADR 0037). The enrolled enum value was already present — no client type change.
  • internal/controlapi/enroll_integration_test.go — new red-first TestEnrollPending_EnrolledStaysOnStripAsConnectedCard: Approves over HTTP, ConfirmEnrolleds the device with its wt0 addr, asserts GET /api/v1/enroll/pending STILL returns the request (status enrolled, probed hostname + mesh address intact). This closes the fake/production gap the ticket named.
  • STATUS.md — lead updated.

Proof

  • Red before green: with {Pending, Approved} the new test failed pending = [], want the landed request still on the strip — reproducing the exact "device vanishes" bug. With Enrolled added it is green.
  • go test ./internal/enroll/... ./internal/controlapi/... ./internal/enrollwire/... → all green.
  • Dashboard seam tests green: pendingDevices.test.ts (11) + pendingActsLive.test.ts (2). These already prove phase === 'enrolled' → ConnectedScreen/connected-device renders; the two ends now meet at the wire contract.

The 300 s blind approve leg (drive 20260829T085335Z, sig c1ac37bc5a0d) went red because connected-device never rendered — the request had left the strip. With the projection now returning it, the dashboard maps enrolled → ConnectedScreen → connected-device, so the leg has a live green to reach. I did NOT re-run the droplet drive from this session (host/harness one-shot); the fix is proven at the seam/integration level the ticket explicitly asked for.

Spun out, not guessed — #982

The ticket's open question — when does the Connected card LEAVE — is a
design-tier decision with three candidates (prune-when-provisioned / recency
window / operator ack) and no chosen default, and it couples the enroll
projection to provisioning/fleet state. I deliberately did NOT guess it.
Filed as #982 (needs-design + bug) with a proposed default ruling
(candidate 1, prune-when-provisioned, which the S5→P4S1 flow edge implies),
and it carries the sibling FleetSurface.vue live-re-read gap. Until #982
lands, the #979 fix is net-correct (a just-joined device shows its true P2-S5
state) but a long-standing community will show stale Connected cards for
already-provisioned devices.

Closing #979: the stated defect — the projection never returns Enrolled, so
P2-S5 can never render live — is fixed and seam-proven.

## Ruled by agent under ADR 0174 — veto anytime **The ruling: option 1 (recommended).** P2-S5 lives ON the pending strip. Added `enroll.StatusEnrolled` to the pending projection query so a landed request renders as the "Connected — not yet set up" card, instead of leaving the strip the instant it enrolls and vanishing from the operator's Fleet. **Why this is a two-way door I can rule.** It is (a) revertible — a one-line query change plus comment/spec/derived-client updates; (b) provable — a new red-first integration test; (c) not on the one-way-door list. And it is the ruling all four design contracts already agree on: - flow — `docs/ux/flows/p2-device-add-cli.mermaid:18` `S4 --approves — device enrolled in the mesh--> S5` - lifecycle doc — `docs/architecture/15-device-node-lifecycle.md:74` "`Enrolled` = P2-S5 / P3-S5" - wireframe — `docs/ux/wireframes/p2-device-add-cli/p2-s5-connected.html` stands on `/fleet` - surface — `PendingDevicesSurface.vue` renders `ConnectedScreen` (the only `data-field="connected-device"`) for `phase === 'enrolled'`. The projection excluding `Enrolled` was the sole divergence, and it survived because the seam test drives a fake (`FakePendingSource.deviceEnrolled`) that can emit `enrolled` while nothing tested the LIVE projection against that phase. ## What landed — `c7eef7e2` - `internal/controlapi/enroll.go` — query `{Pending, Approved}` → `{Pending, Approved, Enrolled}`; projection comment corrected (Enrolled = P2-S5 on the strip, not "leaves the strip"). - `packages/openapi-spec/openapi.yaml` — `/enroll/pending` summary + `RequestView.status` description updated to name the P2-S5 enrolled card; typed client regenerated (`dashboard/src/lib/api/generated.ts`, ADR 0037). The `enrolled` enum value was already present — no client type change. - `internal/controlapi/enroll_integration_test.go` — new **red-first** `TestEnrollPending_EnrolledStaysOnStripAsConnectedCard`: Approves over HTTP, `ConfirmEnrolled`s the device with its `wt0` addr, asserts `GET /api/v1/enroll/pending` STILL returns the request (status enrolled, probed hostname + mesh address intact). This closes the fake/production gap the ticket named. - `STATUS.md` — lead updated. ## Proof - Red before green: with `{Pending, Approved}` the new test failed `pending = [], want the landed request still on the strip` — reproducing the exact "device vanishes" bug. With `Enrolled` added it is green. - `go test ./internal/enroll/... ./internal/controlapi/... ./internal/enrollwire/...` → all green. - Dashboard seam tests green: `pendingDevices.test.ts` (11) + `pendingActsLive.test.ts` (2). These already prove `phase === 'enrolled'` → `ConnectedScreen`/`connected-device` renders; the two ends now meet at the wire contract. The 300 s blind `approve` leg (drive `20260829T085335Z`, sig `c1ac37bc5a0d`) went red because `connected-device` never rendered — the request had left the strip. With the projection now returning it, the dashboard maps `enrolled` → `ConnectedScreen` → `connected-device`, so the leg has a live green to reach. I did NOT re-run the droplet drive from this session (host/harness one-shot); the fix is proven at the seam/integration level the ticket explicitly asked for. ## Spun out, not guessed — #982 The ticket's open question — **when does the Connected card LEAVE** — is a design-tier decision with three candidates (prune-when-provisioned / recency window / operator ack) and no chosen default, and it couples the enroll projection to provisioning/fleet state. I deliberately did NOT guess it. Filed as **#982** (`needs-design` + `bug`) with a proposed default ruling (candidate 1, prune-when-provisioned, which the `S5→P4S1` flow edge implies), and it carries the sibling `FleetSurface.vue` live-re-read gap. Until #982 lands, the #979 fix is net-correct (a just-joined device shows its true P2-S5 state) but a long-standing community will show stale Connected cards for already-provisioned devices. Closing #979: the stated defect — the projection never returns Enrolled, so P2-S5 can never render live — is fixed and seam-proven.
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#979
No description provided.