Compare commits

...
6 Commits
Author SHA1 Message Date
adminandClaude Opus 5.5 da34e1c1bf State the frontmatter line-break rule exactly
Check instruction packages / check (push) Successful in 5s
Check instruction packages / check (pull_request) Successful in 5s
Name the separators the checker rejects and the end-of-file closing
delimiter it accepts, and show that the rule stops at the frontmatter: a
CRLF body and a frontmatter-only file still pass. Split frontmatter lines
once and assert the exact rejection reason.

Refs #20

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 19:04:47 -05:00
adminandClaude Opus 5.5 45eff20ecb Enforce LF-only SKILL.md frontmatter
Check instruction packages / check (push) Successful in 6s
Check instruction packages / check (pull_request) Successful in 5s
The contract stated an LF rule the checker only enforced by accident:
CRLF on a single line, a lone CR, a Unicode line separator, or CRLF on a
delimiter passed. Require LF delimiters and LF-only frontmatter lines, and
test each case. Every package in every tag v0.1.0-v0.14.0 still passes.
The contract now names the required frontmatter keys and shows runnable
check and pack commands.

Refs #20

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 19:01:50 -05:00
adminandClaude Opus 5.5 f872770dc9 Document the LF frontmatter rule and pin it with a test
Check instruction packages / check (push) Successful in 5s
Check instruction packages / check (pull_request) Successful in 6s
The checker already rejects CRLF frontmatter; the contract now says so and
a fixture mutation keeps that statement honest. Use the parsed schema
version for the schema 2 and 3 checks, and rewrap the contract.

Refs #20

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 18:58:35 -05:00
adminandClaude Opus 5.5 ddf95ded04 State every enforced frontmatter and layout rule in the contract
Check instruction packages / check (push) Successful in 5s
Check instruction packages / check (pull_request) Successful in 4s
Add the frontmatter placement, two-space indent, no blank or comment
lines, and real-directory rules; move the example's comment out of its
value line so the example passes; name the code-point sort; and note that
archive digests depend on a POSIX build host. Split the frontmatter line
check into a named condition.

Refs #20

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 18:56:09 -05:00
adminandClaude Opus 5.5 1e9e46bc09 Require inline frontmatter values and correct the package contract
Check instruction packages / check (push) Successful in 4s
Check instruction packages / check (pull_request) Successful in 4s
Reject a top-level frontmatter key without "key: value" form, so
"disable-model-invocation:yes" can no longer bypass the boolean check.
Assert each rejection's reason in the new-pair tests. In the contract,
mark the Tester and Coordinator releases as proposed, list RelayView's
role-level changes, and state the path-depth bound and the identity and
archive sort orders exactly.

Refs #20

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 18:53:47 -05:00
adminandClaude Opus 5.5 8c7d967efd 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>
2026-11-25 18:50:23 -05:00
17 changed files with 626 additions and 14 deletions

No files matched your search

