Move V_delta schema_version from base to document_class#141
Merged
Conversation
Companion to did-schema PR #55, which dropped schema_version from V_delta's base.json fields array and re-spec'd it as a structural key on document_class. schema_version names the overarching schema set (V_delta vs did_v1), not a property of any one class, so it lives alongside class_name / class_version / superclasses on document_class. The previous placement on base.schema_version was the cause of the ~16 DID:Database:ValidationFields errors on NDI-matlab #803 after #140's superclass fix let validation get past the chain check: NDI's legacy base_schema.json declares only session_id/id/name/ datestamp, and the unknown 5th base field tripped the strict-fields validator. Changes ------- - universalRenames now stamps document_class.schema_version (not base.schema_version). It also migrates a stale base.schema_version forward when it finds one — bodies emitted by an earlier V_delta-draft migrator carry the tag on base; move it to document_class and strip from base so the strict-fields validator on the next write doesn't reject base.schema_version as undeclared. - v1_to_v2.isAlreadyVDelta short-circuit reads from document_class.schema_version. - cache.buildBlankDocument stamps document_class.schema_version = 'V_delta' so freshly built blanks are immediately recognised as V_delta-shaped by the dispatcher. - Tests updated end-to-end: makeVDeltaSkeleton puts schema_version on document_class; existing assertions on doc.get('base.schema_version') rewritten to doc.get('document_class.schema_version'). Three new assertions: stale-base->document_class migration, blank-document stamp, and the absence of base.schema_version after migration. The validator's strict-fields check (cache.m:446-458) only applies to chain blocks, so an extra structural key on document_class (the new schema_version) is accepted without further changes. No new schema_version-value enum check yet; the migrator + buildBlankDocument both stamp 'V_delta' by construction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Companion to did-schema #55.
schema_versionis the version of the overarching schema set (V_delta vs did_v1), not a payload field on any class — so it lives atdocument_class.schema_version(sibling ofclass_name,class_version,superclasses), never onbase.The previous placement (
base.schema_version, a declared field on V_delta's base.json) is what caused the ~16DID:Database:ValidationFieldserrors on NDI-matlab #803 after #140 cleared the superclass-chain mismatch: NDI's legacybase_schema.jsondeclares onlysession_id/id/name/datestampunderbase, and the unknown 5th base field tripped the validator. Moving the tag todocument_classremoves it from the base block entirely — NDI's legacy validator sees no extra field; the V_delta strict-fields check (cache.m:446-458) only enforces declared fields on chain blocks, not ondocument_class, so the new structural key is accepted without further change.Changes
universalRenamesstampsdocument_class.schema_versioninstead ofbase.schema_version. Also migrates a stalebase.schema_versionforward (bodies emitted by an earlier V_delta-draft migrator carry the tag onbase; the new pass moves it todocument_classand strips frombase) so the strict-fields validator on the next write doesn't reject the legacy placement.v1_to_v2.isAlreadyVDeltashort-circuit reads fromdocument_class.schema_version.cache.buildBlankDocumentstampsdocument_class.schema_version = 'V_delta'so freshly built blanks are immediately recognised as V_delta-shaped.makeVDeltaSkeletonputsschema_versionondocument_class; existing assertions ondoc.get('base.schema_version')rewritten todoc.get('document_class.schema_version'). Three new assertions: stale-base→document_classmigration, blank-document stamp, and absence ofbase.schema_versionafter migration.Merge order
schema_versionfrom base fields)DID:Database:ValidationFieldserrors. (ThetestTuningCurveCalcnumeric failure is independent.)Test plan
Generated by Claude Code
Generated by Claude Code