Repository navigation
Persist store collections in SQLite, one transaction per write (#835) - #858
Merged
Merged
Conversation
…write (#835) The store's JSON-file engine (in-memory maps, a promise-chain serializer, temp+fsync+rename persistence and the directory lock) is replaced by node:sqlite with direct parameterized SQL: one database per site (store({database}), STORE_DATABASE or data/store.sqlite), shared record, idempotency and audit outbox tables, forward-only schema steps. Every API write is one BEGIN IMMEDIATE transaction covering the checks, the record, the idempotency claim and the audit outbox event; reassign moves every collection in one transaction. Fixes concurrent If-Match writers sharing an ETag within one millisecond. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jimhoyd
enabled auto-merge (squash)
September 28, 2026 20:04
…indows EBUSY on store.sqlite) Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 28, 2026
Closed
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.
First slice of #835: this PR replaces the store's JSON-file engine with
node:sqlite, using direct parameterized SQL (no query builder or ORM). The JSON engine is deleted outright: no compatibility wrapper and no import of old JSON data files.Design
store({database}), elseSTORE_DATABASE, elsedata/store.sqlitebesidehost.mjs, and it must be outsideapp/.synchronous=FULL,busy_timeout=2000,trusted_schema=OFF.application_idanduser_version. Schema steps run forward only, one transaction each. A foreign file or a newer schema refuses activation.store_records,store_idempotencyandstore_audit_outbox, keyed by collection name. A change to a collection's declaration needs no DDL.store_idempotencycan take a result column later, for replay.BEGIN IMMEDIATEtransaction. It covers the idempotency claim, theIf-Matchcheck, key uniqueness, the quotas, the record row and the audit outbox event, and rolls back on any error.urlcode-store reassignmoves every affected collection in one transaction..store.lockmachinery is removed: SQLite's locking keeps a second process from corrupting data, and enforcing exclusivity would rule out online backups and live operator CLI runs.storage_unavailablewith nothing written.If-Matchwriters could both win.urlcode-storetakes--databasein place of--directory, never creates a database, and is safe beside the running server.Evidence (macOS, Node 26)
npm run verifypasses on the branch rebased onto main. It covers the core tests, every workspace suite,test:addonsandtest:proof.npm run test:packagealso passes.If-MatchPATCHes: exactly one wins, the other seven get 412maxRecordsNot claimed
No Windows run locally (CI covers it), no crash, disk-full or soak testing, and no throughput benchmark.
Follow-ups are filed separately: result-aware idempotency and multi-record transitions (the next #835 slice), SQL-side sorted lists, multi-process enforcement, a backup CLI, and the store-crud recipe's target metadata.
🤖 Generated with Claude Code