fleetstate + enroll + controlapi: a device KNOWS its kind, roles, location and the services it runs — the fleet row carries what the Overview card draws #1396

Closed
opened 2026-09-11 20:09:29 +00:00 by ben · 3 comments
Owner

Parent

Control-panel UI pass, Ben 2026-09-10/11 (branch founding-ui-two-colour-rail-ceremony, unmerged at filing). Device-add spec #13 (ADRs 0053–0057, DDR 0109); founding Access step P1-S4/S4a (ADR 0189 / DDR 0190). The dashboard half is BUILT on the branch: dashboard/src/components/device-add/{PlaceScreen,RentServerScreen,RentedScreen}.vue, DeviceAddSurface.vue (stages place → rent → rented | form), shell/DeviceAddDialog.vue, seam dashboard/src/lib/deviceAdd.ts (DevicePlaceOption, ServerOffer, RentServerRequest, RentedServer; OPTIONAL placeOptions/serverOffer/rentServer on DeviceAddSource), fake dashboard/tests/fakes/deviceAdd.ts, browser harness cd dashboard && pnpm harness → http://localhost:5198/panel.html?scenario=steady.

What to build

The Overview's device cards (dashboard/src/components/shell/DeviceCards.vue) draw five facts the control plane does not keep: kind (server | mini-pc | desktop | laptop), roles (one or more of gateway | server | flaky | backup | storage, outlined tags), location (free text — "Marae office", "Ana's place"), per-service memory (GB, from monitoring) and the services placed on the device (label + health chip). Today the dashboard fakes them (dashboard/src/lib/fleet.ts FleetNode.kind?/roles?/location?/services?, interim deviceRoles() fallback from the gateway flag + INTERMITTENT tag) and the enrol form already SENDS name/kind/location on the mint (MintCodeRequest.name/kind/location, POST /api/v1/enroll/codes), which the seam ignores.

  1. internal/enroll MintRequest (+ CodeView) carries name, kind, location; the code remembers them and the device that redeems it inherits them at approve (the fleet row's name is the operator's, else the agent's hostname as now).
  2. internal/fleetstate Device keeps Kind, Location, Roles (derived: gateway flag → gateway; provisioning's placements → server/storage/backup; monitoring's intermittent verdict → flaky — roles are FACTS from the stores, never a free-text field), and the services placed on it with monitoring's chip and memory reading (nil when monitoring has none — never 0).
  3. internal/controlapi/fleet.go FleetNode exposes kind, location, roles, services[] {service,label,mem_mb|null,chip} on GET /api/v1/fleet; the generated dashboard client (dashboard/src/lib/api/generated.ts) and fleetClient.ts map them; deviceRoles()'s fallback goes.
  4. Kind/location are EDITABLE later from the device detail (P9) — out of scope here; note it.

Acceptance criteria

  • Given a mint with {"name":"rimu","kind":"mini-pc","location":"Marae office"}, when that code's device is approved, then GET /api/v1/fleet lists a node named rimu with kind: mini-pc, location: Marae office.
  • Given a mint without them, when approved, then the row keeps today's name and kind/location are absent (never a fabricated default).
  • Given the gateway, when read, then roles contains gateway; given a node with a Nextcloud placement, then server; given monitoring's intermittent verdict, then flaky.
  • Given a node with two placed services, when read, then services lists both with monitoring's chip and mem_mb (or null), and the Overview card's rows match the Fleet tab's for that node.
  • Given the seam tests, when run, then the enroll ledger and fleetstate round-trip the three facts; given the dashboard suite, then DeviceCards renders from the real shape with no fallback.

Why agent

Two-way door: additive fields on two stores and one read; provable by seam tests + the harness.

## Parent Control-panel UI pass, Ben 2026-09-10/11 (branch `founding-ui-two-colour-rail-ceremony`, unmerged at filing). Device-add spec #13 (ADRs 0053–0057, DDR 0109); founding Access step P1-S4/S4a (ADR 0189 / DDR 0190). The dashboard half is BUILT on the branch: `dashboard/src/components/device-add/{PlaceScreen,RentServerScreen,RentedScreen}.vue`, `DeviceAddSurface.vue` (stages place → rent → rented | form), `shell/DeviceAddDialog.vue`, seam `dashboard/src/lib/deviceAdd.ts` (`DevicePlaceOption`, `ServerOffer`, `RentServerRequest`, `RentedServer`; OPTIONAL `placeOptions/serverOffer/rentServer` on `DeviceAddSource`), fake `dashboard/tests/fakes/deviceAdd.ts`, browser harness `cd dashboard && pnpm harness` → `http://localhost:5198/panel.html?scenario=steady`. ## What to build The Overview's device cards (`dashboard/src/components/shell/DeviceCards.vue`) draw five facts the control plane does not keep: **kind** (`server | mini-pc | desktop | laptop`), **roles** (one or more of `gateway | server | flaky | backup | storage`, outlined tags), **location** (free text — "Marae office", "Ana's place"), **per-service memory** (GB, from monitoring) and the **services placed on the device** (label + health chip). Today the dashboard fakes them (`dashboard/src/lib/fleet.ts` `FleetNode.kind?/roles?/location?/services?`, interim `deviceRoles()` fallback from the gateway flag + INTERMITTENT tag) and the enrol form already SENDS name/kind/location on the mint (`MintCodeRequest.name/kind/location`, `POST /api/v1/enroll/codes`), which the seam ignores. 1. `internal/enroll` `MintRequest` (+ `CodeView`) carries `name`, `kind`, `location`; the code remembers them and the device that redeems it inherits them at approve (the fleet row's name is the operator's, else the agent's hostname as now). 2. `internal/fleetstate` `Device` keeps `Kind`, `Location`, `Roles` (derived: gateway flag → `gateway`; provisioning's placements → `server`/`storage`/`backup`; monitoring's intermittent verdict → `flaky` — roles are FACTS from the stores, never a free-text field), and the services placed on it with monitoring's chip and memory reading (nil when monitoring has none — never 0). 3. `internal/controlapi/fleet.go` `FleetNode` exposes `kind`, `location`, `roles`, `services[] {service,label,mem_mb|null,chip}` on `GET /api/v1/fleet`; the generated dashboard client (`dashboard/src/lib/api/generated.ts`) and `fleetClient.ts` map them; `deviceRoles()`'s fallback goes. 4. Kind/location are EDITABLE later from the device detail (P9) — out of scope here; note it. ## Acceptance criteria - [ ] Given a mint with `{"name":"rimu","kind":"mini-pc","location":"Marae office"}`, when that code's device is approved, then `GET /api/v1/fleet` lists a node named rimu with `kind: mini-pc`, `location: Marae office`. - [ ] Given a mint without them, when approved, then the row keeps today's name and `kind`/`location` are absent (never a fabricated default). - [ ] Given the gateway, when read, then `roles` contains `gateway`; given a node with a Nextcloud placement, then `server`; given monitoring's intermittent verdict, then `flaky`. - [ ] Given a node with two placed services, when read, then `services` lists both with monitoring's chip and `mem_mb` (or null), and the Overview card's rows match the Fleet tab's for that node. - [ ] Given the seam tests, when run, then the enroll ledger and fleetstate round-trip the three facts; given the dashboard suite, then `DeviceCards` renders from the real shape with no fallback. ## Why agent Two-way door: additive fields on two stores and one read; provable by seam tests + the harness.

swarm-claim host=matou-dev-server-01 run=21978
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=21978 (automated multi-host claim — lowest live claim id works this ticket)

Ruled by agent under ADR 0174 — veto anytime.

Ruling: land the two stores + one read this ticket's "why agent" names (enroll + fleetstate + controlapi/fleet GET /api/v1/fleet + the OpenAPI contract). Defer the Overview device-card renderer half to the founding-ui-two-colour-rail-ceremony branch merge.

Why this split (the two-way door): the renderer this ticket cites is not in main — dashboard/src/components/shell/DeviceCards.vue, its deviceRoles() fallback, and the fleet.ts kind/roles/location/services view fields all ride the unmerged founding-ui-two-colour-rail-ceremony branch (the ticket itself says "the dashboard half is BUILT on the branch … unmerged at filing"). Additionally, per-service memory/health do not exist in internal/monitor: memory is per-NODE only, and per-(device,service) health lives unexported in provFaults/the alert set. This is the SAME split #1393 and #1375 landed and Ben accepted: Go/contract halves land now, the renderer half rides its own branch. Additive, reversible, provable by seam tests — not on the one-way-door list.

What landed:

  • enroll: MintRequest/CodeView/codeRecord/RequestView carry name/kind/location; the minted code remembers them, the redeeming device inherits them onto its request, they ride verbatim to Enrolled and round-trip the JSON store.
  • fleetstate: Device.Kind/Device.Location (off the enrolled request) and Device.Roles derived by DeriveRoles (gateway flag→gateway, a service placement→server, backup-copy→backup, monitoring's intermittent uptime→flaky) — never a free-text field; the operator's minted name overrides the placement name, else the placement/hostname stands as now.
  • controlapi/fleet.go: FleetNode exposes kind/location/roles/services[] {service,label,mem_mb,chip} on GET /api/v1/fleet. roles/services serialise [] never null; per-service mem_mb/chip rest null because monitoring holds no per-service reading yet (honest, ADR 0100). Label comes from the catalogue.
  • Contract: openapi.yaml grows FleetNode.kind/location/roles/services + a FleetNodeService schema; generated.ts regenerated (check:client green); fleetClient.ts maps them via the generic camelize (no change needed).

Proof: seam tests TestEnroll_DeviceFacts_RoundTrip/…_AbsentByDefault, TestProjection_DeviceFacts, TestDeriveRoles, TestFleetHandler_CarriesDeviceFacts; dashboard vitest (1455) + vue-tsc green; gofmt/vet clean.

Acceptance status: clauses 1–3 and the enroll/fleetstate round-trip of clause 5 are met at the seam; clause 4's "Overview card's rows match the Fleet tab's" and clause 5's "DeviceCards renders from the real shape with no fallback" reconcile at the founding-ui-two-colour-rail-ceremony merge (the render doesn't exist on main). Per-service mem_mb/chip await a monitoring per-service slice. Kind/location editing from device detail is P9 (out of scope, item 4).

**Ruled by agent under ADR 0174 — veto anytime.** **Ruling:** land the **two stores + one read** this ticket's "why agent" names (enroll + fleetstate + controlapi/fleet `GET /api/v1/fleet` + the OpenAPI contract). Defer the Overview device-card *renderer* half to the `founding-ui-two-colour-rail-ceremony` branch merge. **Why this split (the two-way door):** the renderer this ticket cites is **not in `main`** — `dashboard/src/components/shell/DeviceCards.vue`, its `deviceRoles()` fallback, and the `fleet.ts` `kind/roles/location/services` view fields all ride the unmerged `founding-ui-two-colour-rail-ceremony` branch (the ticket itself says "the dashboard half is BUILT on the branch … unmerged at filing"). Additionally, **per-service memory/health do not exist in `internal/monitor`**: memory is per-NODE only, and per-(device,service) health lives unexported in `provFaults`/the alert set. This is the SAME split #1393 and #1375 landed and Ben accepted: Go/contract halves land now, the renderer half rides its own branch. Additive, reversible, provable by seam tests — not on the one-way-door list. **What landed:** - **enroll:** `MintRequest`/`CodeView`/`codeRecord`/`RequestView` carry `name`/`kind`/`location`; the minted code remembers them, the redeeming device inherits them onto its request, they ride verbatim to Enrolled and round-trip the JSON store. - **fleetstate:** `Device.Kind`/`Device.Location` (off the enrolled request) and `Device.Roles` **derived** by `DeriveRoles` (gateway flag→`gateway`, a service placement→`server`, `backup-copy`→`backup`, monitoring's intermittent uptime→`flaky`) — never a free-text field; the operator's minted name overrides the placement name, else the placement/hostname stands as now. - **controlapi/fleet.go:** `FleetNode` exposes `kind`/`location`/`roles`/`services[] {service,label,mem_mb,chip}` on `GET /api/v1/fleet`. `roles`/`services` serialise `[]` never null; per-service `mem_mb`/`chip` rest **null** because monitoring holds no per-service reading yet (honest, ADR 0100). Label comes from the catalogue. - **Contract:** `openapi.yaml` grows `FleetNode.kind/location/roles/services` + a `FleetNodeService` schema; `generated.ts` regenerated (`check:client` green); `fleetClient.ts` maps them via the generic `camelize` (no change needed). **Proof:** seam tests `TestEnroll_DeviceFacts_RoundTrip`/`…_AbsentByDefault`, `TestProjection_DeviceFacts`, `TestDeriveRoles`, `TestFleetHandler_CarriesDeviceFacts`; dashboard vitest (1455) + `vue-tsc` green; gofmt/vet clean. **Acceptance status:** clauses 1–3 and the enroll/fleetstate round-trip of clause 5 are met at the seam; clause 4's "Overview card's rows match the Fleet tab's" and clause 5's "`DeviceCards` renders from the real shape with no fallback" reconcile at the `founding-ui-two-colour-rail-ceremony` merge (the render doesn't exist on `main`). Per-service `mem_mb`/`chip` await a monitoring per-service slice. Kind/location editing from device detail is P9 (out of scope, item 4).

close-report for #1396 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1396,
  "status": "success",
  "commits": [
    "878acba622f6b7c416fd7005a2401adc8b8471b6"
  ],
  "changed_files": [
    "STATUS.md",
    "control-plane/cmd/control-plane/whole_surfaces.go",
    "control-plane/cmd/control-plane/whole_surfaces_test.go",
    "dashboard/src/lib/api/generated.ts",
    "internal/controlapi/fleet.go",
    "internal/controlapi/fleet_integration_test.go",
    "internal/enroll/enroll.go",
    "internal/enroll/enroll_test.go",
    "internal/enroll/ledger.go",
    "internal/fleetstate/fleetstate.go",
    "internal/fleetstate/projection.go",
    "internal/fleetstate/projection_test.go",
    "packages/openapi-spec/openapi.yaml"
  ],
  "tests": [
    {
      "command": "go test ./internal/enroll/... ./internal/fleetstate/... ./internal/controlapi/...",
      "exit_code": 0
    },
    {
      "command": "go test ./control-plane/cmd/control-plane/...",
      "exit_code": 0
    },
    {
      "command": "node packages/openapi-spec/scripts/generate-client.mjs --check",
      "exit_code": 0
    },
    {
      "command": "dashboard: vue-tsc -p tsconfig.json --noEmit",
      "exit_code": 0
    },
    {
      "command": "dashboard: vitest run (1455 tests)",
      "exit_code": 0
    },
    {
      "command": "gofmt -l (touched Go dirs)",
      "exit_code": 0
    },
    {
      "command": "go vet (touched packages)",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Given a mint with {name:rimu,kind:mini-pc,location:Marae office}, when approved, then GET /api/v1/fleet lists a node named rimu with kind: mini-pc, location: Marae office": "enroll carries the facts (enroll.go/ledger.go) → fleetstate projection reads them onto Device.Kind/Location and the operator name overrides the placement name (projection.go) → controlapi FleetNode exposes kind/location (fleet.go, whole_surfaces.go). Proven at the seam by TestProjection_DeviceFacts (name=rimu, kind=mini-pc, location=Marae office) + TestFleetHandler_CarriesDeviceFacts (kind/location on GET /api/v1/fleet).",
    "Given a mint without them, when approved, then the row keeps today's name and kind/location are absent (never a fabricated default)": "TestEnroll_DeviceFacts_AbsentByDefault (request carries none) + TestProjection_DeviceFacts (device b: placement name host-b kept, kind/location empty). Fields are omitempty end to end.",
    "Given the gateway, when read, then roles contains gateway; a node with a Nextcloud placement then server; monitoring's intermittent verdict then flaky": "fleetstate.DeriveRoles (fleetstate.go); proven by TestDeriveRoles + TestProjection_DeviceFacts (a: gateway+server from the files/Nextcloud placement; b: flaky from the intermittent uptime).",
    "Given a node with two placed services, when read, then services lists both with monitoring's chip and mem_mb (or null), and the Overview card's rows match the Fleet tab's for that node": "PARTIAL — services[] {service,label,mem_mb,chip} exposed on GET /api/v1/fleet (fleet.go, whole_surfaces.go), proven by TestFleetHandler_CarriesDeviceFacts (two services; one with mem_mb+chip, one with null). Per-service mem_mb/chip rest null on main (no per-service monitoring exists yet). 'Overview card matches Fleet tab' needs DeviceCards.vue, which is on the unmerged founding-ui-two-colour-rail-ceremony branch — reconciles at that merge (ADR 0174 ruling on the issue).",
    "Given the seam tests, when run, then the enroll ledger and fleetstate round-trip the three facts; given the dashboard suite, then DeviceCards renders from the real shape with no fallback": "Seam round-trip MET: TestEnroll_DeviceFacts_RoundTrip (mint→redeem→enrolled + JSON store restart) + TestProjection_DeviceFacts. DeviceCards render clause DEFERRED: DeviceCards.vue and deviceRoles() do not exist on main (unmerged branch) — the dashboard suite (1455 tests) + vue-tsc are green against the shipped wire shape; the render reconciles at the branch merge (ADR 0174 ruling)."
  },
  "summary": "Landed the enroll + fleetstate stores and the controlapi fleet read (plus the OpenAPI contract) so a device's kind, derived roles, location and placed services flow mint→code→fleet row; the Overview device-card renderer rides the unmerged founding-ui-two-colour-rail-ceremony branch (ADR 0174 ruling).",
  "reason": "",
  "blockers": []
}
**close-report** for #1396 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1396, "status": "success", "commits": [ "878acba622f6b7c416fd7005a2401adc8b8471b6" ], "changed_files": [ "STATUS.md", "control-plane/cmd/control-plane/whole_surfaces.go", "control-plane/cmd/control-plane/whole_surfaces_test.go", "dashboard/src/lib/api/generated.ts", "internal/controlapi/fleet.go", "internal/controlapi/fleet_integration_test.go", "internal/enroll/enroll.go", "internal/enroll/enroll_test.go", "internal/enroll/ledger.go", "internal/fleetstate/fleetstate.go", "internal/fleetstate/projection.go", "internal/fleetstate/projection_test.go", "packages/openapi-spec/openapi.yaml" ], "tests": [ { "command": "go test ./internal/enroll/... ./internal/fleetstate/... ./internal/controlapi/...", "exit_code": 0 }, { "command": "go test ./control-plane/cmd/control-plane/...", "exit_code": 0 }, { "command": "node packages/openapi-spec/scripts/generate-client.mjs --check", "exit_code": 0 }, { "command": "dashboard: vue-tsc -p tsconfig.json --noEmit", "exit_code": 0 }, { "command": "dashboard: vitest run (1455 tests)", "exit_code": 0 }, { "command": "gofmt -l (touched Go dirs)", "exit_code": 0 }, { "command": "go vet (touched packages)", "exit_code": 0 } ], "criteria": { "Given a mint with {name:rimu,kind:mini-pc,location:Marae office}, when approved, then GET /api/v1/fleet lists a node named rimu with kind: mini-pc, location: Marae office": "enroll carries the facts (enroll.go/ledger.go) → fleetstate projection reads them onto Device.Kind/Location and the operator name overrides the placement name (projection.go) → controlapi FleetNode exposes kind/location (fleet.go, whole_surfaces.go). Proven at the seam by TestProjection_DeviceFacts (name=rimu, kind=mini-pc, location=Marae office) + TestFleetHandler_CarriesDeviceFacts (kind/location on GET /api/v1/fleet).", "Given a mint without them, when approved, then the row keeps today's name and kind/location are absent (never a fabricated default)": "TestEnroll_DeviceFacts_AbsentByDefault (request carries none) + TestProjection_DeviceFacts (device b: placement name host-b kept, kind/location empty). Fields are omitempty end to end.", "Given the gateway, when read, then roles contains gateway; a node with a Nextcloud placement then server; monitoring's intermittent verdict then flaky": "fleetstate.DeriveRoles (fleetstate.go); proven by TestDeriveRoles + TestProjection_DeviceFacts (a: gateway+server from the files/Nextcloud placement; b: flaky from the intermittent uptime).", "Given a node with two placed services, when read, then services lists both with monitoring's chip and mem_mb (or null), and the Overview card's rows match the Fleet tab's for that node": "PARTIAL — services[] {service,label,mem_mb,chip} exposed on GET /api/v1/fleet (fleet.go, whole_surfaces.go), proven by TestFleetHandler_CarriesDeviceFacts (two services; one with mem_mb+chip, one with null). Per-service mem_mb/chip rest null on main (no per-service monitoring exists yet). 'Overview card matches Fleet tab' needs DeviceCards.vue, which is on the unmerged founding-ui-two-colour-rail-ceremony branch — reconciles at that merge (ADR 0174 ruling on the issue).", "Given the seam tests, when run, then the enroll ledger and fleetstate round-trip the three facts; given the dashboard suite, then DeviceCards renders from the real shape with no fallback": "Seam round-trip MET: TestEnroll_DeviceFacts_RoundTrip (mint→redeem→enrolled + JSON store restart) + TestProjection_DeviceFacts. DeviceCards render clause DEFERRED: DeviceCards.vue and deviceRoles() do not exist on main (unmerged branch) — the dashboard suite (1455 tests) + vue-tsc are green against the shipped wire shape; the render reconciles at the branch merge (ADR 0174 ruling)." }, "summary": "Landed the enroll + fleetstate stores and the controlapi fleet read (plus the OpenAPI contract) so a device's kind, derived roles, location and placed services flow mint→code→fleet row; the Overview device-card renderer rides the unmerged founding-ui-two-colour-rail-ceremony branch (ADR 0174 ruling).", "reason": "", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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#1396
No description provided.