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..76a2c83 100644 --- a/governance/versioning.md +++ b/governance/versioning.md @@ -7,6 +7,48 @@ 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 +# 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>" +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 +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/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 34555ad..079f43c 100644 --- a/spec/diagnostics.md +++ b/spec/diagnostics.md @@ -4,6 +4,27 @@ 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 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. + +The table below constrains the **reported** diagnostic, never the fixture: + +| `positions` | Implementation reports | Required reported position | +|---|---|---| +| `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 +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 | 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")