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
Merged 11h 57m ago, live in production
mason/forge:mason/18068-sentinel-crew-runs-in-trevato-deal-clock → main 0 commits fork
3 files
changed +59
−0
src/crew/interrupted.ts +8
| @@ -25,6 +25,14 @@ const RESTART = | ||
| 25 | 25 | // out: the run never reached the agent (#6263). |
| 26 | 26 | const CLONE = /^(?:clone|checkout|fetch(?: from the fork)?) failed:/i; |
| 27 | 27 | |
| 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 | ||
| 28 | 36 | /** |
| 29 | 37 | * Why a run that ended without a pull was cut short, read from its summary |
| 30 | 38 | * — 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 | ||
| 35 | 35 | import { spans } from "../kernel/degraded_history.ts"; |
| 36 | 36 | import { QUEUE_AGENT_FULL, QUEUE_CHECK_FULL, QUEUE_WAIT_MAX_MS } from "../kernel/vitals.ts"; |
| 37 | 37 | import { STALE_AFTER_MS } from "../runs/lease.ts"; |
| 38 | import { isInterruptedSummary } from "./interrupted.ts"; | |
| 38 | 39 | import { isOutageSummary } from "./network.ts"; |
| 39 | 40 | import { |
| 40 | 41 | assertionLines, |
| @@ -457,6 +458,8 @@ export function runStreaks(db: Database): Finding[] { | ||
| 457 | 458 | // whether or not the summary leads with it. |
| 458 | 459 | // An outage the runner retried ("no changes pushed: ... EAI_AGAIN") is not a |
| 459 | 460 | // 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. | |
| 460 | 463 | // A person's pull whose branch lives in the repository itself is left with them on |
| 461 | 464 | // purpose (#16356): the runner's own decision, not a push that broke. |
| 462 | 465 | const pushes = failed.filter( |
| @@ -464,6 +467,7 @@ export function runStreaks(db: Database): Finding[] { | ||
| 464 | 467 | !/\bdeclined:/i.test(r.summary) && |
| 465 | 468 | !/branch lives in the repository itself/i.test(r.summary) && |
| 466 | 469 | !isOutageSummary(r.summary) && |
| 470 | !isInterruptedSummary(r.summary) && | |
| 467 | 471 | /\bpush|sandbox|operation not permitted/i.test(r.summary), |
| 468 | 472 | ); |
| 469 | 473 | 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 | }); |
new above
offline