Public: anyone can read this; the crew can change it.

Sentinel: The guard parked 20 runs in trevato/forge in a day #17211

opened this

Merged 41h 52m ago, live in production

mason/forge:mason/17044-sentinel-the-guard-parked-20-runs-in-tre → main 0 commits fork

  • Merged. mason/17044-sentinel-the-guard-parked-20-runs-in-tre was merged into main as f148348.

Review

Sign in to review this change.
2 files changed +18 −3
src/crew/sentinel.ts +4 −2
@@ -256,8 +256,9 @@ export function ledgerStreaks(db: Database, now: number): Finding[] {
256256 lookFor: "A retry decision that is not stop, or a green check after a stop.",
257257 });
258258 }
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).
261262 const parks = new Map<string, Set<string>>();
262263 const skips = new Map<string, number>();
263264 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[] {
265266 skips.set(d.repoId, (skips.get(d.repoId) ?? 0) + 1);
266267 continue;
267268 }
269 if (d.answer !== "capped") continue;
268270 // A cap is one park per issue however often it was asked again.
269271 const set = parks.get(d.repoId) ?? new Set<string>();
270272 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";
2121 import { createRun } from "../src/core/runs.ts";
2222 import { createUser, type User } from "../src/core/users.ts";
2323 import { recordCap } from "../src/crew/guard.ts";
24 import { markRedRouted } from "../src/crew/red_routed.ts";
2425 import { sharedCause } from "../src/checks/shared_red.ts";
2526 import { bugClockAlarm, HIGH_BUG_MS, openBugs } from "../src/flow/bugs.ts";
2627 import {
@@ -372,7 +373,7 @@ describe("the guard", () => {
372373 kind: "guard",
373374 repoId: repo.id,
374375 state: {},
375 answer: "park",
376 answer: "capped",
376377 p: 1,
377378 by: "rule",
378379 ms: 1,
@@ -404,6 +405,18 @@ describe("the guard", () => {
404405 expect(parks()?.title).toContain("parked 20 runs");
405406 expect(parks()?.evidence.join("\n")).toContain("30 skips");
406407 });
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 });
407420 });
408421
409422 describe("a cap", () => {

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs