bootstrap: enroll-seam — the shared enroll package + in-memory fake #26

Closed
opened 2026-07-25 04:54:06 +00:00 by ben · 1 comment
Owner

Parent

Wayfinder map: #7 — the engineering foundation (PROCESS.md Phase 2½, emitted as DAG root slices).

What to build

The shared enroll Go package — the protocol between the device-side agent and the control plane (the seam contract in docs/seams/agent-control-plane.md, carrying ADR 0028's one enrollment mechanism and ADR 0037's shared types). One package holds the wire types and the service interfaces: the connection request as a single resource with a typed, monotonic state machine (Redeemed → Pending → Approved → Enrolled, plus Declined/Expired) whose states map 1:1 to the P2/P3 flow nodes. The boundary's security job is a one-way conversion — a weak, human-carried enrollment code becomes a strong, individually revocable device identity — so the seam splits into two faces: the pre-mesh Enrollment face and the over-mesh fleet-reporting face.

Three service interfaces exist with their full verb sets: ControlPlane (Redeem, Pair, Poll, ConfirmEnrolled — the agent's whole enrollment view, signed by the device key), Operator (List, Approve, Decline, plus the amendments MintCode/RevokeCode from the device-add grill and ListCodes + CodeView.CreatedBy from the shell grill), and FleetReporting (Report — the standing NodeCert-mTLS heartbeat). The IdentityGrant ships the full community CA at v1 (spike #5's Q6 verdict workable): a 90-day NodeCert, SSH host cert, and ClanTrust — the wiring that makes the clan seam's "established connection" credential-first. The error taxonomy has one error per device-end screen.

Notes: the control-plane face must be an embeddable, first-class build target — founding's bundled helper embeds it behind an in-process ledger and the seeded control plane inherits the resulting request record and grant (ADR 0043), so this is not merely a test fake. The seam-test fake is an in-memory ledger plus a clock.

