Repository navigation
feat(mcp): Patchy reads and enforces read-only actions and agent tools before anything writes them - #868
Conversation
Review: GPT-6.1-Sol (xhigh), two roundsRound 1, on 2d7355f. Nothing blocking. Checked: every descriptor reader (CLI and guest, instance inspection, execution loader, stored-row decode, Runtime, Serving); write paths a read-only action could take (integrations, file adoption,
Then a local run of the rehearsal's agent-area path caught a fixture bug: the forced write returned Round 2, on 6bac01d. Nothing blocking.
Commit ids above predate the rebases onto d4d6ed7 and 5f474a6: 2d7355f → 972f904, 5daebd8 → 200bcf3, 6bac01d → b25c549, 421a51d → 1a86c18. Head is now 4e5b744: a docs reflow, plus |
421a51d to
6fc68aa
Compare
…s before anything writes them Handler descriptors gain an optional description on handlers and values, readOnly on actions, and the agentTool mark on agent.* handlers. Every reader decodes them through the shared schema, and absent fields stay omitted, so every bundle published today loads unchanged. A read-only action's invocation capability carries its flag: the callback gate refuses its table and file writes, and nested admission refuses its mutations and actions. Postgres already runs inside BEGIN READ ONLY. Runtime refuses a marked agent tool on any call from a page, nested calls included; whether a call came from an agent is the binding's own field, never set yet. The rollback rehearsal also runs when descriptors or what the CLI writes into them change. Once HEAD's CLI writes read-only actions, step 2 publishes a tier 2 patch with one and an agent tool, and the live release must serve it and enforce both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hanges Co-Authored-By: Claude Opus 5.5 <[email protected]>
…checks Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ady recorded as refused Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…vents, as #865 asks Co-Authored-By: Claude Opus 5.5 <[email protected]>
6fc68aa to
4e5b744
Compare
Acceptance: PASS with notesChecked Done means
Golden journeys
Rollback answers: match the diff. This is the reader/enforcer release; rolling back past it remains safe only before a subsequent release writes the new fields. A later writer release must retain this release as its rollback floor. Evidence Local focused command: pnpm exec vitest run packages/api/src/handlers.test.ts packages/execution/src packages/runtime/src packages/patches/src/PatchesApi.test.ts packages/primitives/src packages/integrations/src/postgresIndependent HTTP and CLI resultsEvery environment CLI invocation used All checks reported by Surfaces exercised: the wire schema and readers, runtime capability/callback/nesting rules, stored manifest and bundle agreement, existing scripted tiers, CLI publishing and reverse states. Reviewed the generated API documentation, runtime vocabulary, rehearsal and CI trigger. No migration or company-resource locking change applies. Not run
Notes
Evidence screenshots contain only invented Brightline scenario data. |
…874) ## What changed Release 16's What's new entry, written from `dd3f41f`. It covers everything merged since release 15's `through` (`9e4b0df`), and sets the `patchy` release to `0.16.0` (`packages/patchy/package.json` and `CURRENT_RELEASE`). | Change | PRs | | --- | --- | | Fixed: Revoke all machines stops logins still on their way | #867 | | Behind the scenes: `mcp` and `oauth` kept off company addresses | #863 | | Behind the scenes: read-only actions and agent tools understood and enforced before anything writes them | #868 | | Behind the scenes: logs record how long a tool's server takes to start | #865 | #814 is release 15's own entry, so it's left out. #818 and #831 are docs (Patchy is live; the Patchy MCP spec) and #864 is dev tooling, so none of them gets a line. ## Look at - **The entry**, at the top of `releases` in `packages/core/src/whatsNew.ts`. #867 is the only change a person could notice. The page's button is still labelled "Revoke all machines" (Disconnect everything is the spec's future name), so the entry uses that label. - **Rollback safety, from the live commit `d77baaf` to `dd3f41f`.** No PR in the range is labelled `one-way`, and every PR answers both Release impact questions with "Yes". - #867 is the only migration: `0019_credentials_ended` adds two nullable columns, `users.credentials_ended_at` and `device_logins.confirmed_at`. At `d77baaf`, every insert into `users` and `device_logins` lists its columns, and nothing reads either table with `SELECT *`. - `rollback-rehearsal` passed on #863, #865, #867 and #868. #868's run covered #867's migration already on main: `Exercised rollback paths passed: d77baaf → ffe9988 → d77baaf`. - A rollback would reopen what #867 closes: an approved login that hasn't finished could again get past Revoke all machines. It would also let new companies take the `mcp` and `oauth` addresses (#863). No release that writes read-only actions or agent tools has shipped, so going back past #868 leaves nothing behind. ## How it was verified - `vitest run packages/core/src/whatsNew.test.ts packages/api/src/schemas.test.ts`: 14 passed. - `pnpm typecheck`: 23 of 23 tasks pass. Prettier and eslint are clean on the changed files. - The live commit was pinned from `/healthz/deep` (`d77baaf`, release 15). The Deploy run updated last succeeded, and none is unfinished. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required The changelog text plus the `patchy` version bump. A CLI installed before this deploy is told to upgrade, as with every release. - **What does a revert leave behind?** Nothing. People whose seen marker reached 16 would just see no new release. - **Does the release before it still work with that?** Yes. If this release misbehaves, roll back to `d77baafcf10c7cdf28c71bd65ea1a0009aa99ced` (release 15). Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code. Co-authored-by: Claude Opus 5.5 <[email protected]>
…869) Bottom of #833's stack (#839–#860), now on `main` since #837 merged as #868. It merges with the rest of the stack, not alone. ## What changed Builder agents can now say what each handler and value is for, and declare an action that only reads. `action({ readOnly: true, … })` gives the handler a context with no writes. Patchy refuses a write forced past the types. The published manifest carries the flag and every description. Nothing requires a description yet; agent tools will (#842). Closes #839 ## Look at **1. A read-only action's context has no writes.** Part of the compile-only checks in `packages/patchy/src/server.types.ts`. Every `@ts-expect-error` holds, so each write is a type error: ```ts export const peek = action({ readOnly: true, description: "Counts leads and totals sales without changing anything.", args: { stage: t.enum(["open", "closed"]).describe("Which leads to count.") }, result: t.object({ count: t.integer().describe("Matching leads."), total: t.number() }), handler: async (ctx, args) => { await ctx.files.documents.get("invoice.pdf"); // reads stay await ctx.connections.sales.query("select …"); // connections stay await ctx.run.leads.list({ stage: null }); // queries stay // @ts-expect-error a read-only action cannot insert rows await ctx.tables.leads.insert({ name: "forbidden" }); // @ts-expect-error a read-only action runs queries only, never mutations void ctx.run.leads.save({ name: "forbidden" }); … ``` `readOnly: true` on a query or mutation is a type error, and the descriptor schema refuses it at build and inspection. At runtime the guest still hands a read-only action an action's table object. That way a forced `ctx.tables.notes.insert` reaches #837's gate and gets `access_denied` (`InvocationLocal.test.ts`, now with SDK-built handlers). The rollback rehearsal's step 2 needs exactly that. **2. One description check, run on what inspection returns.** `descriptionProblem` in `packages/api/src/handlers.ts` returns a structured `DescriptionProblem`, and `descriptionRefusal` says it. They run in three places: the CLI's build, dev rebuilds and the instance's publish. Each runs on the descriptors inspected from the bundle, and each refusal is `invalid_manifest` naming the handler, the value and the fix. The CLI's also names the file, as the spec's Checks paragraph asks; the instance's comes from `InvalidHandlerDescription`: ``` server/leads.ts: leads.read's description of result is 2,001 characters; descriptions are at most 2,000. Shorten it. The last successful binding stays served. demo.find's description of args.name is blank. Say what it holds, or remove its .describe(). ``` The SDK builders don't refuse at construction. Inspection runs the bundle in workerd and reports only "could not be loaded", so a throw from `.describe()` would hide the fix. A blank literal is still a type error (`NonEmptyString`, as for table descriptions). Length is counted in code points, like a patch description. **3. Columns take no description.** `.describe()` turns a column into a handler value, so `table()` refuses it by type. Config execution refuses one forced past the types: `Column "title" of table "notes" has .describe(), but table columns take no description. Remove .describe(), and say what the column holds in the table's description.` When a nullable wrapper and its value are both described, the descriptor keeps both. The JSON Schema mapping in #842 shows the outer one; the skill states the rule. ## How it was verified - Typecheck of `api`, `patchy`, `sdk`, `patches` and `runtime`, plus `tsconfig.test.json`. `server.types.ts` and `config.types.ts` hold the type-level Done means: the read-only context, the flag refused on queries and mutations, blank literals, and described columns, defaults and refs. - `vitest`: `api` (the shared check: blank, 2,001 code points, nested paths), `patchy/server.test.ts` (descriptors written, absent fields omitted, the flag refused past the types), `executeConfig.test.ts` (the described-column refusal), `devServerWatch.test.ts` (a dev rebuild refuses and recovers), `PatchesApi.test.ts` (an SDK-built read-only action publishes, and a hand-rolled publish with a bad description is refused at the instance), `InvocationLocal.test.ts`, `Inspection.test.ts`, `sdk`. - Rollback rehearsal: `main` now has #837 and #838, and against it all three steps pass: `pnpm test:rollback-rehearsal --live dd3f41f` gives `Exercised rollback paths passed: dd3f41f → 0cec8f4 → dd3f41f, in 188s.` This PR switches on step 2, which publishes a read-only action that forces a write. CI's run against production's d77baaf passes step 2 and fails step 3. d77baaf predates #837, so it answers the forced write with `handler_failed`. That's the gate #833 documents, and it stays red until `main` with #837 is deployed. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required The SDK fields are optional and additive. The new refusals apply only to descriptions, which nothing wrote before. - **What does a revert leave behind?** Versions whose stored descriptors carry `description` and `readOnly: true`. - **Does the release before it still work with that?** Yes, as long as it includes #837, which reads and enforces both fields. #833 releases this stack only after #837 is live. Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh).
) Stacked on #883 (ticket #851); merges with the rest of #833's stack, not alone. ## What changed A person's agent can now find their company's patches through Patchy's MCP and open one to see its agent tools. `find_patches` lists exactly the patches the person can open in the portal; `open_patch` answers one patch's own document. While the company's agent access is off, every tool call is refused and names the admins. Closes #852 ## Look at 1. **Visibility reuses the portal's rule.** `Catalogue.visible` is `Patches.read({ state: "live" })` through `Patches.Openability`, the same call the portal's All patches makes, then one new query, `Patches.agentToolSummaries`, for the current versions' tool marks and words. It doesn't load whole manifests and starts nothing. `apps/server/src/McpDoor.test.ts` checks it against the portal's own rendered list. It publishes through the API across sharing scopes (company, public), lifecycle states (live, retired, deleted, operator-disabled), a deactivated owner and a second company. Then it compares `/patches` with `find_patches` for an owning admin, a non-owning admin, a member and a member who owns only off patches. Every listed patch opens. Every other one, by name, id or address, gets the same refusal, and searching its name finds nothing. Making the door list off patches fails it, and four catalogue tests. 2. **Choices within the spec's words**, for Allison to see: - `search` matches when every word appears in the name, title, description or owner's name, ignoring case. - The cursor is base64url JSON `{ after: { tools, name, id }, search?, detail? }`: a keyset position, so a publish or retire between pages never repeats or skips one. It carries its search and detail, so `{ cursor }` alone continues a walk; a cursor sent with a different search or detail is refused `invalid_args`. A forged cursor only positions within the person's own list: pointing it at a hidden patch, another company's, or none gives the same page. - `patch` resolves an id first (ids never change), then a name through `Patches.resolveName`, so a former name follows its rename as the address does. An address must have this instance's origin and the person's company handle. Every miss is one `not_found` in the same words. - `actingFor` is `{ person, company }`, each cut at 200 characters. A find page is measured as it grows, so its compact JSON never passes 100,000 characters; a patch whose tools alone would pass it (only a version that skipped the publish check could) is listed with their names, or without them. `open_patch` refuses `too_large` past 64 KiB, which only a version that skipped the publish check could reach. - The `agent_access_off` refusal names where an admin turns it on and the active admins by name, nothing else. 3. **Events** gain `patchRef`, `catalogueTotal`, `catalogueListed`, `catalogueEndedEarly`, `catalogueSearched`, `catalogueDetail` and `catalogueContinued`, beside `patchId`, `versionId` and `resultBytes`. Never the search words or the cursor. ## How it was verified - `packages/mcp`: `Catalogue.test.ts` covers a narrower openability rule, order, 55 patches over two pages with a publish and a retire between them, the read cap with `detail: "tools"`, search, cursor tampering, bad arguments, resolution by name/id/address/former name, other instances' and companies' addresses, and the 64 KiB cap. `Door.test.ts` covers the agent access refusal for a member and an admin, with discovery and the tool list still working. The shared harness moved to `src/test/door.ts`. - `packages/patches`: `agentToolSummaries` by version. `packages/api`: summaries keep `open_patch`'s order. - `pnpm verify` on 90262f1: format, lint, typecheck, synth, postgres-concurrency, cli-smoke, tier2-smoke and browser passed. In `test`, 2237 of 2239 passed. The two that timed out under the machine's load are in packages this PR doesn't touch: `cliRepoBuild.test.ts` (30 s) and `SdkApi.test.ts` (5 s). Both pass alone, and in CI. Every CI check is green on 90262f1. clerk-live passed on a rerun: its two live tests had passed and only the cleanup sweep got a Clerk 404. - No migration, so `rollback-rehearsal` has nothing to rehearse. #837 (PR #868) and #838 (PR #867) are both on `main`. - Real clients against a dev instance, on the final head: Claude Code 2.1.308 through real consent, and Codex 0.163.0 with a minted token on both its revisions. Each found Ben's 56 patches over two pages (50 + 6), with `deal-desk` first as the one with agent tools, and opened it, by name and by address. With agent access off, each call was refused naming Ada Park, the admin. <details><summary>Real clients against a dev instance, transcripts</summary> A `pnpm dev up team` environment (Acme Co: Ada Park, admin; Ben Ortiz, member) with `deal-desk`, a tier 2 patch whose `agent/deals.ts` exports `listDeals` and `moveDeal`, and 55 static pages, `standup-week-01` to `-55`, all published by Ada. Every client ran as Ben from a temp dir outside `$HOME`, with only that invocation's MCP config. Tool results are cut to 220 characters here. ### Claude Code 2.1.308 through real consent `claude --setting-sources project --strict-mcp-config --mcp-config ./mcp.json`, then `/mcp` › Authenticate. A stub `xdg-open` on its `PATH` recorded the authorize URL instead of opening a browser. A headless Playwright browser signed in as Ben (`/dev/[email protected]&return=<authorize>`), saw the consent page below and pressed Allow: ~~~text consent <instance>/oauth/authorize — Connect Claude Code to Acme Co? returned to http://localhost:63680/callback?code=…&state=…&iss=<instance> Authentication successful | You can close this tab and return to Claude Code. ❯ /mcp ⎿ Authentication successful. Connected to patchy-dev-852. ~~~  Then `claude -p` with the same config: ~~~text tool_use mcp__patchy-dev-852__find_patches({}) -> {"actingFor":{"person":"Ben Ortiz","company":"Acme Co"},"total":56,"patches":[{"name":"deal-desk","description":"Track the sales team's open deals and move them through stages.","owner":"Ada Park","address":"<instance>/… tool_use mcp__patchy-dev-852__find_patches({"cursor": "eyJhZnRlciI6eyJ0b29scyI6ZmFsc2UsIm5hbWUiOiJzdGFuZHVwLXdlZWstNDkiLCJpZCI6IjhwdXU4d3FqbXhzbSJ9fQ"}) -> {"actingFor":{"person":"Ben Ortiz","company":"Acme Co"},"total":56,"patches":[{"name":"standup-week-50","description":"Team standup notes for week 50: what shipped and what is next.","owner":"Ada Park","address":"<instance>/… tool_use mcp__patchy-dev-852__open_patch({"patch": "deal-desk"}) -> {"name":"deal-desk","description":"Track the sales team's open deals and move them through stages.","owner":"Ada Park","address":"<instance>/acme/deal-desk","tools":[{"name":"listDeal… assistant: Acme Co has **56 patches**, and listing them took **2 pages**. I'm acting for Ben Ortiz. - **Page 1:** 50 patches, which were `deal-desk` and `standup-week-01` through `standup-week-49`. It returned a `next` cursor. - **Page 2:** 6 patches, `standup-week-50` through `standup-week-55`. It had no `next`, so that was the end. That adds up to the server's reported total of 56: one `deal-desk` plus 55 weekly standup notes. **Only one patch has agent tools: `deal-desk`**, owned by Ada Park. It tracks the sales team's open deals and moves them through stages. None of the 55 `standup-week-*` patches (also Ada Park's) have any agent tools, so I can't read or change them through Patchy. Ada Park would need to add tools for that. ### `deal-desk` tools 1. **`listDeals`** (read) - Lists the team's deals, newest first. - You can pass an optional `stage` to see only deals in that stage: `lead`, `proposal`, `negotiation`, `won` or `lost`. - Each deal comes back with its `id`, `company` (the customer), `stage`, `amount` (value in euros), `createdAt` and `updatedAt`. 2. **`moveDeal`** (change) - Moves one deal to a different stage and returns the updated deal. - It returns `null` if no deal has that id. - It needs both an `id` (taken from `listDeals`) and a target `stage` (same five options). - Any move is logged as Ben Ortiz, made through me. I only opened the patch. I haven't listed any deals or moved anything. ~~~ With agent access turned off at Company by Ada: ~~~text tool_use mcp__patchy-dev-852__find_patches({}) -> error: Agent access is off at Acme Co, so Patchy refuses every agent until an admin turns it on at <instance>/company. Acme Co's admin is Ada Park; tell the person to ask them. assistant: The `find_patches` call didn't list any patches. It returned an error. Here is the exact text: > Agent access is off at Acme Co, so Patchy refuses every agent until an admin turns it on at <instance>/company. Acme Co's admin is Ada Park; tell the person to ask them. Acme Co's agent access is turned off, so Patchy blocks every agent request until it's switched on. You'll need to ask Ada Park, Acme Co's admin, to turn it on at that URL. After that, I can run the call again and list the patches. ~~~ Claude Code's stored token for the dev server was cleared afterwards (`/mcp` › Clear authentication). ### Codex 0.163.0 with a minted token `pnpm dev mcp-token ben --client Codex`, then `codex exec --ephemeral --ignore-user-config -s read-only -c 'mcp_servers.patchy.url="<instance>/mcp"' -c 'mcp_servers.patchy.bearer_token_env_var="PATCHY_MCP_TOKEN"'`. With agent access off, before Ada turned it on (on the first head, before the singular "admin is" fix): ~~~text agent: I’ll find the Patchy MCP tool and return its answer exactly. mcp_tool_call patchy.find_patches({}) -> failed: Agent access is off at Acme Co, so Patchy refuses every agent until an admin turns it on at <instance>/company. Acme Co's admins are Ada Park; tell the person to ask one of them. agent: Agent access is off at Acme Co, so Patchy refuses every agent until an admin turns it on at <instance>/company. Acme Co's admins are Ada Park; tell the person to ask one of them. ~~~ On, at Codex's default revision (2025-06-18), asked: "Using the patchy MCP server: list every patch my company has, following next until there are no more pages. Tell me how many there are in all, how many pages it took, and which ones have agent tools. Then open the one with agent tools by its address and tell me what each of its tools does." ~~~text agent: I’ll use the Patchy tools to list every page of patches, then open the patch with agent tools and inspect what they do. mcp_tool_call patchy.find_patches({}) -> completed: {"actingFor":{"person":"Ben Ortiz","company":"Acme Co"},"total":56,"patches":[{"name":"deal-desk","description":"Track the sales team's open deals and move them through stages.","owner":"Ada Park","address":"<instance>/… mcp_tool_call patchy.find_patches({"cursor": "eyJhZnRlciI6eyJ0b29scyI6ZmFsc2UsIm5hbWUiOiJzdGFuZHVwLXdlZWstNDkiLCJpZCI6IjhwdXU4d3FqbXhzbSJ9fQ"}) -> completed: {"actingFor":{"person":"Ben Ortiz","company":"Acme Co"},"total":56,"patches":[{"name":"standup-week-50","description":"Team standup notes for week 50: what shipped and what is next.","owner":"Ada Park","address":"<instance>/… mcp_tool_call patchy.open_patch({"patch": "<instance>/acme/deal-desk"}) -> completed: {"name":"deal-desk","description":"Track the sales team's open deals and move them through stages.","owner":"Ada Park","address":"<instance>/acme/deal-desk","tools":[{"name":"listDeal… agent: The Patchy MCP connection is acting for **Ben Ortiz at Acme Co**. I followed `next` until it was absent: **56 patches across 2 pages** (50 + 6). All patches are owned by Ada Park: - **`deal-desk`** — the only patch with agent tools. - **`standup-week-01` through `standup-week-55`**, inclusive — 55 standup patches with no agent tools. I opened [deal-desk](<instance>/acme/deal-desk) by its address. Its tools are: | Tool | Kind | What it does | |---|---|---| | `listDeals` | Read | Lists deals newest first, optionally filtered by stage. Returns each deal’s ID, customer, stage, value in euros, and creation/update timestamps. | | `moveDeal` | Change | Takes a deal ID from `listDeals` and a target stage, moves the deal, and returns the updated record. Returns `null` if the ID doesn’t exist. | Both tools accept these stages: `lead`, `proposal`, `negotiation`, `won`, `lost`. ~~~ With `--enable mcp_2026_07_28` it made the same three calls, with the same answer. ### The door's request events for the final runs | Status | Client | Era / version | Method | Tool | Code or patchRef | Catalogue | | ---: | --- | --- | --- | --- | --- | --- | | 200 | Codex | legacy 2025-06-18 | tools/call | find_patches | — | Total=56, Listed=50, EndedEarly=False, Continued=False | | 200 | Codex | legacy 2025-06-18 | tools/call | find_patches | — | Total=56, Listed=6, EndedEarly=False, Continued=True | | 200 | Codex | legacy 2025-06-18 | tools/call | open_patch | name | — | | 401 | — | | — | — | missing_token | — | | 200 | Claude Code | modern 2026-07-28 | server/discover | — | — | — | | 200 | Claude Code | modern 2026-07-28 | tools/list | — | — | — | | 200 | Claude Code | modern 2026-07-28 | server/discover | — | — | — | | 200 | Claude Code | modern 2026-07-28 | tools/list | — | — | — | | 200 | Claude Code | modern 2026-07-28 | tools/call | find_patches | — | Total=56, Listed=50, EndedEarly=False, Continued=False | | 200 | Claude Code | modern 2026-07-28 | tools/call | find_patches | — | Total=56, Listed=6, EndedEarly=False, Continued=True | | 200 | Claude Code | modern 2026-07-28 | tools/call | open_patch | name | — | | 200 | Codex | legacy 2025-06-18 | initialize | — | — | — | | 202 | Codex | legacy 2025-06-18 | notifications/initialized | — | — | — | | 200 | Codex | legacy 2025-06-18 | tools/list | — | — | — | | 200 | Codex | legacy 2025-06-18 | tools/call | find_patches | — | Total=56, Listed=50, EndedEarly=False, Continued=False | | 200 | Codex | legacy 2025-06-18 | tools/call | find_patches | — | Total=56, Listed=6, EndedEarly=False, Continued=True | | 200 | Codex | legacy 2025-06-18 | tools/call | open_patch | address | — | | 200 | Codex | modern 2026-07-28 | server/discover | — | — | — | | 200 | Codex | modern 2026-07-28 | tools/list | — | — | — | | 200 | Codex | modern 2026-07-28 | tools/call | find_patches | — | Total=56, Listed=50, EndedEarly=False, Continued=False | | 200 | Codex | modern 2026-07-28 | tools/call | find_patches | — | Total=56, Listed=6, EndedEarly=False, Continued=True | | 200 | Codex | modern 2026-07-28 | tools/call | open_patch | address | — | | 200 | Claude Code | modern 2026-07-28 | server/discover | — | — | — | | 200 | Claude Code | modern 2026-07-28 | tools/list | — | — | — | | 200 | Claude Code | modern 2026-07-28 | tools/call | find_patches | — | Total=56, Listed=50, EndedEarly=False, Continued=False | | 200 | Claude Code | modern 2026-07-28 | tools/call | find_patches | — | Total=56, Listed=6, EndedEarly=False, Continued=True | | 200 | Claude Code | modern 2026-07-28 | tools/call | open_patch | name | — | | 200 | Claude Code | modern 2026-07-28 | server/discover | — | — | — | | 200 | Claude Code | modern 2026-07-28 | tools/list | — | — | — | | 200 | Claude Code | modern 2026-07-28 | tools/call | find_patches | agent_access_off | — | </details> ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required No migration and no stored data: the catalogue only reads. - **What does a revert leave behind?** Nothing. Clients that called the two tools get "not built" again, as on #883. - **Does the release before it still work with that?** Yes. Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh).




