Skip to content

feat(mcp): agents connect through consent: authorize, the code exchange and refresh - #881

Merged
allisonmahmood merged 2 commits into
mainfrom
mcp/849-authorization-flow
Oct 23, 2026
Merged

allisonmahmood merged 2 commits into
mainfrom
mcp/849-authorization-flow

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #880 (ticket #848); merges with the rest of #833's stack, not alone.

What changed

An MCP client couldn't turn a person's consent into an agent connection: nothing answered /oauth/authorize or /oauth/token. Now Patchy is the authorization server. The person signs in before anything else happens. The request is checked before anything is shown. An approval records only a short-lived code. The client's code exchange creates the agent connection, and refresh rotates it.

Closes #849

Look at

  • Nobody is sent anywhere before signing in (packages/auth/src/OAuthEndpoints.ts). GET /oauth/authorize signs the person in first. A refused request is explained on the page and never sent back to the client, because its redirect is vouched for only by a stranger's document (RFC 9700 §4.11.2). Only the person's own answer, Allow or Deny (People answer an agent's request on a consent page #850), goes back to the client, with iss and state. An unsigned request even names redirect_uri=https://evil.example/:
    GET /oauth/authorize?…&redirect_uri=https%3A%2F%2Fevil.example%2F   (no session)
    → 401, the sign-in door; no Location header
      its sign-in link returns to https://patchy.example/oauth/authorize?… and nothing else
      no client document was fetched
    
  • The serialisations (packages/auth/src/Consents.ts), each a race test in Consents.test.ts held open both ways round:
  • The token endpoint's failure limit counts failures only. A failure past 60 a minute from one address is answered 429, and a successful exchange or refresh is never refused, even from a shared address. That's my reading of "counted on failures … so shared egress is never refused for being busy". The other reading refuses everything from an address once its failures are spent. The test answers 429 to an address's failures past the limit, never to its successes pins my reading.

How it was verified

  • Done means. apps/server/src/AgentConsent.test.ts boots the whole server as a dev instance boots it: personas, a <label>.localhost origin, its token endpoint at 127.0.0.1, and Claude Code's fixture document. It covers each Done means item:
    • The scripted client reads the metadata. Signed out, it gets only the sign-in door. It signs in as a persona, gets the consent page, approves through Consents.approve, exchanges with a loopback redirect on a random port and refreshes.
    • The work token is 401 on /api/me.
    • The replay ends the connection, so even the refreshed token stops working.
  • With agent access off, nothing is issued: Consents.test.ts › with agent access off nothing is issued… and both off races.
  • The threat model as tests:
    • PKCE downgrade (no method, plain, no challenge, or the challenge sent as the verifier);
    • resource and redirect_uri mix-ups;
    • a parameter sent twice;
    • code injection across accounts (each code redeems only with its own verifier, as its own person);
    • a refused exchange leaving the code to the request it was approved for;
    • expiry;
    • iss on approve and deny;
    • the per-address failure limit and the per-connection rotation limit;
    • CORS * without credentials in production, and none plus no preflight on a dev instance.
  • Mutation check. I removed the off deletion, the stamp check and the replay ending one at a time, and 8 of the then 12 Consents tests failed.
  • A late replay still ends its connection, after the code expired and after a sweep (Consents.test.ts › a replay long after…).
  • Retries within the minute don't spend the rotation limit (OAuthEndpoints.test.ts › limits rotations per agent connection…).
  • Suites. pnpm typecheck and eslint are clean. These all pass:
    • the auth suite (198 tests);
    • companies (55);
    • limits (25);
    • the server's AgentConsent, Server, ApiGuard, SweepSchedules and migrations suites.
  • pnpm verify passed on aeb26fd: format, lint, typecheck, synth, test, postgres-concurrency, cli-smoke, tier2-smoke and browser (81 specs).
  • Rollback rehearsal: pnpm test:rollback-rehearsal --live e4243ff passed, going e4243ff → fb827df → e4243ff → fb827df in 191 s. e4243ff is main's tip and 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. CI's rollback-rehearsal job also passes on aeb26fd.
  • Review: GPT-6.1-Sol (xhigh) ran two rounds; see the review comment below. Round 1 had one blocking and two should-fix findings, all fixed in aeb26fd. Round 2 found nothing blocking.

Surfaces:

  • the limits registry (oauth.token.failures.perMinute, oauth.token.rotations.perMinute), rendered into docs/limits.md;
  • the Auth glossary's Consent;
  • migration 0023_agent_consents;
  • ClientDocumentNetwork now comes from the launcher (start.ts brings the pinned one, so a test can serve fixtures);
  • AgentConnections.chainOf, a lock-free read the token endpoint checks client_id and limits by before it calls Agent connections: the work credential and its tokens #846's refresh.

Untouched:

For #850: the authorize page's success branch (consentPage in OAuthEndpoints.ts) is a placeholder heading. The consent page replaces it and adds the POST answer: re-run Consents.check on the form's fields, then approve or deny, which return the redirect.

Release impact

  • Breaking — requires action from anyone already running this
  • Not breaking — no action required

Two new routes, a new table and two operating rows. Nothing existing changes shape.

Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh).

