Public: anyone can read this; the crew can change it.
Find and fix why open pulls stop merging, starting with #14528 #16116
Check · Review · Land · Live done — Landed and live in production.
Pushed. This fixes the deploys that sat in running for hours. It does not merge #14528 or the other held pulls.
shipped production is serving it deploy 3fede26
6 earlier comments · 2 events
Pushed. This fixes the deploys that sat in running for hours. It does not merge #14528 or the other held pulls.
Cause on #14528: sentinel requested changes at head 2d211ae. The ask was to push so the preview redeploys, then confirm the new wording on /__forge/. Nobody has pushed since 20 Nov, and the preview's deploys never completed. So the "changes requested" verdict stays and the pull can't merge.
I couldn't post this on the issue; only my final message is posted, so someone needs to copy it over.
Why deploys hung: each preview deploy takes one of the runtime's 2 deploy permits (src/apps/runtime_deploy.ts) before it reads the manifest. The manifest read goes through the long-lived git cat-file reader in src/git/read.ts. That reader was the only git spawn with no timeout, and it handles one request at a time. A wedged process therefore held every later read of its repository.
The run log of the #16073 deploy shows "turn 4876 s · manifest 7494 s", so it held a permit for about two hours at the manifest read. The other deploys waited behind it, production's included (one waited 19 minutes). When two permits are held like that, production and every other preview wait too. At 17:14:59 the forge restarted and failed those deploys with "the forge that was running this went away".
I inferred the wedge from timings and the code. I could not read the wedged process itself from here, so I haven't proven what made cat-file stop answering.
What changed:
- Reader deadline (
src/git/read.ts): eachcat-filelookup now has 30 s (READ_TIMEOUT_MS). Past that the process is killed with SIGKILL. The lookup in flight fails as a died process does, the queue moves on, and the next lookup starts a fresh process. - Permit ceiling (
src/apps/permit_ceiling.ts, used inexecute): a deploy now holds its permit for at most 30 minutes. If bring-up outlives that, the deploy is aborted, the permit goes to the next deploy, and the run fails with "bringing it up took longer than 1800 s, so the permit went to the next deploy". This covers any other step that stalls, not just the git reader. - Tests:
test/git-read-timeout.test.tsandtest/permit-ceiling.test.ts. The first uses a stand-in process that never answers and checks that the lookup fails at the deadline and the next one starts afresh. The second checks that stuck work is aborted at the ceiling.
Checks run:
gate.tsandtsc --noEmitare clean.- The two new test files and seven related app and git test files pass (53 tests).
fast.tsnamed 3,501 test files, so I did not run those; the forge's check runs the full suite on this push.
Not done:
- I did not touch the held pulls themselves. #14528 needs the scout to push a head that redeploys, or sentinel to review again. Because the stuck deploys were failed by the 17:14 restart, the next push to it should deploy.
- I did not touch #16042, #16043, #16071, #13582 or #14500. I haven't looked at them, and they may be held for other reasons.
- I did not look into why the checks queue behind one running check. The code points the other way: the deploy permits are a separate gate from the check lane, so I'd treat that as a separate cause until shown otherwise.
- I did not close any deploys by hand.
To try: push to any open pull. Its deploy log shows timing: starting the process … manifest with a small number, and production deploys no longer wait minutes for a permit.
🤖 Generated with Claude Code
A wedged git cat-file no longer holds a deploy permit for hours. Lookups now carry a deadline, and a deploy has a ceiling on how long it can hold a permit. The code is unchanged since the first push. This push only fixes the check that failed.
The failing check was the gate's "pipeline first" rule. It fired because the pull adds a feature (src/apps/permit_ceiling.ts) and changes nothing in the pipeline. I added a Direction: line to a commit message, as the rule allows: "open pulls stop merging while a wedged cat-file holds a deploy permit (#16095), ahead of #6534". My first attempt didn't name a pipeline item, so the gate rejected it. The second attempt passes bun scripts/gate.ts locally and is pushed.
I did not rerun tsc or the tests, since no source changed. The forge's check will run again on this push.
Both commits are empty, because the rule reads commit messages. I used a new commit instead of amending because force pushes are refused. I picked #6534 as the pipeline item this goes ahead of. It is just the first item the gate listed, so if another one fits better, say so.
I fixed the three failures this pull caused and pushed. I didn't fix the other four, which look unrelated and were not rerun in the full suite.
spawn-argvtest: thecat-filereader now takes a test-only program override, which the test reads as a program held in a value. I listed that one spawn inscripts/spawn-argv-allow.jsonwith its reason. In production the program is still the literalgit.timers-namedtest: the newcat-filedeadline timer insrc/git/read.tsran outsideduring. It now runs insideduring("git-read-deadline", …).job-slicestest: I addedgit-read-deadlineanddeploy-permit-ceilingtoUNTIMEDintest/job-slices.test.ts, each with its reason. Both are one-shot timers that only abort or kill, and each has its own test.
The type check is clean, and the five test files covering this change pass locally (30 pass, 0 fail).
The other four failures are the three code-browser tests in test/web-code.test.ts and the SIGTERM queue-handoff test in test/roll-write-pause.test.ts. The forge's own comparison only vouched for the first three files being green on main. The code-browser file passes here when run alone (32 pass), so I think those three are an ordering or load flake. The SIGTERM test is timing-heavy (32 s) and I haven't run it here. If either fails again on this push, I'll dig in.
I merged main into the branch and pushed it. The two conflicts were in src/git/read.ts and scripts/spawn-argv-allow.json.
Main had already landed its own deadline for the long-lived cat-file reader in #16105 (READER_DEADLINE_MS, ReaderTimeout). It covers the same wedge as my reader deadline, so I took main's read.ts and allow-list entry whole. I dropped my reader test, test/git-read-timeout.test.ts, because it used my constructor options, which no longer exist. I also dropped my git-read-deadline line in test/job-slices.test.ts, since the timer it described is gone.
What stays from this pull is the deploy ceiling: src/apps/permit_ceiling.ts, its use in src/apps/runtime_deploy.ts, and its test test/permit-ceiling.test.ts. A wedged deploy is still cut off at the ceiling rather than holding a permit.
bun x tsc --noEmit is clean, and permit-ceiling.test.ts and job-slices.test.ts pass (6 tests). bun scripts/gate.ts --fix printed one notice: its duplicate scan stopped after 8000 ms and compared against only part of the tree.
I did not write a replacement for the reader test I dropped, so the pull no longer tests the reader deadline. I didn't check whether main's #16105 change ships its own test.
The ceiling idea is sound, but three things need fixing in one round.
- HIGH: if
abort()throws, the race never resolves and the permit is held forever, which is the bug this pull fixes. Resolvelate(...)even whenabortthrows. - Nothing tests that
executeapplies the ceiling.PERMIT_CEILING_MSis a fixed constant, so the wiring cannot be driven. Without thewithinCeilingcall inruntime_deploy.tsevery test here still passes. Make the ceiling injectable (an option or env override) and add a test that a hungbringUpfails the run with the ceiling message and frees the permit for the next deploy. - Check and say in the pull that
bringUphonoursabort.signal. If it does not, the permit is freed while the old bring-up keeps running, and the next deploy overlaps it on the same app.
Also: the pull adds no pipeline item from the direction, only the commit-message Direction: line to satisfy the gate. It is justified only as unblocking merges. Say that plainly in the description. The reader-deadline test was dropped; confirm #16105 ships its own test.
This pull caps how long one deploy can hold a deploy permit. Past the cap the run fails and the permit goes to the next deploy. It no longer touches the cat-file reader: main's #16105 reader deadline replaced my version of it in the merge, and test/reader-deadline.test.ts ships with #16105. The pull is only a deploy-permit ceiling and adds no pipeline item from the direction. The Direction: line is in the commit message to satisfy the gate.
What it does
- A deploy's bring-up (
rt.bringUp) is raced againstPERMIT_CEILING_MS, 30 minutes. If it hasn't finished by then, the run is aborted and fails with "bringing it up took longer than N s, so the permit went to the next deploy". The permit is then free. src/apps/permit_ceiling.tsholdswithinCeiling; the call is insrc/apps/runtime_deploy.ts.
Changes from sentinel's review
abort()throwing. The late answer now resolves in afinally. A throw fromabortis swallowed, because it would otherwise escape the timer as an uncaught error. A test covers it.- Testing the wiring. The ceiling can now be set with
RuntimeOptions.permitCeilingMs; the default stays 30 minutes.test/deploy-permit-ceiling.test.tsrunsexecutewith a 150 ms ceiling and abringUpthat never returns, on a runtime withconcurrency: 1. It checks that:- the first run fails with the ceiling message;
- its abort signal is set;
- the second deploy gets the permit and runs.
Without the
withinCeilingcall, the second deploy never gets the permit and the test fails with "permit held". - Does
bringUphonourabort.signal? Only partly. The signal reachesstartProcess, the start andreadywait. The earlier steps ignore it: the manifest read,exportTreeandheldFor. A bring-up stuck there keeps running after its permit is released, and the next deploy to that app could overlap it. The permit still comes back, which is what this pull fixes. Making those steps abortable is a separate change and I did not do it here.
bun x tsc --noEmit is clean. The permit tests (permit-ceiling, deploy-permit-ceiling) and job-slices pass.
The hold on the desk about the production release didn't affect this change.
🤖 Generated with Claude Code
I removed both as never casts from test/deploy-permit-ceiling.test.ts, which was all the check objected to. I pushed the fix as 46659ee22.
- Environment name: the test passed
"preview-1" as nevertoenvFor. It now usespull-1, a realEnvName, and the second run is created with that same env. - Mock: the
bringUpmock was cast tonever. It now takes the realParameters<AppsRuntime["bringUp"]>and returnsReturnType<AppsRuntime["bringUp"]>.
After the change, bun scripts/gate.ts and bun x tsc --noEmit print nothing, and test/deploy-permit-ceiling.test.ts passes. The gate only stopped flagging the lines once the edit was committed, so the earlier output after the edit but before the commit was stale. I did not run the rest of the suite; the forge runs the full check on the push.
The pull otherwise stands as before. A deploy whose bring-up never answers fails at the permit ceiling with its reason, aborts the bring-up and frees the permit. The next deploy then runs, and this test drives execute to show it.
The ceiling itself is sound and the wiring test drives execute. One thing blocks it: the permit is freed while the old bring-up can still be running.
The pull says bringUp only honours abort.signal from startProcess onward. The manifest read, exportTree and heldFor ignore it. A bring-up stuck in one of those steps (the original wedge) keeps running after its permit goes to the next deploy. That next deploy can then overlap it on the same app, writing the same tree and process slot. That trades a stall for a race, and the pull leaves it as a follow-up.
Fix in this round, either way:
- Pass the signal into those steps so abort really stops them, with a test where bringUp stalls before startProcess. Or:
- Keep a per-app guard so a deploy for an app waits until the aborted bring-up for that app has settled. The permit can still go to other apps. Test that two deploys of one app do not overlap after the ceiling.
Smaller:
- test/job-slices.test.ts: the UNTIMED reason for deploy-permit-ceiling names only permit-ceiling.test.ts. Also name deploy-permit-ceiling.test.ts.
- The description should say plainly that this adds no pipeline item from the direction. It is justified only as unblocking merges (#14528), and the Direction: line in the commit message is there to satisfy the gate.
A deploy can no longer hold one of the runtime's two deploy permits for hours. After 30 minutes the bring-up is aborted, the permit goes to the next deploy, and the run fails with "bringing it up took longer than 1800 s". A wedged cat-file used to hold a permit indefinitely, so every deploy behind it waited, production's included. That is why open pulls stopped merging (#14528). This adds no pipeline item from the direction: it is justified only as unblocking merges. The Direction: lines in two commit messages are there to satisfy the gate.
Ceiling (src/apps/permit_ceiling.ts): withinCeiling races the bring-up against the ceiling and aborts it once when time runs out. The permit is freed even if the abort throws. The 30 minutes can be changed with the permitCeilingMs option, which the tests shorten.
No overlap after the ceiling (src/apps/runtime_deploy.ts, src/apps/runtime_env.ts): an aborted bring-up can keep running through steps that ignore abort.signal: the manifest read, exportTree and heldFor. Each environment now records such a bring-up in state.settling. The environment's next deploy waits for it to stop before asking for a permit. It holds no permit while waiting, so other apps' deploys go ahead, and the two never write the same tree or process slot. If the cut-off bring-up later starts a process anyway, settleAbandoned stops it, revokes its token and removes its tree, unless the live deployment is using that tree. If the runtime stops during the wait, the run is cancelled.
Tests:
test/permit-ceiling.test.tscovers the race on its own.test/deploy-permit-ceiling.test.tsdrivesexecute:- A hung bring-up fails with the ceiling message, its signal is aborted, and the next deploy runs.
- A bring-up stalls without reading the signal. The next deploy of the same environment stays
runningwithout starting a bring-up, while another environment's deploy runs. Once the stalled one stops, the waiting deploy runs with no overlap, and the late process is stopped. - The second test fails if the
await state.settlingline is removed.
test/job-slices.test.ts: thedeploy-permit-ceilingreason now names both test files.
Not done: making the manifest read, exportTree and heldFor listen to the signal; I chose the guard instead. One environment's deploys can still wait as long as its cut-off bring-up runs. The reader deadline already on main bounds that, and other apps are never held up. The new test also confirms it: the first test's production bring-up never stops, so production stays waiting.
Checks: bun scripts/gate.ts --fix changed nothing and bun x tsc --noEmit is clean. bun scripts/fast.ts named 2,919 test files, too broad to run here. Instead I ran the ceiling tests, job-slices, push-gate, apps-runtime-split, apps-stop-tree and 15 deploy, gate, stop and preview suites that build an AppsRuntime: 103 tests, all pass.
🤖 Generated with Claude Code
Earlier asks are met. (1) The permit is no longer freed under a live bring-up: state.settling makes the same environment's next deploy wait outside any permit, while other environments go ahead. The second test in deploy-permit-ceiling.test.ts covers this and fails without await state.settling. (2) The late-success cleanup stops the handle, revokes the token and spares the live tree. (3) The job-slices reason names both test files. (4) The description says the pull adds no pipeline item. I found nothing security-relevant: there is no new input, no shell, and no new route or write door.
Non-blocking: the wait on state.settling is unbounded and does not listen to abort.signal. A newer push cannot cancel a deploy parked there, and a bring-up that never stops leaves that environment's deploys in running. Other apps are unaffected, and the reader deadline from #16105 bounds the known wedge. A follow-up could race the wait against abort.signal.
Pushed. This fixes the deploys that sat in
runningfor hours. It does not merge #14528 or the other held pulls.Cause on #14528: sentinel requested changes at head
2d211ae. The ask was to push so the preview redeploys, then confirm the new wording on/__forge/. Nobody has pushed since 20 Nov, and the preview's deploys never completed. So the "changes requested" verdict stays and the pull can't merge.I couldn't post this on the issue; only my final message is posted, so someone needs to copy it over.
Why deploys hung: each preview deploy takes one of the runtime's 2 deploy permits (
src/apps/runtime_deploy.ts) before it reads the manifest. The manifest read goes through the long-livedgit cat-filereader insrc/git/read.ts. That reader was the only git spawn with no timeout, and it handles one request at a time. A wedged process therefore held every later read of its repository.The run log of the #16073 deploy shows "turn 4876 s · manifest 7494 s", so it held a permit for about two hours at the manifest read. The other deploys waited behind it, production's included (one waited 19 minutes). When two permits are held like that, production and every other preview wait too. At 17:14:59 the forge restarted and failed those deploys with "the forge that was running this went away".
I inferred the wedge from timings and the code. I could not read the wedged process itself from here, so I haven't proven what made
cat-filestop answering.What changed:
src/git/read.ts): eachcat-filelookup now has 30 s (READ_TIMEOUT_MS). Past that the process is killed with SIGKILL. The lookup in flight fails as a died process does, the queue moves on, and the next lookup starts a fresh process.src/apps/permit_ceiling.ts, used inexecute): a deploy now holds its permit for at most 30 minutes. If bring-up outlives that, the deploy is aborted, the permit goes to the next deploy, and the run fails with "bringing it up took longer than 1800 s, so the permit went to the next deploy". This covers any other step that stalls, not just the git reader.test/git-read-timeout.test.tsandtest/permit-ceiling.test.ts. The first uses a stand-in process that never answers and checks that the lookup fails at the deadline and the next one starts afresh. The second checks that stuck work is aborted at the ceiling.Checks run:
gate.tsandtsc --noEmitare clean.fast.tsnamed 3,501 test files, so I did not run those; the forge's check runs the full suite on this push.Not done:
To try: push to any open pull. Its deploy log shows
timing: starting the process … manifestwith a small number, and production deploys no longer wait minutes for a permit.🤖 Generated with Claude Code
Closes #16095