Skip to content

fix: preserve format assertion policy in remote schemas - #134

Open
fitchmultz wants to merge 1 commit into
sagold:mainfrom
fitchmultz:fix/remote-format-policy
Open

fitchmultz wants to merge 1 commit into
sagold:mainfrom
fitchmultz:fix/remote-format-policy

Conversation

@fitchmultz

Copy link
Copy Markdown

Problem

formatAssertion: false is respected by a directly compiled schema but lost when addRemoteSchema selects the remote document's draft keywords. A registered email schema therefore rejects a non-email string even though its registering owner requested annotation-only formats.

Correction

  • Retain the effective format policy in the compiled context after meta-schema policy evaluation.
  • Apply that policy when registering remote schemas, including transitive registration.
  • Disable only the format instance validator on remotes; preserve the format parser and malformed-schema diagnostics.

Default and explicit-true behavior remain unchanged. Newly registered schemas follow their registering owner; already compiled external schemas retain their original policy. No resolver, dialect-selection, dependency, or generated distribution changes are included.

Related work

This addresses remote registration separately from #125 / #121, which correct local schema parsing when assertions are disabled. Thanks to @cpruijsen for the related addValidate approach in #125; this PR uses that hook on the remote path to preserve its existing parser. It leaves the local filter unchanged and neither supersedes nor closes #125. When composing the two, retain this context-policy assignment before #125's local keyword mapping.

Verification

  • 69 regression cases across drafts 04, 06, 07, 2019-09 and 2020-12: direct/registered schemas, retrieval identifiers, anchors, transitive registration, owner-policy changes, effective meta-schema policy, and malformed remote formats. Against unchanged production code, 18 annotation-mode cases fail and 51 pass; all 69 pass with this correction.
  • Full unit/in-process Bowtie suite: 1,091 passing, 3 existing pending. Full specification suite: 7,513 passing, 9 existing pending.
  • Source and built CJS/ESM controls: 30 groups / 120 value checks per format; additional in-process Bowtie controls: 25 groups / 100 values.
  • Normal ESM, CJS, IIFE and declaration builds pass; integrated attw reports no problems. Changed-file lint and whitespace checks pass.
  • Full type/lint checks retain the measured clean-main baseline: 4 source-type diagnostics, 107 test-type diagnostics, and 3 unused-import lint errors. Those checks are not reported green.

Based on main 65578c185fc324ebf8fcc8f6e654e85cbfab4da8, with pnpm 10.34.5. Source/tests only. No network validation, external Docker Bowtie, load test, or release was performed.

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.

1 participant