What changed
Patchy now reads the handler fields the Patchy MCP stack will write (a handler's and its values' descriptions,
readOnlyon actions, and the mark on each agent tool) and enforces their rules, before any CLI writes them. Deployed ahead of the stack, it means a rollback from the stack's release lands on a release that still loads every patch published in between and still holds read-only actions to reads and agent tools to agents.Closes #837
Look at
1. One schema, read everywhere.
packages/api/src/handlers.tsgains three optional fields.readOnlyis accepted only on actions, theagentToolmark only onagent.*handlers, and absent fields stay omitted (neverfalseornull). Every reader decodes through it: the CLI and guest, the instance's inspection (which also compares the bundle's word against the manifest's, new fields included), the execution loader, Runtime and Serving's stored rows. A tier 2 bundle carrying all three, built by hand because nothing writes them yet, fails onmain's schema the way it would in production today:2. The rules, in Runtime. The invocation capability carries
readOnly. The callback gate refuses a read-only action's table inserts, updates and deletes and its file puts and deletes. Nested admission refuses its mutations and actions. A marked agent tool is refused on any call from a page, nested calls and live queries included. Whether a call came from an agent is the binding's ownagentfield, which nothing sets until #843. Same workerd test, onmain's runtime, and then for a page calling the agent tool:Postgres already runs every statement inside
BEGIN READ ONLY(Execution.runStatement, covered by "denies INSERT, a side-effect function and multiple statements in native read-only transactions"). The gate leaves a read-only action's connection reads open.3. The rollback rehearsal (
scripts/rollback-rehearsal.ts) now also runs when a PR changes the descriptor schemas or the CLI files that write descriptors (ci.yml). It also gains the exercise for later PRs. At step 2 it probes HEAD's SDK. Onceaction({ readOnly: true, … })keeps the flag (#839), HEAD's CLI inits and publishes a tier 2 patch with a described read-only action that forces a write and a describedagent/tool. Every later step must then serve the patch, answeraccess_deniedto the forced write and leave no note behind, and, once HEAD's build marks the tool (#840), answeraccess_deniedto the page's call to it. Today's CLI drops the flag, so this PR's own rehearsal publishes nothing new and exercises today's bundles only.How it was verified
New tests: the schema's round-trip and refusals (
handlers.test.ts); the gate (CallbackGateway.test.ts); nested admission and agent tools, including a live query and a call with an agent binding (Invocation.test.ts); the hand-built bundle on real workerd (InvocationLocal.test.ts); publish and read-back, plus refusal of a manifest that drops a mark or description its bundle declares (PatchesApi.test.ts); and the loader (Inspection.test.ts). Each red onmain's code as quoted above.The runtime and api suites, the touched primitives, integrations, patches and execution suites,
pnpm typecheck, lint and format.The rehearsal's agent-area path, run locally before the rebase onto d4d6ed7. The branch was then at 6bac01d, now b25c549. A throwaway commit on top (never pushed) made the SDK keep
readOnlyanddescription, as Builders describe handlers and declare read-only actions #839 will:So once this is live, a writer PR's rehearsal passes with the patch served and the write refused by this release. Until then it fails, and that failure is the gate. The first run caught a fixture bug, fixed in b25c549. The agent-tool half waits for A tier 2 patch's agent area is its
agent/folder #840's build to mark one. Today's CLI writes neither field, so CI's rehearsal on this PR (against production's commit) logs "HEAD's CLI writes no read-only actions yet, so it publishes no agent area."Release impact
Readers accept optional fields that nothing writes yet, and the new rules apply only to marks no published patch carries. Every bundle published today loads unchanged.
Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh).