Skip to content

chore: format with bun fmt - #1120

Merged
allisonmahmood merged 5 commits into
mainfrom
bun/fmt
Nov 1, 2026
Merged

allisonmahmood merged 5 commits into
mainfrom
bun/fmt

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

What changed

Formatting ran on Prettier through lint-staged, and a whole-tree check took about 15 s. It now runs on bun fmt, which reads the same prettier.config.js and .prettierignore and accepts every file in the tree as it is. pnpm format, pnpm format:check and the pre-commit hook all call it, and so do pnpm check and CI's lint job through format:check. Prettier is removed; lint-staged stays as the hook's runner. Nothing changes for anyone using Patchy.

The PR also carries the commit that pins Bun. The root devDependency "bun": "runtime:1.4.4" uses pnpm's runtime protocol, so pnpm install puts Bun in node_modules/.bin, checked against sha256 hashes in the lockfile. (An earlier push used devEngines.runtime. npm refuses any devEngines.runtime that isn't Node, so the packed CLI tests' npm pack failed with EBADDEVENGINES. The devDependency form gives the same lockfile entry, and npm never reads it.) pnpm's one-day minimumReleaseAge doesn't cover runtime downloads, so docs/DEVELOPMENT.md says to check a Bun release is at least a day old before bumping to it. That's the same by-hand rule as the Node patches and the node:24-slim digest. It is the only place the Bun version is set: CI, worktrees and, in later PRs, the image build all get Bun from it. Scripts still run on Node.

Part of #1040.

Look at

Bun formats like Prettier 3.9.10. I formatted this deliberately broken file with Prettier 3.9.10 and with bun fmt, both using the repo config:

import {Effect,Schema} from "effect"
import type {ReactNode} from 'react'
export class PatchMissing extends Schema.TaggedErrorClass<PatchMissing>()("PatchMissing",{company:Schema.String,name:Schema.String}){}
const   lookup = Effect.fn("lookup")(function*(company:string,name:string){
  const rows=yield* Effect.succeed([{id:1,company,name,tags:["a","b",],},])
  if(rows.length===0) return yield* new PatchMissing({company,name})
  return rows[0]!
})
export const Card=({title,children,tone='plain'}:{title:string;children?:ReactNode;tone?:'plain'|'danger'})=><section className={tone==="danger"?"note note-refused":"note"} aria-label={title}><h2>{title}</h2>{children}</section>
export const total = (xs: ReadonlyArray<number>) => xs.reduce((sum, x) => sum + x, 0) + xs.filter(x => x > 10).length * 2 + 1
Both outputs, identical (sha256 cdf161bf…ec3869a each)
import { Effect, Schema } from "effect";
import type { ReactNode } from "react";
export class PatchMissing extends Schema.TaggedErrorClass<PatchMissing>()("PatchMissing", {
  company: Schema.String,
  name: Schema.String
}) {}
const lookup = Effect.fn("lookup")(function* (company: string, name: string) {
  const rows = yield* Effect.succeed([{ id: 1, company, name, tags: ["a", "b"] }]);
  if (rows.length === 0) return yield* new PatchMissing({ company, name });
  return rows[0]!;
});
export const Card = ({
  title,
  children,
  tone = "plain"
}: {
  title: string;
  children?: ReactNode;
  tone?: "plain" | "danger";
}) => (
  <section className={tone === "danger" ? "note note-refused" : "note"} aria-label={title}>
    <h2>{title}</h2>
    {children}
  </section>
);
export const total = (xs: ReadonlyArray<number>) =>
  xs.reduce((sum, x) => sum + x, 0) + xs.filter((x) => x > 10).length * 2 + 1;

The same held for YAML, JSON and CSS samples. For a wider test, I took every tracked file and rewrote it in a different style with Prettier (print width 40, tabs, single quotes, no semicolons). Then I formatted that copy once with Prettier 3.9.10 and once with bun fmt, both using the repo config. Bun reformatted 946 files, and 937 of them came out byte-identical to Prettier's.

Where Bun differs from Prettier. Two cases, neither of which occurs in the tree today:

  • CSS custom-property values keep single quotes. Prettier changes --font: 'Geist', sans-serif to double quotes and Bun leaves it alone. The 9 differing files are all this case (look CSS, scenario styles, two HTML files), 23 lines in total. Ordinary declarations such as font-family: 'X' still get double quotes. If a new file uses single quotes in a custom property, the check passes and the quotes stay.
  • A rare Markdown case. A list item followed, without indentation or a blank line, by lines that look like a table: Bun joins the first two of those lines into one. It renders the same.

<!-- prettier-ignore --> and // prettier-ignore still work; docs/limits.md and the generated limits table depend on them.

The shell broker generator. scripts/build-serving-broker.mjs imported Prettier only to format its own output. That output is gitignored, but the format check still scanned it, because neither Prettier nor bun fmt reads nested .gitignore files. .prettierignore now lists that directory, and the generator writes plain text. The browser gets the same script and digest; only the string's quote style in the generated .ts changes. Rollback rehearsal builds old commits in their own checkouts with their own pnpm install, so they keep their Prettier.

The pre-commit hook is still pnpm exec lint-staged. lint-staged now runs bun fmt --ignore-unknown on the staged files, where it used to run prettier --write --ignore-unknown. Every worktree of a clone shares one .git/hooks/pre-commit, which simple-git-hooks rewrites on each pnpm install. A first version of this PR made the hook bun fmt --staged, which broke commits in worktrees still on Prettier (no bun on their PATH), and theirs broke ours (no lint-staged). With the same hook text on both sides of the switch, each worktree runs its own lint-staged config. lint-staged also keeps its stash handling for partly staged files. I checked a staged misformatted .ts (formatted and restaged), a staged binary (skipped), and a real commit of this PR's last change through the hook.

How it was verified

  • bun fmt --check passes on the whole tree (1,015 files), and bun fmt changes nothing. bun fmt --doctor reports every file formatted natively and no Prettier left.

  • pnpm install --frozen-lockfile works in a fresh clone on Linux. It downloads Bun 1.4.4, prepare builds the broker, pnpm format:check passes, and the clone's own hook formats a staged file on commit.

  • pnpm check locally: format, lint, typecheck and synth pass. The offline tests had 2,600 passes and 19 failures, all of them known local failures in code this PR doesn't touch:

    • 17 CLI tests whose stub servers logged a stray GET / (T3 Code probes local ports on this machine).
    • The Supervisor.test.ts residency test, which flakes under load and passes when run alone.
    • The LocalTaskProvider.test.ts routing test, which flakes on both runtimes.

    CI is the gate for those.

  • dependency-review passed on d6317f0.

    • In the dependency-graph diff, which the action reads, bun is a new development dependency from package.json, version runtime:1.4.4, with no vulnerabilities and no license. The action allows that.
    • The only other change is the removal of prettier.
    • GitHub's two advisories for the npm bun package cover versions up to 1.1.39. runtime:1.4.4 isn't semver, so no advisory range can match it.
  • Dependabot, checked against dependabot-core's current source:

    • Its pnpm lockfile helper, run on this lockfile, reads 347 records. Bun is one of them, with an empty version.
    • Its manifest parser does see "bun": "runtime:1.4.4", and looks the version up in the lockfile. semver_for("") is nil, and build_dependency drops a manifest entry whose lockfile record has no version. So it doesn't error, and it never offers a bump to the npm bun package. No dependabot.yml entry is needed.
    • Nothing reads devEngines any more. Dependabot reads only engines and devEngines.packageManager, and the repo has no reader left.
    • A pnpm update <dep> --lockfile-only --no-save -r, the kind of update it runs, leaves the Bun entries intact.
    • So Dependabot doesn't bump Bun. docs/DEVELOPMENT.md says how: change the version and run pnpm install. I checked that this rewrites all ten platform entries.
  • Not verified: Dependabot end to end. Its lockfile step ran here; the manifest step is read from its source. CI's lint and smoke jobs are still running on this PR.

Release impact

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

Dev tooling only. The server, CLI and image don't format anything at runtime. The broker's generated file is never shipped as source, and the script it holds is unchanged.

  • What does a revert leave behind? Nothing. Prettier comes back, and the hook's text doesn't change.
  • Does the release before it still work with that? Yes. Nothing at runtime changed.

Built by Claude Opus 5.5 (xhigh effort) in T3 Code, via Claude Code.

@github-actions github-actions Bot added area:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area size:s Under 100 changed lines labels Oct 31, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Independent review of the current head, including the follow-up that replaces devEngines.runtime with a runtime: devDependency. The earlier EBADDEVENGINES failure is fixed; the repository's pinned npm now passes pack --dry-run --ignore-scripts --json.

  1. [P2] Preserve the release-age safeguard for Bun upgrades — package.json:50, docs/DEVELOPMENT.md:67. With the pinned pnpm 12.9.1, a fresh manifest containing bun: runtime:1.4.4 installs successfully even with minimumReleaseAge: 52560000; an ordinary npm dependency is correctly rejected under the same setting. Runtime resolution bypasses the workspace's one-day delay. Following the documented “change the version and run pnpm install” procedure can therefore admit a newly published compromised Bun immediately, and the formatter/hook then executes it. The SHA-256 pins protect subsequent downloads, not the initial version selection. Add an age check for runtime bumps, or document an explicit manual one-day check instead of silently relying on the existing policy.

  2. [P2] Make the hook compatible with concurrent older worktrees — package.json:69. Installing this branch replaces the shared hook with pnpm exec bun fmt --staged. An older worktree without a global Bun then cannot commit: Command "bun" not found. Installing in that older worktree reverses the failure: this branch's commits stop with Command "lint-staged" not found. I reproduced both directions. Reinstalling the hook only changes which worktree breaks; it does not resolve coexistence. Use a worktree-local hook or a compatibility strategy that selects the current worktree's available formatter.

Targeted verification: pnpm 12.9.1 install and frozen-lockfile install; current-tree Bun and Prettier checks; API/limits rendering tests (3 passed); broker script equality and digest verification; formatter round-trips covering TS, JS, MJS, JSON, YAML, Markdown, CSS and HTML; staged/partly staged hook probes. All ten lockfile runtime hashes match Bun's published checksums.

I found no remaining Prettier invocation in generators, renderers, skills or CI. scripts/verify.ts still reaches the formatter through format:check. The CSS custom-property quote difference occurs on realistic future edits to existing look files and embedded HTML, but causes formatting churn rather than a runtime failure. The Markdown list/table edge also reproduces; I found no blocking semantic change in that case. Dependency-review passes; Dependabot's parser leaves this runtime unmanaged, as documented. I did not run the full suite or native macOS/Windows contributor installs; CI's cross-platform install jobs exercise the packed CLI, not repository Bun setup.

