Skip to content

Sync sqlitedb and database to DID-matlab#227: delete originals after commit, don't reopen a vanished database - #97

Merged
stevevanhooser merged 2 commits into
mainfrom
claude/sync-sqlitedb-write-transactions
Oct 24, 2026
Merged

stevevanhooser merged 2 commits into
mainfrom
claude/sync-sqlitedb-write-transactions

Conversation

@stevevanhooser

Copy link
Copy Markdown
Contributor

Syncs DID-python to VH-Lab/DID-matlab#227 (bb39399). That merge makes "Bridge coverage vs DID-matlab" report drift on sqlitedb.m and database.m for every DID-python PR, and this clears it: the check reports 0 problems again.

Most of #227 (one transaction per write operation, replay after reopen, and the pre-commit replaced-file check) mirrors what is already here from #93 and #94. Two parts weren't, and are ported here.

Changes

  • delete_original sources are deleted only after the write operation commits. _delete_after_commit queues them and _journal_committed deletes them, instead of deleting during ingest, so a rollback no longer leaves the only copy of a file unreferenced in FileDir. Reclaimed cached copies already waited for the commit. A source that two files share is deleted once, and one that's already gone isn't a warning, matching MATLAB's suppression of MATLAB:DELETE:FileNotFound.
  • _recover_transaction doesn't reopen a database file that no longer exists. Reopening created a new, empty database at the path. It now raises the original error with FileNotFoundError as its cause, matching MATLAB's DID:SQLITEDB:DatabaseFileGone.
  • Bridge: sqlitedb and database are bumped to bb39399, the last commit touching each file, with notes added.
    • database.m's change (journal_mode=MEMORY instead of OFF for Validate=false) has nothing to port, since Python never changes journal_mode.
    • The remaining design differences are recorded: BEGIN IMMEDIATE versus a deferred BEGIN, changes() versus rowcount, and where the fields cache is restored. Each has the same effect.

Test changes

  • New: a rolled-back add keeps its original, and deletes it once the add commits; nothing is left queued after an operation.
  • Updated: a deleted database file is an error, and no new database is created at the path.
  • test_open_doc_locations' MATLAB-shaped fixture relied on the old order. Its two files share one original, and the first file's delete_original removed it before the second was copied. Both are now ingested, so test_a_file_with_no_ingested_copy_and_no_original_is_an_error removes filename2's ingested copy itself.

Locally: black --check, ruff check (0.16.5), pytest (802 passed) and check_bridge_coverage.py against DID-matlab main (f4a4905), which reports 0 problems.


Generated by Claude Code

… database

Syncs the two parts of DID-matlab#227 that DID-python didn't have yet.
The transactions, replay and pre-commit replaced-file check it adds
match #93 and #94 here.

- delete_original sources are queued and deleted once the write
  operation commits (_delete_after_commit, flushed by
  _journal_committed), not during ingest. A rollback no longer leaves
  the only copy of a file unreferenced in FileDir. A source two files
  share is deleted once, and a missing one isn't a warning, matching
  MATLAB.
- _recover_transaction doesn't reopen a database file that no longer
  exists, because reopening created a new, empty database there. It
  raises the original error with FileNotFoundError as its cause
  (MATLAB: DID:SQLITEDB:DatabaseFileGone).

test_open_doc_locations' MATLAB-shaped fixture relied on the old order.
Its two files share one original, and the first file's delete_original
removed the source before the second was copied. Both are now
ingested, so the no-copy-no-original test removes filename2's copy
itself.

Bridge notes added for sqlitedb and database. DID-matlab's journal_mode
change has nothing to port, since Python never changes journal_mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Dn4gCNCU2jUGdmfPVCAGK
Both files were last touched by bb39399, the commit DID-matlab#227
merged with. The diff is ported in the previous commit, apart from the
journal_mode change, which has nothing to port. This clears the
"Bridge coverage vs DID-matlab" drift that #227 introduced.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Dn4gCNCU2jUGdmfPVCAGK
@stevevanhooser
stevevanhooser merged commit d84921c into main Oct 24, 2026
7 checks passed
@stevevanhooser
stevevanhooser deleted the claude/sync-sqlitedb-write-transactions branch October 24, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants