Repository navigation
feat(mcp): worker agents find their company's patches and open one - #884
Conversation
|
Review rounds (GPT-6.1-Sol, xhigh) Round 1, on 26bbeac: nothing blocking, three should-fix findings, all fixed in 90262f1.
Also fixed after the Codex run: one admin is named as one ("Acme's admin is Ada Lovelace; tell the person to ask them."). Round 2, on 90262f1: PASS, nothing blocking and no new findings. It checked R1.1–R1.3, the six threat areas (visibility through search, cursors, |
90262f1 to
26bbeac
Compare
26bbeac to
90262f1
Compare
Acceptance: PASSChecked Done means
Golden journeys
Other risks: passed. The local catalogue/door/shaper/patches/server suites exercised keyset pagination across publish/retire, detailed-page caps, the 64 KiB open cap, bad arguments, forged cursors, search privacy, current-version tool summaries, former-name resolution and foreign-address refusals. Catalogue code reads metadata/manifests without invoking Runtime. All 14 PR checks passed on the checked head, including Node 22/24/26 tests, CLI, concurrency and live Clerk. Full-suite validation uses those CI results rather than a duplicate local Independent real-client transcript (sanitized)Consent displayed “Connect Claude Code to Brightline Studio?” as Jordan Lee. After Allow, Claude Code reported “Authentication successful. Connected to patchy-acceptance-884.” Independent HTTP/CLI checksRollback answers: match the diff. There is no migration, data rewrite/deletion or infrastructure change. The catalogue only reads; turning access on/off uses fields already present on the base. Reverting returns the two catalogue tools to Surfaces: shared tool/wire shapes and API docs, dev-loop guidance, MCP vocabulary and reverse states apply and are covered. No new CLI flags/exit codes, migration, company-database caller, served-page implementation or package-layout change. Not run: none of #852's required dev-instance acceptance checks were skipped. |
26e2aef to
1e26a75
Compare
90262f1 to
03c8471
Compare
1e26a75 to
be667c3
Compare
find_patches lists the live patches the person can open, starting from the portal's own read and openability rule: those with agent tools first, then by name, up to 50 a page and ending early under the 100,000-character read cap. Its opaque cursor carries the find's search and detail, and search matches every word in the name, title, description or owner. detail: "tools" adds each tool's kind and words. open_patch answers a patch's own document through the shared shaper, within 64 KiB. patch is an id, a name (a former one follows its rename) or an address on this instance under the person's company; anything else, a patch they can't open included, is one not_found refusal. Every tool call is refused agent_access_off, naming the active admins, while the company's agent access is off. Bad arguments are invalid_args tool results. Catalogue calls read manifests only, through a new Patches.agentToolSummaries, and request events gain the catalogue fields. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…h's tools, and the tools advertise their limits A find's actingFor cuts the person's and company's names at 200 characters, and a patch whose tools alone would pass the read cap is listed with their names, or without them, so no page passes 100,000 characters. open_patch resolves against the visible patches without loading every patch's tool summaries. tools/list advertises the length limits the catalogue enforces, from one set of constants. One admin is named as one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
03c8471 to
f98c0eb
Compare
… agents you've connected (#885) Stacked on #884 (ticket #852); merges with the rest of #833's stack, not alone. ## What changed Your machines now opens with how to connect an agent: a tab per agent (Claude, Claude Code, Codex, ChatGPT, Another agent), each a plain link, showing only that agent's steps with Patchy's address in a copy line. Below it, the person's agent connections are listed beside their machines. Each shows its client and site, when it connected and was last used, and Disconnect. A connection unused for a week says when it ends on its own and that a reconnect leaves it behind. "Revoke all machines" becomes **Disconnect everything**, under "Lost a laptop?", and it shows even when nothing is listed. Closes #853 ## Look at 1. **Release notes: the rename.** Production's button says "Revoke all machines"; from this release it says **Disconnect everything** and ends agents too. It is now always on the page, so an approval nobody has collected can still be cancelled. The What's new entry for the stack's release should name the rename. The form still posts to `/machines/revoke-all`, the route the rollback rehearsal presses. 2. **Choices within the spec's words:** - With no `?agent=`, or an unknown one, the Claude tab is open. Tab links carry `#connect-an-agent`, the id the card's "Connect your agent" link (#845) lands on. - Codex's first step holds both commands as copy lines. Claude Code's `/mcp` stays inline code, because it's typed inside Claude Code. - ChatGPT gets no menu path, only "Only some ChatGPT plans can add custom connectors." - Step 3 is a generic "Ask for something", not a patch-specific example. - A connection never called says Last used "Not yet". The leftover line counts from the last call, or from connecting when there was none. Its "ends on its own" date comes from the new `AgentConnections.list`, using the same SQL as the 30-day ending itself, so the two can't disagree. - Dates carry the year ("13 Oct 2026"), as the mock does; the spec's example drops it. - The reverse state is said once, in the Agents intro: "A disconnected agent can't be brought back: connecting it again makes a new connection." - The page moved out of `DevicePages.ts` into `MachinesPage.ts`. Device login keeps its own module. ### Your machines, access on A member with a fresh Claude Code connection, made through consent, and a week-unused one from before a reconnect (minted with `pnpm dev mcp-token`, its last use moved back in the dev database):  An admin with a machine and an agent (minted with `pnpm dev mcp-token`, so its site is the dev host); then the same page after Disconnect everything, with both lists empty and the button still there: | Before Disconnect everything | After | | --- | --- | |  |  | ### Access off, as a member and as an admin | Member: the admins are named | Admin: Turn it on at Company | | --- | --- | |  |  | ### Phones (390 px) | Member, two agents | Admin, Codex tab | Member, access off | Admin, access off | After Disconnect everything | | --- | --- | --- | --- | --- | |  |  |  |  |  | No page scrolls sideways at 390 px. None logged a console error. ## How it was verified **Done means, with a real Claude Code (2.1.308)** against `pnpm dev up team` on this branch. The run used a throwaway `CLAUDE_CONFIG_DIR` in a temp dir outside `$HOME`, so `~/.claude.json` and `~/.claude/` gained nothing. Consent was driven in a throwaway Playwright context signed in as Ben (member), with agent access turned on at Company by Ada. <details><summary>Connect, see it listed, disconnect, 401</summary> The command came from the Claude Code tab's copy line. `claude mcp login` is the CLI form of `/mcp` › Authenticate, since the interactive TUI can't run here. ~~~text $ claude mcp add --transport http patchy http://<env>.localhost:<port>/mcp Added HTTP MCP server patchy with URL: http://<env>.localhost:<port>/mcp to local config $ claude mcp login patchy --no-browser Visit this URL to authorize: http://<env>.localhost:<port>/oauth/authorize?…&client_id=https%3A%2F%2Fclaude.ai%2Foauth%2Fclaude-code-client-metadata… (Ben, in the browser: the consent page, then Allow → http://localhost:<port>/callback?code=…&state=…&iss=…) Authenticated with "patchy". Its tools are now available in Claude Code. $ claude mcp get patchy Status: ✔ Connected ~~~ Your machines, as Ben: `Claude Code CLAUDE.AI · Connected 22 Oct 2026 · Last used just now · Disconnect`. Ben pressed that row's Disconnect, and the next call failed: ~~~text $ claude mcp get patchy Status: ! Needs authentication ~~~ The server's events for Claude Code's requests, in order: | Request | Status | Code | | | --- | ---: | --- | --- | | POST /oauth/token | 200 | | code exchange | | POST /mcp | 200 | | `server/discover` | | POST /mcp | 200 | | `tools/list` | | POST /mcp | 401 | `invalid_token` | after Disconnect | | POST /oauth/token | 400 | `invalid_grant` | its refresh, after Disconnect | </details> - `MachinesPage.test.ts`, through the page's routes over a migrated database: - each tab's own steps and copy lines, with no inline script; - an unknown `?agent=` opening Claude; - access off naming the admins (an escaped name) to a member, and offering an admin "Turn it on at Company"; - the person's own agents only, with "Not yet" and the leftover line on the week-unused one alone; - Disconnect ending that connection's next call and nobody else's, and 404 for someone else's connection; - machines (moved from `DevicePages.test.ts`); - Disconnect everything shown with nothing listed, ending both kinds, and leaving both lists empty. - `AgentConnections.test.ts`: `list` returns live connections only, newest first, with `endsAt` 30 calendar days after the last call, or after connecting. - `DevicePages.test.ts`: a cross-origin or origin-less POST to Disconnect is refused 403 and leaves the connection working. - `pnpm verify` passed on 8153299: 2,244 tests and 81 browser tests, "All passed." - Rollback rehearsal: CI's check skips itself because no migration changed. This PR changes the page the rehearsal presses (`form[action="/machines/revoke-all"]`), so it was run locally against `e4243ff`, a `main` commit with #837 and #838: "Exercised rollback paths passed: e4243ff → 8153299 → e4243ff → 8153299". - Review: GPT-6.1-Sol, two rounds (comment below). Round 1's one should-fix, the server skill not saying where people connect, is fixed in 8153299. Round 2 found nothing. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required No migration, no API change; one new read (`AgentConnections.list`) and one new page route. - **What does a revert leave behind?** Nothing stored. The page goes back to machines only, with "Revoke all machines" shown only while a machine is listed. Disconnects already made stay made. - **Does the release before it still work with that?** Yes. The routes it keeps are unchanged, and the stack ships as one release. Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh). <!-- patchy-dev:compare:member --> #### Before and after, as Ben Ortiz (member) Before is `90262f1` (where this branch left mcp/852-find-open) and after is `f72f04e` (mcp/853-your-machines), both on the `team` scenario, from `pnpm dev compare`. Every page answered 200 with no browser errors. ##### `/machines` **1280px, after**  <details><summary>1280px, before</summary>  </details> | Width | Before | After | | --- | --- | --- | | 390px |  |  | <!-- /patchy-dev:compare:member --> <!-- patchy-dev:compare:admin --> #### Before and after, as Ada Park (admin) Before is `90262f1` (where this branch left mcp/852-find-open) and after is `f72f04e` (mcp/853-your-machines), both on the `team` scenario, from `pnpm dev compare`. Every page answered 200 with no browser errors. ##### `/machines` **1280px, after**  <details><summary>1280px, before</summary>  </details> | Width | Before | After | | --- | --- | --- | | 390px |  |  | <!-- /patchy-dev:compare:admin -->
## 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 #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_patcheslists exactly the patches the person can open in the portal;open_patchanswers 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
Catalogue.visibleisPatches.read({ state: "live" })throughPatches.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.tschecks 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/patcheswithfind_patchesfor 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.searchmatches when every word appears in the name, title, description or owner's name, ignoring case.{ 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 refusedinvalid_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.patchresolves an id first (ids never change), then a name throughPatches.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 onenot_foundin the same words.actingForis{ 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_patchrefusestoo_largepast 64 KiB, which only a version that skipped the publish check could reach.agent_access_offrefusal names where an admin turns it on and the active admins by name, nothing else.patchRef,catalogueTotal,catalogueListed,catalogueEndedEarly,catalogueSearched,catalogueDetailandcatalogueContinued, besidepatchId,versionIdandresultBytes. Never the search words or the cursor.How it was verified
packages/mcp:Catalogue.test.tscovers a narrower openability rule, order, 55 patches over two pages with a publish and a retire between them, the read cap withdetail: "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.tscovers the agent access refusal for a member and an admin, with discovery and the tool list still working. The shared harness moved tosrc/test/door.ts.packages/patches:agentToolSummariesby version.packages/api: summaries keepopen_patch's order.pnpm verifyon 90262f1: format, lint, typecheck, synth, postgres-concurrency, cli-smoke, tier2-smoke and browser passed. Intest, 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) andSdkApi.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.rollback-rehearsalhas nothing to rehearse. Tier 2 readers accept handler descriptions, read-only actions and agent tools, and enforce them #837 (PR feat(mcp): Patchy reads and enforces read-only actions and agent tools before anything writes them #868) and Deactivation and Disconnect everything end pending device logins and record when a person's credentials ended #838 (PR fix(auth): Disconnect everything and deactivation end device logins not yet collected #867) are both onmain.deal-deskfirst 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.Real clients against a dev instance, transcripts
A
pnpm dev up teamenvironment (Acme Co: Ada Park, admin; Ben Ortiz, member) withdeal-desk, a tier 2 patch whoseagent/deals.tsexportslistDealsandmoveDeal, and 55 static pages,standup-week-01to-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 stubxdg-openon itsPATHrecorded 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:Then
claude -pwith the same config:With agent access turned off at Company by Ada:
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, thencodex 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):
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."
With
--enable mcp_2026_07_28it made the same three calls, with the same answer.The door's request events for the final runs
Release impact
No migration and no stored data: the catalogue only reads.
Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh).