Apply GH-DEC-2026-020: checker prints version and scope, A12 r2 by content.
The layer conformance checker now prints VALIDATED_AGAINST and SCOPE on every run, including the PASS line (kings-guard pattern), and enforces A12 r2 over every key and value of INTENT.md frontmatter and layer.yaml: a versioned standard: path and a companion_version are caught, schema_version and comments are not reached, pep-stance.yaml is outside the run. Tests guard both returns. The playbook carries the adopter change set and confirms the section 5 citation is canonical. WARDEN-WP-0034's open 4220413a note is closed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: opus Assistant-Process: 63291@bnt-lap001 Assistant-Session: 8bd77868-ca68-4f49-bb1e-d539ecc0d703
This commit is contained in:
parent
b9151e20da
commit
c23918d6ec
4 changed files with 191 additions and 18 deletions
|
|
@ -32,6 +32,17 @@ def _intent_frontmatter() -> dict:
|
|||
return yaml.safe_load("\n".join(lines[1:end]))
|
||||
|
||||
|
||||
def _checker():
|
||||
import importlib.util
|
||||
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
"check_layer_conformance", ROOT / "scripts" / "check_layer_conformance.py"
|
||||
)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
def _fold(value: str) -> str:
|
||||
return str(value).strip().encode("ascii", "ignore").decode().lower()
|
||||
|
||||
|
|
@ -81,6 +92,51 @@ class TestDeclaration:
|
|||
assert "standard_version" not in _decl()
|
||||
assert "standard_version" not in _intent_frontmatter()
|
||||
|
||||
def test_no_version_anywhere_in_either_declaration(self):
|
||||
"""A12 r2 / GH-DEC-2026-020 §1-§2: content, not a key name.
|
||||
|
||||
A versioned `standard:` path or a `companion_version` is the same pin as
|
||||
`standard_version`, so the guard walks every key and value of both forms.
|
||||
"""
|
||||
checker = _checker()
|
||||
assert checker.find_version_pins(_intent_frontmatter()) == []
|
||||
assert checker.find_version_pins(_decl()) == []
|
||||
assert not str(_intent_frontmatter()["standard"]).endswith(".md")
|
||||
|
||||
def test_checker_catches_a_versioned_standard_path(self):
|
||||
checker = _checker()
|
||||
pins = checker.find_version_pins(
|
||||
{"layer": "Staff", "standard": "net-kingdom/canon/standards/security-layer-model_v0.7.md"}
|
||||
)
|
||||
assert pins and pins[0].startswith("standard")
|
||||
|
||||
def test_checker_catches_a_companion_version(self):
|
||||
checker = _checker()
|
||||
assert checker.find_version_pins({"layer": "Staff", "companion_version": "0.2"})
|
||||
assert checker.find_version_pins({"nested": {"standard_version": "0.7"}})
|
||||
|
||||
def test_schema_version_is_not_reached(self):
|
||||
assert _checker().find_version_pins({"schema_version": "0.2", "layer": "Staff"}) == []
|
||||
|
||||
def test_stance_map_is_outside_the_run(self):
|
||||
"""GH-DEC-2026-020 §3: a stance map keeps its version; the run must not read it."""
|
||||
stance = yaml.safe_load((ROOT / "pep-stance.yaml").read_text())
|
||||
assert "standard_version" in stance, "pep-stance.yaml keeps its clause-scoped version"
|
||||
assert "pep-stance" not in _checker().SCOPE
|
||||
|
||||
def test_every_run_states_version_and_scope(self):
|
||||
"""GH-DEC-2026-020 §4: the version belongs to the run, printed every time."""
|
||||
checker = _checker()
|
||||
out = subprocess.run(
|
||||
[sys.executable, str(ROOT / "scripts" / "check_layer_conformance.py")],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
).stdout
|
||||
assert f"validated against: {checker.VALIDATED_AGAINST}" in out
|
||||
assert f"scope: {checker.SCOPE}" in out
|
||||
pass_line = next(ln for ln in out.splitlines() if ln.startswith("PASS"))
|
||||
assert checker.VALIDATED_AGAINST in pass_line
|
||||
|
||||
def test_every_tooling_contact_maps_to_a_declared_shape(self):
|
||||
"""§11 mechanical check — the guard against a new undeclared client."""
|
||||
result = subprocess.run(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue