Repository navigation
feat(adapters): SQLite session store with the journal Store port - #61
Merged
Merged
Conversation
One database per source under an injected sessions folder (ADR 0009, file-engine §2.2, §2.3): schema v1 with a schema_migration table, WAL and synchronous=FULL read back on every open, integrity_check and foreign_key_check before any write, fail closed on a damaged, foreign, newer or tampered file. Sessions, groups, members, the decision log (fold, locks and append in one transaction), plans and their status changes, and PlanStore, the core's journal Store for one plan, under the <key>.lock source lock. Adds rusqlite 0.40 with the bundled SQLite (Margaux's OK, 29 Nov 2026). Choices recorded as proposals in SPEC §10. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012N2yvaknQJCM8yjc93h9jN
RUSTSEC-2026-0459 affects the SQLite that libsqlite3-sys 0.38 bundles; rusqlite 0.41 bundles 3.54. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012N2yvaknQJCM8yjc93h9jN
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012N2yvaknQJCM8yjc93h9jN
# Conflicts: # CLAUDE.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012N2yvaknQJCM8yjc93h9jN
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012N2yvaknQJCM8yjc93h9jN
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012N2yvaknQJCM8yjc93h9jN
…s, crash cuts - PlanStore appends only while the plan is applying or stopping (INV-03). - confirm requires the active session, the newest draft and the whole decision log, and supersedes the other drafts; Start fresh supersedes the archived session's drafts (INV-04). - An existing file is checked through a read-only connection first; defensive mode, trusted_schema=OFF and mmap_size=0 before the first read; the whole schema, SQL text included, compared on open; stored paths validated as Windows names; an empty file with a leftover -wal refused; plans fixed by triggers; plans loaded in one read transaction. - Tests: crash cuts at every disk call with crash images and the write-ahead check (INV-13, INV-14), a journal write failing mid-run, append-only and fixed rows (INV-16), the lock (INV-23), the live -wal refusal, the bundled SQLite version. - Docs: file-engine §2.2, §9.7, §13; SPEC §10; threat model T5, T12, T14; nfr §8; testing §4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012N2yvaknQJCM8yjc93h9jN
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012N2yvaknQJCM8yjc93h9jN
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.
What
The M2 SQLite session store in
culla-adapters(culla_adapters::store), implementing the core's journalStoreport and the session and decision-log persistence the core expects (ADR 0009, file-engine §2.2, §2.3).SessionsDir: the injected sessions folder (%LOCALAPPDATA%\Culla\sessionsin the app, a temp folder in tests),<key>.sqliteand<key>.locknamed from the source key (serial + folded path, never the drive letter).SessionDb::open_at: fail closed. An existing file must be a Culla database (application idCULL, or an empty database a crashed first open left), not newer than this build, and passintegrity_checkandforeign_key_checkbefore anything is written. Then WAL,synchronous=FULL,foreign_keys=ON,mmap_size=0,trusted_schema=OFFand a 5 s busy timeout are applied and read back. Migrations run in oneBEGIN IMMEDIATEtransaction. After that the open checksschema_migrationagainstuser_version,op_transitionagainst the core's edges, that every trigger is there, and that the stored source is this one. A refused file is left byte for byte as it was, never recreated.schema_migrationtable, nullable mtimes, fixedpartial_relchecks, more guard triggers.recordfolds the log, reads the locks and appends in one transaction. A refused command appends nothing, and a corrupt log gets nothing more appended.insert_plan(operation ids never reused),journal(replays the entries and checks the derived columns against them: fail closed), status changes under the source lock (confirm,supersede,start,pause,interrupt,closein one transaction with the core'sclose).PlanStore: the core'sStore. Each append is all or nothing and durable on return, and every entry is checked again by thejournal_checktrigger.stoprecordsstopping.Dependency:
rusqlite0.41 withbundled(SQLite 3.54: 0.40 bundles a SQLite hit by RUSTSEC-2026-0459) (MIT; libsqlite3-sys MIT; SQLite public domain; hashlink, fallible-iterator and the rest MIT/Apache, foldhash Zlib, all on the existing allowlist, so nodeny.tomlchange). Margaux gave her OK in chat on 29 Nov 2026. Lockfile refreshed by the workflow.Tests
crates/adapters/tests/store.rs(Linux and Windows):The core has no shared Store conformance suite. The executor test plays that role here against the real
runandclose.Proposals for Margaux (SPEC §10, file-engine §2.2, §2.3, §13)
synchronous=FULL, as proposed in ADR 0009, asserted on every open.Touches dependencies (Cargo.toml, Cargo.lock): waits for Margaux's OK before merge.
https://claude.ai/code/session_012N2yvaknQJCM8yjc93h9jN
Generated by Claude Code