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

Sentinel: Crew runs in trevato/deal-clock keep failing at the push or the sandbox #18076

opened this

Merged 11h 57m ago, live in production

mason/forge:mason/18068-sentinel-crew-runs-in-trevato-deal-clock → main 0 commits fork

  • Merged. mason/18068-sentinel-crew-runs-in-trevato-deal-clock was merged into main as a98d939.

Review

Sign in to review this change.
3 files changed +59 −0
src/crew/interrupted.ts +8
@@ -25,6 +25,14 @@ const RESTART =
2525 // out: the run never reached the agent (#6263).
2626 const CLONE = /^(?:clone|checkout|fetch(?: from the fork)?) failed:/i;
2727
28 /**
29 * Whether the summary was written by `interruptedSummary`: the provider or forge cut the run short,
30 * no push failed.
31 */
32 export function isInterruptedSummary(summary: string): boolean {
33 return summary.trim().startsWith(INTERRUPTED);
34 }
35
2836 /**
2937 * Why a run that ended without a pull was cut short, read from its summary
3038 * — one written by `interruptedSummary`, or an older one that names a
src/crew/sentinel.ts +4
@@ -35,6 +35,7 @@ import { createLog, recentErrors, redactSecrets, type ErrorLedger } from "../ker
3535 import { spans } from "../kernel/degraded_history.ts";
3636 import { QUEUE_AGENT_FULL, QUEUE_CHECK_FULL, QUEUE_WAIT_MAX_MS } from "../kernel/vitals.ts";
3737 import { STALE_AFTER_MS } from "../runs/lease.ts";
38 import { isInterruptedSummary } from "./interrupted.ts";
3839 import { isOutageSummary } from "./network.ts";
3940 import {
4041 assertionLines,
@@ -457,6 +458,8 @@ export function runStreaks(db: Database): Finding[] {
457458 // whether or not the summary leads with it.
458459 // An outage the runner retried ("no changes pushed: ... EAI_AGAIN") is not a
459460 // push that was refused; a "push failed: ... ECONNREFUSED" still counts.
461 // A run the provider cut short ("interrupted: provider limit, resumes ... — no changes
462 // pushed: API Error: 402") resumes by itself: nothing was pushed because nothing was tried.
460463 // A person's pull whose branch lives in the repository itself is left with them on
461464 // purpose (#16356): the runner's own decision, not a push that broke.
462465 const pushes = failed.filter(
@@ -464,6 +467,7 @@ export function runStreaks(db: Database): Finding[] {
464467 !/\bdeclined:/i.test(r.summary) &&
465468 !/branch lives in the repository itself/i.test(r.summary) &&
466469 !isOutageSummary(r.summary) &&
470 !isInterruptedSummary(r.summary) &&
467471 /\bpush|sandbox|operation not permitted/i.test(r.summary),
468472 );
469473 if (pushes.length < STREAK) continue;
test/sentinel-interrupted.test.ts added +47
@@ -0,0 +1,47 @@
1 // #18068: a run the provider cut short ("interrupted: ... — no changes pushed: API Error: 402")
2 // is not a push that failed; the sentinel must not file it as one.
3 import { afterAll, beforeAll, expect, test } from "bun:test";
4 import { mkdtemp, rm } from "node:fs/promises";
5 import { tmpdir } from "node:os";
6 import { join } from "node:path";
7 import { quietLogs } from "./helpers/globals.ts";
8 import { createApp, type App } from "../src/app.ts";
9 import { createRepo } from "../src/actions/repos.ts";
10 import { createRun } from "../src/core/runs.ts";
11 import { createUser } from "../src/core/users.ts";
12 import { findFaults } from "../src/crew/sentinel.ts";
13
14 quietLogs();
15
16 let app: App;
17 let dir: string;
18 let repoId = "";
19
20 function plant(summary: string): void {
21 for (let n = 0; n < 5; n++) {
22 const run = createRun(app.db, { repoId, kind: "agent" });
23 app.db.query("UPDATE run SET state = 'failed', summary = ?2, finished_at = created_at WHERE id = ?1").run(run.id, summary);
24 }
25 }
26
27 beforeAll(async () => {
28 dir = await mkdtemp(join(tmpdir(), "sentinel-interrupted-"));
29 app = createApp({ dataDir: dir, port: 0 });
30 const u = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true });
31 if (!u.ok) throw new Error("user");
32 const made = await createRepo(app, u.value, { name: "garden", visibility: "public" });
33 if (!made.ok) throw new Error("repo");
34 repoId = made.value.id;
35 });
36 afterAll(async () => {
37 await rm(dir, { recursive: true, force: true });
38 });
39
40 test("interrupted runs are not a push failure; real push failures still are", () => {
41 plant("interrupted: provider limit, resumes 05:10 UTC — no changes pushed: API Error: 402 This request requires more credits");
42 const keys = findFaults(app.db, Date.now(), "none").map((f) => f.key);
43 expect(keys).not.toContain(`push:${repoId}`);
44 plant("push failed: refs/heads/x rejected");
45 const after = findFaults(app.db, Date.now(), "none").map((f) => f.key);
46 expect(after).toContain(`push:${repoId}`);
47 });

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

Keyboard shortcuts

Docs