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

Sentinel: The guard parked 62 runs in trevato/forge in a day #17324

opened this

Merged 41h 19m ago, live in production

mason/forge:mason/17233-sentinel-the-guard-parked-62-runs-in-tre → main 0 commits fork 1 thread · 1 unresolved

  • Merged. mason/17233-sentinel-the-guard-parked-62-runs-in-tre was merged into main as 237edd2.

Review

Sign in to review this change.
2 files changed +19 −4
src/crew/guard.ts +6 −2
@@ -146,6 +146,8 @@ function capFrom(db: Database, repo: Repo, issue: Issue, now: Date): string {
146146 * bring-up-to-date is released after `CHECK_FAILED_LIMIT` tries, and a red is
147147 * reworked until the same red comes back after a rework (`sameRedTwice`), where
148148 * the pull waits, open — counted here too, they parked pulls that were working.
149 * A run that pushed landed work, which is what the cap's note says the issue
150 * lacked: a push is progress, not a loop (the hand-over bounds a pull's rounds).
149151 */
150152 export function capReached(
151153 db: Database,
@@ -161,7 +163,8 @@ export function capReached(
161163 AND attempt = 0
162164 AND reason NOT IN ('review', 'conflict', 'check_failed')
163165 AND summary NOT LIKE 'interrupted: %'
164 AND summary NOT LIKE 'skipped: %'`,
166 AND summary NOT LIKE 'skipped: %'
167 AND (pushed IS NULL OR pushed = 0)`,
165168 )
166169 .get(issue.id, capFrom(db, repo, issue, now));
167170 return (row?.n ?? 0) >= cap;
@@ -613,7 +616,8 @@ export function capReachedFor(
613616 AND attempt = 0
614617 AND reason NOT IN ('review', 'conflict', 'check_failed')
615618 AND summary NOT LIKE 'interrupted: %'
616 AND summary NOT LIKE 'skipped: %'`,
619 AND summary NOT LIKE 'skipped: %'
620 AND (pushed IS NULL OR pushed = 0)`,

Nit: align this line with the AND clauses above it (12 spaces).

617621 )
618622 .all(windowStart, ...ids))
619623 if (r.created_at > (from.get(r.issue_id) ?? windowStart))
test/crew-guard-cap.test.ts +13 −2
@@ -22,6 +22,7 @@ import {
2222 CAP_WINDOW_MS,
2323 capNoted,
2424 capReached,
25 capReachedFor,
2526 quoteCut,
2627 } from "../src/crew/guard.ts";
2728 import { quietLogs } from "./helpers/globals.ts";
@@ -58,7 +59,7 @@ function issueOf(): Issue {
5859 }
5960
6061 /** A run on `issue` started `ms` after T0. */
61 function run(issue: Issue, ms: number, reason = "assigned", summary = "done") {
62 function run(issue: Issue, ms: number, reason = "assigned", summary = "done", pushed?: boolean) {
6263 const r = createRun(app.db, {
6364 repoId: repo.id,
6465 kind: "agent",
@@ -67,7 +68,7 @@ function run(issue: Issue, ms: number, reason = "assigned", summary = "done") {
6768 reason,
6869 });
6970 claimRun(app.db, r.id);
70 finishRun(app.db, r.id, { state: "ok", summary, costUsd: 0 });
71 finishRun(app.db, r.id, { state: "ok", summary, costUsd: 0, ...(pushed === undefined ? {} : { pushed }) });
7172 app.db
7273 .query("UPDATE run SET created_at = ?1 WHERE id = ?2")
7374 .run(at(ms).toISOString(), r.id);
@@ -160,6 +161,16 @@ describe("capReached", () => {
160161 expect(reached(issue)).toBe(true);
161162 });
162163
164 test("a run that pushed landed work and is not a start", () => {
165 const issue = issueOf();
166 for (let n = 0; n < CAP + 2; n++) run(issue, n, "feedback", "done", true);
167 expect(reached(issue)).toBe(false);
168 expect(capReachedFor(app.db, repo, [issue], () => CAP, at(HOUR)).get(issue.id)).toBe(false);
169 for (let n = 0; n < CAP; n++) run(issue, 10 + n, "feedback", "done", false);
170 expect(reached(issue)).toBe(true);
171 expect(capReachedFor(app.db, repo, [issue], () => CAP, at(HOUR)).get(issue.id)).toBe(true);
172 });
173
163174 test("a director's word restarts the count; a reader's does not", () => {
164175 const issue = issueOf();
165176 for (let n = 0; n < CAP; n++) run(issue, n);

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

Keyboard shortcuts

Docs