Skip to content

chore(deps): move Effect to 4.1 and its per-family crypto services - #1426

Merged
allisonmahmood merged 3 commits into
mainfrom
t3/bump-effect-41-crypto
Nov 19, 2026
Merged

allisonmahmood merged 3 commits into
mainfrom
t3/bump-effect-41-crypto

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

What changed

Effect moves from 4.0.5 to 4.1.4 (effect, @effect/platform-node, @effect/sql-pg, @effect/sql-pglite, @effect/vitest). People using Patchy see no difference. Nothing stored changes: tokens, digests, HMACs and sealed values are still made and checked by the same node:crypto code. This supersedes #1380, whose CI was red because 4.1 stores HttpApiSchema.status where our refuse() didn't look, so every refusal answered 400.

Beside the Effect group, the lockfile moves only ws, to 8.23.0, which @effect/platform-node-shared 4.1.4 pins exactly. undici 8.12.4 and PGlite 0.5.16, which the 4.1 packages need, are already on main from #1424, so the workspace holds one PGlite again.

Look at

Crypto. 4.1 replaces effect/Crypto with per-family services and drops crypto from the runtime *Services bundles. The Cryptography seam stays as it was. NodeCryptography.layer now also provides Effect's SecureRandom and Digest, using Effect's own Web Crypto layers: no new dependency, nothing at import time, and the same behaviour on Node and Bun. Every entrypoint and test layer already provides it, so "provide NodeCryptography.layer" stays the one rule. The seven direct effect/Crypto users take SecureRandom or Digest instead. @patchy/limits can't depend on core, so Digest is what it uses. AGENTS.md, the service-conventions spec and the oxlint messages say this now.

Refusal statuses. 4.1's HttpApiSchema.status writes a key annotation, which SchemaAST.resolveAt doesn't read. HttpApi's own reader, getStatusErrorSchema, is internal and missing from the published types, so respond.ts follows its rules exactly:

  1. The last check that sets a status wins, looking into check groups too.
  2. Otherwise the schema's own annotation counts, and an explicit undefined clears the status.
  3. Otherwise the key annotation counts.
  4. With none of those, the status is 500.

respond.test.ts compares each case with HttpApi's own reader. One consequence: a schema with no status now answers 500, where it used to answer 400. No current refusal schema lacks one.

Request targets. 4.1's server adapter turns an absolute-form target into its path, and sets Host to the target URL's host, which drops userinfo and the scheme's default port. The door's Host gate then saw a cleaned-up host, so POST http://<public host>/mcp and POST https://user@<public host>/mcp reached the bearer check instead of answering 421. RequestTrust.requestAuthority now reads the target and the Host fields from the Node request as the client sent them (request.source). Sources without raw fields, such as a web Request or the in-memory test client, keep the old reading. I also checked everything else that reads the target or Host:

  • The API guard, serving and the portal resolve request.url against the configured origin, and compare Origin rather than Host. They don't trust the target's authority, and the rewrite makes an absolute target reduce to its path.
  • The CLI dev server's DNS-rebinding guard compares Host. Browsers send origin-form, which the adapter leaves alone, so the guard still does its job.
  • Two private listeners now accept an absolute-form target where they used to refuse it before authentication, and the behaviour stays as it is. The callback gateway (CallbackGatewayApi.ts) used to answer POST https://anything/callback with 200 invalid_request; now it reaches the bearer and identity checks. The supervisor's callback proxy (supervisor.ts) looks up its callback path from the rewritten target. Neither grants anything the checks behind it don't already require.

Oversized uploads. Under 4.1, an undeclared (chunked) body over its cap is answered instead of reset. But the adapter then keeps reading up to 256 KiB more with no deadline, so a sender that stalled kept its connection until the runtime's own timeout. A declared length over the cap had the same problem below 256 KiB, on origin/main as well.

A size refusal now closes the connection, through one hook: closeAfterAnswer in @patchy/api. It adds Connection: close to the current request's answer, and the adapter then ends the socket and destroys it within its 500 ms grace. Measured here, the server closed it about 7 ms after answering, on Node and on Bun. Every capped reader runs the hook, for a cap crossed mid-stream and for a declared length over the cap. Each keeps its existing status and body:

  • readBody, for every JSON API route that reads one: 400 "Malformed request body." mid-stream, 413 declared.
  • The 16 form readers in auth and portal, through capBody(maxBytes): beta links, device login, the OAuth token request and consent answer, machines, shortcuts, logout, terms, What's new, patch pages, sharing, home (two), feedback, user lifecycle, and pinning. Their declared-length prechecks run the hook too.
  • The runtime's call, file and stage readers (413), and the subscriptions stream (413).
  • The callback gateway: the file bound and the byte budget answer, as before, with a 200 refusal body.
  • The supervisor's callback proxy (413).

One reader is left out: the MCP door reads a chunked body to its end by design, so its refusal is unchanged. The device start, device poll and shortcuts descriptions, and docs/API.md, say what the code does. Nothing is stored on any refusal.

Row ids. 4.1's SecureRandom.uuidV7 counts within a millisecond: 42 counter bits and 32 random. #214's contract test pins 74 random bits per id, and Effect's own docs say a monotonic id reveals the one minted before it. So TableOperations builds the UUIDv7 itself from the Effect clock and 16 bytes from SecureRandom, clamping the timestamp to the 48-bit field as 4.0 did.

Other behaviour 4.1 changed that tests asserted:

  • A failed migration step is a typed MigrationError (kind: "Failed") instead of a defect. Startup still fails and the process exits.
  • The CLI parser now splits -json=true into -j -s -o -n, so jsonRequested stops treating it as --json. A global flag's bad value (--log-level loud) now goes through Effect's usage path like any other parse error. That made the entrypoint's InvalidValue catch dead, so it is gone. Under --json stdout stays empty; without it, usage comes before the one line, as ADR-0004 allows.

Mechanical. SqlClient.make takes a driver, and sql.insert takes a non-empty array. docs/API.md drops the eight duplicate RuntimeFailure_N components that differed only by status.

On top of the GitHub integration. Everything on main since #1427 was written against 4.0.5: the GitHub App connection (#1448) and its reads (#1451), workerd binding its own port (#1444), CLI refresh (#1446) and sidebar pins (#1437). Checked against each 4.1 change:

  • Crypto. None of it uses effect/Crypto. Cryptography gains rsaSha256Sign for the App's JWT, which runs on node:crypto like the rest, and NodeCryptography.layer still provides it beside SecureRandom and Digest.
  • Statuses. It adds no routes and no status-bearing refusal schemas. GitHub's refusals reach clients through the existing connection pages, ConnectionsApi (whose declared errors HttpApi encodes itself) and the runtime, which takes its status from the error. The GitHub, connections and dev-read suites assert those statuses over HttpApiTest and real sockets, and pass on 4.1.
  • Body reads. The one new body read is the pin form, which provided MaxBodySize directly. It now goes through capBody. GitHub's connect flow adds none: its filter is a GET, and its choices post through the connection page's existing form read, which fix: every form read is capped #1434 caps.
  • Targets and Host. The GitHub sign-in's redirect URI is built from the configured origin, and nothing new reads Host.
  • The rest. Nothing new calls SqlClient.make, the Migrator, uuidV7 or ws, and no new flag uses a single-dash long spelling.

On top of Pidgeon's new API. #1458 rewrote the Pidgeon integration against 4.0.5, and nothing in it needed a 4.1 change:

  • Its crypto goes through Cryptography.
  • It adds no routes, status-bearing refusal schemas, body reads or CLI flags. Its connect page posts through the connection page's existing form read, which fix: every form read is capped #1434 caps.
  • It doesn't call SqlClient.make, the Migrator or uuidV7.
  • Its migration 0044_pidgeon_drafts joins the record behind this branch's, and the record and upgrade tests pass.

How it was verified

Red, then green, on Effect 4.1.4:

