Public: anyone can read this; the crew can change it.
Full suite red: 4 files in check run 01m83drzfzryz185dqehnwska1 #15892
Check · Review · Land · Live done — Landed and live in production.
torque/forge:torque/15889-full-suite-red-4-files-in-check-run-01m8 → main 0 commits fork 4 threads · 4 unresolved
5 files
changed +109
−10
src/core/pulls_ceiling.ts +10 −3
| @@ -23,7 +23,15 @@ const key = (repoId: string) => `crew.openPullsCeiling.${repoId}`; | ||
| 23 | 23 | |
| 24 | 24 | export function openPullsCeiling(db: Database, repoId: string): number { |
| 25 | 25 | const row = db.query<{ value: string }, [string]>("SELECT value FROM forge_setting WHERE key = ?1").get(key(repoId)); |
| 26 | const n = row === null ? NaN : Number(row.value); | |
| 26 | return ceilingOf(row?.value); | |
| 27 | } | |
| 28 | ||
| 29 | /** | |
| 30 | * A stored ceiling as a number: a missing or invalid row is the default. The one parser both | |
| 31 | * readers use. | |
| 32 | */ | |
| 33 | export function ceilingOf(stored: string | null | undefined): number { | |
| 34 | const n = stored == null ? NaN : Number(stored); | |
| 27 | 35 | return Number.isInteger(n) && n >= 0 ? n : DEFAULT_PULLS_CEILING; |
| 28 | 36 | } |
| 29 | 37 | |
| @@ -49,8 +57,7 @@ export function pullsCeilingHold(db: Database, repoId: string): string | null { | ||
| 49 | 57 | (SELECT COUNT(*) FROM issue WHERE repo_id = ?2 AND kind = 'pull' AND state = 'open') AS open`, |
| 50 | 58 | ) |
| 51 | 59 | .get(key(repoId), repoId); |
| 52 | const n = row?.value == null ? NaN : Number(row.value); | |
| 53 | const ceiling = Number.isInteger(n) && n >= 0 ? n : DEFAULT_PULLS_CEILING; | |
| 60 | const ceiling = ceilingOf(row?.value); | |
| 54 | 61 | if (ceiling === 0) return null; |
| 55 | 62 | const open = row?.open ?? 0; |
| 56 | 63 | return open >= ceiling ? pullsPausedWords(open, ceiling) : null; |
src/crew/knobs.ts +3 −2
| @@ -98,15 +98,16 @@ function sizeRow(id: "boxes" | "chars", name: string, key: "issue.maxBoxes" | "i | ||
| 98 | 98 | const def = CAPACITY[key]; |
| 99 | 99 | const kind = def.kind; |
| 100 | 100 | if (kind.type !== "count") throw new Error(`${key} is a count`); |
| 101 | const value = capacityValue(app.db, key); // one read: the row shows it and its effect words it | |
| 101 | 102 | return { |
| 102 | 103 | id, |
| 103 | 104 | name, |
| 104 | 105 | does: `An open issue over this is handed to the planner to split before a builder starts it. Why: ${def.reason}`, |
| 105 | value: capacityValue(app.db, key), | |
| 106 | value, | |
| 106 | 107 | control: "number", |
| 107 | 108 | min: kind.min, |
| 108 | 109 | max: kind.max, |
| 109 | effect: effectOf(app, key, capacityValue(app.db, key)), | |
| 110 | effect: effectOf(app, key, value), | |
| 110 | 111 | }; |
| 111 | 112 | } |
| 112 | 113 |
src/perf/page_budgets/next.ts +1 −1
| @@ -1,3 +1,3 @@ | ||
| 1 | 1 | import type { PageBudget } from "../page_budget.ts"; |
| 2 | 2 | |
| 3 | export const budget: PageBudget = { page: "next up", pattern: "/:owner/:name/next", medianMs: 50, statements: 68 }; | |
| 3 | export const budget: PageBudget = { page: "next up", pattern: "/:owner/:name/next", medianMs: 50, statements: 70 }; |
test/merged-reads.test.ts added +91
| @@ -0,0 +1,91 @@ | ||
| 1 | /** | |
| 2 | * Two reads merged into one statement keep the fallbacks of the reads they replaced: | |
| 3 | * `limitsOf` falls back like `capacityValue`, `pullsCeilingHold` like `openPullsCeiling`. | |
| 4 | */ | |
| 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 6 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 7 | import { tmpdir } from "node:os"; | |
| 8 | import { join } from "node:path"; | |
| 9 | import { createRepo } from "../src/actions/repos.ts"; | |
| 10 | import { createUser } from "../src/core/users.ts"; | |
| 11 | import { createApp, type App } from "../src/app.ts"; | |
| 12 | import { capacityValue } from "../src/core/capacity.ts"; | |
| 13 | import { ceilingOf, DEFAULT_PULLS_CEILING, pullsCeilingHold } from "../src/core/pulls_ceiling.ts"; | |
| 14 | import { limitsOf } from "../src/crew/too_large.ts"; | |
| 15 | ||
| 16 | let dataDir: string; | |
| 17 | let app: App; | |
| 18 | ||
| 19 | beforeAll(async () => { | |
| 20 | dataDir = await mkdtemp(join(tmpdir(), "forge-merged-reads-")); | |
| 21 | app = createApp({ dataDir, port: 0 }); | |
| 22 | }); | |
| 23 | afterAll(async () => { | |
| 24 | app.db.close(); | |
| 25 | await rm(dataDir, { recursive: true, force: true }); | |
| 26 | }); | |
| 27 | ||
| 28 | const put = (key: string, value: string) => | |
| 29 | app.db.query("INSERT OR REPLACE INTO forge_setting (key, value, updated_by, updated_at) VALUES (?1, ?2, 'test', '2026-01-01T00:00:00.000Z')").run(key, value); | |
| 30 | const drop = (key: string) => app.db.query("DELETE FROM forge_setting WHERE key = ?1").run(key); | |
| 31 | ||
| 32 | test("limitsOf: missing rows are the defaults, a stored count is read, an invalid one falls back as capacityValue does", () => { | |
| 33 | drop("issue.maxBoxes"); drop("issue.maxChars"); | |
| 34 | expect(limitsOf(app.db)).toEqual({ boxes: 12, chars: 6000 }); | |
| 35 | put("issue.maxBoxes", "20"); | |
| 36 | expect(limitsOf(app.db).boxes).toBe(20); | |
| 37 | for (const bad of ["abc", "0", "101", "-3", "1.5", ""]) { | |
| 38 | put("issue.maxBoxes", bad); put("issue.maxChars", bad); | |
| 39 | const l = limitsOf(app.db); | |
| 40 | expect(l.boxes).toBe(Number(capacityValue(app.db, "issue.maxBoxes"))); | |
| 41 | expect(l.chars).toBe(Number(capacityValue(app.db, "issue.maxChars"))); | |
| 42 | expect(l).toEqual({ boxes: 12, chars: 6000 }); | |
| 43 | } | |
| 44 | }); | |
| 45 | ||
| 46 | test("ceilingOf: one parser, a missing or invalid row is the default, 0 is off", () => { | |
| 47 | expect(ceilingOf(undefined)).toBe(DEFAULT_PULLS_CEILING); | |
| 48 | expect(ceilingOf(null)).toBe(DEFAULT_PULLS_CEILING); | |
| 49 | expect(ceilingOf("x")).toBe(DEFAULT_PULLS_CEILING); | |
| 50 | expect(ceilingOf("-1")).toBe(DEFAULT_PULLS_CEILING); | |
| 51 | expect(ceilingOf("0")).toBe(0); | |
| 52 | expect(ceilingOf("7")).toBe(7); | |
| 53 | }); | |
| 54 | ||
| 55 | test("pullsCeilingHold: no row with no pulls is not held; a 0 ceiling never holds; at or over a ceiling it says so", async () => { | |
| 56 | const u = await createUser(app.db, { | |
| 57 | origin: "seed", trusted: true, username: "alice", email: "[email protected]", | |
| 58 | password: "a-good-passphrase", adminIfFirst: true, | |
| 59 | }); | |
| 60 | if (!u.ok) throw new Error(u.error); | |
| 61 | const made = await createRepo(app, u.value, { name: "notes", visibility: "public" }); | |
| 62 | if (!made.ok) throw new Error(String(made.error)); | |
| 63 | const repoId = made.value.id; | |
| 64 | const key = `crew.openPullsCeiling.${repoId}`; | |
| 65 | const owner = u.value; | |
| 66 | drop(key); | |
| 67 | expect(pullsCeilingHold(app.db, repoId)).toBeNull(); | |
| 68 | const open = (n: number) => { | |
| 69 | app.db.query("DELETE FROM issue WHERE repo_id = ?1 AND kind = 'pull'").run(repoId); | |
| 70 | for (let i = 0; i < n; i++) { | |
| 71 | app.db.query("INSERT INTO issue (id, repo_id, number, kind, state, title, body, author_id, created_at, updated_at) VALUES (?1, ?2, ?3, 'pull', 'open', 't', '', ?4, '2026-01-01', '2026-01-01')").run(`i-${i}`, repoId, i + 100, owner.id); | |
| 72 | } | |
| 73 | }; | |
| 74 | try { | |
| 75 | open(DEFAULT_PULLS_CEILING); | |
| 76 | expect(pullsCeilingHold(app.db, repoId)).toBe(`paused: ${DEFAULT_PULLS_CEILING} of ${DEFAULT_PULLS_CEILING} pulls open`); | |
| 77 | put(key, "0"); | |
| 78 | expect(pullsCeilingHold(app.db, repoId)).toBeNull(); | |
| 79 | put(key, "3"); | |
| 80 | open(2); | |
| 81 | expect(pullsCeilingHold(app.db, repoId)).toBeNull(); | |
| 82 | open(3); | |
| 83 | expect(pullsCeilingHold(app.db, repoId)).toBe("paused: 3 of 3 pulls open"); | |
| 84 | open(5); | |
| 85 | expect(pullsCeilingHold(app.db, repoId)).toBe("paused: 5 of 3 pulls open"); | |
| 86 | put(key, "junk"); | |
| 87 | expect(pullsCeilingHold(app.db, repoId)).toBeNull(); | |
| 88 | } finally { | |
| 89 | app.db.query("DELETE FROM issue WHERE repo_id = ?1 AND kind = 'pull'").run(repoId); | |
| 90 | } | |
| 91 | }); |
test/pages-budget.test.ts +4 −4
| @@ -55,13 +55,13 @@ const DEFAULT = { statements: 60, git: 8 }; | ||
| 55 | 55 | /** Pages that cost more today, with the most they may: lower these, never raise them. */ |
| 56 | 56 | const HEAVIER: Record<string, { statements?: number; git?: number }> = { |
| 57 | 57 | "/:owner/:name/issues/:number": { statements: 71 }, // +1: whether the repository is archived, so its pages say noindex (#14305) |
| 58 | "/:owner/:name/next": { statements: 67 }, // +1: whether the repository is archived (#14305); +1: the wallet row, one read of the monthly cap (#13529); +1: the growth line, one read for the week, the open counts and the planner pause (#12290, #12867) | |
| 59 | "/:owner/:name/pulls/:number": { statements: 116 }, // +1: whether the reports door is closed, one primary-key read per request, never from memory (#15053); +1: whether the repository is archived (#14305); +1: the desk hold on the pull, one read of the notes that link it (#12536); +1: whether a repository is the forge's own copy, one read of the source setting for the tell box (#12037); +1: the paused sentence, one read of a queued paused run on the pull (#12010); +1: the header Talk count (#10327); +1: the landing line (#10860); +1: whether a reviewer is seated, read only when Require review is off and the pull would otherwise wait on one; the page loads no crew besides (#11666) | |
| 58 | "/:owner/:name/next": { statements: 70 }, // to lower: #15940; +1: the size limits of held issues, one read of both (#15845); +2: the waiting outsider reports, the decider check and the list (#15840); +1: whether the repository is archived (#14305); +1: the wallet row, one read of the monthly cap (#13529); +1: the growth line, one read for the week, the open counts and the planner pause (#12290, #12867) | |
| 59 | "/:owner/:name/pulls/:number": { statements: 117 }, // to lower: #15941; +1: what a green pull waits for (#15812); +1: whether the reports door is closed, one primary-key read per request, never from memory (#15053); +1: whether the repository is archived (#14305); +1: the desk hold on the pull, one read of the notes that link it (#12536); +1: whether a repository is the forge's own copy, one read of the source setting for the tell box (#12037); +1: the paused sentence, one read of a queued paused run on the pull (#12010); +1: the header Talk count (#10327); +1: the landing line (#10860); +1: whether a reviewer is seated, read only when Require review is off and the pull would otherwise wait on one; the page loads no crew besides (#11666) | |
| 60 | 60 | "/api/v1/asks": { statements: 61 }, // +1: the stopped apps someone asked for, one read of the viewer's archived repositories (#12277) |
| 61 | 61 | "/board": { statements: 72 }, // +1: the forge-copy read for the tell box (#12037); +1: the vitals read the database's growth (#12025); +6: the money line (#510) — one settings read, then the month's and the 30 days' meter, storage and ledger reads; constant in the number of apps |
| 62 | 62 | "/settings/capacity": { statements: 70 }, |
| 63 | "/maintenance": { statements: 96 }, // +3: account-purge (#15620); +3: daily-proof (#15625); +3: deepsec-sweep (#15026); +3: edge-kept (#14682), one more duty reading its own state; +1: every duty's last run in one query (#14674); +1: quieted findings (#14557); +1: the findings fold (#14577); +5: slow-tests (#13966); +3: untested-sources (#14125) and the dismissal query (#13967); +4: flaky-tests (#13937), red apps (#13938), chapter stall (#14057), dead-doc-paths (#13977); +3: stale-branches (#14141) — each reads its own state and runs | |
| 64 | "/api/v1/maintenance/duties": { statements: 78 }, // the same duties as JSON; slow-tests (#13966), stale-branches (#14141), edge-kept (#14682), deepsec-sweep (#15026), daily-proof (#15625) and account-purge (#15620) each add 3 | |
| 63 | "/maintenance": { statements: 99 }, // +3: account-purge (#15620); +3: daily-proof (#15625); +3: deepsec-sweep (#15026); +3: edge-kept (#14682), one more duty reading its own state; +1: every duty's last run in one query (#14674); +1: quieted findings (#14557); +1: the findings fold (#14577); +5: slow-tests (#13966); +3: untested-sources (#14125) and the dismissal query (#13967); +4: flaky-tests (#13937), red apps (#13938), chapter stall (#14057), dead-doc-paths (#13977); +3: stale-branches (#14141); +3: v1-probe (#15652) — each reads its own state and runs | |
| 64 | "/api/v1/maintenance/duties": { statements: 81 }, // the same duties as JSON; slow-tests (#13966), stale-branches (#14141), edge-kept (#14682), deepsec-sweep (#15026), daily-proof (#15625) account-purge (#15620) and v1-probe (#15652) each add 3 | |
| 65 | 65 | }; |
| 66 | 66 | |
| 67 | 67 | /** Patterns with no fixture today: lower this as fixtures are added, never raise it silently. */ |
new above
offline