Files
relayview-skills/tests/test_feature_map.py
T

323 lines
18 KiB
Python
Raw Normal View History

"""Pin the v0.18.0 Feature Map verification guidance: mapped inner-loop checks
for the Implementer, Feature Map-driven inspection and coverage for the Tester,
and the manual outer-loop release verification method for the Coordinator."""
import json
import re
import unittest
from tests.test_overriding import section as guide_section, table_rows
from tests.test_planner_reviewer import DIRECT_REASONS, IMPLEMENTER_FLAGS, ROOT, read
from tools.packages import check_package
VERSION = "0.18.0"
TESTER_REASONS = ("verification_incomplete", "behavioral_tradeoff", "unique_resource_needed")
# name: (role, step, schema, manual, declared files, previous version or None for a new package)
PACKAGES = {
"implementer-handoff": ("implementer", "implementation", 1, False, ["SKILL.md", "handoff.md"], "0.16.0"),
"tester-inspection": ("tester", "testing", 1, False, ["SKILL.md", "inspection.md"], "0.15.0"),
"coordinator-release-verify": ("coordinator", "coordination", 1, True, ["SKILL.md"], None),
}
IDENTIFIER = r"\b\w+_\w+\b|\b[a-z]+[A-Z]\w*\b|\b[A-Z][a-z]+[A-Z]\w*\b"
def text_of(name, path):
return (ROOT / "packages" / name / path).read_text()
class ReleaseTests(unittest.TestCase):
def test_packages_move_to_v0_18_0_with_their_schemas(self):
for name, (role, step, schema, manual, 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"]), (role, step, schema))
self.assertEqual(set(manifest), {"schemaVersion", "source", "role", "step", "files"})
self.assertEqual([item["path"] for item in manifest["files"]], files)
self.assertIn(f"relayview-version: {VERSION}", frontmatter)
self.assertEqual(bool(re.search(r"(?m)^disable-model-invocation: true$", frontmatter)), manual)
self.assertRegex(frontmatter, r"(?i)feature map")
def test_prose_stays_out_of_owner_schemas(self):
# No JSON objects or code fences, and no snake_case, camelCase, or
# PascalCase identifiers beyond each role's existing vocabulary: the
# Feature Map's own schema belongs to the owner, not to the prose.
allowed = {
"implementer-handoff": set(IMPLEMENTER_FLAGS) | {"not_required"},
"tester-inspection": set(TESTER_REASONS),
"coordinator-release-verify": set(),
}
for name, names in allowed.items():
with self.subTest(package=name):
text = read(name)[2]
self.assertNotIn("```", text)
self.assertNotIn("{", text)
self.assertLessEqual(set(re.findall(IDENTIFIER, text)), names)
def test_feature_map_guidance_falls_back_when_the_repository_has_none(self):
for name in PACKAGES:
with self.subTest(package=name):
text = read(name)[2]
self.assertIn("Feature Map", text)
self.assertIn("Verification Driver", text)
self.assertRegex(text, r"has no Feature Map")
self.assertNotRegex(text, r"(?i)issue designer")
def test_no_throwaway_verification_scripts(self):
for name in PACKAGES:
with self.subTest(package=name):
self.assertIn("throwaway", read(name)[2])
class ImplementerFeatureMapTests(unittest.TestCase):
def setUp(self):
self.handoff = text_of("implementer-handoff", "handoff.md")
self.skill = text_of("implementer-handoff", "SKILL.md")
def test_maps_modified_paths_and_runs_mapped_checks_in_the_inner_loop(self):
for phrase in ("modified path", "owning paths", "Feature Map entr", "mapped fast checks",
"Verification Driver", "after each change", "exact candidate", "before sealing"):
with self.subTest(phrase=phrase):
self.assertIn(phrase, self.handoff)
def test_reports_feature_map_coverage_and_unmapped_paths(self):
review = self.handoff[self.handoff.index("## Review content"):]
for phrase in ("Feature Map coverage", "unmapped", "not run"):
with self.subTest(phrase=phrase):
self.assertIn(phrase, review)
def test_prefers_the_owners_path_mapping(self):
self.assertIn("When the owner reports the entries a change touches, use its mapping", self.handoff)
def test_does_not_edit_the_feature_map_outside_the_plan(self):
self.assertIn("Change the Feature Map only when the Plan", self.handoff)
def test_runtime_driver_checks_needing_a_missing_resource_go_to_the_inspector(self):
self.assertIn("leave it to the Building Inspector", self.handoff)
def test_the_handoff_guide_still_owns_the_rules(self):
for rule in ("owning paths", "mapped fast checks", "Feature Map coverage"):
with self.subTest(rule=rule):
self.assertIn(rule, self.handoff)
self.assertNotIn(rule, self.skill)
self.assertIn("Feature Map", self.skill)
def test_implementer_still_never_escalates_directly(self):
text = read("implementer-handoff")[2]
for reason in DIRECT_REASONS:
with self.subTest(reason=reason):
self.assertNotIn(reason, text)
class TesterFeatureMapTests(unittest.TestCase):
def setUp(self):
self.method = text_of("tester-inspection", "inspection.md")
self.text = read("tester-inspection")[2]
def test_drives_inspection_through_feature_map_entries_and_the_driver(self):
for phrase in ("Feature Map entr", "entrypoint", "Verification Driver", "multimodal",
"screenshot", "recording"):
with self.subTest(phrase=phrase):
self.assertIn(phrase, self.text)
def test_verifies_independently_of_the_implementer(self):
self.assertIn("Run every check yourself on the sealed candidate", self.method)
self.assertIn("exit status alone is not an observation", self.method)
def test_bundle_reports_exact_feature_map_coverage_beside_manual_checks(self):
bundle = self.method[self.method.index("## Assemble the Verification Proof Bundle"):
self.method.index("## Escalate with a typed reason")]
for phrase in ("**Feature Map coverage:**", "exercised", "not exercised",
"remaining manual Operator check", "Feature Map gap"):
with self.subTest(phrase=phrase):
self.assertIn(phrase, bundle)
self.assertLess(bundle.index("**Feature Map coverage:**"), bundle.index("**Remaining manual Operator checks:**"))
def test_completion_requires_feature_map_coverage(self):
skill = text_of("tester-inspection", "SKILL.md")
self.assertIn("Feature Map coverage is reported or the missing map is named", skill)
def test_never_edits_the_feature_map_or_driver(self):
self.assertIn("never edit the Feature Map or the Verification Driver", self.text)
def test_keeps_the_building_inspector_method(self):
for phrase in ("Building Inspector", "never substitute a mock", "Verification Proof Bundle",
"verified runtime observations", *TESTER_REASONS):
with self.subTest(phrase=phrase):
self.assertIn(phrase.lower(), self.text.lower())
class ReleaseVerifyTests(unittest.TestCase):
def setUp(self):
self.text = text_of("coordinator-release-verify", "SKILL.md")
def test_is_a_manual_coordinator_method(self):
for phrase in ("/skill:coordinator-release-verify", "release", "merge", "the Operator"):
with self.subTest(phrase=phrase):
self.assertIn(phrase, self.text)
def test_runs_are_bounded_isolated_and_launched_through_the_owner(self):
for phrase in ("exact revision", "bound", "budget", "isolat", "never mutate",
"owner's release verification command", "Lease Registry",
"exploratory", "property", "seed",
"leave repository code and shell commands to the roles that own them"):
with self.subTest(phrase=phrase):
self.assertIn(phrase, self.text)
# Without an owner command, the method proposes a run plan instead of improvising.
self.assertIn("no release verification command is assigned", self.text)
def test_drafts_repro_backed_candidate_bug_specifications(self):
for phrase in ("candidate bug draft", "Specification Designer", "reproduce", "repro steps",
"expected", "observed", "logs", "screenshots", "recordings",
"Feature Map entry", "duplicate"):
with self.subTest(phrase=phrase):
self.assertIn(phrase.lower(), self.text.lower())
# A defect is drafted only when it reproduced; a one-off failure is reported apart.
self.assertIn("Draft a defect only when it reproduced", self.text)
def test_launches_nothing_without_a_scope_or_an_approved_budget(self):
# No Feature Map and no named flows leaves nothing to verify; a budget
# the Coordinator proposes itself needs the Operator's approval first.
self.assertIn("When the repository has no Feature Map and the Operator named no flows", self.text)
self.assertIn("launch only after the Operator approves it", self.text)
self.assertNotIn("propose a modest one in the plan and say so", self.text)
def test_handles_missing_or_stale_projections_and_queued_leases(self):
for phrase in ("When a projection is missing or stale",
"When the owner reports the entries changed since the previous release, use its list",
"the lease is still queued when the budget's time runs out"):
with self.subTest(phrase=phrase):
self.assertIn(phrase, self.text)
def test_never_files_or_changes_the_tracker(self):
for phrase in ("File no issue", "change no issue"):
with self.subTest(phrase=phrase):
self.assertIn(phrase, self.text)
# A match with an open issue is reported for the Operator, never written to it.
self.assertNotIn("add its evidence to that item", self.text)
self.assertIn("name the matching issue or Review Packet in the draft", self.text)
self.assertNotIn("so a known defect is not drafted again", self.text)
def test_orders_unchanged_entries_without_inventing_verification_times(self):
self.assertIn("When the owner reports when each entry was last verified", self.text)
def test_every_no_launch_path_reports_not_run(self):
# "None" means a section was covered; a run that never launched must not read that way.
report = self.text[self.text.index("## Return the report"):]
self.assertIn("When nothing launched, for any reason, write \"Not run\"", report)
# No no-launch path routes its reason anywhere but the Run Summary.
self.assertIn("If the lease is still queued when the budget's time runs out, launch nothing and give "
"the queue reason in Run Summary", self.text)
self.assertNotIn("launch nothing and report it under Coverage Gaps", self.text)
# A missing Feature Map projection is not evidence that the repository has no map.
self.assertIn("A missing Feature Map projection does not mean the repository has no Feature Map", self.text)
def test_returns_its_sections_in_order(self):
headings = ("Run Summary", "Candidate Bug Drafts", "Unconfirmed Signals", "Coverage Gaps")
order = [self.text.index(f"### {heading}") for heading in headings]
self.assertEqual(order, sorted(order))
self.assertIn("Check before finishing", self.text)
def test_stays_independent_of_other_coordinator_packages(self):
for phrase in ("coordinator-dispatch", "coordinator-recovery", "wave-selection",
"`portfolio_conflict`", "Coordinator Working Ledger"):
with self.subTest(phrase=phrase):
self.assertNotIn(phrase, self.text)
class DocumentationTests(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.18.0 section")
for name, (*_, previous) in PACKAGES.items():
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}")
before = f"**Before ({previous}):**" if previous else "**Before:** no package"
self.assertIn(before, entry.group(0))
self.assertIn("**After:**", entry.group(0))
self.assertIn("**Fork:**", entry.group(0))
def test_overriding_names_the_feature_map_seams(self):
text = (ROOT / "OVERRIDING.md").read_text()
match = re.search(r"^### Feature Map verification packages\n.*?(?=^##)", text, re.M | re.S)
self.assertIsNotNone(match, "no Feature Map section in OVERRIDING.md")
for phrase in ("`implementer-handoff`", "`handoff.md`", "`tester-inspection`", "`inspection.md`",
"`coordinator-release-verify`", "`/skill:coordinator-release-verify`",
"(RELEASE-NOTES.md)", "Feature Map coverage", "candidate bug draft"):
with self.subTest(phrase=phrase):
self.assertIn(phrase, " ".join(match.group(0).split()))
def test_docs_do_not_claim_an_earlier_release_for_the_new_package(self):
# coordinator-release-verify is new: it has no earlier release or
# behavior to fall back to, and RelayView admits no Tester or
# Coordinator package yet.
overriding = (ROOT / "OVERRIDING.md").read_text()
section = " ".join(re.search(r"^### Feature Map verification packages\n.*?(?=^##)",
overriding, re.M | re.S).group(0).split())
notes = (ROOT / "RELEASE-NOTES.md").read_text()
notes = " ".join(notes[notes.index("## v0.18.0"):notes.index("### `implementer-handoff`")].split())
readme = " ".join((ROOT / "README.md").read_text().split())
for name, text in (("OVERRIDING.md", section), ("RELEASE-NOTES.md", notes), ("README.md", readme)):
with self.subTest(document=name):
self.assertNotIn("each falls back to its earlier behavior", text.lower())
self.assertNotIn("Each falls back to its earlier behavior", text)
self.assertNotIn("it uses the earlier releases of these packages", section)
# The package list describes each package in full; the no-map fallback follows it.
self.assertIn("Each package forks independently:", section)
# Without a Feature Map the updated packages still report its absence,
# so "earlier behavior" would overstate the fallback.
for name, text in (("OVERRIDING.md", section), ("RELEASE-NOTES.md", notes), ("README.md", readme)):
with self.subTest(document=name):
self.assertNotIn("keep their earlier behavior", text)
self.assertIn("keep their earlier checks", text)
self.assertIn("assigns to the Implementer", section)
def test_added_release_notes_lines_stay_wrapped(self):
notes = (ROOT / "RELEASE-NOTES.md").read_text()
section = notes[notes.index("## v0.18.0"):notes.index("## v0.16.0")]
for line in section.splitlines():
with self.subTest(line=line[:40]):
self.assertLessEqual(len(line), 80)
self.assertIn("Whenever nothing launches, for any reason", " ".join(section.split()))
def test_readme_paragraph_stands_alone(self):
readme = (ROOT / "README.md").read_text()
start = readme.index("The not-yet-tagged v0.18.0 release")
self.assertEqual(readme[start - 2:start], "\n\n")
self.assertNotEqual(readme[start - 3], "\n")
end = readme.index("\n", start)
self.assertEqual(readme[end:end + 2], "\n\n")
def test_overriding_records_the_proposed_owner_boundary(self):
rows = [row for row in table_rows(guide_section((ROOT / "OVERRIDING.md").read_text(),
"What a skill controls and what the owner enforces"))
if row[0] == "Feature Map verification"]
self.assertEqual(len(rows), 1)
self.assertEqual(rows[0][3], "Proposed")
for phrase in ("Feature Map", "Verification Driver", "isolation", "bug draft"):
with self.subTest(phrase=phrase):
self.assertIn(phrase, rows[0][1] + rows[0][2])
def test_coordinator_customization_lists_release_verification(self):
text = " ".join(guide_section((ROOT / "OVERRIDING.md").read_text(),
"Customize the Technical Coordinator").split())
self.assertIn("`coordinator-release-verify`", text)
def test_contract_and_readme_name_the_v0_18_0_release(self):
contract = (ROOT / "docs/authoritative/instruction-package-contract.md").read_text()
adoption = guide_section(contract, "RelayView adoption of the Tester and Coordinator pairs")
self.assertIn("`v0.18.0`, proposed", adoption)
self.assertIn("`coordinator-release-verify`", adoption)
readme = (ROOT / "README.md").read_text()
for name in PACKAGES:
with self.subTest(package=name):
self.assertIn(f"`{name}`", readme[readme.index("v0.18.0"):])
if __name__ == "__main__":
unittest.main()