Repository navigation
feat(mcp): the log says which agent made each change: "Jordan Lee via Claude" - #888
Conversation
2e595f1 to
8a5a41c
Compare
|
Review: GPT-6.1-Sol (xhigh), one round on Round 1 found nothing blocking, should-fix or nit. Its notes on the four risks it was asked to weigh:
No fixes needed. |
8a5a41c to
2313654
Compare
b2ab836 to
fd27c49
Compare
Acceptance: PASS with notesChecked Done means
Golden journeys
Evidence
Rollback answers: match the diff. This layer introduces no migration or new stored row shape; it displays the stack's existing Not run
Notes
The isolated instance, scenario data and browser tab were removed. Tracked files and the PR's code, branch, body and labels were left unchanged. |
875e632 to
d1b1654
Compare
fd27c49 to
1013df8
Compare
d1b1654 to
ad271a6
Compare
… Claude"
Everywhere the log names a person, an agent's work reads "<Person> via <Client>",
with the client name approved at consent: the Log tab's person column and the
steps that acted as the person, the card's Recent activity, a connection's recent
calls, and `patchy logs`, whose entries carry `agent: { name } | null`. A page
from an instance before agents reads as null. No new column, tag or filter.
The rule is the page's: a quiet agent query leaves no row; a query that logs or
fails, a read-only action and a change each get one. patchy-server's agent area
states it in the tested skill text's words.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1013df8 to
52de1e0
Compare
… flight per person (#889) Stacked on #888 (ticket #856); merges with the rest of #833's stack, not alone. ## What changed A person's agent could call a patch through Patchy MCP as often, and as many calls at once, as its client liked. Only the door's 600 requests a minute held it back. Its calls spent none of the company's admission, and its actions took the same two action slots as the person's own tab. Now `read_patch` and `change_patch` are admitted per person, as the spec's Bounds set out: - **300 calls a minute per person per patch** (`mcp.calls.perMinute`), across their agents, beside the page's own `runtime.calls.perMinute`. An agent's loop never touches its person's tab. - **16 calls in flight per person** (`mcp.inFlight`), across their agents. The seventeenth is `busy` with `retryAfterSeconds: 1`. An admitted call holds its slot until its work settles, including after its client hangs up. - **Company admission is shared**: agents' calls now spend the company's bucket with its pages. - **Agents get their own action slots**: an agent's actions take a `tier2.actions.viewer` key of their own beside the person's page. The company's action slots stay shared. Every counter is per host replica and keyed by the person, never an address or connection. A refusal is the refusal shape over HTTP 200 with `retryAfterSeconds`, writes no log row, keeps the change key free, and names its limit id in its wide event. Each call is also cheaper: it used to read the company's patches with a scan of every version's manifest, about 190 ms per call at 200 patches × 20 versions. It now skips that scan and takes about 27 ms (second commit, measured below). Closes #857 ## Look at **Done means, on a dev instance** (`brightline`, New Business given agent tools, tokens from `pnpm dev mcp-token`, driven by a script against `/mcp`). The loop uses `countDeals`, a read-only action, which always writes a log row, so rows count admitted calls exactly. ``` Jordan's two agents (Codex, Claude), one call after another: admitted 300 in 9.9 s, the 301st → 200 rate_limited, retryAfterSeconds 51: "Jordan Lee's agents called new-business more than 300 times in a minute; try again in 51 seconds. Bulk work wants a tool that takes a list; if new-business has none, its owner, Allison Mahmood, can add one." runtime_invocations for agent.countDeals: +300 (the refusals wrote none) Jordan's tab, while his agent is still refused (pnpm dev shot jordan /brightline/new-business): 200, browser errors: none, the board loaded with live deals (below); the next agent call: rate_limited, 44 s Priya's two agents, 17 waitAction calls at once (read-only, 2.5 s each): 16 ok, 1 → busy, retryAfterSeconds 1: "Priya Shah already has 16 calls in flight through their agents; try again in a second, once one has finished." 16 slow calls whose client hangs up after 0.5 s: the next call at once → busy; 3 s later → admitted; the 16 rows say reply_delivered = false ``` Jordan's tab while his agent was refused:  The two refusals' wide events, from `dev.log`: ``` {"route":"/mcp","status":200,"mcpTool":"read_patch","agentTool":"countDeals","outcome":"refused","code":"rate_limited","limitId":"mcp.calls.perMinute","clientName":"Codex", "limits":[…{"limitId":"mcp.calls.perMinute","value":300,"peak":300}]} {"route":"/mcp","status":200,"mcpTool":"read_patch","agentTool":"waitAction","outcome":"refused","code":"busy","limitId":"mcp.inFlight","clientName":"Codex", "limits":[…{"limitId":"mcp.inFlight","value":16,"peak":16}]} ``` The two `busy` cases stay apart in events: a change key still running has no `limitId`, and the in-flight cap's says `mcp.inFlight`. On the dev instance, 17 slow *queries* at once got 8 through and 9 `busy` from the company's database connections. A query holds a connection for its snapshot while it runs. This is the spec's note that 16 in flight can still fill the company's connections, and it is not the cap. The in-flight run above uses read-only actions, with Brightline's action slots raised by an override so the cap is what's measured. **How the slot follows the work** (`packages/mcp/src/Admission.ts`, `Invocation.AgentCall.retain`). The order is: the minute on the patch, then a slot, then company admission, all before a change key is claimed. The request holds the slot while it runs. Runtime takes one more hold for each run it forks, inside its uninterruptible region, nested `ctx.run` children included, and lets each go in that run's `ensuring`. The slot comes back when every hold is gone. - A client that hangs up after dispatch leaves the slot held until Runtime's work settles. - One that gives up before dispatch, such as during the wait for the company's server (#858), gives it back at once. - The request still calls Runtime itself, as #855 settled, so a hang-up still reaches Runtime and the log says the reply wasn't delivered. - Nothing makes a request wait for its work. That would hold shutdown for up to an action's 65 s. **An action Runtime refuses before it starts gives its key back.** That covers its own action slots (`InvocationBusy`), a refused bind (`LifecycleError`) and the execution service at capacity (`ExecutorBusy`). Before this PR, a `busy` refusal said to retry in a second, and the retry with the same key got `key_used`. A mutation's key is never discarded, because its retry already runs under its mutation key. **The per-call company patch read** (handed over from #854). Every agent call, and every catalogue call, read the company's patches through `Patches.read`. Its shared-read edges scan the `uses` of every version of every patch. Measured on the test Postgres, with manifests the size of New Business's (3 KB stored), p50 over 35 calls on a loaded machine: | Company | `Patches.read` (portal, unchanged) | whole `read_patch`, before | after (`Patches.list`) | |---|---:|---:|---:| | 10 patches × 1 version | 2.5 ms | 11.6 ms | 10.3 ms | | 200 × 1 | 26 ms | 34.5 ms | 24.4 ms | | 200 × 20 | 183 ms | 189 ms | 27.3 ms | | 300 × 40 | 513 ms | 340–540 ms | 38.7 ms | At 189 ms a call, one person's agent at 300 a minute on one patch would keep about one platform database core busy, and two across patches under the door's 600. That isn't comfortable. `Patches.list` answers the same patches by the same rule without `reads` and `dependants`, which the door never shows. With it, 300 a minute costs about 0.14 database seconds per second per person per patch, flat in versions and linear only in patches. The portal still uses `read` and pays the version scan on each page. That is out of scope here; caching or bounding those edges is the lever if it shows in data. **`CompanyAdmission`** is the company token bucket, moved out of `RuntimeProduction` into its own service now that it has two consumers. `RuntimeProduction.layer` provides it, so the door spends the same instance as pages. ## How it was verified - **Tests, red first:** - `packages/mcp/src/Admission.test.ts` (4 cases): - the minute per person per patch, across two connections, with TestClock rolling the window. Another patch, a colleague and another company each keep their own; a refused change keeps its key. - the seventeenth in flight across three connections, with a fake Runtime that retains as Invocation does. A hang-up keeps its slot until its work settles; a failure and a give-up before dispatch give it back. A burst racing releases never runs more than 16. - company admission shared with a page's spend. - an action refused before dispatch (action slots, bind, executor capacity) keeps its key. - `packages/runtime/src/Invocation.test.ts`: - an agent's own action slots beside its person's page, with the company's shared and no row for a refusal. - `retain` taken at dispatch and let go when the work settles, after the caller is interrupted, and held by a `ctx.run` child after its action returns; never taken by a call refused, or given up, before dispatch. Fails without the change. - `packages/patches`: `list` answers what `read` does, minus the edges. - **Suites:** `packages/mcp`, `packages/runtime`, `packages/patches`, `packages/portal`, `packages/integrations`, `packages/limits` (the `docs/limits.md` render test) and `packages/api/agentTools` are green. A few runtime and catalogue cases timed out at load average 50–67 and passed when rerun alone. Typecheck, `tsconfig.test.json`, lint and format are clean. - **Dev instance:** as above, on this head's code. - **Rollback rehearsal** against `main` at e4243ff, which has #837 and #838: `pnpm test:rollback-rehearsal --live e4243ff` passed e4243ff → 3d625ad → e4243ff → 3d625ad in 360 s. The later commits touch no migration or descriptor schema. - **Review:** GPT-6.1-Sol, two rounds; round 2 found nothing blocking. The findings and fixes are in the comment below. - **`pnpm verify`** on 5d20897: all passed (format, lint, typecheck, synth, test, postgres-concurrency, cli-smoke, tier2-smoke, browser). CI is green on the same head. - **Acceptance:** PASS with notes on 5d20897 (GPT-6.1-Sol, fresh `brightline` data), in the verdict comment below. Its one load flake, a supervised-workerd diagnostics case, passed alone and is filed as #895. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required New operating limits with defaults. No migration, and no wire or CLI change. - **What does a revert leave behind?** Nothing persistent: the counters are in memory, and no rows or columns are added. Company overrides of `mcp.calls.perMinute` or `mcp.inFlight`, if anyone set them, stay as rows the older release doesn't read. - **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 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 #887 (ticket #855); merges with the rest of #833's stack, not alone.
What changed
When someone's agent changes a patch through Patchy MCP, the log already recorded the agent's client name (#843) but showed only the person, so an owner couldn't tell a colleague's own edits from their agent's. Now everywhere the log names a person, agent work reads "Jordan Lee via Codex", with the client name shown at consent: the Log tab's Person column and the steps that acted as the person, the card's Recent activity, a connection's recent calls, and
patchy logs(text and--json). There is no new column, tag or filter.Closes #856
Look at
Codex on a dev instance (Done means). On
brightline, New Business got two agent tools (listDeals, a query;addNote, a mutation). Jordan's Codex connection (pnpm dev mcp-token jordan --client Codex, per-invocation config outside$HOME) first listed the deals, then was asked to add a note:The database afterwards: the two quiet
listDealsreads rolled up with no row; the change has one.patchy logson that patch, base CLI and server vs. this branch, same data:--json, each entry's{ handler, viewer, agent }: before, entries had noagent; after:agentdecodes with a default, so a newer CLI reading an instance from before agents (or after a rollback) printsnullinstead of failing to decode;docs/API.mdshows it asagent?.The pages, as Allison (the owner and admin), after (before one click away):
Log tab:
Log tab before
Card, Recent activity:
Card before
A connection's recent calls:
Recent calls before
Phones, 390 px: before | after
At 390 px the Log and recent-calls tables scroll sideways, as they did before; the longer name wraps in its cell.
The recent calls are staged: a dev instance can't reach a real Postgres (connections need a public TLS host), so the
postgres/warehouseconnection and its two calls (Jordan's page, then Jordan via Codex) were written straight into the dev database. Everything else above came from real calls.pnpm dev comparewould have shown no change, since no scenario seeds agent activity, so both sides are this worktree's instance on the same data, with the base's five changed source files restored for "before".The rule is pinned at the door on real workerd (
packages/mcp/src/Log.workerd.test.ts): a quiet agent query leaves no row; a query that logs, a query that fails, a read-only action and a change each get a row naming the person and the agent. Runtime never looked at the agent when deciding to log, so this test passed before the change and keeps it that way.Escaping. The client name is a stranger's string (≤ 64 characters, controls and bidi marks removed by #846). Every HTML surface escapes it; the portal and connection tests use
Claude <Code> & co. The person always comes first and from Patchy's own records, so a client's name can't change whose work a row shows.How it was verified
fd27c49(on feat(mcp): worker agents change patches, and a retried change is applied once #887's875e632): CI is all green.pnpm verifypassed format, lint, typecheck, synth, postgres-concurrency, cli-smoke, tier2-smoke and browser. Itstestjob hit 8 timeouts in suites this PR doesn't touch, at a load average near 30; those 8 files then passed alone (82 tests).packages/mcpsuite (workerd included),patchy logstext and CLI, and the api package: 20 files, 279 tests.fd27c49(comment below), on freshbrightlinedata. Its notes are outside this diff: the environment CLI's workerd lookup when publishing (Dev environments come with worker agents and patches that have agent areas #859) and a cold release build.dev.logkeeps writingusr_dev via patchy dev(Builder agents call their agent tools locally withpatchy dev agent#844): it names everyone by id, so it matches the platform's " via " in its own terms.patchy-server's agent area states the rule in the tested skill text's words: "Patchy's log records each change and action as "Person via Client", failures included. A query that succeeds withoutctx.logleaves no row; a patch that wants agent reads seen logs them itself, usingctx.agentfor the name."rollback-rehearsalhas nothing of this PR's to rehearse; the stack's rehearsal waits on 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 as Build Patchy MCP #833 says.PatchesApi.test.ts › refuses a blank or over-long description in the bundle("Invalid server manifest: inspection."), a case this PR doesn't touch. It passed on Node 22 and 26 then, alone on Node 24 in acceptance, and on every Node atfd27c49. It isn't filed as a known flake.Release impact
An additive field on the log's wire shape and wording on existing pages; no migration.
agent_namefrom Runtime runs agent tools for agents, as their person #843's migration.agent: null.Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh).