Skip to content

ci: a PR that changes a migration rehearses a rollback to the live release - #797

Merged
allisonmahmood merged 1 commit into
mainfrom
ci/790-rollback-rehearsal
Oct 19, 2026
Merged

allisonmahmood merged 1 commit into
mainfrom
ci/790-rollback-rehearsal

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

What changed

A migration that breaks the live release used to surface only when a rollback failed in production. Now a PR that changes a capability's src/migrations.ts gets a rollback-rehearsal check. CI deploys the PR onto data the live release seeded, rolls back to the live release, and fails naming the step that broke. Every other PR passes the check in seconds, so it can be required.

Closes #790

Look at

1. A deliberately incompatible migration fails it, on the right step. Throwaway draft PR #801 adds a migration that drops users.whats_new_seen, which the live release reads on every user lookup; its own code stops reading the column. It is closed now, and its branch deleted. Its CI rehearsal on this PR's final code:

Rehearsing 03891e4 → 5624f17 → 03891e4 on one set of data.

▶ Step 1: the live commit (03891e4) seeds the data
  passed in 91s

▶ Step 2: HEAD (5624f17) upgrades it
  passed in 36s

▶ Step 3: the live commit (03891e4) comes back

Step 3 of 3, the live commit (03891e4) comes back, failed while exercising.
  signing in as [email protected] answered 500
  the server's request /dev/sign-in failed
  server-3.log:
  …
  [postgres] … ERROR:  column "whats_new_seen" does not exist at character 160

This PR's own CI rehearsal runs the full path, because it changes the rehearsal itself:

Rehearsing 03891e4 → 0586221 → 03891e4 on one set of data.
▶ Step 1: the live commit (03891e4) seeds the data
  passed in 81s
▶ Step 2: HEAD (0586221) upgrades it
  passed in 32s
▶ Step 3: the live commit (03891e4) comes back
  passed in 34s
Exercised rollback paths passed: 03891e4 → 0586221 → 03891e4, in 148s.

The job takes about 4 minutes, setup included. 03891e4 is production's commit, which the check read itself.

2. The seam, scripts/rollback-rehearsal.ts. All three steps run on one scratch worktree.

  1. The live commit's own pnpm dev up brightline starts fresh, migrates, seeds the scenario and loads its sample data.
  2. git checkout of the PR, and that build's server starts on the same .local/dev data and migrates it. The data is the Postgres cluster (platform and company databases), the stored files and the credential keys.
  3. git checkout back to the live commit, and its server starts on that data again.

Steps 2 and 3 swap only the server build. They start it the way the dev runner's supervisor does, but seed nothing, so rows stay exactly as the migration left them.

Each step is exercised the same way:

  • Health. /healthz/deep answers.
  • CLI. The build's own CLI, from the release its server serves, runs whoami and list, and publishes a new version of a page.
  • Pages. In Chromium, as the scenario's admin: /, /patches, /company, every brightline patch and that page.
    • Each answers 200, with no 5xx and no uncaught exception.
    • Each patch's live queries are delivered: as many snapshots of each as the live release delivered in step 1, read from the server's wide events.
    • Sample-data patches never fall back to their empty state.
  • Server events. The server logs no failed request, call or live query.

3. Two choices.

  • The skip compares the PR's merge commit with its first parent, the PR's own changes, rather than with the live commit. Whether to skip then never depends on production, so a Deploy run in flight holds up only PRs that change a migration.
  • The live commit is /healthz/deep's revision, with any -overlap-N or -seal-N suffix stripped. The Deploy runs are judged by AGENTS.md › Deploying's rule: the live commit is uncertain if any run is unfinished, or if the run updated last didn't succeed. When it is uncertain, the check fails and says why. It never guesses.

How it was verified

  • CI: this PR's run above passes, and demo: throwaway incompatible migration for the rollback rehearsal (do not merge) #801's fails on step 3.
  • Locally:
    • the full path passed in 125s;
    • the same throwaway migration failed on step 3, with the same output as in CI;
    • SIGTERM during step 2 exits 143 and leaves no process, scratch directory, git worktree or dev environment behind.
  • Four GPT 6.1 Sol review rounds, summarised in PR comments, with every finding fixed. The first round's blocking finding, that restarts re-seeded rows and could hide a migration's damage, is what moved steps 2 and 3 to the seed-free server swap.
  • Not shown:
    • the quick skip on a PR without a migration, which every other PR shows once this merges;
    • the "uncertain" failures, since no Deploy run was in flight. Their rule is AGENTS.md's, read through the same gh run list query.
  • Docs:
    • DEVELOPMENT › Checks covers the job beside CI's others, and › Migrations says to run pnpm test:rollback-rehearsal.
    • OPERATIONS › Rolling back says what it covers and what it doesn't: Object Storage, the fleet, anything brightline doesn't reach, and new row shapes without a migration (PRs and deploys say whether a rollback is safe #788).
    • scenarios/README.md notes the rehearsal depends on brightline.

Release impact

Tick exactly one.

  • Breaking — requires action from anyone already running this

  • Not breaking — a CI job, a dev script and docs; no product code changes.

  • What does a revert leave behind? Nothing in production. Once rollback-rehearsal is a required check, though, a revert leaves the ruleset requiring a check that never reports, until it is taken out of the ruleset.

  • Does the release before it still work with that? Yes. No product code, schema or data changes.

For Allison after merge: add rollback-rehearsal to the ruleset's required checks.

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

@allisonmahmood
allisonmahmood force-pushed the ci/790-rollback-rehearsal branch from fdbb24e to 1c511a2 Compare October 19, 2026 13:24
@github-actions github-actions Bot added area:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area size:l 501-1,000 changed lines labels Oct 19, 2026
@allisonmahmood
allisonmahmood force-pushed the ci/790-rollback-rehearsal branch 3 times, most recently from 40ee2c1 to be94117 Compare October 19, 2026 13:51
@allisonmahmood

Copy link
Copy Markdown
Owner Author

GPT 6.1 Sol review, round 1 (on 40ee2c1)

  1. Blocking: restarts re-seeded the data. Steps 2 and 3 went through each build's pnpm dev, whose supervisor re-seeds companies, users and tokens. That can repair exactly what a migration broke; for example, the seed clears revoked_at. Fixed: only step 1 uses the dev runner (pnpm dev up, the live commit's own seeding). Steps 2 and 3 now swap only the server build. The harness starts each build's server on the retained .local/dev data (the Postgres cluster, storage and keys), the way the supervisor does, but seeds nothing.
  2. Should-fix: "runtime calls went quiet" didn't prove the data arrived. Fixed: a tier 1 or 2 page now settles only once the server has logged a delivered first live query (re-run, initial, delivered) for that patch's id. The ids come from patchy list. Every failed server wide event during the exercise still fails the step.
  3. Should-fix: process handling. Fixed:
    • Every child leads its own process group.
    • A timeout or the harness's own SIGINT/SIGTERM stops the group with SIGTERM, then SIGKILL after 10s.
    • Cleanup stops children before tearing anything down.
    • pnpm dev down only runs while step 1's instance is live, so stale pids are never signalled. Otherwise cleanup removes the environment folder itself.

Re-verified locally after the fixes:

  • full path, live → head → live, passed in 135s;
  • the incompatible-migration branch passed steps 1 and 2 and failed step 3 with column "whats_new_seen" does not exist.

A second round is running on the new diff.

@allisonmahmood
allisonmahmood force-pushed the ci/790-rollback-rehearsal branch 2 times, most recently from 11acceb to 9354b07 Compare October 19, 2026 14:04
@github-actions github-actions Bot added size:xl Over 1,000 changed lines; review in multiple passes and removed size:l 501-1,000 changed lines labels Oct 19, 2026
@allisonmahmood
allisonmahmood force-pushed the ci/790-rollback-rehearsal branch from 9354b07 to e1efd20 Compare October 19, 2026 14:13
@allisonmahmood

Copy link
Copy Markdown
Owner Author

GPT 6.1 Sol review, rounds 2 and 3. Neither round found anything blocking. Each raised three should-fix findings, and all were fixed:

Round 2 (on be94117)

  1. Any one delivered live query let a page pass. Kudos runs several subscriptions, so another one could hang or be refused unnoticed. Fixed in round 2 with a per-handler set; round 3 tightened it (below).
  2. Process-group escalation stopped when only the leader exited. Fixed:
    • stopGroup polls kill(-pid, 0) for the group itself: SIGTERM, then SIGKILL until it's empty, bounded.
    • run() stops a command's leftovers when its leader exits, so close always fires.
  3. Cleanup couldn't reach Postgres during startup. Fixed: a finalizer stack.
    • serve() reads its inputs first.
    • It registers Postgres's stop before starting it, and the server's group right after spawning it. Postgres gets 15s to stop, then the scratch cluster's postmaster is killed.
    • A step's stop and cleanup both drain the stack.

Round 3 (on 9354b07)

  1. Subscriptions with the same handler still collapsed. For example, Kudos has three tables.list. Events name no subscription, so step 1 now records how many snapshots each handler delivered on each patch page. Steps 2 and 3 must deliver at least as many, for example "the server delivered 2 of the 3 tables.list snapshots step 1 saw".
  2. A delivery after a discarded first read (retry, replace, rebind) would have failed falsely. Fixed: deliveries count whatever re-ran them.
  3. Cancellation could start things after cleanup had begun. Fixed:
    • SIGINT/SIGTERM now only latches and stops running groups.
    • Nothing new starts outside cleanup once latched.
    • The current step unwinds into the one cleanup path, and the harness exits 128+signal.

Also found by CI between rounds: step 2's readiness probe could hang for undici's 300s. The server's socket listens before its routes exist, so an early probe is accepted and never answered. Each probe is now bounded at 2s on its own connection, as the dev runner's own health check is.

@allisonmahmood
allisonmahmood force-pushed the ci/790-rollback-rehearsal branch from e1efd20 to 781f021 Compare October 19, 2026 14:17
@allisonmahmood

Copy link
Copy Markdown
Owner Author

GPT 6.1 Sol review, round 4 (on e1efd20, confirming the round-3 fixes): no blocking findings. Three should-fix edges of cancellation, all fixed in 781f021:

  1. Playwright's SIGINT handler would close the browser and exit before the rehearsal cleaned up. Fixed: Chromium launches with handleSIGINT, handleSIGTERM and handleSIGHUP off, so the harness owns shutdown.
  2. A stalled postgres.start() couldn't be interrupted. Fixed: start is bounded at a minute and abandoned on a signal. The Postgres finalizer, registered before start, stops whatever it started.
  3. A signal during a cleanup that succeeded could still exit 0. Fixed: the top level exits 128+signal whenever a signal arrived, however the run ended.

Also checked by hand: SIGTERM during step 2 exits 143, leaving no process, scratch directory, git worktree or environment folder behind.

@allisonmahmood
allisonmahmood merged commit 303d37a into main Oct 19, 2026
14 checks passed
@allisonmahmood
allisonmahmood deleted the ci/790-rollback-rehearsal branch October 19, 2026 14:29
allisonmahmood added a commit that referenced this pull request Oct 19, 2026
…connection (#814)

Release 15's What's new entry, written from `9e4b0df`. It covers
everything merged since release 14's `through` (`7694bab`), and sets the
`patchy` release to `0.15.0` (`packages/patchy/package.json` and
`CURRENT_RELEASE`).

| Change | PRs |
| --- | --- |
| New: Your agent can read a tool's log | #786 |
| Fixed: Tools with server code keep one steady connection | #798 |
| Behind the scenes: an unused open tool lets its server rest | #802 |

#783 is release 14's own entry, so it's left out. #795, #796, #797,
#799, #803, #804, #806 and #807 are agent docs, CI and dev tooling, with
no line.

None of the PRs in the range are `one-way`; #786 and #798 predate the
rollback questions, and their diffs leave nothing an older release can't
run with (a new read-only route and CLI command, and the load balancer's
stickiness setting, which the older commit restores).

If this release misbehaves, roll back to `03891e4` (release 14).

Made by Claude Opus 5.5 via Claude 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:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI rehearses a rollback when a PR adds a migration

1 participant