Repository navigation
Version the schema $id so it tracks the contract, not a branch - #19
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new schema $id validation should read schema files with explicit UTF-8 encoding and fail with a clearer diagnostic instead of raising uncaught parse/key errors.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR versions JSON Schema $id values by contract major.minor so schema identities don’t implicitly track a moving branch ref, aligning schema identification with the repository’s pin-by-SHA consumption model (closes #6).
Changes:
- Updates each schema’s
$idto end with/schemas/<MAJOR.MINOR>/<filename>.schema.json(e.g.,.../schemas/0.2/...). - Documents the
$ididentity/versioning policy ingovernance/versioning.md. - Adds a validator check in
tools/validate.pyto enforce that all schema$idvalues embed the currentVERSIONmajor.minor.
File summaries
| File | Description |
|---|---|
| tools/validate.py | Enforces schema $id major.minor alignment with VERSION. |
| schemas/diagnostic.schema.json | Updates $id to the versioned identity form. |
| schemas/consumer-manifest.schema.json | Updates $id to the versioned identity form. |
| schemas/case.schema.json | Updates $id to the versioned identity form. |
| governance/versioning.md | Specifies the schema $id identity policy and how it tracks releases. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # Every schema's $id names the contract minor it belongs to (governance/versioning.md). | ||
| minor = ".".join(version.split(".")[:2]) | ||
| for schema_path in sorted((ROOT / "schemas").glob("*.schema.json")): | ||
| schema_id = json.loads(schema_path.read_text())["$id"] | ||
| if not schema_id.endswith(f"/schemas/{minor}/{schema_path.name}"): | ||
| fail(f"{schema_path.name} $id does not carry the {minor} contract minor: {schema_id}") |
c3d5bfa to
fa6e6ee
Compare
fa6e6ee to
e355eac
Compare
Each schema declared $id: .../raw/main/schemas/<name>.json. A $id is an identity, so resolving it followed main as it moved while everything else in the contract is pinned by SHA - two consumers could validate against different documents through the same identifier. The $id now ends /schemas/<MAJOR.MINOR>/<name>.schema.json and is treated as a name rather than a fetch target. governance/versioning.md records that the segment tracks the VERSION minor and moves only on a release that changes what validates. tools/validate.py checks every schema's $id against the VERSION minor.
e355eac to
b612946
Compare
Follow-up to review on PR #19. The schema $id check read each file with the platform default encoding and did `json.loads(...)["$id"]` raw, so a malformed schema or a missing $id raised a traceback instead of a validation failure. It now goes through load_json (explicit UTF-8, JSONDecodeError reported) and fails with a clear message when $id is absent or non-string.
|
Addressed in Verified: a schema with |
Closes #6.
Each schema declared
$id: https://github.com/Compliatory/MedUI/raw/main/schemas/<name>.json. A$idis an identity, so resolving it followedmainas it moved — while everything else in the contract is pinned by SHA. Two consumers validating against "the" diagnostic schema could be validating different documents.The
$idnow ends/schemas/<MAJOR.MINOR>/<name>.schema.jsonand is treated as a name, not a fetch target.governance/versioning.mdrecords that the segment tracks theVERSIONminor and moves only on a release that changes what validates;tools/validate.pychecks every schema's$idagainst theVERSIONminor.Validation:
python3 tools/validate.py→ OK.Stacked on #18.