+1
View File
@@ -14,5 +14,6 @@ jobs:
- run: python3 -m unittest discover -s tests -v - run: python3 -m unittest discover -s tests -v
- run: for package in packages/*; do python3 -m tools.packages check "$package"; done - run: for package in packages/*; do python3 -m tools.packages check "$package"; done
- run: python3 -m tools.packages check examples/starter-planner - 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: 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 - 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 | | `packages/c4-diff` | Optional guidance | Reviewer / review | 0.13.0 |
| `examples/starter-planner` | Illustrative starter; not a production default | Planner / planning | 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`. 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 ## A named set in RelayView
@@ -0,0 +1,149 @@
# Instruction package contract
An instruction package is one closed directory: `SKILL.md`, optional declared
`.md`/`.txt` resources, and the `relayview-skill.json` sidecar.
`tools/packages.py` enforces this contract. Its `check` action prints a
package's identity and its `pack` action builds the release archive and prints
its SHA-256, for example:
```sh
python3 -m tools.packages check packages/planner-scope
python3 -m tools.packages pack packages/planner-scope dist/planner-scope.zip
```
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.
- The package directory is a real directory, not a symbolic link, and the
sidecar is a regular file.
- No symbolic links, executable bits, or non-regular files; at most 64 entries
(files and directories), and no relative path longer than 8 segments
including the file name.
- 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
`SKILL.md` opens with a frontmatter block between `---` lines. The block
requires `name`, `description`, and `metadata`, and 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
metadata:
relayview-display-name: <at most 128 characters>
relayview-version: <major.minor.patch>
```
`disable-model-invocation` is optional and is exactly `true` or `false`; `true`
makes the package manual-only. Every key other than `metadata` is written
`key: value` with a non-empty value. `metadata:` stands alone on its line,
followed by exactly those two keys, each indented two spaces. The block has no
blank or comment lines. The block and its delimiters contain no line-break
character other than LF (such as CR, vertical tab, form feed, or a Unicode
line or paragraph separator), and the closing `---` ends with LF or the end of
the file. This line-break rule does not apply to the Markdown body. 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, sorted as whole strings
by Unicode code point, 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>/`,
sorted segment by segment (so `a/b.md` precedes `a-b/c.md`, unlike the
whole-string order the identity uses). Every entry carries the timestamp
1980-01-01 00:00:00 and mode `0644`. ZIP headers also record the creating
system, so release digests are computed on a POSIX host, as this repository's
CI does; on such a host 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 only `planner`, `implementer`, `reviewer`, and
`designer` packages. No released package declares `tester` or `coordinator`
yet. The planned releases below are proposed, not published:
| Proposed release | New pair | Planned packages |
| --- | --- | --- |
| `v0.15.0` | `tester`/`testing` | Tester inspection (schema 1) and Tester communication (schema 3) |
| `v0.17.0` | `coordinator`/`coordination` | Coordinator automatic and manual methods (schema 1) and Coordinator communication (schema 3) |
Before RelayView pins a release containing either pair, it must:
1. **Know the role.** Add it to the owner's role types (`SkillWorkflowRole` /
`TrustedSkillRole` in `src/owner/workflowPresets.ts`) and give it an
explicit step in `roleStep()`, which otherwise answers `design` for any
role it does not name.
2. **Admit the sidecar.** In `loadInstructionPackage`, accept the role in its
explicit role check and map it to its step in `expectedStep`. Accept schema 1
and schema 3, keep schema 2 Planner-only, and keep schema 3 closed to
`designer`.
3. **Expose it in Skills settings.** Add the role and step to the package,
assignment, and set-selection schemas in `src/api/contract-skill-settings.ts`
and the generated owner schemas, and to named-set role and step validation
in `src/owner/workflowPresets.ts`, so the role's sets can be selected.
4. **Pin and verify the release.** Add `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 for these pairs, 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"
}
]
}
+291
View File
@@ -0,0 +1,291 @@
"""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):
fields, treatment = "unsupported manifest fields", "invalid communication treatment"
cases = {
"tester-fixture": [
({"treatment": "communication_context"}, fields),
({"schemaVersion": 3}, fields),
({"schemaVersion": True}, fields),
({"schemaVersion": "1"}, fields),
({"schemaVersion": 1.5}, fields),
({"schemaVersion": 4}, fields),
],
"coordinator-communication-fixture": [
({"treatment": "context"}, treatment),
({"treatment": None}, treatment),
({"schemaVersion": 1}, fields),
({"schemaVersion": True}, fields),
],
}
for name, changes in cases.items():
for change, message in changes:
with self.subTest(name=name, change=change), FixtureCopy(name) as copy:
copy.write_manifest(dict(copy.manifest, **change))
self.assertRejected(copy, message)
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):
metadata, boolean = "unsupported skill metadata", "must be a boolean"
cases = (
("metadata:\n", "tools: [shell]\nmetadata:\n", metadata),
("metadata:\n", "allowed-tools: Bash\nmetadata:\n", metadata),
("metadata:\n", "model: any\nmetadata:\n", metadata),
("metadata:\n", "role: coordinator\nmetadata:\n", metadata),
("metadata:\n", "metadata: {}\n", metadata),
("metadata:\n", "metadata:\n relayview-tools: shell\n", metadata),
("metadata:\n", "metadata:\n relayview-role: tester\n", metadata),
("metadata:\n", "name: other-name\nmetadata:\n", metadata),
("metadata:\n", "disable-model-invocation: yes\nmetadata:\n", boolean),
("metadata:\n", "disable-model-invocation:yes\nmetadata:\n", metadata),
("metadata:\n", "disable-model-invocation:\nmetadata:\n", metadata),
)
for name in NEW_PAIR_FIXTURES:
for old, new, message in cases:
with self.subTest(name=name, new=new), FixtureCopy(name) as copy:
if name == "coordinator-manual-fixture":
# Drop the fixture's own key so an inserted one is not merely a duplicate.
copy.replace_in_skill("disable-model-invocation: true\n", "")
copy.replace_in_skill(old, new)
self.assertRejected(copy, message)
def test_frontmatter_lines_end_in_lf_only(self):
def replace_bytes(old, new, count=1):
return lambda copy: copy.write_file("SKILL.md", (copy.path / "SKILL.md").read_bytes().replace(old, new, count))
cases = (
("CRLF throughout", replace_bytes(b"\n", b"\r\n", -1)),
("CRLF after description", replace_bytes(b"\nmetadata:", b"\r\nmetadata:")),
("lone CR after description", replace_bytes(b"\nmetadata:", b"\rmetadata:")),
("U+2028 after description", replace_bytes(b"\nmetadata:", "\u2028metadata:".encode())),
("CRLF on opening delimiter", replace_bytes(b"---\n", b"---\r\n")),
("CRLF on closing delimiter", replace_bytes(b"\n---\n", b"\n---\r\n")),
)
for name in NEW_PAIR_FIXTURES:
for label, mutate in cases:
with self.subTest(name=name, case=label), FixtureCopy(name) as copy:
mutate(copy)
self.assertRejected(copy, "invalid SKILL.md frontmatter")
def test_line_break_rule_stops_at_the_frontmatter(self):
for name in NEW_PAIR_FIXTURES:
with self.subTest(name=name, case="CRLF body"), FixtureCopy(name) as copy:
text = (copy.path / "SKILL.md").read_text()
head, body = text.split("\n---\n", 1)
copy.write_file("SKILL.md", head + "\n---\n" + body.replace("\n", "\r\n") + "\u2028\n")
check_package(copy.path)
with self.subTest(name=name, case="frontmatter only, no final newline"), FixtureCopy(name) as copy:
text = (copy.path / "SKILL.md").read_text()
copy.write_file("SKILL.md", text.split("\n---\n", 1)[0] + "\n---")
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()
+37 -13
View File
@@ -10,6 +10,25 @@ import zipfile
from pathlib import Path 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): class PackageError(ValueError):
pass pass
@@ -44,28 +63,25 @@ def check_package(path):
manifest = json.loads(_text(raw_manifest, str(sidecar))) manifest = json.loads(_text(raw_manifest, str(sidecar)))
except (ValueError, TypeError) as error: except (ValueError, TypeError) as error:
_fail(f"{sidecar}: invalid JSON: {error}") _fail(f"{sidecar}: invalid JSON: {error}")
if not isinstance(manifest, dict) or ( version = manifest.get("schemaVersion") if isinstance(manifest, dict) else None
(manifest.get("schemaVersion") == 1 and set(manifest) != {"schemaVersion", "source", "role", "step", "files"}) or # type() rather than isinstance(): JSON true must not pass as schema 1.
(manifest.get("schemaVersion") == 2 and set(manifest) != {"schemaVersion", "source", "role", "step", "files", "issueClaim"}) or if type(version) is not int or version not in MANIFEST_FIELDS or set(manifest) != MANIFEST_FIELDS[version]:
(manifest.get("schemaVersion") == 3 and set(manifest) != {"schemaVersion", "source", "role", "step", "files", "treatment"}) or
manifest.get("schemaVersion") not in (1, 2, 3)
):
_fail(f"{path}: unsupported manifest fields") _fail(f"{path}: unsupported manifest fields")
source = manifest["source"] source = manifest["source"]
if not isinstance(source, dict) or set(source) != {"kind", "reference"}: if not isinstance(source, dict) or set(source) != {"kind", "reference"}:
_fail(f"{path}: invalid source") _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"]): 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") _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") _fail(f"{path}: incompatible role or step")
if manifest["schemaVersion"] == 2: if version == 2:
claim = manifest["issueClaim"] claim = manifest["issueClaim"]
label = claim.get("statusLabel") if isinstance(claim, dict) else None label = claim.get("statusLabel") if isinstance(claim, dict) else None
if (manifest["role"], manifest["step"]) != ("planner", "planning") or not isinstance(claim, dict) or set(claim) != {"statusLabel"} or ( if (manifest["role"], manifest["step"]) != ("planner", "planning") or not isinstance(claim, dict) or set(claim) != {"statusLabel"} or (
label is not None and (not isinstance(label, str) or not re.fullmatch(r"status/[a-z][a-z0-9-]{0,63}", label) or label == "status/ready-for-agent") label is not None and (not isinstance(label, str) or not re.fullmatch(r"status/[a-z][a-z0-9-]{0,63}", label) or label == "status/ready-for-agent")
): ):
_fail(f"{path}: invalid issue claim policy") _fail(f"{path}: invalid issue claim policy")
if manifest["schemaVersion"] == 3 and (manifest["treatment"] != "communication_context" or manifest["role"] == "designer"): if version == 3 and (manifest["treatment"] != "communication_context" or manifest["role"] == "designer"):
_fail(f"{path}: invalid communication treatment") _fail(f"{path}: invalid communication treatment")
files = manifest["files"] files = manifest["files"]
if not isinstance(files, list) or not 1 <= len(files) <= 16: if not isinstance(files, list) or not 1 <= len(files) <= 16:
@@ -111,14 +127,18 @@ def check_package(path):
if set(observed) != set(declared): if set(observed) != set(declared):
_fail(f"{path}: missing declared file") _fail(f"{path}: missing declared file")
skill = _text(observed["SKILL.md"], "SKILL.md") skill = _text(observed["SKILL.md"], "SKILL.md")
match = re.match(r"\A---\r?\n(.*?)\r?\n---(?:\r?\n|\Z)", skill, re.S) match = re.match(r"\A---\n(.*?)\n---(?:\n|\Z)", skill, re.S)
if not match: if not match:
_fail(f"{path}: invalid SKILL.md frontmatter") _fail(f"{path}: invalid SKILL.md frontmatter")
frontmatter = match.group(1) frontmatter = match.group(1)
lines = frontmatter.split("\n")
# LF is the only line break: CR, CRLF, and other separators split differently.
if frontmatter.splitlines() != lines:
_fail(f"{path}: invalid SKILL.md frontmatter")
top_keys = [] top_keys = []
nested_keys = [] nested_keys = []
in_metadata = False in_metadata = False
for line in frontmatter.splitlines(): for line in lines:
if line.startswith(" "): if line.startswith(" "):
if not in_metadata or not re.fullmatch(r" [a-z-]+: .+", line): if not in_metadata or not re.fullmatch(r" [a-z-]+: .+", line):
_fail(f"{path}: unsupported skill metadata") _fail(f"{path}: unsupported skill metadata")
@@ -127,11 +147,15 @@ def check_package(path):
key = line.split(":", 1)[0] key = line.split(":", 1)[0]
top_keys.append(key) top_keys.append(key)
in_metadata = key == "metadata" in_metadata = key == "metadata"
# metadata stands alone; every other key carries an inline value.
valid_line = line == "metadata:" if in_metadata else bool(re.fullmatch(r"[a-z-]+: .+", line))
if not valid_line:
_fail(f"{path}: unsupported skill metadata")
else: else:
_fail(f"{path}: unsupported skill metadata") _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"}: 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"}:
_fail(f"{path}: unsupported skill metadata") _fail(f"{path}: unsupported skill metadata")
values = dict(line.split(": ", 1) for line in frontmatter.splitlines() if not line.startswith(" ") and ": " in line) values = dict(line.split(": ", 1) for line in lines if not line.startswith(" ") and ": " in line)
if "disable-model-invocation" in values and values["disable-model-invocation"] not in ("true", "false"): if "disable-model-invocation" in values and values["disable-model-invocation"] not in ("true", "false"):
_fail(f"{path}: disable-model-invocation must be a boolean") _fail(f"{path}: disable-model-invocation must be a boolean")
expected_name = path.name expected_name = path.name
@@ -139,7 +163,7 @@ def check_package(path):
_fail(f"{path}: missing or incompatible skill metadata") _fail(f"{path}: missing or incompatible skill metadata")
if not re.fullmatch(r"[a-z0-9]+(?:-[a-z0-9]+)*", expected_name) or len(expected_name) > 64 or len(values["description"]) > 1024: if not re.fullmatch(r"[a-z0-9]+(?:-[a-z0-9]+)*", expected_name) or len(expected_name) > 64 or len(values["description"]) > 1024:
_fail(f"{path}: skill name or description exceeds owner bounds") _fail(f"{path}: skill name or description exceeds owner bounds")
display_name = next(line.split(": ", 1)[1] for line in frontmatter.splitlines() if line.startswith(" relayview-display-name: ")) display_name = next(line.split(": ", 1)[1] for line in lines if line.startswith(" relayview-display-name: "))
if len(display_name) > 128: if len(display_name) > 128:
_fail(f"{path}: display name exceeds owner bounds") _fail(f"{path}: display name exceeds owner bounds")
digest = hashlib.sha256(b"relayview-instruction-package-v1\0" + _frame(raw_manifest)) digest = hashlib.sha256(b"relayview-instruction-package-v1\0" + _frame(raw_manifest))