device-add: the gateway peers its own mesh plane at first deploy, and every wt0-binding unit orders on the mesh (ADR 0214 d.5, makes ADR 0159 true) #964

Closed
opened 2026-08-28 21:49:19 +00:00 by ben · 4 comments
Owner

Parent

Spec #960 (child of device-add spec #13) · ADR 0214 · surfaced by #956 (Ben ruled BUILD). Glossary: mesh plane, setup key (CONTEXT.md).

What to build

A fresh gateway joins its own mesh: the render declares the Netbird client (wt0, 51820) pointed at its plane, and a oneshot runs after management and the identity provider are up, mints one setup key through the same API and token as Approve, and brings the peer up — idempotent when already connected, retrying on failure with no start limit. In the same change every unit that binds wt0 (code, docs-editing, files, the control plane) declares after/wants on the mesh client through one shared render helper, so a reboot never races the mesh.

Acceptance criteria

  • Both gateway renders declare the Netbird client on wt0/51820 with management URL = the gateway's own plane, gated on Mesh.
  • idss-mesh-self-admit oneshot ordered after management + the carrier's identity provider (kanidm or idss-idp); skips when netbird status reports connected; Restart=on-failure, startLimitIntervalSec = 0.
  • A shared meshBound() render helper exists and is applied to every unit binding wt0; the eval smoke / render tests assert the after/wants on each.
  • Live on rehearsal-d: after a deploy the gateway has a wt0 address in netbird status; after a reboot the mesh-bound units come up without a start-limit hit (journal shows no start-limit-hit).
  • go build/vet/lint/tests green; STATUS updated; ADR 0159 marked satisfied in its consequences.

Blocked by

  • #961 (mesh-plane-render)

Task manifest

task: mesh-gateway-self-peer-ordering
implements_flow: p3-device-add-app
implements_edge: "gateway side — the plane has a first peer and mesh-bound units order on it"
wireframe: []
interface: render helper meshBound(unit) adding after/wants on the netbird client unit; oneshot idss-mesh-self-admit
seam: internal/clan render tests + eval smoke; live reboot on rehearsal-d
acceptance:
  - given: a fresh deploy with the plane and identity provider up
    when: the self-admit oneshot runs
    then: the gateway's peer is up with a wt0 address; re-running is a no-op
  - given: a reboot
    when: mesh-bound units start
    then: each waits for the mesh client and none hits a start limit
depends_on: [mesh-plane-render]
out_of_scope: [device-side ordering, mesh ACLs]
needs_human_decision: []
## Parent Spec #960 (child of device-add spec #13) · ADR 0214 · surfaced by #956 (Ben ruled BUILD). Glossary: **mesh plane**, **setup key** (CONTEXT.md). ## What to build A fresh gateway joins its own mesh: the render declares the Netbird client (`wt0`, 51820) pointed at its plane, and a oneshot runs after management and the identity provider are up, mints one setup key through the same API and token as Approve, and brings the peer up — idempotent when already connected, retrying on failure with no start limit. In the same change every unit that binds `wt0` (code, docs-editing, files, the control plane) declares `after`/`wants` on the mesh client through one shared render helper, so a reboot never races the mesh. ## Acceptance criteria - [ ] Both gateway renders declare the Netbird client on `wt0`/51820 with management URL = the gateway's own plane, gated on `Mesh`. - [ ] `idss-mesh-self-admit` oneshot ordered after management + the carrier's identity provider (kanidm or idss-idp); skips when `netbird status` reports connected; `Restart=on-failure`, `startLimitIntervalSec = 0`. - [ ] A shared `meshBound()` render helper exists and is applied to every unit binding `wt0`; the eval smoke / render tests assert the `after`/`wants` on each. - [ ] Live on `rehearsal-d`: after a deploy the gateway has a `wt0` address in `netbird status`; after a reboot the mesh-bound units come up without a start-limit hit (journal shows no `start-limit-hit`). - [ ] `go build`/`vet`/lint/tests green; STATUS updated; ADR 0159 marked satisfied in its consequences. ## Blocked by - #961 (mesh-plane-render) ## Task manifest ```yaml task: mesh-gateway-self-peer-ordering implements_flow: p3-device-add-app implements_edge: "gateway side — the plane has a first peer and mesh-bound units order on it" wireframe: [] interface: render helper meshBound(unit) adding after/wants on the netbird client unit; oneshot idss-mesh-self-admit seam: internal/clan render tests + eval smoke; live reboot on rehearsal-d acceptance: - given: a fresh deploy with the plane and identity provider up when: the self-admit oneshot runs then: the gateway's peer is up with a wt0 address; re-running is a no-op - given: a reboot when: mesh-bound units start then: each waits for the mesh client and none hits a start limit depends_on: [mesh-plane-render] out_of_scope: [device-side ordering, mesh ACLs] needs_human_decision: [] ```

