coordinator-wave-audit (schema 1, manual) audits the entire Ready queue on /skill: request and returns a four-section wave plan: Safe Parallel Wave 1, Contention Pairs, Resource-Affinity Batches, and Blocked/Stale. It dispatches nothing. coordinator-tracker-hygiene (schema 1, manual) classifies implicit contention edges recorded in the Working Ledger and drafts minimal prerequisite-edge or issue-comment proposals that change the tracker only after the Operator approves each one. Both target the proposed v0.17.0 release. OVERRIDING.md lists both packages in the role and package matrices and explains their seams and a manual-set assignment; the README and the contract name them alongside the automatic Coordinator packages. Refs #28 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
370 lines
22 KiB
Python
370 lines
22 KiB
Python
import json
|
|
import re
|
|
import hashlib
|
|
import shutil
|
|
import tempfile
|
|
import unittest
|
|
import zipfile
|
|
from pathlib import Path
|
|
|
|
from tools.packages import PackageError, check_package, package_archive
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
class PackageTests(unittest.TestCase):
|
|
def test_research_auto_contains_only_extracted_method(self):
|
|
package = ROOT / "packages/research-auto"
|
|
check_package(package)
|
|
text = (package / "SKILL.md").read_text()
|
|
self.assertIn("omit the option during broad exploration", text)
|
|
self.assertIn("inspect/fetch returned sources", text)
|
|
self.assertIn("Check publication date", text)
|
|
self.assertIn("Corroborate consequential", text)
|
|
self.assertNotIn("spawn", text)
|
|
self.assertNotIn("save a research file", text)
|
|
|
|
def test_communication_packages_declare_their_treatment(self):
|
|
for role in ("planner", "implementer", "reviewer", "tester", "coordinator"):
|
|
package = ROOT / f"packages/{role}-communication"
|
|
result = check_package(package)
|
|
manifest = json.loads((package / "relayview-skill.json").read_text())
|
|
self.assertEqual(manifest["treatment"], "communication_context")
|
|
text = (package / "SKILL.md").read_text()
|
|
self.assertIn("proportional", text)
|
|
self.assertIn("acknowledgement", text)
|
|
self.assertIn("Markdown", text)
|
|
|
|
def test_coordinator_packages_are_automatic_v0_17_0_coordination_guidance(self):
|
|
expected = {"coordinator-dispatch": (1, ["SKILL.md", "wave-selection.md"]),
|
|
"coordinator-communication": (3, ["SKILL.md"])}
|
|
for name, (schema, files) in expected.items():
|
|
with self.subTest(package=name):
|
|
package = ROOT / "packages" / name
|
|
check_package(package)
|
|
manifest = json.loads((package / "relayview-skill.json").read_text())
|
|
self.assertEqual(manifest["schemaVersion"], schema)
|
|
self.assertEqual((manifest["role"], manifest["step"]), ("coordinator", "coordination"))
|
|
self.assertEqual(manifest["source"], {"kind": "first-party", "reference": "v0.17.0"})
|
|
self.assertEqual([item["path"] for item in manifest["files"]], files)
|
|
frontmatter = (package / "SKILL.md").read_text().split("---", 2)[1]
|
|
self.assertNotIn("disable-model-invocation", frontmatter)
|
|
self.assertIn("relayview-version: 0.17.0", frontmatter)
|
|
size = sum((package / path).stat().st_size for path in files + ["relayview-skill.json"])
|
|
self.assertLess(size, 16 * 1024, "well under the 128 KiB package cap")
|
|
|
|
def test_coordinator_dispatch_separates_judgment_from_owner_authority(self):
|
|
package = ROOT / "packages/coordinator-dispatch"
|
|
text = (package / "SKILL.md").read_text() + (package / "wave-selection.md").read_text()
|
|
for phrase in ("Portfolio Read Model", "Lease Registry", "branch and pull-request footprints",
|
|
"schema migration", "architectural decision", "ml-server", "GPU",
|
|
"Autopilot is `Off`", "Autopilot is `On`", "safe turn boundary",
|
|
"`portfolio_conflict`", "`unique_resource_needed`", "queue reason",
|
|
"The owner grants leases", "an open prerequisite keeps it out",
|
|
"leave repository code and shell commands to the roles that own them",
|
|
"re-run the four selection steps", "while it is `On`, dispatch compatible waves again"):
|
|
self.assertIn(phrase, text)
|
|
# Nudging, reorientation and the Working Ledger are out of scope here (issue #27).
|
|
for phrase in ("nudge", "reorient", "Working Ledger"):
|
|
self.assertNotIn(phrase, text)
|
|
|
|
def test_coordinator_communication_reports_the_control_tower(self):
|
|
text = (ROOT / "packages/coordinator-communication/SKILL.md").read_text()
|
|
for phrase in ("running wave", "lease", "ml-server", "held", "contention",
|
|
"Portfolio Read Model shows as stalled",
|
|
"Review Packet inbox", "Autopilot"):
|
|
self.assertIn(phrase, text)
|
|
|
|
def test_coordinator_manual_methods_are_v0_17_0_manual_coordination_guidance(self):
|
|
for name in ("coordinator-wave-audit", "coordinator-tracker-hygiene"):
|
|
with self.subTest(package=name):
|
|
package = ROOT / "packages" / name
|
|
check_package(package)
|
|
manifest = json.loads((package / "relayview-skill.json").read_text())
|
|
self.assertEqual(manifest["schemaVersion"], 1)
|
|
self.assertEqual((manifest["role"], manifest["step"]), ("coordinator", "coordination"))
|
|
self.assertEqual(manifest["source"], {"kind": "first-party", "reference": "v0.17.0"})
|
|
self.assertEqual([item["path"] for item in manifest["files"]], ["SKILL.md"])
|
|
frontmatter = (package / "SKILL.md").read_text().split("---", 2)[1]
|
|
self.assertRegex(frontmatter, r"(?m)^disable-model-invocation: true$")
|
|
self.assertIn("relayview-version: 0.17.0", frontmatter)
|
|
size = sum((package / path).stat().st_size for path in ("SKILL.md", "relayview-skill.json"))
|
|
self.assertLess(size, 16 * 1024, "well under the 128 KiB package cap")
|
|
|
|
def test_coordinator_wave_audit_returns_a_structured_wave_plan_without_dispatching(self):
|
|
text = (ROOT / "packages/coordinator-wave-audit/SKILL.md").read_text()
|
|
for phrase in ("/skill:coordinator-wave-audit", "entire Ready queue",
|
|
"branch and pull-request footprints", "Lease Registry",
|
|
"Safe Parallel Wave 1", "Contention Pairs", "Resource-Affinity Batches",
|
|
"Blocked/Stale", "schema migration", "ml-server",
|
|
"Dispatch nothing", "an open prerequisite keeps it out",
|
|
"leave repository code and shell commands to the roles that own them"):
|
|
self.assertIn(phrase, text)
|
|
# The four sections appear in the order the Operator reads them.
|
|
order = [text.index(f"### {heading}") for heading in (
|
|
"Safe Parallel Wave 1", "Contention Pairs", "Resource-Affinity Batches", "Blocked/Stale")]
|
|
self.assertEqual(order, sorted(order))
|
|
|
|
def test_coordinator_tracker_hygiene_drafts_proposals_and_never_mutates_silently(self):
|
|
text = (ROOT / "packages/coordinator-tracker-hygiene/SKILL.md").read_text()
|
|
for phrase in ("/skill:coordinator-tracker-hygiene", "Working Ledger",
|
|
"implicit contention edges", "prerequisite edge", "issue comment",
|
|
"Operator approval", "Never change the tracker silently",
|
|
"cycle", "Already recorded", "Stale"):
|
|
self.assertIn(phrase, text)
|
|
|
|
def test_tester_release_sidecars_and_building_inspector_method(self):
|
|
expected = {
|
|
"tester-inspection": (1, None, (
|
|
"Building Inspector", "sealed candidate", "requested proof artifact",
|
|
"Verification Proof Bundle", "exact candidate", "remaining manual Operator checks",
|
|
"never edit product code", "mock", "verification_incomplete",
|
|
"behavioral_tradeoff", "unique_resource_needed", "risk summary",
|
|
)),
|
|
"tester-communication": (3, "communication_context", (
|
|
"observed behavior", "artifact", "defects found", "manual-check checklist",
|
|
)),
|
|
}
|
|
for name, (schema, treatment, phrases) in expected.items():
|
|
with self.subTest(name=name):
|
|
package = ROOT / "packages" / name
|
|
check_package(package)
|
|
manifest = json.loads((package / "relayview-skill.json").read_text())
|
|
self.assertEqual((manifest["role"], manifest["step"]), ("tester", "testing"))
|
|
self.assertEqual(manifest["schemaVersion"], schema)
|
|
self.assertEqual(manifest.get("treatment"), treatment)
|
|
self.assertEqual(manifest["source"], {"kind": "first-party", "reference": "v0.15.0"})
|
|
skill = (package / "SKILL.md").read_text()
|
|
frontmatter = skill.split("---", 2)[1]
|
|
self.assertIn("relayview-version: 0.15.0", frontmatter)
|
|
self.assertNotIn("disable-model-invocation", frontmatter)
|
|
text = "".join((package / item["path"]).read_text() for item in manifest["files"])
|
|
for phrase in phrases:
|
|
self.assertIn(phrase.lower(), text.lower())
|
|
# Owner artifact and tool schemas stay out of prose: no JSON
|
|
# objects or code fences, and no snake_case, camelCase, or
|
|
# PascalCase identifiers beyond the typed escalation reasons.
|
|
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, {"verification_incomplete", "behavioral_tradeoff", "unique_resource_needed"})
|
|
|
|
def test_automatic_review_is_only_extracted_presentation(self):
|
|
package = ROOT / "packages/code-review-auto"
|
|
check_package(package)
|
|
text = (package / "SKILL.md").read_text()
|
|
self.assertIn("path-aware, and actionable", text)
|
|
self.assertNotIn("Report both axes", text)
|
|
self.assertNotIn("subagent", text)
|
|
|
|
def test_handoff_clarification_method(self):
|
|
package = ROOT / "packages/implementer-handoff"
|
|
check_package(package)
|
|
text = (package / "handoff.md").read_text()
|
|
self.assertIn("blocked after reasonable investigation", text)
|
|
self.assertIn("scope changes require owner authority", text)
|
|
self.assertNotIn("Trace load order", text)
|
|
|
|
def test_schema_two_claim_policy_bounds(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
package = Path(directory) / "planner-scope"
|
|
shutil.copytree(ROOT / "packages/planner-scope", package)
|
|
sidecar = package / "relayview-skill.json"
|
|
original = json.loads(sidecar.read_text())
|
|
for label in (None, "status/review"):
|
|
manifest = dict(original, issueClaim={"statusLabel": label})
|
|
sidecar.write_text(json.dumps(manifest))
|
|
check_package(package)
|
|
for claim in ({}, [], {"statusLabel": "status/ready-for-agent"},
|
|
{"statusLabel": 42}, {"statusLabel": "review"},
|
|
{"statusLabel": None, "extra": True}):
|
|
with self.subTest(claim=claim):
|
|
sidecar.write_text(json.dumps(dict(original, issueClaim=claim)))
|
|
with self.assertRaises(PackageError):
|
|
check_package(package)
|
|
for role, step in (("implementer", "implementation"), ("reviewer", "review"), ("designer", "design")):
|
|
sidecar.write_text(json.dumps(dict(original, role=role, step=step)))
|
|
with self.assertRaises(PackageError):
|
|
check_package(package)
|
|
|
|
def test_planner_scope_presentation_and_claim(self):
|
|
package = ROOT / "packages/planner-scope"
|
|
check_package(package)
|
|
text = (package / "scope.md").read_text()
|
|
for phrase in ("affected files and symbols", "invariants and edge cases", "YAML-compatible Markdown", "open_questions:"):
|
|
self.assertIn(phrase, text)
|
|
self.assertNotIn("follow-up monitor", text)
|
|
manifest = json.loads((package / "relayview-skill.json").read_text())
|
|
self.assertEqual(manifest["issueClaim"], {"statusLabel": "status/in-progress"})
|
|
|
|
def test_role_investigation_packages(self):
|
|
for role, step in (("planner", "planning"), ("implementer", "implementation"), ("reviewer", "review")):
|
|
package = ROOT / "packages" / f"{role}-investigation"
|
|
check_package(package)
|
|
manifest = json.loads((package / "relayview-skill.json").read_text())
|
|
self.assertEqual((manifest["role"], manifest["step"]), (role, step))
|
|
text = (package / "SKILL.md").read_text() + (package / "investigation.md").read_text()
|
|
self.assertIn("Trace load order", text)
|
|
self.assertIn("expression pieces", text)
|
|
self.assertNotIn("disable-model-invocation: true", text)
|
|
if role != "implementer":
|
|
self.assertIn("assigned read roots", text)
|
|
for host in ("/etc/", "/usr/share/", "$HOME", "rg -n"):
|
|
self.assertNotIn(host, text)
|
|
|
|
def test_tdd_is_available_to_owner_started_implementers(self):
|
|
package = ROOT / "packages/tdd-auto"
|
|
skill = (package / "SKILL.md").read_text()
|
|
frontmatter = skill.split("---", 2)[1]
|
|
self.assertIn("name: tdd-auto", frontmatter)
|
|
self.assertNotIn("disable-model-invocation: true", frontmatter)
|
|
self.assertIn("relayview-version: 0.13.0", frontmatter)
|
|
manifest = json.loads((package / "relayview-skill.json").read_text())
|
|
self.assertEqual(manifest["source"], {"kind": "first-party", "reference": "v0.13.0"})
|
|
check_package(package)
|
|
self.assertIn("disable-model-invocation: true", (ROOT / "packages/tdd/SKILL.md").read_text())
|
|
|
|
def test_migrated_role_guidance_has_one_declared_role_step(self):
|
|
expected = {"codebase-design": ("planner", "planning"), "grill-me": ("planner", "planning"),
|
|
"grilling": ("planner", "planning"), "to-questionnaire": ("planner", "planning"),
|
|
"diagnosing-bugs": ("implementer", "implementation"),
|
|
"domain-modeling": ("implementer", "implementation"),
|
|
"migrate-to-shoehorn": ("implementer", "implementation"),
|
|
"pr": ("implementer", "implementation"), "prototype": ("implementer", "implementation"),
|
|
"scaffold-exercises": ("implementer", "implementation"),
|
|
"shared-abstraction-refactor": ("implementer", "implementation"),
|
|
"split-large-files": ("implementer", "implementation"),
|
|
"tdd": ("implementer", "implementation"),
|
|
"writing-for-agents": ("implementer", "implementation"),
|
|
"code-review": ("reviewer", "review"),
|
|
"c4-diff": ("reviewer", "review"),
|
|
"research": ("planner", "planning"),
|
|
"improve-codebase-architecture": ("planner", "planning"),
|
|
**{name: ("designer", "design") for name in (
|
|
"issue-designer-default", "specification-designer-default", "designer-wayfinder", "designer-grilling", "designer-prototype",
|
|
"designer-research", "designer-domain-modeling", "designer-triage",
|
|
"designer-to-spec", "designer-to-tickets")}}
|
|
for name, role_step in expected.items():
|
|
with self.subTest(name=name):
|
|
package = ROOT / "packages" / name
|
|
manifest = json.loads((package / "relayview-skill.json").read_text())
|
|
self.assertEqual((manifest["role"], manifest["step"]), role_step)
|
|
check_package(package)
|
|
|
|
def test_release_package_and_starter_are_valid(self):
|
|
for path in sorted((ROOT / "packages").iterdir()) + [ROOT / "examples/starter-planner"]:
|
|
check_package(path)
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
first = package_archive(path, Path(directory) / "one.zip")
|
|
second = package_archive(path, Path(directory) / "two.zip")
|
|
self.assertEqual(first, second)
|
|
|
|
def test_maintained_guidance_covers_distinct_role_steps(self):
|
|
expected = {
|
|
"planner-scope": ("planner", "planning", "scope.md", "Plan"),
|
|
"implementer-handoff": ("implementer", "implementation", "handoff.md", "documentation"),
|
|
}
|
|
for name, (role, step, resource, marker) in expected.items():
|
|
with self.subTest(name=name):
|
|
package = ROOT / "packages" / name
|
|
manifest = json.loads((package / "relayview-skill.json").read_text())
|
|
self.assertEqual((manifest["role"], manifest["step"]), (role, step))
|
|
self.assertEqual(manifest["source"], {"kind": "first-party", "reference": "v0.13.0"})
|
|
self.assertIn(resource, [item["path"] for item in manifest["files"]])
|
|
self.assertIn(marker, (package / "SKILL.md").read_text() + (package / resource).read_text())
|
|
|
|
def test_user_fork_is_distinct_under_same_role_limits(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
package = Path(directory) / "implementer-handoff"
|
|
shutil.copytree(ROOT / "packages/implementer-handoff", package)
|
|
original = check_package(package)
|
|
resource = package / "handoff.md"
|
|
resource.write_text(resource.read_text() + "\n- Prefer the team's concise PR summary format.\n")
|
|
manifest_path = package / "relayview-skill.json"
|
|
manifest = json.loads(manifest_path.read_text())
|
|
manifest["source"] = {"kind": "user", "reference": "team-fork-1"}
|
|
next(item for item in manifest["files"] if item["path"] == "handoff.md")["sha256"] = hashlib.sha256(resource.read_bytes()).hexdigest()
|
|
manifest_path.write_text(json.dumps(manifest))
|
|
self.assertNotEqual(check_package(package), original)
|
|
self.assertEqual((manifest["role"], manifest["step"]), ("implementer", "implementation"))
|
|
|
|
def test_rejects_scripts_and_undeclared_files(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
package = Path(directory) / "planner-scope"
|
|
shutil.copytree(ROOT / "packages/planner-scope", package)
|
|
(package / "helper.py").write_text("print('unsafe')\n")
|
|
with self.assertRaises(PackageError):
|
|
check_package(package)
|
|
|
|
def test_rejects_permission_expansion(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
package = Path(directory) / "planner-scope"
|
|
shutil.copytree(ROOT / "packages/planner-scope", package)
|
|
manifest = package / "relayview-skill.json"
|
|
data = json.loads(manifest.read_text())
|
|
data["tools"] = ["shell"]
|
|
manifest.write_text(json.dumps(data))
|
|
with self.assertRaises(PackageError):
|
|
check_package(package)
|
|
|
|
def test_rejects_role_mismatch(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
package = Path(directory) / "planner-scope"
|
|
shutil.copytree(ROOT / "packages/planner-scope", package)
|
|
manifest = package / "relayview-skill.json"
|
|
data = json.loads(manifest.read_text())
|
|
data["role"] = "reviewer"
|
|
manifest.write_text(json.dumps(data))
|
|
with self.assertRaises(PackageError):
|
|
check_package(package)
|
|
|
|
def test_rejects_changed_resource(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
package = Path(directory) / "planner-scope"
|
|
shutil.copytree(ROOT / "packages/planner-scope", package)
|
|
(package / "scope.md").write_text("changed\n")
|
|
with self.assertRaises(PackageError):
|
|
check_package(package)
|
|
|
|
def test_rejects_frontmatter_permission_request(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
package = Path(directory) / "planner-scope"
|
|
shutil.copytree(ROOT / "packages/planner-scope", package)
|
|
skill = package / "SKILL.md"
|
|
skill.write_text(skill.read_text().replace("metadata:\n", "tools: [shell]\nmetadata:\n"))
|
|
manifest = package / "relayview-skill.json"
|
|
data = json.loads(manifest.read_text())
|
|
next(item for item in data["files"] if item["path"] == "SKILL.md")["sha256"] = hashlib.sha256(skill.read_bytes()).hexdigest()
|
|
manifest.write_text(json.dumps(data))
|
|
with self.assertRaises(PackageError):
|
|
check_package(package)
|
|
|
|
def test_rejects_owner_incompatible_frontmatter_values(self):
|
|
for old, new in (
|
|
("metadata:\n", "disable-model-invocation: yes\nmetadata:\n"),
|
|
("description: Check assigned issue scope, neighboring work, and verification before drafting a Plan.", "description: "),
|
|
):
|
|
with self.subTest(new=new), tempfile.TemporaryDirectory() as directory:
|
|
package = Path(directory) / "planner-scope"
|
|
shutil.copytree(ROOT / "packages/planner-scope", package)
|
|
skill = package / "SKILL.md"
|
|
skill.write_text(skill.read_text().replace(old, new))
|
|
manifest = package / "relayview-skill.json"
|
|
data = json.loads(manifest.read_text())
|
|
next(item for item in data["files"] if item["path"] == "SKILL.md")["sha256"] = hashlib.sha256(skill.read_bytes()).hexdigest()
|
|
manifest.write_text(json.dumps(data))
|
|
with self.assertRaises(PackageError):
|
|
check_package(package)
|
|
|
|
def test_archive_carries_license_and_notice(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
archive_path = Path(directory) / "planner-scope.zip"
|
|
package_archive(ROOT / "packages/planner-scope", archive_path)
|
|
with zipfile.ZipFile(archive_path) as archive:
|
|
self.assertEqual(archive.read("LICENSE"), (ROOT / "LICENSE").read_bytes())
|
|
self.assertEqual(archive.read("NOTICE.md"), (ROOT / "NOTICE.md").read_bytes())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|