Spec: community mesh plane on the gateway + setup key at Approve (ADR 0214, child of device-add #13, closes #956's rung) #960

Open
opened 2026-08-28 21:46:30 +00:00 by ben · 0 comments
Owner

Parent

Wayfinder map: Matou/ourcloud#7 — device-add (defined on ticket #9). This is a child spec of spec #13 (device-add), closing the rung #13 deferred to "#844" and #956 surfaced: the mesh half of a device's grant. Ruled on #956 by Ben (option 1, BUILD) and shaped by ADR 0214 (amends ADR 0039; binds ADR 0159, 0199, 0209, 0210). Inherits the map's cross-feature constraints: clan substrate behind the clan seam, one enrollment mechanism with full community CA at v1, Netbird mesh, advice never veto. Design contract: docs/ux/flows/p3-device-add-app.mermaid (P3-S4 → P3-S5, plus the new P3-S4 failed-landing branch) and docs/ux/wireframes/p3-device-add-app/ (one ✎ state added to the dashboard's pending-devices strip). Glossary: mesh plane, setup key (CONTEXT.md, ADR 0214).

Problem Statement

An operator approves a device and the device dies on its own terminal. Phase-5 drive 20260828T202109Z reached 23/24 legs: the gateway signs the grant, the device collects it, and netbird up refuses the admission — because the grant's mesh half is placeholder material (random bytes and the fabricated host mesh.internal) and the community has no mesh plane at all: nothing on the gateway coordinates peers, so there is nothing real to hand a device. The operator's strip sits at "approved — joining now" for five minutes and never learns why. Every later step of device-add and provisioning (assess, files on a member device over the mesh, takeover-ready over the mesh) is unreachable until a device can actually join.

Solution

The community gateway ships the mesh plane — Netbird management, signal and relay — as part of both gateway renders, reachable from a member's home through the front door on mesh.<apex>. When the operator approves a connection request, the control plane mints a setup key for that request through a new MeshMinter port and puts it in the grant; the device redeems it once at landing, reads its own mesh address off the box and reports it as before (ADR 0209). The gateway joins its own plane at first deploy, and every unit that binds the mesh interface orders on it (ADR 0159). If a landing fails, the device reports the failure back and the operator sees it on the strip in seconds. Members never log into Netbird; the control plane is the plane's only user, with one service identity per identity carrier.

User Stories

  1. As an operator, I want approving a device to give it a real mesh admission, so that the device actually joins the community network.
    • Given a Pending connection request and a whole composition with the mesh plane up, When I approve it on the dashboard, Then the grant carries a setup key minted for node-<requestID> and Management is https://mesh.<apex>:443, and the strip shows "approved — joining now".
  2. As a device owner, I want netbird up to succeed with the admission I was given, so that P3-S4 Joining reaches P3-S5 Joined.
    • Given a device holding an approved grant, When the agent redeems it, Then the mesh comes up, the device's own wt0 address is read from netbird status, and ConfirmEnrolled carries that address (never a control-plane-derived one).
  3. As an operator, I want a failed landing to show on the strip, so that I am not left watching "joining now" for five minutes.
    • Given an approved request whose device failed to land, When the device reports the failure, Then the row renders pending-device-error with the device's own sentence within seconds, the request stays Approved (the grant is still the device's to retry), and the e2e race resolves on the error, not the timeout.
  4. As an operator, I want an honest refusal when the mesh plane is missing, so that a misconfigured gateway fails at Approve, not on the device.
    • Given a composition with no MeshMinter wired, When I approve, Then Approve fails with the named ErrNoMeshPlane, surfaced through the strip's error channel with a legible sentence (parity with ErrNoCA).
  5. As an operator, I want the mesh plane to ship with the gateway on both carriers, so that a kanidm community and an IDIP community both have a mesh without extra setup.
    • Given a founding on either carrier, When the gateway deploys, Then netbird-management, netbird-signal and coturn are running, the datastore key and coturn secret are clan vars generated on the gateway, and the eval smoke asserts every dereferenced generator by name.
  6. As a device owner at home, I want to reach the plane from outside the community's LAN, so that a rented gateway admits my device over the internet.
    • Given a rented gateway, When a device dials https://mesh.<apex>:443, Then the front door routes management and signal gRPC to the local daemons under a public-CA certificate, and the port table (8011/8012) is never exposed on the WAN directly.
  7. As a device owner on the gateway's LAN, I want enrolment to work before wt0 exists, so that the first peer can join.
    • Given the plane's control ports open on the LAN-facing nic and wt0, When a peer dials over the LAN, Then management answers (the spike Q5 nuance is honoured).
  8. As the control plane, I want one service identity per carrier to talk to the plane's API, so that no member ever needs a Netbird login.
    • Given the kanidm carrier, When the control plane requests a token, Then a client-credentials token from kanidm is accepted by POST /api/setup-keys; Given the IDIP carrier, the same via idss-idp. (Verification V1 — see Testing.)
  9. As an operator, I want each setup key single-use and request-scoped, so that a leaked admission admits at most one peer and is revocable by request.
    • Given a minted key, When it is redeemed once, Then a second redemption is refused; When the request is revoked, Then the peer it admitted is removed by its node-<requestID> name/group.
  10. As the gateway, I want to peer my own plane at first deploy, so that mesh-bound services have a wt0 to bind (ADR 0159).
    • Given a fresh deploy, When management and the identity provider are up, Then the idss-mesh-self-admit oneshot mints a key through the same API and brings the gateway's peer up; re-running it is a no-op when already connected; it retries on failure without a start limit.
  11. As a maintainer, I want every unit that binds wt0 to order on the mesh client, so that a reboot never races the mesh (ADR 0159 made true).
    • Given the code, docs-editing, files and control-plane units, When rendered, Then each declares after/wants on the mesh client unit via one shared helper, and the eval smoke asserts it.
  12. As a maintainer, I want the placeholder admission gone, so that a fabricated admission can never read as redeemable again.
    • Given the enroll package, When built, Then MeshAdmissionFor no longer exists, the gateway role's admission is the zero value, and TLSPin is empty on member grants.
  13. As an operator, I want the mesh and relay port groups to mean what they say, so that a closed group degrades by name once devices exist.
    • Given a self-hosted gateway with a device enrolled, When the mesh group is closed, Then monitoring names it (DDR 0140), no change to the required set at founding.
  14. As a maintainer, I want the spike's traps recorded, so that the next render change does not re-learn them.
    • Given the render lands, When GOTCHAS is read, Then signal-port, datastore-key, coturn-ownership and LAN-before-wt0 entries exist.
  15. As a design-verify reviewer, I want the failed-landing state on the wireframe, so that the shipped strip can be checked against a contract.
    • Given p3-device-add-app, When wireframes are read, Then a ✎ pending-device-error state on the dashboard strip exists with data-status="pending-device-error" and the device's sentence field.

Implementation Decisions

  • Mesh plane render (clan seam). A netbirdServer emitter in the gateway renders (both kanidm and IDIP), gated on a new GatewayFacts.Mesh flag the founding paths set; promotes the spike's content, not its file (the module is never added to the known-module list). Generator name constants netbird-datastore and netbird-coturn are the render↔feed contract and are asserted like the CA generators. No Netbird dashboard. Firewall: 8011/8012 on the LAN nic and wt0; 51820/udp + 3478/udp are the existing mesh/relay port groups.
  • Front door. One additional host mesh.<apex> with three path routes (management gRPC, signal gRPC, /api) to localhost; certificate via the existing acme-dns path. Signal URI = front-door host with an explicit :443.
  • Admission shape. MeshAdmission{SetupKey, Management, TLSPin} unchanged; Management is the absolute front-door URI, TLSPin empty, Redeemable() unchanged.
  • MeshMinter port on the ledger config beside Granter: Mint(ctx, GrantSpec, now) (MeshAdmission, error). Approve calls Granter.Grant then MeshMinter.Mint; nil minter → ErrNoMeshPlane (composition-root wiring mirrors productionCommunityCA: env in, port or nil out, one honest log line). Production minter calls the gateway-local management API with the carrier's service token; keys are single-use, request-TTL, named/grouped node-<requestID>. MeshAdmissionFor deleted.
  • Service identity per carrier. kanidm: an OAuth2 client for the control plane with client-credentials; IDIP: the bridge issues the same. Token source is behind one small interface so V1's outcome (or the PAT fallback as a clan var) changes the adapter, not the port.
  • Gateway self-peer + ordering. Gateway render declares the Netbird client (wt0, 51820) pointed at its own plane; idss-mesh-self-admit oneshot after management + identity; shared meshBound() render helper adopted by every wt0-binding unit in the same slice.
  • Failed-landing report. ReportLandingFailed(ctx, requestID, err) on the join orchestrator's control-plane port and a matching control-API verb; ledger stores LandingError on the Approved view; PendingDevicesSurface renders it as pending-device-error from the read, not only from the Approve verb's own error.
  • Not the address oracle. The plane never supplies a device's address; ADR 0209 ruling 3 stands.
  • Glossary + architecture diagram: mesh plane, setup key already in CONTEXT.md; docs/architecture gains the mesh-plane view in the render slice.

