engine-adapters: store-runtime-ledgers — the runtime ledgers become state-directory documents #165

Closed
opened 2026-07-29 05:09:33 +00:00 by ben · 1 comment
Owner

Parent

Engine-adapters child spec: #161 (ADRs 0102–0107; scoped on wayfinder #160 — Ben ruled live: per-family clan-lab smokes gate each family, the arc closes on a real-hardware end-to-end, tickets arm the swarm). Everything else agent-decided, post-hoc review pending.

What to build

Every runtime Load/Save ledger port gets its durable backing (ADR 0103 §1): jsonstore.File documents in the control plane's state directory — the member, invite, reset-link and enrollment-code ledgers plus monitoring's expected-pattern tunings. Whole-document single-writer discipline, Check-refused corruption, restart survival. Deliberately lost-in-rebuild (ADR 0078 §3); no live token ever reaches the repo replica.

Acceptance criteria

  • Given an open invite and a minted enrollment code, When the control plane restarts, Then both are still in their ledgers
  • Given a corrupted ledger document, When it is loaded, Then the load is refused loudly, never silently reset
  • Given the repo replica, When it syncs, Then no invite/reset/code token material is in it

Blocked by

  • bootstrap:skeleton — #23 (closed; satisfied)

Task manifest

task: engine-adapters:store-runtime-ledgers
implements_seam: "the confirmed seams + ADRs 0102-0107 are the design contract (no flow/wireframe — spec #161)"
interface: "the existing Ledger/InviteLedger/ResetLedger/code-ledger/pattern ports — contracts unchanged"
seam: "each owning package's seam tests (jsonstore.Memory today) re-run over jsonstore.File; a restart-survival integration test"
acceptance:
  - given: writes through every ledger port; when: the process restarts; then: state survives and corrupt documents refuse