@github-actions github-actions Bot added area:server Touches the server area area:docs Touches the docs area size:xl Over 1,000 changed lines; review in multiple passes labels Oct 22, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review: GPT-6.1-Sol (xhigh), two rounds

Round 1, on fb827df: one blocking, two should-fix.

  1. Blocking: fixed in aeb26fd. Approval's sweep deleted expired codes even after they'd been exchanged. A replay after the code's minute was then refused as unknown, and the connection stayed live. Now the sweep deletes only unexchanged codes (connection_id IS NULL), and an exchanged code stays with its connection. A new test covers it: a replay long after the code expired still ends the connection it made.
  2. Should-fix: fixed. The per-connection limit counted refresh attempts, so retries inside the minute spent rotations. AgentConnections.chainOf now also reports whether the presented token is current, and only a current one spends oauth.token.rotations.perMinute. Two concurrent refreshes with one current token can both spend one; I accepted that, since it only ever errs strict. The endpoint test now does retries between rotations.
  3. Should-fix: fixed. A reason switch chose user-facing messages and the wire error, which the Effect service spec forbids. Now:
    • AuthorizeRequestRefused carries parameter, with one message;
    • CodeRefused is always invalid_grant, and its reason is diagnostic only;
    • a foreign resource is its own ResourceRefused, answered as invalid_target.

Sol agreed with the failures-only reading of the per-address limit: a failure past 60 a minute gets 429, and a success is never refused.

Round 2, on aeb26fd: nothing blocking, nothing new. Sol rechecked all eight threat areas, the ticket and #833 invariants, and the mirrored surfaces.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance: PASS with notes

