Skip to content

Cloud download restores documents deleted locally (NDI-matlab#1238) - #371

Merged
stevevanhooser merged 2 commits into
mainfrom
claude/pensive-cannon-7ncs7l
Nov 13, 2026
Merged

stevevanhooser merged 2 commits into
mainfrom
claude/pensive-cannon-7ncs7l

Conversation

@stevevanhooser

Copy link
Copy Markdown
Contributor

Port of VH-Lab/NDI-matlab#1241 (fixes VH-Lab/NDI-matlab#1238 on the Python side).

Summary

DID retires the id of a document removed from the database and refuses to add it again. So a cloud sync couldn't ingest a downloaded document that the user had deleted locally and the remote still holds.

  • New keyword-only restore_deleted_id=False on ndi_database.add / add_many, ndi_session.database_add and ndi_dataset.database_add. It's MATLAB's 'RestoreDeletedId', snake-cased like error_if_not_found.
  • SQLiteDriver maps it to DID-python's add_docs(..., OnDeletedId="restore") and passes it only when it's set, as NDI-matlab's didsqlite/do_add does. The default call is unchanged.
  • The cloud sync passes restore_deleted_id=True where it ingests downloads, because a cloud document is the same document coming back:
    • cloud.sync.operations._ingest_downloaded_docs, used by download-new, mirror-from-remote and two-way sync. This matches the end of MATLAB's downloadNdiDocuments.
    • cloud.orchestration._sync_download_new.
  • tests/conftest.py: FakeDataset.database_add accepts the new keyword, as the real one does.

INTERFACE UPDATE: I have modified the bridge contract for database_add (session, dataset) and ndi.database/add to reflect the MATLAB source (new RestoreDeletedId argument).

Requires DID-python's OnDeletedId option (VH-Lab/DID-python#110, already merged).

Tests

  • New tests/test_restore_deleted_document.py, mirroring the MATLAB tests:
    • a deleted id is still refused by default
    • restore_deleted_id=True restores it
    • _ingest_downloaded_docs brings back a document deleted locally
  • The two restore tests fail without the fix and pass with it.
  • black --check and ruff check are clean.
  • Full suite locally, compared before and after this change:
    • Identical failure/error set: 264 failed and 88 errors in both runs. All are pre-existing and come from GitHub-only dependencies (ndr, vhlab-*, ndi-compress, ...) that the sandbox couldn't download.
    • 3 more passes after the change: the new tests.
    • CI has the full dependency set.

Generated by Claude Code

Port of VH-Lab/NDI-matlab#1241. DID retires the id of a document
removed from the database and refuses to add it again, so a cloud sync
failed to ingest a downloaded document that had been deleted locally.

- restore_deleted_id (keyword-only, default False) on ndi_database.add /
  add_many, ndi_session.database_add and ndi_dataset.database_add; the
  SQLite driver maps it to DID-python's OnDeletedId="restore", passed
  only when set.
- The cloud sync's ingestion (_ingest_downloaded_docs, used by
  download-new, mirror-from-remote and two-way sync) and
  orchestration._sync_download_new pass restore_deleted_id=True.
- Bridge contracts for database_add (session, dataset) and
  ndi.database/add gain the RestoreDeletedId argument.
- tests/test_restore_deleted_document.py, mirroring the MATLAB tests.

Requires VH-Lab/DID-python with add_docs OnDeletedId (DID-python#110,
merged).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011v7R5vMg5Qz8W7zUb26wM2
The bridge-completeness job checks NDI-matlab out at this PR's matching
branch, where downloadNdiDocuments.m, dataset.m, session.m (4930b5dd)
and database.m (b5e629c0) carry the RestoreDeletedId change this PR
ports. Each entry's python_path is changed in this PR, so this is a
regular port and the hash is the record of examination.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011v7R5vMg5Qz8W7zUb26wM2
@stevevanhooser
stevevanhooser merged commit 30699a2 into main Nov 13, 2026
15 checks passed
@stevevanhooser
stevevanhooser deleted the claude/pensive-cannon-7ncs7l branch November 13, 2026 20:58
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.

mirroring from cloud breaks because did does not allow the same ID to be used again

2 participants