depends_on: [bootstrap:skeleton]
out_of_scope: [screen changes (no UI surface in this arc), the release source / rollout mechanics (out of arc, wayfinder #160)]
needs_human_decision: []
## Parent Engine-adapters child spec: #161 (ADRs 0102–0107; scoped on wayfinder #160 — Ben ruled live: per-family clan-lab smokes gate each family, the arc closes on a real-hardware end-to-end, tickets arm the swarm). Everything else agent-decided, post-hoc review pending. ## What to build Every runtime Load/Save ledger port gets its durable backing (ADR 0103 §1): `jsonstore.File` documents in the control plane's state directory — the member, invite, reset-link and enrollment-code ledgers plus monitoring's expected-pattern tunings. Whole-document single-writer discipline, Check-refused corruption, restart survival. Deliberately lost-in-rebuild (ADR 0078 §3); no live token ever reaches the repo replica. ## Acceptance criteria - [ ] Given an open invite and a minted enrollment code, When the control plane restarts, Then both are still in their ledgers - [ ] Given a corrupted ledger document, When it is loaded, Then the load is refused loudly, never silently reset - [ ] Given the repo replica, When it syncs, Then no invite/reset/code token material is in it ## Blocked by - bootstrap:skeleton — #23 (closed; satisfied) ## Task manifest ```yaml task: engine-adapters:store-runtime-ledgers implements_seam: "the confirmed seams + ADRs 0102-0107 are the design contract (no flow/wireframe — spec #161)" interface: "the existing Ledger/InviteLedger/ResetLedger/code-ledger/pattern ports — contracts unchanged" seam: "each owning package's seam tests (jsonstore.Memory today) re-run over jsonstore.File; a restart-survival integration test" acceptance: - given: writes through every ledger port; when: the process restarts; then: state survives and corrupt documents refuse depends_on: [bootstrap:skeleton] out_of_scope: [screen changes (no UI surface in this arc), the release source / rollout mechanics (out of arc, wayfinder #160)] needs_human_decision: [] ```
Author
Owner

Done in 8126d60 (on origin/main).

ADR 0103 §1's mechanics — every runtime Load/Save ledger port now has a jsonstore.File durable variant beside its seam-test jsonstore.Memory, delivered as durable types with contracts unchanged (no schema-version fields — a corrupt document is refused via the JSON-parse failure jsonstore.decode already gives):

  • member/invite/reset: member.NewFileLedger / NewFileInviteLedger / NewFileResetLedger (internal/member/{ledger,invite,reset}.go).
  • enrollment-code: internal/enroll/store.go — Memory/FileStore over enroll.State plus Persist(l, store) and OpenLedger(cfg, store) wrapping the existing Export/NewLedgerFromState (ADR 0043) handover.
  • monitoring expected-pattern tunings: internal/monitor/patternstore.go — Memory/FilePatternStore over a PatternDoc, plus SnapshotPatterns/ResumePatterns on the orchestrator (mirroring the alert set's StandingAlerts/Resume).

Acceptance criteria — proven at each owning package's seam re-run over jsonstore.File (member/filestore_test.go, enroll/store_test.go, monitor/patternstore_test.go) and by a cross-ledger restart-survival integration test (control-plane/cmd/control-plane/ledgers_restart_integration_test.go):

  • AC1 — an open invite (member) and a minted enrollment code (enroll) both survive a restart (reopened over the same state-directory documents). ✅
  • AC2 — every runtime ledger refuses a corrupt document loudly on load, never a silent reset. ✅
  • AC3 — token material homes in the state directory alone; the modelled config-repo replica stays clean (lost-in-rebuild by design, ADR 0078 §3). ✅

Scope note (agent-decided, spec #161): this slice ships the durable types + seam/integration proof. main.go is deliberately untouched — the composition-root wiring of the state directory (systemd StateDirectory) rides the compose slices (#155 members, #181 aggregation root), and enroll/monitor's save-trigger their transport slices. The member composition is still honest-resting (fail-loud Save) until #155; the config-repo half of ADR 0103 (§2) is #166/#102's. go build, go vet, golangci-lint and the full test suite are clean.

Done in `8126d60` (on `origin/main`). **ADR 0103 §1's mechanics** — every runtime Load/Save ledger port now has a `jsonstore.File` durable variant beside its seam-test `jsonstore.Memory`, delivered as durable types with contracts unchanged (no schema-version fields — a corrupt document is refused via the JSON-parse failure `jsonstore.decode` already gives): - **member/invite/reset:** `member.NewFileLedger` / `NewFileInviteLedger` / `NewFileResetLedger` (`internal/member/{ledger,invite,reset}.go`). - **enrollment-code:** `internal/enroll/store.go` — `Memory`/`FileStore` over `enroll.State` plus `Persist(l, store)` and `OpenLedger(cfg, store)` wrapping the existing `Export`/`NewLedgerFromState` (ADR 0043) handover. - **monitoring expected-pattern tunings:** `internal/monitor/patternstore.go` — `Memory`/`FilePatternStore` over a `PatternDoc`, plus `SnapshotPatterns`/`ResumePatterns` on the orchestrator (mirroring the alert set's `StandingAlerts`/`Resume`). **Acceptance criteria** — proven at each owning package's seam re-run over `jsonstore.File` (`member/filestore_test.go`, `enroll/store_test.go`, `monitor/patternstore_test.go`) and by a cross-ledger restart-survival integration test (`control-plane/cmd/control-plane/ledgers_restart_integration_test.go`): - **AC1** — an open invite (member) and a minted enrollment code (enroll) both survive a restart (reopened over the same state-directory documents). ✅ - **AC2** — every runtime ledger refuses a corrupt document loudly on load, never a silent reset. ✅ - **AC3** — token material homes in the state directory alone; the modelled config-repo replica stays clean (lost-in-rebuild by design, ADR 0078 §3). ✅ **Scope note (agent-decided, spec #161):** this slice ships the durable *types* + seam/integration proof. `main.go` is deliberately untouched — the composition-root wiring of the state directory (systemd `StateDirectory`) rides the compose slices (#155 members, #181 aggregation root), and enroll/monitor's save-trigger their transport slices. The member composition is still honest-resting (fail-loud `Save`) until #155; the config-repo half of ADR 0103 (§2) is #166/#102's. `go build`, `go vet`, `golangci-lint` and the full test suite are clean.
ben closed this issue 2026-07-29 17:06:51 +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#165
No description provided.