Repository navigation
ui-server: a Claude memory observation lands after its turn left the journal (main red since #2830) #2893
Description
Context
Main CI went red on 2d21e915f and d9f4405ce in packages/ui-react/tests/turn-journal-runtime.test.ts, "persisted external memory uses the existing reader and authenticated recovery" (dark 320 and light 1280). It passes intermittently in CI (87a0f83a4, 1c5666e7a) and fails deterministically on this host.
error: The change journal cannot safely retain this observation: memory observation requires an active turn
reason: "journal_storage_unavailable",
at recordClaudeMemory (packages/ui-server/src/brain/turn-journal.ts:538)
at persistClaudeMemory (packages/ui-server/src/brain/turn-journal.ts:520)
Expected to contain: "1 steering"
Received: "0 changed files · 0 steering · Cost unknown · Limits unknown"
Bisect (bun run test packages/ui-react/tests/turn-journal-runtime.test.ts -t 'persisted external memory'): 2/2 pass at 1f032f95b, 2/2 fail at b192ca0c0 (#2830, journal/Activity/native-lease commits moved to the SQLite write worker). A successful native Claude memory save or authenticated recovery observed during the turn is now recorded after the turn has left the journal's active set, so the journal refuses it and the steering change is lost from the turn.
Acceptance criteria
- A Claude memory save / authenticated recovery observed during a turn is recorded before that turn finishes; the test above passes deterministically (repeat ≥10 runs locally).
- The late-observation refusal stays for genuinely late observations (test).
- Every journal record path that reads the active turn after an await introduced by CONTRACT: fix(ui-server): commit journal, Activity and native-lease SQLite off the event loop #2830 is checked; each instance fixed has a test that fails on
b192ca0c0. - Mutation: restoring the CONTRACT: fix(ui-server): commit journal, Activity and native-lease SQLite off the event loop #2830 ordering fails the named test.
Verification
bun run test packages/ui-react/tests/turn-journal-runtime.test.ts packages/ui-server, root ./tests.
Activity