Repository navigation
feat(mcp): builders describe handlers and declare read-only actions - #869
Merged
Merged
Conversation
allisonmahmood
force-pushed
the
mcp/839-descriptions-readonly
branch
from
October 22, 2026 08:26
a021745 to
6914bda
Compare
Owner
Author
Review: GPT-6.1-Sol (xhigh), two roundsRound 1 (at 9b7df60)
Round 2 (at 6914bda): no findings. All three fixes verified; nothing blocking. |
1 of 2 tasks
allisonmahmood
force-pushed
the
mcp/837-readers-first
branch
from
October 22, 2026 09:00
421a51d to
6fc68aa
Compare
allisonmahmood
force-pushed
the
mcp/839-descriptions-readonly
branch
from
October 22, 2026 09:02
6914bda to
ba74d58
Compare
allisonmahmood
force-pushed
the
mcp/837-readers-first
branch
from
October 22, 2026 09:21
6fc68aa to
4e5b744
Compare
allisonmahmood
force-pushed
the
mcp/839-descriptions-readonly
branch
from
October 22, 2026 09:24
ba74d58 to
2a4b34e
Compare
allisonmahmood
force-pushed
the
mcp/839-descriptions-readonly
branch
from
October 22, 2026 09:40
2a4b34e to
0cec8f4
Compare
Owner
Author
Acceptance: PASS with notesChecked Done means
Golden journeys
Rollback answers: Match the diff for the prerequisite release specified by #833. A revert leaves published descriptors carrying descriptions and Not run
Notes
Independent packed CLI probe output |
allisonmahmood
force-pushed
the
mcp/839-descriptions-readonly
branch
from
October 23, 2026 02:08
0cec8f4 to
8434931
Compare
Closed
action({ readOnly: true, ... }) types its handler with a
ReadOnlyActionContext: an action's reads, no writes, and ctx.run for
queries only. The descriptor carries readOnly: true, its kind stays
action, and the flag on a query or mutation is refused by the types and
the descriptor schema. A write forced past the types still reaches the
host's gate, which #837 taught to refuse it.
Every handler takes an optional description and every handler value
.describe(text). Blank literals are type errors. The CLI's build and dev
builds, and the instance's publish, run one shared check on the
inspected descriptors, so a blank or over-2,000-character description is
invalid_manifest naming the handler and the fix. Inspection runs in
workerd and reports only that a bundle failed to load, so the SDK
doesn't refuse at construction, where the message would be lost.
.describe() turns a column into a handler value, so table() refuses it
by type, and config execution refuses one forced past the types with a
message saying how to fix it.
ctx.agent is in every handler context as { name } | null, always null
until agent tools run for agents. The generated server module exports a
bound ReadOnlyActionContext for helpers.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The shared check now returns where the problem is and what it is, and one formatter says it. The instance refuses with InvalidHandlerDescription, built from those fields, instead of a preformatted sentence on InvalidManifest. The CLI's build and dev builds name the handler's file, as the spec's Checks paragraph asks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
allisonmahmood
force-pushed
the
mcp/839-descriptions-readonly
branch
from
October 23, 2026 11:34
8434931 to
706e730
Compare
allisonmahmood
added a commit
that referenced
this pull request
Oct 23, 2026
Stacked on #869 (ticket #839); merges with the rest of #833's stack, not alone. ## What changed A tier 2 patch can now have tools for people's agents: every export of a root `agent/*.ts` file publishes as an agent tool named after its export, with no `refresh`. The page can't import or call them. #837's readers already refuse page calls to them; this PR is what first writes the mark. Closes #840 ## Look at **1. The build folds `agent/` into one module named `agent`.** The generated entry in `packages/patchy/src/serverBuild.ts` passes `agent/` files by name to `createGuest`. `foldAgentArea` in `handlerDescriptors.ts` merges them, and `extractHandlerDescriptors` marks each `agent.<export>` descriptor `agentTool: true`. A re-export is one handler under two names, unmarked for the page. Published on a dev instance, from a fresh `patchy init --tier 2` plus this file, with no refresh: ```ts // agent/deals.ts export { list } from "../server/notes.js"; export const addNote = mutation({ description: "Adds a note with a title. Refuses a blank title.", … }); ``` ``` $ patchy publish --json | jq -c '[.handlers[].name]' ["agent.addNote","agent.list","notes.create","notes.list"] ``` Inspection returns `agent.list` with `"agentTool": true` and `notes.list` without it. **2. Duplicate names are refused naming both files, `export *` included.** The guest's fold reads the real module namespaces, so it knows exactly which two files export a name. Inside workerd, though, a throw while loading loses its message. So `createGuest` answers every request with its refusal instead of throwing (`guest.ts`). `packages/execution/src/inspection.ts` reports that answer as reason `refused`, carrying its text as `problem`, and the CLI's publish and dev builds show it. The instance keeps its generic `invalid_manifest` and never echoes text from a bundle, and a refused bundle never binds. Statically following `export *` was tried and dropped after review (see the review comment). The build reads each file's own export statements only to name a tool's file in #839's description refusals, or `agent/*.ts` when there is none. The four refusals and the warning, from the same dev repo: ``` $ patchy publish --json # agent/crm.ts re-exports addNote from agent/deals.ts {"ok":false,"error":"addNote is exported by agent/crm.ts and agent/deals.ts; each tool needs its own name.","kind":"local","code":"invalid_manifest"} $ patchy publish --json # with server/agent.ts {"ok":false,"error":"server/agent.ts: Agent tools live in agent/; move these exports there.","kind":"local","code":"invalid_manifest"} $ patchy publish --json # src/App.tsx imports ../agent/deals.js {"ok":false,"error":"src/App.tsx imports \"../agent/deals.js\", but the page can't import agent/ at runtime. Agent tools are for people's agents only; call server/ handlers through patchy.server.","kind":"local","code":"import_refused"} $ patchy publish --json | jq -c '{ok, warnings}' # tsconfig.json include without agent {"ok":true,"warnings":["tsconfig.json doesn't include agent/, so pnpm typecheck skips your agent tools. Add \"agent\" to its include list."]} ``` `agent/` below tier 2 is `tier_mismatch` (`agent/ requires tier 2. Change the tier and run \`patchy refresh\`, or remove agent/.`), from the same check as `server/` (`repoBuild.test.ts`). Page imports from `server/` now get the same kind of fix-it message instead of the generic package one. **3. The dev watcher watches `agent/` beside `server/`.** `devServerWatch.ts` keeps one directory watch per folder and restarts the Vite watcher when either file list changes. A new agent file rebinds with no refresh reminder. The tsconfig check runs whenever the agent file list changes. ## How it was verified - `vitest`: `devServerWatch.test.ts` covers, on real Vite and workerd builds: - a re-export plus a tool of its own, folded and marked with no refresh; - a named duplicate and an `export *` duplicate, each refused naming both files in watch, and through inspection of publish's `buildServer` output; - ambiguous `export *` and a `__proto__` file building cleanly; - recovery; - an agent tool's blank description naming `agent/intake.ts`. `Inspection.test.ts` carries a guest's refusal as `refused` and no other failure's text, and `guest.test.ts` covers the refusing guest. Also `server.test.ts`, `serverModules.test.ts`, `pageImports.test.ts`, `repoBuild.test.ts`, `initProject.test.ts` and the bundled-CLI suites. #837's fixtures for older `server/agent.ts` bundles (`InvocationLocal.test.ts`, `PatchesApi.test.ts`) still pass. - Typecheck of `patchy` and `tsconfig.test.json`; lint on the changed files. - Hand-checked on this worktree's dev instance, as above. `~/Patchy` gained nothing. - Rollback rehearsal: against `main` dd3f41f, which has #837 and #838: `pnpm test:rollback-rehearsal --live dd3f41f` gives `Exercised rollback paths passed: dd3f41f → bde24e7 → dd3f41f, in 208s.` Step 2 publishes the rehearsal's `agent/notes.ts` through HEAD's CLI, which marks `agent.countNotes` as an agent tool, and both releases refuse the page's call to it. CI's run against production's d77baaf fails at step 3, because d77baaf can't read the new descriptor fields. That's the gate #833 documents until #837 is live. - `pnpm verify` on bde24e7: format, lint, typecheck, synth, postgres-concurrency, cli-smoke, tier2-smoke and browser pass. The test stage had seven timeouts while other lanes loaded the machine. Its seven failing files, rerun alone with two workers, pass (78 tests). - Not checked here: an agent actually calling a tool. That needs #843 (agent invocation) and #844/#854 (`patchy dev agent`, the door). ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required Today the build ignores `agent/`. Now it builds it, and only tier 2 repos that have the folder change. A repo with a `server/agent.ts` is refused; only the unmerged prototype (#727) used that file. - **What does a revert leave behind?** Versions whose stored descriptors mark `agent.*` handlers `agentTool: true`. - **Does the release before it still work with that?** Yes, from #837 on, which reads the mark and refuses page calls to marked tools. #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).
This was referenced Oct 23, 2026
allisonmahmood
added a commit
that referenced
this pull request
Oct 23, 2026
## What changed This PR adds release 17's What's new entry, written from `5dd94f3`. It covers everything merged since release 16's `through` (`dd3f41f`), and it sets the `patchy` release to `0.17.0` in `packages/patchy/package.json` and `CURRENT_RELEASE`. With this release, people's agents can use their company's patches through Patchy MCP (#833). | Change | PRs | | --- | --- | | New: Your AI agent can use your company's tools | #873, #878, #880, #881, #882, #883, #884, #886, #887 | | New: Admins choose whether agents can use the company's tools | #871 | | Improved: Your machines shows your agents too (Revoke all machines is now Disconnect everything) | #885, #879 | | New: See what agents can do with a tool | #876 | | New: The log says when an agent made a change | #888 | | New: Your agent can make a tool ready for agents | #869, #870, #872, #875, #896 | | Behind the scenes: agents' calls have their own limits, and a server only an agent uses rests a minute after its last call | #889, #892 | | Behind the scenes: New and Improved changes are public, for patchyhq.com | #893 | | Behind the scenes: library updates | #899 | Five merged PRs get no line: - #874 is release 16's own entry. - #894 is dev tooling: worker agent launchers and scenario data. Its one CLI fix lets a `patchy` installed outside a tier 2 repo publish it. The skills have agents use the repo's pinned `pnpm patchy` instead, so that path is off the documented one. - #900 is CI. - #901 rewords an internal skill. ## Look at - **The entry**, at the top of `releases` in `packages/core/src/whatsNew.ts`. - It names only Claude Code and Codex. Both have connected through real consent against dev instances. Hosted clients (Claude.ai, ChatGPT) are checked in production only (`docs/product.md` › Patchy MCP › Acceptance). - Its labels are the pages' own: Agent access on Company, Your machines, What agents can do, Disconnect everything, and "Jordan Lee via Claude". - **Rollback safety, from the live commit `e4243ff` to `5dd94f3`.** - No PR in the range is labelled `one-way`, and every PR answers both Release impact questions with "Yes". - Migrations 0020–0025 are all additive: - three defaulted or nullable columns on `companies`; - `agent_name` on the runtime log, with a widened `credential_kind` check; - the agent connection tables, `agent_consents` and `change_keys`; - two columns on execution bindings. The new tables reference `users` without a cascade, but no release deletes users or companies. Release 16 reads the runtime log only for credential kinds it knows, so rows from agents can't break it. - `rollback-rehearsal` on #892 rehearsed the whole stack, since #892 adds the last migration and the rest of the stack sits below it: `Exercised rollback paths passed: e4243ff → c8bede4 → e4243ff → c8bede4, in 238s.` #896's run skipped, because it changes no migration or handler descriptor. - #883 turns on the load balancer's host header preservation, which the Deploy workflow's app stack deploy applies. A rollback leaves it on. That's harmless, because release 16's server never reads `Host`. - A rollback takes `/mcp` and `/whats-new.json` away. Connected agents get a 404 until this release returns, and then their connections work again, unless one ended in between. Agent tools published in between stay refused to pages, because #837 already shipped in release 16. ## How it was verified - `pnpm check` on `2d528b1`: format, lint, typecheck and synth passed. In the test step, 2,300 of 2,301 tests passed. The one failure was `packages/sdk/src/install.test.ts` › "says how to reach patchy when the prefix's bin is not on PATH", which timed out at 180 s while the shared machine was loaded. Rerun alone, that file passes all 7 tests in 62 s. The release's own tests pass too: `whatsNew.test.ts`, `schemas.test.ts` and `WhatsNewPages.test.ts`. - The live commit was pinned from `/healthz/deep`: `e4243ff`, release 16. The Deploy run updated last succeeded, and none is unfinished. - Each PR in the range was read with `gh pr view`, including its Release impact answers. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required This PR changes only the changelog text and the `patchy` version. As with every release, a CLI installed before this deploy is told to upgrade. - **What does a revert leave behind?** Nothing. People whose seen marker reached 17 would just see no new release. - **Does the release before it still work with that?** Yes. If this release misbehaves, roll back to `e4243ff54d2acbbc88b60eeb0cf9b82a26dc9d5d` (release 16). Prepared by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code. Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bottom of #833's stack (#839–#860), now on
mainsince #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-errorholds, so each write is a type error:readOnly: trueon 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 forcedctx.tables.notes.insertreaches #837's gate and getsaccess_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.
descriptionProbleminpackages/api/src/handlers.tsreturns a structuredDescriptionProblem, anddescriptionRefusalsays 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 isinvalid_manifestnaming 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 fromInvalidHandlerDescription: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, sotable()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
api,patchy,sdk,patchesandruntime, plustsconfig.test.json.server.types.tsandconfig.types.tshold 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.mainnow has Tier 2 readers accept handler descriptions, read-only actions and agent tools, and enforce them #837 and Deactivation and Disconnect everything end pending device logins and record when a person's credentials ended #838, and against it all three steps pass:pnpm test:rollback-rehearsal --live dd3f41fgivesExercised 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 Tier 2 readers accept handler descriptions, read-only actions and agent tools, and enforce them #837, so it answers the forced write withhandler_failed. That's the gate Build Patchy MCP #833 documents, and it stays red untilmainwith Tier 2 readers accept handler descriptions, read-only actions and agent tools, and enforce them #837 is deployed.Release impact
The SDK fields are optional and additive. The new refusals apply only to descriptions, which nothing wrote before.
descriptionandreadOnly: true.Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh).