Skip to content

Binding check reaches nested fields (lands off by default; did-schema#89) - #601

Draft
jesshaley wants to merge 2 commits into
V2from
claude/binding-check-nested
Draft

jesshaley wants to merge 2 commits into
V2from
claude/binding-check-nested

Conversation

@jesshaley

@jesshaley jesshaley commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Builds [binding check reaches nested fields] (B2, option A) and follows [nested check lands before arming] (C1 = A). Both were decided by Jess Haley on 2026-12-03 and are recorded in did-schema docs/plans/did_v2_go_forward_class_audit.md. Tracked in Waltham-Data-Science/DID-schema#89.

BindingConformance stays OFF by default in this PR. It is armed later, once every name-only variable that production code writes has a registered term.

What changes

  • did2.schema.cache/validateField calls a new validateNestedBindings.
    • It walks the field's declared sub-fields at any depth: a struct, a struct array, or a cell of structs.
    • Each bound sub-field goes to the same checkBinding, with the same gates and error ids. Paths are named like method.parameters(2).variable.
    • Not judged: a missing key; an empty value ([], '', a struct with no fields); an element holding only blanks (holdsOnlyBlanks, the placeholder buildBlankDocument writes).
    • holdsBinding skips sub-trees that have no bound field.
  • strictMode('BindingConformance') is unchanged: envFlag('DID_ENFORCE_BINDING_CONFORMANCE'), off unless the variable is set. Comments say arming waits for [nested check lands before arming].
  • testBindingConformance:
    • testBindingConformanceIsDISARMEDByDefault is kept; the env variable is cleared for that test.
    • New testTheEnvironmentCanArmIt: 1 arms the check, a typo leaves it off.
    • Ten nested tests: a malformed nested variable is refused; conforming, absent and blank-placeholder values pass; nested sets are checked; a nested preferred binding refuses nothing; with the switch off nothing is checked; top-level behaviour is unchanged.

Measured armed (first head 94ecf18, since reverted)

Six corpora: 0 quarantined.

Corpus Final documents
20211116 5,950
B 29,571
Dab 65,998
PRED 40
JH 82,845
Soph 642,885

Tests: armed, the check refused name-only variables.

  • DID: 71 unit tests failed. 68 are testBuild*. The other three cover two DID passes: openMINDS citations and the Ngrid non-area condition.
  • NDI: 53 failed in the suite, 28 in the Haley import, 5 in the migrate assemblers.

See the comment on this PR for the details.

https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf


Generated by Claude Code

[binding check reaches nested fields] (B2 option A) and [binding check
armed after a corpus count] (B1), Decided by Jess Haley, 2026-12-03,
did-schema docs/plans/did_v2_go_forward_class_audit.md; tracked in
Waltham-Data-Science/DID-schema#89.

- did2.schema.cache/validateField now calls validateNestedBindings, which
  applies the one checkBinding to every bound sub-field at any depth
  (method.parameters(k).variable, statement.conditions(k).variable,
  data.dimensions(k).term, relative_time_reference.value.clock, ...).
  Absent sub-fields, empty ones, and elements holding only blanks (the
  buildBlankDocument placeholder) are not judged.
- strictMode('BindingConformance') is armed by default
  (~envFlagIsOff('DID_ENFORCE_BINDING_CONFORMANCE')); =0 disarms it.
  Comments that said it was disarmed are updated, with the B1 count.
- testBindingConformance: the default test now asserts ARMED (the
  decision inverts it); new tests for the env switch and for nested
  bound fields (malformed refused, conforming / absent pass, nested
  sets, preferred advisory, switch off, top level unchanged).

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

Copy link
Copy Markdown
Collaborator Author

CI on 94ecf18: the corpora are clean, but arming refuses name-only variables that tests and production writers build. No tests or writers have been changed yet; this needs a team decision before anything is changed.

Corpora: 0 quarantined. Final document counts are the same as the B1 census and as V2 run 47204548077.

Corpus Sources Final documents Quarantined
20211116 1,220 5,950 0
B 12,917 29,571 0
Dab 27,561 65,998 0
PRED 14 40 0
JH 78,688 82,845 0
Soph (run 47206648890, 6 shards) 101,427 642,885 0
  • Dab and PRED have pass-1 quarantines (1,605 and 1), all resolved by a later pass, still 0. V2 shows the same numbers.
  • Sources: Test code run 47206647683, jobs "corpus: others" and "corpus: JH".

Unit and builder tests fail. The 71 are the same failures in the builder, quick and unit runs.

Run Tests run Passed Failed Incomplete
did2.build 47206647592 452 384 68 65
did2.build baseline 47204596027 459 459 0 0
Quick 47206647591 2,941 2,819 71 117
Quick baseline 47204595475 2,937 2,886 0 51
Test code unit 47206647683 2,941 2,819 71 117
Test code unit, V2 47204548077 2,930 2,879 0 51
  • 68 of the 71 are testBuild* tests that build bare names with no node, mostly statement.variable ('voltage', 'time', 'dose', …), plus method.parameters.variable and data.dimensions.term. They run with TermRegistry off.
  • testNgridSampledBodyFold/testANonAreaNodeIsCountedThroughTheDispatcher: the decided "[non-area image node, revisited] … a condition with a plain label variable" writes a name-only nested variable, which is now quarantined. This conflicts with that earlier decision.
  • testResolveOpenmindsCitations (2 tests): the pass writes statement.variable as the name-only 'version innovation'.
  • testBindingConformance: all 28 tests pass.

NDI-matlab (branch claude/binding-check-nested = V2 95c22c7a2, which picks this DID branch):

Run Passed Failed Incomplete
Run NDI Test Suite 47206908719 3,349 53 165
Same NDI sha on DID V2, 47145208306 3,402 0 133
Run Tests run Failed
V2 import (Haley) 47206914086 345 28
V_eta migrate assemblers 47206918645 121 5

All the binding refusals in these runs are name-only variables written by NDI production code:

  • data.covariates(k).variable 'channel number' (TestIngestedArchiveBodies, 15)
  • statement.variable: 'perfusing gas', 'illumination', 'serial number', 'short name', 'visual stimulus', 'condition', 'control trial', 'fluorescence intensity'
  • method.parameters(1).variable in stimulus items: 'orientation', 'centre position', 'repetitions', 'sound file name'
  • interaction.method.parameters(1).variable 'frequency'
  • clock_alignment_configuration.method.parameters(2).variable 'sync file name'

The siblings-first rule applies, so NDI has to be fixed before this merges.


Generated by Claude Code

[nested check lands before arming] (C1 = A), Decided by Jess Haley,
2026-12-03, did-schema docs/plans/did_v2_go_forward_class_audit.md: the
nested-field extension merges with the switch OFF by default; arming
waits until every name-only variable production code writes has a
registered term.

- strictMode('BindingConformance') back to
  envFlag('DID_ENFORCE_BINDING_CONFORMANCE') (off unless set);
  Contents.m, epochStringRetention.m and runCorpusDiscovery.m back to V2.
- validateNestedBindings / holdsBinding and the blank-placeholder
  handling are kept; comments say arming waits for the decision and
  cite the armed measurement on 94ecf18.
- testBindingConformance: testBindingConformanceIsDISARMEDByDefault
  restored (env variable cleared for the test); the env test now checks
  that 1 arms it and a typo leaves it off; nested tests kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf
@jesshaley jesshaley changed the title Binding check reaches nested fields, then is armed by default (did-schema#89) Binding check reaches nested fields (lands off by default; did-schema#89) Dec 3, 2026
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