Repository navigation
Record thread events in an opt-in event journal - #206
Merged
Merged
Conversation
Routines Phase 0 needs an event journal: thread events in node:sqlite with a durable cursor, written alongside the existing storage behind a flag. state.json and the per-thread files stay authoritative. - EventJournal (engine/event-journal.ts) appends every ThreadEvent with a monotonic seq. Writes are batched every 250 ms and flushed on quit. Within a batch, an item's later updates merge into its pending row and the newest status or thread event replaces the earlier one. A streamed reply therefore costs about one row per batch, and replay is unchanged. since(cursor) pages events, and replayItems() folds them the way the runner applies them. - Main records each event it sends to the window and the companion when MODEX_EVENT_JOURNAL=1 (app/events.sqlite). A journal failure turns the journal off and never touches a turn. Off by default. - Exit test: a real scripted runner session, and a real app session in e2e, replay from the journal to exactly their saved transcripts. Cursors survive reopening, and the merge rules equal applying events in order. The resume endpoint, the paired sleep test and retention come next (docs/event-journal.md). Coven-Harness: Claude Code / claude-opus-5-5
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
# Conflicts: # docs/status.md
This was referenced Oct 18, 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.
This is the first slice of Routines Phase 0: an opt-in event journal, as specified in the routines spec. It records thread events in
node:sqlitewith a durable cursor, written alongside the existing storage behind a flag.state.jsonand the per-thread files stay authoritative; nothing reads the journal to decide app state. It's off by default.What
engine/event-journal.ts:EventJournalappends everyThreadEvent(item,item_update,status,thread) with a monotonicseqcursor that survives restarts. It uses SQLite in WAL mode with no native module;node:sqliteworks in Electron 44 (Node 24.21, SQLite 3.53.4).statusorthreadevent replaces the earlier one. A streamed reply therefore costs about one row per batch instead of one per token, and replay is unchanged.since(cursor, { threadId, limit })pages events, andreplayItems()folds them the way the runner applies them.src/main/index.ts: withMODEX_EVENT_JOURNAL=1, main records each event it already sends to the window and the paired companion, intoapp/events.sqlite. If the journal can't open or a write fails, it's logged and turned off for that run; turns and state files are unaffected. The journal is closed indrainServices.docs/event-journal.md, a progress note in the routines spec, anddocs/status.md.Exit test: replay equals the transcript
test/event-journal.test.tsrecords a real two-turnThreadRunnersession (mock backend with thinking, streaming, a shell tool andapply_patch) through the journal. Replaying it equals the persisted transcript, and so does folding the raw event stream.e2e/event-journal.spec.tslaunches the real app with the flag on, runs a thread and quits. Reopeningevents.sqlitefrom the test process replays exactly the savedthreads/<id>.json. With the flag off, no journal file is created.Verification
npm run build,npm run typecheckandnpm testpass: 1,430 unit tests, 1,414 passed, 16 skipped, 0 failed.Not yet
The resume endpoint (desktop and companion fetch after their last cursor), the paired desktop-and-phone sleep test, and retention. These are listed in
docs/event-journal.md.