Correct the playbooks where they disagree with the spec or the code
Before adoption: this commit came in with the history the project adopted, so no landing records it.
- add-operation gains a first step that pins the new contract in packages/protocol/test/contracts.test.ts and its example payload and success in test/contract-examples.ts (both from W2, issue 215), red by an assertion naming the tag; the old bullet pointed contract examples at test/examples.ts, which holds refusal examples and ids. - add-operation: a write is Idempotent when a replay converges, by a RequestId or by its nature (spec 3.2 marks claim, release and fork idempotent without one), not only when it takes a RequestId. - add-operation: Audience "decider" and Visibility "maintainers" only document; the logic refuses NotDecider and the handler leaves the fields out (spec 3.1). MCP filters by Surfaces from W2 (215), the CLI reads Cli and Surfaces from W4; cross-project reads come from the front-page projection (W3). - add-port cited RepoHost.push's doc comment for "not atomic"; push has none, RefOutcome's comment says it. - add-check-kind names the domain round-trip test (domain.test.ts, W2) and marks the gate's defaultMarkers in markers.ts as W4 (402), not W2. - add-refusal's render step gains its done-when, so every step ends on one as the provenance row says. - Tests: none; Markdown only. bun run fix and bun run verify pass.
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+27 added−20 removed
- other:+27 added−20 removed
Provenance
- Commit
233ebe9- Tree
8c7165e- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent
c7961d3
4 files changed+27 added−20 removed
modified:.agents/skills/add-check-kind/SKILL.md+5 added-5 removed
23 unmodified lines2425262728282930313213 unmodified lines464748495050515253545253545556575822 unmodified lines23 unmodified lines## 2. Add the schema member
Add a tagged member to `CheckSpec` in `packages/protocol/src/domain/check.ts` (from W2). Its fields are what the maintainer gives, never facts the platform derives. Wire fields follow AGENTS.md "Effect traps".
Done when a round-trip test of the new member passes, seen red first.Done when a round-trip test of the new member in `packages/protocol/test/domain.test.ts` (from W2) passes, seen red first.
## 3. Add the builder
Add `check.<kind>(…)` to `packages/sdk/src/index.ts` (from W2), returning plain data. Test it in `packages/sdk/test/sdk.test.ts`: build a config that uses it, and decode the result with `Policy`.13 unmodified linesDone when every step 1 case has a passing test here.
## 5. Teach the gate
In `packages/gate/src/` (from W2):In `packages/gate/src/`:
- how a failure of this kind classifies in `classify.ts`: failed checks, a flake, a blocked verifier or a stale base;- if the kind counts something, its ratchet in `stages/ratchet.ts`;- if an answer could weaken it with a marker (a disable comment), that marker in the default weakening markers.- how a failure of this kind classifies in `classify.ts` (from W2): failed checks, a flake, a blocked verifier or a stale base;- if the kind counts something, its ratchet in `stages/ratchet.ts` (from W2);- if an answer could weaken it with a marker (a disable comment), that marker in `defaultMarkers` in `markers.ts` (from W4).
Done when gate tests cover the kind's classification, and each marker or ratchet it adds refuses a weakened answer with `Weakened`.
## 6. Show it in an example22 unmodified linesmodified:.agents/skills/add-operation/SKILL.md+19 added-14 removed
7 unmodified lines89101112121314151617181920212223242526212728293031262728323334353036373238393440413642434445464742484950515253485455565752585960616263596465666768696570717273746 unmodified lines7 unmodified linesAn operation is one contract: an `Rpc` in the one schema. Every surface is a projection of it (principle 4), so the work is the contract, its server logic and its tests; the surfaces follow from its annotations.
A step marked "from W<n>" names code a later build wave adds. If that path is missing, use the stand-in the step names and say so in the report. `Rpc` and `RpcGroup` source is in `node_modules/effect/src/rpc/`; for Effect's own tests and examples, run `bash scripts/vendor-agent-sources.sh` and read `.agent_sources/effect`.
## 1. Define the contract## 1. Pin it in the group test
From W2, `packages/protocol/test/contracts.test.ts` pins every contract in a table: its tag in group order, its flags, audience and surfaces, and its error subset. Add the new contract's row there, and its example payload and success to `packages/protocol/test/contract-examples.ts` (both from W2; reuse the ids in `packages/protocol/test/examples.ts`). Run `npx vitest run test/contracts.test.ts` in `packages/protocol`.
Done when that test fails by an assertion that names the new tag. Before W2, `packages/protocol/test/annotations.test.ts` is the only group test: say so in the report.
## 2. Define the contract
- In `packages/protocol/src/contracts.ts`, write `export class <Name> extends Rpc.make("<tag>", { payload, success, error }) {}` and add it to `Contracts`' `RpcGroup.make(…)`. The tag is a camelCase verb: `listAsks`, `submitAnswer`.- Build the payload and the success from the branded ids in `packages/protocol/src/ids.ts` and the domain schemas in `packages/protocol/src/domain/` (from W2). The success is a `Schema.Struct`, because an MCP output schema needs an object at its root.- `error` is a `Schema.Union` of the refusals this contract can give, a subset of `Refusal` in `packages/protocol/src/refusal.ts`, so each handler stays exhaustive. A refusal the union lacks comes first, through the `add-refusal` skill. Leave out `Unauthenticated`: the `Authenticated` middleware adds it.- Every wire field follows AGENTS.md "Effect traps".
Done when `bun run typecheck` inside `packages/protocol` reports nothing but `Contracts.toLayer` calls that lack the new tag.
## 2. Annotate it## 3. Annotate it
Each annotation in `packages/protocol/src/annotations.ts` is a `Context.Reference` with a default, set with `.annotate(Key, value)` on the `Rpc`:
- `Description`: one sentence in `GLOSSARY.md` words. Every surface shows it.- `Audience`: `public`, `signedIn` or `decider`. Only a `public` contract will answer a caller with no credential (from W3).- `Visibility`: `maintainers` when the response may carry what a public reader must not see (principle 7).- `ReadOnly`, `Idempotent` and `Destructive`, each set explicitly. MCP treats a tool without hints as destructive. A write is `Idempotent` only when it takes a `RequestId` and a replay returns the same result (principle 8).- `Audience`: `public`, `signedIn` or `decider`. Only a `public` contract will answer a caller with no credential (from W3). `decider` only documents the rule: the logic checks the caller against the project's deciders and refuses with `NotDecider` (from W2), so list it in `error`.- `Visibility`: `maintainers` when the response may carry what a public reader must not see (principle 7). It only documents and keeps web caches off; the handler leaves those fields out for anyone who isn't a decider.- `ReadOnly`, `Idempotent` and `Destructive`, each set explicitly. MCP treats a tool without hints as destructive. A write is `Idempotent` only when a replay converges on the same result (principle 8): by a `RequestId`, as `submitAnswer` does, or by its nature, as a holder's re-claim returns the same claim.- `NeedsApproval` when a person must confirm. The CLI then asks for `--yes` (from W4).- `Cli` (its command name and positionals) and `Surfaces` (which of `rpc`, `mcp`, `cli` and `web` serve it). The projections read both from W4.- `Cli` (its command name and positionals) and `Surfaces` (which of `rpc`, `mcp`, `cli` and `web` serve it). MCP is filtered by `Surfaces` from W2, and the CLI reads both from W4.
Done when `packages/protocol/test/annotations.test.ts` passes with the new contract in the group.Done when `packages/protocol/test/annotations.test.ts` and step 1's test pass with the new contract in the group.
## 3. Write the server logic, then the handler## 4. Write the server logic, then the handler
- The logic lives in the owning package, never in the app (principle 6): a method on `ProjectApi` in `packages/project/src/project.ts` (from W2), tested over `/memory` adapters in `packages/project/test/`.- The logic lives in the owning package, never in the app (principle 6): a method on `ProjectApi` in `packages/project/src/project.ts` (from W2), tested over `/memory` adapters in `packages/project/test/`. A read across every project comes from the front-page projection instead (from W3).- The handler in `apps/platform/src/handlers.ts` (from W3; until then `apps/platform/src/vacant.ts`) stays thin. It resolves the project, calls it, and fails only with the contract's own refusals.- `Contracts.toLayer` must name every tag, so each call gains a handler for the new one: the platform's, and the stand-ins tests build (as in `packages/protocol/test/mcp.test.ts`). `bun run typecheck` lists every call that lacks it.
Done when `bun run typecheck` passes and the logic's tests are green.
## 4. Check the projections## 5. Check the projections
Projections live only in `packages/protocol/src/{cli,mcp}.ts` and `apps/*/src/surfaces.ts` (principle 4). They read the group and its annotations, so a new contract usually needs no edit there. Touch `apps/platform/src/surfaces.ts` or `apps/cli/src/surfaces.ts` only for what the group can't express, such as a stream's route.
Done when you can name each surface that serves the contract, and the annotation that put it there.
## 5. Test every surface it is on## 6. Test every surface it is on
Write each test red first: watch it fail by an assertion, then make it pass (the `tdd` skill).
- Add example payload and success values to `packages/protocol/test/examples.ts`.- MCP: `tools/list` shows the tool with its hints, and `tools/call` returns its success and a refusal as typed JSON (`packages/protocol/test/mcp.test.ts`).- CLI: the command takes the payload as flags and prints the success (`packages/protocol/test/cli.test.ts`).- RPC: `apps/platform/test/surfaces.test.ts` calls it as the person a bearer token names.
Done when every surface in `Surfaces` has a test that fails without the contract.
## 6. Regenerate the reference## 7. Regenerate the reference
Run `bun run gen` and commit what it writes under `docs/reference/`. Those files come only from the schema; `gen:check` compares them with it.
Done when `bun run gen:check` passes.
## 7. Gate## 8. Gate
`bun run fix`, then `bun run verify`; fix the cause, never weaken the fence.
## Report6 unmodified linesmodified:.agents/skills/add-port/SKILL.md+1 added-1 removed
23 unmodified lines24 - `export class <Port> extends Context.Service<<Port>, { readonly <op>: (…) => Effect.Effect<A, E> }>()("<pkg>/<Port>") {}`;25 - its errors as `Schema.TaggedError` classes beside it, named for what went wrong in the job (`RepoNotFound`, `HostBusy`). Map the vendor's errors to them inside each adapter;26 - its values as Schemas or branded types, so a caller needs no vendor package to use it.27 28-Keep the operations few and named for what callers need. Say in each doc comment what is idempotent and what is not atomic, as `RepoHost.push` does.28+Keep the operations few and named for what callers need. Say in a doc comment what is idempotent and what is not atomic, as `RefOutcome` says a `RepoHost.push` is never atomic across refs.29 30 Done when the port file imports no adapter.31 32 ## 3. Write the contract suite, one case at a time39 unmodified linesmodified:.agents/skills/add-refusal/SKILL.md+2 added
39 unmodified lines40 ## 4. Render it41 42 Add its reason to `reason` in `packages/protocol/src/render.ts`: a lowercase clause, shown on git's `remote:` lines, in the CLI and in MCP text. `protocol/render` is the one renderer, and `Match.typeTags` makes typecheck name a missing reason.43 44+Done when `bun run typecheck` inside `packages/protocol` passes.45+46 ## 5. Add its example47 48 Add one instance to `examples` in `packages/protocol/test/examples.ts`, in union order. The round-trip, render and group tests then cover it.49 27 unmodified lines