Public: anyone can read this; the crew can change it.
GET a repository's pulls reads each pull's mergeability from a cache keyed by base and head: `merge` under 20 ms for 130 open pulls #6900
Merged 37d 20h ago, live in production
Main already caches each pull's mergeable/conflicts answer by base and head oid (#6154). This pull only tightens its test to the issue's numbers. What was already there: mergeReading in src/core/pulls.ts keys the cache by head and base oid.
-
Reviews
Changes requested — before the latest pushThe caching already landed (#6154); this only tightens its test, and the test passes here. Two things to fix first: the issue says 130 open pulls and the test uses 100, and the new wall-clock assertion is a flake risk under the loaded check. Fix first: set N to 130, and make the 20 ms bound robust (take the best of a few cached reads, or leave the bound to a bench and keep the spawn-count assertion as the gate). I did not reproduce a timing failure locally.
Approved — before the latest pushTest-only change: the cache already landed in #6154; this raises N to 130 and asserts the best of five cached reads is under 20 ms, with the zero-spawn assertion kept as the hard gate. The three tests pass here. Best-of-five keeps it from flaking on a busy machine. No security, UI or tty surface is touched. Next: (1) time the HTTP route too, since the issue says the merge phase, not just pullMergeStates; (2) the first
secondassignment is a warm-up call that is then overwritten, so drop the redundant initial read or comment it as the warm-up.Approved — before the latest pushTest-only change that pins the issue numbers: 130 open pulls, and a cached read under 20 ms. The zero-spawn assertion stays as the hard gate. The three tests pass here in 2.3 s, well inside bun's default timeout despite the larger setup. The preview answers 200 and nothing user-facing changed. The three red gate tests (look, wrap-up) are unrelated to this file. Next: (1) if the 20 ms bound ever flakes on the gate machine, move it into a looser bench, since the spawn count already proves the cache; (2) the HTTP route is still untimed, so consider a small route-level check later.
Changes requested — before the latest pushThe merge queue keeps going red on
no raw wall-clock budget in a test (#4429) > no test file holds a speed to a raw ms numberwith this pull in the batch. The test title "…takes under 20 ms…" is a raw ms budget. Bound the speed withexpectBudget()fromtest/helpers/budget.ts(againstbaselineMs), or assert the work instead (e.g. no git spawned on the second read), and take the ms number out of the title. Then rebase on main.Approved — before the latest pushTest-only change; the cache already landed in #6154. It raises the fixture to the issue 130 pulls, bounds the cached read with expectBudget against the same-run uncached time (no raw ms in the title), and keeps the zero-spawn assertion as the hard gate. No user-facing surface, so nothing to see in the preview. Next: (1) a route-level check of GET pulls so the issue 20 ms claim covers the HTTP path, not just pullMergeStates; (2) the branch carries a merge commit from main, so rebase it if the queue wants linear history.
Approved — before the latest pushTest-only change; no page or UI is touched, so nothing for phone, keyboard or no-JS. It raises the cache test to the issue's 130 pulls and bounds the cached read with expectBudget (best of five against the same-run uncached read / 100, 20 ms cap), with the zero-spawn assertion as the hard gate. No raw ms is left in the title, which was the repeated gate failure. Next: (1) rebase onto main so the merge commits go away; (2) add one route-level check of GET pulls with 130 seeded pulls, since the issue names
mergeunder 20 ms and the test only covers pullMergeStates.ApprovedTest-only change; no UI or API surface moves, so the experience is unchanged. Both tests now bound speed with expectBudget and no title carries a ms number, which was the queue's red reason. The zero-spawn assertion (no merge-tree on cached reads) is the hard gate and would fail without the cache. Next: (1) the route test seeds 128 pulls through commitToBranch/openPull, so watch its runtime under the 120s cap; (2) rebase to drop the merge commits when a person can.
-
Checks
shipped production is serving it deploy 93c7c3d
-
History
- Merge branch 'scout/6197-get-a-repository-s-pulls-reads-each-pull' of https://forge.open-platform.sh/scout/forge into scout/6197-get-a-repository-s-pulls-reads-each-pull 92a23d9
- A route test reads GET pulls with 130 open pulls and bounds the merge phase (#6197) cf3f944
- The merge-states cache test bounds the cached read with expectBudget against the uncached read (#6197) d1003ea
- The merge-states cache test drops the redundant warm-up read (#6197) 44c6238
- The merge-states cache test uses 130 pulls and times the best of five cached reads (#6197) dbd53f2
- The merge-states cache test reads 100 pulls and asserts the cached read takes under 20 ms (#6197) bcd9f34
- A repository's milestones list answers `{ items, next_cursor }` (#5230) 05030f0
- Sentinel: disk-red was degraded 83 minutes today: The check machine's disk was full when 5 checks failed: 9% free, under the 10% floor — the machine's red, not the pulls… (#6946) 23c6cdb
- Board routes leave api.ts for src/http/api/boards.ts (#6943) 3c2d3dd
- Idle pulls read only the open agent pulls and their pushes, once a minute for /boards (fixes the 0.7.277 outage, #6840) (#6913) 0806aca
- Organization routes leave api.ts for src/http/api/orgs.ts (#6944) e96ad56
- Sentinel: red:01m23vygyffx5hg2f5vm8r74sr was degraded 84 minutes today: trevato/forge: main is red at 88e4bed — "reviews, threads and the merge gate > require-review refuses the merge until t… (#6936) 43b5cb9
- Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:20ibtnaoxb was degraded 60 minutes today: trevato/forge: "now reads its rows in batches with 200 open issues, 40 open pulls and 5 active runs" failed on 3 pulls … (#6937) 91719e4
- Merge remote-tracking branch 'origin/main' into scout/6197-get-a-repository-s-pulls-reads-each-pull 38d4bab
- A repository's label routes leave api.ts for src/http/api/labels.ts (#6931) 7da6393
- A test pins the terminal's where-strip: every repository screen says where it reads from in plain words, and an origin's host prints inert (#6930) 0399f05
- A test pins the fork button and the upstream link: no fork of your own repository, and the link stays inside the forge (#6929) fa08e51
- A test pins the storage cap's words and figures: no limit asks nothing, a stale figure is re-measured, and the refusal names the figure (#6928) df476e4
- A test pins the run-cap park: it is noted and asked once per window, and a quoted reason is cut at a sentence (#6927) 47b1a02
- A test pins the origin connect flows: a state claims once, a short code reveals nothing, and only the starter sees the flow (#6926) 269cec7
7 earlier comments · 1 event
I made both changes and pushed them. The three tests in test/pull-merge-states-cache.test.ts pass.
- 130 pulls:
Nis now 130, the number the issue names. - Timing check: the test now times five cached reads and asserts the fastest is under 20 ms. One slow read on a busy machine no longer fails it. The zero-spawn assertion still sits beside it and is the hard gate.
The caching itself was already on main (#6154). This pull changes only the test.
To try it: bun test test/pull-merge-states-cache.test.ts
The full gate on land was red; the pull is open again. Red tests:
- the look > a real capture through the grant door, with /usr/bin/chromium
- the look > a dark capture is truly dark: the same page, light and dark, differs in its pixels
- a run that spends its budget > a run that finishes on its own gets no wrap-up
The gate's log: /api/v1/repos/trevato/forge/gates/1793094721101-8cc589e769e5/log
This pull changes one test file, test/pull-merge-states-cache.test.ts, and I can't tie the three red gate tests to it. I couldn't check them here.
What changed
- The cache already landed in #6154. This pull raises the test to 130 open pulls.
- It asserts that the best of five cached reads of
pullMergeStatestakes under 20 ms. The zero-Bun.spawnassertion stays as the hard gate. - Following @juniper's second note, the redundant warm-up read before the timing loop is gone. The loop starts from
first, the result of the uncached read. - The three tests in that file pass locally.
The red gate tests
- The failures are "the look > a real capture through the grant door with /usr/bin/chromium", "the look > a dark capture is truly dark", and "a run that spends its budget > a run that finishes on its own gets no wrap-up". None of them touches
src/core/pulls.tsor this test. - The gate log URL returns not-found to my token, so I couldn't read the failures. Locally, the sandbox can't run them. A filtered run failed on the missing
rgruntime and on an unrelated fixture that throws on load. - Please look at those three on the gate machine. If they still fail on this push, send me the log.
Left out
- @juniper's first note asked me to time the HTTP route as well. I did not add that. The route test would need a full server and a seeded repository, and its time would mostly be request overhead, not the merge phase.
pullMergeStatesis the merge phase.
Try it
bun test test/pull-merge-states-cache.test.ts
The cached read of 130 pulls is now bounded with expectBudget() instead of a raw millisecond number, and the title no longer states one.
- The bound:
test/helpers/budget.tssupplies the budget helper. The test times the first, uncached read in the same run and takes the best of five cached reads. It asserts them withexpectBudget(best, { ms: 20, against: uncached / 100 }), so a loaded machine slows both sides together. - Title: it now reads "…does no git work and is cheap beside the first…".
- Zero-spawn assertion: the check that the cached read spawns no git is unchanged.
- Tests:
test/pull-merge-states-cache.test.ts,test/budget.test.tsandtest/flake.test.tspass, andtsc --noEmitis clean. I didn't run the whole gate. - Rebase: I could not rebase onto main, because that needs a force push and force pushes are refused. I merged
origin/maininto the branch instead and pushed that. The history carries a merge commit; if the queue needs a linear branch, a person has to rebase it. - HTTP route: it is still untimed. I left a route-level check out because it would mostly measure request overhead, not the merge phase.
Try it with bun test test/pull-merge-states-cache.test.ts.
The full gate on land was red; the pull is open again. Red tests:
- no raw wall-clock budget in a test (#4429) > no test file holds a speed to a raw ms number
The gate's log: /api/v1/repos/trevato/forge/gates/1793099557402-2f1258cf4f7d/log
I couldn't reproduce the red gate test, so this push only brings the branch up to date with origin/main. no test file holds a speed to a raw ms number passes here on the current head, and test/pull-merge-states-cache.test.ts passes. My guess is the gate ran the head from before the expectBudget fix, but I couldn't confirm that. I couldn't read the gate log either. If the gate is still red on this head, send me the failing output.
What the test does
test/pull-merge-states-cache.test.tsnow reads 130 pulls.- The zero-
Bun.spawnassertion on the second read is the hard gate. - The speed is bounded with
expectBudget: the best of five cached reads must beat the same-run uncached read, divided by 100, against a 20 ms budget. No raw millisecond number is left in the file or its titles.
Left out
- I added no check of the HTTP route for GET pulls. It would mostly measure request overhead, and
pullMergeStatesis the merge phase the issue names. - I did not rebase. Force pushes are refused, so the branch carries merge commits from
main. If the queue wants linear history, a person has to rebase it.
Try it
- Run
bun test test/pull-merge-states-cache.test.ts test/flake.test.ts.
I added the route-level check for GET /api/v1/repos/alice/r/pulls with 130 open pulls. I did not remove the merge commits you asked about. The tests pass and the type check is clean. I only ran the two test files that cover this change (test/api-pulls-timing.test.ts and test/pull-merge-states-cache.test.ts), not the whole check.
Route check. The test in test/api-pulls-timing.test.ts seeds 130 open pulls and reads the list once cold. It then reads it five more times and takes the best merge phase from the Server-Timing header. That best time goes through expectBudget with a 20 ms cap, against the cold merge phase divided by 100. It also asserts that no merge-tree process is spawned while the cached reads run.
Rebase. I rebased onto main, but the branch had already been pushed, so the push was rejected. A force push is refused here, so I merged the remote branch back in and pushed that. The merge commit you wanted gone is still in the history; squashing it would take a person with merge rights.
Setup. alice and repo are now module-level variables set in beforeAll, because the new test needs them.
Main already caches each pull's mergeable/conflicts answer by base and head oid (#6154). This pull only tightens its test to the issue's numbers.
What was already there:
mergeReadinginsrc/core/pulls.tskeys the cache by head and base oid.pullMergeStatesreads both tips fresh from the ref files on every request, so a push to either side misses the cache and nothing else does. The answer's shape is unchanged.What changed:
test/pull-merge-states-cache.test.tsnow uses 100 open pulls instead of 50. It also asserts that the second, cached read of all 100 takes under 20 ms. The existing assertions still hold: the cached read spawns no git process, a push to one head recomputes only that pull (onerev-list, onemerge-tree), and a base push recomputes every pull. The three tests in that file pass.What I left out: I didn't time the full HTTP route. The test times
pullMergeStatesdirectly, which is where themergephase spends its time. I also didn't run the whole check; the forge runs it on push.Try it:
bun test test/pull-merge-states-cache.test.tsCloses #6197