control plane: the enrollment ledger is never persisted — codes, pending requests (and enrolled devices?) live only in memory; a restart in the update window drops them (#1975 class) #2007

Closed
opened 2026-09-30 01:12:37 +00:00 by ben · 3 comments
Owner

Symptom

On a live gateway, every enrollment code and every device request exists only in the control plane's memory. On Whakatōhea Demo (2026-09-30) the operator minted a code at 00:33Z and a device paired to Pending at 00:51Z; /var/lib/idss/enroll.json on the box was last written 2026-09-23 22:39 (founding's hand-over) and holds neither. Both are readable only through GET /api/v1/enroll/codes and /pending on the running process.

Consequence: a control-plane restart — every update lands one; the demo's window is 11:00–13:00 UTC daily — drops every unspent code and every pending request. Whether an enrolled device survives (the ledger's nodes and requests are what the fleet projection and ConfirmEnrolled read) needs establishing as part of this ticket; if it does not, a device joined after founding vanishes from the fleet at the next update.

Cause

openEnrollLedger (control-plane/cmd/control-plane/whole_composition.go:1041) opens the ledger over enroll.NewFileStore(<state>/enroll.json) — and that is the only place the store is touched. enroll.Persist (internal/enroll/store.go:56) has two callers in the tree: the smoke-stores tool and the app helper's persistedEnroll wrapper (app/helper/cmd/helper/enrollpersist.go), which saves after every verb precisely because "a memory-only ledger strands every approved request the moment its process exits". The control plane never got the same wrapper. Ledger.MintCode/Redeem/Pair/Approve mutate memory and return.

Same class as #1975 (update policy in memory only, closed).

Fix

  • Wrap the control plane's ledger the way the helper does: every verb persists the whole document before returning; a persist failure on an otherwise-successful verb fails loud (ADR 0100). Move persistedEnroll into internal/enroll so both compositions share one wrapper rather than a copy.
  • A restart test in the control-plane composition: mint → pair → restart over the same file → the code and the pending request are still there; and the enrolled-device case, whichever way it comes out today, pinned.
  • GOTCHAS entry: reading the live ledger on a box is curl http://127.0.0.1:8080/api/v1/enroll/codes (loopback, no auth), not enroll.json.

Found while joining bens-mac-04 to Whakatōhea Demo by hand; sibling tickets filed alongside.

Siblings

Found in the one hand run (bens-mac-04 → Whakatōhea Demo, 2026-09-30): #2002 #2003 #2004 #2005 #2006

## Symptom On a live gateway, every enrollment code and every device request exists **only in the control plane's memory**. On Whakatōhea Demo (2026-09-30) the operator minted a code at 00:33Z and a device paired to Pending at 00:51Z; `/var/lib/idss/enroll.json` on the box was last written **2026-09-23 22:39** (founding's hand-over) and holds neither. Both are readable only through `GET /api/v1/enroll/codes` and `/pending` on the running process. Consequence: a control-plane restart — every update lands one; the demo's window is 11:00–13:00 UTC daily — drops every unspent code and every pending request. Whether an **enrolled** device survives (the ledger's `nodes` and `requests` are what the fleet projection and `ConfirmEnrolled` read) needs establishing as part of this ticket; if it does not, a device joined after founding vanishes from the fleet at the next update. ## Cause `openEnrollLedger` (`control-plane/cmd/control-plane/whole_composition.go:1041`) opens the ledger over `enroll.NewFileStore(<state>/enroll.json)` — and that is the only place the store is touched. `enroll.Persist` (`internal/enroll/store.go:56`) has two callers in the tree: the smoke-stores tool and the **app helper's** `persistedEnroll` wrapper (`app/helper/cmd/helper/enrollpersist.go`), which saves after every verb precisely because "a memory-only ledger strands every approved request the moment its process exits". The control plane never got the same wrapper. `Ledger.MintCode`/`Redeem`/`Pair`/`Approve` mutate memory and return. Same class as #1975 (update policy in memory only, closed). ## Fix - Wrap the control plane's ledger the way the helper does: every verb persists the whole document before returning; a persist failure on an otherwise-successful verb fails loud (ADR 0100). Move `persistedEnroll` into `internal/enroll` so both compositions share one wrapper rather than a copy. - A restart test in the control-plane composition: mint → pair → restart over the same file → the code and the pending request are still there; and the enrolled-device case, whichever way it comes out today, pinned. - GOTCHAS entry: reading the live ledger on a box is `curl http://127.0.0.1:8080/api/v1/enroll/codes` (loopback, no auth), not `enroll.json`. ## Related Found while joining `bens-mac-04` to Whakatōhea Demo by hand; sibling tickets filed alongside. ## Siblings Found in the one hand run (bens-mac-04 → Whakatōhea Demo, 2026-09-30): #2002 #2003 #2004 #2005 #2006

swarm-claim host=bens-mac-04 run=36142
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=bens-mac-04 run=36142 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #2007 — status success

⛔ close-report gates REFUSED this close — the following claims did not verify:

  • commit 504a4a5325 is not reachable from origin/main (not landed)
  • changed_files: 'STATUS.md' is not in the diff of the claimed commits
  • changed_files: 'app/helper/cmd/helper/enrolldevice_test.go' is not in the diff of the claimed commits
  • changed_files: 'app/helper/cmd/helper/enrollpersist.go' is not in the diff of the claimed commits
  • changed_files: 'app/helper/cmd/helper/enrollpersist_test.go' is not in the diff of the claimed commits
  • changed_files: 'app/helper/cmd/helper/wiring_dev.go' is not in the diff of the claimed commits
  • changed_files: 'app/helper/cmd/helper/wiring_prod.go' is not in the diff of the claimed commits
  • changed_files: 'control-plane/cmd/control-plane/compose_enroll_test.go' is not in the diff of the claimed commits
  • changed_files: 'control-plane/cmd/control-plane/enroll_persist_restart_test.go' is not in the diff of the claimed commits
  • changed_files: 'control-plane/cmd/control-plane/whole_composition.go' is not in the diff of the claimed commits
  • changed_files: 'control-plane/cmd/control-plane/whole_composition_community_test.go' is not in the diff of the claimed commits
  • changed_files: 'docs/GOTCHAS.md' is not in the diff of the claimed commits
  • changed_files: 'internal/enroll/persisted.go' is not in the diff of the claimed commits
envelope
{
  "issue": 2007,
  "status": "success",
  "commits": [
    "504a4a5325ac5dd714fc6e7a7076307126700192"
  ],
  "changed_files": [
    "STATUS.md",
    "app/helper/cmd/helper/enrolldevice_test.go",
    "app/helper/cmd/helper/enrollpersist.go",
    "app/helper/cmd/helper/enrollpersist_test.go",
    "app/helper/cmd/helper/wiring_dev.go",
    "app/helper/cmd/helper/wiring_prod.go",
    "control-plane/cmd/control-plane/compose_enroll_test.go",
    "control-plane/cmd/control-plane/enroll_persist_restart_test.go",
    "control-plane/cmd/control-plane/whole_composition.go",
    "control-plane/cmd/control-plane/whole_composition_community_test.go",
    "docs/GOTCHAS.md",
    "internal/enroll/persisted.go"
  ],
  "tests": [
    {
      "command": "go build ./...",
      "exit_code": 0
    },
    {
      "command": "go vet ./internal/enroll/... ./app/helper/cmd/helper/... ./control-plane/cmd/control-plane/...",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/enroll/... ./app/helper/cmd/helper/...",
      "exit_code": 0
    },
    {
      "command": "go test ./control-plane/cmd/control-plane/ -count=1",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Every mutating verb persists the whole document before returning; a persist failure on an otherwise-successful verb fails loud (ADR 0100)": "internal/enroll/persisted.go — PersistedLedger.persist folds a save failure into the verb result (verb error wins); helper's TestEnrollFace_PersistFailureFailsLoud still green over the shared type",
    "persistedEnroll moved into internal/enroll so both compositions share one wrapper (no copy)": "internal/enroll/persisted.go defines enroll.PersistedLedger; app/helper/cmd/helper/enrollpersist.go deleted; wiring_prod.go/wiring_dev.go call enroll.OpenPersistedLedger; whole_composition.go openEnrollLedger returns enroll.PersistedLedger",
    "Restart test in the control-plane composition: mint -> pair -> restart over the same file -> the code and the pending request are still there": "control-plane/cmd/control-plane/enroll_persist_restart_test.go TestOpenEnrollLedger_CodeAndPendingSurviveRestart (green)",
    "The enrolled-device case pinned (whichever way it comes out)": "control-plane/cmd/control-plane/enroll_persist_restart_test.go TestOpenEnrollLedger_EnrolledDeviceSurvivesRestart proves an Enrolled device survives the restart (it did NOT before the fix)",
    "GOTCHAS entry: reading the live ledger on a box is curl http://127.0.0.1:8080/api/v1/enroll/codes (loopback, no auth), not enroll.json": "docs/GOTCHAS.md #372"
  },
  "summary": "The control plane's enroll ledger now persists after every mutating verb (shared enroll.PersistedLedger), so a restart no longer drops codes, pending requests, or enrolled devices.",
  "blockers": []
}
**close-report** for #2007 — status `success` :no_entry: **close-report gates REFUSED this close** — the following claims did not verify: - commit 504a4a5325ac5dd714fc6e7a7076307126700192 is not reachable from origin/main (not landed) - changed_files: 'STATUS.md' is not in the diff of the claimed commits - changed_files: 'app/helper/cmd/helper/enrolldevice_test.go' is not in the diff of the claimed commits - changed_files: 'app/helper/cmd/helper/enrollpersist.go' is not in the diff of the claimed commits - changed_files: 'app/helper/cmd/helper/enrollpersist_test.go' is not in the diff of the claimed commits - changed_files: 'app/helper/cmd/helper/wiring_dev.go' is not in the diff of the claimed commits - changed_files: 'app/helper/cmd/helper/wiring_prod.go' is not in the diff of the claimed commits - changed_files: 'control-plane/cmd/control-plane/compose_enroll_test.go' is not in the diff of the claimed commits - changed_files: 'control-plane/cmd/control-plane/enroll_persist_restart_test.go' is not in the diff of the claimed commits - changed_files: 'control-plane/cmd/control-plane/whole_composition.go' is not in the diff of the claimed commits - changed_files: 'control-plane/cmd/control-plane/whole_composition_community_test.go' is not in the diff of the claimed commits - changed_files: 'docs/GOTCHAS.md' is not in the diff of the claimed commits - changed_files: 'internal/enroll/persisted.go' is not in the diff of the claimed commits <details><summary>envelope</summary> ```json { "issue": 2007, "status": "success", "commits": [ "504a4a5325ac5dd714fc6e7a7076307126700192" ], "changed_files": [ "STATUS.md", "app/helper/cmd/helper/enrolldevice_test.go", "app/helper/cmd/helper/enrollpersist.go", "app/helper/cmd/helper/enrollpersist_test.go", "app/helper/cmd/helper/wiring_dev.go", "app/helper/cmd/helper/wiring_prod.go", "control-plane/cmd/control-plane/compose_enroll_test.go", "control-plane/cmd/control-plane/enroll_persist_restart_test.go", "control-plane/cmd/control-plane/whole_composition.go", "control-plane/cmd/control-plane/whole_composition_community_test.go", "docs/GOTCHAS.md", "internal/enroll/persisted.go" ], "tests": [ { "command": "go build ./...", "exit_code": 0 }, { "command": "go vet ./internal/enroll/... ./app/helper/cmd/helper/... ./control-plane/cmd/control-plane/...", "exit_code": 0 }, { "command": "go test ./internal/enroll/... ./app/helper/cmd/helper/...", "exit_code": 0 }, { "command": "go test ./control-plane/cmd/control-plane/ -count=1", "exit_code": 0 } ], "criteria": { "Every mutating verb persists the whole document before returning; a persist failure on an otherwise-successful verb fails loud (ADR 0100)": "internal/enroll/persisted.go — PersistedLedger.persist folds a save failure into the verb result (verb error wins); helper's TestEnrollFace_PersistFailureFailsLoud still green over the shared type", "persistedEnroll moved into internal/enroll so both compositions share one wrapper (no copy)": "internal/enroll/persisted.go defines enroll.PersistedLedger; app/helper/cmd/helper/enrollpersist.go deleted; wiring_prod.go/wiring_dev.go call enroll.OpenPersistedLedger; whole_composition.go openEnrollLedger returns enroll.PersistedLedger", "Restart test in the control-plane composition: mint -> pair -> restart over the same file -> the code and the pending request are still there": "control-plane/cmd/control-plane/enroll_persist_restart_test.go TestOpenEnrollLedger_CodeAndPendingSurviveRestart (green)", "The enrolled-device case pinned (whichever way it comes out)": "control-plane/cmd/control-plane/enroll_persist_restart_test.go TestOpenEnrollLedger_EnrolledDeviceSurvivesRestart proves an Enrolled device survives the restart (it did NOT before the fix)", "GOTCHAS entry: reading the live ledger on a box is curl http://127.0.0.1:8080/api/v1/enroll/codes (loopback, no auth), not enroll.json": "docs/GOTCHAS.md #372" }, "summary": "The control plane's enroll ledger now persists after every mutating verb (shared enroll.PersistedLedger), so a restart no longer drops codes, pending requests, or enrolled devices.", "blockers": [] } ``` </details>

close-report for #2007 — status success

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

envelope
{
  "issue": 2007,
  "status": "success",
  "commits": [
    "504a4a5325ac5dd714fc6e7a7076307126700192"
  ],
  "changed_files": [
    "STATUS.md",
    "app/helper/cmd/helper/enrolldevice_test.go",
    "app/helper/cmd/helper/enrollpersist.go",
    "app/helper/cmd/helper/enrollpersist_test.go",
    "app/helper/cmd/helper/wiring_dev.go",
    "app/helper/cmd/helper/wiring_prod.go",
    "control-plane/cmd/control-plane/compose_enroll_test.go",
    "control-plane/cmd/control-plane/enroll_persist_restart_test.go",
    "control-plane/cmd/control-plane/whole_composition.go",
    "control-plane/cmd/control-plane/whole_composition_community_test.go",
    "docs/GOTCHAS.md",
    "internal/enroll/persisted.go"
  ],
  "tests": [
    {
      "command": "go build ./...",
      "exit_code": 0
    },
    {
      "command": "go vet ./internal/enroll/... ./app/helper/cmd/helper/... ./control-plane/cmd/control-plane/...",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/enroll/... ./app/helper/cmd/helper/...",
      "exit_code": 0
    },
    {
      "command": "go test ./control-plane/cmd/control-plane/ -count=1",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Every mutating verb persists the whole document before returning; a persist failure on an otherwise-successful verb fails loud (ADR 0100)": "internal/enroll/persisted.go — PersistedLedger.persist folds a save failure into the verb result (verb error wins); helper's TestEnrollFace_PersistFailureFailsLoud still green over the shared type",
    "persistedEnroll moved into internal/enroll so both compositions share one wrapper (no copy)": "internal/enroll/persisted.go defines enroll.PersistedLedger; app/helper/cmd/helper/enrollpersist.go deleted; wiring_prod.go/wiring_dev.go call enroll.OpenPersistedLedger; whole_composition.go openEnrollLedger returns enroll.PersistedLedger",
    "Restart test in the control-plane composition: mint -> pair -> restart over the same file -> the code and the pending request are still there": "control-plane/cmd/control-plane/enroll_persist_restart_test.go TestOpenEnrollLedger_CodeAndPendingSurviveRestart (green)",
    "The enrolled-device case pinned (whichever way it comes out)": "control-plane/cmd/control-plane/enroll_persist_restart_test.go TestOpenEnrollLedger_EnrolledDeviceSurvivesRestart proves an Enrolled device survives the restart (it did NOT before the fix)",
    "GOTCHAS entry: reading the live ledger on a box is curl http://127.0.0.1:8080/api/v1/enroll/codes (loopback, no auth), not enroll.json": "docs/GOTCHAS.md #372"
  },
  "summary": "The control plane's enroll ledger now persists after every mutating verb (shared enroll.PersistedLedger), so a restart no longer drops codes, pending requests, or enrolled devices.",
  "blockers": []
}
**close-report** for #2007 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 2007, "status": "success", "commits": [ "504a4a5325ac5dd714fc6e7a7076307126700192" ], "changed_files": [ "STATUS.md", "app/helper/cmd/helper/enrolldevice_test.go", "app/helper/cmd/helper/enrollpersist.go", "app/helper/cmd/helper/enrollpersist_test.go", "app/helper/cmd/helper/wiring_dev.go", "app/helper/cmd/helper/wiring_prod.go", "control-plane/cmd/control-plane/compose_enroll_test.go", "control-plane/cmd/control-plane/enroll_persist_restart_test.go", "control-plane/cmd/control-plane/whole_composition.go", "control-plane/cmd/control-plane/whole_composition_community_test.go", "docs/GOTCHAS.md", "internal/enroll/persisted.go" ], "tests": [ { "command": "go build ./...", "exit_code": 0 }, { "command": "go vet ./internal/enroll/... ./app/helper/cmd/helper/... ./control-plane/cmd/control-plane/...", "exit_code": 0 }, { "command": "go test ./internal/enroll/... ./app/helper/cmd/helper/...", "exit_code": 0 }, { "command": "go test ./control-plane/cmd/control-plane/ -count=1", "exit_code": 0 } ], "criteria": { "Every mutating verb persists the whole document before returning; a persist failure on an otherwise-successful verb fails loud (ADR 0100)": "internal/enroll/persisted.go — PersistedLedger.persist folds a save failure into the verb result (verb error wins); helper's TestEnrollFace_PersistFailureFailsLoud still green over the shared type", "persistedEnroll moved into internal/enroll so both compositions share one wrapper (no copy)": "internal/enroll/persisted.go defines enroll.PersistedLedger; app/helper/cmd/helper/enrollpersist.go deleted; wiring_prod.go/wiring_dev.go call enroll.OpenPersistedLedger; whole_composition.go openEnrollLedger returns enroll.PersistedLedger", "Restart test in the control-plane composition: mint -> pair -> restart over the same file -> the code and the pending request are still there": "control-plane/cmd/control-plane/enroll_persist_restart_test.go TestOpenEnrollLedger_CodeAndPendingSurviveRestart (green)", "The enrolled-device case pinned (whichever way it comes out)": "control-plane/cmd/control-plane/enroll_persist_restart_test.go TestOpenEnrollLedger_EnrolledDeviceSurvivesRestart proves an Enrolled device survives the restart (it did NOT before the fix)", "GOTCHAS entry: reading the live ledger on a box is curl http://127.0.0.1:8080/api/v1/enroll/codes (loopback, no auth), not enroll.json": "docs/GOTCHAS.md #372" }, "summary": "The control plane's enroll ledger now persists after every mutating verb (shared enroll.PersistedLedger), so a restart no longer drops codes, pending requests, or enrolled devices.", "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.

Dependencies

No dependencies set.

Reference
Matou/idss#2007
No description provided.