idip: idss-idp bbolt persistence for auth-code/refresh records #794

Closed
opened 2026-08-25 09:12:59 +00:00 by matou-build-agent · 3 comments

Follow-up from #776 (ADR 0196). The idss-idp bridge (internal/idp/storage.go) currently keeps auth-code and refresh-token records IN MEMORY behind an unexported store. ADR 0196 calls for embedded bbolt at the declared StateDirectory=/var/lib/idss-idp so a bridge RESTART (as opposed to a wipe) does not drop every live 30-day refresh session.

Every #776 acceptance clause holds either way — including story 18 (a WIPE loses only live sessions; nothing here is a member record) — so this was ruled a two-way-door deferral under ADR 0174. Scope: back the code/refresh maps (and only those; the signing key already persists via the Nix generator, and the verified-key cache is deliberately ephemeral) with bbolt, keyed the same, so a restart re-hydrates live sessions. Add go.etcd.io/bbolt (+ lockfile). The seam (internal/idp/seam_test.go) should gain a restart-survives-refresh case.

Follow-up from #776 (ADR 0196). The idss-idp bridge (`internal/idp/storage.go`) currently keeps auth-code and refresh-token records IN MEMORY behind an unexported `store`. ADR 0196 calls for embedded **bbolt** at the declared `StateDirectory=/var/lib/idss-idp` so a bridge RESTART (as opposed to a wipe) does not drop every live 30-day refresh session. Every #776 acceptance clause holds either way — including story 18 (a WIPE loses only live sessions; nothing here is a member record) — so this was ruled a two-way-door deferral under ADR 0174. Scope: back the code/refresh maps (and only those; the signing key already persists via the Nix generator, and the verified-key cache is deliberately ephemeral) with bbolt, keyed the same, so a restart re-hydrates live sessions. Add `go.etcd.io/bbolt` (+ lockfile). The seam (`internal/idp/seam_test.go`) should gain a restart-survives-refresh case.
Author
Member

This was generated by AI during triage.

Verified against the current code: the idip bridge's store keeps auth-code/refresh records in in-memory maps only (the code's own comment names this as the ADR 0196 gap this ticket closes). The scope is well-bounded and excludes the signing key (already Nix-persisted) and the verified-key cache (deliberately ephemeral). Two-way door — a new embedded-DB dependency, revertible by commit, provable by a restart-survives-refresh seam test — proceeding to ready-for-agent.

Agent Brief

Category: enhancement
Summary: Back the idip bridge's auth-code and refresh-token records with embedded bbolt persistence so a bridge process restart doesn't drop live sessions.

Current behavior:
The bridge's auth-code and refresh-token records live only in in-memory maps behind an unexported store type. A process restart (as distinct from a state wipe) loses every live session, forcing affected members to re-authenticate even though nothing about their membership actually changed.

Desired behavior:
Auth-code and refresh-token records are persisted to an embedded bbolt database at the declared state directory (/var/lib/idss-idp). A bridge restart re-hydrates these records from disk so live sessions (including 30-day refresh sessions) survive. A full wipe of the state directory still loses live sessions — that remains correct behavior (no member record is stored here; membership truth lives elsewhere).

Key interfaces:

  • The store's auth-code and refresh-token maps need a persistent backing (bbolt buckets keyed identically to the current map keys) alongside or replacing the in-memory maps.
  • The signing key (already persisted via the Nix generator) and the verified-key cache (deliberately ephemeral) must NOT be moved into this persistence layer — scope is auth-code/refresh records only.
  • New dependency: go.etcd.io/bbolt, with the module's lockfile updated accordingly.

Acceptance criteria:

  • A refresh-token record issued before a bridge restart is still valid and usable after the restart.
  • An auth-code record issued before a restart behaves identically to one issued after (still single-use, still expires per its original lifetime).
  • A full state-directory wipe still drops all live sessions (unchanged — no persistence bypasses this).
  • The signing key and verified-key cache are unaffected by this change.
  • A seam test demonstrates a restart-survives-refresh case (issue token → simulate restart → refresh succeeds).

