Public: anyone can read this; the crew can change it.
The engine picks the same issue every tick, is refused because a twin holds it, and starts nothing else #12379
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/12376-the-engine-picks-the-same-issue-every-ti → main 5 commits fork 2 threads · 2 unresolved
9 files
changed +190
−13
src/crew/dispatch.ts +31 −6
| @@ -436,6 +436,28 @@ export function outsideSeat( | ||
| 436 | 436 | export const NOT_A_BUILDER_NOTE = |
| 437 | 437 | "I am not a builder here, so I have not started on this. Assign it to a builder on the crew, or change my roles in Settings."; |
| 438 | 438 | |
| 439 | /** How long a twin refusal stays quiet in the log. */ | |
| 440 | const TWIN_LOG_MS = 3_600_000; | |
| 441 | ||
| 442 | /** | |
| 443 | * Per app, when each issue's twin refusal was last logged; expired entries are dropped as new | |
| 444 | * ones are written. | |
| 445 | */ | |
| 446 | const twinLogged = new WeakMap<App, Map<string, number>>(); | |
| 447 | ||
| 448 | /** | |
| 449 | * Whether the refusal of `issueId` should be logged now; says so once per hour per issue. | |
| 450 | */ | |
| 451 | function twinLogDue(app: App, issueId: string, at: number): boolean { | |
| 452 | let seen = twinLogged.get(app); | |
| 453 | if (seen === undefined) twinLogged.set(app, (seen = new Map())); | |
| 454 | const last = seen.get(issueId); | |
| 455 | if (last !== undefined && at - last < TWIN_LOG_MS) return false; | |
| 456 | for (const [id, t] of seen) if (at - t >= TWIN_LOG_MS) seen.delete(id); | |
| 457 | seen.set(issueId, at); | |
| 458 | return true; | |
| 459 | } | |
| 460 | ||
| 439 | 461 | /** Queue a run about an issue for an agent, unless one is already waiting. */ |
| 440 | 462 | export function queueAgentRun( |
| 441 | 463 | app: App, |
| @@ -564,12 +586,15 @@ export function queueAgentRun( | ||
| 564 | 586 | if (reason === "assigned" && group === undefined) { |
| 565 | 587 | const twin = twinOf(app.db, issue); |
| 566 | 588 | if (twin !== undefined) { |
| 567 | log.info("build run refused: a twin holds the work", { | |
| 568 | repo: `${repo.ownerName}/${repo.name}`, | |
| 569 | issue: issue.number, | |
| 570 | twin: twin.number, | |
| 571 | standing: twin.standing, | |
| 572 | }); | |
| 589 | // One line per issue an hour, not one a tick. | |
| 590 | if (twinLogDue(app, issue.id, Date.now())) { | |
| 591 | log.info("build run refused: a twin holds the work", { | |
| 592 | repo: `${repo.ownerName}/${repo.name}`, | |
| 593 | issue: issue.number, | |
| 594 | twin: twin.number, | |
| 595 | standing: twin.standing, | |
| 596 | }); | |
| 597 | } | |
| 573 | 598 | refusedAsTwin = twin; |
| 574 | 599 | return undefined; |
| 575 | 600 | } |
src/crew/held.ts +26 −1
| @@ -26,6 +26,9 @@ | ||
| 26 | 26 | * Only under ask: a repository on go's builders retry it, bounded by `run_cap`. |
| 27 | 27 | * Never for good: a change in its inputs, or a day, tries it again (`retry.ts`). |
| 28 | 28 | * - `red_fix`: a fix for a red main already covers it (`red_fix.ts`). |
| 29 | * - `twin`: another issue with the same title holds the work: a run going, a | |
| 30 | * pull open, or a pull landed since this one was opened (`twin.ts`). The | |
| 31 | * dispatcher would refuse the build, so the tick never picks it. | |
| 29 | 32 | * - `hot_file`: a file it names is touched by `HOT_PULLS` or more open |
| 30 | 33 | * pulls, or an admin holds it (`file_holds.ts`); it starts when that pile |
| 31 | 34 | * drains under the limit or the hold is released (`hot_files.ts`). |
| @@ -56,6 +59,8 @@ import { heldFiles, type FileHold } from "./file_holds.ts"; | ||
| 56 | 59 | import { expectedFiles, hotFiles, hotOverlap, pullsTouching, relievedFiles } from "./hot_files.ts"; |
| 57 | 60 | import { coveredByRedFix } from "./red_fix.ts"; |
| 58 | 61 | import { landedUnder } from "./stalls.ts"; |
| 62 | import { isShared, sharedTitles, twinOf, type Twin } from "./twin.ts"; | |
| 63 | import { variantGroupOf } from "../core/runs.ts"; | |
| 59 | 64 | |
| 60 | 65 | export const HOLDS = [ |
| 61 | 66 | "running", |
| @@ -68,6 +73,7 @@ export const HOLDS = [ | ||
| 68 | 73 | "run_cap", |
| 69 | 74 | "parked_twice", |
| 70 | 75 | "red_fix", |
| 76 | "twin", | |
| 71 | 77 | "hot_file", |
| 72 | 78 | ] as const; |
| 73 | 79 | |
| @@ -85,6 +91,8 @@ export interface Held { | ||
| 85 | 91 | readonly pinned: ReadonlyMap<number, FileHold>; |
| 86 | 92 | /** Of the `hot_file` ones, those that wait because another issue already relieves the same path: issue number to that path and issue. */ |
| 87 | 93 | readonly relieving: ReadonlyMap<number, { path: string; by: number }>; |
| 94 | /** Of the `twin` ones: issue number to the twin that holds the same work. */ | |
| 95 | readonly twins: ReadonlyMap<number, Twin>; | |
| 88 | 96 | } |
| 89 | 97 | |
| 90 | 98 | export interface LastRun { |
| @@ -187,6 +195,7 @@ export function heldBy( | ||
| 187 | 195 | const hot = hotFiles(repo.id, admit); |
| 188 | 196 | const pins = new Map(heldFiles(app.db, repo.id).map((h) => [h.path, h])); |
| 189 | 197 | const pinned = new Map<number, FileHold>(); |
| 198 | const twins = new Map<number, Twin>(); | |
| 190 | 199 | // The hold an admin set on a file the issue names, if any: the first by hold order. |
| 191 | 200 | const pinOf = (issue: Issue): FileHold | undefined => |
| 192 | 201 | pins.size === 0 ? undefined : expectedFiles(issue).map((f) => pins.get(f)).find((h) => h !== undefined); |
| @@ -231,6 +240,7 @@ export function heldBy( | ||
| 231 | 240 | (i) => runCapOf(repo, i, app.config), |
| 232 | 241 | )); |
| 233 | 242 | const lastRuns = lastAgentRuns(app, ready.map((r) => r.issue.id)); |
| 243 | let shared: Set<string> | undefined; | |
| 234 | 244 | const holdOf = (issue: Issue): HoldName | null => { |
| 235 | 245 | if (busyIssues.has(issue.id)) return "running"; |
| 236 | 246 | if (proposed.has(issue.number)) return "open_pull"; |
| @@ -243,6 +253,16 @@ export function heldBy( | ||
| 243 | 253 | if (!isGo(repo) && parkedCount(app.db, repo, issue.id) >= PARK_STRIKES && retryReason(app.db, repo, issue, now) === undefined) |
| 244 | 254 | return "parked_twice"; |
| 245 | 255 | if (coveredByRedFix(app.db, repo.id, issue)) return "red_fix"; |
| 256 | // Variants share a title on purpose; any other same-title work in hand holds this one. | |
| 257 | // Only a title another issue or pull bears can have a twin: one scan names them. | |
| 258 | shared ??= sharedTitles(app.db, repo.id); | |
| 259 | if (isShared(shared, issue.title) && variantGroupOf(app.db, issue.id) === undefined) { | |
| 260 | const twin = twinOf(app.db, issue); | |
| 261 | if (twin !== undefined) { | |
| 262 | twins.set(issue.number, twin); | |
| 263 | return "twin"; | |
| 264 | } | |
| 265 | } | |
| 246 | 266 | const pin = pinOf(issue); |
| 247 | 267 | if (pin !== undefined) { |
| 248 | 268 | pinned.set(issue.number, pin); |
| @@ -265,7 +285,7 @@ export function heldBy( | ||
| 265 | 285 | if (hold === null) startable.push(r); |
| 266 | 286 | else by[hold].push(r.issue); |
| 267 | 287 | } |
| 268 | return { startable, by, pinned, relieving }; | |
| 288 | return { startable, by, pinned, relieving, twins }; | |
| 269 | 289 | } |
| 270 | 290 | |
| 271 | 291 | /** The count per filter, in `HOLDS` order. */ |
| @@ -335,6 +355,7 @@ const HOLD_WORDS: Readonly<Record<HoldName, string>> = { | ||
| 335 | 355 | run_cap: "it has used its runs for the day", |
| 336 | 356 | parked_twice: "parked twice; it is the planner's", |
| 337 | 357 | red_fix: "a fix for a red main covers it", |
| 358 | twin: "another issue holds the same work", | |
| 338 | 359 | hot_file: "a file it names is hot", |
| 339 | 360 | }; |
| 340 | 361 | |
| @@ -367,6 +388,10 @@ export function mapHolds( | ||
| 367 | 388 | pulls = pullsTouching(repo.id, top.path, admit); |
| 368 | 389 | } |
| 369 | 390 | } |
| 391 | if (name === "twin") { | |
| 392 | const twin = held.twins.get(issue.number); | |
| 393 | if (twin !== undefined) detail = `waits for #${twin.number}, which holds the same work`; | |
| 394 | } | |
| 370 | 395 | holds.set(issue.number, { by: name, detail, ...(pulls === undefined ? {} : { pulls }) }); |
| 371 | 396 | } |
| 372 | 397 | } |
src/crew/twin.ts +17
| @@ -27,6 +27,23 @@ const TWINS_ASKED = 8; | ||
| 27 | 27 | |
| 28 | 28 | const same = (title: string): string => title.trim().toLowerCase(); |
| 29 | 29 | |
| 30 | /** | |
| 31 | * The titles more than one issue or pull of the repository bears, as `twinOf` | |
| 32 | * reads them. No title outside this set has a twin, so a pass over many | |
| 33 | * candidates asks `twinOf` only of the few inside it: one scan, not one per issue. | |
| 34 | */ | |
| 35 | export function sharedTitles(db: Database, repoId: string): Set<string> { | |
| 36 | const rows = db | |
| 37 | .query<{ t: string }, [string]>( | |
| 38 | "SELECT lower(trim(title)) AS t FROM issue WHERE repo_id = ?1 GROUP BY t HAVING count(*) > 1", | |
| 39 | ) | |
| 40 | .all(repoId); | |
| 41 | return new Set(rows.map((r) => r.t)); | |
| 42 | } | |
| 43 | ||
| 44 | /** Whether `title` is one `sharedTitles` names. */ | |
| 45 | export const isShared = (shared: ReadonlySet<string>, title: string): boolean => shared.has(same(title)); | |
| 46 | ||
| 30 | 47 | /** The twin, if any, already holding `issue`'s work: running before open before landed. */ |
| 31 | 48 | export function twinOf(db: Database, issue: Pick<Issue, "id" | "repoId" | "number" | "title" | "createdAt">): Twin | undefined { |
| 32 | 49 | const t = same(issue.title); |
src/flow/why.ts +12
| @@ -29,6 +29,7 @@ export const CAUSES = [ | ||
| 29 | 29 | "wall", |
| 30 | 30 | "ceiling", |
| 31 | 31 | "hot_file", |
| 32 | "twin", | |
| 32 | 33 | "blocked_by", |
| 33 | 34 | "later_gate", |
| 34 | 35 | "no_builder", |
| @@ -45,6 +46,8 @@ export interface WhyFacts { | ||
| 45 | 46 | readonly actor: Actor | null; |
| 46 | 47 | readonly ceilingUsd?: number; |
| 47 | 48 | readonly hotFile?: string; |
| 49 | /** The words of the hold another issue with the same title puts on it. */ | |
| 50 | readonly twin?: string; | |
| 48 | 51 | readonly blockedBy?: readonly number[]; |
| 49 | 52 | readonly laterGate?: string; |
| 50 | 53 | readonly builders?: number; |
| @@ -88,6 +91,13 @@ const RULES: Readonly<Record<CauseName, (f: WhyFacts) => Omit<Cause, "name"> | n | ||
| 88 | 91 | clears: "land or close the open pulls on that file, or release an admin's hold on it.", |
| 89 | 92 | } |
| 90 | 93 | : null, |
| 94 | twin: (f) => | |
| 95 | f.twin !== undefined | |
| 96 | ? { | |
| 97 | says: `Another issue holds the same work: ${f.twin}.`, | |
| 98 | clears: "close this issue as a duplicate, or retitle it if it is different work.", | |
| 99 | } | |
| 100 | : null, | |
| 91 | 101 | blocked_by: (f) => |
| 92 | 102 | f.blockedBy !== undefined && f.blockedBy.length > 0 |
| 93 | 103 | ? { |
| @@ -184,11 +194,13 @@ export function whyIssue(app: App, repo: Repo, issue: Issue, now = new Date()): | ||
| 184 | 194 | const held = heldNow(app, repo); |
| 185 | 195 | const holdOf = mapHolds(repo, held).holds.get(issue.number); |
| 186 | 196 | const hot = holdOf?.by === "hot_file" ? holdOf.detail : undefined; |
| 197 | const twin = holdOf?.by === "twin" ? holdOf.detail : undefined; | |
| 187 | 198 | const later = graph.deferred.get(issue.id); |
| 188 | 199 | return { |
| 189 | 200 | cause: firstCause({ |
| 190 | 201 | actor: "builder", |
| 191 | 202 | ...(hot !== undefined ? { hotFile: hot } : {}), |
| 203 | ...(twin !== undefined ? { twin } : {}), | |
| 192 | 204 | blockedBy: openBlockers, |
| 193 | 205 | ...(later !== undefined ? { laterGate: later } : {}), |
| 194 | 206 | ...sharedFacts(app, repo, now), |
test/boards-held.test.ts +1 −1
| @@ -16,7 +16,7 @@ let app: App; | ||
| 16 | 16 | let alice = ""; |
| 17 | 17 | |
| 18 | 18 | function issue(id: string, repo: string, n: number): void { |
| 19 | app.db.run("INSERT INTO issue (id, repo_id, number, kind, title, body, author_id, state) VALUES (?1, ?2, ?3, 'issue', 't', '', ?4, 'open')", [id, repo, n, alice]); | |
| 19 | app.db.run("INSERT INTO issue (id, repo_id, number, kind, title, body, author_id, state) VALUES (?1, ?2, ?3, 'issue', ?5, '', ?4, 'open')", [id, repo, n, alice, `t ${id}`]); | |
| 20 | 20 | } |
| 21 | 21 | function running(repo: string, issueId: string): void { |
| 22 | 22 | app.db.run("INSERT INTO run (id, repo_id, kind, issue_id, state) VALUES (?1, ?2, 'agent', ?3, 'running')", [`run-${issueId}`, repo, issueId]); |
test/crew-direction-autonomy.test.ts +1 −1
| @@ -360,7 +360,7 @@ describe("a reader's pull from a fork", () => { | ||
| 360 | 360 | ); |
| 361 | 361 | const pull = ok( |
| 362 | 362 | await openPull(app, mallory, repo, { |
| 363 | title: "Rounder corners", | |
| 363 | title: "Rounder corners, mine", | |
| 364 | 364 | body: `Closes #${wanted.number}`, |
| 365 | 365 | baseBranch: "main", |
| 366 | 366 | headBranch: "mine", |
test/held-relieves-map.test.ts +1 −1
| @@ -119,7 +119,7 @@ test("a second issue relieving the same path waits on the one in flight, and the | ||
| 119 | 119 | const repoId = await hotRepo("relieving"); |
| 120 | 120 | const first = open(repoId, TUI); |
| 121 | 121 | createRun(app.db, { repoId, kind: "agent", issueId: first.id }); |
| 122 | const second = open(repoId, TUI); | |
| 122 | const second = open(repoId, { ...TUI, title: `${TUI.title} (again)` }); | |
| 123 | 123 | for (const map of [await apiMap("relieving"), await mcpMap("relieving")]) { |
| 124 | 124 | expect(heldOf(map, first.number)?.by).toBe("running"); |
| 125 | 125 | expect(heldOf(map, second.number)).toEqual({ |
test/mcp-flow-why.test.ts +13
| @@ -26,6 +26,7 @@ describe("the list of causes", () => { | ||
| 26 | 26 | ["wall", { actor: "person", wall: ["anyone signed out could read pack records"] }], |
| 27 | 27 | ["ceiling", { actor: "builder", ceilingUsd: 20 }], |
| 28 | 28 | ["hot_file", { actor: "builder", hotFile: "src/a.ts is in 3 open pulls" }], |
| 29 | ["twin", { actor: "builder", twin: "waits for #3, which holds the same work" }], | |
| 29 | 30 | ["blocked_by", { actor: "builder", blockedBy: [4, 9] }], |
| 30 | 31 | ["later_gate", { actor: "builder", laterGate: "behind the Later gate" }], |
| 31 | 32 | ["no_builder", { actor: "builder", builders: 0 }], |
| @@ -167,6 +168,18 @@ describe("MCP flow with a subject", () => { | ||
| 167 | 168 | expect(r.value.says).toContain("src/pinned.ts"); |
| 168 | 169 | }); |
| 169 | 170 | |
| 171 | test("an issue whose twin has a run going is held by twin, and says which", async () => { | |
| 172 | const first = issueOf("Twin work"); | |
| 173 | const second = issueOf("twin work"); | |
| 174 | const bot = getUserByName(app.db, "bot")!; | |
| 175 | app.db | |
| 176 | .query(`INSERT INTO run (id, repo_id, kind, issue_id, actor_id, state) VALUES (?1, ?2, 'agent', ?3, ?4, 'running')`) | |
| 177 | .run(crypto.randomUUID(), repo.id, first.id, bot.id); | |
| 178 | const r = await call(ownerTok, { repo: "alice/one", issue: second.number }); | |
| 179 | expect(r.value).toMatchObject({ moving: false, cause: "twin" }); | |
| 180 | expect(r.value.says).toContain(`#${first.number}`); | |
| 181 | }); | |
| 182 | ||
| 170 | 183 | test("an issue filed under Later is held by later_gate, not blocked_by", async () => { |
| 171 | 184 | const gate = issueOf("Later gate: not yet"); |
| 172 | 185 | const umbrella = issueOf("Later: someday"); |
test/twin-runs.test.ts +88 −3
| @@ -3,7 +3,7 @@ | ||
| 3 | 3 | * issue whose twin (same title) has a run going, a pull open or a pull |
| 4 | 4 | * merged is refused; and wasted runs are counted per day. |
| 5 | 5 | */ |
| 6 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 6 | import { afterAll, beforeAll, describe, expect, spyOn, test } from "bun:test"; | |
| 7 | 7 | import { mkdtemp, rm } from "node:fs/promises"; |
| 8 | 8 | import { tmpdir } from "node:os"; |
| 9 | 9 | import { join } from "node:path"; |
| @@ -13,9 +13,13 @@ import { assignIssue, openIssue } from "../src/actions/issues.ts"; | ||
| 13 | 13 | import { createRepo } from "../src/actions/repos.ts"; |
| 14 | 14 | import { getRepoById, type Repo } from "../src/core/repos.ts"; |
| 15 | 15 | import { createUser, getUserByName, type User } from "../src/core/users.ts"; |
| 16 | import { createIssue, listComments, type Issue } from "../src/core/issues.ts"; | |
| 17 | import { sweepAssigned } from "../src/crew/dispatch.ts"; | |
| 16 | import { createIssue, getIssueById, listComments, type Issue } from "../src/core/issues.ts"; | |
| 17 | import { queueAgentRun, sweepAssigned } from "../src/crew/dispatch.ts"; | |
| 18 | import { getAgent } from "../src/core/agents.ts"; | |
| 19 | import { heldNow, mapHolds } from "../src/crew/held.ts"; | |
| 18 | 20 | import { twinOf } from "../src/crew/twin.ts"; |
| 21 | import { once } from "./helpers/statements.ts"; | |
| 22 | import { expectWork } from "./helpers/work.ts"; | |
| 19 | 23 | import { isWasted, wastedDays } from "../src/core/wasted_days.ts"; |
| 20 | 24 | |
| 21 | 25 | describe("twins", () => { |
| @@ -106,6 +110,24 @@ describe("twins", () => { | ||
| 106 | 110 | expect(twinOf(app.db, again)?.standing).toBe("landed"); |
| 107 | 111 | }); |
| 108 | 112 | |
| 113 | test("a twin-held issue is held under its own reason, and the free one stays startable", () => { | |
| 114 | const first = open("Harbour light"); | |
| 115 | const twin = open("Harbour light"); | |
| 116 | const free = open("Quite another job"); | |
| 117 | assign(first); | |
| 118 | sweepAssigned(app); | |
| 119 | const held = heldNow(app, fresh()); | |
| 120 | const nums = held.startable.map((r) => r.issue.number); | |
| 121 | expect(nums).not.toContain(twin.number); | |
| 122 | expect(nums).toContain(free.number); | |
| 123 | expect(held.by.twin.map((i) => i.number)).toContain(twin.number); | |
| 124 | const { holds } = mapHolds(fresh(), held); | |
| 125 | expect(holds.get(twin.number)).toMatchObject({ | |
| 126 | by: "twin", | |
| 127 | detail: `waits for #${first.number}, which holds the same work`, | |
| 128 | }); | |
| 129 | }); | |
| 130 | ||
| 109 | 131 | test("a pull titled the same stands in front, and a different title does not", () => { |
| 110 | 132 | const dup = open("Domino Run"); |
| 111 | 133 | pullOn("Domino Run", "bot/unrelated", true); |
| @@ -142,6 +164,69 @@ describe("twins", () => { | ||
| 142 | 164 | expect(said[0]!.authorId).toBe(bot.id); |
| 143 | 165 | }); |
| 144 | 166 | |
| 167 | test("the twin refusal is logged once an hour per issue, and again when the hour is up", () => { | |
| 168 | const first = open("Beacon"); | |
| 169 | assign(first); | |
| 170 | sweepAssigned(app); | |
| 171 | const second = open("Beacon"); | |
| 172 | const lines: string[] = []; | |
| 173 | const spy = spyOn(console, "info").mockImplementation((msg: string) => { | |
| 174 | if (String(msg).includes("a twin holds the work")) lines.push(String(msg)); | |
| 175 | }); | |
| 176 | const realNow = Date.now; | |
| 177 | let clock = realNow(); | |
| 178 | Date.now = () => clock; | |
| 179 | try { | |
| 180 | const agent = getAgent(app.db, bot.id)!; | |
| 181 | queueAgentRun(app, fresh(), second, agent, "assigned"); | |
| 182 | queueAgentRun(app, fresh(), second, agent, "assigned"); | |
| 183 | expect(lines).toHaveLength(1); | |
| 184 | clock += 3_600_001; | |
| 185 | queueAgentRun(app, fresh(), second, agent, "assigned"); | |
| 186 | expect(lines).toHaveLength(2); | |
| 187 | } finally { | |
| 188 | Date.now = realNow; | |
| 189 | spy.mockRestore(); | |
| 190 | } | |
| 191 | }); | |
| 192 | ||
| 193 | test("a variant-group issue sharing a title is not held as a twin", () => { | |
| 194 | const first = open("Mosaic"); | |
| 195 | assign(first); | |
| 196 | sweepAssigned(app); | |
| 197 | const variant = open("Mosaic"); | |
| 198 | app.db | |
| 199 | .query( | |
| 200 | `INSERT INTO run (id, repo_id, kind, issue_id, actor_id, state, variant_group) | |
| 201 | VALUES (?1, ?2, 'agent', ?3, ?4, 'ok', 'try-1')`, | |
| 202 | ) | |
| 203 | .run(crypto.randomUUID(), repo.id, variant.id, bot.id); | |
| 204 | expect(twinOf(app.db, variant)?.number).toBe(first.number); | |
| 205 | const held = heldNow(app, fresh()); | |
| 206 | expect(held.by.twin.map((i) => i.number)).not.toContain(variant.number); | |
| 207 | }); | |
| 208 | ||
| 209 | test("the twin hold stays cheap with hundreds of open issues", async () => { | |
| 210 | for (let i = 0; i < 400; i++) open(`Bulk job ${i}`); | |
| 211 | const all = app.db | |
| 212 | .query<{ id: string }, [string]>("SELECT id FROM issue WHERE repo_id = ?1 AND kind = 'issue' AND state = 'open'") | |
| 213 | .all(repo.id) | |
| 214 | .map((r) => getIssueById(app.db, r.id)!); | |
| 215 | const perIssue = await once(app.db, () => { | |
| 216 | for (const i of all) twinOf(app.db, i); | |
| 217 | }); | |
| 218 | console.log(`twinOf over ${all.length} open issues: ${perIssue} statements`); | |
| 219 | expectWork(perIssue / all.length, { max: 3 }); | |
| 220 | // The pass itself asks twinOf only of titles that repeat: none of the 400 added do. | |
| 221 | let held!: ReturnType<typeof heldNow>; | |
| 222 | const pass = await once(app.db, () => { | |
| 223 | held = heldNow(app, fresh()); | |
| 224 | }); | |
| 225 | console.log(`heldNow over ${all.length} open issues: ${pass} statements`); | |
| 226 | expect(held.by.twin.length).toBeLessThan(20); | |
| 227 | expectWork(pass, { max: 5 * all.length }); | |
| 228 | }); | |
| 229 | ||
| 145 | 230 | test("an issue's own pull, though titled the same, is not its twin", () => { |
| 146 | 231 | const mine = open("Own pull"); |
| 147 | 232 | pullOn("Own pull", `bot/${mine.number}-own-pull`); |
new above
offline
twinOf runs per candidate per tick and per map render; show it stays cheap, and test the variantGroupOf exemption.