Skip to content

fix(serving): a kept public page reloads once its patch is company-only again - #1375

Merged
allisonmahmood merged 2 commits into
mainfrom
fix/kept-public-shell-reload
Nov 10, 2026
Merged

allisonmahmood merged 2 commits into
mainfrom
fix/kept-public-shell-reload

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

What changed

Someone made a tier 1 patch public, switched it back to company 23 seconds later, and reopened it. Every save then failed with "Runtime request refused: principal_changed." Production served a public page as public, max-age=60 to members too, so for a minute their browser started its kept copy of the public page. The kept copy's me named them, because the patch was company again, so the page enabled its buttons. But a public shell binds no principal, so every data call was refused. On a public frame that refusal shows no notice, so the page simply looked broken.

#1339, merged and not yet released, stops caching a member's public page, which closes the path production took. This PR is the backstop for any other copy a browser keeps, such as a page restored by a proxy or an older cached response. A public shell never hands its patch a viewer. If its first me names someone, the patch is no longer public, so the shell reloads the address and the person gets the company page.

Refs #1373 (refused calls count against no limit, which let that tab send about 60,000 of them in under an hour).

Look at

identify() in packages/serving/src/broker.ts. A company shell pins the viewer from me, as before. A public shell now treats a non-null me as a sign that it's stale: it releases the reply's bytes, stops the broker, removes the frame and reloads, and the patch's call fails as a lost request rather than resolving. Runtime answers a public version's me with null and the broker caches me per document, so only a document that starts after the sharing change reaches this branch.

What it leaves alone. A public tab that is already open when the patch goes back to company keeps #1339's contract. It keeps its page and draft, and the patch sees principal_changed, as stream.spec.ts "a member's public patch that goes back to company refuses the patch, not the page…" still checks. I tried reloading on that refusal too and backed it out, because it would throw away a draft that #1339 keeps on purpose.

How it was verified

  • New browser case in tier1.spec.ts, "a kept public copy that starts after its patch went back to the company reloads as the company page". It serves a page the test kept from when the patch was public, after sharing goes back to company. On main's broker it fails: the page stays the public shell, and while diagnosing I saw the patch get the viewer from me and its table calls refused principal_changed. With this change it passes: the page reloads as the company shell, me names the viewer and a table call lists.

    Error: expect(locator).toHaveAttribute(expected) failed
    Expected: "company"
    Received: "public"
      1 failed
    
  • The tier 1, stream, pinned-viewer, switcher and switcher-relay browser specs pass on the rebased head: 83 passed.

  • bun fmt --check, oxlint, pnpm typecheck:tests and the serving package's effect-tsgo tsc pass.

  • The ADR-0010 public-shell paragraph says the shell never gives its patch a viewer.

Release impact

  • Breaking — requires action from anyone already running this

  • Not breaking — shell script change; the server and wire are unchanged

  • What does a revert leave behind? Nothing. Shells rendered by this release carry the new broker; after a revert, pages render the old one.

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

Written by Claude Opus 5.5 in Claude Code, running in T3 Code.

🤖 Generated with 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:docs Touches the docs area size:s Under 100 changed lines labels Nov 10, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Sol review

  • packages/serving/src/broker.ts:545 — should-fix: A non-null first me can reload an already-open public document and discard its draft. The switcher relay reveals the frame before this lookup settles; hold the initial /api/runtime/call before forwarding it to Runtime, enter a draft, switch sharing to company, then release the request. Runtime now returns the viewer and this branch removes/reloads the frame, violating fix(serving): members get the switcher on their company's public patches #1339's draft-preservation contract. Both the existing preservation case and the new kept-copy case wait for initial identity, so they miss this ordering. Fix: finish stale-public-shell validation before exposing an interactive frame, and cover a sharing change while the initial me has not reached Runtime.

  • docs/adr/ADR-0010-sandboxed-frame-and-broker.md:26 — nit: A viewer from the first me does not prove that this is a kept copy started after the patch returned to company sharing. Publishing a replacement public version also makes the loaded older version company-only (packages/patches/src/LoadedVersions.ts:30), and the initial lookup can race a sharing change as above. Fix: describe the loaded version as no longer public, without asserting a particular cache or sharing history.

Otherwise, the cleanup ordering, rejected identity cache and caller guards look sound. Runtime returns null for every public version regardless of the reader's session, company or guest grant, so legitimate public readers do not enter a reload loop. The new test replays the kept HTML once against real Runtime and would fail without the branch. Browser and e2e suites were not run, as requested.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Replies to the Sol review, in 1cad6a0:

  • Delayed first me (dismissed, with reason). The window is real: between the SDK's ready and the first me reply, a sharing change can reload a document that's already showing. But main already ends that window the same way for everyone else. On a public frame, identify() at ready goes to identifyFailure, which turns session_expired, principal_changed or access_denied into a notice. That's a navigation, so a signed-out reader or an outsider loses the same draft in the same window today. The first me is already the public document's start check. This PR gives a signed-in reader, who gets a viewer instead of a refusal, the same ending. fix(serving): members get the switcher on their company's public patches #1339's contract covers documents after that check, and its test still passes. Holding every public page hidden until me returns would add a round trip before every public page appears, to protect what someone types in the first round trip during a sharing change. The code comment now says this is the start check.
  • ADR wording (fixed). Agreed: replacing the current public version also makes the loaded one company-only. ADR-0010 and the broker comments now say the loaded version is no longer public and give a kept copy as one example, not the only cause.

