Repository navigation
feat(mcp): a tier 2 patch's agent area is its agent/ folder - #870
Conversation
6914bda to
ba74d58
Compare
cec9b2d to
736e18f
Compare
ba74d58 to
2a4b34e
Compare
8584fe3 to
7f93c31
Compare
Review by GPT-6.1-Sol (xhigh), five roundsRound 1 (f76fecf): nothing blocking.
Round 2 (6b4ba5d):
Round 3 (cec9b2d):
Round 4 (c86425c):
Round 5 (8584fe3, unchanged by the rebase to 7f93c31): no findings, nothing blocking. Sol's probes covered erased TypeScript declarations, Acceptance at 814cd9c: FAIL (verdict). A duplicate made by Round 6 (bde24e7): no findings, nothing blocking. Sol checked that refused guests can't bind or invoke (422 |
2a4b34e to
0cec8f4
Compare
7f93c31 to
814cd9c
Compare
Acceptance: PASS with notesChecked All four Done means lines pass. The star-export diagnostic that failed acceptance at Done means
Previously failing reproduction With valid exports in // agent/repeated.ts
export * from "./deals.js";The repo's pinned CLI, {"ok":false,"error":"addDeal is exported by agent/deals.ts and agent/repeated.ts; each tool needs its own name.","kind":"local","code":"invalid_manifest"}The running dev watcher also names both files, ending with Golden journeys
Additional evidence and surfaces
Rollback answers: Match the diff and the stated stack release order. A revert leaves versions with marked agent descriptors; the stacked base already reads that field and rejects page calls to it. No schema or infrastructure migration is introduced. The latest rollback-rehearsal check passes all three stages, reporting Not run / notes
|
0cec8f4 to
8434931
Compare
bde24e7 to
884ef8a
Compare
8434931 to
706e730
Compare
Every export of agent/*.ts is an agent tool named after its export. The server build folds the folder into the one module named agent, so a tool's handler is agent.<export>, and the guest marks each of those descriptors agentTool, which #837's readers already enforce. A re-export from server/ is one handler under both names, unmarked for the page. Nothing generated lists agent files: publish and the dev watcher discover them on every build, so adding one needs no refresh. The build refuses a name two files export, naming both files (following export * as the bundle links it), server/agent.ts, and a nested agent/ folder. agent/ below tier 2 is tier_mismatch and page imports from it are refused, as for server/. A tsconfig.json that leaves out agent/ gets a warning in dev builds and publish, and description refusals for a tool name its file under agent/. New repos include agent in tsconfig.json and eslint, and AGENTS.md names the folder. patchy-server gains "The agent area", patchy-loop names agent/, and the global skill's tier line says agents reach only a tier 2 agent area. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t * is no duplicate The fold builds its exports on a null prototype, and the server entry passes modules and agent files under computed keys, so an export or a file named __proto__ is a key rather than an object's prototype. The build's duplicate check now reads export * as ES modules link it: a name two star sources give, which the module doesn't export itself, is ambiguous and left out of the namespace, so another file's export of it is no duplicate. After the dev builder fails to start, a new server module still gets its refresh reminder. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nts only names it is sure of The guest refuses a server module named agent only beside an agent area, where the names would clash, and otherwise keeps its handlers. An older version built from server/agent.ts loads as before, and the CLI still refuses server/agent.ts outright. The duplicate check's export * walk is conservative: a name two star sources give may be one binding or an ambiguity ES modules leave out, so it counts as maybe and never causes a refusal. The guest still refuses a real duplicate when the bundle loads. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A walk that meets a module it is still visiting cuts the cycle, and what it found then depends on where the walk started. Such a result makes every name its module gets through export * a maybe, and it is never reused for another agent file. Explicit exports stay certain. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Working out at build time which names export * gives kept finding new ways to be wrong: ambiguous names, shared bindings, cycles, and CommonJS names that only exist until runtime. The check is only for the message, since the guest refuses any duplicate when the bundle loads. It now counts the names each agent file's own export statements declare, which are always in its namespace; a duplicate only export * creates is left to the guest's plainer refusal, and such a tool to no file. A description refusal for a tool the build found no file for names agent/*.ts, never a name inherited from Object.prototype. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… export * included Acceptance found that a duplicate made by export * got only "Could not inspect the server bundle". The guest's fold already names both files for every duplicate, since it reads the real module namespaces, but it threw while the bundle loaded, and inside workerd that message is lost. The guest now answers every request with its refusal instead of throwing. Inspection reports a guest's own refusal 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. A refused bundle still never binds. The build's own duplicate check goes; its reading of each file's own exports stays only to name a tool's file in description refusals. A non-handler export now gets its own message in the CLI too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
884ef8a to
2e2a24a
Compare
Stacked on #870 (ticket #840); merges with the rest of #833's stack, not alone. ## What changed Every Patchy MCP call will need the company's agent access on, and until now there was no switch. Company now ends with an **Agent access** section: an On or Off tag, who made the latest change and when ("Turned off by Priya Shah on 12 Oct 2026"), a paragraph, and for admins one button, Turn on or Turn off, with no confirmation. Members see the same state and stamp without a button: "Connect yours on Your machines" when it's on, the admins' names when it's off. It starts off for every company, new or existing. Closes #841 ## Look at **1. The switch lives on the company row** (`0020_agent_access`): `agent_access_on` defaults to false, and `agent_access_changed_by`/`_at` hold the latest change, null together for the starting Off. `Companies` gains `agentAccess`, `setAgentAccess` and `holdAgentAccess`. A change is one `UPDATE … WHERE agent_access_on <> $on`, so asking for the state it already has changes nothing and reports nothing. Each real change reports `agent_access.changed` with `on`, after it commits. **2. The lock #849 shares.** `holdAgentAccess` reads whether the switch is on, `FOR SHARE` of the company row. Inside a transaction, a change waits for the holder, and the holder waits for a change in flight and then reads what it committed. It returns the switch alone: a read that waited re-reads only the locked row, so a joined stamp could come back stale (Sol's round 1). Code issuance and the code exchange call it, so an exchange never acts on an "on" an "off" already replaced. The same row lock serializes it with deactivation, which locks the company row `FOR UPDATE`. `Companies.test.ts` › "makes a change wait for a holder of agent access, and a holder wait for a change" shows both directions on Postgres, waiting for a session the holder blocks; without the `FOR SHARE` it times out. **3. The page and route.** `POST /company/agent-access` with `state=on|off`, same-origin, admins only. A member's POST is the page's existing 403, and a malformed state is a 422 alert. It redirects to `/company#agent-access`, so the admin lands back on the section at the foot of the page. Screenshots and a short film: **The admin's Company page, before and after** (Ada, `team`): <!-- patchy-dev:compare:ada --> #### Before and after, as Ada Park (admin) Before is `f76fecf` (where this branch left mcp/840-agent-folder) and after is `7eeba59` (mcp/841-agent-access-switch), both on the `team` scenario, from `pnpm dev compare`. Every page answered 200 with no browser errors. ##### `/company` **1280px, after**  <details><summary>1280px, before</summary>  </details> | Width | Before | After | | --- | --- | --- | | 390px |  |  | <!-- /patchy-dev:compare:ada --> **A member's** (Ben): <!-- patchy-dev:compare:ben --> #### Before and after, as Ben Ortiz (member) Before is `f76fecf` (where this branch left mcp/840-agent-folder) and after is `7eeba59` (mcp/841-agent-access-switch), both on the `team` scenario, from `pnpm dev compare`. Every page answered 200 with no browser errors. ##### `/company` **1280px, after**  <details><summary>1280px, before</summary>  </details> | Width | Before | After | | --- | --- | --- | | 390px |  |  | <!-- /patchy-dev:compare:ben --> **Turning it on and off** as the admin, head only: <!-- patchy-dev:film:agent-access --> #### Flow `agent-access`, as Ada Park (admin) After is `7eeba59` (mcp/841-agent-access-switch), on the `team` scenario, from `pnpm dev film`. - After: finished in 9.6s https://github.com/user-attachments/assets/72a61412-4a7a-4de1-a4b5-ace15e541024 <!-- /patchy-dev:film:agent-access --> ## How it was verified - `vitest`: `Companies.test.ts` covers a new company starting Off with no stamp, on and off stamped with who and when (under `TestClock`), a repeated state leaving the stamp alone, unknown companies, and the hold in both directions. `CompanyPage.test.ts` covers the four page states, the redirect, the events, a stale Turn on from a second admin, the 422, and `/company/agent-access` in the member-refusal and Origin cases. Also `apps/server/src/migrations.test.ts`, the companies suite, `AuthPages`, `DevicePages` and serving's `Pages`. - Typecheck (build plus `tsconfig.test.json`) and lint. - `pnpm verify` on e3ecce3: 8 of 9 steps passed. The `test` step had 14 timeouts in 9 files this PR doesn't touch (CLI repo builds, SDK, fleet, PGlite) while the machine's load was above 30. Rerun alone, all 9 passed (137 tests), and CI's three `test` jobs passed. - Rollback rehearsal against `main` dd3f41f, which has #837 and #838: `pnpm test:rollback-rehearsal --live dd3f41f` gives `Exercised rollback paths passed: dd3f41f → e3ecce3 → dd3f41f, in 470s.` CI's run against production's d77baaf fails only in step 3, on the agent-area patch production can't serve, the gate #833 documents. Its upgrade step, which applies `0020_agent_access`, passes. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required An additive migration: three columns on `companies`, defaulted or null. Nothing reads the switch yet; the door and consent (#849 onward) will. - **What does a revert leave behind?** The three columns, and a latest change on companies an admin switched. - **Does the release before it still work with that?** Yes. It never selects the columns, and every insert it makes takes their defaults. Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh).
## 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]>
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/*.tsfile publishes as an agent tool named after its export, with norefresh. 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 namedagent. The generated entry inpackages/patchy/src/serverBuild.tspassesagent/files by name tocreateGuest.foldAgentAreainhandlerDescriptors.tsmerges them, andextractHandlerDescriptorsmarks eachagent.<export>descriptoragentTool: true. A re-export is one handler under two names, unmarked for the page. Published on a dev instance, from a freshpatchy init --tier 2plus this file, with no refresh:Inspection returns
agent.listwith"agentTool": trueandnotes.listwithout 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. SocreateGuestanswers every request with its refusal instead of throwing (guest.ts).packages/execution/src/inspection.tsreports that answer as reasonrefused, carrying its text asproblem, and the CLI's publish and dev builds show it. The instance keeps its genericinvalid_manifestand never echoes text from a bundle, and a refused bundle never binds. Statically followingexport *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, oragent/*.tswhen there is none. The four refusals and the warning, from the same dev repo:agent/below tier 2 istier_mismatch(agent/ requires tier 2. Change the tier and run \patchy refresh`, or remove agent/.), from the same check asserver/(repoBuild.test.ts). Page imports fromserver/` now get the same kind of fix-it message instead of the generic package one.3. The dev watcher watches
agent/besideserver/.devServerWatch.tskeeps 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.tscovers, on real Vite and workerd builds:export *duplicate, each refused naming both files in watch, and through inspection of publish'sbuildServeroutput;export *and a__proto__file building cleanly;agent/intake.ts.Inspection.test.tscarries a guest's refusal asrefusedand no other failure's text, andguest.test.tscovers the refusing guest. Alsoserver.test.ts,serverModules.test.ts,pageImports.test.ts,repoBuild.test.ts,initProject.test.tsand the bundled-CLI suites. Tier 2 readers accept handler descriptions, read-only actions and agent tools, and enforce them #837's fixtures for olderserver/agent.tsbundles (InvocationLocal.test.ts,PatchesApi.test.ts) still pass.Typecheck of
patchyandtsconfig.test.json; lint on the changed files.Hand-checked on this worktree's dev instance, as above.
~/Patchygained nothing.Rollback rehearsal: against
maindd3f41f, which 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:pnpm test:rollback-rehearsal --live dd3f41fgivesExercised rollback paths passed: dd3f41f → bde24e7 → dd3f41f, in 208s.Step 2 publishes the rehearsal'sagent/notes.tsthrough HEAD's CLI, which marksagent.countNotesas 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 Build Patchy MCP #833 documents until Tier 2 readers accept handler descriptions, read-only actions and agent tools, and enforce them #837 is live.pnpm verifyon 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 Runtime runs agent tools for agents, as their person #843 (agent invocation) and Builder agents call their agent tools locally with
patchy dev agent#844/Worker agents read patches through their agent tools #854 (patchy dev agent, the door).Release impact
Today the build ignores
agent/. Now it builds it, and only tier 2 repos that have the folder change. A repo with aserver/agent.tsis refused; only the unmerged prototype (#727) used that file.agent.*handlersagentTool: true.Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh).