spec: general referential-integrity gate — every $ref must resolve - #277
Merged
Conversation
334 schemas, 135 $refs, but the per-example validators only exercise schemas
that ship examples. A schema declaring a $ref to a moved/renamed/typo'd target
sails through: nothing loads it, so nothing notices the reference points at a
hole. That is declared-not-enforced at the spec's own reference layer.
validate_schema_references.py asserts, for every schemas/*.json:
1. valid JSON + structurally valid JSON Schema (Draft 2020-12 metaschema)
2. every $ref (internal #/…, relative File.json[#/…], or canonical $id URI)
resolves to a real schema AND a real pointer target inside it
Self-excluding (a self-validating checker must exclude itself): scans schemas/
only; the validator lives in tools/, never in the scanned set; its teeth are
proven every run by an inline SYNTHETIC negative control (dangling file ref,
dangling internal pointer, file+fragment, malformed schema) that never touches
schemas/. If that control fails to trip, the gate exits 2 and certifies nothing.
Also fails closed on an empty scan (won't green a scan of zero schemas).
Wired into `make validate` (which CI runs), so the whole spec now enforces its
own referential integrity going forward. First run: 334 schemas clean, all 135
$refs resolve.
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.
Closes the pending register item: make spec pointer-resolution a general validator that excludes itself.
The gap
334 schemas, ~135
$reflinks — but the per-example validators only exercise schemas that ship examples. A schema declaring a$refto a moved / renamed / mistyped target sails straight through: nothing loads it, so nothing notices the reference resolves to a hole. That is the declared-not-enforced defect at the spec's own reference layer.The gate
tools/validate_schema_references.pyasserts, for everyschemas/*.json:check_schema);$ref— internal#/…, relativeFile.json(optionally#/fragment), or canonical$idURI — resolves to a real schema and a real pointer target inside it.Self-excluding + teeth
schemas/only; the validator lives intools/, never in the scanned set.schemas/. If it fails to trip, the gate exits 2 and certifies nothing.Result
Wired into
make validate(CI runs it viavalidate-ops-history.yml), so the spec enforces its own referential integrity going forward — same shape as the moving-tag ratchet: clean today, kept clean by a gate that can actually fail.