Acceptance criteria

  • Given the seam contract, when the enroll package is built, then the connection-request resource carries a monotonic, typed state machine (Redeemed/Pending/Approved/Enrolled/Declined/Expired) matching the P2/P3 flow nodes, with terminal states that never change.
  • Given the three faces, when the package is built, then ControlPlane (Redeem/Pair/Poll/ConfirmEnrolled), Operator (List/Approve/Decline + MintCode/RevokeCode/ListCodes with CodeView.CreatedBy), and FleetReporting (Report) all exist with their listed verbs.
  • Given a mistyped or reused code, when Redeem is called, then it validates without consuming the code, is idempotent on (Code, KeyID), and a second key presenting the same code gets ErrCodeInUse; the full taxonomy (ErrCodeUnknown/Expired/Revoked/Consumed/InUse, ErrSpecGate, ErrVirtUnavailable, ErrGone) exists, each mapping to a distinct device-end screen.
  • Given an approval, when the code is converted, then the IdentityGrant delivers the full community-CA-signed NodeCert (90-day validity), SSH host cert, mesh admission, and ClanTrust; nothing in it is re-derivable from the code.
  • Given ADR 0043, when the control-plane face is built, then it is an embeddable first-class target (founding's helper embeds it over an in-process/on-disk ledger), and the seam-test fake is an in-memory ledger + clock.

Blocked by

  • #23 — needs the Go workspace + dev shell.

Task manifest

task: bootstrap:enroll-seam
implements_seam: docs/seams/agent-control-plane.md
implements_edge: —   # engineering slice; no flow edge
wireframe: —         # no wireframe; the seam contract IS the design
interface: enroll — the connection-request resource (typed monotonic state machine)
  plus ControlPlane (Redeem/Pair/Poll/ConfirmEnrolled), Operator (List/Approve/Decline
  + MintCode/RevokeCode/ListCodes, CodeView.CreatedBy), FleetReporting (Report); the
  error taxonomy and the IdentityGrant (full community CA, 90-day NodeCert)
seam: enroll seam tests (Go) against a fake control plane = in-memory ledger + clock;
  the control-plane face also built as an embeddable target (founding helper)
acceptance:
  - given: the seam contract
    when: the package builds
    then: the request resource is a monotonic typed state machine matching the P2/P3 nodes, terminal states immutable
  - given: the three faces
    when: the package builds
    then: ControlPlane, Operator (incl. MintCode/RevokeCode/ListCodes + CodeView.CreatedBy), and FleetReporting exist with their verbs
  - given: a mistyped/reused code
    when: Redeem is called
    then: it is non-consuming and idempotent on (Code, KeyID), a second key gets ErrCodeInUse, and the full error taxonomy exists (one per device-end screen)
  - given: an approval
    when: the grant is issued
    then: IdentityGrant carries a full community-CA 90-day NodeCert, SSH host cert, mesh admission, and ClanTrust, none re-derivable from the code
  - given: ADR 0043
    when: the control-plane face is built
    then: it is an embeddable first-class target and the seam fake is an in-memory ledger + clock
depends_on: [skeleton]
out_of_scope: [the clan install/deploy mechanics (clan-seam's — the two "enroll"s are
  different things), the device-add and founding flow UIs (their features), the code
  ledger's dashboard screens (shell/device-add), CA key ceremony operations (founding)]
needs_human_decision: []
## Parent Wayfinder map: #7 — the engineering foundation (PROCESS.md Phase 2½, emitted as DAG root slices). ## What to build The shared `enroll` Go package — the protocol between the device-side agent and the control plane (the seam contract in `docs/seams/agent-control-plane.md`, carrying ADR 0028's one enrollment mechanism and ADR 0037's shared types). One package holds the wire types and the service interfaces: the connection request as a single resource with a typed, monotonic state machine (Redeemed → Pending → Approved → Enrolled, plus Declined/Expired) whose states map 1:1 to the P2/P3 flow nodes. The boundary's security job is a one-way conversion — a weak, human-carried enrollment code becomes a strong, individually revocable device identity — so the seam splits into two faces: the pre-mesh Enrollment face and the over-mesh fleet-reporting face. Three service interfaces exist with their full verb sets: `ControlPlane` (Redeem, Pair, Poll, ConfirmEnrolled — the agent's whole enrollment view, signed by the device key), `Operator` (List, Approve, Decline, plus the amendments MintCode/RevokeCode from the device-add grill and ListCodes + `CodeView.CreatedBy` from the shell grill), and `FleetReporting` (Report — the standing NodeCert-mTLS heartbeat). The `IdentityGrant` ships the full community CA at v1 (spike #5's Q6 verdict `workable`): a 90-day NodeCert, SSH host cert, and ClanTrust — the wiring that makes the clan seam's "established connection" credential-first. The error taxonomy has one error per device-end screen. Notes: the control-plane face must be an embeddable, first-class build target — founding's bundled helper embeds it behind an in-process ledger and the seeded control plane inherits the resulting request record and grant (ADR 0043), so this is not merely a test fake. The seam-test fake is an in-memory ledger plus a clock. ## Acceptance criteria - [ ] Given the seam contract, when the `enroll` package is built, then the connection-request resource carries a monotonic, typed state machine (Redeemed/Pending/Approved/Enrolled/Declined/Expired) matching the P2/P3 flow nodes, with terminal states that never change. - [ ] Given the three faces, when the package is built, then `ControlPlane` (Redeem/Pair/Poll/ConfirmEnrolled), `Operator` (List/Approve/Decline + MintCode/RevokeCode/ListCodes with `CodeView.CreatedBy`), and `FleetReporting` (Report) all exist with their listed verbs. - [ ] Given a mistyped or reused code, when Redeem is called, then it validates without consuming the code, is idempotent on (Code, KeyID), and a second key presenting the same code gets `ErrCodeInUse`; the full taxonomy (`ErrCodeUnknown`/`Expired`/`Revoked`/`Consumed`/`InUse`, `ErrSpecGate`, `ErrVirtUnavailable`, `ErrGone`) exists, each mapping to a distinct device-end screen. - [ ] Given an approval, when the code is converted, then the `IdentityGrant` delivers the full community-CA-signed NodeCert (90-day validity), SSH host cert, mesh admission, and ClanTrust; nothing in it is re-derivable from the code. - [ ] Given ADR 0043, when the control-plane face is built, then it is an embeddable first-class target (founding's helper embeds it over an in-process/on-disk ledger), and the seam-test fake is an in-memory ledger + clock. ## Blocked by - #23 — needs the Go workspace + dev shell. ## Task manifest ```yaml task: bootstrap:enroll-seam implements_seam: docs/seams/agent-control-plane.md implements_edge: — # engineering slice; no flow edge wireframe: — # no wireframe; the seam contract IS the design interface: enroll — the connection-request resource (typed monotonic state machine) plus ControlPlane (Redeem/Pair/Poll/ConfirmEnrolled), Operator (List/Approve/Decline + MintCode/RevokeCode/ListCodes, CodeView.CreatedBy), FleetReporting (Report); the error taxonomy and the IdentityGrant (full community CA, 90-day NodeCert) seam: enroll seam tests (Go) against a fake control plane = in-memory ledger + clock; the control-plane face also built as an embeddable target (founding helper) acceptance: - given: the seam contract when: the package builds then: the request resource is a monotonic typed state machine matching the P2/P3 nodes, terminal states immutable - given: the three faces when: the package builds then: ControlPlane, Operator (incl. MintCode/RevokeCode/ListCodes + CodeView.CreatedBy), and FleetReporting exist with their verbs - given: a mistyped/reused code when: Redeem is called then: it is non-consuming and idempotent on (Code, KeyID), a second key gets ErrCodeInUse, and the full error taxonomy exists (one per device-end screen) - given: an approval when: the grant is issued then: IdentityGrant carries a full community-CA 90-day NodeCert, SSH host cert, mesh admission, and ClanTrust, none re-derivable from the code - given: ADR 0043 when: the control-plane face is built then: it is an embeddable first-class target and the seam fake is an in-memory ledger + clock depends_on: [skeleton] out_of_scope: [the clan install/deploy mechanics (clan-seam's — the two "enroll"s are different things), the device-add and founding flow UIs (their features), the code ledger's dashboard screens (shell/device-add), CA key ceremony operations (founding)] needs_human_decision: [] ```
Author
Owner

Done in commit 250e68b (internal/enroll/).

The shared enroll Go package — the agent↔control-plane boundary as one shared module (ADR 0037: the types ARE the schema).

What landed:

  • The connection request as one resource with a typed, MONOTONIC state machine — Redeemed→Pending→Approved→Enrolled plus the Declined/Expired off-ramps — states mapping 1:1 to the P2/P3 flow nodes; the three terminal states never change.
  • Three faces, full verb sets: ControlPlane (Redeem/Pair/Poll/ConfirmEnrolled), Operator (List/Approve/Decline + MintCode/RevokeCode/ListCodes with CodeView.CreatedBy), FleetReporting (Report). Static interface checks bind all three to the Ledger.
  • Redeem is non-consuming and idempotent on (Code, KeyID) — a re-redeem rejoins the same request; a second key gets ErrCodeInUse. Spec-gate failure is a typed *SpecGateError that STAYS Redeemed so the code survives. The full taxonomy (ErrCodeUnknown/Expired/Revoked/Consumed/InUse, ErrSpecGate, ErrVirtUnavailable, ErrGone) each maps to a distinct device-end screen via DeviceScreenFor.
  • The IdentityGrant: approval mints a full-community-CA 90-day NodeCert, SSH host cert, mesh admission, and ClanTrust via a pluggable Granter (StubGranter = the pinned-key fallback shape); random material, nothing re-derivable from the code. The real CA ceremony plugs in behind the same types (founding's).
  • Embeddable first-class target (ADR 0043): the single Ledger (in-memory maps + injectable Clock) is both the seam-test fake and founding's in-process control-plane target. Export/NewLedgerFromState are the state handover (founding's request record + grant move into the seeded control plane); the on-disk form is the same State through JSON.

Evidence: 15 seam tests in internal/enroll/enroll_test.go (happy path, non-consuming/idempotent redeem, spec-gate stays-redeemed, VM-virt loop, decline/expiry/revoke off-ramps, blocking poll, grant shape + per-node freshness, taxonomy→distinct-screens, ADR-0043 state handover, crash-resend). go build/go vet ./..., go test -race ./internal/enroll/, and golangci-lint run all clean.

Out of scope (untouched): the founding/device-add flow UIs, the CA key ceremony, and the clan install/deploy enroll (clan-seam's — the two "enroll"s are different things). Sibling root slice #25 (clan-seam) remains.

Done in commit `250e68b` (`internal/enroll/`). The shared `enroll` Go package — the agent↔control-plane boundary as one shared module (ADR 0037: the types ARE the schema). **What landed:** - **The connection request** as one resource with a typed, MONOTONIC state machine — `Redeemed→Pending→Approved→Enrolled` plus the `Declined`/`Expired` off-ramps — states mapping 1:1 to the P2/P3 flow nodes; the three terminal states never change. - **Three faces, full verb sets:** `ControlPlane` (Redeem/Pair/Poll/ConfirmEnrolled), `Operator` (List/Approve/Decline + MintCode/RevokeCode/ListCodes with `CodeView.CreatedBy`), `FleetReporting` (Report). Static interface checks bind all three to the `Ledger`. - **Redeem is non-consuming and idempotent on (Code, KeyID)** — a re-redeem rejoins the same request; a second key gets `ErrCodeInUse`. Spec-gate failure is a typed `*SpecGateError` that STAYS Redeemed so the code survives. The full taxonomy (`ErrCodeUnknown`/`Expired`/`Revoked`/`Consumed`/`InUse`, `ErrSpecGate`, `ErrVirtUnavailable`, `ErrGone`) each maps to a distinct device-end screen via `DeviceScreenFor`. - **The `IdentityGrant`**: approval mints a full-community-CA 90-day NodeCert, SSH host cert, mesh admission, and ClanTrust via a pluggable `Granter` (`StubGranter` = the pinned-key fallback shape); random material, nothing re-derivable from the code. The real CA ceremony plugs in behind the same types (founding's). - **Embeddable first-class target (ADR 0043):** the single `Ledger` (in-memory maps + injectable `Clock`) is *both* the seam-test fake *and* founding's in-process control-plane target. `Export`/`NewLedgerFromState` are the state handover (founding's request record + grant move into the seeded control plane); the on-disk form is the same `State` through JSON. **Evidence:** 15 seam tests in `internal/enroll/enroll_test.go` (happy path, non-consuming/idempotent redeem, spec-gate stays-redeemed, VM-virt loop, decline/expiry/revoke off-ramps, blocking poll, grant shape + per-node freshness, taxonomy→distinct-screens, ADR-0043 state handover, crash-resend). `go build`/`go vet ./...`, `go test -race ./internal/enroll/`, and `golangci-lint run` all clean. **Out of scope (untouched):** the founding/device-add flow UIs, the CA key ceremony, and the clan install/deploy `enroll` (clan-seam's — the two "enroll"s are different things). Sibling root slice #25 (clan-seam) remains.
ben closed this issue 2026-07-25 10:12:31 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/idss#26
No description provided.