Repository navigation
feat(mcp): a patch's card shows what agents can do - #876
Conversation
8a37cb1 to
2821ae1
Compare
Review: GPT-6.1-Sol (xhigh), two roundsRound 1 at
Round 2 at |
56ab1f9 to
4739933
Compare
0790e3c to
cdd420b
Compare
4739933 to
31862c3
Compare
Acceptance: PASS with notesChecked Done means
Fresh-head screenshots: member on/off and phone layoutMember, access on, 1280 px; read-only action description expanded Member, access off, 1280 px
Base/head comparison: a tier 2 card without agent tools, desktop and phoneBefore and after, as Jordan Lee (member)Before is Every page answered 200 with no browser errors.
|
| Width | Before | After |
|---|---|---|
| 390px | ![]() |
![]() |
Golden journeys
- Find and open a tool: passed. Jordan's Home lists the scenario patches; searching
kudosfinds one result, which opens in its sandboxed frame. - Use a tier 1 tool live: passed. Jordan sent kudos to Priya; Priya's already-open page received the message without reloading (14 → 15 kudos).
- Use a tier 2 tool: passed. Both viewers opened the seeded pipeline. Jordan moved Verdant Grocers from Lead to Discovery; Allison's open board updated without reloading. Moving it back also updated Allison's board. Spend refused Jordan's own approval with “You can't approve your own request.” and left it Waiting.
- Publishing/lifecycle and the sign-in door: passed for the checks above. The published agent area appears on the card, version rollback and retire/delete/restore work, and a signed-out card returns 401 with
Cache-Control: private, no-storeand the sign-in door. Persona sign-in returns to the requested page.
Tests and affected surfaces
pnpm exec vitest run packages/portal packages/core packages/companies/src/CompanyPage.test.ts: 178 passed, 7 files. The direct HTTP/CLI checks passed all 40 assertions. All CI checks on this head are green, including browser, live Clerk and packed CLI/tier 2 suites.
Focused tests and selected direct-check output
Test Files 7 passed (7)
Tests 178 passed (178)
PASS signed-out card is a private 401 sign-in door
PASS member cannot turn agent access off
PASS rollback to v1 removes the panel
PASS rollback to v3 restores the panel
PASS retired card has no panel
PASS restore from retirement restores the panel
PASS deleted card has no panel
PASS restore from deletion restores the panel
The portal/shared-shell and vocabulary surfaces apply: the shell component, UI spec, product description and Portal glossary agree. The extracted Company-page sentence helper is covered by the Company-page suite. Reverse states were exercised above. There are no API/CLI contract, migration, dev-loop, company-resource or package-layout changes in this diff.
Rollback answers: match the diff. This adds rendering and a shared CSS component, with no migration, persisted state change, new route or CLI contract; no one-way label is needed. CI's rollback-rehearsal job passed by correctly skipping: “No migration or handler descriptor changed, so there is no rollback to rehearse.”
Not run
- Full local
pnpm verifyand local live-Clerk sign-in were not rerun; used the green CI results at the checked head plus the focused local suites. - A complete agent-connection flow is unavailable at this stacked head:
/machines#connect-an-agentreturns Your machines, but Your machines shows how to connect an agent and lists the agents you've connected #853's connect section is not present yet. The panel emits the intended URL, as the PR documents.
Notes
-
The environment's installed CLI refuses publishing even a minimal agent area with
invalid_manifest: “Could not inspect the server bundle. Its modules must load and export only valid handlers.” A freshpnpm dev transcriptreproduced the same failure on both stacked basecdd420band head31862c3, so this is a baseline/stack issue, outside this rendering diff. The panel fixture was published successfully with the head's source CLI; the server and browser checks used the unmodified head.base cdd420b: exit 1, invalid_manifest (bundle inspection) head 31862c3: exit 1, invalid_manifest (bundle inspection) -
This verdict covers this layer of the stack, not standalone readiness of the whole MCP feature. The PR already calls out that it must merge with the stack.
cdd420b to
9c97a47
Compare
31862c3 to
f74b681
Compare
9c97a47 to
3b82274
Compare
A live patch whose current version has agent tools gets a side panel beside its card's Overview: each tool in open_patch's order with Reads or Changes, its description opening in place, and Connect your agent. With agent access off a note names the admins instead, and an admin gets Turn it on at Company. The card's two-column layout is the shell's new card-split; sentenceList moves to core for its second page. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The panel read whatever version was current when it ran, so a publish or rollback between the card's read and its own could put one version's tools beside another's Overview. It now reads the card's version. Renderer tests cover several admins, the viewer as "you" and escaping. Co-Authored-By: Claude Opus 5.5 <[email protected]>
f74b681 to
45c2e4a
Compare
…esh tokens (#878) Stacked on #876 (ticket #845); merges with the rest of #833's stack, not alone. ## What changed People's agents had no credential of their own: the only bearer was a machine token, which opens the CLI's API. This adds the agent connection, the `work` credential that Patchy MCP's door (#851) will take, with its storage and tokens. Consent (#849) creates connections and #847 ends them; this is the credential itself. Closes #846 ## Look at **The one recoverable secret.** A retry within a minute of a rotation gets the same new tokens, so they must be kept recoverable for that minute. They're encrypted (AES-256-GCM) under a key derived (HKDF) from the refresh token that was rotated, not under a server key. Only whoever presents that old token can read the copy. The database holds its hash, which yields no key, so a database leak alone reveals nothing, and no keyring or `PATCHY_CREDENTIAL_KEYS` dependency enters Auth. Whether a copy is served is decided by the database's clock alone. The server's sweeper also drops every copy past its minute, every 15 seconds whatever the traffic, so none is stored much past it. See `packages/auth/src/AgentConnections.ts` and the sweeper in `apps/server/src/Server.ts`. **Reuse detection keeps every refresh token a connection issued** (as hashes, in `agent_connection_refresh_tokens`), not just the previous one. Otherwise someone who copied a token and rotated twice could make the real client's later reuse look "unknown", and keep the connection. A partial unique index keeps one current token per connection: the one chain. **Everything runs on the database's clock.** The hour, the retry minute, the 30 idle days and the comparison with #838's credentials-ended stamp are all `clock_timestamp()` in the statement that uses them, so app servers whose clocks disagree can't move any boundary. The tests move time by backdating stored stamps rather than with `TestClock`. The `work` bearer check is one `UPDATE … RETURNING`: it checks the token and stamps last used on every admitted call, so last used is the last call and 30 idle days are exact. **The bearer check takes its purpose.** `Authorization.identify("build" | "work")` maps each purpose to its own store and identity type, with no casts. The API guard and dev reads now ask for `"build"`. Agent tokens are never stored as machine tokens, so any release's API refuses them as unknown. ``` $ pnpm --silent dev mcp-token [email protected] --client Codex Codex can act as Patchy Dev at Patchy Dev. Token pwa_… Connection agc_ks84kxpmpsg6alxmkpbsazx3 $ curl -s -o /dev/null -w "%{http_code}\n" -H "Authorization: Bearer $agent_token" $url/api/me 401 $ curl -s -w "\n%{http_code}\n" -H "Authorization: Bearer patchy-dev-token" $url/api/me {"user":{"id":"usr_dev",…},"machine":{"id":"tok_dev","name":"Dev Machine"}} 200 $ pnpm --silent dev mcp-token [email protected] --client Codex Nobody with the email [email protected] is in this instance's database yet; sign in as them once first. ``` In the dev database the minted connection holds only 64-character hashes, nothing in `machine_tokens`, and an access lifetime of `365 days`. ## How it was verified - `packages/auth/src/AgentConnections.test.ts`, 12 cases, one per Done-means line and threat: - an access token passes for 59 minutes and is refused at 61; - refresh rotates, and a retry inside the minute gets the same tokens; - four racing refreshes of one token all get the same tokens, leaving one chain; - reuse after the minute, including a token two rotations back, ends the connection, and the ending is committed before `RefreshRefused`; - a retry is refused once the connection is disconnected or its person deactivated; - 30 idle days end a connection however often it refreshes; every call stamps last used and refreshes never do; - the sweep drops a retry copy past its minute and keeps one still inside it; - a connection made at or before the credentials-ended stamp is dead; - each purpose refuses the other's credential (and an access token used as a refresh token ends nothing); - the dev mint's access token is year-long. - The auth and server packages, dev reads and the dev runner suites pass, including the sweeper's schedule test. Typecheck and lint pass. - By hand on this worktree's instance, as above. - **Rollback rehearsal:** step 2 now mints a connection with HEAD's `pnpm dev mcp-token`, and every later step's `/api/me` must answer its token 401. `pnpm test:rollback-rehearsal --live e4243ff` (main's tip, with #837 and #838) passed at 223af6a: `e4243ff → 223af6a → e4243ff, in 189s`. CI's `rollback-rehearsal` passed too. - **Not yet built, so not checked here:** the door itself (#851), consent (#849), and the endings that write rows (#847). `pnpm dev mcp-token`'s token works at `/mcp` once #851 lands. **Surfaces.** Migrations: `0022_agent_connections`, above the stack's 0021. The vitest template takes the tables through `apps/server`'s migration record, and its seed rows are unchanged, so tests mint their own. `docs/DEVELOPMENT.md` and the `patchy-dev-loop` skill cover `pnpm dev mcp-token`. The Auth glossary's *Agent connection*, *Purpose* and *Machine token* already read as built, so they're unchanged. No route, CLI command or `docs/API.md` change. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required Three new tables; nothing existing changes shape. - **What does a revert leave behind?** The three agent connection tables and any rows in them (only dev-minted ones until consent ships). - **Does the release before it still work with that?** Yes. It never reads those tables, and an agent connection's token is unknown to its API. 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]>
## What changed Patchy MCP has been live in production since release 17, but the product doc, the glossary map and the MCP glossary still called it specified or being built. They now describe what runs, and where the build settled a detail differently from the spec, the spec now says what the code does. Production acceptance (#861) hasn't run: the section says so, and claims about particular clients are framed as what the build was designed for. Part of #862. This is everything in #862's "What to do" except "What remains takes acceptance's findings", which waits for #861. ## Look at **Status and pointers.** Each of these now reads as built: - `docs/product.md`: the "Built and live" intro line names Patchy MCP; the Patchy MCP section opens "Built, and live since release 17", links #833 and says #861 hasn't run. - The same file's tier 2 sentence, `agent/` pointer, Companies (admins, deactivation), Who's who and Bounds' admission rule. - `GLOSSARY-MAP.md`: Auth and Patchy MCP. - `packages/mcp/GLOSSARY.md`. - `README.md`: the layout, plus one sentence on tier 2. - `AGENTS.md`'s tier 2 line. - `docs/OPERATIONS.md`: request events. **Spec details the build settled differently.** Each claim was checked against main: | Claim in the doc | What main does | Where | | --- | --- | --- | | A forwarded host is trusted from Patchy's proxy | The door never believes a forwarded host and refuses two `Host` fields | `packages/mcp/src/RequestTrust.ts:7-10` | | `Host` gates the OAuth endpoints too | Only `/mcp` is Host-gated; a dev instance serves every route on `127.0.0.1` | `packages/mcp/src/Door.ts:372`, `packages/auth/src/OAuthEndpoints.ts:19-20` | | An unknown method is `404` | `404` on 2026-07-28, `200` on legacy, where 404 means session ended | `packages/mcp/src/Door.ts:356-363` | | An `unknown_outcome` always resolves on retry | Only until a few minutes before 24 h; then `key_expired` | `packages/mcp/src/ChangeKeys.ts:116-123`, `Calls.ts:339-347` | | An action's key never runs again | Unless Runtime refused the first try before it started | `packages/mcp/src/ChangeKeys.ts:60-64`, `Calls.ts:409-419` | | `resource` is bound through exchange and refresh | Optional; must name the door wherever sent | `packages/auth/src/Consents.ts:203-205, 345-348` | | Consent re-asks after an account switch | Also re-asks an Allow after the client's name changes | `packages/auth/src/OAuthEndpoints.ts:423-436` | | With agent access off, consent names the admins | To members; an admin is told to turn it on | `packages/auth/src/OAuthEndpoints.ts:182-185` | | "logged as Jordan via Claude" | The person's full name: "Jordan Lee via Claude" | `packages/auth/src/OAuthEndpoints.ts:151-162` | | The docs say how to reconnect by hand | Not written; Connect an app gives first-time steps only | no such doc in `docs/`, `skills/`, `packages/sdk/skills` | | Publish's warning points at `<instance>/company` | `<instance>/company/agent-access` | `packages/patches/src/PatchesApi.ts:454` | | The instance names a duplicated tool | It can't: inspection drops the bundle's message; only the CLI names it | `packages/execution/src/inspection.ts:12-16` | | A read-only action's writes are type errors | Table and file writes are; Pidgeon writes typecheck and the callback gate refuses them | `packages/patchy/src/server.ts:247-262`, `packages/runtime/src/CallbackGateway.ts:107-111` | | `dev.log` names the person | It writes their id: `usr_dev via patchy dev …` | `packages/patchy/src/devLog.ts:23-27` | | New repos include `agent` | Tier 1 and 2 repos do | `packages/patchy/src/initProject.ts:207` | | The MCP request event says whether its binding is agent-only | Only the binding event carries `agentOnly` | `packages/analytics/src/WideEvents.ts:228` | | An in-flight slot is held after the client disconnects | A client gone before dispatch gives it back | `packages/mcp/src/Admission.ts:13-17` | | The week-unused note opens "Not used since 2 Oct." | It opens "If you reconnected …" | `packages/auth/src/MachinesPage.ts:178` | | "today a person types everything into them" | Agents now find, read and change patches too | the section itself | | Pages "get phone checks when built" | They were checked at 390 px in their PRs' screenshots (#871 #876 #882 #885 #931 #932) | — | ## How it was verified - Four read-only passes went claim by claim through the Patchy MCP section against main at 2f9f7c1. I re-read the code for every finding before changing a line. The table lists each change. - **Findings left as they are:** - "the one secret Patchy keeps recoverable": the context is the connection's tokens. - "each change gets a fresh change key" in `patchy dev agent`: the code's own comment says the same. - The lists of which outside clients can connect: these are facts about those clients, and the code offers no dynamic registration. - `pnpm check`: format, lint, typecheck and synth passed. Two test files failed under load average 19, a 5 s timeout in `PgliteCompanyDatabases.test.ts` and a worker SIGKILL in `devExecution.test.ts`. Both passed when rerun alone. Neither touches docs. - **Not done here:** `packages/sdk/skills/patchy-server/SKILL.md:415` and `packages/sdk/src/sdkCapabilities.ts:107` say a patch's tools fit in 64 KiB, but the check allows 60 KiB of that answer. Those files belong to another lane, so they're left for a follow-up. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required Docs only. - **What does a revert leave behind?** Nothing; the docs go back to calling Patchy MCP specified. - **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). --------- Co-authored-by: Claude Opus 5.5 <[email protected]>








Stacked on #875 (ticket #844); merges with the rest of #833's stack, not alone.
What changed
Nothing on a patch's card said what someone's own agent could do with it. Now the card of a live patch whose current version has agent tools shows What agents can do beside its Overview: each tool in
open_patch's order, its name in code with a Reads or Changes tag, its description opening in place, then "Connect your agent". With agent access off, a note naming the admins takes the connect link's place, and an admin also gets "Turn it on at Company". A patch without agent tools looks as it does today.Closes #845
Look at
The card with agent tools
The brightline scenario's new-business card, its version 2 published with an
agent/folder that re-exports four of its handlers with descriptions. Before this PR the card looks like new-business in the before-and-after below: no panel.Access on, as Jordan (member), with
addNoteopenedAccess off, as Jordan (member): the note names the admin in place of Connect your agent.
Access off, as Allison (admin): "that's you" and Turn it on at Company
Phones: the panel drops below the card.
Playwright full-page captures of this worktree's
brightlineenvironment at2821ae1. The head31862c3is that commit restacked onto the stack below as it moved, so it renders the same.pnpm dev comparecan't show these states: it starts from fresh scenario data, and scenario patches get agent areas only in #859.A card without agent tools looks as it does today
Before and after, as Jordan Lee (member)
Before is
c76773f(where this branch left mcp/844-dev-agent) and after is2821ae1(mcp/845-card-agent-panel), both on thebrightlinescenario, frompnpm dev compare.Every page answered 200 with no browser errors.
/patches/new-business1280px, after
1280px, before
/patches/kudos1280px, after
1280px, before
Choices worth a look
card-splitputs the panel beside the whole card on the Overview tab only, top-aligned with the breadcrumb; below 960 px it drops under the card.card-splitis the one new shell piece (packages/core/src/html.ts,ui-consistency); everything else composesside-panel,list-compactrows withdetails,tag,note-warnandbtn./company#agent-access)./machines#connect-an-agent, which Your machines shows how to connect an agent and lists the agents you've connected #853 builds; until then the link lands on Your machines' top. The spec's card line now names the anchor so Your machines shows how to connect an agent and lists the agents you've connected #853 uses it.agentTools, so a rollback to a version without tools removes the panel. Retired and deleted cards have none.How it was verified
PortalPages.test.ts› what agents can do on a socket: a member, owner and admin each see the tools inopen_patch's order (page handlers left out, a read-only action as Reads), escaped descriptions and the connect link; the panel is absent on Versions; with access off a member sees the admins named and no links, an admin sees "you" and Turn it on. A second test keeps the card unchanged for a tier 2 patch without agent tools, a tier 0 page, a patch rolled back to a version without tools, and a retired patch.pnpm exec vitest run packages/portal packages/core packages/auth/src/CompanyPage.test.ts: 196 passed.render.test.ts›renderAgentPanel: each tool's kind and escaped description, the connect link while on; while off, several admins named with the viewer first as "you", escaped company and admin names, and Turn it on only for an admin.pnpm verifyon31862c3: format, lint, typecheck, synth, postgres-concurrency, cli-smoke, tier2-smoke and browser passed. Under load from other lanes' runs (load average about 14), two CLI tests outside this diff timed out at 30 s,cliRepoBuild.test.tsandcliRepoDescriptions.test.ts; both files pass run alone (18 tests).main'se4243ff, 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 e4243ffpassed e4243ff → 31862c3 → e4243ff in 159 s.31862c3is green.clerk-livewas re-run once after the runner's Ubuntu mirror stalled duringaptand the job was cancelled before any test ran.Release impact
Tick exactly one.
Breaking — requires action from anyone already running this
Not breaking — no action required: a panel on a page, with no schema, API, CLI or configuration change.
What does a revert leave behind? Nothing: no migration, no stored rows, no new route.
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).