Validate Tester and Coordinator role/step pairs
Check instruction packages / check (push) Successful in 4s
Check instruction packages / check (pull_request) Successful in 8s

Accept tester/testing and coordinator/coordination under schemas 1 and 3,
reject a JSON boolean schemaVersion and an inline metadata frontmatter value,
and cover the new pairs with valid fixtures plus single-mutation rejections.
The tests mirror RelayView's identity and archive computation and pin the
identity framing. Document the full instruction package contract and the
RelayView sidecar changes required before pinning v0.15.0 and v0.17.0.

Refs #20

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-11-25 18:50:23 -05:00
1 parent c103def91b
commit 8c7d967efd
17 files changed
+553 -8

No files matched your search

+1
View File
@@ -14,5 +14,6 @@ jobs:
- run: python3 -m unittest discover -s tests -v
- run: for package in packages/*; do python3 -m tools.packages check "$package"; done
- run: python3 -m tools.packages check examples/starter-planner
- run: for package in tests/fixtures/packages/*; do python3 -m tools.packages check "$package"; done
- run: for package in packages/*; do python3 -m tools.packages pack "$package" "dist/${package##*/}.zip"; done
- run: python3 -m tools.packages pack examples/starter-planner dist/starter-planner.zip
+1 -1
View File
@@ -35,7 +35,7 @@ Public source for RelayView-maintained instruction-only role skills and an illus
| `packages/c4-diff` | Optional guidance | Reviewer / review | 0.13.0 |
| `examples/starter-planner` | Illustrative starter; not a production default | Planner / planning | 0.13.0 |
Only named releases of maintained packages receive RelayView compatibility testing and maintenance. Optional guidance requires explicit role assignment; the Planner and Implementer defaults remain available alongside the pinned Issue Designer default. User forks are maintained by their publishers. Instruction packages use schema version 1, or schema version 2 for a Planner package declaring owner-validated `issueClaim` metadata. Schema 2 accepts a nullable target status label; the owner enforces the claim transition after proved implementation handoff. It contains only `SKILL.md`, declared `.md`/`.txt` resources, and `relayview-skill.json` within each package. Scripts, executable files, undeclared files, and requested permissions fail checks and owner admission. There is no fixed release calendar: maintained packages are versioned when their content or compatibility changes. A breaking owner contract requires a new compatible maintained release before the product depends on it.
Only named releases of maintained packages receive RelayView compatibility testing and maintenance. Optional guidance requires explicit role assignment; the Planner and Implementer defaults remain available alongside the pinned Issue Designer default. User forks are maintained by their publishers. Instruction packages use schema version 1, schema version 2 for a Planner package declaring owner-validated `issueClaim` metadata, or schema version 3 for a role communication package. Schema 2 accepts a nullable target status label; the owner enforces the claim transition after proved implementation handoff. Each package declares one role/step pair: `planner`/`planning`, `implementer`/`implementation`, `reviewer`/`review`, `designer`/`design`, `tester`/`testing`, or `coordinator`/`coordination`. RelayView admits Tester and Coordinator packages only after it adopts those pairs. A package contains only `SKILL.md`, declared `.md`/`.txt` resources, and `relayview-skill.json` within each package. The [instruction package contract](docs/authoritative/instruction-package-contract.md) gives every rule the checks enforce, the identity and archive algorithms, and the RelayView changes each new pair requires. Scripts, executable files, undeclared files, and requested permissions fail checks and owner admission. There is no fixed release calendar: maintained packages are versioned when their content or compatibility changes. A breaking owner contract requires a new compatible maintained release before the product depends on it.
## A named set in RelayView
@@ -0,0 +1,121 @@
# Instruction package contract
An instruction package is one closed directory: `SKILL.md`, optional declared
`.md`/`.txt` resources, and the `relayview-skill.json` sidecar.
`python3 -m tools.packages check <package>` enforces this contract and prints
the package identity; `python3 -m tools.packages pack <package> <zip>` builds
the release archive and prints its SHA-256. RelayView's owner applies its own
admission check, which stays authoritative: a package that passes here can
still be refused by an owner that does not yet support its role/step pair.
## Role and step
Each package guides exactly one role during that role's one step.
| `role` | `step` | Schemas |
| --- | --- | --- |
| `planner` | `planning` | 1, 2, 3 |
| `implementer` | `implementation` | 1, 3 |
| `reviewer` | `review` | 1, 3 |
| `designer` | `design` | 1 |
| `tester` | `testing` | 1, 3 |
| `coordinator` | `coordination` | 1, 3 |
Any other pairing, including a known role with another role's step, fails the
check. Role and step names are lower-case strings.
## Sidecar fields
The sidecar is UTF-8 JSON without a BOM or NUL bytes, at most 64 KiB, with
exactly the fields its integer `schemaVersion` names:
- **Schema 1** — `schemaVersion`, `source`, `role`, `step`, `files`.
- **Schema 2** — schema 1 plus `issueClaim: {"statusLabel": <label or null>}`;
`planner`/`planning` only. A label matches `status/[a-z][a-z0-9-]{0,63}` and
is never `status/ready-for-agent`.
- **Schema 3** — schema 1 plus `treatment: "communication_context"`; every
pair except `designer`/`design`. The treatment marks the package's ablation
boundary and grants no tools or authority.
`source` is exactly `{"kind": "first-party" | "user", "reference": <1–128 of
[A-Za-z0-9._:-]>}`. `files` lists 1–16 `{"path", "sha256"}` entries: unique
relative paths without `.`/`..`/empty segments or backslashes, at most 256
characters, `SKILL.md` required, other paths ending `.md` or `.txt`, and
lower-case 64-hex SHA-256 digests. Any additional field — such as `tools`,
`permissions`, or `network` — fails the check.
## Package contents
- Every file in the directory except the sidecar is declared, and every
declared file is present with exactly its declared SHA-256.
- No symbolic links, executable bits, or non-regular files; at most 64 entries
and 8 directory levels.
- Each file is non-empty UTF-8 without a BOM or NUL bytes; the sidecar plus all
declared files total at most 128 KiB.
## `SKILL.md` frontmatter
The frontmatter allows only these keys, each at most once:
```yaml
name: <the directory name: hyphen-separated lower-case letters and digits, at most 64 characters>
description: <non-empty, at most 1024 characters>
disable-model-invocation: true # optional; true or false; true makes the package manual-only
metadata:
relayview-display-name: <at most 128 characters>
relayview-version: <major.minor.patch>
```
`metadata:` stands alone on its line, followed by exactly those two indented
keys. Any other key, such as `tools` or `allowed-tools`, fails the check.
## Identity and archive
The package identity is the SHA-256 of `relayview-instruction-package-v1\0`
followed by length-framed parts (a 4-byte big-endian length, then the bytes):
the raw sidecar bytes, then for each declared path in sorted order the UTF-8
path and the file bytes.
The release archive is an uncompressed ZIP containing the repository
`LICENSE` and `NOTICE.md`, then every package file under `<package-name>/` in
sorted path order. Every entry carries the timestamp 1980-01-01 00:00:00 and
mode `0644`, so the archive digest depends only on those bytes.
RelayView's `scripts/verify-first-party-skills-source.py` recomputes both
values from a tagged release and compares them with its
`first-party-skills/<tag>/bundle-lock.json`. The tests in
`tests/test_role_steps.py` mirror that computation and pin the identity
framing. The `v0.1.0` archive predates the bundled `LICENSE` and `NOTICE.md`;
every later release uses the archive format above.
## Releases are immutable
A published tag is never moved or rebuilt. A change to any package byte ships
under a new release tag; RelayView keeps earlier bundles to reconstruct
retained sessions.
## RelayView adoption of the Tester and Coordinator pairs
RelayView's owner admits `planner`, `implementer`, `reviewer`, and `designer`
packages. Before RelayView pins a release containing a `tester` or
`coordinator` package, its sidecar admission must accept that pair:
| Release | New pair | Packages |
| --- | --- | --- |
| `v0.15.0` | `tester`/`testing` | `tester-inspection` (schema 1), `tester-communication` (schema 3) |
| `v0.17.0` | `coordinator`/`coordination` | coordinator automatic and manual methods (schema 1), `coordinator-communication` (schema 3) |
The RelayView change for each pair:
1. Accept the pair in the owner's sidecar admission (the role-to-step map in
`src/owner/workflowPresets.ts`), with schema 1 and schema 3; keep schema 2
Planner-only and schema 3 closed to `designer`.
2. Add the step to the Skills settings contract and named-set validation so
the role's sets can be selected (`src/api/contract-skill-settings.ts`, the
generated owner schemas, and the set step check in
`src/owner/workflowPresets.ts`).
3. Pin the release in `first-party-skills/<tag>/` with its `bundle-lock.json`
and add the bundle to `scripts/verify-first-party-skills-source.py`.
The identity framing, archive format, file rules, and frontmatter rules do not
change, so existing bundle locks stay valid.
@@ -0,0 +1,11 @@
---
name: coordinator-communication-fixture
description: Report the running wave, leases, and held issues briefly.
metadata:
relayview-display-name: Coordinator communication fixture
relayview-version: 0.0.1
---
# Coordinator communication fixture
Validation fixture for the coordinator/coordination pair; not a released package.
@@ -0,0 +1,16 @@
{
"schemaVersion": 3,
"source": {
"kind": "user",
"reference": "fixture-1"
},
"role": "coordinator",
"step": "coordination",
"treatment": "communication_context",
"files": [
{
"path": "SKILL.md",
"sha256": "4f380a0e67e5e821dd6b577d7c111981a4f8c61f76e0518d07c157f3cb4251ce"
}
]
}
+11
View File
@@ -0,0 +1,11 @@
---
name: coordinator-fixture
description: Hold contending Ready issues out of the same wave.
metadata:
relayview-display-name: Coordinator fixture
relayview-version: 0.0.1
---
# Coordinator fixture
Validation fixture for the coordinator/coordination pair; not a released package.
@@ -0,0 +1,19 @@
{
"schemaVersion": 1,
"source": {
"kind": "user",
"reference": "fixture-1"
},
"role": "coordinator",
"step": "coordination",
"files": [
{
"path": "SKILL.md",
"sha256": "150d3c53a5a65829230bfad76b48a78d280f63a7d156d3e9d1faa68d70f987af"
},
{
"path": "wave-selection.md",
"sha256": "edc636e0f98163ad3a9538971c99cdea319576f8a5becd63c615418873ad2a6f"
}
]
}
@@ -0,0 +1,3 @@
# Wave selection
Name the shared file, schema, or resource behind each held pair.
@@ -0,0 +1,12 @@
---
name: coordinator-manual-fixture
description: Audit the Ready queue on request.
disable-model-invocation: true
metadata:
relayview-display-name: Coordinator manual fixture
relayview-version: 0.0.1
---
# Coordinator manual fixture
Validation fixture for the coordinator/coordination pair; not a released package.
@@ -0,0 +1,15 @@
{
"schemaVersion": 1,
"source": {
"kind": "user",
"reference": "fixture-1"
},
"role": "coordinator",
"step": "coordination",
"files": [
{
"path": "SKILL.md",
"sha256": "56dd9f2794eba8709da20590238edd5d07f82e2c92a0164f711cac4f690d93d6"
}
]
}
@@ -0,0 +1,11 @@
---
name: tester-communication-fixture
description: Present observed proof before remaining manual checks.
metadata:
relayview-display-name: Tester communication fixture
relayview-version: 0.0.1
---
# Tester communication fixture
Validation fixture for the tester/testing pair; not a released package.
@@ -0,0 +1,16 @@
{
"schemaVersion": 3,
"source": {
"kind": "user",
"reference": "fixture-1"
},
"role": "tester",
"step": "testing",
"treatment": "communication_context",
"files": [
{
"path": "SKILL.md",
"sha256": "5cb3a5fb4b289269ba2139e51ea061031501f9946815d7853104caf80040b3fd"
}
]
}
+11
View File
@@ -0,0 +1,11 @@
---
name: tester-fixture
description: Exercise a sealed candidate and report observed proof.
metadata:
relayview-display-name: Tester fixture
relayview-version: 0.0.1
---
# Tester fixture
Validation fixture for the tester/testing pair; not a released package.
+3
View File
@@ -0,0 +1,3 @@
# Inspection
Record each observation beside the proof artifact that shows it.
@@ -0,0 +1,19 @@
{
"schemaVersion": 1,
"source": {
"kind": "user",
"reference": "fixture-1"
},
"role": "tester",
"step": "testing",
"files": [
{
"path": "SKILL.md",
"sha256": "63d958e9afaaea5fa06e2480743f59f46882c93195e78867d5dd60951cabe640"
},
{
"path": "inspection.md",
"sha256": "62efbba79a3a8d7a95455466755b320b9d54792599fe39da55c276cffaffa341"
}
]
}
+258
View File
@@ -0,0 +1,258 @@
"""Validation of every supported role/step pair, including Tester and Coordinator.
The fixtures under tests/fixtures/packages are valid packages for the newer
role/step pairs; invalid cases are derived from them by one mutation each.
"""
import hashlib
import json
import os
import shutil
import struct
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]
FIXTURES = ROOT / "tests/fixtures/packages"
NEW_PAIR_FIXTURES = {
"tester-fixture": (1, "tester", "testing"),
"tester-communication-fixture": (3, "tester", "testing"),
"coordinator-fixture": (1, "coordinator", "coordination"),
"coordinator-communication-fixture": (3, "coordinator", "coordination"),
"coordinator-manual-fixture": (1, "coordinator", "coordination"),
}
def reference_identity(package):
"""Mirror RelayView's scripts/verify-first-party-skills-source.py identity."""
manifest_bytes = (package / "relayview-skill.json").read_bytes()
identity = hashlib.sha256(b"relayview-instruction-package-v1\0")
def frame(data):
identity.update(struct.pack(">I", len(data)))
identity.update(data)
frame(manifest_bytes)
for item in sorted(json.loads(manifest_bytes)["files"], key=lambda item: item["path"]):
frame(item["path"].encode("utf-8"))
frame((package / item["path"]).read_bytes())
return identity.hexdigest()
def reference_archive_sha256(package, destination):
"""Mirror RelayView's scripts/verify-first-party-skills-source.py archive."""
with zipfile.ZipFile(destination, "w", compression=zipfile.ZIP_STORED) as archive:
files = [(file.name, file) for file in (ROOT / "LICENSE", ROOT / "NOTICE.md")]
files += [(f"{package.name}/{file.relative_to(package).as_posix()}", file)
for file in sorted(package.rglob("*")) if file.is_file()]
for name, file in files:
info = zipfile.ZipInfo(name, date_time=(1980, 1, 1, 0, 0, 0))
info.external_attr = 0o100644 << 16
archive.writestr(info, file.read_bytes())
return hashlib.sha256(Path(destination).read_bytes()).hexdigest()
class FixtureCopy:
"""A temporary copy of one fixture that a test mutates once."""
def __init__(self, name):
self.name = name
def __enter__(self):
self._directory = tempfile.TemporaryDirectory()
self.path = Path(self._directory.name) / self.name
shutil.copytree(FIXTURES / self.name, self.path)
return self
def __exit__(self, *exc):
self._directory.cleanup()
@property
def manifest(self):
return json.loads((self.path / "relayview-skill.json").read_text())
def write_manifest(self, manifest):
(self.path / "relayview-skill.json").write_text(json.dumps(manifest, indent=2) + "\n")
def write_file(self, relative, data, declare=True):
"""Write package content; when declared, refresh its digest so only the content is under test."""
file = self.path / relative
file.write_bytes(data if isinstance(data, bytes) else data.encode("utf-8"))
if declare:
manifest = self.manifest
digest = hashlib.sha256(file.read_bytes()).hexdigest()
entry = next((item for item in manifest["files"] if item["path"] == relative), None)
if entry is None:
manifest["files"].append({"path": relative, "sha256": digest})
else:
entry["sha256"] = digest
self.write_manifest(manifest)
def replace_in_skill(self, old, new):
text = (self.path / "SKILL.md").read_text()
assert old in text, old
self.write_file("SKILL.md", text.replace(old, new, 1))
class NewRoleStepPairTests(unittest.TestCase):
def test_fixtures_declare_the_new_pairs_under_schema_one_and_three(self):
self.assertEqual(sorted(path.name for path in FIXTURES.iterdir()), sorted(NEW_PAIR_FIXTURES))
for name, (schema, role, step) in NEW_PAIR_FIXTURES.items():
with self.subTest(name=name):
manifest = json.loads((FIXTURES / name / "relayview-skill.json").read_text())
self.assertEqual((manifest["schemaVersion"], manifest["role"], manifest["step"]), (schema, role, step))
self.assertEqual(manifest.get("treatment"), "communication_context" if schema == 3 else None)
def test_valid_fixtures_pass_with_relayview_identity_and_archive(self):
for name in NEW_PAIR_FIXTURES:
with self.subTest(name=name), tempfile.TemporaryDirectory() as directory:
package = FIXTURES / name
self.assertEqual(check_package(package), reference_identity(package))
first = package_archive(package, Path(directory) / "one.zip")
second = package_archive(package, Path(directory) / "two.zip")
self.assertEqual(first, second)
self.assertEqual(first, reference_archive_sha256(package, Path(directory) / "reference.zip"))
with zipfile.ZipFile(Path(directory) / "one.zip") as archive:
for info in archive.infolist():
self.assertEqual(info.date_time, (1980, 1, 1, 0, 0, 0))
self.assertEqual(info.external_attr >> 16, 0o100644)
self.assertEqual(info.compress_type, zipfile.ZIP_STORED)
def test_identity_algorithm_is_pinned(self):
# Regression pin: changing this value means the relayview-instruction-package-v1
# framing changed, which would break every RelayView bundle lock.
self.assertEqual(check_package(FIXTURES / "tester-fixture"),
"31a04937d9572067f0c3327fbaba97e11f6962fd7f68fefdb2c70ef8f5aad394")
def test_manual_fixture_disables_model_invocation(self):
self.assertIn("disable-model-invocation: true\n", (FIXTURES / "coordinator-manual-fixture/SKILL.md").read_text())
class RoleStepRejectionTests(unittest.TestCase):
def assertRejected(self, copy, message):
with self.assertRaisesRegex(PackageError, message):
check_package(copy.path)
def test_rejects_wrong_role_step_combinations(self):
combinations = (
("tester", "coordination"), ("coordinator", "testing"),
("tester", "review"), ("tester", "implementation"),
("coordinator", "planning"), ("coordinator", "design"),
("planner", "testing"), ("reviewer", "coordination"), ("designer", "testing"),
("Tester", "testing"), ("coordinator", "Coordination"),
("tester", None), (["tester"], "testing"), ("operator", "coordination"),
)
for name in NEW_PAIR_FIXTURES:
for role, step in combinations:
with self.subTest(name=name, role=role, step=step), FixtureCopy(name) as copy:
copy.write_manifest(dict(copy.manifest, role=role, step=step))
self.assertRejected(copy, "incompatible role or step")
def test_rejects_issue_claim_outside_the_planner(self):
for name in ("tester-fixture", "coordinator-fixture"):
with self.subTest(name=name), FixtureCopy(name) as copy:
copy.write_manifest(dict(copy.manifest, schemaVersion=2, issueClaim={"statusLabel": None}))
self.assertRejected(copy, "invalid issue claim policy")
def test_rejects_schema_and_treatment_mismatches(self):
cases = {
"tester-fixture": [
{"treatment": "communication_context"},
{"schemaVersion": 3},
{"schemaVersion": True},
{"schemaVersion": "1"},
{"schemaVersion": 1.5},
{"schemaVersion": 4},
],
"coordinator-communication-fixture": [
{"treatment": "context"},
{"treatment": None},
{"schemaVersion": 1},
{"schemaVersion": True},
],
}
for name, changes in cases.items():
for change in changes:
with self.subTest(name=name, change=change), FixtureCopy(name) as copy:
copy.write_manifest(dict(copy.manifest, **change))
with self.assertRaises(PackageError):
check_package(copy.path)
with FixtureCopy("tester-communication-fixture") as copy:
manifest = copy.manifest
del manifest["treatment"]
copy.write_manifest(manifest)
self.assertRejected(copy, "unsupported manifest fields")
def test_rejects_sidecar_capability_fields(self):
for name in NEW_PAIR_FIXTURES:
for field, value in (("tools", ["shell"]), ("permissions", {"network": True}), ("network", True),
("credentials", ["gitea"]), ("dispatch", True), ("resources", ["gpu-worker"])):
with self.subTest(name=name, field=field), FixtureCopy(name) as copy:
copy.write_manifest(dict(copy.manifest, **{field: value}))
self.assertRejected(copy, "unsupported manifest fields")
with self.subTest(name=name, field="source.scope"), FixtureCopy(name) as copy:
copy.write_manifest(dict(copy.manifest, source={"kind": "user", "reference": "fixture-1", "scope": "all"}))
self.assertRejected(copy, "invalid source")
def test_rejects_bad_digests(self):
for name in ("tester-fixture", "coordinator-fixture"):
resource = next(item["path"] for item in json.loads((FIXTURES / name / "relayview-skill.json").read_text())["files"] if item["path"] != "SKILL.md")
for path in ("SKILL.md", resource):
for digest, message in (("0" * 64, "changed file"), ("A" * 64, "invalid digest"),
("0" * 63, "invalid digest"), (None, "invalid digest")):
with self.subTest(name=name, path=path, digest=digest), FixtureCopy(name) as copy:
manifest = copy.manifest
next(item for item in manifest["files"] if item["path"] == path)["sha256"] = digest
copy.write_manifest(manifest)
self.assertRejected(copy, message)
with self.subTest(name=name, change="content after digest"), FixtureCopy(name) as copy:
(copy.path / resource).write_text("changed\n")
self.assertRejected(copy, "changed file")
def test_rejects_forbidden_frontmatter(self):
for name in NEW_PAIR_FIXTURES:
for old, new in (
("metadata:\n", "tools: [shell]\nmetadata:\n"),
("metadata:\n", "allowed-tools: Bash\nmetadata:\n"),
("metadata:\n", "model: any\nmetadata:\n"),
("metadata:\n", "role: coordinator\nmetadata:\n"),
("metadata:\n", "metadata: {}\n"),
("metadata:\n", "metadata:\n relayview-tools: shell\n"),
("metadata:\n", "metadata:\n relayview-role: tester\n"),
("metadata:\n", "name: other-name\nmetadata:\n"),
("metadata:\n", "disable-model-invocation: yes\nmetadata:\n"),
):
if "disable-model-invocation" in new and name == "coordinator-manual-fixture":
old, new = "disable-model-invocation: true\n", "disable-model-invocation: yes\n"
with self.subTest(name=name, new=new), FixtureCopy(name) as copy:
copy.replace_in_skill(old, new)
with self.assertRaises(PackageError):
check_package(copy.path)
def test_rejects_unsafe_or_undeclared_content(self):
cases = (
("BOM", lambda copy: copy.write_file("SKILL.md", b"\xef\xbb\xbf" + (copy.path / "SKILL.md").read_bytes()), "invalid text"),
("NUL", lambda copy: copy.write_file("notes.md", "a\x00b\n"), "invalid text"),
("invalid UTF-8", lambda copy: copy.write_file("notes.md", b"\xff\xfe\n"), "invalid UTF-8"),
("empty resource", lambda copy: copy.write_file("notes.md", b""), "text bounds"),
("undeclared", lambda copy: copy.write_file("notes.md", "extra\n", declare=False), "undeclared file"),
("script", lambda copy: copy.write_file("helper.py", "print('unsafe')\n"), "unsupported package content"),
("JSON resource", lambda copy: copy.write_file("data.json", "{}\n"), "unsupported package content"),
("missing declared", lambda copy: copy.write_manifest(dict(copy.manifest, files=copy.manifest["files"] + [{"path": "absent.md", "sha256": "0" * 64}])), "missing declared file"),
("escape", lambda copy: copy.write_manifest(dict(copy.manifest, files=copy.manifest["files"] + [{"path": "../outside.md", "sha256": "0" * 64}])), "invalid file path"),
("executable", lambda copy: os.chmod(copy.path / "SKILL.md", 0o755), "executable"),
("symlink", lambda copy: os.symlink(copy.path / "SKILL.md", copy.path / "link.md"), "is a link"),
)
for name in NEW_PAIR_FIXTURES:
for label, mutate, message in cases:
with self.subTest(name=name, case=label), FixtureCopy(name) as copy:
mutate(copy)
self.assertRejected(copy, message)
if __name__ == "__main__":
unittest.main()
+25 -7
View File
@@ -10,6 +10,25 @@ import zipfile
from pathlib import Path
# Each role guides exactly one workflow step. RelayView's owner admits a pair
# only once its own sidecar contract lists it; see
# docs/authoritative/instruction-package-contract.md.
ROLE_STEPS = {
"planner": "planning",
"implementer": "implementation",
"reviewer": "review",
"designer": "design",
"tester": "testing",
"coordinator": "coordination",
}
MANIFEST_FIELDS = {
1: {"schemaVersion", "source", "role", "step", "files"},
2: {"schemaVersion", "source", "role", "step", "files", "issueClaim"},
3: {"schemaVersion", "source", "role", "step", "files", "treatment"},
}
class PackageError(ValueError):
pass
@@ -44,19 +63,16 @@ def check_package(path):
manifest = json.loads(_text(raw_manifest, str(sidecar)))
except (ValueError, TypeError) as error:
_fail(f"{sidecar}: invalid JSON: {error}")
if not isinstance(manifest, dict) or (
(manifest.get("schemaVersion") == 1 and set(manifest) != {"schemaVersion", "source", "role", "step", "files"}) or
(manifest.get("schemaVersion") == 2 and set(manifest) != {"schemaVersion", "source", "role", "step", "files", "issueClaim"}) or
(manifest.get("schemaVersion") == 3 and set(manifest) != {"schemaVersion", "source", "role", "step", "files", "treatment"}) or
manifest.get("schemaVersion") not in (1, 2, 3)
):
version = manifest.get("schemaVersion") if isinstance(manifest, dict) else None
# type() rather than isinstance(): JSON true must not pass as schema 1.
if type(version) is not int or version not in MANIFEST_FIELDS or set(manifest) != MANIFEST_FIELDS[version]:
_fail(f"{path}: unsupported manifest fields")
source = manifest["source"]
if not isinstance(source, dict) or set(source) != {"kind", "reference"}:
_fail(f"{path}: invalid source")
if source["kind"] not in ("first-party", "user") or not isinstance(source["reference"], str) or not re.fullmatch(r"[A-Za-z0-9._:-]{1,128}", source["reference"]):
_fail(f"{path}: invalid source identity")
if (manifest["role"], manifest["step"]) not in (("planner", "planning"), ("implementer", "implementation"), ("reviewer", "review"), ("designer", "design")):
if not isinstance(manifest["role"], str) or ROLE_STEPS.get(manifest["role"]) != manifest["step"]:
_fail(f"{path}: incompatible role or step")
if manifest["schemaVersion"] == 2:
claim = manifest["issueClaim"]
@@ -127,6 +143,8 @@ def check_package(path):
key = line.split(":", 1)[0]
top_keys.append(key)
in_metadata = key == "metadata"
if in_metadata and line != "metadata:":
_fail(f"{path}: unsupported skill metadata")
else:
_fail(f"{path}: unsupported skill metadata")
if len(top_keys) != len(set(top_keys)) or set(top_keys) - {"name", "description", "metadata", "disable-model-invocation"} or len(nested_keys) != len(set(nested_keys)) or set(nested_keys) != {"relayview-display-name", "relayview-version"}: