Skip to content

Fix #981: make generic_file.ext optional in generic_file schema - #982

Closed
claude[bot] wants to merge 1 commit into
mainfrom
claude/fix-issue-981-generic-file-optional
Closed

claude[bot] wants to merge 1 commit into
mainfrom
claude/fix-issue-981-generic-file-optional

Conversation

@claude

@claude claude Bot commented Sep 9, 2026

Copy link
Copy Markdown

Summary

Fixes #981. The 12 TestGeneFromFiles failures on main — every one of the form:

Required file "generic_file.ext" is declared in the file_list of
generic_file doc <id> but no file is bound to that name
(files.file_info has no entry for it)

— come from session.database_add(...) on a generic_file doc produced by ndi.fun.doc.gene.makeSourceFile under its default attachFile=false. DID-matlab's issue-#199 tightening (did.database.checkfiles at database.m:1710) now refuses this case that used to fall through to isvalid = 1.

The generic_file class is used in two legitimate modes:

  • describe-only (the default): the doc records the source file's name and MD5 checksum without ingesting a copy — deliberate for the ~9.4 GB SAW .gef case, documented on makeSourceFile itself.
  • attach (attachFile=true): the file is bound to the doc.

This PR flips mustbenotempty: 1 → mustbenotempty: 0 on the generic_file.ext file entry in generic_file_schema.json. Both modes validate cleanly under DID's tightened check:

  • Step 1 (setdiff(expectedNames, actual_file_list)) still passes because the definition file continues to declare generic_file.ext in file_list.
  • Step 3 (must-bind check) is now skipped for generic_file.ext; the attach path still binds it, the describe path is no longer refused.

This matches the pattern already used by pyraview_schema.json and the tile files in spatialGeneExpressionTiles_schema.json, which declare optional bindings with mustbenotempty: 0.

Options considered:

  • A. Bind a placeholder in makeSourceFile — would satisfy the schema but would force testSourceFileDescribesWithoutIngestingAPayload to stop asserting verifyEmpty(doc.current_file_list()), which is exactly the documented invariant of the describe-only default.
  • B (this PR). Loosen the schema — one-line change, no test churn, semantically correct because the class genuinely has two modes.
  • C. Split into two classes — most churn; disproportionate for the fix.

The check being loosened only fired at write time on a doc whose file_list declared generic_file.ext but bound nothing. Since makeSourceFile is the only producer of generic_file docs in the codebase and its two branches are add_file(...) or nothing, there is no attach-path bug the required-file check was silently catching.

Expected effect on CI

All 12 previously-failing TestGeneFromFiles tests should pass:

  • testPyramidTilesCarryTheSourceFileDependency
  • testCellsCarryTheSourceFileDependency
  • testFromGefBuildsTheWholeLadder
  • testFromGefTakesTheChipAndPixelSizeFromTheFile
  • testFromGefRecordsTheSourceFileByDefault
  • testFromGefReportsProgressThroughTheWholeRun
  • testFromGefWithoutAProgressFcnIsSilentRatherThanBroken
  • testFromGefRefusesWithoutASubject (was reporting 'DID:Database:ValidationFiles' before fromGEF reached the subject-required check)
  • testFromCellBinBuildsCellsAgainstThePyramid
  • testFromCellBinRecordsWhatTheReaderConcludedNotWhatWasAsked
  • testFromCellBinIngestsARequestedLabeling
  • testFromCellBinTakesUnsupervisedFromTheCallerNotTheFile

The attachFile=true test (testSourceFileCanAttachWhenAsked) also continues to pass — the schema now permits the file binding rather than requiring it, and the code still binds when asked.

Once this lands, PR #979 will go green on rebase (its diff is orthogonal — lightsheet scaffold).

Test plan

  • CI: Run NDI Test Suite No Cloud — expect the 12 TestGeneFromFiles failures to clear.
  • Local reviewer with MATLAB: run ndi.unittest.fun.doc.gene.TestGeneFromFiles and confirm all pass.
  • Static: no other producer of generic_file docs beyond makeSourceFile; the schema change does not affect docs that already bind a file.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Cn7RipE1szEPizasFa1EEo


Generated by Claude Code

The generic_file class is used in two legitimate modes: describe-only
(the default in ndi.fun.doc.gene.makeSourceFile, where the doc records
the source file's name and MD5 checksum without ingesting a copy) and
attach (attachFile=true, where the file itself is bound to the doc).

The schema declared "generic_file.ext" with mustbenotempty: 1, which
was tolerated by an earlier DID-matlab validator that fell through to
isvalid=1 when nothing was bound. DID's issue #199 tightening now
refuses a required file-list entry that has no matching file_info
binding, so every session.database_add on a describe-only doc fails.

Loosen the schema to mustbenotempty: 0. Both modes still validate:
the file_list still declares generic_file.ext (so Step 1 of
did.database.checkfiles passes), the attach path continues to bind
the file, and the describe path is no longer refused. This matches
the pattern used by other optional-file schemas such as pyraview.

Fixes #981.

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

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Test Results

1 295 tests  ±0   1 262 ✅ ±0   4m 34s ⏱️ +3s
  201 suites ±0      33 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 3eb8db8. ± Comparison against base commit 114e034.

@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 29.19%. Comparing base (114e034) to head (3eb8db8).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #982   +/-   ##
=======================================
  Coverage   29.19%   29.19%           
=======================================
  Files         853      853           
  Lines       43037    43037           
=======================================
  Hits        12566    12566           
  Misses      30471    30471           

☔ 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.

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.

TestGeneFromFiles fails against current DID-matlab: makeSourceFile must attach the file when generic_file schema requires it

1 participant