Skip to content

did2 sqlitedb: a file store (ingestion) - #215

Merged
jesshaley merged 1 commit into
V2from
claude/ecstatic-pascal-md91fw
Oct 4, 2026
Merged

jesshaley merged 1 commit into
V2from
claude/ecstatic-pascal-md91fw

Conversation

@jesshaley

Copy link
Copy Markdown
Collaborator

did2.database.sqlitedb stored documents only. The legacy did.implementations.sqlitedb copies files into <db folder>/files/<uid>, but that was never ported to V2. So a V2 writer that creates bytes, like the Haley V2 import's masks and tracks, had nowhere to put them. NDI's did2sqlite errors on any file not recorded by location.

What changes

Ingestion

  • On add, every files.file_info location with ingest true is copied into <db folder>/files/<uid>. This is the same layout as the legacy backend, so NDI's file_directory is unchanged.
  • Each copy is recorded in a new files table.
  • delete_original removes the source only after the documents are committed.
  • A location with ingest false is recorded and read where it is.

Lookup: hasFile, filePath and fileNames. filePath raises an error that names the missing piece (noSuchFile, fileNotHere, missingDocument) and never returns an empty path.

Refusals instead of warnings: these are errors, and nothing in the batch is written. Files already copied for it are deleted.

  • an unsafe uid;
  • a missing source file;
  • a location type other than file;
  • a uid already stored with different bytes.

The legacy backend warned and stored the document anyway, which left a document whose file was missing.

Removal: deletes the bytes a document ingested, unless another document still records the same uid.

Older databases gain the files table when opened.

CI: testSqliteDbFiles adds 14 tests. test-builder.yml now also runs testSqliteDb* and triggers on +did2/+database changes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf


Generated by Claude Code

files.file_info locations with ingest true are copied into
<database folder>/files/<uid> on add (the legacy layout), recorded in a
files table, and found again by hasFile / filePath; ingest false is
recorded and read where it is. Refusals (unsafe uid, missing source,
non-file location, uid stored with other bytes) leave nothing written;
removal deletes the bytes a document ingested unless another document
records the same uid. A database from before the store gains it on open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf
jesshaley pushed a commit to Waltham-Data-Science/DID-schema that referenced this pull request Oct 4, 2026
The seven subject.type kinds (#84, signed 2026-10-02) are staged with empty
nodes like the other bound value sets; #84 did not raise the number because
the did-schema gates run this sweep without --enforce, so it surfaced only
in DID-matlab's quick gate (VH-Lab/DID-matlab#215).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf

Copy link
Copy Markdown
Collaborator Author

Quick migrator tests / Migrator transform tests (no corpora) is red, but not because of this PR. Its check_empty_ontology_nodes.py --enforce step reads the did-schema checkout and reports "93 schema-side entries, baseline 86". did-schema #84 added seven subject.type terms with empty nodes and didn't raise the baseline. This PR touches none of that.

The fix is Waltham-Data-Science/DID-schema#87, which raises the baseline to 93. It's on the same-named did-schema branch, so this job picks it up. I've re-run the failed job once against it.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

The re-run got past the ontology-term guard, so DID-schema#87 fixes that part. It then failed 78 migrator tests, for a reason that isn't this PR's either.

The tests this PR adds (testSqliteDbFiles, plus the existing testSqliteDb) run in did2.build tests, which is green. That job fails on any filtered or incomplete test.

No fix exists here: it needs the migrators brought up to the #73 schema, which is separate work.


Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

Test code / Analyse and test code is red, but not because of this PR, for the same reason as the quick gate.

No fix belongs in this PR. I haven't re-run this ~5 h job: the one re-run went to the quick gate above.


Generated by Claude Code

@jesshaley
jesshaley marked this pull request as ready for review October 4, 2026 19:51
@jesshaley
jesshaley merged commit aba8d66 into V2 Oct 4, 2026
6 of 10 checks passed
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