Out of scope:

  • Persisting the signing key (already handled) or the verified-key cache (deliberately ephemeral).
  • Any change to session lifetimes (1h access / 30d rotating refresh / 12h) — persistence only, not policy.
  • Member record storage — this store holds no member records per ADR 0196's own framing.
> *This was generated by AI during triage.* Verified against the current code: the idip bridge's `store` keeps auth-code/refresh records in in-memory maps only (the code's own comment names this as the ADR 0196 gap this ticket closes). The scope is well-bounded and excludes the signing key (already Nix-persisted) and the verified-key cache (deliberately ephemeral). Two-way door — a new embedded-DB dependency, revertible by commit, provable by a restart-survives-refresh seam test — proceeding to `ready-for-agent`. ## Agent Brief **Category:** enhancement **Summary:** Back the idip bridge's auth-code and refresh-token records with embedded bbolt persistence so a bridge process restart doesn't drop live sessions. **Current behavior:** The bridge's auth-code and refresh-token records live only in in-memory maps behind an unexported store type. A process restart (as distinct from a state wipe) loses every live session, forcing affected members to re-authenticate even though nothing about their membership actually changed. **Desired behavior:** Auth-code and refresh-token records are persisted to an embedded bbolt database at the declared state directory (`/var/lib/idss-idp`). A bridge restart re-hydrates these records from disk so live sessions (including 30-day refresh sessions) survive. A full wipe of the state directory still loses live sessions — that remains correct behavior (no member record is stored here; membership truth lives elsewhere). **Key interfaces:** - The store's auth-code and refresh-token maps need a persistent backing (bbolt buckets keyed identically to the current map keys) alongside or replacing the in-memory maps. - The signing key (already persisted via the Nix generator) and the verified-key cache (deliberately ephemeral) must NOT be moved into this persistence layer — scope is auth-code/refresh records only. - New dependency: `go.etcd.io/bbolt`, with the module's lockfile updated accordingly. **Acceptance criteria:** - [ ] A refresh-token record issued before a bridge restart is still valid and usable after the restart. - [ ] An auth-code record issued before a restart behaves identically to one issued after (still single-use, still expires per its original lifetime). - [ ] A full state-directory wipe still drops all live sessions (unchanged — no persistence bypasses this). - [ ] The signing key and verified-key cache are unaffected by this change. - [ ] A seam test demonstrates a restart-survives-refresh case (issue token → simulate restart → refresh succeeds). **Out of scope:** - Persisting the signing key (already handled) or the verified-key cache (deliberately ephemeral). - Any change to session lifetimes (1h access / 30d rotating refresh / 12h) — persistence only, not policy. - Member record storage — this store holds no member records per ADR 0196's own framing.
Author
Member

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

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

close-report for #794 — status success

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

envelope
{
  "issue": 794,
  "status": "success",
  "commits": [
    "d59c90c1"
  ],
  "changed_files": [
    "STATUS.md",
    "control-plane/cmd/idss-idp/main.go",
    "go.mod",
    "go.sum",
    "internal/idp/config.go",
    "internal/idp/config_test.go",
    "internal/idp/persist.go",
    "internal/idp/provider.go",
    "internal/idp/seam_test.go",
    "internal/idp/storage.go"
  ],
  "tests": [
    {
      "command": "go build ./...",
      "exit_code": 0
    },
    {
      "command": "go vet ./...",
      "exit_code": 0
    },
    {
      "command": "gofmt -l internal/idp/ control-plane/cmd/idss-idp/",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/idp/...",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/clan/...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "A refresh-token record issued before a bridge restart is still valid and usable after the restart": "TestSeam_Restart_SurvivesRefresh (internal/idp/seam_test.go): issues a refresh, restarts the bridge over the same StateDirectory+signing key, asserts the pre-restart token still rotates (200) and survives a second restart; backed by store.load() re-hydrating bucketRefresh (persist.go) and write-through in newRefreshToken/renewRefreshToken (storage.go)",
    "An auth-code record issued before a restart behaves identically to one issued after (still single-use, still expires per its original lifetime)": "The codes map keeps its existing single-use/expiry semantics unchanged; persistence only mirrors SaveAuthCode/DeleteAuthRequest to bucketCodes (storage.go persistCode/deleteCode) — the full auth-code code flow stays green (TestSeam_ActiveMember_CodeFlowAndClaims and all seam tests pass)",
    "A full state-directory wipe still drops all live sessions (unchanged)": "TestSeam_WipedBridge_LosesOnlySessions stays green (a fresh bridge instance / new StateDirectory has no record); only the codes/refresh maps are persisted, no member record on disk",
    "The signing key and verified-key cache are unaffected by this change": "Only bucketCodes/bucketRefresh are persisted (persist.go); the signing key stays Nix-persisted and store.held (verified-key cache) is untouched — no persistence path references either",
    "A seam test demonstrates a restart-survives-refresh case (issue token -> simulate restart -> refresh succeeds)": "TestSeam_Restart_SurvivesRefresh in internal/idp/seam_test.go (commit d59c90c1)"
  },
  "summary": "Backed the idss-idp bridge's auth-code and refresh-token maps with embedded bbolt at the unit's StateDirectory so a bridge restart re-hydrates live sessions.",
  "reason": "",
  "blockers": [],
  "no_code_change": ""
}
**close-report** for #794 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 794, "status": "success", "commits": [ "d59c90c1" ], "changed_files": [ "STATUS.md", "control-plane/cmd/idss-idp/main.go", "go.mod", "go.sum", "internal/idp/config.go", "internal/idp/config_test.go", "internal/idp/persist.go", "internal/idp/provider.go", "internal/idp/seam_test.go", "internal/idp/storage.go" ], "tests": [ { "command": "go build ./...", "exit_code": 0 }, { "command": "go vet ./...", "exit_code": 0 }, { "command": "gofmt -l internal/idp/ control-plane/cmd/idss-idp/", "exit_code": 0 }, { "command": "go test ./internal/idp/...", "exit_code": 0 }, { "command": "go test ./internal/clan/...", "exit_code": 0 } ], "criteria": { "A refresh-token record issued before a bridge restart is still valid and usable after the restart": "TestSeam_Restart_SurvivesRefresh (internal/idp/seam_test.go): issues a refresh, restarts the bridge over the same StateDirectory+signing key, asserts the pre-restart token still rotates (200) and survives a second restart; backed by store.load() re-hydrating bucketRefresh (persist.go) and write-through in newRefreshToken/renewRefreshToken (storage.go)", "An auth-code record issued before a restart behaves identically to one issued after (still single-use, still expires per its original lifetime)": "The codes map keeps its existing single-use/expiry semantics unchanged; persistence only mirrors SaveAuthCode/DeleteAuthRequest to bucketCodes (storage.go persistCode/deleteCode) — the full auth-code code flow stays green (TestSeam_ActiveMember_CodeFlowAndClaims and all seam tests pass)", "A full state-directory wipe still drops all live sessions (unchanged)": "TestSeam_WipedBridge_LosesOnlySessions stays green (a fresh bridge instance / new StateDirectory has no record); only the codes/refresh maps are persisted, no member record on disk", "The signing key and verified-key cache are unaffected by this change": "Only bucketCodes/bucketRefresh are persisted (persist.go); the signing key stays Nix-persisted and store.held (verified-key cache) is untouched — no persistence path references either", "A seam test demonstrates a restart-survives-refresh case (issue token -> simulate restart -> refresh succeeds)": "TestSeam_Restart_SurvivesRefresh in internal/idp/seam_test.go (commit d59c90c1)" }, "summary": "Backed the idss-idp bridge's auth-code and refresh-token maps with embedded bbolt at the unit's StateDirectory so a bridge restart re-hydrates live sessions.", "reason": "", "blockers": [], "no_code_change": "" } ``` </details>
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#794
No description provided.