Skip to content

feat(auth): people accept updated terms on their next page - #1204

Merged
allisonmahmood merged 4 commits into
mainfrom
companies/terms-acceptance
Nov 10, 2026
Merged

allisonmahmood merged 4 commits into
mainfrom
companies/terms-acceptance

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

What changed

Patchy Cloud only knew that a person ticked Clerk's box at sign-up. It had no record of which terms they accepted, and no way to ask again when the terms change. Now each person's acceptance is recorded by revision. When the terms or privacy notice move, everyone gets one prompt on their next page in a browser: "We've updated our terms", links to the dated pages, Accept, and Sign out. Accept goes on to the page they were opening.

Closes #976 (rescoped 2026-11-02: per person, industry standard).

Look at

The prompt, as approved in the mock, now drawn with the overhaul's door (P8, #1343): doorResponse with Accept as its primary action and the usual "Signed in as … · Sign out" foot, and no styles of its own. team's Cleo hasn't accepted yet, so it stands in for her Home:

Before and after, as Cleo Shah (member)

Before is e8851ea (where this branch left main) and after is 1e926f4 (companies/terms-acceptance), both on the team scenario, from pnpm dev compare.

Every page answered 200 with no browser errors.

/

1280px, after

After: / at 1280px

1280px, before

Before: / at 1280px

Width Before After
390px Before: / at 390px After: / at 390px

Accept goes on to where she was heading, the query included, and her next page asks nothing:

Flow accept-terms, as Cleo Shah (member)

After is 1e926f4 (companies/terms-acceptance), on the team scenario, from pnpm dev film.

  • After: finished in 6.9s
after.mp4

Who is asked, and where. This was the part worth checking:

  • Who: everyone who hasn't accepted the current revisions or later ones. That covers members, admins and guests. A guest is asked about their own record; the host company never matters.
  • Where: only a top-level page load: GET with Sec-Fetch-Mode: navigate and Sec-Fetch-Dest: document. It applies at the two page boundaries, RequireSession.withViewer (portal, company, What's new, device-login and consent pages) and Serving's door for company patch addresses.
  • Never asked:
    • fetches, a patch's /~content frame, live streams and runtime calls;
    • form posts (the page a post redirects to asks);
    • public patches, the login door, create-or-join and Clerk's handshake;
    • any client without browser fetch metadata, so agents, machine tokens, MCP and the CLI pass.

The record is the new terms_acceptances table (migration 36). It has one row per person and pair of revisions, holding who, the terms revision, the privacy revision, when, and via. via is sign-up for the row written with each new user at create-or-join, and prompt for Accept. Rows are only ever added. There's no foreign key, so a record outlives its account. Accepting again adds nothing. A release on older revisions, such as a rollback, asks nobody again. A form left open across an account switch or a revision change records nothing and asks again with 409, unless whoever is signed in has already accepted.

The revisions are one line: current in packages/companies/src/Terms.ts. URLs derive from the ids (https://patchyhq.com/cloud/terms/<id>, …/privacy/<id>). This head holds terms 2026-11-10 and privacy 2026-11-10, published by patchy-web #52 (merged); both dated pages answer 200. A release never names an id whose dated page doesn't answer.

Ship order: #52 live (done; both dated pages answer 200) → merge this → release → deploy. The website makes a revision current when it publishes it, so anyone who signs up before the deploy is recorded with the older ids and asked once after it.

Rollout:

  • Every existing person is asked once on their next page in a browser.
  • Nobody is backfilled from Clerk, and Clerk's sign-up time stays as it is.
  • The new revision says earlier acceptances stay in force until the person accepts it in Patchy Cloud, and this prompt is how each person accepts it.
  • An account Patchy creates for someone is covered by the new terms' line that they accept the terms when they first use it. If its company is created after this ships, it's recorded at creation and never asked; if it was created before, it's asked once.

How it was verified

  • New tests:
    • Users: sign-up rows for created and invited users; later revisions count, older ones don't, and accepting again adds nothing.
    • AuthPages: the prompt in place of a page; fetch, iframe and metadata-free requests pass; Accept records and returns to the path with its query; a switched account or stale revision gets 409 and records nothing; a foreign return goes to /.
    • Serving: a colleague and a guest are asked at a patch address, never in its frame, on a public patch or without fetch metadata.
  • vitest run packages/auth packages/companies packages/serving packages/portal apps/server/src/migrations.test.ts scripts/dev/src/scenario.test.ts: 38 files, 494 tests pass. pnpm verify: see the review comment.
  • pnpm dev compare and pnpm dev film above, on throwaway instances at this commit.
  • Seeds: the dev seed, every scenario person and the tier 1 browser instance's people start past the prompt. team's Cleo is termsPending. The rollback rehearsal accepts the prompt once when HEAD's revisions are newer than the seed's, which is what every existing person will see.
  • Not checked: the production Clerk sign-up path. Its new user takes the same create and consumeInvite insert the tests cover.

Follow-up (#1205): acceptance records are deleted 7 years after the account or company closes. The privacy notice states that retention; nothing deletes records yet, and nothing can close for years.

Release impact

  • Breaking — requires action from anyone already running this

  • Not breaking — an additive table; no CLI, API or config change. Every existing person sees the prompt once in a browser, by design.

  • What does a revert leave behind? The terms_acceptances table and its rows. Nothing else reads them.

  • Does the release before it still work with that? Yes. It never reads the table, and it doesn't prompt. Coming forward again asks only people who hadn't accepted.

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:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area area:ui Portal and first-party browser pages, shared rendering and styles size:l 501-1,000 changed lines labels Nov 2, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review rounds (GPT-6.1-Sol, xhigh)

  • Round 1 at acd41b5: no blocking, should-fix or nit findings.
    • Gate: both page boundaries hold the exact GET, navigate and document condition. Guests are asked for their own record; every excluded surface stays outside the gate.
    • Accept: checks the shown account and both revisions, runs under sameOrigin, validates returnPath and keeps path and query. A matching receipt survives the prompt.
    • Record: both enrollment paths share the one atomic user-and-acceptance insert, and a conflicting user insert records nothing. Comparisons use COLLATE "C", the primary key prevents duplicate pairs, and migration 34 is composed by the server.
    • Surfaces: docs, both glossaries, the dev-loop skill, scenarios, seeds, browser fixtures and the rollback rehearsal are covered.
    • Standards: no Effect service or UI consistency findings.
  • After round 1, b28ae61 is test-only: a test's header typing and the tier 2 smoke's seeded colleague starting past the prompt. CI is green on it.

@allisonmahmood
allisonmahmood force-pushed the companies/terms-acceptance branch 4 times, most recently from 201add2 to 19f7f6c Compare November 2, 2026 13:03
allisonmahmood added a commit that referenced this pull request Nov 5, 2026
…ng their email (#1246)

## What changed

Big prospects ask for "a link to try it", but the person who will
actually try Patchy is on the CEO's team, and nobody knows their email.
Clerk's waitlist only admits an invitation to a known address. A **beta
link** is a forwardable address, `/join/<secret>`, made by the operator
for a company's name. The first work email entered keeps the link for
good, and Clerk emails that address an ordinary invitation. Its sign-up
proves the mailbox and shows the terms checkbox. Create-or-join then
marks the link used and starts the company with the link's name, which
the person can change. They invite their team from `/company` as usual.

`pnpm beta-links create --for "Acme" [--days 30]` prints the link once.
`list` shows each link's state, the email it went to, and its person's
company. `resend <id>` replaces a lost invitation, and `revoke <id>`
ends a link and withdraws its invitation. Each command takes `--json`.

## Look at

**The page, in each state** (personas instance; the mock picked was B):

| Open | Refused email | Sent |
|---|---|---|
|
![open](https://github.com/user-attachments/assets/267fe190-29f2-486b-823b-44f27fc3be80)
|
![refused](https://github.com/user-attachments/assets/20716eda-137f-4c89-ab1b-2a9ce0f00502)
|
![sent](https://github.com/user-attachments/assets/934db9ec-dba4-4994-a1a2-30448dabdd06)
|

| Couldn't send (Try again, same address only) | Used | Ended (410) |
|---|---|---|
|
![failed](https://github.com/user-attachments/assets/5ba38d9b-6d4e-4252-aa22-6209dda490f4)
|
![used](https://github.com/user-attachments/assets/071cf822-9e87-452e-b9ab-6724475c467b)
|
![ended](https://github.com/user-attachments/assets/78487a1f-7d6d-4fd7-a9d8-1c6ae0bb42c2)
|

**Create-or-join after the link**, with the link's name filled in:

![create
company](https://github.com/user-attachments/assets/12d5fe0d-6f86-4a58-861e-68bff04ea3a9)

**Serialization.** Claim, retry, resend and revoke each lock the link's
row (`SELECT … FOR UPDATE`) and hold the lock through the Clerk call and
the commit, uninterruptibly. This is the pattern `Invitations.ts` uses,
so a revoke can't cross a send. The test "holds a revoke until the
invitation being sent is stored, then withdraws it" fails if that lock
is removed (checked by hand).

**Design choices (reviewed twice by GPT 6.1 Sol before building):**
- **What a link page shows.** Once an invitation is sent, the page has
no resend button. A lost email goes through the operator. This keeps a
forwarded link from spending Clerk's instance-wide limit of 100
invitations an hour, which company invitations share.
- **Clerk failures.** If Clerk fails, the address stays reserved and Try
again goes to that address only, because Clerk may have created an
invitation whose answer never reached us. A link gets five attempts from
its page in all, then says to ask whoever sent it, so a link Clerk keeps
refusing can't spend the hourly allowance. The operator's resend isn't
counted.
- **One live link per address,** so arriving at create-or-join names
exactly one link.
- **`InvitationNotPending` gains `state: accepted | revoked`,** so
revoke can say "they already have an account" instead of "withdrawn".
Company invitations handle it as before.

## How it was verified

- **`BetaLinks.test.ts`** (11 cases, migrated Postgres, recording,
failing and slow Clerk layers) covers:
  - each state;
  - the secret and full address never appearing in the page;
  - a cross-origin POST getting a 403;
  - one email per link and one live link per address;
- Clerk failing, then Try again, and Try again stopping after five
attempts;
- two links claiming one address at the same moment (the second gets the
409 refusal, not a 503);
  - expiry;
  - arrival marking the link once and prefilling the company name;
- resend and revoke, including an already-accepted invitation, revoke
waiting for a send in flight, and unknown secrets.
- **Other suites.** `packages/auth`, `packages/companies` and the
migration-ledger test pass (324 tests). `pnpm typecheck` and `pnpm lint`
are clean. Locally, `pnpm check` failed only in the CLI suites, from T3
Code's stray `GET /` probes, and in the SDK installer suite, because
this shell has no `npm` on PATH. Neither touches this change.
- **Headless Chromium on a personas instance:** refused email, then
claim, then the sent page, then signing in as that address, then
create-or-join with "Acme" filled in, company created, link used.
- **Against a throwaway Clerk development app set up like production**
(waitlist mode, terms consent, email code, no passwords), with `pnpm dev
--clerk`:
  - The link created a real pending Clerk invitation.
- The invitation opened Clerk's sign-up page, which asked only for the
terms checkbox.
- After signing in, create-or-join showed "Acme Probe" filled in, and
the link read "This link has been used".
- `resend` replaced the invitation at Clerk. `revoke` withdrew it, and a
second revoke was safe. Revoking a link whose invitation had been
accepted reported `accepted`.
- Clerk's development instances only hand a session back to a local app
through a redirect, so the run clicked the door's Sign in once after
sign-up. Production shares `patchyhq.com`, so this extra click doesn't
happen there.
- **Not checked:** production. The table arrives with the release, and
the first real link waits for that deploy.

## Release impact

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

The change adds one table and new routes. Nothing existing changes
shape, and no configuration is new: the operator script reads the
settings the server already has.

**Migration id:** this takes `0034_beta_links`, and #1204 also takes 34.
Whichever lands second renumbers to 35. The ledger test fails until it
does.

- **What does a revert leave behind?** The `beta_links` table and its
rows, plus any Clerk invitations already sent. The release before
ignores the table. A sent invitation still admits its person through
Clerk, and they land on create-or-join without the name filled in.
- **Does the release before it still work with that?** Yes.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Nov 5, 2026
…a link (#1247)

## What changed

This adds release 38's What's new entry, written from `1d59c40`. It
covers everything merged since release 37's `through` (`dc89c70`), and
sets the `patchy` release to `0.38.0` in `packages/patchy/package.json`
and `CURRENT_RELEASE`.

| Change | PRs |
| --- | --- |
| Behind the scenes: Patchy can now give a prospect a link that lets one
person on their team skip the waitlist, for someone whose email nobody
knows yet | #1246 |

There's no announced change: nobody already using Patchy sees anything
different, and the link is handed out by Patchy, not something people
can turn on. #1245 is release 37's own entry.

## Look at

- **The entry**, at the top of `releases` in
`packages/core/src/whatsNew.ts`.
- **Rollback safety, from the live commit `354133d` (release 37) to
`1d59c40`:**
- #1246 is the only change. It adds migration `0034_beta_links`, a new
`beta_links` table that nothing earlier reads, plus the `/join/:secret`
routes. Release 37 starts with that migration in its ledger and ignores
the table. Its `rollback-rehearsal` check passed all four stages, on the
same data. Not `one-way`.
- Invitations a beta link already sent stay ordinary Clerk invitations
after a rollback: their person can still sign up, and lands on
create-or-join without the company name filled in.
- No new configuration. The operator script reads settings the server
already has.
- #1204 also uses migration id 34 and must renumber to 35 before it
lands; its ledger test will fail until it does.

**Rollback line:** If this release misbehaves, roll back to `354133d`
(release 37).

## How it was verified

- **Tests.** The `packages/core` and `packages/api` suites pass (133
tests), including `whatsNew.test.ts` and `schemas.test.ts`.
- **The range.** #1246 had a GPT 6.1 Sol review with every finding fixed
or answered in writing, acceptance PASS with notes, and all 18 required
checks green on its head before it was squash-merged.
- **Deploy state.** The live commit, pinned from `/healthz/deep`, is
`354133d` (release 37). The Deploy run updated last succeeded, and none
is unfinished.

## Release impact

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

Text and version numbers only. Like every release, the `0.38.0` bump
tells CLIs and patch repos installed before this deploy to upgrade.

- **What does a revert leave behind?** Nothing.
- **Does the release before it still work with that?** Yes.

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

Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Nov 7, 2026
…1264)

Stacked on #1262 (reads), which is stacked on #1266 (#1251's connections
and pages). Review only this PR's diff.

Rebased onto #1266 at `f9897e7` with #1262 at `d05caa3`; the commit ids
below are the rebased ones. Rebasing added `0ac096f`: #1266 gave each
integration's recent calls an intro saying what its calls keep, and
IMAP's now says a stage keeps its size, never its filename or upload
token.

## What changed

A patch could read a company mailbox (#1262), but not keep what came
attached: invoices arrive as PDFs, and a patch had no way to save one.
Now a tier 2 action stages a message's attachment and adopts it into the
patch's own file store, byte for byte, in `patchy dev` and published.

How it works:

- **`stageAttachment({ ref, part })`** answers `{ upload, size, sha256,
contentType, filename }`. The part is checked against the message's
current `BODYSTRUCTURE`: the wire takes numbered sections only, never
`HEADER`, `TEXT` or `.MIME`, and a forwarded message's container is
refused while its own parts stage. Patchy downloads the part through the
call's session, under its gates, recheck and destroy rules, decoded by
`BINARY` where the server offers it, in 1 MiB chunks, with ImapFlow's
byte bound one past 20 MiB, so a larger part answers `too_large` and is
never staged cut.
- **Host staging.** The bytes stage through a new internal Files entry
point, `FileStaging`, which shares the page staging route's code: the
same reservation, quotas (16 uploads and 100 MiB per viewer per patch),
one-hour expiry and single-use adoption. Only the Upload crosses into
workerd; the action adopts it with `ctx.files.<store>.put(name,
upload)`.
- **Bounds.** `imap.download.chunk` (1 MiB, held within
`imap.parser.literal` by a test) and `imap.attachments.concurrent` (4
per process, from download to staging) join the limits registry.
- **`patchy dev`.** The dev door gets a private byte transport: the
instance downloads the part and answers its bytes, at most 20 MiB, with
their size and sha256. The dev daemon stages them in its local store
only once they match. JSON results keep their 8 MiB bound.
- **Recent calls** record a stage's size, in a new nullable `bytes`
column (migration 0035), never its filename or Upload. Wide events carry
`stagedBytes`.
- **The `patchy-imap` skill** covers staging, names by ref and part, and
the refusals, and carries one complete reference importer. That importer
is word for word the `imap` scenario's (a test holds the two equal), and
the live tier runs it from the skill.

Part of #1250
Closes #1253

## Look at

The screenshots, the `patchy dev` runs and the saved-file digests are
fresh at `0ac096f`, on a new `pnpm dev up imap` that connected the
mailbox through #1266's connect form. The flags table is from the
earlier run at `2173289`; nothing since changes how a download opens or
fetches.

### The saved files match the source, byte for byte

The `imap` scenario's invoice inbox imported INBOX through `patchy dev`
and saved its attachments. Each file's sha256, as staged and as read
back from the store, against the sha256 of the attachment the scenario's
mail server holds:

| File | Size | Source sha256 | Staged | Stored |
| --- | --- | --- | --- | --- |
| `factura-2026-0412.pdf` | 61 | `001d1549…ebe551e0` | same | same |
| `INV-88213.pdf` | 61 | `58a4e8da…81f29230` | same | same |
| `Rechnung-7731.pdf` | 54 | `d77679de…3155fc10` | same | same |

```console
$ patchy dev agent importAttachments '{"folder":"INBOX","since":"2026-10-01"}'
{ "result": { "imported": 4, "done": true, "stopped": null }, "version": 1 }

$ patchy dev agent savedAttachments
{ "result": [
    { "filename": "Rechnung-7731.pdf", "size": 54, "file": "INBOX.1794003292/4/2",
      "staged": "d77679decb18a011c06bfde1c4fc170ce6059eb696b5ad7fab8c76823155fc10",
      "stored": "d77679decb18a011c06bfde1c4fc170ce6059eb696b5ad7fab8c76823155fc10" },
    … ] }

$ patchy dev agent importAttachments '{"folder":"INBOX","since":"2026-10-01"}'   # again
{ "result": { "imported": 0, "done": true, "stopped": null }, "version": 1 }
```

The second run starts from the stored checkpoint and finds nothing new.

### Published, as a member

The published patch, opened by Priya Raman, a member, after **Save
attachments**. A row shows its sha256 only when the stored bytes match
the staged digest:

![The published invoice inbox after saving attachments: three files with
sizes and matching
digests](https://github.com/user-attachments/assets/415cdb5b-5ce2-46a7-b063-7ee7b29e0716)

### Recent calls record the size, nothing else

Each stage appears with its duration and size ("54 B"), from the
published patch as Priya and from `patchy dev`. No filename and no
Upload is kept; the sentinel test checks recent calls, logs and wide
events for both.

![The connection's recent calls in #1266's full-width layout:
stageAttachment rows from the published patch and from patchy dev, each
with its size beside its
duration](https://github.com/user-attachments/assets/5d3a0ce6-f2eb-42b3-858c-b69cbf4887e0)

### Nothing on the server changed

Flags read from the scenario's mail server after every download, dev and
published:

| UID | Subject | Flags |
| --- | --- | --- |
| 1 | Factura nº 2026-0412 — papel reciclado | none |
| 2 | Invoice INV-88213: October freight | `\Recent` |
| 3 | Reminder: INV-87760 is overdue | `\Recent` |
| 4 | Rechnung 7731 für Werkzeuge | `\Seen \Recent` |

Messages 1 and 2 had their attachments downloaded and are still unread;
message 4 was read before any of this.

## How it was verified

- **Files contract, on Postgres and PGlite.** Host staging shares the
page's quota count, refuses a tier 1 version or a call with no viewer,
holds the staged-file bound, adopts once, and an Upload not adopted
within the hour fails `not_found`.
- **Offline, over a scripted mail server.** These run there:
- every byte value under base64, quoted-printable and 8bit, with and
without BINARY, in chunks;
- exactly the bound staged, and one byte past refused with the session
destroyed;
- a container, a missing part, a gone message and another connection's
ref, each refused with nothing staged;
  - an abandoned download destroying the session;
  - the attachment places answering `busy`;
  - a quota refusal handed on, keeping the session.
- **Live, on Dovecot and GreenMail** (`pnpm test:imap`, 20 tests): a PDF
in base64, a CSV in quoted-printable, a text file in 8bit and a PNG
inside a forwarded message, compared by sha256. On Dovecot also: exactly
20 MiB staged and one byte more refused, and 20 MiB staged through a
relay adding 100 ms of round trip in about 4 seconds.
- **The reference importer, live.** The live tier takes it from the
skill and runs it in real workerd over real tables and files against
Dovecot, through each way a run can stop: a stage refused on quota, a
message expunged as its page is read, an attachment past the bound kept
by name and size, a row write that fails after its file was adopted, and
a restart that imports only what arrived since.
- **The dev transport.** A stub instance checks that a whole transfer
stages, a short or differing one stages nothing, one past the bound is
refused, and an instance refusal is handed on. The real door, over a
scripted mailbox, streams a part that the daemon stages, and records its
size. A client that stops reading a 19 MiB body keeps the process's
place until it reads.
- **The sentinel** now covers filenames and Upload tokens, through the
generated client.
- **`flock … pnpm verify`.** Format, lint, typecheck, synth, browser,
cli-smoke, install, tier2-smoke and postgres-concurrency pass. The test
lanes failed locally only on suites this PR doesn't touch, for CI to
settle:
- the CLI stub-server suites, where the editor's port probes on this
machine reach the stub;
  - the `Supervisor` and `LocalTaskProvider` flakes;
- `RequestEvents.test.ts`, which saw one extra event line in both full
local runs and passes alone 5/5. It runs nothing this PR changes, and
looks like the same stray probe request.
- **Not checked:** a real company mailbox. Only Dovecot, GreenMail and
the dev scenario's server.

## Review

Grok 4.7 reviewed `feat/imap-attachments` at `2173289`:

| Finding | What happened |
| --- | --- |
| P1: the dev door drops the attachment place while 20 MiB is still
held. The place covered only the download, and the whole buffer then sat
in the response until a slow `patchy dev` client read it, letting
further downloads start past the limit. | **Fixed** in `e8f5396`. The
door takes the place into the request's own scope, which the server
closes only once the response is written or the client goes, and streams
the body 64 KiB at a time as the socket drains. A new `placeIn` takes
the place and registers its release in one step. A test holds a client
that stops reading a 19 MiB body: the process's one place stays taken
until the body is read, then comes back. With the old code it fails. The
published path already held its place through staging. |
| P2: the skill's description doesn't mention attachments, so agents
choosing skills by description miss them. | **Fixed** in `4e17ec3`: it
now names saving attachments into the patch's own files. |

**After acceptance** (`7a64558`, `f51a365`, `ea713e1`, `58258c0`):
- `stagedBytes` now sums a request's successful stages instead of
keeping the last download's size.
- The dev daemon checks its local staging quota before asking the door,
so a full quota downloads nothing.
- `58258c0`: host staging takes the call's binding as an argument,
fixing the runtime build's Effect check.

**After the acceptance re-check** (`11b2770`, `c81c1a9`):
- Each part carries `attachment`, decided once in the structure reader.
It replaces the `body` flag an earlier fix added. A part is an
attachment when it is attached by disposition, or when it is named and
isn't a resource the body embeds (inside `multipart/related` with a
Content-ID, such as a signature logo). The body, its HTML twin, the part
it's encrypted in and a forwarded message's container never count; a
forwarded message's own files do. `hasAttachments` is now true exactly
when a part is one, so it changes #1262's reader: a forward with no
files, or an HTML body with only an embedded logo, says false.
- The reference importer, in the skill and the scenario, saves exactly
the parts marked `attachment`. Structure tests cover each edge of the
rule, and the live tier now also imports a forward (only its PDF saved,
not its text or HTML) and an HTML body with an embedded logo (only its
PDF saved). The scenario's mail is plain attached PDFs, so the evidence
above is unchanged.
- A published stage checks staging's quota before it takes a place or
logs in. A test holds a full quota to no session and no FETCH, and fails
without the check. A quota that others fill during the download is still
handed on.

**After the second re-check** (`05b56e4`, `c2186ea`):
- A signed message's signature never counts. That is the second part of
a `multipart/signed`, an `application/pkcs7-signature`,
`application/x-pkcs7-signature` or `application/pgp-signature`, a
forwarded message's too. Mail programs show it as a badge, so a signed
invoice says `hasAttachments` only for what it carries, and the importer
no longer saves a `smime.p7s` or `.asc`.
- A part of any type other than text counts even with no filename and no
disposition, unless it's a resource the body embeds. A nameless text
part that isn't the body still doesn't count, so a forward's own text
and HTML stay out. A PDF a scanner sends with no name is saved, its
`filename` null; storage names already come from the ref and part.
- Structure tests add an S/MIME-signed message with a PDF, PGP-signed
ones, a forwarded signed message and a nameless PDF in `multipart/mixed`
and alone, each checking that `hasAttachments` agrees. Each fails with
its half of the rule taken out. The live importer adds a signed message
(only its PDF saved, not `smime.p7s`) and a nameless PDF (saved,
filename null).
- `c2186ea`: a `message/*` part other than a forwarded message's
container counts only when attached by disposition, so a bounce's
delivery status and a read receipt's notification never become files; a
bounced message's own PDF still counts. Structure tests cover a bounce,
an internationalized bounce and a read receipt, and fail without the
change.
- Release impact: this PR and #1262 ship in one release, and this PR is
`one-way`; see below. #1262's body says so too.

**After the stack acceptance** (`a53242c`):
- The reference importer passed a whole scan page, up to 100 messages,
to `getMessages`, which takes 25, so any window past 25 messages was
refused `invalid_request` on its first page and never imported. It now
reads each page 25 refs at a time, in the skill and the scenario alike,
and the skill says why beside it. The live importer test adds a folder
of 130 messages, past one scan page and past 25 refs, with a PDF on
every tenth. A row write on the second page fails once, the next run
imports only that page, and every message is kept once with no gaps.
With the old importer that test fails. On a fresh `pnpm dev up imap`,
the published invoice inbox saved all six files from 34 INBOX messages
as Priya, reading 25 then 9.

**After the scale acceptance** (`ff525ff`):
- A batch of 25 refs is bounded in refs, not bytes, so long plain-text
mail could pass `getMessages`' 8 MiB answer bound, and the importer then
failed on that batch on every run. It now reads a refused batch again in
halves. One ref always fits, since a message's answer is at most 1 MiB,
so the common case stays one call per 25 refs. The live importer test
adds 25 quote-heavy exports sized from `runtime.result.bytes` (they come
to 9,185,458 bytes): the batch is refused once and read in halves, and
all 30 UIDs are kept once. Against the previous importer the same test
is refused on that batch run after run, keeping nothing.

## Decisions worth a look

- **`imap.attachments.concurrent` (4 per process).** Without it, 32
calls at once could each buffer 20 MiB, about 640 MiB. It covers
download through staging (or, in dev, until the body is sent); past it a
call answers `busy`.
- **A part past the bound destroys its session**, since a chunk may
still be in flight. That costs one login.
- **The skill's `isPatchyError` line was wrong for server code.** Server
bundles refuse `patchy/client`, so an action reads a refusal's `code`;
the page narrows with `isPatchyError`.
- **The live importer test writes its manifest by hand**, mirroring the
scenario's config: `executeConfig` can't resolve `patchy/config` in the
scenario folder, which has no installed packages.
- **GreenMail quirks.** It drops a text part's last line break from its
section, and it answers NO with a ClassCastException of its own for
parts inside a forwarded message. The live test stages nested parts on
Dovecot, and on GreenMail holds Patchy to relaying the refusal.

## Release impact

Tick exactly one.

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

Upgrading needs no action: one runtime operation, a dev door route, two
registry limits, a wide-event field and a nullable column, all additive.
The break is the way back, so this PR is `one-way`.

**Ships in the same release as #1262, with no deploy between them.**
#1262's parts have no `attachment` flag, so a release with #1262 alone
serves importers written against this PR parts they skip.

- **What does a revert leave behind?**
- Migration 0035 adds a nullable `bytes` column to `runtime_calls`, with
two checks that hold for rows that never set it. Older code names its
columns, never writes `bytes` and never reads it, so its rows pass the
checks.
  - Staged uploads and adopted files are the page's own shapes.
- Rolled back past both PRs, to the release before the stack, a
published patch that calls the reads or `stageAttachment` keeps serving,
but each call fails `access_denied` at the callback gateway. The
reference importer fails before its checkpoint, and rolling forward
again resumes it without a republish.
- Republishing such a repo means `patchy refresh` onto the older
release, whose client has no `stageAttachment`, so its typecheck fails
until the call comes out.
- **Does the release before it still work with that?** Not if it has
#1262 without this PR. Rolling back past #1264 to a release that has
#1262 alone would break importers written against this PR, the skill's
reference importer among them, because that release's parts have no
`attachment` flag: `if (!part.attachment) continue` skips every part,
each message's row is saved without its files and the checkpoint moves
past them, so rolling forward never imports them and nothing says so;
fix forward instead.
- **Migration id.** 0035 collides with the open PRs #1204 and #1217,
which both still need renumbering past main's 0034. Whichever lands
later renumbers.

Built by Claude Opus 5.5 in Claude Code, reviewed by Grok 4.7.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Nov 7, 2026
…nts (#1293)

## What changed

This adds release 39's What's new entry, written from `17b1ad8`. It
covers everything merged since release 38's `through` (`1d59c40`), and
sets the `patchy` release to `0.39.0` in `packages/patchy/package.json`
and `CURRENT_RELEASE`.

| Change | PRs |
| --- | --- |
| New: Patches can read a company mailbox | #1266, #1262 |
| New: Patches can keep email attachments | #1264 |
| Improved: Recent calls fit a connection's page | #1266 |
| Behind the scenes: a refused mailbox password pauses the connection
after one try | #1266, #1262 |

#1247 is release 38's own entry. The range is exactly the Email (IMAP)
stack, which ships as one release.

## Look at

- **The entry**, at the top of `releases` in
`packages/core/src/whatsNew.ts`.
- **Rollback safety, from the live commit `cbbd767` (release 38) to this
PR's merge:**
- **#1266 is `one-way`.** It adds the `imap` integration kind. Release
38 can't decode a manifest that declares `imap`, so after a rollback,
patches published with an Email (IMAP) connection would fail. No
migration.
- **#1264 is `one-way`.** Its parts carry an `attachment` flag that
#1262 alone doesn't have. That only matters for a rollback to a release
holding #1262 without #1264, and none exists, because the three ship
together here.
- **#1264 adds migration `0035_runtime_calls_bytes`,** a nullable column
that release 38 ignores. Its `rollback-rehearsal` check passed.
- **No new configuration or infrastructure.** Hosts already allow
outbound connections, so mail servers on ports 993 and 143 are
reachable.
- **Open PRs #1204 and #1217 also claim migration id 35.** Whichever
lands next must renumber to 36; the migration ledger test fails until it
does.

**Rollback line:** Rolling back past #1266 would break patches that
declare an Email (IMAP) connection, because release 38 can't read a
manifest that declares `imap`; fix forward instead.

## How it was verified

- **Tests.** The `packages/core` What's new test and the `packages/api`
suites pass (69 tests).
- **The range.** Each of #1266, #1262 and #1264:
- had Grok 4.7 reviews, with every finding fixed or answered in writing;
- had acceptance verdicts (PASS with notes), the last run end to end
across the stack, with 260 messages imported, resumed and saved byte for
byte against a local mail server;
- had all 18 required checks green on the head it was squash-merged
from.
- **The stacked merges.** #1262 and #1264 were rebased onto `main`
between merges. Each rebased tree was identical to the head its verdict
was given on.
- **Deploy state.** The live commit, pinned from `/healthz/deep`, is
`cbbd767` (release 38). The Deploy run updated last succeeded, and none
is unfinished.

## Release impact

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

Text and version numbers only. Like every release, the `0.39.0` bump
tells CLIs and patch repos installed before this deploy to upgrade. The
release it announces is `one-way`; see the rollback line.

- **What does a revert leave behind?** Nothing.
- **Does the release before it still work with that?** Yes.

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

Co-authored-by: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the companies/terms-acceptance branch from 19f7f6c to 60f2ff9 Compare November 9, 2026 09:44
@allisonmahmood
allisonmahmood force-pushed the companies/terms-acceptance branch from 60f2ff9 to 8362171 Compare November 10, 2026 09:32
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance carried to 8362171. The PASS with notes verdict at 60f2ff9 still holds. git range-diff shows the first two commits as =. The third changes only the id line in packages/companies/src/Terms.ts (2026-11-09 → 2026-11-10 for both documents) and its commit title. Behaviour is the same, the 411 terms-related tests pass, and CI is green on this head. Both dated pages still answer 404 until patchy-web #52 merges.

@allisonmahmood
allisonmahmood force-pushed the companies/terms-acceptance branch 2 times, most recently from 44d5385 to dcc49f7 Compare November 10, 2026 16:52
@allisonmahmood
allisonmahmood force-pushed the companies/terms-acceptance branch from dcc49f7 to 4df75c8 Compare November 10, 2026 17:09
allisonmahmood added a commit that referenced this pull request Nov 10, 2026
…1343)

Stacked on #1345; part of #1315. Merge the stack together, not alone.

## What changed

Every page Patchy draws outside the app shell was its own card: sign-in,
create and join, beta links, device login, consent, errors and Serving's
notices each assembled their kicker, heading, buttons and sign-out by
hand, with page CSS. They now all render through F2's one Door template,
so a door reads the same wherever someone meets it. Device login shows
the code to compare in Geist Mono and never says a computer is connected
before the CLI collects its key. Consent shows who meets whom and what
the app can and can't do. A retired or deleted patch's address stays an
app page, apart from the stopping notices.

Closes #1330

## Look at

**Device login.** The code is the thing on the page; who is asking to
publish as whom, the computer's name, Confirm and Deny, then when it
expires beside who is signed in and **Not you?**, which signs out and
comes back to the same code.

![Device login,
after](https://github.com/user-attachments/assets/e3e4a881-70e0-4e0a-a501-420c77f6a46b)

**Consent.** Who meets whom, each can or can't line saying which in
words, Deny and Allow at equal width, where the answer goes, and Use
another account.

![Consent,
after](https://github.com/user-attachments/assets/52a5d1b8-b11b-420a-9122-68c3de0399b6)

**Sign-in and create.** The setup line is a copy line in the sign-in
door's foot. Create uses the field helpers: a refusal sits under its
field in one line, and the field takes the focus.

![Sign-in,
after](https://github.com/user-attachments/assets/6f179174-c9f5-4442-bab6-22f28f54479f)

![Create your company with a refused address,
after](https://github.com/user-attachments/assets/7fb23cc0-2854-4e2f-af83-96ab4a4bbada)

**Outcomes on the same anatomy:** confirmed (go back to your terminal),
access off, a local callback warning, a stopping notice, the 404, a
denied code.

![Door outcomes,
after](https://github.com/user-attachments/assets/e92b4ede-099c-48b4-8d46-0dcaccbc30d3)

**Phones:** sign-in, device login, consent, create.

![Doors on a phone,
after](https://github.com/user-attachments/assets/76064768-63d8-4f7e-aa4f-fde41403d3a7)

<details><summary>Before</summary>

![Device login,
before](https://github.com/user-attachments/assets/5aa9700d-24cb-4f61-bbba-93b8602b3eb1)

![Device confirmed,
before](https://github.com/user-attachments/assets/7b637436-e9e0-4809-a3aa-4f1f9972214c)

![Sign-in,
before](https://github.com/user-attachments/assets/8b0ce5d2-3b08-4e59-8eab-8a29c90d1e0d)

![Create,
before](https://github.com/user-attachments/assets/9578458f-4ac7-4d55-bd52-809736d7824a)

![Phones,
before](https://github.com/user-attachments/assets/be1044d1-b3a1-4a66-a252-bad28dd5a424)

</details>

### Every door, on the template

| Door | States |
|---|---|
| Sign-in (`RequireSession.door`) | signed-out root with the setup line,
`/login`, private patch address, Clerk waitlist, failed sign-in |
| Create and join (`companies/Join.ts`) | one invitation (who invited
you, as what), several invitations as rows, create, field refusals
(name, address taken, reserved, malformed, with a free fix), refusals no
field owns, already in a company |
| Beta link | open, refused email, sent, send failed with and without
Try again, used, ended, unavailable, invalid form |
| Device login | confirm, account changed, refreshed sign-in, invalid
name, replacing a computer of the same name, no code, confirmed, denied,
already connected, expired, used, unknown, rate limited, malformed and
oversize form, unavailable |
| Consent | consent, account or client changed, local callback warning,
access off for members and admins, ran out, can't connect (refused,
client document unavailable or busy, too long, account changed),
unreadable answer, rate limited, unavailable |
| Other doors | deactivated account, refused cross-origin form,
AuthPages' unavailable and invalid-form doors, dev persona picker with
its closed and cross-site refusals, the demo link's failures, Serving's
admission failures |
| Serving notices | global 404, every stopping notice (`data-notice`
kept), needs rebuild |
| Address notice | retired or deleted patch: now an app page on the
Index template, never a door |

A refusal no field owns (an account or client changed while the page was
open, a refreshed sign-in, an invitation that went away, already in a
company) is where the page's focus starts; a field's refusal sits under
the field, which takes the focus. Consent asked again with a local
callback says both in one notice.

The Final step's inline confirmation (`DevicePages.confirmForm`) keeps
its form, hidden fields, `data-inline-confirm` and Not me; it moved to
the field and button helpers and leaves validation to Patchy
(`novalidate`) instead of `formnovalidate` on Not me. P1 restyles the
guide around it.

## How it was verified

- `pnpm check`: format, lint, typecheck and synth pass. Offline tests:
everything I touched passes (auth, companies, serving, portal, core,
`apps/server`). The failures left locally are the CLI stub-log tests
that T3's port probes break on this machine, and `findWorktree` in
`scripts/dev`, which this change doesn't touch; CI is the judge.
- Unit tests updated to the new copy and markup, plus: the stopping
notice is a door marked with its code, the address notice is an app page
and not a door, the device page puts the code ahead of the identity and
never says connected, consent's buttons answer the form by id, and a
focused test for the new core helpers.
- Live-Clerk browser tests updated for the new headings and labels (`Is
this the code in your terminal?`, `Name this computer`, `Go back to your
terminal`, `Address`); they run only in CI.
- Captured every door on a brightline dev instance, desktop and phone,
as Allison and as new accounts; consent from the OAuth test harness's
fixture client. The dev host is rewritten or blurred in the screenshots.

## Core additions

New files only, plus one export line and one chunk line:

- `packages/core/src/ui/door.ts`: `doorCard` (the card around a
`doorPage`, which `pageResponse` and Serving's notices both draw),
`verificationCode`, `meet`, `canList`, `answerPair`.
- `packages/core/src/ui/refusal.ts`: `refusal`, the focus target for a
refusal no field owns (spec §10 Errors), and `typedExactly`, which keeps
a phone from capitalising or correcting an `input` or `prefixInput` such
as the company address.
- `packages/core/src/styles/door-parts.ts`, registered after `doors`.
- Auth: `doorResponse`, `unavailableDoor` and `accountFoot` in
`auth/page.ts`. `signOutForm` stays for integrations' pages until P6.

## Left out

- `/~ui` has no door states yet: the gallery is F2's existing file. G or
the integrator can add them from these helpers.
- The terms prompt: #1204 hasn't landed.

## Release impact

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

Copy and markup on first-party doors only. Routes, forms, field names,
statuses and headers are unchanged, and so is the running patch wrapper.

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

Built by Claude Opus 5.5 (xhigh) in Claude Code, orchestrated by Fermy.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the companies/terms-acceptance branch from 4df75c8 to 1e926f4 Compare November 10, 2026 21:04
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance: PASS with notes

Checked fb0e4a8540f9af562f8474591870957cb8713cbe (base e8851ea9264bb86a630a317333d98ed0f036af11) on a fresh team instance, by GPT-6.1-Sol (xhigh) in Codex on T3 Code. This replaces my FAIL at 1e926f4: its rollback-selector blocker is cleared. Some other CI jobs remain pending, so this is not a claim that merge checks are complete.

Done means — this re-check

  • Rollback rehearsal: passed. rollback-rehearsal succeeded in 3m51s. The CI run's headSha is the full checked SHA above.
  • Selector matches the rendered prompt: passed. On team's initially pending Cleo, form#terms-accept matches exactly 1 element; form#terms-accept[action="/auth/terms"] matches 1; button[type="submit"][form="terms-accept"] matches 1. The button is outside the form, and its DOM form property points to that form.
  • Accept records and continues: passed. Cleo starts with zero acceptance rows. Clicking the rendered Accept control sends POST /auth/terms, gets 303, and loads /patches?view=mine&from=acceptance-recheck with 200, title All patches – Acme Co. The database then holds exactly one row for Cleo, terms and privacy both 2026-11-10, via=prompt, with a timestamp. Her next navigation opens Home with no prompt.
  • Rest of CI: no failures observed; incomplete. At posting, 20 checks pass, 3 are pending (test (22), test (24), pidgeon-suite), and 2 are conditionally skipped (imap-live, attio-live). Passing checks include browser, test (26), test (bun), clerk-live, lint, Postgres concurrency, both CLI smoke jobs, all three installer platforms, tier 2 smoke and the server image. CI run.

Carried product evidence and golden journeys

As requested, I carry the behaviour evidence from the fresh team and guests acceptance run at 1e926f4, rather than repeat it. git range-diff e8851ea9..1e926f4 e8851ea9..fb0e4a8 confirms all three earlier commits are unchanged. The only new commit changes the rehearsal selector and adds the AuthPages markup assertion; no product code changed.

  • Portal and private-patch prompts at 1280/390: passed; shared door, legal links, Accept and account foot render correctly, without overflow or normal-load browser/CSP errors.
  • Accept/return/idempotence and sign out: passed; original private path and query survive, three parallel repeats leave one row, and signing out restores the private sign-in door without accepting.
  • Guest's own acceptance: passed on tier 1 and tier 2 doors; accepting records only the guest, leaving the host company's pending people unchanged.
  • Exclusions and public pages: passed; fetches, frames, metadata-free agent requests, CLI publish, MCP initialize/list and anonymous or pending viewers of public pages keep working without acceptance rows.
  • Stale revision and switched-account forms: passed; each returns 409 and writes no incorrect row; the warning receives focus.
  • Revision IDs, dated legal pages and migration: passed in that run; both revisions are 2026-11-10, the dated pages answered 200, and the fresh ledger ended at migration 36.

The earlier focused suites passed 5 files / 91 tests. These results are carried evidence, not newly executed tests at fb0e4a8.

Rollback answers: still match the additive diff. A revert leaves the table and its rows for older code to ignore; no one-way label is needed. The formerly failing rehearsal now passes.

Not run / notes

  • The full product matrix and full local pnpm verify were not repeated in this narrow re-check. Full machine-login, invite/join, lifecycle, two-viewer live sync and tier 2 business-rule journeys remain outside this run. Production Clerk signup/handshake was not exercised locally.
  • Three pending CI checks above are not counted as passed. Seven-year acceptance deletion remains follow-up Delete terms acceptance records 7 years after the account or company closes #1205.
  • Browser submission used the environment's printed hostname. An initial attempt through its generic localhost alias was refused by the instance-origin guard and wrote no acceptance row.

Surface coverage for the new commit: rollback runner and rendered form/button contract. Earlier coverage of both page boundaries, shared UI, seeds, migration, isolated CLI and MCP is carried forward; wire and CLI contracts are unchanged. The fresh instance was taken down, the preview tab was closed, and the working tree is clean. No production service or database was touched and no PR code, branch, body or labels were changed.

@allisonmahmood
allisonmahmood force-pushed the companies/terms-acceptance branch from fb0e4a8 to 662defa Compare November 10, 2026 21:30
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance carried to 662defa. The PASS with notes at fb0e4a8 (#1204 (comment)) still holds. This head is a clean rebase onto main 0bad5f3 (#1375). That commit changes only the broker, ADR-0010 and a tier 1 browser spec, none of which the prompt or the door uses, and git range-diff shows all four PR commits as =.

allisonmahmood and others added 4 commits November 10, 2026 23:05
Sign-up's checkbox stays the sign-up consent, now recorded against the
revisions in force when a user is created. When the terms or privacy notice
move, everyone who hasn't accepted them gets one prompt on their next page
load in a browser, portal or patch, guests included. Accept records who,
which revisions and when, append-only, and goes on to that page. Agents,
the CLI, fetches, frames, streams and public patches are never asked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The website now makes a revision current when it publishes it, and a
release follows; people who sign up in between are recorded with the
older ids and asked once after the release.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
P8's door puts Accept in its actions, outside the form it submits, so the
rehearsal finds it by the form it names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the companies/terms-acceptance branch from 662defa to f212c20 Compare November 10, 2026 22:05
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance carried to f212c20. This is a clean rebase onto main 805e9c9 (#1374, skill docs and the lock hash only). git range-diff shows all four PR commits as =, so the PASS with notes at fb0e4a8 still holds.

@allisonmahmood
allisonmahmood merged commit a25a9c5 into main Nov 10, 2026
26 checks passed
@allisonmahmood
allisonmahmood deleted the companies/terms-acceptance branch November 10, 2026 23:05
allisonmahmood added a commit that referenced this pull request Nov 10, 2026
…d once (#1376)

## What changed

This adds release 41's What's new entry, written from `a25a9c5`. It
covers everything merged since release 40's `through` (`08e1fd9`), and
sets the `patchy` release to `0.41.0` in `packages/patchy/package.json`
and `CURRENT_RELEASE`.

It ships the UI overhaul together with #1204, the terms prompt, as one
release, at Allison's word.

| Change | PRs |
| --- | --- |
| Improved: Patchy has a new look | #1332, #1336, #1338, #1343, #1353,
#1354, #1369, #1372 |
| New: Accept updated terms once | #1204 |
| Improved: Settings holds People, Integrations and Agent access |
#1334, #1341 |
| Improved: Home starts with what needs you | #1344, #1353 |
| New: A blue dot marks patches you haven't opened | #1370 |
| Improved: A patch's page has one header and tabs | #1345 |
| Improved: Search lands on All patches | #1346, #1353 |
| Improved: Inviting and deactivating people is clearer | #1349 |
| Improved: Your agents shows what's connected | #1352 |
| Improved: Integrations use plain words | #1347, #1351 |
| Improved: Agents and integrations show their own logos | #1371 |
| Improved: What's new goes by month | #1350 |
| Fixed: ⌘⇧K works on your company's public patches | #1339 |
| Fixed: Saving works after a patch stops being public | #1339, #1375 |
| Behind the scenes: every page built from one set of parts, with a
check | #1338, #1354 |
| Behind the scenes: agents know a once-public page's refusals mean
reload, and retries wait and stop | #1374 |
| Patch changes: a kept public page reloads into the company page; check
retries wait and stop | #1375, #1374 |

#1337 is release 40's own entry. #1340 (routes split, plus the call
summary Home and All patches show) and #1342 (the `dense` dev scenario)
need no line of their own: the call summary is part of the Home and All
patches changes, and the scenario is tooling. The overhaul makes no
patch changes. Running patches keep their own styles, which #1332 pins,
and the only SDK change is the wording of two error messages' admin
addresses.

## Look at

- **The entry**, at the top of `releases` in
`packages/core/src/whatsNew.ts`.
- **Rollback safety, from the live commit `d3d32da` (release 40) to this
PR's merge:**
- **#1334 is `one-way`.** Your agents and Settings moved to `/agents`
and `/settings/…`. Old addresses redirect forward, but release 40 serves
none of the new ones. This release's CLI hints, the `patchy` skill on
`main`, and the API, MCP and publish hints all name the new addresses,
so on release 40 they'd answer 404.
- **#1372 needs the private font bucket**, and that's done. Its deploy
step fetches the pinned Cabinet Grotesk file and checks it before
recording anything. The bucket was created on 2026-11-10 and holds the
pinned bytes. A rollback to a commit from before #1372 pins no font and
builds as before.
- **#1204** adds migration `0036_terms_acceptances`, an additive table
that release 40 never reads. Release 40 doesn't prompt, and coming
forward again asks only people who hadn't accepted. Not `one-way`.
- **#1375** changes only the public shell's script, and #1374 is skill
text. Release 40 renders its own shell and serves its own skills.
- **#1370 and #1339** add rows to the existing `patch_opens` table (a
guest's opens, and members' opens of public patches). Release 40 reads
them like any other open.
- **Everything else** is pages, styles, copy and docs: no migrations,
and no API, `--json` or configuration changes.
- **patchy-web #53**, the website line #1371's logos needed, is merged
(771e6d9).

**Rollback line:** Rolling back past #1334 would break every `/agents`
and `/settings/…` link that this release's CLI, skill and hints hand
out, because release 40 answers them with 404. Fix forward instead.

## How it was verified

- **Tests:** the `packages/core` What's new test passes (5), the
`packages/api` suites pass (64), and the three files are formatted.
- **The range.** Each of the 22 overhaul PRs was:
- reviewed by GPT 6.1 Sol at xhigh, with every finding fixed or declined
in writing on the PR;
  - accepted on its final head by an agent that didn't write it;
- merged green, by a merge train that rebuilt each PR's accepted tree on
main's tip and checked that main's tree matched it after every merge.
- **#1339, #1375, #1374 and #1204** were each Sol-reviewed and accepted,
and merged on their own: #1339 before the train, the other three after
it. #1204's acceptance was rerun on the new sign-in pages.

## Release impact

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

The changelog entry and the release version only.

- **What does a revert leave behind?** Nothing. CLIs installed from this
release report `0.41.0` and are told to match the server, as at every
release.
- **Does the release before it still work with that?** Yes.

Changes made by Claude Opus 5.5 in Claude Code, running in T3 Code.

Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Nov 12, 2026
… kept missing (#1249)

## What changed

Agents building on Patchy kept tripping over the same few platform
behaviours that nothing they read said plainly. The fixes are facts, one
or two sentences each, in the two places builders read: the `AGENTS.md`
that `patchy init` writes, and the project skills.

- **A page's form never submits.** Every page runs in a sandboxed frame
without `allow-forms`, so `<form onSubmit>` with a submit button sends
nothing. This caused 27 of the 53 failing runs on main (51%), nearly all
of them Terra's.
- **A plain `Error` doesn't reach the page.** Anything a handler throws
besides a declared `HandlerError`, or one of Patchy's own refusals,
arrives as `handler_failed`, with its message lost.
- **An agent knows a tool's arguments only from its description and
schema.** `t.enum` lists the accepted values in the schema; `t.text()`
names none.
- **The look can colour every `button`'s text, as the Patchy look
does.** A button restyled with a light background then keeps the look's
cream text and disappears.
- **What `ctx.viewer` is, and how a row id reaches
`ctx.tables.<t>.get`.** This was the most common reason builders left
the skills to read Patchy's type declarations.
- **`get` refuses an empty id.**

A last round of edits, written by Claude Fable 5.2 from the judges'
findings on this branch, is the last four commits, the last of them
fixing a review of the round:

- **List order and paging.** A list on a declared index comes back
ascending by the index's columns, so oldest first when `eq` fixes them
all, unless it passes `order: "desc"`; and rows past `limit` come only
through the cursor. The tables example passes both, and patchy-server
gains a paged handler example.
- **What a refusal looks like on the page.** A `HandlerError`'s
`message` is its code. The generated client exports `isHandlerError` and
`isPatchyError`, and patchy-preact shows a page telling them apart and
keeping `retry()` for a lost reply.
- **`useQuery` can't be skipped**, so a query that can't run yet belongs
in a component rendered once it can.
- **`useFileUrl` downloads the whole file as soon as it mounts**, and
each download counts against the viewer's 300 calls a minute.
- **An action's table writes commit one at a time**, and a write that
fails with `unknown_outcome` may have committed.
- **Every `server/` export is callable from the page.** `ctx.agent` is
null where no tool arrives, and a re-export can rename a tool with `as`.
- **The look's heading colour and paragraph width hold** the way its
button colour does.
- **The members skill exists only after `pnpm patchy add members`.**
- It also cuts paragraphs repeated word for word in another skill,
corrects the per-patch live-query re-run limit (2, not 1), and gives the
agent section's error sentence the same exception for Patchy's own
refusals.

Part of #1141. Supersedes #1244, whose change is the first commit here.

## Look at

![Judge scores, main vs this
branch](https://github.com/user-attachments/assets/b43a8987-8351-4374-9bfa-15f657d81af8)

| ×6, 120 verdicts a side | Fit | Platform | Correctness | UX | Code |
Mean | Checks pass |
| --- | --- | --- | --- | --- | --- | --- | --- |
| main (`8a3b347`) | 4.02 | 3.89 | 3.75 | 4.11 | 3.96 | 3.95 | 50/60
(83%) |
| this branch | **4.20** | **4.03** | 3.90 | **4.06** | 3.94 | **4.03**
| **54/60 (90%)** |

The goal was 4.0 or more on every judge dimension. Fit, platform and UX
meet it; **correctness (3.90) and code (3.94) don't yet**. UX and code
are level with main in this run, within noise, though round K moved
both. The rest of the correctness gap is design choices: paging, which
agent tools exist, copying a handler instead of re-exporting it, receipt
cleanup. Five rounds of facts didn't move those (see below).

- **Native-form pages** went from 4 to 0, and "the page sent Patchy
nothing" failures from 6 to 0.
- **Off-skill lookups** fell on the hard tasks: war-room/terra 4.0 →
0.3, spend-approvals/terra 3.7 → 0.0, spend-approvals/sonnet 5.7 → 2.8
per run.
- **Per task**, spend-approvals/terra went from 3/6 to 6/6. One drop:
spend-approvals/sonnet went 5/6 → 4/6. One head build subscribed every
viewer to an admin-only query, and logged `not_admin` refusals. In
another, Ben's request wasn't on Ada's starting view.

**Held-out tasks** (#1242 `recipe-book`, #1243 `standup`, ×3, never used
to choose a change): checks pass 9/12 → **12/12**; judges 3.68 →
**4.04**, correctness 3.04 → 3.75.

**On today's main, with the last round.** Measured after rebasing onto
`7f93b91`:

| ×3, 60 verdicts a side | Fit | Platform | Correctness | UX | Code |
Mean | Checks pass |
| --- | --- | --- | --- | --- | --- | --- | --- |
| main (`7f93b91`) | 3.85 | 3.88 | 3.65 | 4.08 | 3.97 | 3.89 | 17/30 |
| the first five commits (two suites, 120 verdicts) | **4.10** | 3.98 |
3.79 | **4.18** | 3.98 | **4.01** | 16/30, 18/30 |
| with the last round | **4.05** | **4.10** | 3.90 | **4.13** | **4.00**
| **4.04** | 18/30 |

- **The first five commits** still score higher than main on every
dimension.
- **The last round** against the first five is within ×3 noise on scores
(+0.06 mean), but what it aimed at moved. The judges' high and medium
findings about paging and truncation fell from 38 to 17, lists returning
the wrong end from 12 to 6, and retry handling from 18 to 12. All high
and medium findings fell from 170 to 154.
- **Pass rates are low on every side because the eval is broken on
main.** Since #1204, the `team` scenario's Cleo hasn't accepted the
terms, so when the grader opens a patch as her it gets the terms prompt
and the patch never loads. Every cheers and spend-approvals build fails
there. That hits both sides equally, so the comparison holds, but these
pass rates can't be compared with the ×6 above.

**Where the facts go matters more than what they say.** Terra (Codex)
loads `AGENTS.md` into its instructions and reads the skills as long
tool output. Each fact in this table was first tried in a skill alone,
and none changed what Terra built there. In `AGENTS.md`, each did:

| Fact | In the skill only | In `AGENTS.md` |
| --- | --- | --- |
| Forms never submit | native-form pages 1 → 4 of 12, dropped (H1) |
native-form pages 2 → 0; pass 77% → 93% (round A) |
| A plain `Error` is `handler_failed` | plain throws 2 → 1, judges flat,
dropped (G) | plain throws 1 → 0; pass 80% → 90% (H) |
| `t.enum` is in the tool's schema | judges 3.86 → 3.81, dropped (C) |
every dimension up, mean 3.91 → 4.01 (I) |
| A restyled button keeps the look's text colour | too rare in its suite
to read, dropped (F) | transparent-button rules 9 → 3 of 30; UX 3.92 →
4.15, code 3.85 → 3.98 (K) |

`AGENTS.md` is written once, at `patchy init`; `refresh` never touches
it. So each fact also goes into its skill, as it was measured there, so
builders in existing repos get it too. Those skill versions measured
neutral on their own, not harmful. After review, three sentences were
tightened without changing what they tell a builder. A business refusal
is a declared `HandlerError`, and Patchy's own refusals keep their
codes. A tool's description counts as well as its schema. The button
rule holds when the look sets a button text colour.

**War room, Terra, one build each side (round K):** before, the Resolved
and All filter tabs are cream text on cream and only Open shows; after,
all three read.

| Before | After |
| --- | --- |
|
![before](https://github.com/user-attachments/assets/810f0641-3dbf-4d96-ab8a-9d3ffa708a3b)
|
![after](https://github.com/user-attachments/assets/130c7d7c-ba0b-4917-ab6e-6891a4d00311)
|

<details><summary>Every round, kept and dropped</summary>

Each round is an A/B suite: base and head both build all five training
tasks ×3, both builders (Claude Code on Sonnet 5.5, Codex on Terra 6.1),
both judges (Opus 5.5, Sol 6.1): 30 runs and 60 verdicts a side (H2, run
twice: 60 and 120). Rounds after A are measured against #1244 + A.

| Round | Change, and where | Judges, mean | Pass | Target signal |
Result |
| --- | --- | --- | --- | --- | --- |
| H1 | Retitle patchy-loop's "Tier 1 constraints" to cover every page
(forms) | 3.93 → 3.80 | 80% → 77% | native-form pages 1 → 4 of 12 |
dropped |
| H2 | patchy-server: `ctx.viewer`'s shape; row ids reach tables as
`Id<"table">` (×6) | 3.85 → 3.83 | 83% → 78% | off-skill lookups on the
hard tasks 5.2 → 2.1 per run; held-out `standup` too | **kept** (was
#1244) |
| H3 | patchy-server: a `HandlerError`'s message is its code; the
`errors` list | 3.92 → 3.91 | 80% → 83% | bare-code findings 16 → 15 |
dropped |
| A | `AGENTS.md` and patchy-preact: forms never submit in the frame;
patchy-tables: `get` refuses an empty id | 3.82 → **4.03** | 77% →
**93%** | native-form pages 2 → 0; "sent nothing" 3 → 0 | **kept** |
| B | patchy-server: a `t.member()` column holds `user.id`, a copied
name goes stale; patchy-tables: filtering a fetched page misses later
pages | 3.86 → 3.80 | 83% → 73% | builds using a member column 5 → 5 of
12; truncation findings 65 → 67 | dropped |
| C | patchy-server: an action with no tool is closed to agents;
`t.enum` is in the tool's schema | 3.86 → 3.81 | 73% → 73% |
agent-coverage findings 17 → 18 | dropped |
| D | patchy-look: recipe classes need their CSS, the Patchy look's
example company is made up; files: `put` by a caller's name,
`useFileUrl` fetches on mount | 3.93 → 3.91 | 90% → 83% | look findings
13 → 10, files 22 → 15; dimensions flat | dropped |
| F | patchy-tables: a declared index lists ascending; patchy-look: a
restyled button keeps the look's text colour | 3.97 → 4.01 | 90% → 90% |
invisible-text findings 1 → 1, order findings 5 → 7 | dropped |
| G | patchy-server: a plain `Error` reaches the page as
`handler_failed` | 4.06 → 4.05 | 90% → 87% | plain throws 2 → 1 |
dropped (moved to H) |
| H | `AGENTS.md`: G's fact | 3.95 → 3.95 | 80% → **90%** | plain throws
1 → 0; `handler_failed` failures 1 → 0 | **kept** |
| I | `AGENTS.md`: C's `t.enum` fact | 3.91 → **4.01** | 83% → 80% |
every dimension up; agent-check failures 1 → 0 | **kept** (part of the
lift is likely noise: it spans tasks without agent tools) |
| J | `AGENTS.md`: a `list` returns one page and a cursor | 3.99 → 3.96
| 83% → 83% | truncation findings 17 → 19 | dropped |
| K | `AGENTS.md`: F's button fact | 3.92 → **4.03** | 90% → 77% |
transparent-button rules 9 → 3 of 30; UX 3.92 → 4.15 | **kept**, an
exception: its pass dip was 4 plain-`Error` refusals and 1 free-text
agent argument, H's and I's targets, which K's branch lacked |

Judges are the mean of the five dimensions over both judges; each round
is 30 runs and 60 verdicts a side (H2: 60 runs and 120 verdicts).

</details>

## What didn't work, and why

- **Restating a rule where Terra already reads it.** Terra `cat`s whole
skill files on both sides of every A/B, so a heading never gated whether
it saw the form rule (H1). It saw it, and wrote a native form about half
the time anyway. The same fact in `AGENTS.md` worked.
- **Facts about design choices.** Telling builders that a `t.member()`
column holds a stable id (B), that leaving out an agent tool closes it
to agents (C), that filtering a fetched page misses later pages (B, and
J in `AGENTS.md`), or that a declared index lists oldest first (F) left
the designs unchanged. Truncation findings stayed at 65 → 67 and 17 →
19. Only facts about behaviour the builder didn't know changed what it
built. The exception came in the last round: it restated paging as what
`list` does, with an example passing `order` and the cursor, and the
paging findings halved (38 → 17).
- **Saying what a refusal looks like on the page (H3).** True, and
builders still showed the bare code.
- **The look's example company.** I wrote that the Patchy look's example
markup names a made-up company, Acme Co, after judges flagged pages that
read "Acme Co". The `team` scenario's company *is* Acme Co, so those
pages were right and the judges wrong. Dropped (D). The last round says
only that the sample's names are placeholders and the company's name is
`company.name`.
- **Codex truncating long output.** Terra prints several skills in one
command, so I checked whether the form rule fell in an elided middle.
Runs where the rule landed in the visible head or tail used native forms
as often (3/5) as those where it was cut (21/49), so that isn't why.

## How it was verified

- **Final:** this branch's head against main (`8a3b347`), ×6 (two ×3
suites on the same commits), all five training tasks, both builders,
both judges.
- **Held-out:** both held-out tasks, #1242 `recipe-book` and #1243
`standup`, merged locally onto main, with this branch on top. They were
never used to choose a change. Result, ×3, 24 verdicts a side: pass 9/12
(75%) → **12/12 (100%)**; judges 3.68 → **4.04** (fit 3.79 → 4.17,
platform 3.96 → 4.25, correctness 3.04 → 3.75, UX 3.92 → 4.13, code 3.71
→ 3.88); native-form pages 3 → 0.
- **Facts checked against the code:**
- forms: `packages/serving/src/shell.ts`, the frame's
`sandbox="allow-scripts allow-modals"`
- refusals: `packages/runtime/src/Invocation.ts`, `HandlerFailed`'s
fixed message
  - enums in tool schemas: `packages/api/src/agentTools.ts`
- buttons: `packages/companies/looks/patchy/look.css`, the `button` rule
- empty ids: `packages/api/src/runtime.ts`, `tables.get` takes
`NonEmptyText`
- viewer shape: `ContextBase.viewer: Me` in
`packages/patchy/src/server.ts`
- **The last round:** its head (`c8af5ed`, before the last commit's two
wording fixes and a clean rebase) against the first five commits, ×3;
and the first five against main in a separate ×3 suite, both on
`7f93b91`. Each claim in it was checked against the code:
`TableOperations.ts` for list order, `handlerError.ts`,
`generateClient.ts` and `generateServer.ts` for refusals and imports,
`useQuery.ts`, the admission in `Runtime.ts` for file downloads,
`registry.ts` for limits, `handlerDescriptors.ts` for re-exports,
`Generation.ts` for the members skill, and `look.css`.
- **Review of the last round:** GPT-6.1 Sol at xhigh, in Codex. Its five
findings are fixed in the last commit: a declared index sorts by its
columns, not by age; the page's error example left the `missing` code to
show as text; only handler runs leave log entries; a call never sent
fails with `unknown_outcome` and no `retry()`; and patchy-server
repeated patchy-preact on `useQuery`.
- **Raw runs stay on the eval machine.**
- On this head, format, the SDK's skill tests (34, in `install`,
`FrontDoor` and `SdkApi`) and `initProject.test.ts` (15) pass. Before
the last round, `env -u NODE_ENV pnpm check`: format, lint, typecheck
and synth pass; 2,828 of 2,830 tests pass. The two that timed out at 30
s (`cliRepoPublish`, `devServerWatch`) did so while four eval suites
shared the machine; rerun alone with `initProject.test.ts`, all 38 pass.

**Noise, so the numbers read right.** The same main commit read between
3.89 and 3.99 mean across suites, and one run is 3.3 points of a ×3 pass
rate. Rounds were kept when their target moved and their pass rate held;
K is the stated exception. The headline numbers pool two ×3 suites run
on the same two commits.

**Found on the way, outside this PR:**
- **The eval since #1204.** The grader can't open a patch as the `team`
scenario's Cleo, who hasn't accepted the terms, so two of the five tasks
can't pass. A fix: the eval accepts the current terms for every person
it signs in as.
- **A live-query race.** A shell `replace` that arrives after a later
`subscribe` is refused with 409, and the grader fails any check whose
page logged an error. That can fail a correct build.
- **Eval disk use.** The harness keeps a ~2 GB builder home per run. A
trimmer on the eval machine covered it here.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required: skill text, and the
`AGENTS.md` text new repos get.

- **What does a revert leave behind?** Repos initialised in between keep
the new `AGENTS.md` sentences, which stay true; skills regenerate from
the release.
- **Does the release before it still work with that?** Yes.

Claude Opus 5.5 in Claude Code, through T3 Code; the last round's skill
edits by Claude Fable 5.2.

---------

Co-authored-by: Allison Mahmood <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Nov 12, 2026
Since team's Cleo became termsPending (#1204), the grader landed on the
terms prompt whenever it opened a patch as her, so every cheers and
spend-approvals check that needs her failed on both sides. A run's people
now all start past the prompt; no task is about it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Nov 12, 2026
## What changed

`pnpm dev eval` has failed every check that opens a patch as `team`'s
Cleo since #1204, on both sides of every suite. #1204 made Cleo
`termsPending` so the terms prompt could be shown, and every run copies
its scenario's people, Cleo included. So when the grader opened a patch
as her, it landed on "We've updated our terms" instead of the patch.
Since then, cheers checks that need her and spend-approvals' approval
and rejection checks have failed whatever was built. Pass rates from
that point on can't be compared with earlier ones.

A run's people now all start past the terms prompt. No eval task is
about the prompt, and the scenario itself is unchanged: `pnpm dev up
team` still shows Cleo the prompt.

## Look at

`namespaceScenario` in `scripts/dev/src/eval/fixtures.ts` copies each
person without `termsPending`. A new test seeds a run of `team` and
checks that every run person has accepted the current terms. It fails on
main and passes here:

```text
main:  × starts every run's people past the terms prompt, as its checks open pages as them
       AssertionError: expected false to be true
here:  Tests  45 passed (45)   (scripts/dev/src/eval/eval.test.ts)
```

**Real runs.** `pnpm dev eval` seeds both sides with the eval code of
the checkout that runs it, so the comparison is between whose eval code
ran, not between the sides. Sonnet built, with no judges:

| Eval code | Task | Runs | The checks that open as Cleo |
| --- | --- | --- | --- |
| main, yesterday's ×3 suite | cheers | 14 | all 14 fail "each cheer
reaches a third colleague: The patch never showed Cleo Shah anything." |
| main, yesterday's ×3 suite | spend-approvals | 12 | approval and
rejection fail in 10 with the same sentence; the other 2 failed earlier,
on their builds |
| main `3a43a84`, today | cheers | 4 | all 4 fail with the same sentence
|
| this branch | cheers | 4 | 4/4 checks pass in every run |
| this branch | spend-approvals | 2 | 6/6 checks pass in every run |

## How it was verified

- `scripts/dev/src/eval/eval.test.ts`: 45 pass, including the new test.
- `scripts/dev` typechecks; lint and format pass on the changed files.
- The eval runs above, from a checkout of main and from this branch.
- `docs/DEVELOPMENT.md` now says a run's people start past the prompt,
under "A run's identities".

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — the dev eval's own fixtures; nothing that ships
changes.

- **What does a revert leave behind?** Nothing. Eval runs' people would
get the prompt again.
- **Does the release before it still work with that?** Yes.

Claude Opus 5.5 in Claude Code, through T3 Code.

Co-authored-by: Allison Mahmood <[email protected]>
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:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area area:server Touches the server area area:ui Portal and first-party browser pages, shared rendering and styles size:l 501-1,000 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Each company accepts the terms, and an admin accepts again when they change

1 participant