From b612946412f3dabd55b18a4718c7a541d57081ac Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc Date: Mon, 7 Sep 2026 08:40:22 +0200 Subject: [PATCH 1/2] Version the schema $id so it tracks the contract, not a branch Each schema declared $id: .../raw/main/schemas/.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//.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. --- governance/versioning.md | 10 ++++++++++ schemas/case.schema.json | 2 +- schemas/consumer-manifest.schema.json | 2 +- schemas/diagnostic.schema.json | 2 +- tools/validate.py | 7 +++++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/governance/versioning.md b/governance/versioning.md index 76a2c83..219b543 100644 --- a/governance/versioning.md +++ b/governance/versioning.md @@ -7,6 +7,16 @@ already-defined outcome. Tags are immutable. Consumers pin the exact 40-characte A contract change is accepted only after every implementation claiming the affected capability passes the candidate commit. Capabilities are `syntax`, `semantics`, `layout`, and `safety`. +## Schema identity + +Every file in `schemas/` carries an `$id` ending `/schemas//.schema.json`. The +`$id` is an identity, not a fetch target: it names the contract revision a schema belongs to, so +two consumers that resolve "the case schema" through a pinned commit are resolving the same +document. The `` segment tracks the `VERSION` file's major and minor. A schema change +that alters what validates is at least a minor release and moves the segment with it; a patch +release leaves every `$id` untouched. Consumers still pin the commit SHA, which is what makes any +`$id` reproducible. + ## The consumer manifest A consumer records what it pins and what it claims in a `medui-conformance.toml` at its repository diff --git a/schemas/case.schema.json b/schemas/case.schema.json index 887f0d2..aa5bc46 100644 --- a/schemas/case.schema.json +++ b/schemas/case.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/Compliatory/MedUI/raw/main/schemas/case.schema.json", + "$id": "https://github.com/Compliatory/MedUI/schemas/0.2/case.schema.json", "title": "MedUI conformance case", "type": "object", "additionalProperties": false, diff --git a/schemas/consumer-manifest.schema.json b/schemas/consumer-manifest.schema.json index bdddb31..03668bb 100644 --- a/schemas/consumer-manifest.schema.json +++ b/schemas/consumer-manifest.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/Compliatory/MedUI/raw/main/schemas/consumer-manifest.schema.json", + "$id": "https://github.com/Compliatory/MedUI/schemas/0.2/consumer-manifest.schema.json", "title": "MedUI consumer manifest", "description": "The parsed structure of a consumer's medui-conformance.toml. The file on disk is TOML; this describes what a harness sees after parsing it.", "type": "object", diff --git a/schemas/diagnostic.schema.json b/schemas/diagnostic.schema.json index f0725d6..1d11d96 100644 --- a/schemas/diagnostic.schema.json +++ b/schemas/diagnostic.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/Compliatory/MedUI/raw/main/schemas/diagnostic.schema.json", + "$id": "https://github.com/Compliatory/MedUI/schemas/0.2/diagnostic.schema.json", "title": "MedUI diagnostic envelope", "type": "object", "additionalProperties": false, diff --git a/tools/validate.py b/tools/validate.py index 64e38df..cd7a3e7 100644 --- a/tools/validate.py +++ b/tools/validate.py @@ -66,6 +66,13 @@ def main() -> None: if decision_numbers != list(range(1, len(decision_numbers) + 1)): fail(f"decision identifiers are not contiguous from 001: {decision_numbers}") + # 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}") + registry_text = (ROOT / "spec/diagnostics.md").read_text(encoding="utf-8") code_phase = {code: phase for code, phase in REGISTRY_ROW.findall(registry_text)} code_list = re.findall(r"^\|\s*`(MEDUI-E[0-9]{3})`\s*\|", registry_text, flags=re.MULTILINE) From 6d6b5e7e053d979bc762f5d95244476daa9bcda3 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc Date: Mon, 7 Sep 2026 09:34:32 +0200 Subject: [PATCH 2/2] Read schema files through load_json in the $id check 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. --- tools/validate.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/validate.py b/tools/validate.py index cd7a3e7..566a800 100644 --- a/tools/validate.py +++ b/tools/validate.py @@ -69,7 +69,9 @@ def main() -> None: # 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"] + schema_id = load_json(schema_path).get("$id") + if not isinstance(schema_id, str): + fail(f"{schema_path.name} has no string $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}")