Repository navigation
feat(pm-stack): break-glass owner token — local CLI, audit-first issuance (#9608) - #12941
Merged
Merged
Conversation
…ance (#9608) First slice of #1253 split 6 (design section 6): the owner can issue a single-use, at-most-one-hour admin stack token from the laptop via the aggregator's local CLI. Issuance is written as an audit event before the token record is persisted — if the audit write fails, no token exists. Only the token's sha256 hash is persisted; consume is single-use and fails closed on unknown, expired, or reused tokens. - src/break-glass.ts: token store (fresh disk reads, serialized check-and-consume), issue/consume, issuance audit event - scripts/issue-break-glass-token.ts: the local CLI - src/config.ts: breakGlassFile path (PM_AGG_BREAK_GLASS_FILE) - test/break-glass.test.ts: 7 tests against the section-6 oracle
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 38 seconds. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
dezren39
added a commit
that referenced
this pull request
Nov 23, 2026
Conflict resolution: pm-stack/aggregator/src/config.ts — keep both additive fields (stackTokenSecret from this branch, breakGlassFile from main, PR #12941). Shepherd fixes (no re-implementation): - stack-token.ts: verification now requires explicit iat/exp claims. normalizeClaims substitutes minting defaults for absent timestamps, which let a correctly signed timestamp-less token verify indefinitely (Codex P2 finding on this PR). Minting unchanged. Regression test added to test/stack-token.test.ts. - server.ts: the stack-token exchange route treated only "" as unconfigured; cfg.stackTokenSecret is string | null, so an unconfigured secret slipped through to mintStackToken (TS2345, tsc --noEmit failed; runtime returned a misleading 400 instead of 503). Guard is now !secret. Verification: stack-token + config + break-glass suites 23 pass / 0 fail; tsc --noEmit clean; full aggregator suite 3042 pass / 20 fail with a failure set identical to a pristine-main baseline run (all 20 pre-existing under load, incl. boot.test.ts).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #9608 — the first slice of the #1253 split-6 break-glass work (design record
doc/2026-11-10T23-58-00Z_design_pm_stack_identity, section 6): the owner break-glass token.When Access or the IdP is down, asserted authorship must not return as a fallback. The one recovery path the design allows is local: the owner, from the laptop directly, issues a single-use admin stack token via the aggregator's local CLI. This PR lands that path:
src/break-glass.ts—BreakGlassTokenStore(file-backed, fresh disk reads on every operation, serialized check-and-consume so a second presentation can never also win),issueBreakGlassToken,consumeBreakGlassToken, and the issuance audit-event builder. Invariants: TTL capped at one hour (longer requests refused, never silently honoured); the audit event is recorded before the token record is persisted — an audit-write failure means no token exists; only the token's sha256 hash is ever persisted; unknown, expired, already-consumed, and empty tokens all fail closed.scripts/issue-break-glass-token.ts— the local CLI (--ttl-minutes,--tokens,--events). It resolves the state paths directly rather than throughloadConfig: it is a local operator tool, not the server, so the server's Source gate (Aggregator: fail loud instead of defaulting to fixtures outside dev #1195) must not stand between the owner and the recovery path during an outage.src/config.ts—breakGlassFile(PM_AGG_BREAK_GLASS_FILE, default~/.local/state/pm-aggregator/break-glass-tokens.json, mirroring the identity-registry precedent from impl(pm-stack): aggregator identity registry table + owner admin actions + audit events (#1253 split 2) #9604) so the path has one canonical home for the follow-on server wiring.The Q4 gate on #1253 covers only the comment surface; this slice touches no comment code. Remaining slices for #9608, named on the issue: outage queueing for eligible non-comment writes, and server-side acceptance of the break-glass token on admin routes (the consume half is implemented and tested here; the route wiring is the next slice).
Evidence
Ran on the laptop in a worktree off origin/main:
bun test test/break-glass.test.tson origin/main fails (module../src/break-glass.tsnot found); after this change: 7 pass / 0 fail — audit-before-persist ordering (a sink that inspects the token file mid-issuance sees zero tokens), audit-failure fails closed, one-hour cap, single-use, expiry, hash-only persistence, audit-event shape. Oracle: design section 6.bun test test/identity-registry.test.ts test/config.test.tsplus events/access-identity — 22 pass / 0 fail in the final combined run (58 pass across identity-registry + events + access-identity earlier in the run).bunx tsc --noEmitreports no errors in the touched files.--ttl-minutes 45prints the token once, writes exactly onebreak-glass-token-issuedaudit event and one hash-only token record;--ttl-minutes 61exits 1.test/boot.test.tsfails identically on a pristine origin/main worktree (0 pass / 1 fail) and in this branch.Merge Danger
Low. New module + new script + one additive config field with a default; no server route changes, no changes to existing stores or file formats. The token store file is created only when the CLI is run. Reverting removes the slice cleanly.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.