Checked aeb26fd0c93e012cf201a477254e3d54799cc06a (base 867c0726fdc8b68a7d46df66d9b458a66052bf07, mcp/848-client-metadata / #880) on a fresh, throwaway team instance and disposable test databases, by GPT-6.1-Sol (xhigh) in the Codex harness on T3 Code.

Done means

  • Scripted authorize → approve → exchange → refresh with a fixture document: passed. Re-ran apps/server/src/AgentConsent.test.ts, which boots the full server with personas and the Claude Code fixture. It signs in, reaches the consent heading, approves through Consents.approve as The authorization flow: authorize, the code exchange and refresh #849 specifies, exchanges on the loopback token endpoint, and refreshes. Independently checked fixture-backed approval against the throwaway instance's database and its real HTTP token endpoint; the resulting token authenticates as Ben and is refused by /api/me with 401.
  • A replayed code ends its connection: passed. Independently expired an exchanged code, triggered the next approval's cleanup, then replayed it: 400 invalid_grant; the refreshed access token no longer authenticates and its refresh token is refused. The concurrent-exchange and late-replay tests also passed.
  • With agent access off, nothing is issued: passed. Approval returned AgentAccessOff without inserting a code. Off/on did not revive an earlier code. Also independently checked that Disconnect everything and deactivation/reactivation cancel pending codes, while fresh consent afterward works. Both lock orders in the approval/off and exchange/off race tests passed.
  • An unsigned-in person is sent only to sign in: passed. An unsigned request naming an external client and redirect returned 401, no Location, and a sign-in URL on this instance returning to the original authorization request. Signed in, the malformed request returned an on-page 400 without a redirect. The test also checks that no client document was fetched before sign-in.

Golden journeys

  • Sign in and sign out: passed on team; the company page changed from 401 to 200 after persona sign-in, and the sign-out response cleared the cookie.
  • Log a machine in and out: passed with the environment's packed CLI, clearing inherited API URL/token variables and using its isolated CLI state. Login → browser confirmation → completion → whoami named Ada and Acceptance machine; after logout, whoami exited 1 asking for login.
  • Publish a page; find and open it; reverse its lifecycle: passed. Ada published; Ben found it on Home and by search, then opened it. Retire and delete replaced its content with their notices; restore reopened the same address.
  • Share and unshare: passed. Public sharing returned 200 signed out; company sharing restored the 401 door.
  • Tier 1 live updates and tier 2 tools: passed in existing CI, whose logs I inspected. The browser job passed all 81 tests, including colleague writes updating subscriptions and two viewers staying in sync; tier2-smoke also passed.
  • Invite/join and membership endings: passed in the focused suites and existing CI. The local companies/auth suites cover invitations, revocation, joining, deactivation and reactivation. The Clerk job passed its Backend API and browser tests, including create/revoke/re-invite.

Additional evidence

Focused command at the checked head:

pnpm exec vitest run packages/auth packages/companies packages/limits \
  apps/server/src/AgentConsent.test.ts apps/server/src/Server.test.ts \
  apps/server/src/ApiGuard.test.ts apps/server/src/SweepSchedules.test.ts \
  apps/server/src/migrations.test.ts

Test Files  35 passed (35)
     Tests  312 passed (312)

Independent HTTP checks, using the default registry values:

PASS wrong verifier/client/redirect/resource refused without burning the code
PASS approval creates only a code; denial writes nothing; answers carry iss and state
PASS rotations 1–10 succeed, with a successful retry after each rotation
PASS rotation 11 is 429 with Retry-After; another connection still rotates
PASS failed token requests 1–60 are 400; failure 61 is 429 with Retry-After
PASS a valid exchange from the same exhausted address still succeeds
PASS dev token responses are no-store, have no CORS, and preflight is 404

Production CORS (*, no credentials), duplicate parameters, malformed requests, expiry, PKCE downgrade, account/code injection and optional redirect/resource handling passed in the focused suites. All reported CI checks were green at this head.

Rollback answers: match the diff. Reverting leaves the additive agent_consents table, pending codes and connections in the existing connection tables. The prior release does not read the consent table and continues enforcing credential endings; no existing row or wire shape changed. No one-way label is needed. I inspected the successful rollback rehearsal: all four steps passed, e4243ff → b3995f1 → e4243ff → b3995f1, where b3995f1 is CI's merge checkout for this head.

Mirrored surfaces checked: the two limits and rendered documentation, Auth's Consent glossary, migration composition, and server/test launcher wiring. No API schema, CLI contract, dev runner, package layout or company-resource path changed.

Not run

  • I did not independently replay the named brightline demo sequences or rerun live Clerk; the broader journey results above rely on the existing green CI at this head.
  • Real hosted-client/production consent was not exercised. This run stayed on throwaway local instances and fixture documents.

Notes

@allisonmahmood
allisonmahmood force-pushed the mcp/848-client-metadata branch from 867c072 to 056b09a Compare October 23, 2026 02:09
@allisonmahmood
allisonmahmood force-pushed the mcp/849-authorization-flow branch from aeb26fd to 9fa5e38 Compare October 23, 2026 02:09
@allisonmahmood allisonmahmood mentioned this pull request Oct 23, 2026
@allisonmahmood
allisonmahmood force-pushed the mcp/848-client-metadata branch from 056b09a to 1dd34b1 Compare October 23, 2026 13:50
Base automatically changed from mcp/848-client-metadata to main October 23, 2026 14:08
…ge and refresh

Patchy becomes the authorization server for agent connections. GET
/oauth/authorize signs the person in before anything else, then holds the
request to every rule and explains a refused one on the page, sending nowhere.
Consents.approve records only a minute's code for the account, bound to its
client, redirect and S256 challenge; deny records nothing; every answer
carries iss. POST /oauth/token exchanges a code once, creating the agent
connection, and a replay ends the connection it made before invalid_grant.
Refresh runs AgentConnections' rotation with resource and client checked.

Issuance and the exchange hold agent access; off deletes the company's codes
not yet exchanged; a code made at or before the credentials-ended stamp is
dead. Failed token attempts are limited per address (a success is never
refused) and refreshes per connection, as registry rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ns spend the refresh limit

Sol's round 1. Expired codes are swept only while unexchanged, so an
exchanged code stays with its connection and a replay after its minute still
ends it. The per-connection limit counts refreshes that present the current
token, so retries within the minute spend nothing. Authorization request
refusals name their parameter in one message; a foreign resource at the token
endpoint is its own error, ResourceRefused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the mcp/849-authorization-flow branch from 9fa5e38 to d994ee4 Compare October 23, 2026 14:08
@allisonmahmood
allisonmahmood merged commit 3469f0e into main Oct 23, 2026
36 of 38 checks passed
@allisonmahmood
allisonmahmood deleted the mcp/849-authorization-flow branch October 23, 2026 14:42
allisonmahmood added a commit that referenced this pull request Oct 23, 2026
Stacked on #881 (ticket #849); merges with the rest of #833's stack, not
alone.

## What changed

An MCP client asking to connect got #849's placeholder heading and
nothing to answer with. Now the person gets the consent door picked on
#739. It shows who is asking to act as whom, and what the agent will and
won't be able to do. The person answers Allow or Deny, and only that
answer goes back to the client.

Closes #850

## Look at

**1. The answer's guards** (`packages/auth/src/OAuthEndpoints.ts`).
`POST /oauth/authorize` posts back the request's own query and runs
`Consents.check` on it again, then calls #849's `approve` or `deny`.
Each item below is a test in `OAuthEndpoints.test.ts` or
`DevPersonas.test.ts`. I removed each guard in turn and its test went
red.

- **CSRF.** The answer goes through `RequireSession.sameOrigin`, the
same check as every first-party POST. Another `Origin`, `Origin: null`,
or no `Origin` without `Sec-Fetch-Site: same-origin` gets a 403 before
the body is read. Nothing is recorded.
- **Clickjacking.** Every consent page sends `frame-ancestors 'none'`.
- **Account switch.** The form carries the `userId` the page was
rendered for. If someone else is signed in when the answer arrives, the
page is drawn again for them with the warning, as a 409, and nothing
goes back to the client.
- **Persona switch mid-consent (dev only).** `GET /dev/sign-in?as=` is
refused with a 403 for `Sec-Fetch-Site: cross-site` or `same-site`, and
sets no cookie. `none`, `same-origin` and no header all still switch.
- **Open redirect through Deny.** Deny runs the same check as Allow. A
query whose `redirect_uri` the document doesn't list gets the "can't
connect" page as a 400, with no `Location`. A signed-out answer is sent
back to the page (303 to `GET /oauth/authorize?…`) and answers nothing.
- **What the page echoes.** The client's name is already cleaned and cut
to 64 characters by #846's `clientName`. The site is a host Patchy
fetched from, so DNS bounds it. Both are escaped with everything else.
The test document's name is `<img src=x onerror=alert(1)>` plus U+202E
and 80 `a`s. It renders escaped, without the bidi control, and cut to 64
characters.
- **`form-action`.** Browsers hold a form's redirect to `form-action`,
so the page adds the redirect's origin, for example `form-action 'self'
https://claude.ai`. A host CSP can't name exactly, such as `[::1]` or
one with other characters, adds only its scheme. A stranger's document
can never write into the header.
- **The name the connection keeps** is the one the page showed. The
answer fetches the client's document again, so the form carries the
shown name. An Allow whose document now names the client differently
asks again (409), and approves nothing.
- **A request too long to carry through sign-in** is refused before it
(414). Sign-in and Use another account carry the request's address in
their own addresses, encoded again at each hop, and a browser adds the
page it came from as `Referer`. The bound is 2,048 characters of query
(real clients send under 1 KiB). The socket test carries the longest
allowed request through sign-out and back to the sign-in door, with a
browser's headers.

**2. For Allison: four calls the ticket didn't settle.**

- **The page lasts ten minutes.** "A request that ran out" needs a
lifetime, and nothing server-side expires before Allow. The form carries
when it was shown. An answer more than ten minutes later gets "This
request has run out" (410), and nothing goes back to the client. Ten
minutes matches a device login's code. The time isn't signed: only a
same-origin POST from the person's own browser can send it, so changing
it helps no one but themselves.
- **"Logged as Jordan Lee via Claude"**, with the full name. The mock
says "Jordan via Claude", but the log will write "Jordan Lee via Claude"
(#739), and the page promises what the log says.
- **Use another account** is today's "Not you?" sign-out block under the
footer, with a new label. The mock puts it inline in the footer
sentence, but a sign-out needs a POST, and the shell has no inline
link-button style. `/logout` now takes a `return`, so it signs out and
lands on the sign-in door for the same request. The off page has it too,
for someone signed in to the wrong company.
- **The limit counts signed-in loads and answers.** Signed-out loads
only reach the sign-in door, fetch nothing and spend nothing. A connect
costs two (page and answer). This is `oauth.consent.perMinute` in the
registry and `docs/limits.md`.

## Before and after

Before, #849's placeholder:

| Desktop | Phone |
| --- | --- |
|
![](https://github.com/user-attachments/assets/39bd7428-5173-4696-8b10-b41e38c0f16c)
|
![](https://github.com/user-attachments/assets/3bcaf658-10f7-4a30-b6a4-c1ca63a8d6b5)
|

After, as Jordan Lee (member) at Brightline Studio on a `pnpm dev up
brightline` instance. The real Claude and Claude Code documents were
fetched from claude.ai.

**Claude (hosted redirect)**


![](https://github.com/user-attachments/assets/9178ae83-d7b8-4272-a32a-3edee0639672)

**Claude Code (answer returns to this computer)**


![](https://github.com/user-attachments/assets/5a6f3f92-fe37-462f-9822-cdb3c7b27354)

**The account changed while the page was open** (Priya signed in from
another tab, then Jordan's page pressed Allow)


![](https://github.com/user-attachments/assets/9ee061a4-75f2-425b-9dae-147f00f0e67f)

**Agent access off, as a member, then as an admin**


![](https://github.com/user-attachments/assets/c8a984c5-96c3-451e-bc82-d910aecaa7e0)


![](https://github.com/user-attachments/assets/966607a7-7b6a-4111-af03-a99526bd183e)

**The request ran out** (`shown` set an hour back, then Allow)


![](https://github.com/user-attachments/assets/0d6a8ff8-84f6-4609-ade7-04aa51791e37)

**Deactivated** (today's page) **and no company yet** (create-or-join,
then back to consent, where the new company's access is off and its
creator is the admin)


![](https://github.com/user-attachments/assets/b3c6d53b-4b00-44b1-89c5-fcb142d26d46)


![](https://github.com/user-attachments/assets/6e367aca-91df-4475-b9f4-534dfca1f2e5)


![](https://github.com/user-attachments/assets/f62d2817-8f6f-4b07-8247-cf7b7a762732)

**Use another account** lands on the sign-in door, returning to the same
request


![](https://github.com/user-attachments/assets/2b2e0c0c-e6ae-4353-9b56-17a8ab8e2f87)

**Phones (390 px)**

| Claude | Claude Code | Account changed |
| --- | --- | --- |
|
![](https://github.com/user-attachments/assets/9ce876d4-cc98-415c-adba-b549535497ef)
|
![](https://github.com/user-attachments/assets/c64ce9a3-cd38-4427-8f15-a292b0b61c4e)
|
![](https://github.com/user-attachments/assets/ba92c005-a126-4eaf-8f38-922cd9be529f)
|

| Off, member | Off, admin | Ran out |
| --- | --- | --- |
|
![](https://github.com/user-attachments/assets/ec578e32-ba0b-4d04-87cc-87b384634f40)
|
![](https://github.com/user-attachments/assets/8708dd07-a640-4dd1-9510-4f50463666c5)
|
![](https://github.com/user-attachments/assets/bc094fd0-8bc4-4c1a-9982-37a22c8b5fb4)
|

| Deactivated | Create-or-join | Back to consent | Use another account |
| --- | --- | --- | --- |
|
![](https://github.com/user-attachments/assets/7dfc2573-65c8-4cd9-9587-a635b4423b47)
|
![](https://github.com/user-attachments/assets/56fb8672-b7cd-4ecc-a62b-54181a538731)
|
![](https://github.com/user-attachments/assets/ea81ddb7-8267-42de-88ab-49917d2958ac)
|
![](https://github.com/user-attachments/assets/0949b97e-3ff1-41cd-b6be-c882ac6c0a70)
|

## How it was verified

- **Done means, on a dev instance in a browser** (Playwright as dev
personas against the `brightline` environment, with the real claude.ai
documents):
- **Allow.** Claude Code's request, with the redirect on a random
`127.0.0.1` port where the script listened. The callback got `code`,
`state=client-state` and `iss=<instance>`. The code exchanged at
`/oauth/token` for `200 {access_token, expires_in, refresh_token, scope:
"patches", token_type: "Bearer"}`.
- **Deny.** The callback got `error=access_denied`, `state` and `iss`,
and no code.
- **Account switch.** Priya signed in from another tab, then Jordan's
page answered. Patchy asked again as Priya and sent nothing back.
  - **Every state** above, at 1280 px and 390 px.
- **Tests.**
  - `OAuthEndpoints.test.ts` gains 13 consent tests. They cover:
    - the page's content and headers;
    - the loopback warning with its CSP source (IPv4 and `[::1]`);
    - escaping and the cut;
    - Allow then exchange, and Deny recording nothing;
    - cross-site answers;
    - the account switch and the renamed client;
- the ten-minute boundary (TestClock at 10:00 passes, 10:01 runs out);
- access off for a member and an admin, including Allow from a page
shown while it was on;
    - a signed-out answer, and Deny to an unlisted redirect;
    - the 2,048-character bound, exactly at it and over it;
    - the per-address limit.
- `DevPersonas.test.ts` covers the persona refusal. `AuthPages.test.ts`
covers logout's `return`, which stays local. `AuthPages.socket.test.ts`
covers the longest request through sign-out to the door.
- `apps/server/src/AgentConsent.test.ts` now approves through the page's
POST instead of a service call.
  - Each guard in "Look at" was removed in turn, and its test went red.
- **Review.** GPT-6.1-Sol (xhigh), four rounds; [the rounds and their
outcomes](#882 (comment)).
Round 4 found nothing blocking or should-fix.
- **Suites.** CI's 14 checks pass on the head. Locally: auth (216), core
(81), portal (98), limits (25) and the server's AgentConsent test pass.
eslint, prettier, `tsc -p tsconfig.test.json` and the builds of auth,
portal and server are clean.
- **`pnpm verify` on 2e101dc.** 8 of 9 steps pass: format, lint,
typecheck, synth, postgres-concurrency, cli-smoke, tier2-smoke and
browser (81). The test step passed 2,183 of 2,184. The one failure was
`packages/patchy/src/cliRepoPublish.test.ts`: tar read
`typescript/lib/_tsc.js` as another checkout on this machine rewrote
that shared, hard-linked file (`File shrank by 10893220 bytes`). The
suite passes rerun alone (3/3), and passes in CI's three test jobs on
this head.
- **Rollback rehearsal** against production's commit, which has #837 and
#838: `pnpm test:rollback-rehearsal --live e4243ff` passed e4243ff →
2e101dc → e4243ff → 2e101dc in 185 s. CI's `rollback-rehearsal` job
skips, since nothing here migrates.
- **Acceptance:** [PASS with
notes](#882 (comment))
on 2e101dc, by GPT-6.1-Sol (xhigh).

**Surfaces:**
- The shell gains `agent-mark` (with core's `agentMark` and `agentIcon`,
now shared with the guide), `consent-strip` and `can-list`, and
`ui-consistency` names all three. The consent door joins its list of
doors.
- The limits registry gains `oauth.consent.perMinute`, rendered into
`docs/limits.md`.
- `docs/product.md` › Consent gains the ten minutes and how Use another
account behaves. The Auth glossary's *Consent* gains the ten minutes.
- `docs/DEVELOPMENT.md` gains the persona refusal, "Connecting through
consent" (the walkthrough #849 left for this page) and a Consent entry
under What to exercise. `patchy-dev-loop` says the same.

Untouched:
- `packages/api`, so `docs/API.md` stands.
- The CLI.
- Migrations.
- The dev runner's code: its tools already send `none` or no
`Sec-Fetch-Site`.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required

One new route (`POST /oauth/authorize`), a registry row and shell CSS.
`/logout` takes an optional `return`. No schema change.

- **What does a revert leave behind?** Nothing new. Codes an Allow made
are #849's `agent_consents` rows, which expire in a minute.
- **Does the release before it still work with that?** Yes. It has no
POST route, so an open consent page's answer would 404, and the client
would start again.

Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and
accepted by GPT-6.1-Sol (xhigh).
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs Touches the docs area area:server Touches the server area size:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The authorization flow: authorize, the code exchange and refresh

1 participant