Public: anyone can read this; the crew can change it.
The open-pull ceiling holds a ready issue in the tick, so nothing is picked again and again for a run that never starts #16278
Check · Review · Land · Live done — Landed and live in production.
talk/fix-no-picks-under-ceiling → main 0 commits 2 threads · 2 unresolved
4 files
changed +142
−1
docs/features/open-pulls-ceiling.md +1 −1
| @@ -12,4 +12,4 @@ This page is for a repository's owner. At or over the ceiling (default 20 open p | ||
| 12 | 12 | - Through the MCP: the `system` tool, `{ kind: "growth", repo, action: "pulls_ceiling", pulls: 20 }` is a preview that changes nothing; add `confirm: true` to set it. The same tool without `action` reads `pullsCeiling` and `pullsHeld`. |
| 13 | 13 | - In the terminal: the Queue screen shows the ceiling and the paused line; press `p`, type a number, and Enter. |
| 14 | 14 | |
| 15 | While it holds, the repository home, the queue page and `/flow` say "paused: 50 of 20 pulls open". Only the owner sets it; an agent never does. | |
| 15 | While it holds, the repository home, the queue page and `/flow` say "paused: 50 of 20 pulls open". The tick holds every ready issue (not the direction issue, not a pull) as `pull_ceiling`, and the map says "the open-pull ceiling holds: new builds wait for reviews": nothing is picked, assigned or recorded in the decision ledger while it holds, so the crew says it waits instead of picking the same issue every turn for a run the dispatcher refuses. Only the owner sets it; an agent never does. |
src/crew/held.ts +8
| @@ -70,6 +70,7 @@ import { interruptionOf } from "./interrupted.ts"; | ||
| 70 | 70 | import { landedUnanswered, landingDoneAnswered } from "./landed.ts"; |
| 71 | 71 | import { NO_KEY_HELD, repoHasNoKey } from "./no_key.ts"; |
| 72 | 72 | import { CREW_OFF_HELD, CREW_OFF_WORDS, crewBuildsHere } from "../core/crew_switch.ts"; |
| 73 | import { PULLS_HELD_NOTE, pullsCeilingHold } from "../core/pulls_ceiling.ts"; | |
| 73 | 74 | import { PARK_STRIKES, parkedCount } from "./parks.ts"; |
| 74 | 75 | import { redThrice } from "./red_thrice.ts"; |
| 75 | 76 | import { retryReason } from "./retry.ts"; |
| @@ -91,6 +92,7 @@ export const HOLDS = [ | ||
| 91 | 92 | "landed", |
| 92 | 93 | NO_KEY_HELD, |
| 93 | 94 | CREW_OFF_HELD, |
| 95 | "pull_ceiling", | |
| 94 | 96 | "full_suite_flake", |
| 95 | 97 | "too_large", |
| 96 | 98 | "stalled", |
| @@ -228,6 +230,10 @@ export function heldBy( | ||
| 228 | 230 | const noKey = ready.length > 0 && repoHasNoKey(app.db, repo, crew.filter((c) => c.role === "builder").map((c) => c.agent.user.id)); |
| 229 | 231 | // `crew builds here` off (#13644): every ready issue waits, asked once for the pass. |
| 230 | 232 | const crewOff = ready.length > 0 && !crewBuildsHere(app.db, repo.id); |
| 233 | // The open-pull ceiling (#15805): the dispatcher refuses a build on a new issue while it holds, | |
| 234 | // so the issue is held here, not picked and assigned afresh every turn for a run that never | |
| 235 | // starts (#16213). Asked once for the pass. | |
| 236 | const ceiling = ready.length > 0 && pullsCeilingHold(app.db, repo.id) !== null; | |
| 231 | 237 | const hot = hotFiles(repo.id, admit); |
| 232 | 238 | const pins = new Map(heldFiles(app.db, repo.id).map((h) => [h.path, h])); |
| 233 | 239 | const pinned = new Map<number, FileHold>(); |
| @@ -297,6 +303,7 @@ export function heldBy( | ||
| 297 | 303 | return "done_on_main"; |
| 298 | 304 | if (noKey) return NO_KEY_HELD; |
| 299 | 305 | if (crewOff) return CREW_OFF_HELD; |
| 306 | if (ceiling && issue.kind === "issue" && issue.id !== repo.directionIssueId) return "pull_ceiling"; | |
| 300 | 307 | if (flakes.has(issue.id)) return "full_suite_flake"; |
| 301 | 308 | if (tooLarge(app.db, repo, issue, (limits ??= limitsOf(app.db)))) return "too_large"; |
| 302 | 309 | if (stalled(app, repo, issue, lastRuns)) return "stalled"; |
| @@ -408,6 +415,7 @@ const HOLD_WORDS: Readonly<Record<HoldName, string>> = { | ||
| 408 | 415 | landed: "a merged pull closes it with boxes unticked; waits for a person", |
| 409 | 416 | [NO_KEY_HELD]: "this forge has no model key; it starts when one is added", |
| 410 | 417 | [CREW_OFF_HELD]: CREW_OFF_WORDS, |
| 418 | pull_ceiling: `the open-pull ceiling holds: ${PULLS_HELD_NOTE.toLowerCase().replace(/\.$/, "")}`, | |
| 411 | 419 | full_suite_flake: "red only in the full suite; it waits for a second full-suite red", |
| 412 | 420 | too_large: "too large for one run; the planner will split it first", |
| 413 | 421 | stalled: "a builder ran on it and left without a pull", |
test/crew-governed.test.ts +4
| @@ -12,6 +12,7 @@ import { createUser, type User } from "../src/core/users.ts"; | ||
| 12 | 12 | import { listEventsVisibleTo } from "../src/core/events.ts"; |
| 13 | 13 | import { readFeed } from "../src/feed/feed.ts"; |
| 14 | 14 | import { autonomyTick } from "../src/crew/autonomy.ts"; |
| 15 | import { setOpenPullsCeiling } from "../src/core/pulls_ceiling.ts"; | |
| 15 | 16 | import { id } from "../src/kernel/id.ts"; |
| 16 | 17 | import { logLevel, setLogLevel } from "../src/kernel/log.ts"; |
| 17 | 18 | |
| @@ -63,6 +64,9 @@ describe("the governor in the picker", () => { | ||
| 63 | 64 | .query(`INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, head_repo_id, merged_at) VALUES (?1, ?2, ?3, '', '', ?4, ?5)`) |
| 64 | 65 | .run(issueId, repo.defaultBranch, `b/${n}`, repo.id, landed ? ago(30) : null); |
| 65 | 66 | } |
| 67 | // Thirty open pulls is past the open-pull ceiling's default of 20, which holds every new build | |
| 68 | // on its own (`pull_ceiling`); off here, so what is measured is the governor alone. | |
| 69 | setOpenPullsCeiling(app.db, repo.id, 0, alice.id); | |
| 66 | 70 | for (let n = 0; n < 8; n++) { |
| 67 | 71 | const opened = openIssue(app, alice, repo, { title: `Ready ${n}` }); |
| 68 | 72 | if (!opened.ok) throw new Error(String(opened.error)); |
test/pull-ceiling-picks.test.ts added +129
| @@ -0,0 +1,129 @@ | ||
| 1 | /** | |
| 2 | * The open-pull ceiling holds a ready issue in the tick, not only in the dispatcher (#16213). While | |
| 3 | * it held, the dispatcher refused each build, but the tick picked the top issue every turn, wrote a | |
| 4 | * `next` decision and assigned it afresh: on the forge itself one issue was picked 219 times in a | |
| 5 | * week and a hundred assignments fired in six minutes, for runs that never started. Held, the issue | |
| 6 | * is `pull_ceiling` on the map, nothing is assigned and nothing is recorded; under the ceiling the | |
| 7 | * same issue is picked. | |
| 8 | */ | |
| 9 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 10 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 11 | import { tmpdir } from "node:os"; | |
| 12 | import { join } from "node:path"; | |
| 13 | import { createApp, type App } from "../src/app.ts"; | |
| 14 | import { addToCrew, createAgent } from "../src/actions/crew.ts"; | |
| 15 | import { openIssue } from "../src/actions/issues.ts"; | |
| 16 | import { openPull } from "../src/actions/pulls.ts"; | |
| 17 | import { | |
| 18 | commitToBranch, | |
| 19 | createRepo, | |
| 20 | updateRepoSettings, | |
| 21 | } from "../src/actions/repos.ts"; | |
| 22 | import { getIssueById, type Issue } from "../src/core/issues.ts"; | |
| 23 | import { setOpenPullsCeiling } from "../src/core/pulls_ceiling.ts"; | |
| 24 | import { getRepoById, type Repo } from "../src/core/repos.ts"; | |
| 25 | import { createUser, type User } from "../src/core/users.ts"; | |
| 26 | import { driveRepo } from "../src/crew/autonomy.ts"; | |
| 27 | import { heldNow, heldWords, mapHolds } from "../src/crew/held.ts"; | |
| 28 | import { quietLogs } from "./helpers/globals.ts"; | |
| 29 | ||
| 30 | quietLogs(); | |
| 31 | ||
| 32 | let dataDir: string; | |
| 33 | let app: App; | |
| 34 | let alice: User; | |
| 35 | let repo: Repo; | |
| 36 | let issue: Issue; | |
| 37 | ||
| 38 | const fresh = () => getRepoById(app.db, repo.id)!; | |
| 39 | const count = (sql: string) => | |
| 40 | app.db.query<{ n: number }, [string]>(sql).get(repo.id)!.n; | |
| 41 | const assignments = () => | |
| 42 | count( | |
| 43 | "SELECT COUNT(*) AS n FROM event WHERE repo_id = ?1 AND kind = 'issue.assigned'", | |
| 44 | ); | |
| 45 | const picks = () => | |
| 46 | count( | |
| 47 | "SELECT COUNT(*) AS n FROM decision WHERE repo_id = ?1 AND kind = 'next'", | |
| 48 | ); | |
| 49 | ||
| 50 | beforeAll(async () => { | |
| 51 | dataDir = await mkdtemp(join(tmpdir(), "forge-pull-ceiling-picks-")); | |
| 52 | app = createApp({ dataDir, port: 0 }); | |
| 53 | const a = await createUser(app.db, { | |
| 54 | origin: "seed", | |
| 55 | trusted: true, | |
| 56 | username: "alice", | |
| 57 | email: "[email protected]", | |
| 58 | password: "a-good-passphrase", | |
| 59 | adminIfFirst: true, | |
| 60 | }); | |
| 61 | if (!a.ok) throw new Error(a.error); | |
| 62 | alice = a.value; | |
| 63 | const made = await createRepo(app, alice, { | |
| 64 | name: "notes", | |
| 65 | visibility: "public", | |
| 66 | }); | |
| 67 | if (!made.ok) throw new Error(String(made.error)); | |
| 68 | repo = made.value; | |
| 69 | const first = await commitToBranch(app, alice, repo, { | |
| 70 | message: "Start", | |
| 71 | files: [{ path: "package.json", content: `{"name":"notes"}\n` }], | |
| 72 | }); | |
| 73 | if (!first.ok) throw new Error(JSON.stringify(first.error)); | |
| 74 | const builder = await createAgent(app, alice, { username: "b1" }); | |
| 75 | if (!builder.ok) throw new Error(String(builder.error)); | |
| 76 | expect(addToCrew(app, alice, repo, "b1").ok).toBe(true); | |
| 77 | const on = await updateRepoSettings(app, alice, repo, { | |
| 78 | autonomy: "autonomous", | |
| 79 | autonomyDirection: "Keep the notes tidy.", | |
| 80 | autonomySlots: 1, | |
| 81 | autonomyBy: alice.id, | |
| 82 | }); | |
| 83 | expect(on.ok).toBe(true); | |
| 84 | // One open pull against a ceiling of one: held. | |
| 85 | const branch = await commitToBranch(app, alice, fresh(), { | |
| 86 | branch: "waiting", | |
| 87 | base: "main", | |
| 88 | message: "Waiting", | |
| 89 | files: [{ path: "W.md", content: "w\n" }], | |
| 90 | }); | |
| 91 | if (!branch.ok) throw new Error(JSON.stringify(branch.error)); | |
| 92 | const pull = await openPull(app, alice, fresh(), { | |
| 93 | title: "Waiting for review", | |
| 94 | baseBranch: "main", | |
| 95 | headBranch: "waiting", | |
| 96 | }); | |
| 97 | if (!pull.ok) throw new Error(String(pull.error)); | |
| 98 | setOpenPullsCeiling(app.db, repo.id, 1, alice.id); | |
| 99 | const opened = openIssue(app, alice, fresh(), { title: "Rename a note" }); | |
| 100 | if (!opened.ok) throw new Error(String(opened.error)); | |
| 101 | issue = opened.value; | |
| 102 | }); | |
| 103 | ||
| 104 | afterAll(async () => { | |
| 105 | app.close(); | |
| 106 | await rm(dataDir, { recursive: true, force: true }); | |
| 107 | }); | |
| 108 | ||
| 109 | test("held by the ceiling: on the map, never picked, assigned or recorded, however many turns", async () => { | |
| 110 | const held = heldNow(app, fresh()); | |
| 111 | expect(held.startable).toHaveLength(0); | |
| 112 | expect(heldWords(held)).toContain("pull_ceiling="); | |
| 113 | expect( | |
| 114 | [...mapHolds(fresh(), held).holds.values()].map((h) => h.detail), | |
| 115 | ).toContain("the open-pull ceiling holds: new builds wait for reviews"); | |
| 116 | const [before, recorded] = [assignments(), picks()]; | |
| 117 | for (let turn = 0; turn < 3; turn++) | |
| 118 | expect(await driveRepo(app, fresh())).not.toBe("picked"); | |
| 119 | expect(assignments()).toBe(before); | |
| 120 | expect(picks()).toBe(recorded); | |
| 121 | expect(getIssueById(app.db, issue.id)!.assigneeId).toBeNull(); | |
| 122 | }); | |
| 123 | ||
| 124 | test("under the ceiling the same issue is picked", async () => { | |
| 125 | setOpenPullsCeiling(app.db, repo.id, 0, alice.id); | |
| 126 | expect(heldWords(heldNow(app, fresh()))).not.toContain("pull_ceiling"); | |
| 127 | expect(await driveRepo(app, fresh())).toBe("picked"); | |
| 128 | expect(getIssueById(app.db, issue.id)!.assigneeId).not.toBeNull(); | |
| 129 | }); |
new above
offline
Add the tick hold to docs/features/open-pulls-ceiling.md: the
pull_ceilinghold, what the map says, and that nothing is picked while it holds.