Skip to content

Commit 2c436bf

Browse files
Brooooooklynclaude
andauthored
feat(api): routing-after-tx go-live + guarded routing publishers (#181)
* feat(api): routing-after-tx go-live + guarded routing publishers Rewrite deploy/rollback routing consistency, split out of the Deploy-on-GitHub branch (PR #179): - routing KV is written only AFTER the go-live DB commit; a failed in-tx check publishes zero routing (no rollback class) - durable `routing_published` marker on deployments (migration 0026) + hourly live-routing reconciler heals degraded publishes - all routing publishers serialize on the project FOR UPDATE lock and re-check active-ness before writing (deploy, rollback, domains, suspension, retention, cron sync, queue-token backfill) - domain activation claims its row conditionally; deletion runs under the project lock; stale queue routes are swept uniformly - rollback derives serving type from the target deployment's manifest, not the project's current type Migration note: 0026_cuddly_lilith keeps its original journal identity (when=1780982697858) so environments that already applied it (staging) skip it and fresh environments apply it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(api): exempt explicitly-unpublished rows from the reconciler recency window Review finding (P1): rollback to a target older than 24h clears routing_published without touching deployed_at, so a failed post-commit publish left the active deployment permanently invisible to the hourly reconciler — dispatch would serve stale/missing KV forever. The recency window now bounds only legacy NULL-marker rows (the one-time backfill mass). Rows explicitly marked false (sole writer: markRoutingUnpublished in the rollback go-live tx) are always eligible — the set is bounded by the active-pointer join and self-clears on heal. deployed_at stays untouched: it is ever-went-live history used by retention/admin. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(api): treat a deleting/missing project as superseded in the routing publish chokepoint A parked deploy/rollback publisher — or the hourly reconciler — resuming during teardown (after teardownProject set status='deleting' and deleted the routing KV entries, but before deleteProjectCascade removed the row) re-passed the pointer-only active check in publishRoutingIfStillActive and re-created the slug/domain:*/queue:* routes, leaving permanent orphan routes the reconciler could never heal once the row was gone. publishRoutingIfStillActive now re-reads projects.status under the project lock (new lockProjectForPublish sibling, leaving the shared lockProjectAndGetActiveDeploymentId untouched) and returns 'superseded' when the row is missing or status='deleting'. getRecentlyLiveActiveDeployments also excludes deleting projects so the reconciler never selects them. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(api): lock routing-suspension fan-out + handle rollback publish rejection setProjectsRoutingSuspension did a lock-free per-key get→modify→put. A suspender's pre-publish snapshot could overwrite a concurrent publisher's fresh route after it set routing_published=true, leaving permanently stale routing the reconciler skips (it heals only unpublished rows). Wrap the slug + domain fan-out in one project FOR UPDATE lock tx — the same lock publishers hold — so `suspended` is folded onto the re-read fresh route. Closes the cursor "Unguarded suspension clobbers routing" finding and the codex "Wire suspension updates through the guarded RMW" finding (same race). The rollback handler's post-commit publishRoutingIfStillActive await sat outside any catch: a transient Hyperdrive/lock error after the go-live commit returned 500 for an already-committed rollback, prompting users to retry a completed operation. Treat a thrown helper the same as a 'failed' publish so the row stays routing-unpublished and the hourly reconciler heals it; the endpoint returns success/degraded. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(api): refuse domain activation while project is deleting tryActivateDomain took the project FOR UPDATE lock but never re-read status, so a pending-domain verification interleaving with teardownProject could re-PUT domain:<host> for a project about to be cascade-deleted, leaving an orphan route the reconciler can't heal (teardown deletes slug/domain KV lock-free, then cascade-deletes rows last). Swap lockProjectAndGetActiveDeploymentId -> lockProjectForPublish and bail (write nothing, claim nothing) on a missing/deleting project, mirroring publishRoutingIfStillActive's same-lock guard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0bdedb9 commit 2c436bf

28 files changed

Lines changed: 9052 additions & 856 deletions

‎.github/workflows/ci.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ jobs:
130130
- run: vp run build
131131
working-directory: framework
132132
- run: vp install --frozen-lockfile
133+
# Phase 1 ran the PR branch's vite-plus, which may have written a task
134+
# cache the prod branch's older vite-plus cannot read ("Unrecognized
135+
# database version"). The checkout above keeps untracked state, so drop
136+
# the cache before building with the prod toolchain.
137+
- run: vp cache clean
133138
- run: mkdir -p packages/dashboard/.void && echo '{"files":[]}' > packages/dashboard/.void/tsconfig.json
134139
- run: vp run build
135140
- run: vp run test

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ TODOs.md
1313
.codex
1414
.worktrees
1515
.playwright-mcp
16+
.firecrawl
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE "deployments" ADD COLUMN "routing_published" boolean;

0 commit comments

Comments
 (0)