Verdict: ship after fixes.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Both findings are fixed, in dd1fefb:

  1. Release age. Confirmed: pnpm's minimumReleaseAge doesn't gate runtime: downloads. docs/DEVELOPMENT.md now makes the bump a by-hand step: check that the Bun release is at least a day old (gh release view bun-v<version> -R oven-sh/bun --json publishedAt) before changing the pin. That's the rule the Node patches and the node:24-slim digest already follow. Bun is bumped only by hand, since Dependabot leaves it unmanaged, so the check sits at the one place a new version can come in.
  2. Shared hook. The hook goes back to pnpm exec lint-staged, and lint-staged now runs bun fmt --ignore-unknown. Worktrees from before and after the switch write the same hook text, so each runs its own config and neither breaks the other. A staged misformatted file is formatted and restaged, a staged binary is skipped, and lint-staged keeps its stash handling for partly staged files.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Re-check of dd1fefb against the earlier review and the author's reply.

  1. Release-age fix: resolved — docs/DEVELOPMENT.md:67. The docs explicitly say minimumReleaseAge does not cover runtime downloads and require checking that a Bun release is at least a day old before changing the pin. The documented gh release view command works; Bun 1.4.4 was published on October 22. This is the manual safeguard the first finding allowed, not an install-time enforcement claim.

  2. Shared-hook fix: resolved — package.json:70, package.json:73. In a throwaway clone with origin/main and PR worktrees sharing hooks, I alternated pnpm install between them and made real commits from both after each install. All four combinations passed, and the generated hook stayed byte-identical. Each worktree used its own lint-staged configuration and formatter.

The staged-file checks passed with both the old Prettier command and bun fmt --ignore-unknown: unknown text and binary files were skipped; paths with spaces and renamed files were formatted and restaged; deleted files caused no failure; partly staged files committed only the formatted staged content and preserved unstaged edits. Parse errors restored the index and working content. Explicitly passed files respected .prettierignore, including pnpm-lock.yaml; forced-staged gitignored files were also left alone. The PR's generated-broker ignore rule worked too.

lint-staged remains at 17.6.0. The complete lockfile comparison only adds Bun and removes Prettier, with no unrelated package or snapshot changes. Installs left the lockfiles unchanged. The revised docs accurately describe the tested behavior.

No new findings and no unresolved findings from the first review. Its previously documented CSS/Markdown differences remain nonblocking. Only targeted checks were run; the real repository's hooks were left untouched.

Verdict: ship.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

pidgeon-suite and pidgeon-live failed on dd1fefb because of Pidgeon's new 10-minute rule on new messages to the same recipient (PidgeonRateLimited, source_rate_limited: "This address wrote to … in the last 10 minutes"). That's #1117, which is open and unrelated to this change. The tier ran only because the lockfile changed. Neither check is required; every required check passes.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance: PASS with notes

Checked dd1fefb4042a42b496dbe95c495a85a52914b6c1 (base 54438fa3303fe8867867f0a9b260536a033da0f6, fetched origin/main) on brightline, by gpt-6.1-sol in T3 Code through the Codex harness. I did not write this change.

Done means

  • Fresh install provides pinned Bun: passed. In an isolated checkout with no node_modules, pnpm install --frozen-lockfile using pnpm 12.9.1 and Node 26.12.1 completed, including broker generation. The checkout's node_modules/.bin/bun --version returned 1.4.4; Prettier was absent and the lockfile stayed unchanged.

  • Formatting commands and hook behave: passed. The clean tree passed pnpm format:check; pnpm format reported 0 formatted, 1,015 unchanged. A deliberately misformatted TS fixture made the check exit 1; formatting fixed it and the check returned 0. Invoking the installed pre-commit hook formatted and restaged the staged content of a partly staged TS file, preserved its unstaged edit, and skipped a binary. The generated broker module and ignored lockfile stayed byte-identical through formatting. All probes were removed and the checkout was clean.

  • The browser gets the same broker and digest: passed. Both commits were installed and built with their own generator and dependencies. Their exported browser scripts were byte-identical, 325,029 UTF-8 bytes, and each exported digest matched an independent SHA-256 calculation:

    base  bc02a08f53e0c7f90a3e308ddc195da07346cbdd33ae11d7e635302e80420093
    head  bc02a08f53e0c7f90a3e308ddc195da07346cbdd33ae11d7e635302e80420093
    

    The head's actual HTTP broker response decoded to those same bytes. Its own digest URL returned public, max-age=31536000, immutable; a foreign digest returned no-cache. Scripted pages retained sandbox="allow-scripts allow-modals".

  • Existing check entry points: passed. pnpm check still invokes format:check through scripts/verify.ts, and CI's lint job invokes it directly. The head's lint, Node 22/24/26 offline tests, browser, CLI smoke, tier 2 smoke, release tarball, image and dependency-review checks passed. No whole suite was run locally.

Golden journeys

These five can reach the generated broker; I exercised them on one fresh Brightline instance, using its own CLI state with PATCHY_API_URL and PATCHY_API_TOKEN unset:

  • Publish a page: passed. Allison published scripted HTML; Priya saw its executed script in the sandbox and found the page on Home. Retire replaced the content with its notice and no patch frame; restore reopened the same address. Brightline's admin/colleague roles cover the publishing journey otherwise described with Team's Ada/Ben.
  • Share and unshare: passed. Kickoff answered anonymous requests with 401 and private, no-store; sharing public changed this to 200 and public, max-age=60, without Set-Cookie; sharing company restored the 401 door.
  • Find and open a tool: passed. Jordan searched Home for Kudos and opened its rendered frame.
  • Use a tool live: passed. Jordan sent kudos and Priya's already-open page showed the exact message without any page or frame navigation.
  • Use a tier 2 tool: passed. New Business loaded its sample deals. Jordan moved Saltwater Hotels from Lead to Discovery and back; Allison's open board followed both changes without navigation. Spend refused Jordan approving his own newly submitted request with You can't approve your own request.

The final complete browser probe exited 0 with no uncaught browser errors. Only one instance ran; pnpm dev down stopped it and removed its data.

Rollback answers: They match the diff. The six changed files introduce no migration, persisted data shape, mail, infrastructure, wire contract or CLI flag/JSON change. Returning to the base installs Prettier successfully; both versions retain the same pnpm exec lint-staged hook, and the broker bytes/digest are identical. No one-way label is needed. CI's rollback-rehearsal passed its change gate; its deploy/rollback steps were correctly skipped.

Not run

  • Sign in, log a machine in, invite/join: these journeys do not use the patch broker, and this diff changes none of their auth, identity, membership or runtime CLI code. Persona sign-in was used to drive the selected journeys; it is not a live Clerk acceptance run.
  • Whole local suite, native macOS/Windows contributor Bun installs, and live integrations: outside this focused Linux run. The full suite was explicitly excluded from local execution.

Notes

  • Pidgeon live CI is red at this head: 17 passed, 2 failed. Both failures report upstream HTTP 429, source_rate_limited, with retry delays of 573/559 seconds and Pidgeon's ten-minute source restriction. The integration and its tests are unchanged by this PR; this is external service throttling, not a formatter or broker regression. No matching open flaky issue was found.
  • Attio live CI was still running when this verdict was prepared; it is not counted as passed.
  • An initial install attempt in /tmp hit that shared filesystem's inode limit. Moving this run's checkout to the home filesystem and repeating the fresh install with the pinned pnpm succeeded. No other worktree or running instance was changed.

allisonmahmood and others added 5 commits November 1, 2026 01:51
pnpm install now downloads Bun 1.4.4 with the lockfile's integrity hashes
and puts it on the PATH for scripts, so CI, worktrees and the image build
get the same Bun without a separate installer. Scripts still run on Node.

Co-authored-by: Claude Opus 5.5 <[email protected]>
`pnpm format`, `pnpm format:check` (and so `pnpm check` and CI's lint job)
and the pre-commit hook now run `bun fmt`, which reads prettier.config.js
and .prettierignore and formats the tree byte for byte as Prettier did, in
a fraction of the time. Prettier and lint-staged are gone.

The shell broker generator formatted its gitignored output with Prettier
only so the format check would pass; the formatter now skips that
directory and the generator writes plain text.

Co-authored-by: Claude Opus 5.5 <[email protected]>
npm refuses any devEngines.runtime that isn't Node, so the packed CLI tests'
npm pack from the repository root failed with EBADDEVENGINES. pnpm's runtime:
protocol as a devDependency pins the same Bun with the same lockfile entry,
and npm never reads it.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Every worktree of a clone shares one .git/hooks, and simple-git-hooks
rewrites it on each install. A hook of `bun fmt --staged` broke commits in
worktrees still on Prettier, and theirs broke ours. Keeping the hook text
`pnpm exec lint-staged` and pointing lint-staged at `bun fmt --ignore-unknown`
makes both work. Also document checking a Bun release's age by hand,
because pnpm's minimumReleaseAge doesn't cover runtime downloads.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood merged commit cc5074f into main Nov 1, 2026
23 checks passed
@allisonmahmood
allisonmahmood deleted the bun/fmt branch November 1, 2026 01:09
allisonmahmood added a commit that referenced this pull request Nov 1, 2026
… timing (#1122)

> **Stack:** based on #1120 (`bun/fmt`) so the Bun PRs land in one line:
#1120 → this → the runtime move (#1040) → #1121. The change is test-only
and doesn't depend on #1120.

## What changed

On Bun, `Supervisor.test.ts` › "refuses an older host's task-wide stop
that waited while a newer host bound the task" failed every time. The
test got its fiber ordering from I/O timing, and Bun's faster `rm` broke
it. The test now forks each fiber so it runs to its first suspension at
once (`Effect.forkChild({ startImmediately: true })`), which gives the
same order on every runtime. No production code changes.

The other failure reported as Bun-only, `RequestEvents.test.ts` › "emits
one event per route…", isn't Bun and isn't production. It fails on Node
too, and is left unchanged. Details below.

Part of #1040.

## Look at

**1. The supervisor test: a timing assumption, not a supervisor bug.**
The test kills the standby, then forks three fibers, with an
`Effect.yieldNow` between each:
- a slow bind, which holds admission while it discards the dead standby;
- a newer host's bind, at epoch 2;
- an older host's stop, at epoch 1.

It expects the bind and the stop to queue in that order. I logged
admission order on each runtime (ms since the kill):

| | Node 24.20 | Bun 1.4.4 |
|---|---|---|
| newer bind queues (`free=0`) | 30.4 | 18.3 |
| older stop arrives | **34.0, `free=0`: queues behind the bind** |
22.3, `free=1` |
| slow bind's discard finishes | 36.0 | **20.1, before the stop
arrives** |
| next into admission | newer bind (epoch 2), then the stop, refused
`stale_epoch` | **the stop**, which sets `stopped`; the newer bind is
then refused `stopped` |

The discard is a closed child plus an async `rm` of its temp directory.
Bun finishes the `rm` within the two event-loop turns the `yieldNow`s
give away. The slow bind then releases admission before the stop asks.
Effect's `Semaphore` wakes queued waiters from a scheduled task, and
gives a free permit to whoever asks first, so the stop takes it ahead of
the bind that is still waking.

With `startImmediately`, all three fibers are queued before the event
loop can finish the discard, on either runtime.

Production behaviour is the same on both runtimes. Concurrent bind and
stop requests are ordered by whichever takes admission first. A stop
that waited while a newer bind went first is refused by its second epoch
check (`supervisor.ts`, "Its authority again"). A stop that finds
admission free holds the current epoch at that moment, so stopping is a
valid outcome, just as if it had arrived a moment earlier. Bun changes
how often a test can land in that gap. It doesn't change what the
supervisor allows.

**2. RequestEvents: the second event is a probe from outside the test.**
In the failing Bun run (175 files at `--maxWorkers=4`), the extra event
was `{"route":"/","method":"GET","status":401}`, with no viewer. The
test never sends that request. The T3 Code desktop app on the dev
machine probes every newly listening local port with `GET /` (user agent
`node`, with `b3` and `traceparent` headers). I measured it on
standalone servers:
- it arrives about 0.75 s after `listen`, on both runtimes;
- for a server bound only to `127.0.0.1`, it arrived after 2.9 s.

The server block runs in about 0.4 s on Bun and 0.45 s on Node in
isolation, so it only catches the probe when the machine is loaded. When
it does, the probe's event lands in whichever request's window is open.
That's why the reported request was `GET /no-such-page`, and why mine
was `POST /api/publish`.

To check, I held that test for 1.5 s of real time:
- Bun failed in its one held run.
- Node failed in one of three held runs, the same way: the probe's 401
event ahead of the first request.
- The other two Node runs missed the probe, because its timing varies.
In isolation Bun passes 5/5, `GET /no-such-page` included, so a 404
emits one event on Bun. CI has no such client.

## How it was verified

- **Red before.** The original test, run alone on Bun, failed 5/5 with
`Supervisor bind failed: stopped`. It also failed in the wide Bun run.
- **Green after.** The changed test passed in all of these:
  - five whole-file runs of `Supervisor.test.ts` on each runtime;
- five runs of the test alone (`-t "refuses an older host"`) on each
runtime.
- **The load flake.** In the whole-file runs, "does not reap active
calls as idle…" timed out at 20 s on both runtimes: Bun 3/5, Node 4/5.
The shared machine was heavily loaded at the time. That's the known
flake under load, and this PR doesn't touch it.
- **Seam suites on Bun.** The full server-side set (175 files, 1,784
tests) ran on Bun, with only the two failures above. One by one:
- `packages/core/src/NodeCryptography.test.ts`, including the RFC
vectors and the fixtures sealed by the old code: pass.
  - `CredentialKeys.test.ts` and `AgentConnections.test.ts`: pass.
- `filesContract.ts`, through `packages/primitives/src/Files.test.ts`:
pass.
- `process.ts` spawn and reap: `Process.test.ts`, `Engine.test.ts`,
`Inspection.test.ts` and `Supervisor.test.ts` pass, apart from the load
flake above.
- `HandlerTls.test.ts`, `ClientDocumentNetwork.test.ts`, and the
`SourceClient` suites (`Source`, `Execution`, `Parity`): pass.
- Drain on signal in `apps/server/src/start.ts`: no test covers it.
`start.test.ts` only covers refused starts, which exit before listening.
Not checked.
- **Bun 1.4 TLS defaults against these seams' exact shapes.** I probed
both runtimes directly with a self-signed server and got identical
results:
- `ClientDocumentNetwork`'s pinned `lookup` is called with `{ all: true
}`, and falls back from `::1` to `127.0.0.1`.
- TLS over an existing socket with no `servername`, which `SourceClient`
uses for an IP host, sends no SNI.
- An untrusted certificate is refused with `DEPTH_ZERO_SELF_SIGNED_CERT`
before `checkServerIdentity` runs.

Both seams already set `servername` and `checkServerIdentity`
explicitly, so the new defaults don't reach them.
- **`pnpm check`.** Format, lint, typecheck and synth pass. Its offline
test step failed on the loaded shared machine, with vitest workers
SIGKILLed under memory pressure. I reran the 15 failed files plus the
killed file at `--maxWorkers=2`, and 13 tests still failed:
- twelve are `packages/patchy` CLI and dev-loop cases whose stub servers
recorded T3's stray `GET /`, for example `expected { method: 'GET', url:
'/' } to match { url: '/api/me' }`;
- one is the known `LocalTaskProvider` "routes independent providers…"
flake.

None of them touch this change. I didn't run `pnpm verify`, so CI is the
full gate.

## Release impact

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

This is a test-only change in `packages/execution`.

- **What does a revert leave behind?** Nothing. The test goes back to
depending on I/O timing.
- **Does the release before it still work with that?** Yes. Production
code is unchanged.

Built by Claude Opus 5.5 (xhigh effort) in T3 Code, via Claude Code.

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

The server, its company exec tasks and fleet promotion now run on Bun
1.4.4 in production, the version the root `package.json` pins. People
notice nothing: patch code still runs in workerd and the CLI stays on
Node. CI now tests what production runs: the offline suite on Bun, every
CI lane's server on Bun, and the built image itself.

Closes #1040

Stacked on #1122 (`bun/seams`), which sits on #1120 (`bun/fmt`). #1122
fixes the stale-stop Supervisor test that failed only on Bun. This PR's
`test (bun)` runs it, and every other server test, without skipping.

## Look at

**1. How Bun gets into the image.** The runner stage is
`oven/bun:1.4.4-slim`, pinned by digest. Its `bun` is byte-identical to
the binary `pnpm-lock.yaml` pins (sha256 `10702245…`), which is the one
CI's tests run on. `scripts/build-server-image.mjs` refuses a runner
whose tag names another version than `"bun": "runtime:<version>"`, or
whose binary isn't the lockfile's. Users stay as #1040 describes: the
image's `bun` user is uid 1000 for hosts, and exec tasks run as root and
drop each workerd to its own uid. Node 24 stays as the builder stage.

**2. Rolling back across the runtime change.** Three places hardcoded
`node`, and each would have broken a deploy or a rollback:

| Seam | Before | Now |
|---|---|---|
| The host's ECS provider overrode every exec task's command with `node
dist/exec.js` | A Bun host would start the previous release's Node
spares with Bun, or the reverse | No override: each release's task
definition names its own runtime |
| `deploy.yml` promoted with `node dist/fleet.js` | A Bun-only image
couldn't promote | Promotes with the `fleetCommand` the image build
recorded (present since #521), so a rollback to a Node release promotes
with `node` |
| Older hosts still send `node dist/exec.js` | — | In the Bun image,
`node` falls back to Bun (the base image's `bun-node-fallback-bin`), so
a rolled-back Node host still starts this release's spares |

A scratch run (not in the repo) of a mixed fleet on one TLS+SCRAM
database:
- host A on the **Node** image from `main`, host B on the **Bun** image,
sharing tasks;
- `bun dist/fleet.js promote` promoted B;
- the Node image's own `node dist/fleet.js promote` rolled back to A;
- both hosts exited on SIGTERM.

**3. The two images, built locally and booted the same way.** Each
image's rootfs ran under bwrap as uid 1000, with the server as PID 1,
against a local Postgres that takes only TLS (verify-full, scratch CA)
and SCRAM. The machine was shared and loaded, so treat the numbers as
relative.

| | Node image (`main`) | Bun image (this PR) |
|---|---|---|
| Compressed layers (what ECR stores and Fargate pulls) | 187.0 MB |
190.0 MB |
| Unpacked | 526 MB | 488 MB |
| Boot, process start to `/healthz` 200, median of 7 | 1,228 ms | 996 ms
|
| RSS once ready, idle, median | 208 MiB | 167 MiB |
| SIGTERM to exit, idle, median | 18 ms (exit 130) | 16 ms (exit 130) |

**4. Which runtime each commit's server runs on in the rollback
rehearsal.** The rehearsal harness stays on Node, as #1121 left it. Each
checkout's server runs on the runtime its own `apps/server/package.json`
`start` script names: the same file that says how that commit runs,
`node dist/start.js` before this PR and `bun dist/start.js` from it. So
this PR rehearses live (Node) → this PR (Bun) → live (Node) → this PR
(Bun); once a Bun release is live it is Bun throughout. Reading it from
each checkout, not from the harness, keeps a later rehearsal across this
PR honest in either direction.

## How it was verified

**CI, new or changed:**
- `test (bun)` runs `pnpm test:bun`: the offline suite under `bun --bun
vitest`. `vitest.bun.config.ts` names the 15 Node-only files and says
why: 13 CLI process and dev-loop tests,
`packages/sdk/src/install.test.ts` and `lint/rules.test.ts`. `test
(22)`, `test (24)` and `test (26)` are unchanged and still run every
file. Nothing else is skipped: #1122 fixed the one real Bun-only
failure, and the other (`RequestEvents`) was a local port probe that CI
doesn't have.
- `image` (server-image.yml) now loads the built image and runs
`scripts/server-image-smoke.mjs` with Docker:
- two hosts on two revisions boot from the default command, as uid 1000,
against a TLS-only, SCRAM-only Postgres; connecting by IP (not in the
certificate) and without TLS are refused;
- `bun dist/fleet.js promote` promotes the staged revision, then rolls
back;
  - both hosts and the exec task exit on SIGTERM, not SIGKILL;
- the exec supervisor runs as root with AppStack's dropped capabilities,
and its standby workerd runs as its own uid;
  - `node` in the image runs Bun 1.4.4.
- `browser` (tier 1 and 2 pages), `cli-smoke`, `tier2-smoke` and
`clerk-live` (live Clerk) now start their server on the pinned Bun; the
CLI stays on Node.
- `rollback-rehearsal` starts each build's server on the runtime its
`apps/server/package.json` start script names, so this PR rehearses live
(Node) → this PR (Bun) → live (Node) → this PR. It runs here because the
rehearsal script changed.
- `NodeCryptography.test.ts` gains a credential and an agent retry copy
sealed on Bun 1.4.4. Node's lanes open them, which is the rollback
direction; the Bun lane opens the Node-sealed fixtures already there.

**Locally:**
- `pnpm lint`, `pnpm typecheck`, infra tests, `EcsTaskProvider.test.ts`,
and the crypto fixtures on both runtimes.
- `pnpm test:packed-tier2-e2e` with the server on Bun: PASS (packed
init, both dev mounts, publish, two-viewer sync, keyed retry, sharing,
files, members, CSV).
- The `browser` lane with the server on Bun: 53 tests passed across
`tier1`, `stream`, `server-subscriptions` and `starting` (local fleet,
idle release, host restart, HTTP/2 ingress). One `tier1` test failed
only on a stray `GET /` to its foreign-origin harness port. That's T3
Code's local port probe, which CI doesn't have, and that server is the
harness's own, on Node.
- The image smoke, end to end, through a scratch stand-in for Docker
(bwrap and unshare; Docker isn't usable on the build machine), plus the
mixed Node/Bun fleet above.
- TLS and SCRAM through Effect's sql-pg, on both built images. Each
connects only with the scratch CA, and refuses an unknown CA ("unable to
verify the first certificate"), an IP the certificate doesn't name, a
wrong SCRAM password, and plaintext.
- The real `@aws-sdk/client-ecs` against a loopback endpoint on Bun:
SigV4-signed, and the response parsed, the same as on Node. The S3
client already runs on Bun in the content-store contract tests.
- Process identity and reap: the image's exec entrypoint as root in a
user namespace with a uid range. The supervisor stays root; workerd runs
as uid 60000 and is gone within ~200 ms of SIGTERM. Started as `node
dist/exec.js`, the process is `/usr/local/bin/bun`.

**Shown only in production:**
- Neon itself: the local Postgres stands in for its TLS and SCRAM.
- The task role's credentials through ECS's container credentials
endpoint, and the Clerk production instance.
- Fargate's CPUs: no AVX2 risk. Bun 1.4's x64 releases are
baseline-only, and the pinned `oven/bun:1.4.4-slim` image ships the
`x64-baseline` binary, byte-identical to pnpm's pin. That was checked in
review against Bun's v1.4.4 slim Dockerfile.
- Memory over several hours.
- Not done here, as #1040 scopes it: `BunHttpServer` stays a separate,
measured follow-up (`Bun.serve` closes silent connections after 10 s
unless streams set `idleTimeout: 0`). The server keeps
`@effect/platform-node` through node:http compat, as the 2026-10-28
trial ran it.

## Release impact

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

The runtime under the server changes; nothing anyone runs or calls does.
The CLI, the API and the schema are unchanged.

- **What does a revert leave behind?** No data in a new shape: no
migration, and rows are written by the same code on either runtime.
Credentials sealed on Bun open on Node (the new fixture runs on every
Node lane). In ECR, the Bun image stays tagged with its commit. Exec
task definitions from the Bun release stay registered (as every
release's do) and name `bun dist/exec.js`.
- **Does the release before it still work with that?** Yes. A rollback
runs the Node release's own task definitions and promotes with its own
`node dist/fleet.js`. While its hosts still replenish this release's
spares, they start them with `node dist/exec.js`, which the Bun image
runs on Bun. The rollback rehearsal and the mixed-fleet run above
exercise that path. Not `one-way`.

Built by Claude Opus 5.5 (xhigh effort) in T3 Code, via Claude Code.

---------

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

`pnpm dev` ran its runner, supervisor and dev server on Node with the
tsx loader. That was slow to start, and it doesn't match production once
the server moves to Bun. Now the runner, supervisor and dev server run
on the Bun that `package.json` pins. `pnpm check`/`verify`, the Clerk
live launcher, `seed:dev` and the Pidgeon sweep run on it too. The CLI
still runs on Node, as it does on people's machines.

Part of #1040. Stacked on #1123, #1122 and #1120, which have merged.
Merge it after #1123: its parity with production's server only holds
once production runs on Bun. #1123 also settles the rollback rehearsal:
each checkout's server runs on whatever that commit's own start script
names.

## Look at

**The split lives in one place, `scripts/dev/src/runtimes.ts`.** The
runner used `process.execPath` to start the server, the release builds,
the environment's `bin/node`, the pinned CLI for scenario publishes, and
the workspace's `mise.toml` pin. Under Bun, every one of those would
have quietly become Bun. Now:

- `bun` starts the supervisor and the server.
- `realNode()` serves everything else. It asks the first `node` on
`PATH` for its own binary and version, and refuses one that turns out to
be Bun.

The guest-share step that main added to `pnpm dev up` while this PR was
open is covered too. It runs the pinned CLI on the environment's
`bin/node`, like the refresh and publish steps beside it.

`runtimes.test.ts` covers both cases. Bun answering to the name `node`
shows why the version has to come from real Node:

```
$ ln -s node_modules/.bin/bun /tmp/x/node && PATH=/tmp/x:$PATH node -e '…'
{"execPath":"…/node_modules/.pnpm/bun@runtime+1.4.4/node_modules/bun/bun","version":"26.3.0","bun":"1.4.4"}
```

Under Bun, `process.versions.node` says `26.3.0`. The old code would
have pinned the agent workspace's `mise.toml` to a Node that isn't
installed.

**Which runtime runs what**, on this branch's `pnpm dev up brightline`:

```
supervisor  exe=node_modules/.pnpm/bun@runtime+1.4.4/node_modules/bun/bun  --conditions=development scripts/dev/src/main.ts supervise
server      exe=node_modules/.pnpm/bun@runtime+1.4.4/node_modules/bun/bun  --conditions=development apps/server/src/start.ts
```

`process.versions` from inside the environment's `bin/patchy` (a preload
via `NODE_OPTIONS`, during `patchy whoami --json`):

```
inside bin/patchy: {"execPath":"<mise>/node/24.20.0/bin/node","node":"24.20.0","bun":null}
```

The workspace's `mise.toml` pins `node = "24.20.0"`, and `bin/node`
links to that same binary.

**Startup, before and after**, as medians on this machine. It's a shared
box: the launcher and runner rows were measured interleaved under the
same load. The `pnpm dev` row ran under higher load after the change
(load average about 25, against about 7 for the baseline), which favours
the baseline.

| | Node + tsx | Bun |
|---|---|---|
| `pnpm check`'s launcher (`scripts/verify.ts`, to its usage line) |
127–131 ms | 15–16 ms |
| The runner alone (`pnpm dev --dry-run --json`) | 1.39–1.63 s |
0.61–0.75 s |
| `pnpm dev` to ready, existing state dir, release build cached |
16.9–17.7 s | 8.1–8.5 s |
| … of which, to the supervisor's first line | 9.0–10.1 s | 3.5–4.1 s |
| … of which, server start to `/healthz` | 6.5–7.0 s | 3.7–3.8 s |

**On #1123's `test (bun)` lane**, the dev runner's two tests
(`main.test.ts` and `runtimes.test.ts`) are in `vitest.bun.config.ts`'s
Node-only list. They need a real `node` first on PATH, as on a person's
machine, and the runner refuses a `node` that is Bun, which is the point
of `realNode()`. Under `bun --bun`, the `node` on PATH is Bun's shim.
The Node lanes run both tests with `pnpm dev` itself on Bun, so the Bun
runner is still covered.

## How it was verified

- On this machine, with this branch:
  - `pnpm dev`, `stop`, `status`, `logs` and `mcp-token`.
- `pnpm dev up team`, then `pnpm dev shot ada /`: 200, no browser
errors.
- `pnpm dev down`, then `pnpm dev up brightline` from a wiped state. Its
three repos were built, refreshed and published by the pinned CLI on
`bin/node`, and sample data loaded through Playwright, which now runs
in-process on Bun.
- `pnpm dev shot jordan /brightline/kudos`: the tier 2 patch rendered
its sample data for a member, with no browser errors and no server error
lines in `dev.log`.
  - `pnpm dev stop` left no supervisor, server or Postgres pid behind.
  - `pnpm dev down` at the end.
- `pnpm check` now launches from Bun; vitest itself still runs on Node.
Locally, format, lint, typecheck and synth pass. `pnpm exec vitest run
scripts/dev` passes: 15 files, 94 tests.
- `test` failed locally on this shared machine:
- CLI stub-server tests in `packages/patchy`,
`LocalTaskProvider.test.ts` and one PGlite timeout. The CLI and
LocalTaskProvider stubs received stray requests: local port probes,
which CI doesn't have.
  - A different set fails on each run: 17 tests, then 12.
- `origin/bun/fmt` without this commit fails the same way: 9 tests, the
same kind of failures.
- None of those files import anything this PR touches. CI is the gate
for the full suite.
- The moved scripts were each run on Bun offline:
  - `scripts/verify.ts` printed its usage.
  - `test:pidgeon:sweep` without a key: "nothing to sweep".
- `test:clerk` with bad arguments loads its imports and refuses the
arguments.
- Bun keeps `detached` children in their own process group and signals
the group, which the Clerk launcher relies on.
- **Not run:**
- `test:clerk` against Clerk and `test:pidgeon:sweep` with a key,
because both touch live accounts. CI's `clerk-live` and `pidgeon-live`
jobs exercise them.
  - `seed:dev` against an instance.
- `pnpm dev compare`, `film`, `transcript` and `trial`. They spawn the
same runner on evidence clones, and `transcript` and `trial` share the
environment code exercised above.

**Stays on Node:**
- `pnpm patchy`, the CLI from source.
- vitest's runner.
- `pnpm test:browser`.
- The release and broker builds the runner starts.
- `test:rollback-rehearsal`. It runs people's CLI and an SDK probe with
Node-only flags (`--input-type=module -e`) through `process.execPath`.
It also starts each commit's server the way that commit's production
would, so which runtime it uses belongs with `bun/runtime`.

`tsx` stays a devDependency for these and for `render-docs` and the
infra synth.

## Release impact

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

Dev tooling only: the dev runner, repo scripts and their docs. Nothing
in the CLI, the API, the schema or production changes.

- **What does a revert leave behind?** Nothing persistent. A dev
instance started on Bun keeps running until `pnpm dev stop`, which stops
it by pid whichever runtime started it. Environment folders and state
dirs keep the same shape.
- **Does the release before it still work with that?** Yes.

Built by Claude Opus 5.5 (xhigh effort) in T3 Code, via Claude Code.

---------

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

This adds release 34's What's new entry, written from `e5334ca`. It
covers everything merged since release 33's `through` (`d5a7862`), and
sets the `patchy` release to `0.34.0` in `packages/patchy/package.json`
and `CURRENT_RELEASE`.

| Change | PRs |
| --- | --- |
| Behind the scenes: Patchy's servers moved to a faster JavaScript
runtime, Bun, so each one uses less memory and handles more requests |
#1123 |

There's no announced change. Nobody using Patchy does anything
differently, and the speed and memory gains were measured on our own
machines, not yet in production. #1120 (the formatter), #1122 (a test)
and #1121 (the local dev loop) are tooling and test changes, so they get
no line. #1148 is release 33's own entry.

## Look at

- **The entry**, at the top of `releases` in
`packages/core/src/whatsNew.ts`.
- **Rollback safety, from the live commit `fb2264f` (release 33) to
`e5334ca`:**
- #1120, #1122 and #1121 change dev tooling, a test and docs. Nothing
that runs in production changes.
- #1123 moves the server image and its task commands from Node to Bun.
There's no migration, and rows are written by the same code on either
runtime. Credentials sealed on Bun open on Node: a fixture checks that
on every Node lane. A rollback runs release 33's own task definitions
and promotes with its own `node dist/fleet.js`. While release 33's hosts
still refill this release's spares, they start them with `node
dist/exec.js`, and the Bun image runs that on Bun. CI's
`rollback-rehearsal` passed against release 33 on #1123's merged head.
Not `one-way`.
- If a Bun host can't start, for example because it can't reach the
database, the server fails before it listens. ECS's circuit breaker then
rolls the service back before anything is promoted.

**Rollback line:** If this release misbehaves, roll back to `fb2264f`
(release 33).

## How it was verified

- **Tests.** `whatsNew.test.ts`, `WhatsNewPages.test.ts` and
`schemas.test.ts` pass (25 tests), and `bun fmt` passes on the changed
files.
- **The range.** Each PR had a GPT 6.1 Sol review with every finding
resolved, and acceptance gave PASS with notes. #1121 was re-accepted at
its rebased head. Each PR landed with all 12 required checks green, and
`test (bun)` and `image` green too.
- **Deploy state.** The live commit, pinned from `/healthz/deep`, is
`fb2264f` (release 33). 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. The `0.34.0` bump tells CLIs and patch
repos installed before this deploy to upgrade, as every release does.

- **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]>
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 size:s Under 100 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant