Apply GH-DEC-2026-020 to the layer conformance checker

The checker now prints VALIDATED_AGAINST and its scope on every run,
including the OK line (kings-guard pattern). A12 detection widens from
the key name standard_version to every key and value of INTENT.md
frontmatter and layer.yaml: versioned standard:/companion: paths,
companion_version, and any *_version key except schema_version.
Comments and non-declaration files are not reached. Declaration
unchanged; gate-house confirmed it conforms.

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:
tegwick 2026-09-21 09:37:24 +02:00
parent cd54d8e716
commit 9fd05d09fe
2 changed files with 147 additions and 12 deletions

View file

@ -1,3 +1,5 @@
import contextlib
import io
from pathlib import Path
from tempfile import TemporaryDirectory
import unittest
@ -66,6 +68,25 @@ class LayerDeclarationTest(unittest.TestCase):
self.assertNotIn("standard_version", decl)
self.assertNotIn("standard_version", layer.load_intent())
def test_no_version_anywhere_in_either_form(self):
"""GH-DEC-2026-020 / A12 r2: no version in any key or value, not only the key name."""
decl = yaml.safe_load(layer.DECL.read_text())
self.assertEqual(layer.declaration_versions(decl), [])
self.assertEqual(layer.declaration_versions(layer.load_intent()), [])
self.assertNotIn("companion_version", decl)
self.assertNotIn("companion_version", layer.load_intent())
def test_every_run_prints_version_and_scope(self):
"""GH-DEC-2026-020 §4: the version lives in the run, including the OK line."""
out = io.StringIO()
with contextlib.redirect_stdout(out):
self.assertEqual(layer.main([]), 0)
text = out.getvalue()
self.assertIn(f"validated against: {layer.VALIDATED_AGAINST}", text)
self.assertIn(f"scope: {layer.SCOPE}", text)
ok = [line for line in text.splitlines() if line.startswith("OK:")]
self.assertTrue(ok and layer.VALIDATED_AGAINST in ok[0])
def test_vocabulary_is_the_closed_four_tokens(self):
self.assertEqual(layer.LAYER_VOCABULARY, {"taxonomy", "tooling", "engine", "staff"})
@ -158,3 +179,52 @@ class LayerCheckerFailureTest(unittest.TestCase):
joined = "\n".join(errors)
self.assertIn("fastapi", joined)
self.assertIn("/v1/check", joined)
def test_versioned_standard_path_is_exit_2(self):
with TemporaryDirectory() as directory:
root = Path(directory)
_write_tree(root, intent=INTENT.replace(
"standard: netkingdom-security-layer-model",
"standard: net-kingdom/canon/standards/security-layer-model_v0.7.md",
))
code, errors, _ = layer.evaluate(root=root)
self.assertEqual(code, 2)
self.assertTrue(any("standard" in item and "v0.7" in item for item in errors))
def test_companion_version_is_exit_2(self):
for decl, intent in (
({**DECL, "companion_version": "0.2"}, INTENT),
(DECL, INTENT.replace("role: PIP\n", 'role: PIP\ncompanion_version: "0.2"\n')),
(DECL, INTENT.replace("role: PIP\n", "role: PIP\ncompanion: net-kingdom/SECURITY-COMPANION.md v0.2\n")),
):
with TemporaryDirectory() as directory:
root = Path(directory)
_write_tree(root, decl=decl, intent=intent)
code, errors, _ = layer.evaluate(root=root)
self.assertEqual(code, 2, errors)
def test_versioned_path_nested_in_layer_yaml_is_exit_2(self):
with TemporaryDirectory() as directory:
root = Path(directory)
_write_tree(root, decl={**DECL, "catalog_entry": {"source": "canon/standards/security-layer-model_v0.8.md"}})
code, errors, _ = layer.evaluate(root=root)
self.assertEqual(code, 2)
def test_schema_version_and_comments_are_not_reached(self):
with TemporaryDirectory() as directory:
root = Path(directory)
_write_tree(root, decl={**DECL, "schema_version": "0.1"})
path = root / "layer.yaml"
path.write_text("# Framework: security-layer-model_v0.7.md\n" + path.read_text())
code, errors, _ = layer.evaluate(root=root)
self.assertEqual(code, 0, errors)
def test_non_declaration_files_are_not_read(self):
"""GH-DEC-2026-020 §3: stance/claims/classification maps keep their versions."""
with TemporaryDirectory() as directory:
root = Path(directory)
_write_tree(root)
(root / "pep-stance.yaml").write_text('standard_version: "0.7"\n')
(root / "pip-claims.yaml").write_text('standard_version: "0.7"\n')
code, errors, _ = layer.evaluate(root=root)
self.assertEqual(code, 0, errors)