Case At 8980889 Now
RequestTrust.test.ts, the gate behind the real NodeHttpServer adapter: POST http://cloud.patchyhq.com/mcp passed the gate 421
McpDoor.test.ts, the whole server: POST http://user@<host>/mcp 400 (past the gate) 421
Same tests: origin form, the door's own absolute target (200), two Host fields — unchanged
AuthApi.socket.test.ts (JSON) and AuthPages.socket.test.ts (form): an unterminated 8 KiB chunked upload 400, connection still open at 3 s, on Node and Bun 400, then closed, on Node and Bun
AuthApi.socket.test.ts: Content-Length: 8192 sent with no body (open on origin/main too) 413, still open at 3 s, on Node and Bun 413, then closed
RuntimeApi.test.ts: a call streamed just past its cap, a stage upload streamed past its cap, and a stage upload declared past it 413, still open at 3 s, on Node and Bun 413, then closed
RuntimeStreamApi.test.ts: a subscriptions body streamed past its cap 413, still open at 3 s, on Node and Bun 413, then closed
CallbackGatewayApi.test.ts: a callback file body streamed past its bound 200 refusal, still open at 3 s, on Node and Bun 200 refusal, then closed
respond.test.ts: a status set inside a check group 409 403, as HttpApi
UUIDv7 contract: a clock at −1 ms timestamp field all ones 0

Suites:

  • On the head rebased onto main at 2a17d16, which now carries the Effect checker at 0.68 (chore(deps): move the Effect checker to 0.68 #1425), pnpm check passes in full (3741 offline tests).
  • pnpm verify on the previous head, on main at 47deb91:
    • Pass in the full run: format, lint, typecheck, synth, the offline tests on Node (3732) and Bun (3405), postgres-concurrency and install.
    • Pass rerun alone: cli-smoke, tier2-smoke and the Chromium browser suite (189). In the full run they couldn't find the browser builds that Playwright 1.65 (from chore(deps): bring the remaining dependencies up to date #1424) asks for; once installed, all three pass.
    • Could not start: the Firefox suite, because Firefox there lacks the system libraries it needs. CI's required browser-firefox job covers it, and it passed in an earlier round (186 tests).
  • The suites the Pidgeon rewrite touches pass on Node and on Bun (646 tests across 72 files each): all of packages/integrations and packages/api, the CLI's pidgeon, dev-resource and dev-preparation tests, and the server's migration record test.
  • The GitHub integration's suites, run alone on 4.1, pass on Node (361 tests across 27 files, with portal and the CLI's repo, global-CLI and dev-resource files) and on Bun (286 tests across 24 files; the CLI files run on Node only). They cover:
    • github/Connections.test.ts: connecting through the App against a stub GitHub on real sockets.
    • github/Operations.test.ts: the reads.
    • github/Pages.test.ts: the connect pages.
    • github/Source.test.ts and Generate.test.ts: the source and generated tables.
    • ConnectionsApi.test.ts, ConnectionPages.test.ts and DevReads.test.ts, with their status assertions.
    • NodeCryptography.test.ts, including RS256 signing.
  • Each rebase took main's lockfile and regenerated it with pnpm install; it differs from main's only in the Effect group and ws.
  • install.test.ts builds its PATH from the running Node, so these runs put the repo's pinned Node 24 first.
  • The supervisor's callback proxy gets the same hook, but has no socket test: reaching it needs a live workerd resident to register the callback path and capability.
  • Not checked: the server image (server-image needs Docker; CI runs it), live Clerk, and a deploy.

Release impact

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

This is a dependency bump, and the stored formats and the API's statuses and bodies are unchanged. Three things a client could notice:

  • An oversized chunked upload now gets its refusal and a closed connection, where it used to get a reset.

  • A declared length over a cap gets its 413 and a closed connection, where the connection used to stay open.

  • The undocumented single-dash -json=<b> spelling is no longer read as --json. --json and --json=<b> are unchanged.

  • What does a revert leave behind? Nothing: no migration, no new stored shape. Ids, tokens, digests and sealed values are made the same way on both sides.

  • Does the release before it still work with that? Yes.

Built by Claude Opus 5.5 in T3 Code via Claude Code.

@github-actions github-actions Bot added area:server Touches the server area area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:core Touches the core area area:docs Touches the docs area area:primitives Patch tables and files area:ui Portal and first-party browser pages, shared rendering and styles size:l 501-1,000 changed lines labels Nov 13, 2026
@allisonmahmood allisonmahmood changed the title build(deps): move Effect to 4.1 and its per-family crypto services chore(deps): move Effect to 4.1 and its per-family crypto services Nov 13, 2026
@github-actions github-actions Bot added size:xl Over 1,000 changed lines; review in multiple passes and removed size:l 501-1,000 changed lines labels Nov 13, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Code review (GPT 6.1 Sol, xhigh), three rounds, ending at e5e46787 with no blocker or should-fix open.

