Repository navigation
Rehydrate per-session audit verify key on operator restart - #20
Merged
Merged
Conversation
The operator's token registry is process memory and starts empty after a restart. reregisterMemoryToken restored each session's memory bearer token on every reconcile path, but the per-session audit public key was registered only at step 4 of Reconcile, below ~30 early returns. A restarted operator therefore accepted a session's bearer token yet held no key to verify what that bearer signed, so every append-only write failed provenance verification with "403 ... no usable key <keyID>". A terminal session, whose reap short-circuits before step 4 forever, could never recover. Restore the verify key alongside the token in reregisterMemoryToken, reading it from status (the same source step 4 uses) through a shared registerAuditVerifyKey helper so the two registration sites cannot drift.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
samkim
approved these changes
Oct 6, 2026
This branch was successfully deployed
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
After an operator restart, a session could fail with
MemoryUnavailable: ... 403 ... no usable key <keyID> for session:...on its next append-only write (for example, when recording a user turn). This was observed in practice after the operator was OOM-killed and restarted.Background
The operator keeps each session's memory bearer token and its audit signing (verify) key in process memory, rebuilt from durable state on every reconcile. Both are needed to accept an append-only write: the token authenticates the caller, and the key verifies the provenance signature on what it writes.
The bearer token was restored at the very top of reconcile, on every path. The audit verify key, however, was only re-registered much later in reconcile — past the many early returns that a terminal or transiently-gated session takes. So after a restart the operator would accept a session's token (no 401) but hold no key to verify what that token signed, and the write was rejected with a 403. A terminal session, which short-circuits before the late registration on every subsequent reconcile, could never recover.
Fix
Restore the audit verify key in the same early, every-path step that already restores the bearer token, reading it from the public key the operator anchored on the session's status. Both registration sites now go through a single shared helper so they cannot drift apart.
Testing