Testing Decisions

Good tests exercise the existing seams from outside: the ledger through its public verbs with fakes at its ports; renders through their emitted text and the nix eval smoke; the join orchestrator through its fake control plane and mesh; the dashboard through component tests on data-status/data-field; the whole through the standing phase-5 drive.

  • Ledger seam (existing, enroll): Approve with a fake MeshMinter → grant carries the minted admission; nil minter → ErrNoMeshPlane, request stays Pending; ReportLandingFailed → LandingError on the view, status Approved, idempotent. Prior art: TestFilesGranter_SignsFromSplitFilesAndFailsNoCA, the ledger Approve tests, enrolltesting's granter stub (gains a minter stub).
  • Clan render seam (existing): string assertions on both gateway renders (services present, generators declared, exports gated on Mesh, meshBound on every wt0 unit, front-door mesh.<apex> routes) + the eval smoke. Prior art: community_ca_vars_test.go, gatewayAssertions tests.
  • Join seam (existing): a mesh failure at landing calls ReportLandingFailed with the sentence and does not call ConfirmEnrolled. Prior art: resume_anchor_test.go, land tests.
  • Dashboard component (existing): a row whose read carries LandingError renders pending-device-error with the sentence. Prior art: PendingDevicesSurface specs.
  • Verification V1 (new rung, live): on the standing rehearsal-d community, a client-credentials token from the carrier's issuer mints a setup key via POST /api/setup-keys (spike Q4 proved the user-JWT variant). Recorded in docs/spike-findings; its failure swaps the token adapter (PAT fallback), not the port.
  • Whole: phase-5 drive (#854) approve → assess green with a real wt0 address on ConfirmEnrolled; the e2e fixture's existing race needs no new surface.

Out of Scope

  • Members as Netbird users / Netbird's device-auth flow (ADR 0214 rejected); deviceapprove.go stays for other CLIs.
  • Netbird dashboard; Netbird groups/policies beyond the per-request group.
  • Mesh ACLs between member devices (a later policy feature).
  • Self-hosted front-door reachability itself (ADR 0177).
  • Files-on-device (ADR 0210) — first consumer, separate spec; this spec only makes its precondition true.
  • Device removal / revocation UI (ADR 0057 posture; the per-request naming here is the hook, not the feature).

Further Notes

  • The map's device-add constraint says "Netbird mesh with no relay"; ADR 0039 and the relay port group say relay ships. ADR 0214 follows 0039 and the spike (coturn on). The relay port group stays informational at founding; if Ben prefers no relay, it is one flag in the render — flag it at slice-map, not a blocker.
  • V1 is the only unknown with teeth; sequence it first in the plane slice so the minter slice never builds on a guess.
  • Both drives are parked on this: #854 (phase 5) directly; #788 (IDIP) reaches its own device leg later.
## Parent Wayfinder map: https://git.matou.nz/Matou/ourcloud/issues/7 — device-add (defined on ticket #9). This is a **child spec of spec #13** (device-add), closing the rung #13 deferred to "#844" and #956 surfaced: the mesh half of a device's grant. Ruled on #956 by Ben (option 1, BUILD) and shaped by **ADR 0214** (amends ADR 0039; binds ADR 0159, 0199, 0209, 0210). Inherits the map's cross-feature constraints: clan substrate behind the `clan` seam, one enrollment mechanism with full community CA at v1, Netbird mesh, advice never veto. Design contract: `docs/ux/flows/p3-device-add-app.mermaid` (P3-S4 → P3-S5, plus the new P3-S4 failed-landing branch) and `docs/ux/wireframes/p3-device-add-app/` (one ✎ state added to the dashboard's pending-devices strip). Glossary: **mesh plane**, **setup key** (CONTEXT.md, ADR 0214). ## Problem Statement An operator approves a device and the device dies on its own terminal. Phase-5 drive `20260828T202109Z` reached 23/24 legs: the gateway signs the grant, the device collects it, and `netbird up` refuses the admission — because the grant's mesh half is placeholder material (random bytes and the fabricated host `mesh.internal`) and the community has **no mesh plane at all**: nothing on the gateway coordinates peers, so there is nothing real to hand a device. The operator's strip sits at "approved — joining now" for five minutes and never learns why. Every later step of device-add and provisioning (assess, files on a member device over the mesh, takeover-ready over the mesh) is unreachable until a device can actually join. ## Solution The community gateway ships the **mesh plane** — Netbird management, signal and relay — as part of both gateway renders, reachable from a member's home through the front door on `mesh.<apex>`. When the operator approves a connection request, the control plane mints a **setup key** for that request through a new `MeshMinter` port and puts it in the grant; the device redeems it once at landing, reads its own mesh address off the box and reports it as before (ADR 0209). The gateway joins its own plane at first deploy, and every unit that binds the mesh interface orders on it (ADR 0159). If a landing fails, the device reports the failure back and the operator sees it on the strip in seconds. Members never log into Netbird; the control plane is the plane's only user, with one service identity per identity carrier. ## User Stories 1. As an operator, I want approving a device to give it a real mesh admission, so that the device actually joins the community network. - Given a Pending connection request and a whole composition with the mesh plane up, When I approve it on the dashboard, Then the grant carries a setup key minted for `node-<requestID>` and `Management` is `https://mesh.<apex>:443`, and the strip shows "approved — joining now". 2. As a device owner, I want `netbird up` to succeed with the admission I was given, so that P3-S4 Joining reaches P3-S5 Joined. - Given a device holding an approved grant, When the agent redeems it, Then the mesh comes up, the device's own `wt0` address is read from `netbird status`, and `ConfirmEnrolled` carries that address (never a control-plane-derived one). 3. As an operator, I want a failed landing to show on the strip, so that I am not left watching "joining now" for five minutes. - Given an approved request whose device failed to land, When the device reports the failure, Then the row renders `pending-device-error` with the device's own sentence within seconds, the request stays Approved (the grant is still the device's to retry), and the e2e race resolves on the error, not the timeout. 4. As an operator, I want an honest refusal when the mesh plane is missing, so that a misconfigured gateway fails at Approve, not on the device. - Given a composition with no `MeshMinter` wired, When I approve, Then Approve fails with the named `ErrNoMeshPlane`, surfaced through the strip's error channel with a legible sentence (parity with `ErrNoCA`). 5. As an operator, I want the mesh plane to ship with the gateway on both carriers, so that a kanidm community and an IDIP community both have a mesh without extra setup. - Given a founding on either carrier, When the gateway deploys, Then `netbird-management`, `netbird-signal` and coturn are running, the datastore key and coturn secret are clan vars generated on the gateway, and the eval smoke asserts every dereferenced generator by name. 6. As a device owner at home, I want to reach the plane from outside the community's LAN, so that a rented gateway admits my device over the internet. - Given a rented gateway, When a device dials `https://mesh.<apex>:443`, Then the front door routes management and signal gRPC to the local daemons under a public-CA certificate, and the port table (8011/8012) is never exposed on the WAN directly. 7. As a device owner on the gateway's LAN, I want enrolment to work before `wt0` exists, so that the first peer can join. - Given the plane's control ports open on the LAN-facing nic and `wt0`, When a peer dials over the LAN, Then management answers (the spike Q5 nuance is honoured). 8. As the control plane, I want one service identity per carrier to talk to the plane's API, so that no member ever needs a Netbird login. - Given the kanidm carrier, When the control plane requests a token, Then a client-credentials token from kanidm is accepted by `POST /api/setup-keys`; Given the IDIP carrier, the same via `idss-idp`. (Verification V1 — see Testing.) 9. As an operator, I want each setup key single-use and request-scoped, so that a leaked admission admits at most one peer and is revocable by request. - Given a minted key, When it is redeemed once, Then a second redemption is refused; When the request is revoked, Then the peer it admitted is removed by its `node-<requestID>` name/group. 10. As the gateway, I want to peer my own plane at first deploy, so that mesh-bound services have a `wt0` to bind (ADR 0159). - Given a fresh deploy, When management and the identity provider are up, Then the `idss-mesh-self-admit` oneshot mints a key through the same API and brings the gateway's peer up; re-running it is a no-op when already connected; it retries on failure without a start limit. 11. As a maintainer, I want every unit that binds `wt0` to order on the mesh client, so that a reboot never races the mesh (ADR 0159 made true). - Given the code, docs-editing, files and control-plane units, When rendered, Then each declares `after`/`wants` on the mesh client unit via one shared helper, and the eval smoke asserts it. 12. As a maintainer, I want the placeholder admission gone, so that a fabricated admission can never read as redeemable again. - Given the enroll package, When built, Then `MeshAdmissionFor` no longer exists, the gateway role's admission is the zero value, and `TLSPin` is empty on member grants. 13. As an operator, I want the mesh and relay port groups to mean what they say, so that a closed group degrades by name once devices exist. - Given a self-hosted gateway with a device enrolled, When the mesh group is closed, Then monitoring names it (DDR 0140), no change to the required set at founding. 14. As a maintainer, I want the spike's traps recorded, so that the next render change does not re-learn them. - Given the render lands, When GOTCHAS is read, Then signal-port, datastore-key, coturn-ownership and LAN-before-`wt0` entries exist. 15. As a design-verify reviewer, I want the failed-landing state on the wireframe, so that the shipped strip can be checked against a contract. - Given `p3-device-add-app`, When wireframes are read, Then a ✎ pending-device-error state on the dashboard strip exists with `data-status="pending-device-error"` and the device's sentence field. ## Implementation Decisions - **Mesh plane render (clan seam).** A `netbirdServer` emitter in the gateway renders (both kanidm and IDIP), gated on a new `GatewayFacts.Mesh` flag the founding paths set; promotes the spike's *content*, not its file (the module is never added to the known-module list). Generator name constants `netbird-datastore` and `netbird-coturn` are the render↔feed contract and are asserted like the CA generators. No Netbird dashboard. Firewall: 8011/8012 on the LAN nic and `wt0`; 51820/udp + 3478/udp are the existing mesh/relay port groups. - **Front door.** One additional host `mesh.<apex>` with three path routes (management gRPC, signal gRPC, `/api`) to localhost; certificate via the existing acme-dns path. Signal `URI` = front-door host with an explicit `:443`. - **Admission shape.** `MeshAdmission{SetupKey, Management, TLSPin}` unchanged; `Management` is the absolute front-door URI, `TLSPin` empty, `Redeemable()` unchanged. - **`MeshMinter` port** on the ledger config beside `Granter`: `Mint(ctx, GrantSpec, now) (MeshAdmission, error)`. `Approve` calls `Granter.Grant` then `MeshMinter.Mint`; nil minter → `ErrNoMeshPlane` (composition-root wiring mirrors `productionCommunityCA`: env in, port or nil out, one honest log line). Production minter calls the gateway-local management API with the carrier's service token; keys are single-use, request-TTL, named/grouped `node-<requestID>`. `MeshAdmissionFor` deleted. - **Service identity per carrier.** kanidm: an OAuth2 client for the control plane with client-credentials; IDIP: the bridge issues the same. Token source is behind one small interface so V1's outcome (or the PAT fallback as a clan var) changes the adapter, not the port. - **Gateway self-peer + ordering.** Gateway render declares the Netbird client (`wt0`, 51820) pointed at its own plane; `idss-mesh-self-admit` oneshot after management + identity; shared `meshBound()` render helper adopted by every `wt0`-binding unit in the same slice. - **Failed-landing report.** `ReportLandingFailed(ctx, requestID, err)` on the join orchestrator's control-plane port and a matching control-API verb; ledger stores `LandingError` on the Approved view; `PendingDevicesSurface` renders it as `pending-device-error` from the *read*, not only from the Approve verb's own error. - **Not the address oracle.** The plane never supplies a device's address; ADR 0209 ruling 3 stands. - Glossary + architecture diagram: **mesh plane**, **setup key** already in CONTEXT.md; `docs/architecture` gains the mesh-plane view in the render slice. ## Testing Decisions Good tests exercise the existing seams from outside: the ledger through its public verbs with fakes at its ports; renders through their emitted text and the nix eval smoke; the join orchestrator through its fake control plane and mesh; the dashboard through component tests on `data-status`/`data-field`; the whole through the standing phase-5 drive. - **Ledger seam (existing, `enroll`)**: `Approve` with a fake `MeshMinter` → grant carries the minted admission; nil minter → `ErrNoMeshPlane`, request stays Pending; `ReportLandingFailed` → `LandingError` on the view, status Approved, idempotent. Prior art: `TestFilesGranter_SignsFromSplitFilesAndFailsNoCA`, the ledger Approve tests, `enrolltesting`'s granter stub (gains a minter stub). - **Clan render seam (existing)**: string assertions on both gateway renders (services present, generators declared, exports gated on `Mesh`, `meshBound` on every `wt0` unit, front-door `mesh.<apex>` routes) + the eval smoke. Prior art: `community_ca_vars_test.go`, `gatewayAssertions` tests. - **Join seam (existing)**: a mesh failure at landing calls `ReportLandingFailed` with the sentence and does not call `ConfirmEnrolled`. Prior art: `resume_anchor_test.go`, land tests. - **Dashboard component (existing)**: a row whose read carries `LandingError` renders `pending-device-error` with the sentence. Prior art: `PendingDevicesSurface` specs. - **Verification V1 (new rung, live)**: on the standing `rehearsal-d` community, a client-credentials token from the carrier's issuer mints a setup key via `POST /api/setup-keys` (spike Q4 proved the user-JWT variant). Recorded in `docs/spike-findings`; its failure swaps the token adapter (PAT fallback), not the port. - **Whole**: phase-5 drive (#854) `approve` → `assess` green with a real `wt0` address on `ConfirmEnrolled`; the e2e fixture's existing race needs no new surface. ## Out of Scope - Members as Netbird users / Netbird's device-auth flow (ADR 0214 rejected); `deviceapprove.go` stays for other CLIs. - Netbird dashboard; Netbird groups/policies beyond the per-request group. - Mesh ACLs between member devices (a later policy feature). - Self-hosted front-door reachability itself (ADR 0177). - Files-on-device (ADR 0210) — first consumer, separate spec; this spec only makes its precondition true. - Device removal / revocation UI (ADR 0057 posture; the per-request naming here is the hook, not the feature). ## Further Notes - The map's device-add constraint says "Netbird mesh with **no relay**"; ADR 0039 and the relay port group say relay ships. ADR 0214 follows 0039 and the spike (coturn on). The relay port group stays informational at founding; if Ben prefers no relay, it is one flag in the render — flag it at slice-map, not a blocker. - V1 is the only unknown with teeth; sequence it first in the plane slice so the minter slice never builds on a guess. - Both drives are parked on this: #854 (phase 5) directly; #788 (IDIP) reaches its own device leg later.
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#960
No description provided.