Round one, at 89808890. Held: the status port for all 43 status-bearing schemas, the crypto wiring on Node and Bun with unchanged algorithms and byte formats, row-id randomness, migrations, the CLI exit ladder, SQL call sites and the rendered contract (46 routes). Found, and fixed in f34b555a:

  • The MCP door's request-trust check read a request target Effect 4.1 had already rewritten, so an absolute-form target with the wrong scheme or with userinfo passed the host gate where 4.0.5 answered 421. It now reads the target and Host fields as the client sent them, with socket tests through the real adapter.
  • An oversized chunked upload that never terminated got its 400 and kept its connection. capBody now closes after the answer.
  • refuse()'s status reader now follows HttpApi's rules exactly and is tested case by case against HttpApi's own reader.
  • The hand-built UUIDv7 clamps its timestamp as 4.0.5 did.

Round two, at f34b555a. The three smaller fixes were complete, and all 341 endpoint and middleware error-schema appearances carry an explicit status. Found, and fixed in e5e46787: the runtime's own bounded readers (calls, file and stage uploads, the subscriptions stream, the callback gateway, the supervisor's callback proxy) count bytes themselves and did not register the close, and declared-length refusals left the connection open (that one was also true on main). Every size refusal now runs one exported hook, closeAfterAnswer, and keeps its status and body.

Round three, at e5e46787. The delta is complete and does not over-reach: successful runtime calls and ordinary callbacks keep Connection: keep-alive and reuse their socket on Node 22, 24, 26 and Bun, and real workerd completed its next callback on a fresh connection after an early size refusal. All six new socket cases fail against f34b555a. The supervisor proxy path was read, not exercised through a live resident.

One nit not fixed here, with the reason: the new socket helper (test/socket.ts) asserts the status line and the close, not that the whole refusal body arrived first. Acceptance on this head checked that directly: the declared-overflow 413 and the chunked-overflow 400 both returned their full, identical bodies before the close. The helper gets the stronger assertion in the follow-up that reuses it.

Also recorded in the body: an absolute-form target is now accepted by the callback gateway and the supervisor's callback-path lookup before their bearer and capability checks, which grants nothing those checks do not already require. @effect/sql-pglite 4.1.4 uses only PGlite calls that 0.5.10 has, so this does not depend on #1424.

@allisonmahmood
allisonmahmood force-pushed the t3/bump-effect-41-crypto branch from e5e4678 to f68c8de Compare November 13, 2026 16:44
@allisonmahmood allisonmahmood mentioned this pull request Nov 13, 2026
1 of 2 tasks
@allisonmahmood
allisonmahmood force-pushed the t3/bump-effect-41-crypto branch from f68c8de to aedbfbd Compare November 16, 2026 13:12
@allisonmahmood

Copy link
Copy Markdown
Owner Author

pidgeon-suite is red on aedbfbd2 for a reason outside this PR, and is not a required check.

