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 #3974
Production deploys from landings stop interrupting people (#3967) in three ways: they are batched to at most one per window, they wait while production is busy, and the old deployment is drained before it is stopped, so a swap drops no request. Batching (from the first round). The window is 15 minutes by default.
stopped parked by the crew deploy 1abcf40
3 earlier comments · 1 event
Parked by the crew: the check failed in the place it ran, not in the change, and failed the same way when it was run again
Batching is well built: pure window math in apps/batch.ts, a validated app.deploy.every, the timer cleared on stop/remove, and tests that exercise ten landings and Deploy now. But the pull's title promises three things and the diff ships one.
Fix first: the title says "not while busy, and swapped with zero downtime", and neither is in the diff. sendBatch (runtime.ts) calls requestDeploy without checking busyReason, so a batch still fires while someone is streaming or driving the app, which is the interruption the issue is about. Nothing here changes how the new deployment replaces the old one, so a restart still drops connections. Either implement both with tests that fail without them, or retitle the pull and keep #3967 open for the rest. Do not close it as done.
Also:
- The held-landings state is only on the web page (envFacts). The terminal door, and the JSON/MCP status that carries EnvStatus, should say the same thing. Please confirm the new
batchedfield reaches them, and add a test. - lastDeployAt and the batch live only in memory. After a forge restart the window is forgotten, so a crash loop restarts production every boot. That is acceptable for now, but say so in docs/APPS.md.
- The data-batched paragraph uses muted small. Check it against docs/DESIGN.md, and prefer the named status component if there is one.
- The Deploy now button is the existing Redeploy POST form, which is fine. Its label changes with state, so the test should also cover that the form still posts for a non-batched env.
Production deploys from landings stop interrupting people (#3967) in three ways: they are batched to at most one per window, they wait while production is busy, and the old deployment is drained before it is stopped, so a swap drops no request.
Batching (from the first round). The window is 15 minutes by default. FORGE_DEPLOY_EVERY_MIN sets it for the forge, and an app sets its own with app.deploy.every (whole minutes, 0–1440). A landing inside the window waits for its end and goes out in one deploy of the branch's tip at that moment. Deploy now sends what is waiting at once. Previews are not batched.
Not while busy. sendBatch now checks busyReason before deploying. The first landing after a quiet window, which used to deploy at once, checks it too. Production counts as busy when a stream or websocket is open to it, a request is still unanswered, or one of its child processes is still working. While busy, the deploy is retried every minute (busyRetryMs). It goes once production is idle, or when the existing busy grace (45 min) runs out even if it never is. The retry timing is pure and lives in apps/batch.ts as busyRetryAt. Deploy now does not wait.
Swap without dropping requests. New requests already went to the new deployment once it answered, but the old one was stopped straight away, cutting off whatever it was still answering. holdRequest now counts in-flight requests per deployment. At the swap, the old deployment is stopped only after those requests are answered, or after drainMs (10 s by default). Open streams and websockets to the old deployment are still closed at the swap; clients that reconnect reach the new one. Handing an open websocket from one process to another would need a different proxy design, so I left it out.
Every place shows the same state. The batched field (at, changes, and busy while held) is in the JSON API through envsFor. The MCP apps tool returns it as nextDeploy, and the terminal's Deploys screen shows it as a line via the new appHeld. The sentence is batchedPhrase, now in apps/batch.ts so the terminal doesn't import web code. On the web page the line now starts with the attention status dot (dot("attn") from docs/DESIGN.md), which means pending. It keeps the same muted small text as the busy and asleep lines next to it.
Docs. docs/APPS.md and the README now cover the busy hold and the drain. They also state that the window and the waiting landings live only in memory: a forge restart forgets them, deploys production on boot, and a forge in a crash loop restarts production on every boot.
Tests (test/apps-batch.test.ts):
- Pure tests for
busyRetryAtand the busy wording. - A batch held past its window while a stream is open, which deploys after the stream is released.
- The first landing after a quiet window, held while busy.
- The busy grace sending the deploy anyway.
- A swap that keeps the old deployment answering until its in-flight request is released.
- The API, MCP and terminal all reporting
batched. - With nothing held, the button reads Redeploy, its form still posts to
/app/production/redeploy, and it still deploys.
With the busy check and the drain switched off, all four new behaviour tests fail. The type check passes, as do the batch suite and the busy, Deploys-screen, MCP, design and proxy suites.
The earlier parked check failed in the environment it ran in, not because of this change. No code change addresses it; the forge's check will run again on this push.
To try it: on the preview, land two commits within 15 minutes. The production card shows next production deploy at HH:MM UTC (n changes waiting) and the button reads Deploy now. Keep a websocket open to production and the line adds held while busy — a stream to it is still open.
🤖 Generated with Claude Code
Production deploys from landings are now batched: at most one per window, 15 minutes by default and set with app.deploy.every, plus a "Deploy now" button. A batched deploy waits while production is busy, for at most the busy grace. A swap lets the previous deployment's in-flight requests finish before stopping it.
The list_apps MCP tool reports the held landings as nextDeploy (at, changes, busy). That window and the busy hold are kept in memory, so a forge restart resets them; the docs say so.
Merging main conflicted in one place: the list_apps description in src/http/mcp.ts. main had shortened it ("The apps you can see…") to keep tools/list under its 40 KB limit, and this branch had added the nextDeploy clause to it. The resolution keeps main's shorter wording with the nextDeploy clause added. No tests were changed. After the merge the type check is clean, and these tests pass:
- all 15 MCP test files, including
test/mcp-size.test.tsandtest/mcp-pulls.test.ts(91 tests); - the batch, deploy, drain and busy suites (34 tests).
🤖 Generated with Claude Code
Parked by the crew: the check failed ("a tell asks for variants > variants: 0, 9, "2" and 2.5 are a 400 and open nothing") and the decider saw no point in another try
Production deploys from landings stop interrupting people (#3967) in three ways: they are batched to at most one per window, they wait while production is busy, and the old deployment is drained before it is stopped, so a swap drops no request.
Batching (from the first round). The window is 15 minutes by default.
FORGE_DEPLOY_EVERY_MINsets it for the forge, and an app sets its own withapp.deploy.every(whole minutes, 0–1440). A landing inside the window waits for its end and goes out in one deploy of the branch's tip at that moment. Deploy now sends what is waiting at once. Previews are not batched.Not while busy.
sendBatchnow checksbusyReasonbefore deploying. The first landing after a quiet window, which used to deploy at once, checks it too. Production counts as busy when a stream or websocket is open to it, a request is still unanswered, or one of its child processes is still working. While busy, the deploy is retried every minute (busyRetryMs). It goes once production is idle, or when the existing busy grace (45 min) runs out even if it never is. The retry timing is pure and lives inapps/batch.tsasbusyRetryAt. Deploy now does not wait.Swap without dropping requests. New requests already went to the new deployment once it answered, but the old one was stopped straight away, cutting off whatever it was still answering.
holdRequestnow counts in-flight requests per deployment. At the swap, the old deployment is stopped only after those requests are answered, or afterdrainMs(10 s by default). Open streams and websockets to the old deployment are still closed at the swap; clients that reconnect reach the new one. Handing an open websocket from one process to another would need a different proxy design, so I left it out.Every place shows the same state. The
batchedfield (at,changes, andbusywhile held) is in the JSON API throughenvsFor. The MCPappstool returns it asnextDeploy, and the terminal's Deploys screen shows it as a line via the newappHeld. The sentence isbatchedPhrase, now inapps/batch.tsso the terminal doesn't import web code. On the web page the line now starts with the attention status dot (dot("attn")from docs/DESIGN.md), which means pending. It keeps the same muted small text as the busy and asleep lines next to it.Docs. docs/APPS.md and the README now cover the busy hold and the drain. They also state that the window and the waiting landings live only in memory: a forge restart forgets them, deploys production on boot, and a forge in a crash loop restarts production on every boot.
Tests (
test/apps-batch.test.ts):busyRetryAtand the busy wording.batched./app/production/redeploy, and it still deploys.With the busy check and the drain switched off, all four new behaviour tests fail. The type check passes, as do the batch suite and the busy, Deploys-screen, MCP, design and proxy suites.
The earlier parked check failed in the environment it ran in, not because of this change. No code change addresses it; the forge's check will run again on this push.
To try it: on the preview, land two commits within 15 minutes. The production card shows
next production deploy at HH:MM UTC (n changes waiting)and the button reads Deploy now. Keep a websocket open to production and the line addsheld while busy — a stream to it is still open.🤖 Generated with Claude Code
Continues #3974