Public: anyone can read this; the crew can change it.
Sentinel: The guard parked 20 runs in trevato/forge in a day #17211
Merged 41h 52m ago, live in production
mason/forge:mason/17044-sentinel-the-guard-parked-20-runs-in-tre → main 0 commits fork
2 files
changed +18
−3
src/crew/sentinel.ts +4 −2
| @@ -256,8 +256,9 @@ export function ledgerStreaks(db: Database, now: number): Finding[] { | ||
| 256 | 256 | lookFor: "A retry decision that is not stop, or a green check after a stop.", |
| 257 | 257 | }); |
| 258 | 258 | } |
| 259 | // A skip is a run the guard saved — nothing new to act on — not a run it | |
| 260 | // refused; only the decisions that parked work are counted. | |
| 259 | // A skip is a run the guard saved — nothing new to act on — and a `routed` | |
| 260 | // row only marks a failed run as decided (red_routed.ts); neither refused a | |
| 261 | // run. Only a cap, which parks an issue, is counted (#17044). | |
| 261 | 262 | const parks = new Map<string, Set<string>>(); |
| 262 | 263 | const skips = new Map<string, number>(); |
| 263 | 264 | for (const d of decisionsSince(db, "guard", new Date(now - DAY_MS).toISOString())) { |
| @@ -265,6 +266,7 @@ export function ledgerStreaks(db: Database, now: number): Finding[] { | ||
| 265 | 266 | skips.set(d.repoId, (skips.get(d.repoId) ?? 0) + 1); |
| 266 | 267 | continue; |
| 267 | 268 | } |
| 269 | if (d.answer !== "capped") continue; | |
| 268 | 270 | // A cap is one park per issue however often it was asked again. |
| 269 | 271 | const set = parks.get(d.repoId) ?? new Set<string>(); |
| 270 | 272 | set.add(d.issueId ?? d.id); |
test/sentinel.test.ts +14 −1
| @@ -21,6 +21,7 @@ import { getRepoById, type Repo } from "../src/core/repos.ts"; | ||
| 21 | 21 | import { createRun } from "../src/core/runs.ts"; |
| 22 | 22 | import { createUser, type User } from "../src/core/users.ts"; |
| 23 | 23 | import { recordCap } from "../src/crew/guard.ts"; |
| 24 | import { markRedRouted } from "../src/crew/red_routed.ts"; | |
| 24 | 25 | import { sharedCause } from "../src/checks/shared_red.ts"; |
| 25 | 26 | import { bugClockAlarm, HIGH_BUG_MS, openBugs } from "../src/flow/bugs.ts"; |
| 26 | 27 | import { |
| @@ -372,7 +373,7 @@ describe("the guard", () => { | ||
| 372 | 373 | kind: "guard", |
| 373 | 374 | repoId: repo.id, |
| 374 | 375 | state: {}, |
| 375 | answer: "park", | |
| 376 | answer: "capped", | |
| 376 | 377 | p: 1, |
| 377 | 378 | by: "rule", |
| 378 | 379 | ms: 1, |
| @@ -404,6 +405,18 @@ describe("the guard", () => { | ||
| 404 | 405 | expect(parks()?.title).toContain("parked 20 runs"); |
| 405 | 406 | expect(parks()?.evidence.join("\n")).toContain("30 skips"); |
| 406 | 407 | }); |
| 408 | ||
| 409 | test("a red marked routed is bookkeeping, not a park (#17044)", () => { | |
| 410 | app.db.query("DELETE FROM decision WHERE kind = 'guard'").run(); | |
| 411 | for (let n = 0; n < 40; n++) { | |
| 412 | const r = createIssue(app.db, { repoId: repo.id, authorId: alice.id, title: `red ${n}` }); | |
| 413 | if (!r.ok) throw new Error("issue"); | |
| 414 | markRedRouted(app.db, repo.id, r.value.id, `run-${n}`); | |
| 415 | } | |
| 416 | expect( | |
| 417 | findFaults(app.db, Date.now()).find((x) => x.key === `parks:${repo.id}`), | |
| 418 | ).toBeUndefined(); | |
| 419 | }); | |
| 407 | 420 | }); |
| 408 | 421 | |
| 409 | 422 | describe("a cap", () => { |
new above
offline