diff --git a/OVERRIDING.md b/OVERRIDING.md new file mode 100644 index 0000000..3f88f91 --- /dev/null +++ b/OVERRIDING.md @@ -0,0 +1,328 @@ +# Overriding RelayView role skills + +RelayView gives each agent role the first-party packages in this repository as +its default instructions. This guide shows which package each role runs, what +a replacement package can change, what RelayView's owner enforces regardless of +any package, and how to publish a fork that the owner admits. + +RelayView's own documentation and admission checks stay authoritative. This +guide describes the owner behavior that RelayView documents as current, and +labels planned behavior as proposed. The +[instruction package contract](docs/authoritative/instruction-package-contract.md) +gives every file, sidecar, and frontmatter rule the local checks enforce. + +## Role matrix + +A package declares one `role` and its one `step`. Schema 3 packages carry +`treatment: "communication_context"`; schema 2 is the Planner's issue-claim +schema. RelayView's maintained deployment assigns the automatic defaults below, +in launch order. + +| Role | `role` / `step` | Schemas | `communication_context` | RelayView admission | Maintained automatic default (launch order) | Other first-party packages | +| --- | --- | --- | --- | --- | --- | --- | +| Specification Designer | `designer` / `design` | 1 | No (schema 3 is rejected) | Admitted | `issue-designer-default` (pinned) | Manual: `designer-wayfinder`, `designer-grilling`, `designer-research`, `designer-domain-modeling`, `designer-triage`, `designer-to-spec`, `designer-to-tickets`, `designer-prototype`; none is assigned until the Operator selects it | +| Technical Coordinator | `coordinator` / `coordination` | 1, 3 | Yes | Not yet admitted | None | None published | +| Planner | `planner` / `planning` | 1, 2, 3 | Yes | Admitted | `planner-investigation`, `planner-scope`, `planner-communication`, `research-auto` | Automatic: `codebase-design`. Manual: `grill-me`, `grilling`, `improve-codebase-architecture`, `research`, `to-questionnaire` | +| Implementer | `implementer` / `implementation` | 1, 3 | Yes | Admitted | `implementer-investigation`, `implementer-handoff`, `implementer-communication` | Automatic: `tdd-auto`, `diagnosing-bugs`, `domain-modeling`. Manual: `tdd`, `pr`, `prototype`, `migrate-to-shoehorn`, `scaffold-exercises`, `shared-abstraction-refactor`, `split-large-files`, `writing-for-agents` | +| Reviewer | `reviewer` / `review` | 1, 3 | Yes | Admitted | `reviewer-investigation`, `code-review-auto`, `reviewer-communication` | Manual: `code-review`, `c4-diff` | +| Tester | `tester` / `testing` | 1, 3 | Yes | Not yet admitted | None | None published | + +RelayView calls the Designer role the Specification Designer; the current +default package keeps its earlier ID, `issue-designer-default`. RelayView's +Tester runs today without skill assignment, and RelayView has no Technical +Coordinator role yet. This repository already validates both pairs, so a fork +can be prepared, but RelayView refuses `tester` and `coordinator` packages +until it adopts them; the +[contract](docs/authoritative/instruction-package-contract.md#relayview-adoption-of-the-tester-and-coordinator-pairs) +lists the proposed releases and the owner changes each pair needs. + +Optional automatic packages such as `tdd-auto` run only when an Operator adds +them to the role's automatic assignment. Manual packages run only when an +Operator sends `/skill:` to a session that has them assigned. + +## Package matrix + +Mode comes from the `SKILL.md` frontmatter: `disable-model-invocation: true` +makes a package manual. Release is the sidecar's `source.reference`, the tag +whose bytes RelayView pins for that package. + +| Package | Role / step | Mode | Schema | Sidecar extra | Version | Release | RelayView maintained default | +| --- | --- | --- | --- | --- | --- | --- | --- | +| `issue-designer-default` | `designer` / `design` | automatic | 1 | — | 0.13.0 | `v0.13.0` | Pinned Designer default | +| `designer-domain-modeling` | `designer` / `design` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `designer-grilling` | `designer` / `design` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `designer-prototype` | `designer` / `design` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `designer-research` | `designer` / `design` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `designer-to-spec` | `designer` / `design` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `designer-to-tickets` | `designer` / `design` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `designer-triage` | `designer` / `design` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `designer-wayfinder` | `designer` / `design` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `planner-investigation` | `planner` / `planning` | automatic | 1 | — | 0.13.0 | `v0.13.0` | Planner automatic, 1st | +| `planner-scope` | `planner` / `planning` | automatic | 2 | `issueClaim: status/in-progress` | 0.13.0 | `v0.13.0` | Planner automatic, 2nd | +| `planner-communication` | `planner` / `planning` | automatic | 3 | `communication_context` | 0.14.0 | `v0.14.0` | Planner automatic, 3rd | +| `research-auto` | `planner` / `planning` | automatic | 1 | — | 0.13.0 | `v0.13.0` | Planner automatic, 4th | +| `codebase-design` | `planner` / `planning` | automatic | 1 | — | 0.13.0 | `v0.13.0` | No | +| `grill-me` | `planner` / `planning` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `grilling` | `planner` / `planning` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `improve-codebase-architecture` | `planner` / `planning` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `research` | `planner` / `planning` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `to-questionnaire` | `planner` / `planning` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `implementer-investigation` | `implementer` / `implementation` | automatic | 1 | — | 0.13.0 | `v0.13.0` | Implementer automatic, 1st | +| `implementer-handoff` | `implementer` / `implementation` | automatic | 1 | — | 0.13.0 | `v0.13.0` | Implementer automatic, 2nd | +| `implementer-communication` | `implementer` / `implementation` | automatic | 3 | `communication_context` | 0.13.0 | `v0.13.0` | Implementer automatic, 3rd | +| `diagnosing-bugs` | `implementer` / `implementation` | automatic | 1 | — | 0.13.0 | `v0.13.0` | No | +| `domain-modeling` | `implementer` / `implementation` | automatic | 1 | — | 0.13.0 | `v0.13.0` | No | +| `tdd-auto` | `implementer` / `implementation` | automatic | 1 | — | 0.13.0 | `v0.13.0` | No | +| `migrate-to-shoehorn` | `implementer` / `implementation` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `pr` | `implementer` / `implementation` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `prototype` | `implementer` / `implementation` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `scaffold-exercises` | `implementer` / `implementation` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `shared-abstraction-refactor` | `implementer` / `implementation` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `split-large-files` | `implementer` / `implementation` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `tdd` | `implementer` / `implementation` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `writing-for-agents` | `implementer` / `implementation` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `reviewer-investigation` | `reviewer` / `review` | automatic | 1 | — | 0.13.0 | `v0.13.0` | Reviewer automatic, 1st | +| `code-review-auto` | `reviewer` / `review` | automatic | 1 | — | 0.13.0 | `v0.13.0` | Reviewer automatic, 2nd | +| `reviewer-communication` | `reviewer` / `review` | automatic | 3 | `communication_context` | 0.13.0 | `v0.13.0` | Reviewer automatic, 3rd | +| `c4-diff` | `reviewer` / `review` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | +| `code-review` | `reviewer` / `review` | manual | 1 | — | 0.13.0 | `v0.13.0` | No | + +`tests/test_overriding.py` fails when this table disagrees with a package's +sidecar or frontmatter. + +## What a skill controls and what the owner enforces + +A package is model-facing text. It changes how an agent works inside its role; +it never changes what the role may do. A package that requests tools, +permissions, network access, or scripts fails both the local check and owner +admission. + +| Concern | A skill can customize | RelayView's owner enforces regardless of skill prose | Owner rule status | +| --- | --- | --- | --- | +| Tools, network, credentials | Which assigned tools to reach for, and in what order | Each role's tool allowlist, network policy, filesystem confinement, and credentials come from its owner capability profile | Current | +| Which instructions load | Its own text and declared resources | Ambient skill discovery is off; only admitted packages are captured, and their bytes and package identity are verified before every launch | Current | +| Specification work | Interview style, question order, method entry, draft shape | Publication, the method-entry gate, and Operator acceptance of a specification | Current | +| Planning and investigation | Investigation methods, scope analysis, research method, Plan presentation | Plan authority, finalization schemas, validation-manifest adoption, research budgets and tool contracts | Current | +| Issue claim | Nothing in prose | The schema-2 `issueClaim` sidecar value selects the claim; the owner validates and performs the Gitea change after proved implementation handoff | Current | +| Implementation handoff | Change focus, clarification cadence, documentation-writing technique | Report fields, documentation disposition, evidence submission, clean committed candidates, stop rules | Current | +| Review | Finding presentation and inspection techniques | Exact-candidate scope, dispositions, correction routing, review and merge gates | Current | +| Communication | Tone, detail, examples, acknowledgements | Publication identity and order, mandatory status, complete durable artifacts; communication packages load only when the frozen `communication_context` treatment is on | Current | +| Manual methods | When a method is worth invoking | `/skill:` reaches a session only if that name is in its captured assignment | Current | +| Acceptance | Nothing | Operator acceptance requires a person | Current | +| Coordination | Wave-selection and contention heuristics, Control Tower reporting tone | Dispatch authority, resource leases, nudge budgets and cooldowns | Proposed | +| Review tiers | How to frame a risk or escalation summary | Repository trust ceiling (Layer A), the Operator's per-specification stamp (Layer B), and the one-way escalation ratchet with typed reasons (Layer C): no agent may downgrade `operator_review_required` | Proposed | + +Proposed rows come from RelayView's coordinator and verification operating +model, which RelayView documents as speculative architecture. Do not rely on +an owner rule marked Proposed; until RelayView ships it, a package cannot +assume it. + +Existing sessions keep the bytes they captured at launch. A new selection +affects only future sessions. + +## Fork and override recipe + +This example forks `planner-scope` as `team-planner-scope`. Substitute your +own package and name throughout. + +1. **Copy the package under a distinct name.** The directory name, the + frontmatter `name`, and the RelayView import ID must all be equal and must + differ from every first-party ID; RelayView never lets a configured or + imported package overwrite an admitted ID. + + ```sh + cp -R packages/planner-scope team-planner-scope + ``` + +2. **Edit the frontmatter.** Set `name: team-planner-scope`, give it your own + `relayview-display-name` and `relayview-version`, and keep + `disable-model-invocation` as it is unless you mean to change the mode. + Then edit the instructions and resources. + +3. **Edit the sidecar.** Set `"source": {"kind": "user", "reference": + "team-planner-scope-1.0.0"}`. Keep `role`, `step`, and `schemaVersion`. + - A Planner scope fork keeps `schemaVersion: 2` and its `issueClaim` object + if it should keep the owner's linked-issue claim; schema 1 declares no + claim, and the owner then claims nothing. An automatic Planner assignment + may contain only one schema-2 package. + - A communication fork keeps `schemaVersion: 3` and + `"treatment": "communication_context"`, so RelayView keeps applying the + communication treatment boundary to it. + - Add any new resource to `files`; every file in the directory except the + sidecar must be declared. + +4. **Recalculate the SHA-256 digests.** This rewrites every `files[].sha256` + from the current bytes: + + ```sh + python3 - team-planner-scope <<'EOF' + import hashlib, json, sys + from pathlib import Path + package = Path(sys.argv[1]) + sidecar = package / "relayview-skill.json" + manifest = json.loads(sidecar.read_text()) + for item in manifest["files"]: + item["sha256"] = hashlib.sha256((package / item["path"]).read_bytes()).hexdigest() + sidecar.write_text(json.dumps(manifest, indent=2) + "\n") + EOF + ``` + +5. **Check and pack it.** `check` prints the package identity the owner will + record; `pack` writes a reproducible archive and prints its SHA-256. + + ```sh + python3 -m tools.packages check team-planner-scope + python3 -m tools.packages pack team-planner-scope dist/team-planner-scope.zip + ``` + + Preserve `LICENSE` and `NOTICE.md` when you redistribute a fork; the archive + includes both. + +6. **Install it.** Copy the package directory under the owner's configured + `trustedSkills.root`, which must not contain or sit inside any target + repository. + +7. **Import it in RelayView Settings → Skills.** Enter the ID + `team-planner-scope` and the path `team-planner-scope/SKILL.md`, relative + to the trusted root. Import requires `source.kind: "user"`, validates the + package, and records its digest; it does not assign it. To change a + package after import, publish it under a new ID. + +8. **Assign it.** + - **Planner, Implementer, Reviewer:** add the ID to a named set in + `trustedSkills.sets` with the matching `role`, `step`, and + `invocationMode`, restart the owner to load the set, then select the set + for the role in Settings → Skills and save. A saved automatic set + replaces the whole automatic assignment: list every package the role + should still run. + + ```yaml + trustedSkills: + sets: + - id: team-planning + name: Team planning + role: planner + step: planning + invocationMode: automatic + members: [planner-investigation, team-planner-scope, planner-communication, research-auto] + ``` + + - **Specification Designer:** select the imported package in the + Specification Designer card, as the default (an automatic package) or as + an optional method (a manual package), and save. No named set or restart + is needed. + +New sessions for that role use the fork; existing sessions keep their +captured packages. + +## Release identity + +A release tag pins public source. Published tags are never moved or rebuilt: a +change to any package byte ships under a new tag, and RelayView keeps every +earlier bundle so retained sessions can reconstruct their exact packages. + +RelayView copies a release into `first-party-skills//` with a +`bundle-lock.json` recording the source repository, the release tag and +commit, each package's identity and archive SHA-256, and the SHA-256 of every +bundled file, including `LICENSE` and `NOTICE.md`. RelayView's +`npm run verify:first-party-skills-source` recomputes those values from the +tagged source and fails on any difference. To recompute them yourself, for +example for `planner-communication` at `v0.14.0`: + +```sh +git fetch --tags origin +git switch --detach v0.14.0 +python3 -m tools.packages check packages/planner-communication +python3 -m tools.packages pack packages/planner-communication dist/planner-communication.zip +git switch main +``` + +The two printed digests match the `identity` and `archiveSha256` recorded for +`planner-communication` in RelayView's `first-party-skills/v0.14.0/bundle-lock.json`. +A fork's changed `source` gives it a distinct identity even when its +instructions match a first-party package, so a bundled update never replaces +a fork. + +## Layer-4 authoring template + +RelayView follows a trust pyramid for recurring defects: correct them as low +as possible, and write a skill only for a judgment call nothing lower can +decide. + +1. **Architecture and APIs** — a boundary that makes the failure impossible. +2. **Static checks and fast tests** — a lint rule with a root-cause message, a + type constraint, an import fence, or a regression test. +3. **Verification harness** — a feature map entry, verification driver, + property test, or formal check. +4. **A role skill** — judgment that cannot be checked deterministically. + +RelayView's proposed Guardrail Proposal loop would draft layer 1–3 tasks or a +candidate layer-4 skill when a defect escapes, and would activate a skill only +on explicit Operator approval. Until RelayView ships it, an Operator activates +a layer-4 skill through the [fork and override recipe](#fork-and-override-recipe). + +Before writing a layer-4 skill, confirm each item: + +- [ ] No architecture change, lint rule, type, test, or harness check can catch + this failure class; if one can, put the correction there instead. +- [ ] The guidance concerns a judgment the role makes, not a tool, permission, + gate, or schema the owner controls. +- [ ] It names one role and step, and adds no instruction an existing package + in that assignment already gives. + +Start from this template. Replace each `<...>` with your text, keep the +frontmatter keys exactly as shown, and set `role` and `step` in the sidecar to +the one pair the guidance serves. + +```markdown +--- +name: team-review-judgment +description: Weigh when reviewing the assigned candidate. +metadata: + relayview-display-name: Team review judgment + relayview-version: 1.0.0 +--- + +# Team review judgment + +Use this guidance when , which no check in the repository decides. + +## Decide + +1. Gather , reading them from . +2. Weigh ; tips it toward . +3. Report the decision, its reason, and the evidence you read. + +## Check before finishing + +- +``` + +```json +{ + "schemaVersion": 1, + "source": { + "kind": "user", + "reference": "team-review-judgment-1.0.0" + }, + "role": "reviewer", + "step": "review", + "files": [ + { + "path": "SKILL.md", + "sha256": "" + } + ] +} +``` + +After writing it, confirm each item: + +- [ ] Each instruction states an action and a check the agent can run on its + own result, rather than only what to avoid. +- [ ] The text claims no tool, permission, network access, workflow authority, + or owner schema, and does not restate owner-enforced rules. +- [ ] The guidance changed behavior across several runs, judged from each + run's tool calls, not one successful conversation. +- [ ] `python3 -m tools.packages check ` passes after recalculating + the digest. diff --git a/README.md b/README.md index e307ae6..97f9976 100644 --- a/README.md +++ b/README.md @@ -4,36 +4,7 @@ Public source for RelayView-maintained instruction-only role skills and an illus ## Packages and support -| Directory | Status | Role / step | Version | -| --- | --- | --- | --- | -| `packages/{planner,implementer,reviewer}-investigation` | Maintained automatic guidance | One matching role / step each | 0.13.0 | -| `packages/planner-scope` | Maintained default | Planner / planning | 0.13.0 | -| `packages/implementer-handoff` | Maintained default | Implementer / implementation | 0.13.0 | -| `packages/issue-designer-default` | Maintained default | Designer / design | 0.13.0 | -| `packages/designer-wayfinder`, `designer-grilling` | Optional manual guidance | Designer / design | 0.13.0 | -| `packages/designer-prototype` | Optional manual guidance | Designer / design | 0.13.0 | -| `packages/designer-research`, `designer-domain-modeling`, `designer-triage` | Optional manual guidance | Designer / design | 0.13.0 | -| `packages/designer-to-spec`, `designer-to-tickets` | Optional manual guidance | Designer / design | 0.13.0 | -| `packages/codebase-design` | Optional guidance | Planner / planning | 0.13.0 | -| `packages/grill-me` | Optional guidance | Planner / planning | 0.13.0 | -| `packages/grilling` | Optional guidance | Planner / planning | 0.13.0 | -| `packages/to-questionnaire` | Optional guidance | Planner / planning | 0.13.0 | -| `packages/research` | Optional guidance | Planner / planning | 0.13.0 | -| `packages/improve-codebase-architecture` | Optional guidance | Planner / planning | 0.13.0 | -| `packages/diagnosing-bugs` | Optional guidance | Implementer / implementation | 0.13.0 | -| `packages/domain-modeling` | Optional guidance | Implementer / implementation | 0.13.0 | -| `packages/migrate-to-shoehorn` | Optional guidance | Implementer / implementation | 0.13.0 | -| `packages/pr` | Optional guidance | Implementer / implementation | 0.13.0 | -| `packages/prototype` | Optional guidance | Implementer / implementation | 0.13.0 | -| `packages/scaffold-exercises` | Optional guidance | Implementer / implementation | 0.13.0 | -| `packages/shared-abstraction-refactor` | Optional guidance | Implementer / implementation | 0.13.0 | -| `packages/split-large-files` | Optional guidance | Implementer / implementation | 0.13.0 | -| `packages/tdd` | Optional manual guidance | Implementer / implementation | 0.13.0 | -| `packages/tdd-auto` | Optional automatic guidance | Implementer / implementation | 0.13.0 | -| `packages/writing-for-agents` | Optional guidance | Implementer / implementation | 0.13.0 | -| `packages/code-review` | 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 | +[OVERRIDING.md](OVERRIDING.md) lists every package with its role and step, automatic or manual mode, schema, version, and release, and marks the defaults RelayView assigns to each role. It also separates what a package can change from what RelayView's owner enforces, and gives the recipe for publishing and assigning a fork. `examples/starter-planner` is an illustrative Planner starter, not a production default. 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. @@ -68,9 +39,7 @@ python -m tools.packages pack examples/starter-planner dist/starter-planner.zip Replace `examples/starter-planner` in the last two commands with your package directory. The `pack` command writes a reproducible ZIP containing the package, `LICENSE`, and `NOTICE.md`, then prints its SHA-256. The check returns the owner's package identity digest. Both use only Python 3's standard library and this repository's source. Preserve the license and notice when redistributing the package or fork. -To use a user fork, place its closed package directory under the owner's configured trusted root. For Planner, Implementer, or Reviewer guidance, use Settings → Skills to import the relative `SKILL.md` path under a new unique ID. Import validates and records the package; it does not assign it. Add that ID to a role-compatible named set in the owner configuration and restart the owner to load the set. Then select the set for the matching role in Settings → Skills and save. For an optional Designer method, declare its ID and relative `SKILL.md` path in `trustedSkills.catalog`, list the ID in `workflowPresets.designerSkills`, and restart the owner. Designer has no Settings import or set selector for this assignment. These assignments affect future sessions; existing sessions retain their captured bytes. The owner's admission remains authoritative even when these local checks pass. - -To use a maintained Planner or Implementer default, copy its release package under the same trusted root, admit its `SKILL.md` through the owner catalog, then select it for its declared role in Settings. Settings import accepts user-source packages; configure first-party packages in the owner catalog. Select a fork with `source.kind: user` and a distinct ID to replace a Planner or Implementer future assignment. RelayView pins and assigns the Issue Designer default automatically; its optional methods use `workflowPresets.designerSkills`. Planner guidance uses existing read and planning tools; Implementer guidance uses existing implementation and reporting tools. Guidance selection does not change a role's tools, credentials, lifecycle stages, validation requirements, Gitea effects, review, merge, or Operator acceptance. The owner keeps the existing Gitea task workflow. +To replace a default or add guidance in RelayView, follow the [fork and override recipe](OVERRIDING.md#fork-and-override-recipe). Assignments affect future sessions; existing sessions retain their captured bytes. The owner's admission remains authoritative even when these local checks pass. Guidance selection does not change a role's tools, credentials, lifecycle stages, validation requirements, Gitea effects, review, merge, or Operator acceptance. ## Write the guidance @@ -84,7 +53,7 @@ Judge a change over several runs, using the tool calls each run made, not one su ## Release identity -A release tag pins public source. CI runs package checks and archives from that source. RelayView's bundled copy records the source tag and commit plus each package identity and file hash, then verifies the bytes in its own focused test. A bundled update creates a new release identity; it does not overwrite a user fork. +A release tag pins public source. CI runs package checks and archives from that source. RelayView's bundled copy records the source tag and commit plus each package identity and file hash, then verifies the bytes in its own focused test. A bundled update creates a new release identity; it does not overwrite a user fork. [OVERRIDING.md](OVERRIDING.md#release-identity) shows how to recompute a release's identity and archive digests and compare them with RelayView's `bundle-lock.json`. The MIT license covers this repository only. The contribution policy is in [CONTRIBUTING.md](CONTRIBUTING.md); dependency notices are in [NOTICE.md](NOTICE.md). diff --git a/tests/test_overriding.py b/tests/test_overriding.py new file mode 100644 index 0000000..ac12b08 --- /dev/null +++ b/tests/test_overriding.py @@ -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("", digest)) + check_package(package) + manifest = json.loads((package / "relayview-skill.json").read_text()) + self.assertEqual(manifest["source"]["kind"], "user") + + +if __name__ == "__main__": + unittest.main()