Skip to content

Retire the manifest cloud-reference workaround (#986) - #989

Closed
stevevanhooser wants to merge 1 commit into
mainfrom
claude/ndi-986-retire-manifest-workaround
Closed

stevevanhooser wants to merge 1 commit into
mainfrom
claude/ndi-986-retire-manifest-workaround

Conversation

@stevevanhooser

Copy link
Copy Markdown
Contributor

Summary

Closes the last item on #986. Removes the "belt and suspenders" workaround at updateFileInfoForLocalFiles.m:96-101, which used to write a second ndicloud location alongside the local file location on every downloaded series manifest.

Why the workaround existed

Before DID-matlab#191, DID's read path could not reach a manifest that lived on the local disk directly — its customFileHandler only got called for non-file locations. So when updateFileInfoForLocalFiles re-pointed a downloaded manifest at its local copy, DID would try to open a member of the series, hand the local path to download_file_from_cloud, and hit NDI:Didsqlite:UnsupportedFileLocationType. DID treats a handler that fails as a plain miss (deliberately, since it resolves speculatively), so every member of a downloaded series read as absent — silently. See #966.

The workaround: keep the cloud reference alongside the local one, so the handler always had an ndic:// path to work with, whichever DID reached for first.

Why it can be retired now

Two DID-side fixes closed both sides of the gap:

The full cloud round trip now has coverage on both sides:

Either would fail if this retirement regressed member reads.

What's in the diff

  1. src/ndi/+ndi/+cloud/+sync/+internal/updateFileInfoForLocalFiles.m — remove the 30-line block that wrote the second location (both the code and the long comment explaining why the workaround existed). The reconstructSeriesIngestLocations call for DID#185's guard stays; that's unrelated.
  2. tests/+ndi/+unittest/TestDownloadedSeriesManifestKeepsItsCloudLocation.m — deleted. Its whole subject was pinning the second location; with the workaround gone, its assertions describe behavior we deliberately no longer have.
  3. tests/+ndi/+unittest/+database/TestUpdateFileInfoPreservesSeries.m — add testSeriesManifestHasExactlyOneLocation. Guards the new invariant: after updateFileInfoForLocalFiles, the manifest's file_info has exactly one location, and it's the local file. Reintroducing an ndic:// second location trips this test immediately.

Related

Test plan

  • ndi.unittest.database.TestUpdateFileInfoPreservesSeries — the new testSeriesManifestHasExactlyOneLocation should pass; the other three (from NDI-matlab#945) should keep passing.
  • ndi.unittest.cloud.FileSeriesRoundTripTest.testMembersSurviveADownloadFromTheCloud (SyncFiles=true) — must keep passing after the workaround is gone. This is the real regression guard.
  • ndi.unittest.cloud.FileSeriesRoundTripTest.testMembersSurviveADownloadFromTheCloudWithSyncFilesFalse — must keep passing.
  • Full offline unit-test suite in CI.

Cannot run MATLAB locally in this session — please review and validate before merging.

🤖 Generated with Claude Code

https://claude.ai/code/session_015dKpDXCo8VTS4AHiibNnCp


Generated by Claude Code

updateFileInfoForLocalFiles no longer writes a second 'ndicloud' location
alongside the local 'file' location on a series manifest. That workaround
existed to give DID's customFileHandler a non-'file' sourcePath for
member fetches, because sqlitedb.download_file_from_cloud raised
NDI:Didsqlite:UnsupportedFileLocationType on a plain local path -- so
every member of a downloaded series read as absent, silently
(NDI-matlab#966).

DID-matlab#191 taught the read path to reach a local-file manifest
directly, and DID-matlab#201 closed the last case
(cloud-only manifest fetched through the same handler). The workaround
became "belt and suspenders" and has been dead weight since #201 landed.
Both sides of the cloud round trip have coverage now: SyncFiles=true via
testMembersSurviveADownloadFromTheCloud (existing) and SyncFiles=false
via testMembersSurviveADownloadFromTheCloudWithSyncFilesFalse (NDI-matlab#988).

The offline test that pinned the workaround
(TestDownloadedSeriesManifestKeepsItsCloudLocation) is removed -- its
whole subject was the second location. In its place,
TestUpdateFileInfoPreservesSeries.testSeriesManifestHasExactlyOneLocation
guards the new invariant: exactly one location, type 'file'. Reintroducing
a second ndic:// location would fail that test immediately.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015dKpDXCo8VTS4AHiibNnCp
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

1 386 tests   - 3   1 353 ✅  - 3   4m 38s ⏱️ -13s
  205 suites  - 1      33 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 2ad46c0. ± Comparison against base commit aea0c72.

This pull request removes 4 and adds 1 tests. Note that renamed tests count towards both.
ndi.unittest.TestDownloadedSeriesManifestKeepsItsCloudLocation ‑ testAPlainFileGetsNoCloudReference
ndi.unittest.TestDownloadedSeriesManifestKeepsItsCloudLocation ‑ testNoCloudDatasetIdMeansNoCloudReference
ndi.unittest.TestDownloadedSeriesManifestKeepsItsCloudLocation ‑ testTheManifestAlsoKeepsItsCloudReference
ndi.unittest.TestDownloadedSeriesManifestKeepsItsCloudLocation ‑ testTheManifestKeepsItsLocalCopy
ndi.unittest.database.TestUpdateFileInfoPreservesSeries ‑ testSeriesManifestHasExactlyOneLocation

@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 29.79%. Comparing base (aea0c72) to head (2ad46c0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #989      +/-   ##
==========================================
- Coverage   29.79%   29.79%   -0.01%     
==========================================
  Files         857      857              
  Lines       43723    43720       -3     
==========================================
- Hits        13029    13026       -3     
  Misses      30694    30694              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor Author

Closing — the workaround is not retirable, my audit note was wrong

Cloud CI 1 failed on 2ad46c0 with two SyncFiles=true failures on FileSeriesRoundTripTest:

  • testMembersSurviveADownloadFromTheCloud — DID:SQLITEDB:open, chunkdata.bin_1 ... cannot be accessed ... bytes are not on this machine and could not be retrieved.
  • testTheBatchScopeIsTheSeriesAndNotTheWholeDocument — same shape.

testMembersSurviveADownloadFromTheCloudWithSyncFilesFalse passed on the same commit — the manifest arrives as ndic:// there and never has a local-only location for this problem to bite on.

What I missed

I misread what DID-matlab#191 gives us. Reading DID more carefully:

  • fetchSeriesMemberBytes (sqlitedb.m:1521) iterates every location the manifest carries and hands each one, in turn, to the customFileHandler as sourcePath, with the member's uid in ctx.uid. Remote first, then local. So DID#191 taught DID to offer a local-file manifest path to the handler.
  • NDI's download_file_from_cloud refuses any sourcePath that doesn't start with ndic:// (didsqlite.m:246, error NDI:Didsqlite:UnsupportedFileLocationType). DID catches that as a miss and moves on.
  • The workaround's second ndicloud location gave the handler an ndic:// URL to actually service on member fetches. Without it — post-retirement — the manifest's only location is a local file path; the handler refuses; there are no more locations to try; DID reports the member as absent.

So DID#191 is a necessary but not sufficient condition. The retirement is only safe if the handler can service a local sourcePath OR if the manifest is guaranteed to also carry an ndic:// location. The retirement removed the guarantee.

What #201 does and doesn't cover

DID#201's fetch is for the manifest itself when it's cloud-only. In the SyncFiles=false shape, the manifest starts as ndicloud, so the handler gets an ndic:// URL from the moment the doc lands — no local-file case to worry about. The SyncFiles=false test in NDI-matlab#988 passes for that reason.

The SyncFiles=true shape is different: the manifest bytes come down on disk, updateFileInfoForLocalFiles reshapes its location to file://..., and — without the workaround — the manifest has no other location. That's the case that broke.

Paths forward

Two real options; both are follow-ups, not this PR:

  1. Keep the workaround (recommended for now). Simplest and self-contained; the "belt and suspenders" characterization is wrong.
  2. Teach download_file_from_cloud to service a local-file sourcePath — read the manifest locally to learn the member's uid, then fetch the member from the cloud by composing the ndic:// URL. Requires threading a cloudDatasetId into the handler's context (a DID contract change) or looking it up from the document via the session (session state in a handler is ugly).

I'll re-comment on #986 with this analysis so the "workaround retirement is pending" item can be reframed accurately.

Closing this PR without merging. The offline test I removed (TestDownloadedSeriesManifestKeepsItsCloudLocation) stays where it is on main, and the branch claude/ndi-986-retire-manifest-workaround will remain around as a record of the attempt.


Generated by Claude Code

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