Blocked — needs a human scoping/sequencing decision (asked on Mattermost, no reply in 20 min)

The self-admit oneshot (ADR 0214 decision 5) must "mint one setup key through the same API and token as Approve". Approve's token source is decision 4 — the MeshMinter presenting a Netbird service-user PAT to POST http://localhost:8011/api/setup-keys (the V1 fallback #961 recorded, since neither carrier issues a non-interactive client-credentials token — a deterministic property of kanidm + the idss-idp bridge).

That token infrastructure is #963 (mesh-minter-at-approve), which is OPEN / not landed:

  • No MeshMinter port, no ErrNoMeshPlane, no POST /api/setup-keys wiring anywhere in the tree.
  • enroll.MeshAdmissionFor still hands placeholder material (randBytes(32), mesh.internal); the gateway role gets the zero value (#907 — "founds the mesh at its own deploy", which is this ticket).
  • No Netbird service-user PAT clan var is declared or provisioned.
  • The pinned nixpkgs netbird module (services.netbird.tunnels.* + services.netbird.server) has no declarative account/setup-key bootstrap — minting strictly requires an authenticated API call with a token only #963 provides.

So the gateway cannot self-peer (no wt0 address) until #963 lands → AC2 (the oneshot minting + bringing the peer up) and AC4 (live wt0 address on rehearsal-d) are unmeetable this iteration.

But the DAG (docs/slices/device-add.yaml) lists mesh-gateway-self-peer-ordering depends_on: [mesh-plane-render] ONLY — it omits the #963 edge. Since that ordering looks deliberate, I did not want to unilaterally override it.

The decision needed (pick one, then re-arm ready-for-agent):

  • (A) Ship the render-only half now, deferring the mint/live proof to #963:
    • the Netbird client tunnel on wt0/51820 pointed at the gateway's own plane (AC1) — pure render, no token;
    • the shared meshBound() ordering helper (after/wants netbird-mesh — really netbird-wt0.service on this pin) on the 4 wt0-binding units (code / docs-editing / files / control plane) with eval-smoke assertions (AC3 — the ADR 0159 render-level rule, which needs no token);
    • the idss-mesh-self-admit oneshot structure (ordering after management + IdP, netbird status idempotency skip, Restart=on-failure, startLimitIntervalSec=0) written to rest honestly (ADR 0100) until #963's token exists, so no perpetually-failing unit lands on the fleet.
    • Proves: render string tests + nix eval smoke. Reversible. Does not prove: AC2/AC4 live (gated on #963).
  • (B) Block #964 on #963 — add the missing depends_on: mesh-minter-at-approve edge, and land the self-peer whole once the token source exists. Cleaner (no half across the #963 seam), but the ordering contract (AC3) waits on the minter.

There is also an unresolved token-bootstrap question #963 must answer regardless: how the first Netbird PAT is obtained non-interactively on a fresh single-account plane when neither carrier issues a service token (the spike's "named impedance"). That is #963's to solve, not this ticket's — flagging it so it isn't lost.

Why human

A deliberate DAG-ordering choice (#964 decoupled from #963) collides with a hard token dependency; whether to ship the reversible render-only half now or re-sequence #964 behind #963 is a scoping call I should not make unilaterally. No revertible test can prove AC2/AC4 this iteration, so it is not an ADR-0174 two-way door I can rule.

## Blocked — needs a human scoping/sequencing decision (asked on Mattermost, no reply in 20 min) The self-admit oneshot (ADR 0214 decision 5) must *"mint one setup key through the **same API and token as Approve**"*. Approve's token source is **decision 4** — the `MeshMinter` presenting a Netbird **service-user PAT** to `POST http://localhost:8011/api/setup-keys` (the V1 *fallback* #961 recorded, since neither carrier issues a non-interactive client-credentials token — a deterministic property of kanidm + the idss-idp bridge). **That token infrastructure is #963 (`mesh-minter-at-approve`), which is OPEN / not landed:** - No `MeshMinter` port, no `ErrNoMeshPlane`, no `POST /api/setup-keys` wiring anywhere in the tree. - `enroll.MeshAdmissionFor` still hands placeholder material (`randBytes(32)`, `mesh.internal`); the gateway role gets the zero value (#907 — "founds the mesh at its own deploy", which is *this* ticket). - No Netbird service-user PAT clan var is declared or provisioned. - The pinned nixpkgs netbird module (`services.netbird.tunnels.*` + `services.netbird.server`) has **no declarative account/setup-key bootstrap** — minting strictly requires an authenticated API call with a token only #963 provides. **So the gateway cannot self-peer (no `wt0` address) until #963 lands** → AC2 (the oneshot minting + bringing the peer up) and AC4 (live `wt0` address on rehearsal-d) are unmeetable this iteration. **But the DAG (`docs/slices/device-add.yaml`) lists `mesh-gateway-self-peer-ordering` `depends_on: [mesh-plane-render]` ONLY — it omits the #963 edge.** Since that ordering looks deliberate, I did not want to unilaterally override it. ### The decision needed (pick one, then re-arm `ready-for-agent`): - **(A) Ship the render-only half now**, deferring the mint/live proof to #963: - the Netbird **client tunnel** on `wt0`/51820 pointed at the gateway's own plane (AC1) — pure render, no token; - the shared **`meshBound()`** ordering helper (after/wants `netbird-mesh` — really `netbird-wt0.service` on this pin) on the 4 wt0-binding units (code / docs-editing / files / control plane) with eval-smoke assertions (AC3 — the ADR 0159 render-level rule, which needs no token); - the `idss-mesh-self-admit` oneshot **structure** (ordering after management + IdP, `netbird status` idempotency skip, `Restart=on-failure`, `startLimitIntervalSec=0`) written to **rest honestly** (ADR 0100) until #963's token exists, so no perpetually-failing unit lands on the fleet. - *Proves:* render string tests + `nix eval` smoke. *Reversible.* *Does not prove:* AC2/AC4 live (gated on #963). - **(B) Block #964 on #963** — add the missing `depends_on: mesh-minter-at-approve` edge, and land the self-peer **whole** once the token source exists. Cleaner (no half across the #963 seam), but the ordering contract (AC3) waits on the minter. There is also an **unresolved token-bootstrap question #963 must answer regardless**: how the *first* Netbird PAT is obtained non-interactively on a fresh single-account plane when neither carrier issues a service token (the spike's "named impedance"). That is #963's to solve, not this ticket's — flagging it so it isn't lost. ## Why human A deliberate DAG-ordering choice (#964 decoupled from #963) collides with a hard token dependency; whether to ship the reversible render-only half now or re-sequence #964 behind #963 is a scoping call I should not make unilaterally. No revertible test can prove AC2/AC4 this iteration, so it is not an ADR-0174 two-way door I can rule.
Author
Owner

Ruled (A) — ship the render-only half now (session, ADR 0174 two-way door: pure render, revertible, eval-smoke-provable). Since you asked, #963 has landed (353ec1c6), but the token it needs is still unprovisioned — that bootstrap hole is now #973 (ready-for-human, recommendation A: the control plane is the plane's own issuer). So:

  • Land AC1 (client tunnel on wt0/51820 at the gateway's own plane), AC3 (meshBound() on the four wt0 units + eval-smoke assertions — the ADR 0159 rule), and the idss-mesh-self-admit oneshot structure resting honestly (ADR 0100) until IDSS_MESH_TOKEN_FILE exists — never a perpetually-failing unit on the fleet.
  • AC2/AC4 (live mint + wt0 address on rehearsal-d) move to #973's acceptance; name them as residue in your close comment.
  • The DAG edge you flagged is real: mesh-gateway-self-peer-ordering now also depends_on: mesh-minter-at-approve (yaml fixed on main).

Re-armed ready-for-agent.

**Ruled (A) — ship the render-only half now** (session, ADR 0174 two-way door: pure render, revertible, eval-smoke-provable). Since you asked, #963 has landed (`353ec1c6`), but the token it needs is still unprovisioned — that bootstrap hole is now **#973** (ready-for-human, recommendation A: the control plane is the plane's own issuer). So: - Land AC1 (client tunnel on `wt0`/51820 at the gateway's own plane), AC3 (`meshBound()` on the four `wt0` units + eval-smoke assertions — the ADR 0159 rule), and the `idss-mesh-self-admit` oneshot **structure resting honestly** (ADR 0100) until `IDSS_MESH_TOKEN_FILE` exists — never a perpetually-failing unit on the fleet. - AC2/AC4 (live mint + `wt0` address on rehearsal-d) move to #973's acceptance; name them as residue in your close comment. - The DAG edge you flagged is real: `mesh-gateway-self-peer-ordering` now also `depends_on: mesh-minter-at-approve` (yaml fixed on main). Re-armed `ready-for-agent`.

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

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

close-report for #964 — status success

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

envelope
{
  "issue": 964,
  "status": "success",
  "commits": [
    "e1a8cdcb"
  ],
  "changed_files": [
    "STATUS.md",
    "docs/adr/0159-mesh-bound-services-order-against-the-mesh.md",
    "docs/slices/device-add.yaml",
    "internal/clan/code.go",
    "internal/clan/docsediting.go",
    "internal/clan/files.go",
    "internal/clan/netbird.go",
    "internal/clan/netbird_test.go",
    "internal/clan/vmguest.go"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci -c go build ./...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c go vet ./...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c golangci-lint run ./internal/clan/",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c go test ./...",
      "exit_code": 0
    },
    {
      "command": "IDSS_EVAL_SMOKE=1 nix develop .#go-ci -c go test ./internal/clan/ -run TestOwnVPSGateway_EvalSmoke",
      "exit_code": 0
    }
  ],
  "criteria": {
    "AC1 — both gateway renders declare the Netbird client on wt0/51820 with management URL = the gateway's own plane, gated on Mesh": "internal/clan/netbird.go netbirdClient() emits services.netbird.clients.mesh {port=51820; interface=\"wt0\"; NB_MANAGEMENT_URL=http://localhost:8011} gated on GatewayFacts.Mesh, spliced beside netbirdServer in all four gateway surfaces (vmguest.go renderGatewayGuest/IDIP + renderControlPlaneSurface/IDIP); TestNetbird_ClientDeclaredOnAllRenders asserts it on every render",
    "AC2 — idss-mesh-self-admit oneshot ordered after management + IdP; skips when connected; Restart=on-failure, startLimitIntervalSec=0": "STRUCTURE landed (meshSelfAdmitOneshot): after netbird-mesh + netbird-management + kanidm/idss-idp + idss-control-plane, wants the client, Type=oneshot, `netbird status` idempotency skip, Restart=on-failure/RestartSec=5s/startLimitIntervalSec=0 (TestNetbird_SelfAdmitOneshotStructure). Per Ben's #964 ruling the BODY rests honestly (ADR 0100, TestNetbird_SelfAdmitRestsHonestly); the LIVE mint + peer-up move to #973/#854",
    "AC3 — shared meshBound() helper exists and is applied to every wt0-binding unit; eval smoke / render tests assert after/wants on each": "meshBound(unit) in netbird.go applied to code.go→forgejo, docsediting.go→coolwsd, files.go→nginx (standalone mesh-listen); the control plane takes the same ordering inline (gatewayControlPlaneUnit/controlPlaneAfterList, same-file mkMerge conflict avoided). TestMeshBound_EmitsTheFourProperties + TestMeshBound_AppliedToEveryWt0Unit; the own-VPS gateway eval smoke evaluates the composed gateway",
    "AC4 — live on rehearsal-d (wt0 address after deploy; reboot with no start-limit-hit)": "DEFERRED to #973/#854 per Ben's #964 ruling — the gateway has no wt0 address until the control-plane self-mint is wired; named as residue here and in docs/slices/device-add.yaml + ADR 0159 consequences",
    "AC5 — go build/vet/lint/tests green; STATUS updated; ADR 0159 marked satisfied in its consequences": "go build/vet/golangci-lint/go test ./... all exit 0 (+ eval smoke green); STATUS.md new lead paragraph; ADR 0159 consequences gained a 'Satisfied at the render level (#964)' section"
  },
  "summary": "The gateway declares its own netbird peer (wt0/51820 at its own plane) and every wt0-binding unit orders on the mesh via the shared meshBound() helper; the self-admit oneshot structure rests honestly until #973 wires the live mint.",
  "reason": "Render-only half per Ben's #964 ruling (option A); AC1/AC3 landed and eval-smoke-proven, AC2 structure resting honestly, AC4 live proof deferred to #973/#854.",
  "blockers": []
}
**close-report** for #964 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 964, "status": "success", "commits": [ "e1a8cdcb" ], "changed_files": [ "STATUS.md", "docs/adr/0159-mesh-bound-services-order-against-the-mesh.md", "docs/slices/device-add.yaml", "internal/clan/code.go", "internal/clan/docsediting.go", "internal/clan/files.go", "internal/clan/netbird.go", "internal/clan/netbird_test.go", "internal/clan/vmguest.go" ], "tests": [ { "command": "nix develop .#go-ci -c go build ./...", "exit_code": 0 }, { "command": "nix develop .#go-ci -c go vet ./...", "exit_code": 0 }, { "command": "nix develop .#go-ci -c golangci-lint run ./internal/clan/", "exit_code": 0 }, { "command": "nix develop .#go-ci -c go test ./...", "exit_code": 0 }, { "command": "IDSS_EVAL_SMOKE=1 nix develop .#go-ci -c go test ./internal/clan/ -run TestOwnVPSGateway_EvalSmoke", "exit_code": 0 } ], "criteria": { "AC1 — both gateway renders declare the Netbird client on wt0/51820 with management URL = the gateway's own plane, gated on Mesh": "internal/clan/netbird.go netbirdClient() emits services.netbird.clients.mesh {port=51820; interface=\"wt0\"; NB_MANAGEMENT_URL=http://localhost:8011} gated on GatewayFacts.Mesh, spliced beside netbirdServer in all four gateway surfaces (vmguest.go renderGatewayGuest/IDIP + renderControlPlaneSurface/IDIP); TestNetbird_ClientDeclaredOnAllRenders asserts it on every render", "AC2 — idss-mesh-self-admit oneshot ordered after management + IdP; skips when connected; Restart=on-failure, startLimitIntervalSec=0": "STRUCTURE landed (meshSelfAdmitOneshot): after netbird-mesh + netbird-management + kanidm/idss-idp + idss-control-plane, wants the client, Type=oneshot, `netbird status` idempotency skip, Restart=on-failure/RestartSec=5s/startLimitIntervalSec=0 (TestNetbird_SelfAdmitOneshotStructure). Per Ben's #964 ruling the BODY rests honestly (ADR 0100, TestNetbird_SelfAdmitRestsHonestly); the LIVE mint + peer-up move to #973/#854", "AC3 — shared meshBound() helper exists and is applied to every wt0-binding unit; eval smoke / render tests assert after/wants on each": "meshBound(unit) in netbird.go applied to code.go→forgejo, docsediting.go→coolwsd, files.go→nginx (standalone mesh-listen); the control plane takes the same ordering inline (gatewayControlPlaneUnit/controlPlaneAfterList, same-file mkMerge conflict avoided). TestMeshBound_EmitsTheFourProperties + TestMeshBound_AppliedToEveryWt0Unit; the own-VPS gateway eval smoke evaluates the composed gateway", "AC4 — live on rehearsal-d (wt0 address after deploy; reboot with no start-limit-hit)": "DEFERRED to #973/#854 per Ben's #964 ruling — the gateway has no wt0 address until the control-plane self-mint is wired; named as residue here and in docs/slices/device-add.yaml + ADR 0159 consequences", "AC5 — go build/vet/lint/tests green; STATUS updated; ADR 0159 marked satisfied in its consequences": "go build/vet/golangci-lint/go test ./... all exit 0 (+ eval smoke green); STATUS.md new lead paragraph; ADR 0159 consequences gained a 'Satisfied at the render level (#964)' section" }, "summary": "The gateway declares its own netbird peer (wt0/51820 at its own plane) and every wt0-binding unit orders on the mesh via the shared meshBound() helper; the self-admit oneshot structure rests honestly until #973 wires the live mint.", "reason": "Render-only half per Ben's #964 ruling (option A); AC1/AC3 landed and eval-smoke-proven, AC2 structure resting honestly, AC4 live proof deferred to #973/#854.", "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#964
No description provided.