From f22f6046be46451ea3b7f56a3f36a220279037d8 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc Date: Sat, 15 Aug 2026 17:25:29 +0200 Subject: [PATCH 1/2] Declare diagnostic position precision, and correct the alias policy A case pins an exact line and column, while spec/diagnostics.md defined `0` only for an emitted diagnostic. Whether an implementation reporting an unknown position satisfies a case pinning a known one was therefore undefined, and it decides whether a line-accurate implementation can claim a phase at all. TrustSC hit this immediately: its parser is line-oriented and reports no column, so it agreed with every syntax case on acceptance, code and line while having no defined standing. Precision is now declared rather than assumed. A consumer names `positions` in its manifest and a claimed phase is checked at that precision, so a line-accurate implementation can claim a phase honestly instead of choosing between an unsupportable claim and no claim at all. The declaration is checked in both directions: reporting more position than declared fails, so precision cannot be gained or lost silently, and a wrong non-zero position fails at every precision. The consumer manifest was referenced by the README but never specified. governance/versioning.md now gives its shape and says a phase claimed at reduced precision still counts as claimed for the change-acceptance rule. The MDX-E alias policy said MduX "accepts these aliases for one release". MduX has no diagnostic input path and accepts nothing; it emits canonical identifiers and exposes the map as legacyId() for consumers still matching the old ones. The policy now describes what ships. Closes #7. --- compat/mdx-e-aliases-v0.1.json | 2 +- ...DUI-DEC-005-diagnostics-and-conformance.md | 6 ++++++ governance/versioning.md | 19 +++++++++++++++++++ spec/diagnostics.md | 18 ++++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/compat/mdx-e-aliases-v0.1.json b/compat/mdx-e-aliases-v0.1.json index 1b14031..e805014 100644 --- a/compat/mdx-e-aliases-v0.1.json +++ b/compat/mdx-e-aliases-v0.1.json @@ -1,5 +1,5 @@ { - "policy": "MduX accepts these aliases for one release; canonical output uses MEDUI-E codes.", + "policy": "Historical map for consumers still matching MduX's pre-contract MDX-E### output. Canonical output is MEDUI-E###; the numbers are unchanged, so only the namespace differs. MduX exposes the mapping as legacyId() and does not accept legacy identifiers as input.", "aliases": { "MDX-E000": "MEDUI-E000", "MDX-E001": "MEDUI-E001", "MDX-E002": "MEDUI-E002", "MDX-E003": "MEDUI-E003", "MDX-E004": "MEDUI-E004", "MDX-E010": "MEDUI-E010", diff --git a/decisions/MEDUI-DEC-005-diagnostics-and-conformance.md b/decisions/MEDUI-DEC-005-diagnostics-and-conformance.md index a528bdf..c030396 100644 --- a/decisions/MEDUI-DEC-005-diagnostics-and-conformance.md +++ b/decisions/MEDUI-DEC-005-diagnostics-and-conformance.md @@ -8,3 +8,9 @@ never changes and retired numbers are never reused. Conformance cases assert observable acceptance, diagnostics, normalized semantics, layout, or goldens. Consumers declare capabilities and must not silently skip a claimed phase. + +Position precision is declared, not assumed. A consumer names the precision it reports, and a +claimed phase is checked at that precision: a case's position is matched as far as the declaration +goes, and a diagnostic carrying more position than declared is a failure. The declaration is +checked rather than tolerated, so gaining precision is a manifest change and never a silent one. +A phase claimed at reduced precision is still claimed. diff --git a/governance/versioning.md b/governance/versioning.md index 4d21b9a..4b69b44 100644 --- a/governance/versioning.md +++ b/governance/versioning.md @@ -7,6 +7,25 @@ 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`. +## The consumer manifest + +A consumer records what it pins and what it claims in a `medui-conformance.toml` at its repository +root: + +```toml +repository = "https://github.com/Compliatory/MedUI" +version = "0.1.0-candidate" +commit = "<40-character SHA>" +capabilities = ["syntax"] +positions = "full" # or "line-only", or "none" +``` + +`positions` declares the diagnostic position precision defined by `spec/diagnostics.md`. A phase +claimed at reduced precision is still claimed, and counts for the rule above: a candidate commit +must pass every implementation claiming the affected capability, each at the precision it +declares. Precision is a property of the implementation, not of the phase, so it is declared once +rather than per capability. + Moving TrustSC or MduX into the Compliatory organization is deferred until the 1.0 milestone and appropriate open-source GitHub Copilot benefits are available. Repository ownership is not part of the language contract. diff --git a/spec/diagnostics.md b/spec/diagnostics.md index 34555ad..b080b75 100644 --- a/spec/diagnostics.md +++ b/spec/diagnostics.md @@ -4,6 +4,24 @@ The canonical finding envelope is defined by `schemas/diagnostic.schema.json`. P 1-based; `0` means unknown. Columns count UTF-8 bytes. Messages and fix hints may be reworded, but a code's meaning, severity, and phase are stable. +## Positions in conformance cases + +A case pins the position a fully position-reporting implementation must produce. A consumer +declares its own precision as `positions` in its manifest, and a case is matched against that +declaration: + +| `positions` | Reports | A case's pinned position is | +|---|---|---| +| `full` | line and column | matched exactly | +| `line-only` | line only | `line` matched exactly; `column` must be `0` | +| `none` | neither | both must be `0` | + +Reporting `0` where a case pins a non-zero value satisfies the case only at the declared +precision. Reporting a position the declaration says will not be reported is a failure, so an +implementation cannot quietly gain precision without amending its manifest — and cannot quietly +lose it either. An implementation reporting a *different* non-zero position from the one pinned +fails at every precision. + | Code | Phase | Meaning | |---|---|---| | `MEDUI-E000` | support | recipe unreadable | From c8cc45ecec2f2dfd84940b9efc17c613e691cc0d Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc Date: Sat, 15 Aug 2026 19:17:29 +0200 Subject: [PATCH 2/2] Specify the consumer manifest, and fix the position table wording Both reviewers read the position table's last column as constraining the *fixture* rather than the reported diagnostic, which would lead a harness to zero or ignore the pinned values. The column now says "Required reported position", the cells name which side each constraint applies to, and the opening paragraph states that a case always pins a full position and is never rewritten, zeroed, or adjusted for a consumer. The manifest was an example, not a specification: nothing said which keys were required, what `repository` identified, whether `version` had to agree with `commit`, or what an unknown key meant. Two harnesses could therefore accept contradictory manifests while each claimed conformance. - `repository` identifies the contract repository, never the consumer's. - `commit` alone identifies the contract. `version` is informational and never consulted, so `0.1.0-candidate` against a `VERSION` of `0.1.0` is the ordinary case rather than a mismatch to reconcile. - An unknown key is an error, so a misspelled `capabilties` fails instead of silently claiming nothing. An empty `capabilities` is an error for the same reason: a harness reading it asserts nothing while reporting success. schemas/consumer-manifest.schema.json states the constraints in machine-readable form, describing the parsed structure since the file on disk is TOML. validate.py checks the schema against the prose - required keys, unknown-key rejection, the capability set and the precision set - so the two cannot drift; each check verified to fail when mutated. --- governance/versioning.md | 23 ++++++++++++++++++++ schemas/consumer-manifest.schema.json | 31 +++++++++++++++++++++++++++ spec/diagnostics.md | 17 +++++++++------ tools/validate.py | 16 ++++++++++++++ 4 files changed, 80 insertions(+), 7 deletions(-) create mode 100644 schemas/consumer-manifest.schema.json diff --git a/governance/versioning.md b/governance/versioning.md index 4b69b44..76a2c83 100644 --- a/governance/versioning.md +++ b/governance/versioning.md @@ -13,6 +13,7 @@ A consumer records what it pins and what it claims in a `medui-conformance.toml` root: ```toml +# The MedUI contract repository being pinned - always this one, never the consumer's own. repository = "https://github.com/Compliatory/MedUI" version = "0.1.0-candidate" commit = "<40-character SHA>" @@ -20,6 +21,28 @@ capabilities = ["syntax"] positions = "full" # or "line-only", or "none" ``` +| Key | Required | Value | +|---|---|---| +| `repository` | yes | the MedUI contract repository this manifest pins. It identifies the contract, not the consumer, and is always this repository. | +| `commit` | yes | the exact 40-character lowercase hexadecimal commit SHA pinned in that repository. | +| `capabilities` | yes | a non-empty array drawn from `syntax`, `semantics`, `layout`, `safety`. | +| `positions` | yes | exactly one of `full`, `line-only`, `none`. | +| `version` | no | a human-readable label for the pinned revision. | + +`commit` alone identifies the contract. `version` is informational: it records which release a pin +was taken from and is never consulted, so a `version` that does not match the `VERSION` file at the +pinned commit is not an error — a pre-release label such as `0.1.0-candidate` against a `VERSION` +of `0.1.0` is the ordinary case. + +An unknown key is an error rather than something to ignore, so a misspelled `capabilties` fails +instead of silently claiming nothing; TOML already forbids a repeated key in one table. An empty +`capabilities` array is an error too, because a harness reading it would assert nothing while still +reporting success. + +`schemas/consumer-manifest.schema.json` states these constraints in machine-readable form. It +describes the manifest's *parsed* structure — the file on disk is TOML — so a harness can validate +against it after parsing rather than reimplementing the rules. + `positions` declares the diagnostic position precision defined by `spec/diagnostics.md`. A phase claimed at reduced precision is still claimed, and counts for the rule above: a candidate commit must pass every implementation claiming the affected capability, each at the precision it diff --git a/schemas/consumer-manifest.schema.json b/schemas/consumer-manifest.schema.json new file mode 100644 index 0000000..bdddb31 --- /dev/null +++ b/schemas/consumer-manifest.schema.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://github.com/Compliatory/MedUI/raw/main/schemas/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", + "additionalProperties": false, + "required": ["repository", "commit", "capabilities", "positions"], + "properties": { + "repository": { + "const": "https://github.com/Compliatory/MedUI", + "description": "The contract repository being pinned, not the consumer's own." + }, + "version": { + "type": "string", + "minLength": 1, + "description": "Informational label for the pinned revision. Never consulted; `commit` identifies the contract." + }, + "commit": { + "type": "string", + "pattern": "^[0-9a-f]{40}$" + }, + "capabilities": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { "enum": ["syntax", "semantics", "layout", "safety"] } + }, + "positions": { "enum": ["full", "line-only", "none"] } + } +} diff --git a/spec/diagnostics.md b/spec/diagnostics.md index b080b75..079f43c 100644 --- a/spec/diagnostics.md +++ b/spec/diagnostics.md @@ -6,15 +6,18 @@ code's meaning, severity, and phase are stable. ## Positions in conformance cases -A case pins the position a fully position-reporting implementation must produce. A consumer -declares its own precision as `positions` in its manifest, and a case is matched against that -declaration: +A case always pins a full position — both `line` and `column` — and those pinned values are the +same for every consumer. A case is never rewritten, zeroed, or otherwise adjusted to suit an +implementation. What varies is how much of that pinned position an implementation is required to +reproduce, which it declares as `positions` in its manifest. -| `positions` | Reports | A case's pinned position is | +The table below constrains the **reported** diagnostic, never the fixture: + +| `positions` | Implementation reports | Required reported position | |---|---|---| -| `full` | line and column | matched exactly | -| `line-only` | line only | `line` matched exactly; `column` must be `0` | -| `none` | neither | both must be `0` | +| `full` | line and column | `line` equals the pinned line, and `column` equals the pinned column | +| `line-only` | line only | `line` equals the pinned line, and `column` is `0` | +| `none` | neither | `line` is `0`, and `column` is `0` | Reporting `0` where a case pins a non-zero value satisfies the case only at the declared precision. Reporting a position the declaration says will not be reported is a failure, so an diff --git a/tools/validate.py b/tools/validate.py index 3808b7d..f1ad769 100644 --- a/tools/validate.py +++ b/tools/validate.py @@ -10,6 +10,8 @@ ROOT = Path(__file__).resolve().parents[1] PHASES = {"syntax", "semantics", "layout", "safety", "support"} +CAPABILITIES = ["syntax", "semantics", "layout", "safety"] +PRECISIONS = ["full", "line-only", "none"] CASE_ID = re.compile(r"MEDUI-CASE-[A-Z0-9-]+\Z") CODE = re.compile(r"MEDUI-E[0-9]{3}\Z") @@ -34,6 +36,20 @@ def main() -> None: if len(known_codes) != 22: fail(f"expected 22 registered diagnostics, found {len(known_codes)}") + # The consumer-manifest schema and governance/versioning.md state the same constraints; a + # harness reads one and a maintainer reads the other, so they are checked against each other + # rather than trusted to stay in step. + manifest_schema = json.loads((ROOT / "schemas/consumer-manifest.schema.json").read_text()) + if set(manifest_schema["required"]) != {"repository", "commit", "capabilities", "positions"}: + fail(f"consumer manifest required keys changed: {manifest_schema['required']}") + if manifest_schema["additionalProperties"] is not False: + fail("the consumer manifest must reject unknown keys") + properties = manifest_schema["properties"] + if properties["positions"]["enum"] != PRECISIONS: + fail(f"declared precisions changed: {properties['positions']['enum']}") + if properties["capabilities"]["items"]["enum"] != CAPABILITIES: + fail(f"capabilities changed: {properties['capabilities']['items']['enum']}") + aliases = json.loads((ROOT / "compat/mdx-e-aliases-v0.1.json").read_text())["aliases"] if set(aliases.values()) != known_codes: fail("MDX-E alias values must cover the canonical diagnostic registry exactly")