Skip to content

fix(training-agent): fall back to InMemoryReplayStore when no DB initialized#3381

Closed
bokelley wants to merge 2 commits into
mainfrom
claude/issue-3376-replay-store-no-db-fallback
Closed

fix(training-agent): fall back to InMemoryReplayStore when no DB initialized#3381
bokelley wants to merge 2 commits into
mainfrom
claude/issue-3376-replay-store-no-db-fallback

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Closes #3376

Summary

PR #3351 swapped InMemoryReplayStore for PostgresReplayStore to fix cross-instance replay detection on Fly's multi-machine deployment. The storyboard CI runner (run-storyboards.ts) starts the training-agent without Postgres — no DATABASE_URL, no initializeDatabase() call — so getPool() threw "Database not initialized" on every signed request. All 28 positive signed_requests storyboard vectors returned 401 instead of 2xx; every PR against main has been failing CI since 2bb3dcd8.

Fix: check isDatabaseInitialized() before choosing the store in buildAuthenticatorWithCapability():

Also guards startReplayCacheSweeper()'s interval callback with if (!isDatabaseInitialized()) return to prevent tick-level getPool() throws if the sweeper is ever started in a no-DB context.

Note on neg/016 in CI: The per-authenticator InMemoryReplayStore correctly handles the intra-run replay vector via white-box harness injection (documented in negative/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

  • code-reviewer: approved — no blockers; fixed stale JSDoc on buildStrictRequestSigningAuthenticator per reviewer's issue flag; nits surfaced (missing unit test for isDatabaseInitialized() branch, sweeper guard is defensive dead-code in current call sites)
  • ad-tech-protocol-expert: approved — isDatabaseInitialized() guard is safe per boot sequence; non-breaking per spec definition; changeset classification correct; neg/016 CI scope documented

Triage-managed PR. This bot does not currently iterate on
review comments or PR conversation threads (only on the source
issue). To unblock:

  • Push fixup commits directly: gh pr checkout <num>
    fix → push.
  • Or re-trigger: comment /triage execute on the source
    issue.

See #3121
for context.

Session: https://claude.ai/code/session_015vh3dBv4iAKcoWj4a16ygU


Generated by Claude Code

claude added 2 commits April 28, 2026 07:24
…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
@bokelley bokelley added bug Something isn't working claude-triaged Issue has been triaged by the Claude Code triage routine. Remove to re-triage. labels Apr 28, 2026
@bokelley bokelley marked this pull request as ready for review April 28, 2026 19:01
@bokelley

Copy link
Copy Markdown
Contributor Author

Routine: persistent DIRTY against main. Please rebase locally, resolve, and force-push.

@bokelley

Copy link
Copy Markdown
Contributor Author

Closing as superseded — #3379 landed the same fix on main (commit c614493b0). CI green since.

@bokelley bokelley closed this Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working claude-triaged Issue has been triaged by the Claude Code triage routine. Remove to re-triage.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Training Agent Storyboards: signed_requests 28-vector failure on main since #3351 (PostgresReplayStore swap)

2 participants