Every failing case starts from connecting a Pidgeon address, which fails because Pidgeon retired the API call it makes (#1457). The same live tier is red on main since 15 November and green on #1458, which moves the integration to Pidgeon's new API. On this branch's previous head, before Pidgeon's move, the suite passed on Effect 4.1.4.

Nothing to change here; it goes green once #1458 lands and this branch is rebased over it.

@allisonmahmood
allisonmahmood force-pushed the t3/bump-effect-41-crypto branch 2 times, most recently from 3517ce7 to b131060 Compare November 18, 2026 21:43
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review round 4, by GPT 6.2 Sol at high on b1310609: does the code that landed on main after this PR was written (the GitHub integration, #1448 and #1451, and the Pidgeon rewrite, #1458), which this diff does not touch, behave differently on Effect 4.1.4? Crypto layers, refusal statuses, request targets, ids, SQL and migrations, CLI flags and outbound HTTP were compared against the 4.0.5 sources. No blocking findings; one finding and two notes:

  • The connection page's shared form read has no cap (ConnectionPage.ts, formBody), and on 4.1 an uncapped buffered read is no longer what resets an oversized upload. Dismissed for this PR: the read is uncapped on main today, this PR does not change it, and fix: every form read is capped #1434, stacked directly on this branch and next in line, caps it at 256 KiB through capBody, with the declared-length check and the close after the answer. The body here already says fix: every form read is capped #1434 is where that cap lands.
  • A signed-out absolute-form request to an integration page now returns to that page after sign-in, where 4.0.5 fell back to /join, because the adapter hands on the path and query. No change needed: browsers send origin-form, the return path is still checked as a path, and the sign-in and OAuth callback addresses still come from the configured public origin.
  • Pidgeon's budget refusal when the rollback itself fails. If a draft claim is refused for budget and rolling back the transaction then fails too, 4.1 surfaces the rollback failure (a 500) where 4.0.5 could still answer the 429. No change needed: a failed rollback means the database connection is broken, and a 500 says so. An ordinary budget refusal is still a 429.

allisonmahmood and others added 3 commits November 18, 2026 23:32
Effect 4.1.4 replaces effect/Crypto with SecureRandom and Digest, and no
longer bundles crypto into the runtime services. NodeCryptography.layer now
provides both beside Cryptography, so it stays the one crypto layer a host
provides; the direct effect/Crypto users take SecureRandom or Digest.

Other 4.1 changes ported:
- HttpApiSchema.status stores a key annotation, so refuse() reads it there
  too; refusals answered 400 instead of their declared status without this.
- SqlClient.make takes the driver; sql.insert takes a non-empty array.
- Row ids keep 74 random bits per UUIDv7 rather than SecureRandom's
  monotonic counter, so an id does not reveal the one minted before it.
- An oversized undeclared body is drained and answered instead of reset.
- A failed migration step is a typed MigrationError, not a defect.
- The CLI parser splits -json=true into short flags and renders a global
  flag's bad value through usage, so the entrypoint's special case goes.
- docs/API.md drops the duplicate RuntimeFailure_N components.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lose

Effect 4.1's server adapter rewrites an absolute-form target to its path
and sets Host to the target's URL host, dropping userinfo and the scheme's
default port, so the MCP door's Host gate saw a cleaned-up host and let
http-scheme and userinfo targets through. It now reads the target and Host
from the Node request the client sent.

The adapter also answers an oversized streamed body and then keeps reading
up to 256 KiB with no deadline, so a sender that stalls held its connection.
Body readers now go through capBody, which closes the connection once the
400 is sent.

refuse() reads statuses by HttpApi's own rules (checks, groups and an
explicit clear), and row-id UUIDv7 timestamps clamp to the 48-bit field as
Effect 4.0 did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
capBody covered the platform's own body cap, but the runtime's call, file,
stage and subscriptions readers, the callback gateway and the supervisor's
callback proxy count bytes themselves, so an oversized upload whose sender
stalled stayed connected while Effect's server read on. A declared length
over a cap did the same below the server's 256 KiB threshold.

closeAfterAnswer, now exported from @patchy/api, is the one hook: every
size refusal runs it, mid-stream or declared, and keeps its answer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the t3/bump-effect-41-crypto branch from b131060 to 2de49fa Compare November 18, 2026 23:39
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance: PASS with notes

Checked 2de49fae1b2aef456a8d9679615149ab9bb50f49 (base 2a17d167da99aa10cb0593c3e26e1656a0d58650) on team, brightline, github, pidgeon, and dense, by GPT 6.2 Sol in T3 Code.

Done means

  • Dependency install passed. pnpm 12.20.0 completed a frozen install with the repository's release-age policy. The lockfile SHA-256 matched before and after, and the install contained one Effect 4.1.4 and one PGlite 0.5.16.
  • Refusal and CLI contracts passed. Signed-out API identity returned 401 with the expected refusal body. The packed CLI returned exit 0 for documented JSON success, 1 for bad flags and unknown commands, and 2 with wrong_state when restoring a live patch. JSON errors left stdout empty. The single-dash spelling returned exit 1.
  • Socket behavior passed. Authenticated MCP initialization returned 200 for both origin-form and a matching absolute-form target. Finding and opening New Business and reading its deals through MCP also worked. A complete declared upload above the device-login cap returned 413 with Request body is too large. in the body. A complete chunked upload returned 400 Malformed request body. Both returned the full JSON refusal and Connection: close, then the peer closed the socket.
  • Integration pages passed. A synthetic GitHub App rendered the sign-in and repository-choice steps. Without an App, the catalogue omitted the GitHub link and the direct page returned 404. The Pidgeon form rendered the inbox and access choices. In dense, GitHub's uninstalled and permissions-changed states and Pidgeon's test-key state rendered on their connection pages.
  • Repository checks passed. pnpm check passed format, lint, typecheck, infrastructure synth and all 3,741 offline tests across 337 files. Those tests include HTTP status parity with Effect HttpApi, MCP request trust, body-cap handling across the API and runtime, the migration ledger, cryptography vectors, and GitHub and Pidgeon connection and read tests with doubles.
  • Browser CI passed on this head. Chromium passed 190 tests. The required browser-firefox job passed with 187 tests and 3 skips. Chromium · Firefox

Golden journeys

  • Sign in passed. Ben saw the 401 door, signed in and returned to the requested patch frame. Sign-out brought back the door.
  • Machine login passed. Ada confirmed the code shown by the packed CLI in her browser. whoami named the machine and logout ended access.
  • Publish a page passed. Ada published an HTML file. Ben saw its frame and Home link. Retire removed the frame and restore brought it back.
  • Share and unshare passed. The signed-out reader saw 401, then 200 with public caching after public sharing, then 401 again after switching back to company.
  • Find and open a tool passed. Jordan saw studio tools on Home, searched for Kudos, and opened it in its frame.
  • Use a tool live passed. Jordan's new kudos appeared in Priya's open frame without a reload.
  • Use a tier 2 tool passed. Jordan moved a seeded deal from Lead to Discovery and back on Allison's open board without a reload. Spend minted a UUIDv7 for Jordan's request and refused self-approval in the browser and through MCP.
  • Invite and join passed. Ada invited a new persona, who joined Acme Co and reached Home. Ada revoked a pending invitation and deactivated and reactivated Ben.

Rollback answers: The diff supports both answers. The implementation of Patchy's token, digest, HMAC, sealing and RS256 operations is byte-identical to the base. The Effect deployment digest still uses SHA-256 over the same bytes. Row IDs retain the UUIDv7 layout, timestamp bounds and 74 random bits. The diff changes no migration, handler descriptor format or infrastructure. The CI rollback job confirmed that its rehearsal trigger did not apply. Rollback check

Not run

  • Live GitHub connection and tier 2 reads. The scenario requires a development App installation. The live CI job on this head skipped because a test App was unavailable for the run. GitHub live CI
  • Pidgeon Support desk reads against a test inbox. The scenario requires a Pidgeon test key to connect the inbox and publish the patch. The live Pidgeon CI suite was still pending when this verdict was posted. Pidgeon live CI
  • Live Clerk locally. The local sign-in and invitation journeys used dev personas. The head's live Clerk CI job passed. Clerk CI
  • Supervisor callback proxy's size-refusal branch on a socket. I checked the shared close hook in the diff. The direct socket checks exercised the device-login reader.

Notes

  • The Node test matrix, CLI smoke and Linux install checks were pending at the verdict. CI run

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Merged with the live Pidgeon and Attio jobs for 2de49fae still queued behind other branches; neither is a required check. The live Pidgeon suite and live tier passed on this branch's previous head, b1310609 (run), which already held Effect 4.1.4 with the rewritten Pidgeon integration. The two heads differ only by the rebase over the Effect checker (#1425, build time) and TanStack hotkeys (#1423, the page SDK), neither of which the Pidgeon path runs.

@allisonmahmood
allisonmahmood merged commit eebaac0 into main Nov 19, 2026
28 checks passed
@allisonmahmood
allisonmahmood deleted the t3/bump-effect-41-crypto branch November 19, 2026 00:06
allisonmahmood added a commit that referenced this pull request Nov 19, 2026
## What changed

A few forms never got a body cap, so the server read whatever was sent
to them: creating or joining a company, People and Agent access, Teams,
the integration connection forms, and the local dev server's agent door
and shortcuts form. They now cap their reads as the rest of Patchy's
forms do. A submission over the cap gets the answer that page already
gives a form it can't read, and the connection closes.

Builds on #1426, now merged, which added `closeAfterAnswer`.

## Look at

**`capBody` now refuses a declared length over its cap before reading.**
Until now it noticed an overflow only once the bytes arrived, so a
sender that declared `content-length: 4097` to a 4 KiB form and sent
nothing got no answer until Node's request timeout. It now fails at
once, with the same `HttpServerError` the platform raises mid-stream.
Each page answers it as it answers any unreadable form, and the
connection closes after the answer. The forms in auth and portal that
already read through `capBody` alone get the same: logout, terms, beta
links, machines, What's new, patch pages, sharing, home, feedback and
user lifecycle. Their answer is unchanged; it just comes without the
wait. Readers that check the declared length themselves (`readBody`,
device login, OAuth) answer their own 413 first, as before.

With the new socket test over `capBody` without that check:

```
AssertionError: /join {"declared":4097}: expected +0 to equal 400
```

With it, the test passes.

**The caps**, each sized from the largest legitimate submission of its
form:

| Reader | Cap | Why |
| --- | --- | --- |
| `/join` (`Join.ts`) | 4 KiB | an invitation id, or a company name of
up to 200 UTF-16 units (at most 9 bytes each once percent-encoded: 1,800
bytes) and a 32-character handle |
| People › Invite (`CompanyPage.ts`) | 233,596 bytes (about 228 KiB) |
worked out from the address schema: an address is up to 254 UTF-16
units, each at most 9 bytes once percent-encoded (a three-byte UTF-8
character; a four-byte one is two units, 6 bytes each), and a separator
at most 9 (a comma or semicolon and a CRLF). The cap reads twice a full
batch of those, so a longer paste is refused by its count, and 4 KiB
more for the role and the list's filter: 2 × 50 × 2,295 + 4,096 |
| People › role and Resend, Agent access (`CompanyPage.ts`) | 1 KiB |
one hidden field each |
| Teams, all five forms (`TeamsPage.ts`) | 8 MiB | a roster form carries
up to two member ids per person (a shown member's removal and its keep
box), about 70 bytes a person. Nothing limits how many people a company
holds, so the cap sits far past any roster the page could show at once:
about 119,000 people. It was 1 MiB (about 14,000 people) until
acceptance submitted a 16,000-person roster and was refused. A team name
is 100 code points (1,200 bytes at most) |
| Every connection form (`formBody` in `ConnectionPage.ts`) | 256 KiB |
Postgres's connection string may be 16,384 characters, up to 9 bytes
each once encoded (147,456 bytes), beside a handle and a description |
| Dev server `/~dev/agent` | `mcp.body.bytes` (1,114,112) | the call as
Patchy MCP reads one: the tier 2 argument cap plus 64 KiB of envelope |
| Dev server `/api/me/shortcuts` | 4 KiB | as Patchy's own
`/api/me/shortcuts` reads it |

**How an over-cap form answers** is how that page already answers an
unreadable one:

- Join, People, Agent access and Teams: the auth pages' 400 "Invalid
form" door.
- Connection forms, Pidgeon's and GitHub's included: the form again with
400 "The form could not be read. Submit it again."
- Dev server shortcuts: 400 `Send value=on or value=off.`
- Dev server agent door: the refusal Patchy MCP's door gives a body over
its cap, `too_large` in the door's words, as the dev agent's usual
answer, so `patchy dev agent` reports a refusal and exits 2 (below). A
malformed call within the cap keeps its 400 `Bad request`.

**An over-cap `patchy dev agent` call is the door's `too_large`.** A
plain 400 would have made the CLI say the tool "may or may not have run"
and exit 3, when the call was refused before anything started. A body
over `mcp.body.bytes` is refused unread, so the dev server answers with
the door's own refusal of such a body. That refusal, `bodyTooLarge`, now
lives in `@patchy/api` beside the other shapes of a tool call's answer,
and the door's 413 reads its words from there, unchanged. `patchy dev
agent` then exits 2 with the door's words, as the README and ADR-0004
already say any refusal the door would give does; both now name this
`too_large` beside the oversized read. Answered before the body is read,
the CLI's own client (undici) still reads the refusal: a 1,114,155-byte
call gets it, in each of four runs.

**`test/socket.ts`.** `stalledUpload` reads the answer's
`content-length` and rejects when the server closed before the whole
answer arrived, so a close that cuts a refusal short no longer passes
for one. It returns the body, so tests assert which refusal came back.
Against a throwaway server, a whole answer resolves, one cut 5 bytes
short rejects with "The server closed the connection 5 bytes short of
its answer's body.", and a close with no answer rejects too. The five
suites that already used it pass unchanged.

## How it was verified

Each reader gets a body one byte past its cap over a real socket
(`NodeHttpServer.layerTest`), twice: as one chunk that never ends, and
as a declared length with nothing sent. Each must answer its whole
refusal and close within 3 seconds. Routes that share a reader share one
case.

- `AuthPages.socket.test.ts`: Join, the four People and Agent access
reads, Teams.
- `ConnectionPages.test.ts`: the connect form, through the one
`formBody` every connection form reads with.
- `devServer.test.ts`: both dev server readers, inside the existing dev
server test, so it boots once. The agent door's answer is the door's
refusal, also sent through the CLI's own client; a malformed call within
the cap is still a 400.
- `cliDevAgent.test.ts`: `patchy dev agent` given that refusal exits 2
and prints the door's words, in text and `--json`.
- `CompanyPage.test.ts`: a full batch of the longest addresses the page
accepts (50 addresses, 114,924 bytes with the longest filter) is read
and invites all 50; twice that (228,024 bytes) is refused by its count,
"That is 100 addresses". The socket case refuses one byte past 233,596.

Red, with one piece taken out at a time, then green with it back:

| Taken out | Failing assertion |
| --- | --- |
| `capBody`'s declared-length check | `/join {"declared":4097}: expected
+0 to equal 400` |
| Teams' cap (at its first value, 1 MiB) |
`/settings/company/teams/create {"chunked":1048577}: expected +0 to
equal 400` |
| The connection forms' cap | `{"chunked":262145}: expected +0 to equal
400` |
| The dev agent door's cap | `POST /~dev/agent HTTP/1.1
{"chunked":1114113}: expected +0 to equal 200` |
| The dev agent door's refusal (its plain 400 back) | `POST /~dev/agent
HTTP/1.1 {"chunked":1114113}: expected 400 to equal 200` |
| The invite cap's arithmetic (64 KiB back) | the full batch: `expected
400 to equal 303` |

Existing page tests post real forms through `HttpServerRequest.fromWeb`,
which enforces `MaxBodySize` as the socket does, so a cap below a
legitimate form would fail them. They pass, including the 51-address
invite refusal and every connection form.

Rebased onto #1426's earlier head (`b1310609`, on main at `47deb913`,
with Pidgeon's new API from #1458 and the dependency sweep from #1424),
`pnpm check` passes in full: format, lint, typecheck, synth and all
3,736 offline tests. Neither #1458 nor #1424 added a body read.
Pidgeon's connect form now posts through the shared `formBody`, so the
256 KiB cap covers it, and Postgres's connection string is still the
largest thing a connection form carries. The suites this PR and the
rebase touch pass on Node (810 tests, before the sweep landed:
`packages/integrations`, `packages/companies`, `packages/api`,
`packages/mcp`, the auth socket and company-page tests, and the CLI's
dev-agent, dev-server and `pidgeon` tests). On Bun at this head they
pass too (803; the dev-agent and dev-server files run on Node only).

`pnpm verify` ran before the rebase, at the first commit, `6e54ccd5`, on
a shared machine under heavy load (load average 40 to 60 during the test
phases). Format, lint, typecheck, synth and every acceptance suite
passed: postgres-concurrency, cli-smoke, install, tier2-smoke, browser
and browser-firefox. The offline `test` and `test (bun)` phases each
failed some tests: timeouts in files this PR doesn't touch, a different
set on each run. Rerun alone at low load, all of them passed (10 files
on Node, 6 on Bun). The socket cases ran in both phases, except
`devServer.test.ts`, which is Node-only, as the CLI is. The installer
suite needs `npm` beside the `node` it runs; with the pinned Node first
on `PATH` it passes.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required: forms people submit read as
before; only bodies past a form's largest legitimate size are refused

- **What does a revert leave behind?** Nothing: no schema, rows or
contract change.
- **Does the release before it still work with that?** Yes.

Built by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, run from T3
Code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Allison Mahmood <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:core Touches the core area area:docs Touches the docs area area:primitives Patch tables and files area:server Touches the server area area:ui Portal and first-party browser pages, shared rendering and styles size:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant