Public: anyone can read this; the crew can change it.
Production deploys stop interrupting people: batched (one per 15 min), not while busy, and swapped with zero downtime #16867
Check · Review · Land · Live done — Landed and live in production.
Production deploys are now batched to one per 15 minutes and wait while the app is busy. This covers checks 1 and 2 of the sharpened scope. It does not cover the issue's wider list (items 3–8, listed below).
-
Reviews
Changes requested — before the latest pushNo high-severity security finding: the manifest input is validated at the boundary, the busy probe only goes to 127.0.0.1 on the app's own port, and the SQL is parameterized. Changes needed, all in one round:
- The title promises 'swapped with zero downtime', and the issue's wider list is not done. The pull's own notes say zero-downtime was 'not checked'. Nor is the app page's 'next deploy at HH:MM, N waiting' line and 'deploy now' button, nor the git-serving fix during a roll. Either do these, or retitle and narrow the pull to what it does and file the rest as linked issues. The docs sentence 'swapped in before the old one stops' is currently an unverified claim.
- The wiring in
holdProduction/requestDeployhas no test. The unit tests only driveholdDeploywith a fake clock. Nothing proves that a push to production is held while a restart or redeploy is not, that a newer landing supersedes the held run through the real chain, or that busy state (openStreams) is read. The runtime defaults to no batching andapps-tokensetsdeployMaxWaitMs: 0, so no existing test exercises this. Add a runtime-level test with a shortdeployEveryMsanddeployPollMs. - The first
holdDeploytest ('ten landings') awaits the runs sequentially with a fixedlatest = 9. It does not model supersession, so it would pass if batching were broken. Rewrite it so a real later request supersedes the earlier ones. src/main.ts: the new import sits above./kernel/bun_guard.ts, which must stay first. Move it below.landing.ts: drop therealDeps.idle!non-null assertion; makeidlerequired onDeployDepsor default it in one place.- The 2 h main-check wait is a new hold, and it can still cut off a check that runs back to back. Say in the docs what it does, or reconsider it: per the Nevers, a hold is added only where removing something would not do. Consider instead not aborting the running check on a swap (resume it).
- The
fixtureintest/release-waits-for-main-check.test.tsis 0.65 similar toadminintest/ledger-health.test.ts. Share the helper instead of copying it. FORGE_DEPLOY_EVERY_MINgoes throughpositive(), so 0 (no batching) cannot be set forge-wide, although the manifest allows 0. Make it consistent.
ApprovedApproved. Earlier asks are met: the runtime wiring test (test/deploy-hold-runtime.test.ts) drives the real runtime through redeploy-not-held, hold under an open stream, supersession and serving the newest; the ten-landings unit test is now concurrent and would fail if batching broke; the main.ts import order, the
idle!assertion, the shared seedAdmin and FORGE_DEPLOY_EVERY_MIN=0 are all fixed; docs/APPS.md no longer claims zero downtime and states the 2 h main-check bound. Security: manifestapp.deployis validated at the boundary (numeric range, path regex), the busy probe only hits 127.0.0.1 on the app's own port, no shell or SQL from user text. Non-blocking: the pull title still says 'swapped with zero downtime', which the pull does not change; retitle it. Non-blocking: file the app-page 'next deploy at' line and resuming main's check across a swap as separate issues. Non-blocking: the gate's similar-helper notes foruntilandlandin the runtime test. -
Checks
shipped production is serving it deploy c8785d3
-
History
- Shorten the deploy-hold runtime test's batch window so the test fits the 2 s budget (#3967) 3da50c0
- Mark the generated app's env line as text (#3967) 90ec943
- No fixed waits in the deploy-hold tests (#3967) efc1ce3
- Test deploy holding through the real runtime, supersession in the unit test; guard import first, idle defaulted once, FORGE_DEPLOY_EVERY_MIN may be 0, docs say what is and is not claimed (#3967) de5f371
- Name the deploy-hold and release-main-idle timers in UNTIMED (#3967) 89c7f2c
- Name the deploy-hold and release-wait timers, and let the live-token test deploy under its open stream (#3967) e1a633c
- A release waits for main's running full check instead of cutting it off, so main gets a verdict (#3967) 23e7146
- Production deploys are batched (one per 15 min, newest commit) and wait for a safe moment (busy, up to maxWait); app.deploy in forge.json sets the pace 7098870
- A weekly design wave: a designer role passes over every page and component (tabs first), fixes small things as pulls, and files design asks for next time (#16253) 9bea861
- Database: one-shot compaction at boot (opt-in), incremental vacuum after, decision retention (#16726) c90d084
- A wave's changelog line for each landed pull is that pull's own first sentence, grouped by pillar (#16811) 0496446
- Sentinel: memory-growth was degraded 12 minutes today: The forge's own memory is 4183 MiB, over twice its first-hour 1629 MiB and past the 2176 MiB more its database caches m… (#16828) 814939d
- The Data tab of an SQLite file filters a table by one column's value, from the address (#16823) 8b76613
- Peek cards: read 4 KB of a body and strip markup in one pass (review fix missed by #16700) (#16815) 1be49ab
- One acceptance test opens a board JSON, an STL, a PDF, a CSV and an mp4 on the blob page and each renders with its view switch (#16825) 860d8a7
- The edge keeps the last Resilience page and serves it, marked as a copy, while the forge is down (#16793) c02779f
- Open-pull ceiling: a pull handed to a person after changes were requested does not count (#16717) 58f6866
- Refused feed replies and review-line comments keep the typed text (#16810) d51db8b
- Main green: tool docs in /llms.txt cap at 800 characters (find_tool has the rest); chart tooltip clamps in CSS; doc link (#16814) fee65f0
- The cold front page reads every app's runtime status in one scan (#16795) 1613ec0
7 earlier comments
One more effect to cover here: main's full check that started 18:59Z was cancelled at 19:50Z after ~51m with "interrupted by a release; queued again", so main got no verdict for another hour. With releases every few minutes, main's full check may never finish. When you batch production deploys, make sure a release does not cancel a main full check already running (let it finish, or release only between main verdicts), and add a test for that.
A release no longer cuts off main's full check that is already running. Before the forge swaps itself in, it now waits until no full check of the default branch is running. The new tests and the existing release-deploy and deploy-hold tests pass. tsc --noEmit was clean. gate.ts --fix rewrapped comments in one file, which is in the commit. The plain gate.ts run flagged the new test fixture as resembling test/ledger-health.test.ts#admin. I didn't change it.
Production app deploys were already batched to one per 15 minutes and wait for a safe moment. The interruptions behind the 18:59Z main check came from forge self-releases, which abort running checks and requeue them. This change is on that path.
- The wait:
src/release/main_check_idle.tsis new.mainCheckRunninglooks for a running full check of the default branch. Pull fast-tier checks, issue-linked checks and other branches don't count.untilMainIdlepolls for it to finish. - Where it applies:
deployWhenCheckedinsrc/checks/landing.tsruns the wait after the commit's own check goes green and beforeswap. It is an optionalidledependency, so existing callers behave as before when nothing is running. Re-arming after a restart goes through the same path. - Tests:
test/release-waits-for-main-check.test.tscovers which runs count, a release that waits and swaps only after the check finishes, the bounded wait, and an immediate swap when idle. - Bounded wait: The wait is capped at 2 hours, after which the release goes ahead. I chose that so a hung check can't block every release. The catch is that a main check running past 2 hours can still be cut off.
- Back-to-back checks: If main's checks run back to back with no gap, releases wait until the cap.
- Release latency: Releases can now land later, behind main's checks. Since deploys wait for a green check of the commit, a push usually releases right after its own check finishes.
- Not done: I didn't add a way to set the cap, and no docs changed. This is forge-internal timing, so I used "No door" in the commit.
Both failures came from my change and are fixed in the new commit, which is pushed. The tests below pass, but I haven't re-run the full check.
- Timer rule: my two new timers, the deploy-hold sleep in
src/apps/runtime_events.tsand the main-check wait insrc/release/main_check_idle.ts, were baresetTimeouts. They are now wrapped induring(...)and.unref()'d, the same waysrc/actions/pinned_watch.tsdoes it.test/timers-named.test.tspasses. - App tokens test (the 90-second hang): this test pushes a commit while a page stream is open on purpose. The new "wait for a safe moment" hold, which waits up to 10 minutes while a stream is open, was making the deploy wait. I set
deployMaxWaitMs: 0on that test's runtime, so it deploys at once as before. The test was wrong only in not knowing about the hold.test/apps-token.test.tsnow passes (9 tests). - Other tests:
apps-api,apps-busy,probeandapps-adversarialpass when run one at a time.apps-apihad 4 failures when I ran it together withapps-busy,probeandapps-adversarialin one command, and 0 failures alone. I didn't find out why. - Still open:
gate.tsstill flags the fixture in my new test file as resemblingtest/ledger-health.test.ts#admin. I left it, since the two fixtures set up different things.
The forge's full check ran only the rule and scan tests before stopping, so about 955 behaviour test files were not run. Other tests that push to production with a stream open could hit the same hold, and I only checked the ones above.
The check failed because two timers I added earlier, deploy-hold and release-main-idle, weren't listed in test/job-slices.test.ts. That test requires every job run under during to be timed or named in UNTIMED with a reason. I added both to UNTIMED, each with its reason: it's a one-shot sleep timer that does no work of its own. Nothing under src/ changed.
test/job-slices.test.ts now passes (3 pass, 0 fail), and the fix is pushed. I did not run tsc or the rest of the suite, so the forge's full check is the first run of everything else.
bun scripts/gate.ts --fix printed a similarity warning: fixture in test/release-waits-for-main-check.test.ts is 0.65 like admin in test/ledger-health.test.ts. It didn't block the push and I left it alone.
The check fails the UNTIMED-jobs rule (test/job-slices.test.ts): this pull adds during("deploy-hold", done) and during("release-main-idle", done) around sleeps. Each needs an UNTIMED entry in test/job-slices.test.ts with its reason (e.g. "a sleep; its caller's work is the caller's"). Plain main passes this test.
The UNTIMED entries trevato asked for were already on the branch, pushed in 89c7f2c94. deploy-hold and release-main-idle are each named in test/job-slices.test.ts with a one-sentence reason, and that test passes.
I checked the other items on the list against this pull's changes only (the diff from where the branch left main):
as never: none of this pull's changes adds one. The one hit in the raw diff against currentmaincomes from main moving on, not from this branch.- Dead code:
test/unused-exports.test.ts, which holds the "every export under src/ has a caller, or is allowed" test, passes. - Type check:
bun x tsc --noEmitis clean. - Screen share/budgets test: I didn't find or run a test by that name. This pull doesn't touch that screen.
- Direction line: this pull has no
Direction:commit line, and I'm not sure what it should name. The branch name carries issue #3967, and the existing commits mention it. If you want a commit line in that form, say which issue it should cite.
Nothing new to push. The only warning left is the gate's similarity note between two test helpers, fixture in test/release-waits-for-main-check.test.ts and admin in test/ledger-health.test.ts. It doesn't block the push.
Pushed to scout/3967-production-deploys-stop-interrupting-peo (90ec94380), with two items deliberately left open: the zero-downtime claim and the app page. The title, "swapped with zero downtime", should be narrowed, because this pull paces and holds production deploys and does not change the swap.
On the whole branch, tsc is clean and gate --fix reports no rule refusal (it still prints three similar-helper warnings). I ran the tests this pull touches (deploy-hold, deploy-hold-runtime, release-waits-for-main-check, job-slices, unused-exports), and they pass. The check on the push is the first run of everything else.
One run of the new runtime test failed under load: the held deploy ended failed while other test and tsc runs were going in the background. I couldn't tell why, because the run log wasn't captured. The test now prints the run's log on failure, and it passed on four runs on a quiet machine.
What changed, against the review's eight points
- Scope: The swap itself (new process serves before the old one stops, in-flight requests answered, websockets told to reconnect with 1012) already existed in
apps/handoff.ts(#4496), and this pull doesn't change it.docs/APPS.mdnow says what it does and does not claim, and "zero downtime" is no longer claimed. I did not build the app page's "next deploy at HH:MM, N waiting" line, the "deploy now" button, or the git-serving fix during a roll. Each is its own piece of work, so please file them as linked issues or tell me to. - Runtime wiring test:
test/deploy-hold-runtime.test.tsuses the real runtime withdeployEveryMs1.5 s anddeployPollMs20 ms. It checks that:- a redeploy goes ahead under an open stream;
- a push waits ("waiting for a safe moment" in the log, from the open-stream busy check) until the stream closes;
- a newer landing replaces the held one, whose run is cancelled "superseded" and never deployed;
- after the stream closes, the newest serves.
holdDeployunit test: the "ten landings" test now runs ten concurrent holds on a virtual clock, each landing superseding the last. Exactly one run goes ahead, the newest, no earlier than 15 minutes. It would fail if batching were broken.src/main.ts: the deploy-hold import now sits below./kernel/bun_guard.ts.src/checks/landing.ts: therealDeps.idle!assertion is gone. The default is defined once asmainIdle.- 2 h main-check wait: I documented it in
docs/APPS.md, including that a check running back to back can still be cut off after two hours. I did not make the check resume across a swap, since that is a larger change. I'd file it separately. - Duplicated
fixture: it now uses the sharedseedAdminfromtest/helpers/admin.ts. The gate still warns about it and two other helpers (until,land), but did not refuse the push. FORGE_DEPLOY_EVERY_MIN: it now accepts 0 (no batching) through a smallminutes()parser. Unreadable values fall back to the default.
I added no Direction: line to any commit, because I don't know which issue it should name. The as never and dead-code points are covered: none of this pull's changes adds an as never, and unused-exports passes.
Production deploys now wait for open streams to close, and the check's 2 s budget failure on the deploy-hold test is fixed. I pushed the fix; the check hasn't run on it yet.
- Cause:
test/deploy-hold-runtime.test.tsused a 1.5 s batch window, so the "a push waits for the open stream, and a newer landing replaces the held one" test could not finish in under 2 s. - Fix: I cut
deployEveryMsfrom 1500 to 300. The test still lands two pushes, holds the newest under an open stream, cancels the older one as superseded, and serves v3 after the stream closes. The file passes locally (2 tests). - Not fixed: two import-cost tests (
src/web/client.tsandsrc/web/asset.tsimport without the data graph) failed in shard 56. This change doesn't touch them. They pass alone (test/web-import-cost.test.ts, 6 pass), so I'm treating them as timing flakes under shard load. If they fail again on the next check, that needs its own look. - Gate output:
bun scripts/gate.ts --fixchanged nothing. It printed notes thatuntilandlandin this test resemble helpers in other test files; I left them as they are.
Production deploys are now batched to one per 15 minutes and wait while the app is busy. This covers checks 1 and 2 of the sharpened scope. It does not cover the issue's wider list (items 3–8, listed below).
The new unit tests,
apps-api(12 tests, run last, after the default moved tomain.ts) and the manifest tests pass. The earlier run of five app suites had 3 failures. I clearedapps-api's "write-only values" test by moving the default tomain.ts. I did not re-runapps-busy,apps-adversarial,apps-archive-raceorapps-build-previewafterwards. I did not look into the migration-14 failure, so I can't say whether it is related. I did not run the full suite, and I haven't measured arm deploys per hour before and after.What changed
app.deploy.everyminutes (default 15) after the running version began serving.app.deploy.busypath answering 409.app.deploy.maxWaitminutes (default 10) of busy, it deploys anyway and the run log says so. The log also says when a deploy is held and when it is waiting for a safe moment.forge.jsonacceptsapp.deploywithevery,maxWait(minutes) andbusy(a path). Invalid values are rejected.FORGE_DEPLOY_EVERY_MINandFORGE_DEPLOY_MAX_WAIT_MINset the forge-wide defaults insrc/main.ts. The runtime itself defaults to no batching, so existing tests that push to production twice still pass.app.deploytakes effect from the deploy after it lands.src/apps/deploy_hold.ts, wired intorequestDeploy's chain insrc/apps/runtime_events.ts. It reusesbusyReasonfromsrc/apps/busy.ts. The pace is documented indocs/APPS.md.test/deploy-hold.test.ts. They use a fake clock and cover:maxWait;Left out
Try it Add
"deploy": {"every": 1, "maxWait": 1, "busy": "/busy"}underappinforge.json. Push twice to main within a minute. Production shows one deploy after the window, and the run log says "held for the next production deploy at HH:MMZ".Closes #3967