Skip to content

Close the fail-open in check_files' step 3 (DID-matlab#200) - #86

Merged
stevevanhooser merged 1 commit into
mainfrom
claude/did-python-matlab-sync-vlzx8g
Sep 9, 2026
Merged

stevevanhooser merged 1 commit into
mainfrom
claude/did-python-matlab-sync-vlzx8g

Conversation

@stevevanhooser

Copy link
Copy Markdown
Contributor

Summary

Ports the actionable half of DID-matlab#200 into Python.

check_files' step 3 looped over the actual file_info entries and fell through to is_valid = True when a required name had none — the same fail-open PR #182 closed for step 1, one step further down. A demoFile document declaring both filename1.ext and filename2.ext but binding neither was accepted by add_docs and only noticed at read time.

check_files now separates the two absences:

  • A name missing from the document's file_list keeps the existing message.
  • A name that IS in the file_list with nothing bound for it gets its own message, naming the file and file_info rather than sending the reader to the field that is correct.

The other half of DID-matlab#200 — reading file_list independently of file_info so a throw on the latter doesn't discard the former — is not a bug on the Python side. _validate_files already reads the two fields independently and did not share MATLAB's try/catch shape, so no code change beyond check_files was needed.

Everything else DID-matlab merged in the last 48 hours (PRs #190–#198) was already ported to DID-python in the same window in #76–#85.

Changes

  • src/did/validate.py — check_files step 3 no longer silently passes an unbound required file.
  • tests/test_validation.py — new TestFileValidationDiagnosis (6 tests, mirroring MATLAB's TestFileValidationDiagnosis one for one). Mutation-checked: reverting the guard turns the two diagnosis-pinning tests red and leaves the four keep-passing guards (no files section, optional files unbound, bound required files, unit-level check_files) green.
  • src/did/did_matlab_python_bridge.yaml — bumped database.matlab_last_sync_hash ec1e733 → 9b36124 and recorded the port in the checkfiles decision log and sync_notes.

Test plan

  • pytest tests/ --ignore=tests/symmetry — 699 passed, 1 xfailed
  • pytest tests/symmetry — 23 passed, 10 skipped (expected)
  • black --check src/ tests/ (pinned 26.5.1) — clean
  • ruff check src/ tests/ (pinned 0.16.5) — clean
  • Mutation check: stash validate.py, tests fail exactly as intended; restore, tests pass

🤖 Generated with Claude Code

https://claude.ai/code/session_015sRBh2MWZi2LfLBszaDuuB


Generated by Claude Code

check_files' step 3 looped over the actual file_info entries and fell
through to is_valid = True when a required name had none -- an empty
match loop, the same fail-open PR #182 closed for step 1, one step
further down. A demoFile document declaring both filename1.ext and
filename2.ext but binding neither was accepted by add_docs and only
noticed at read time.

Ported from DID-matlab 0ffc1b5 / PR #200. check_files now separates the
two absences: a name missing from the document's file_list keeps the
existing message, and a name that IS in the file_list with nothing bound
for it gets its own, naming the file and file_info rather than sending
the reader to the field that is correct.

The other half of DID-matlab#200 -- reading file_list independently of
file_info to survive a throw on the latter -- is not a bug on the Python
side. _validate_files already reads the two fields independently and did
not share MATLAB's try/catch shape, so no code change beyond check_files
was needed. Mutation-checked: removing the guard turns the two
diagnosis-pinning tests red and leaves the four guards green.

Bridge:
  - database.matlab_last_sync_hash bumped ec1e733 -> 9b36124.
  - checkfiles decision_log records the port and its coverage.
  - sync_notes names the change and why the try/catch half was skipped.

Coverage: tests/test_validation.py:TestFileValidationDiagnosis, six
tests mirroring MATLAB's TestFileValidationDiagnosis one for one.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015sRBh2MWZi2LfLBszaDuuB
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