"""Pin the v0.16.0 Implementer guidance: tight inner-loop convergence on fast checks before sealing, and indirect escalation through the Planner.""" import re import unittest from tests.test_planner_reviewer import DIRECT_REASONS, IMPLEMENTER_FLAGS, ROOT, VERSION, read from tools.packages import check_package # name: (schema, sidecar extra, declared files) PACKAGES = { "implementer-handoff": (1, {}, ["SKILL.md", "handoff.md"]), "implementer-communication": (3, {"treatment": "communication_context"}, ["SKILL.md"]), } class ImplementerReleaseTests(unittest.TestCase): def test_packages_release_with_planner_and_reviewer_and_keep_their_schemas(self): for name, (schema, extra, files) in PACKAGES.items(): with self.subTest(package=name): check_package(ROOT / "packages" / name) manifest, frontmatter, _ = read(name) self.assertEqual(manifest["source"], {"kind": "first-party", "reference": f"v{VERSION}"}) self.assertEqual((manifest["role"], manifest["step"], manifest["schemaVersion"]), ("implementer", "implementation", schema)) for key, value in extra.items(): self.assertEqual(manifest[key], value) self.assertEqual([item["path"] for item in manifest["files"]], files) self.assertIn(f"relayview-version: {VERSION}", frontmatter) self.assertNotIn("disable-model-invocation", frontmatter) def test_prose_stays_out_of_owner_report_and_flag_schemas(self): # No JSON objects or code fences, and no snake_case, camelCase, or # PascalCase identifiers beyond the two flag names and the existing # documentation disposition value. for name in PACKAGES: with self.subTest(package=name): text = read(name)[2] self.assertNotIn("```", text) self.assertNotIn("{", text) identifiers = set(re.findall(r"\b\w+_\w+\b|\b[a-z]+[A-Z]\w*\b|\b[A-Z][a-z]+[A-Z]\w*\b", text)) self.assertLessEqual(identifiers, set(IMPLEMENTER_FLAGS) | {"not_required"}) def test_packages_use_specification_designer_terminology(self): for name in PACKAGES: with self.subTest(package=name): self.assertNotRegex(read(name)[2], r"(?i)issue designer") class InnerLoopTests(unittest.TestCase): def setUp(self): self.text = read("implementer-handoff")[2] def test_converges_fast_checks_before_sealing(self): for phrase in ("fast check", "seconds, not minutes", "types, lint, static analysis", "unit and integration tests", "Plan", "Planner feedback", "before sealing", "Building Inspector", "until they pass", "the exact candidate you seal"): with self.subTest(phrase=phrase): self.assertIn(phrase.lower(), self.text.lower()) def test_does_not_seal_a_failing_candidate_as_ready(self): # A fast check that cannot pass is reported, never presented as ready. self.assertIn("A command attempted is not a check passed", self.text) self.assertIn("do not present the candidate as ready", self.text) def test_reports_test_resource_readiness_and_known_gaps(self): for phrase in ("declared test resource", "readiness", "known gap", "verification goal", "remaining manual Operator check"): with self.subTest(phrase=phrase): self.assertIn(phrase.lower(), self.text.lower()) def test_keeps_existing_clarification_method(self): handoff = (ROOT / "packages/implementer-handoff/handoff.md").read_text() self.assertIn("blocked after reasonable investigation", handoff) self.assertIn("scope changes require owner authority", handoff) class IndirectEscalationTests(unittest.TestCase): def setUp(self): self.text = read("implementer-handoff")[2] def test_flags_go_to_the_planner_not_the_operator(self): for flag in IMPLEMENTER_FLAGS: with self.subTest(flag=flag): self.assertIn(f"`{flag}`", self.text) for phrase in ("to the Planner", "Do not page the Operator", "silently improvise", "genuine specification ambiguity", "unexpected sensitive boundary", "scope creep", "just to be safe", "flag interface the owner assigns", "Where none is assigned"): with self.subTest(phrase=phrase): self.assertIn(phrase, self.text) def test_implementer_never_escalates_directly(self): # Typed Layer C reasons belong to the Planner, Reviewer, and Tester; the # Implementer only flags, so no direct reason appears in its packages. for name in PACKAGES: text = read(name)[2] for reason in DIRECT_REASONS: with self.subTest(package=name, reason=reason): self.assertNotIn(reason, text) class CommunicationTests(unittest.TestCase): def test_communication_frames_handoffs_and_flags(self): text = read("implementer-communication")[2] for phrase in ("Specification Designer", "fast check", "candidate", "known gap", "`needs_operator_decision`", "`scope_exceeded`", "Planner", "options", "evidence", "meanwhile", "proportional", "acknowledgement", "Markdown"): with self.subTest(phrase=phrase): self.assertIn(phrase, text) class ReleaseNotesTests(unittest.TestCase): def test_release_notes_give_before_and_after_for_each_package(self): notes = (ROOT / "RELEASE-NOTES.md").read_text() match = re.search(rf"^## v{re.escape(VERSION)}\b.*?(?=^## |\Z)", notes, re.M | re.S) self.assertIsNotNone(match, "no v0.16.0 section") for name in PACKAGES: with self.subTest(package=name): entry = re.search(rf"^### `{name}`\n.*?(?=^### |\Z)", match.group(0), re.M | re.S) self.assertIsNotNone(entry, f"no entry for {name}") self.assertIn("**Before (0.13.0):**", entry.group(0)) self.assertIn("**After:**", entry.group(0)) self.assertIn("**Fork:**", entry.group(0)) def test_overriding_names_the_implementer_seams(self): text = (ROOT / "OVERRIDING.md").read_text() match = re.search(r"^### Implementer inner-loop and flag packages\n.*?(?=^##)", text, re.M | re.S) self.assertIsNotNone(match, "no Implementer section in OVERRIDING.md") for phrase in ("`implementer-handoff`", "`handoff.md`", "`implementer-communication`", "`needs_operator_decision`", "`scope_exceeded`", "(RELEASE-NOTES.md)"): with self.subTest(phrase=phrase): self.assertIn(phrase, match.group(0)) if __name__ == "__main__": unittest.main()