These are comment and doc changes only, so the browser run on a4c9e24 still covers the behaviour.

allisonmahmood and others added 2 commits November 10, 2026 22:10
…ly again

A browser could start a public shell it kept after the patch went back to
company sharing. Its `me` then named the viewer, while every data call
carried no principal and was refused `principal_changed`. The public shell
now reloads the address when `me` names anyone, so the person gets the
company page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ion is no longer public

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the fix/kept-public-shell-reload branch from 1cad6a0 to c3b02d4 Compare November 10, 2026 21:10
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance: PASS with notes

Checked c3b02d49e1fee26527540707f0589937fcfbc478 (base e8851ea9264bb86a630a317333d98ed0f036af11) on the offline tier 1 browser fixtures, with fresh Patchy Dev/Pine test people and disposable databases, by GPT-6.1 Sol (xhigh) in the Codex harness, running in T3 Code. I did not write this change. Local HEAD and the PR head match; the tracked tree stayed clean.

Rebase check and reused evidence

The diff is byte-identical to the previously accepted 1cad6a09a28f7d421ef792e89e56b16bc845ddde against its base 58bb17d7ec7d57d0bab78e10e8263c6f3350a5be:

git diff 58bb17d7...1cad6a09  versus  git diff origin/main...HEAD
6,322 bytes in each; byte-for-byte equality confirmed
SHA-256 (both): 2c82c122afc68dc549870e59c879f3b5d93c6e8bc5b30f8ca5cbe2af21d68269

git log 58bb17d7..e8851ea9
e8851ea9 feat(core): page titles in Cabinet Grotesk, the font kept out of the repo (#1372)

I inspected that intervening change. It changes first-party typography, font serving/startup validation and image/deploy packaging, with no change to the broker, Runtime admission, sharing/version lookup, shell HTML or shell stylesheet. The broker, shell renderer, shell stylesheet, Runtime, LoadedVersions and both requested specs are also byte-identical to the previously accepted head. The fresh run below built and started the rebased server, exercising the adjacent font startup dependency. I therefore reuse the earlier acceptance's independent probes and reasoning where explicitly identified below; they were not rerun.

Done means

There is no closing issue; the PR's What changed is the claim checked. Referenced #1373's refused-call rate limiting remains separate work.

  • A kept public copy whose first me names a viewer recovers to a working company page: passed freshly. The kept-copy case reloads to a company shell, identifies the viewer and successfully lists its table.
  • The stale public shell does not deliver that viewer to its patch: passed, using the unchanged broker's release/stop/detach/reload path and the prior acceptance's head-versus-base identity probes. Those probes showed the base exposing a viewer followed by principal_changed, while the head recovered with the route preserved.
  • An established public document keeps its draft after unsharing or session end: passed freshly. Both existing stream cases passed, including the expected data refusal without page navigation. The earlier delayed delivery of an already-evaluated null identity remains supporting evidence.
  • Replacing a public version can trigger the same recovery: passed using prior evidence. The earlier independent replacement probe observed one reload into the latest public version with anonymous identity; the relevant lookup and broker code are unchanged.

Golden journeys

  • Share/unshare and publish/open a page: passed for the public/company shell transitions, cached-page return and working company data access after recovery.
  • Sign-in boundary: passed in the fresh offline signed-session case covering the login door, logout, expiry, account switch, revocation and public errors.
  • Keep using an open page: passed for draft retention, live-stream reconnects, publish/rollback notices, routing, file/download behavior and isolation exercised by these two specs. The earlier pinned company/local-document reasoning is reused, with no claim that its separate spec ran again.

Fresh local evidence

pnpm exec playwright test -c playwright.tier1.config.ts --project=chromium test/browser-tier1/tier1.spec.ts test/browser-tier1/stream.spec.ts

40 passed (2.5m)

pgrep -af 'playwright|vitest' found no suite before launch. This was the only heavy suite I ran. Fixture teardown completed; no Playwright/Vitest process remained afterwards. No PR code, branch, body or labels were changed, and no unrelated process was killed.

Rollback answers: They match the diff: browser script, ADR and test only; no schema, persisted data shape, infrastructure or wire change. An older release remains compatible, so no one-way label is needed. The rebased head's CI rollback-rehearsal check passed.

Not run

  • pnpm verify: explicitly excluded by this task.
  • The prior acceptance-only probes and pinned-viewer.spec.ts: evidence/reasoning reused after confirming the unchanged diff and relevant source; not rerun.
  • A live Clerk journey locally: these fixtures use offline signed test sessions.
  • Full CI completion: browser, Clerk and several other jobs were still pending/in progress at the final check; no failed check was reported. This verdict does not assert merge readiness.

Notes

  • The earlier startup caveat still applies: the public frame can become interactive before its first me completes. Unsharing during that interval can discard a member's newly entered input. I retain the prior acceptance's scope decision: the base already navigates signed-out readers and outsiders away in that ordering, while its member path exposes an unusable viewer; the successful initial-check path preserves drafts. Reusing that reasoning does not eliminate the startup draft-loss window. The committed kept-copy test does not cover that race; the earlier independent probes did.
  • Applicable mirrored surfaces are the served shell and ADR-0010. The CLI, API, migrations, dev runner and package layout have no changed contract.

@allisonmahmood
allisonmahmood merged commit 0bad5f3 into main Nov 10, 2026
25 checks passed
@allisonmahmood
allisonmahmood deleted the fix/kept-public-shell-reload branch November 10, 2026 21:25
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]>
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 size:s Under 100 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant