fix(training-agent): fall back to InMemoryReplayStore when no DB initialized#3381
Closed
bokelley wants to merge 2 commits into
Closed
fix(training-agent): fall back to InMemoryReplayStore when no DB initialized#3381bokelley wants to merge 2 commits into
bokelley wants to merge 2 commits into
Conversation
…ialized The storyboard CI runner starts the training-agent without Postgres, so `getPool()` threw "Database not initialized" on every signed request after #3351. All 28 positive `signed_requests` storyboard vectors returned 401 instead of 2xx, blocking all PRs against main. Restores pre-#3351 behavior in CI: each authenticator gets its own `InMemoryReplayStore` when `isDatabaseInitialized()` is false. In production (DB always initialized before the server starts listening, per http.ts:8531 vs 8641) the shared `PostgresReplayStore` singleton is unchanged. Also guards `startReplayCacheSweeper()` to no-op inside its interval when no DB is present, preventing tick-level throws if the sweeper is ever started in a no-DB context. Closes #3376 https://claude.ai/code/session_015vh3dBv4iAKcoWj4a16ygU
…uthenticator The comment still referenced per-authenticator InMemoryReplayStore as the isolation mechanism. Since #3351, production isolation comes from the @target-uri-derived scope column of the Postgres singleton. https://claude.ai/code/session_015vh3dBv4iAKcoWj4a16ygU
Contributor
Author
|
Routine: persistent DIRTY against main. Please rebase locally, resolve, and force-push. |
Contributor
Author
|
Closing as superseded — #3379 landed the same fix on main (commit |
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.
Closes #3376
Summary
PR #3351 swapped
InMemoryReplayStoreforPostgresReplayStoreto fix cross-instance replay detection on Fly's multi-machine deployment. The storyboard CI runner (run-storyboards.ts) starts the training-agent without Postgres — noDATABASE_URL, noinitializeDatabase()call — sogetPool()threw"Database not initialized"on every signed request. All 28 positivesigned_requestsstoryboard vectors returned 401 instead of 2xx; every PR against main has been failing CI since2bb3dcd8.Fix: check
isDatabaseInitialized()before choosing the store inbuildAuthenticatorWithCapability():listen()perhttp.ts:8531vs8641): unchanged — sharedPostgresReplayStoresingleton, cross-instance replay protection.InMemoryReplayStore, restoring exact pre-fix(training-agent): PostgresReplayStore so vector 016 catches cross-instance replays #3351 behavior. Each route gets its own store, so cross-route false positives can't occur (training-agent verifier: replay store doesn't reject duplicate (keyid, nonce) — fails grader neg/016 #3338).Also guards
startReplayCacheSweeper()'s interval callback withif (!isDatabaseInitialized()) returnto prevent tick-levelgetPool()throws if the sweeper is ever started in a no-DB context.Note on neg/016 in CI: The per-authenticator
InMemoryReplayStorecorrectly handles the intra-run replay vector via white-box harness injection (documented innegative/016-replayed-nonce.json). Cross-instance replay (the scenario #3351 was solving for) is only validated in production against the Postgres-backed verifier — CI tests the single-process guarantee only.Non-breaking justification
Server-side infrastructure change only. No schema fields, task definitions, or
@adcp/*package API changed. In production the Postgres store path is unaffected. Changeset:--empty.Pre-PR review
buildStrictRequestSigningAuthenticatorper reviewer's issue flag; nits surfaced (missing unit test forisDatabaseInitialized()branch, sweeper guard is defensive dead-code in current call sites)isDatabaseInitialized()guard is safe per boot sequence; non-breaking per spec definition; changeset classification correct; neg/016 CI scope documentedSession: https://claude.ai/code/session_015vh3dBv4iAKcoWj4a16ygU
Generated by Claude Code