Publish the Operator role-skill override guide
Add OVERRIDING.md with the six-role matrix, a complete package matrix pinned to every sidecar by tests/test_overriding.py, the skill-versus-owner boundary with proposed owner rules labelled, the fork and override recipe, release identity verification, and a layer-4 authoring template that the tests admit as a valid user package. Point the README at the guide in place of its incomplete package table and stale Designer assignment text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c6323b8219
commit
6c74666289
3 files changed
+477
-34
No files matched your search
@@ -0,0 +1,146 @@
|
||||
"""Keep the Operator override guide consistent with the packages it describes."""
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from tools.packages import ROLE_STEPS, check_package
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
GUIDE = ROOT / "OVERRIDING.md"
|
||||
|
||||
ROLE_NAMES = {
|
||||
"Specification Designer": "designer",
|
||||
"Technical Coordinator": "coordinator",
|
||||
"Planner": "planner",
|
||||
"Implementer": "implementer",
|
||||
"Reviewer": "reviewer",
|
||||
"Tester": "tester",
|
||||
}
|
||||
SCHEMAS = {
|
||||
"planner": "1, 2, 3",
|
||||
"implementer": "1, 3",
|
||||
"reviewer": "1, 3",
|
||||
"designer": "1",
|
||||
"tester": "1, 3",
|
||||
"coordinator": "1, 3",
|
||||
}
|
||||
|
||||
|
||||
def section(text, heading):
|
||||
"""Return a level-2 section's body; headings inside code fences do not end it."""
|
||||
lines, body, fenced = text.splitlines(keepends=True), None, False
|
||||
for line in lines:
|
||||
if line.startswith("```"):
|
||||
fenced = not fenced
|
||||
if not fenced and line.startswith("## "):
|
||||
if body is not None:
|
||||
break
|
||||
if line.rstrip("\n") == f"## {heading}":
|
||||
body = []
|
||||
continue
|
||||
if body is not None:
|
||||
body.append(line)
|
||||
if body is None:
|
||||
raise AssertionError(f"OVERRIDING.md has no '## {heading}' section")
|
||||
return "".join(body)
|
||||
|
||||
|
||||
def table_rows(text):
|
||||
rows = []
|
||||
for line in text.splitlines():
|
||||
if line.startswith("| ") and not set(line) <= set("|- "):
|
||||
rows.append([cell.strip() for cell in line.strip("|").split("|")])
|
||||
return rows[1:]
|
||||
|
||||
|
||||
def codes(cell):
|
||||
return re.findall(r"`([^`]+)`", cell)
|
||||
|
||||
|
||||
def package_facts(path):
|
||||
manifest = json.loads((path / "relayview-skill.json").read_text())
|
||||
frontmatter = (path / "SKILL.md").read_text().split("---\n")[1]
|
||||
manual = re.search(r"^disable-model-invocation: true$", frontmatter, re.M)
|
||||
if manifest["schemaVersion"] == 2:
|
||||
extra = f"issueClaim: {manifest['issueClaim']['statusLabel']}"
|
||||
elif manifest["schemaVersion"] == 3:
|
||||
extra = manifest["treatment"]
|
||||
else:
|
||||
extra = None
|
||||
return {
|
||||
"role_step": [manifest["role"], manifest["step"]],
|
||||
"mode": "manual" if manual else "automatic",
|
||||
"schema": str(manifest["schemaVersion"]),
|
||||
"extra": extra,
|
||||
"version": re.search(r"relayview-version: (\S+)", frontmatter).group(1),
|
||||
"release": manifest["source"]["reference"],
|
||||
}
|
||||
|
||||
|
||||
class OverrideGuideTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.text = GUIDE.read_text()
|
||||
|
||||
def test_readme_points_operators_to_the_guide(self):
|
||||
readme = (ROOT / "README.md").read_text()
|
||||
self.assertTrue("(OVERRIDING.md)" in readme, "README.md does not link OVERRIDING.md")
|
||||
|
||||
def test_package_matrix_matches_every_package_sidecar(self):
|
||||
rows = table_rows(section(self.text, "Package matrix"))
|
||||
listed = {}
|
||||
for row in rows:
|
||||
name = codes(row[0])[0]
|
||||
self.assertNotIn(name, listed, f"{name} is listed twice")
|
||||
extra = codes(row[4])
|
||||
listed[name] = {
|
||||
"role_step": codes(row[1]),
|
||||
"mode": row[2],
|
||||
"schema": row[3],
|
||||
"extra": extra[0] if extra else None,
|
||||
"version": row[5],
|
||||
"release": codes(row[6])[0],
|
||||
}
|
||||
packages = sorted(path.name for path in (ROOT / "packages").iterdir())
|
||||
self.assertEqual(sorted(listed), packages)
|
||||
for name in packages:
|
||||
with self.subTest(package=name):
|
||||
self.assertEqual(listed[name], package_facts(ROOT / "packages" / name))
|
||||
|
||||
def test_role_matrix_covers_all_six_roles(self):
|
||||
rows = table_rows(section(self.text, "Role matrix"))
|
||||
seen = {}
|
||||
for row in rows:
|
||||
role = ROLE_NAMES[row[0]]
|
||||
seen[role] = row
|
||||
self.assertEqual(codes(row[1]), [role, ROLE_STEPS[role]])
|
||||
self.assertEqual(row[2], SCHEMAS[role])
|
||||
self.assertEqual(row[3].split(" ")[0], "No" if role == "designer" else "Yes")
|
||||
for name in codes(row[5]):
|
||||
with self.subTest(role=role, default=name):
|
||||
facts = package_facts(ROOT / "packages" / name)
|
||||
self.assertEqual(facts["role_step"], [role, ROLE_STEPS[role]])
|
||||
self.assertEqual(facts["mode"], "automatic")
|
||||
self.assertEqual(set(seen), set(ROLE_STEPS))
|
||||
|
||||
def test_layer_four_template_is_a_valid_user_package(self):
|
||||
template = section(self.text, "Layer-4 authoring template")
|
||||
skill = re.search(r"```markdown\n(.*?)```", template, re.S).group(1)
|
||||
sidecar = re.search(r"```json\n(.*?)```", template, re.S).group(1)
|
||||
name = re.search(r"^name: (\S+)$", skill, re.M).group(1)
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
package = Path(directory) / name
|
||||
package.mkdir()
|
||||
(package / "SKILL.md").write_text(skill)
|
||||
digest = hashlib.sha256(skill.encode()).hexdigest()
|
||||
(package / "relayview-skill.json").write_text(sidecar.replace("<sha256 of SKILL.md>", digest))
|
||||
check_package(package)
|
||||
manifest = json.loads((package / "relayview-skill.json").read_text())
|
||||
self.assertEqual(manifest["source"]["kind"], "user")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user