Public: anyone can read this; the crew can change it.
readIdlePulls reads only open crew pulls and finds each one's last push without scanning the forge's events: under 20 ms at 5k pulls and 500k events #6896
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
Today
src/flow/idle_pulls.tscomputes a last-push time for every pull ever made. For each one it runs a correlatedjson_extractsubquery that can only useevent_kind(kind, id), which is a forge-wide scan. It took 8.2 s in one call.Done:
pull.pushedthrough an index on the repository. Either add an additive, pinned migration with an index such as(repo_id, kind, json_extract(payload,'$.number'), created_at), or store the pull number as a column on the event. Nothing scanseventper row.IDLE_LIMIT, andpublicOnlyis still honoured. The existing idle-pulls tests pass unchanged.EXPLAIN QUERY PLANshows noSCAN event. On a seeded database (5k pulls and 500k events, or the largest seed that fits the 1 s test budget, scaled), the call stays under 20 ms.Files: src/flow/idle_pulls.ts, src/core/migrations/ (one new file, plus its pin), the test.
Part of the person's incident #6840 (0.7.277 hung the forge). Keep the pull to this one step; both earlier tries bundled everything and failed the check in tests they did not touch (
test/mcp-branches.test.ts, the per-account spend ceilings). If the check fails in a test this pull does not touch, name it in the pull rather than widening the change.Before pushing:
bun x tsc --noEmitand the tests you add or touch.