MAS-WP-0005-T07: v0.2 draft bundle; mas_core accepts v0.1 and v0.2 statutes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 252470@bnt-lap001
Assistant-Session: ad628c8f-4be2-4979-94c9-76c7ed6f8241
This commit is contained in:
tegwick 2026-10-18 22:19:34 +02:00
parent 3709fbb54b
commit a12e1c4370
17 changed files with 1814 additions and 20 deletions

View file

@ -59,7 +59,7 @@ def test_no_parent_walk():
({U: OSError("connection refused")}, FailureKind.TransportFailure),
({U: ok(GS, "text/html")}, FailureKind.InvalidContentType),
({U: Response(200, JSON, b"{not json")}, FailureKind.NotJson),
({U: ok({**GS, "mas_version": "0.2"})}, FailureKind.UnsupportedVersion),
({U: ok({**GS, "mas_version": "0.3"})}, FailureKind.UnsupportedVersion),
({U: ok({**GS, "profiles": {"p1": True}})}, FailureKind.SchemaInvalid),
({U: ok(statute_document("semantic-p2-disabled-modes.json"))}, FailureKind.SemanticInvalid),
({U: ok({**GS, "namespace": "other.example"})}, FailureKind.NamespaceMismatch),

View file

@ -132,3 +132,9 @@ def test_received_quoted_non_mas_stays_invalid(raw):
def test_canonical_parser_still_rejects_quotes():
with pytest.raises(MasSyntaxError):
parse_address('"ticket=PR42"@example.com')
def test_vendored_v02_schema_matches_draft_bundle():
a = (ROOT / "mas-v0.2-spec/schema/mas-statute-v0.2.schema.json").read_bytes()
b = (ROOT / "mas_core/schema/mas-statute-v0.2.schema.json").read_bytes()
assert a == b

View file

@ -87,3 +87,26 @@ def test_intake_for_lint():
assert "intake-unknown-type" not in _with_address({"kind": "function", "intake_for": "ticket"})
assert _with_address({"kind": "function", "intake_for": "invoice"})["intake-unknown-type"] == ERROR
assert _with_address({"kind": "group", "intake_for": "ticket"})["intake-not-function"] == ERROR
def _v02(**extra):
doc = statute_document("valid-great-service.json")
doc["mas_version"] = "0.2"
doc.update(extra)
return doc
def test_v02_statute_builds_with_new_fields():
doc = _v02(alternate_syntax={"resource": True, "interaction": True})
doc["equivalence"]["resource_id_case"] = "insensitive"
st = build_statute(doc, "great-service.example")
assert (st.mas_version, st.alt_resource, st.alt_interaction, st.resource_id_case) == \
("0.2", True, True, "insensitive")
plain = build_statute(_v02(), "great-service.example")
assert (plain.alt_resource, plain.alt_interaction, plain.resource_id_case) == (False, False, "exact")
def test_v01_statute_rejects_v02_fields():
doc = statute_document("valid-great-service.json")
doc["alternate_syntax"] = {"resource": True}
assert any(f.severity == ERROR and f.layer == "schema" for f in lint(doc, "great-service.example"))