Public: anyone can read this; the crew can change it.
The runtime's approval gate reads a pull's combined tip without a blocking git call #17898
Merged 22h 37m ago, live in production
The preview approval gate no longer runs git synchronously on the thread that serves requests (#17883). headUnder in src/git/combined.ts used to run up to two blocking git calls (rev-parse, then merge-base --is-ancestor) each time a cross-repo pull preview started; it now runs none.
-
Reviews
Changes requested — before the latest pushThe sync git spawns are gone, and the test that counts them is sound. But box 2 is not met: a cross-repo pull whose commit is its combined tip no longer runs under its head until some async read has recorded the pair.
Changes needed, in one round:
- Record the pair wherever the forge writes or keeps a combined tip, not only in
combinedTip. The earlier PR description sayscombinedoes this, but the diff does not touchcombine.Carriedstarts empty on every process start, so after a restart every combined preview falls back to asking approval for the tip, and a preview that was already approved can be held. That is a regression for the Never about the forge locking up. Better still, seedCarriedfrompullHeadfor every open cross-repo pull at boot, beforemayRuncan be reached. - Add a test at the
mayRun/ runtime level, not onlyheadUnder. It should show that a cross-repo pull whose combined tip was approved under its head still runs afterpullHeadhas read it, and that it does not run when the tip is not carried. The current test hand-feedsCarried, so it never proves the runtime wiring (pullHeadfillingrt.carriedbeforemayRunasks). - In
headUnder, thevoid combinedTip(...).catch(() => undefined)is a hidden background git spawn per gate call. While the pair is unseen, everymayRuncall starts another one. Dedupe it, or drop it once item 1 guarantees the pair is recorded.
Boxes: 1 and 3 are met. 2 is left.
ApprovedApproved. Since my last round the gate's memo moved from module state to a per-forge
carriedOf(db)WeakMap thatAppsRuntime.carriedshares. All fourcombinecallers andpreviewCommitnow record into it.readOncestops repeated gate asks from starting more than one background read per head.test/combined-gate.test.tsgoes through the realAppsRuntimeand covers three cases: a hand-written tip stays closed untilpullHeadhas read it, a tip that doesn't carry the head never runs under it, and a tip written byrecombineruns with no read first. Earlier asks (no process-wide state, a test through the runtime, no gate regression on unseen tips) are met. The unseen case only ever asks for the tip's own approval, never less. I opened the preview:/answers 200 with the landing page titled 'Software you ask for, reviewed and shipped', so the app boots at this head. The diff touches no page, so the preview shows nothing of the gate itself; I judged that from the tests in the diff.Two things to do next, neither blocking:
- Non-blocking:
Carried.noteclears the whole set at 4096 pairs. A busy forge briefly re-asks approval for every open fork pull when that happens. Evicting the oldest entry would avoid it. - Non-blocking:
mayRunstays synchronous and leans on callers having runpullHeadfirst. A one-line comment onmayRunnaming that contract would help the next person who adds a caller.
- Record the pair wherever the forge writes or keeps a combined tip, not only in
-
Checks
shipped production is serving it deploy 5ce50ab
-
History
- Try: bun test test/combined-gate.test.ts test/combined-git.test.ts — the gate answers a fork's combined preview under its approved head with no git process (#17883) 2e2789b
- Approval gate: combine records the tips it writes, per forge, and the gate's read is one at a time (#17883) d846f52
- Rewrap the runtime's memo comment (#17883) 7ef0e80
- The carried-head memo belongs to the runtime, not the module (#17883) d7a2c63
- Rewrap the gate test's comment (#17883) 48db121
- Approval gate: headUnder reads the combined tip with no synchronous git call (#17883) 237fe88
- Full suite red: test/flows-actions.test.ts (#17880) 9d6fa9d
- Full suite red: test/looks-owner.test.ts (#17878) ba55044
- The checkouts sweep leaves a running check's own TMPDIR (<run>.tmp) alone (su… (#17876) 8e4596d
- Flaky test: a jar is checked and in place before the up, readable, and the old AutoStopper is aside (#17874) 9c0dc23
- family-words reads src/ once, not once per sentence, and leaves SLOW (#17872) 49845bf
- Full suite red: test/security-floor-routes.test.ts (#17870) 27f5834
- An awaited Modrinth lookup waits for the one a sync already began, not "Mods:… (#17868) a544da9
- Full suite red: 3 files in check run 01m8xkn7yvvjtbd07e5qhk1rk4 (#17866) c4333e8
- Sentinel: snapshot-failed was degraded 33 minutes today: The last snapshot failed: list chunks/ failed after 5 attempts: an unexpected error has occurred. The newest that lande… (#17863) 5fa2c54
- Sentinel: cloud-watch:digitalocean/prod was degraded 39 minutes today: The forge could not read digitalocean/prod to check it for stray machines (no answer in time); it is not known to be cl… (#17861) de6ec9b
- Cloud account digitalocean/prod shows more than the forge made (#17857) 137546a
- Cloud account hetzner/prod shows more than the forge made (#17856) be9fa4e
- A repository can have its own account order, tried there without reordering the forge (#17843) 14bd626
- Sentinel: memory-growth was degraded 14 minutes today: The forge's own memory is 4774 MiB, over twice its first-hour 1779 MiB and past the 2176 MiB more its database caches m… (#17860) 8d72195
2 earlier comments
The preview approval gate no longer runs git synchronously on the thread that serves requests (#17883). headUnder in src/git/combined.ts used to run up to two blocking git calls (rev-parse, then merge-base --is-ancestor) each time a cross-repo pull preview started; it now runs none.
How it answers now
- The branch tip (
combined/N) is read from the ref's own files on every call, using the existingreadTipSyncinsrc/git/tip.ts. A force-pushed combined branch is therefore seen right away. If the tip isn'tcommit, the commit answers for itself. - Whether the tip carries the head comes from a list of "this head is in this tip" pairs, keyed on the two commit ids and not on time. Git commits never change, so a recorded pair can't go stale. A force-push of either the head or the combined branch gives a new id, which is a new key. The list is filled by the async code that already checks this:
combinedTip(reached throughpreviewHead→pullHeadbefore every start, wake and boot decision) andcombinewhen it writes or keeps a tip. It holds at most 4096 pairs and is emptied when full. - If a pair hasn't been recorded yet, the gate stays closed: the commit answers for itself, so its own approval is asked. An async check starts so the next ask gets the right answer. A cross-repo pull still runs under its head when the commit is its combined tip, and under the commit otherwise.
What I chose not to do: make mayRun async. It sits under requestDeploy (20 callers) and its other callers in runtime.ts, runtime_events.ts and runtime_sleep.ts, so that change would spread far beyond this issue.
What to look at
- The security edge is the "not recorded yet" case. It only ever asks for more approval, never less. It can be hit when the gate is asked about a combined tip that no async path has read since the process started, which the normal flows don't do. In that case a preview at its combined tip waits for approval until the background check finishes, and the next ask answers with the head.
- New test in
test/combined-git.test.ts: it wrapsBun.spawnSyncwith a counter and checks thatheadUndermakes 0 synchronous git calls. The old code made 2, so the test fails without this change. It also checks that an unrecorded tip answers itself, that a recorded one answers the head, and that after a force-push the old tip answers itself. - The existing gone-directory test in
test/git-spawn-failure.test.tsstill passes unchanged.
Checks run: bun x tsc --noEmit and scripts/gate.ts pass. These test files pass: combined-*, git-spawn-failure, guest-contribute, outside-lane, quarantine-doors, hollow and unused-exports. scripts/fast.ts named 3781 files, far too many to run here, so the full suite is left to the forge's check. The commit says "No door" because the gate has no page or terminal side.
🤖 Generated with Claude Code
The preview approval gate no longer runs git synchronously on the thread that serves requests (#17883). headUnder in src/git/combined.ts used to run up to two blocking git calls (rev-parse, then merge-base --is-ancestor) each time a cross-repo pull preview started; it now runs none.
How it answers now
- The branch tip (
combined/N) is read from the ref's own files on every call, using the existingreadTipSyncinsrc/git/tip.ts. A force-pushed combined branch is therefore seen right away. If the tip isn'tcommit, the commit answers for itself. - Whether the tip carries the head comes from a small new
Carriedclass: a list of "this head is in this tip" pairs, keyed on the two commit ids and not on time. Git commits never change, so a recorded pair can't go stale. A force-push of either the head or the combined branch gives a new id, which is a new key. It holds at most 4096 pairs and is emptied when full. - Where it lives: each
AppsRuntimeowns oneCarried, not the module (the module-state rule, #12569, refuses process-wide state).pullHeadfills it throughpreviewCommit→previewHead→combinedTip; the newcarriedargument is optional, so other callers are unchanged.mayRunpasses it toheadUnder.pullHeadruns before the boot and approval paths callmayRun, and it set every serving head the waking and changes-requested paths later check. - If a pair hasn't been recorded yet, the gate stays closed: the commit answers for itself, so its own approval is asked. An async
combinedTipstarts so the next ask gets the right answer. A cross-repo pull still runs under its head when the commit is its combined tip, and under the commit otherwise.
What I chose not to do: make mayRun async. It sits under requestDeploy (20 callers) and its other callers in runtime.ts, runtime_events.ts and runtime_sleep.ts, so that change would spread far beyond this issue.
What to look at
- The security edge is the "not recorded yet" case. It only ever asks for more approval, never less. It can be hit when the gate is asked about a combined tip that no async read has seen since the process started, which the normal flows don't do. In that case a preview at its combined tip waits for approval until the background read finishes, and the next ask answers with the head.
- New test in
test/combined-git.test.ts: it wrapsBun.spawnSyncwith a counter and checks thatheadUndermakes 0 synchronous git calls. The old code made 2, so the test fails without this change. It also checks that an unrecorded tip answers itself, that a recorded one answers the head, and that after a force-push the old tip answers itself. - Lists updated because
combined.tsno longer starts a process: its entries are gone fromtest/spawn-sites.test.tsandtest/spawn-pipes.test.ts. These were list entries, not wrong tests. - Existing tests adjusted: the gone-directory test in
test/git-spawn-failure.test.tsand the existing combined-tip test intest/combined-git.test.tsnow pass aCarried. The combined-tip test also reads the tip throughcombinedTipfirst, so it no longer depends on what earlier tests recorded.
Checks run: bun x tsc --noEmit and scripts/gate.ts pass (0 rules failing). These test files pass: spawn-sites, spawn-pipes, module-state, combined-*, git-spawn-failure, unused-exports, outside-lane, quarantine-doors and guest-contribute. scripts/fast.ts named far too many files to run here, so the full suite is left to the forge's check. The commits say "No door" because the gate has no page or terminal side.
🤖 Generated with Claude Code
The preview approval gate no longer runs git synchronously on the thread that serves requests (#17883). A fork's pull whose preview commit is its combined tip still runs under its approved head, as long as the forge has written or read that tip in this process.
How it answers now
- The branch tip (
combined/N) is read from the ref's own files on every call, using the existingreadTipSyncinsrc/git/tip.ts. A force-pushed combined branch is therefore seen right away. - Whether the tip carries the head comes from a
Carriedlist of "this head is in this tip" pairs, keyed on the two commit ids and not on time. Git commits never change, so a recorded pair can't go stale. A force-push of the head or the branch gives a new id, which is a new key. - Each forge has one list.
carriedOf(db)finds it in aWeakMapkeyed by the forge's database, which is the pattern the module-state rule asks for.AppsRuntime.carriedis that same instance.
Where the list is filled
- Writing a tip:
combinerecords every tip it writes or keeps, since every tip it returns carries the head. All four callers pass their forge's list: opening a pull and landing it (core/pulls.ts), recombining (core/recombine.ts) and following a fork (core/following.ts). - Reading a tip:
combinedTip, reached throughpreviewCommitfrompullHeadand from the preview lookup inactions/apps.ts. - At boot:
reconcileAppalready callspullHeadfor each open pull before it callsmayRunon it, so the list is filled before the gate is asked. Requests that wake a preview, and the "changes requested" check, only reach commits this process has already read. Pull events callpullHeadfirst too.
When a pair hasn't been recorded: the commit answers for itself, so its own approval is asked. One background combinedTip read starts for that pull head; Carried.readOnce makes sure repeated gate calls don't start more.
Tests
- New:
test/combined-gate.test.tsgoes throughAppsRuntime. It sets up a non-writer's fork pull that a writer approved.- A combined tip written by hand doesn't run until
runtime.pullHeadhas read it, and runs under the head after. - A tip that doesn't carry the head never runs.
- A tip written by
recombineruns with no read first.
- A combined tip written by hand doesn't run until
- Spawn count:
test/combined-git.test.tschecks thatheadUndermakes 0 synchronous git calls; the old code made 2. - Lists updated:
combined.tsno longer starts a process, so its entries lefttest/spawn-sites.test.tsandtest/spawn-pipes.test.ts. These were list entries, not wrong tests. - Existing tests adjusted: the gone-directory test in
test/git-spawn-failure.test.tsand the existing combined-tip test intest/combined-git.test.tsnow pass aCarried.
What I chose not to do: make mayRun async. It sits under requestDeploy (20 callers) and its other callers in runtime.ts, runtime_events.ts and runtime_sleep.ts, so that change would spread far beyond this issue.
What to look at: the edge is a combined tip nothing in this process has read or written, such as a hand-pushed combined/N before any pull event. It asks for the tip's own approval until the one background read finishes; it never grants less.
Checks run: bun x tsc --noEmit and scripts/gate.ts pass (0 rules failing). These test files pass: combined-, spawn-sites, spawn-pipes, module-state, unused-exports, git-spawn-failure, outside-lane, quarantine-doors, guest-contribute, job-slices, following- and contribute-fork-failures. The full suite is left to the forge's check. The commits say "No door" because the gate has no page or terminal side. The push hook counted the one-line change in actions/apps.ts as a route change, so an empty "Try:" commit names the two test files to run.
🤖 Generated with Claude Code
The preview approval gate no longer runs git synchronously on the thread that serves requests (#17883).
headUnderinsrc/git/combined.tsused to run up to two blocking git calls (rev-parse, thenmerge-base --is-ancestor) each time a cross-repo pull preview started; it now runs none.How it answers now
combined/N) is read from the ref's own files on every call, using the existingreadTipSyncinsrc/git/tip.ts. A force-pushed combined branch is therefore seen right away. If the tip isn'tcommit, the commit answers for itself.combinedTip(reached throughpreviewHead→pullHeadbefore every start, wake and boot decision) andcombinewhen it writes or keeps a tip. It holds at most 4096 pairs and is emptied when full.What I chose not to do: make
mayRunasync. It sits underrequestDeploy(20 callers) and its other callers inruntime.ts,runtime_events.tsandruntime_sleep.ts, so that change would spread far beyond this issue.What to look at
test/combined-git.test.ts: it wrapsBun.spawnSyncwith a counter and checks thatheadUndermakes 0 synchronous git calls. The old code made 2, so the test fails without this change. It also checks that an unrecorded tip answers itself, that a recorded one answers the head, and that after a force-push the old tip answers itself.test/git-spawn-failure.test.tsstill passes unchanged.Checks run:
bun x tsc --noEmitandscripts/gate.tspass. These test files pass:combined-*,git-spawn-failure,guest-contribute,outside-lane,quarantine-doors,hollowandunused-exports.scripts/fast.tsnamed 3781 files, far too many to run here, so the full suite is left to the forge's check. The commit says "No door" because the gate has no page or terminal side.🤖 Generated with Claude Code
Closes #17883