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

Health says whether the forge is serving; what it would like done is a separa… #12075

Parked opened this in answer to
Closed without merging

scout/forge:scout/12071-health-says-whether-the-forge-is-serving → main 3 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
11 files changed +234 −37
src/actions/health.ts +20 −2
@@ -97,8 +97,26 @@ export function readHealth(
9797 return { ok, version, commit, draining };
9898 }
9999 if (!actor?.isAdmin) return forge;
100 const v = forgeVitals(app);
101 return { ...v, ...forge, ok: forge.ok && v.ok };
100 return whole(forge, forgeVitals(app));
101 }
102
103 /**
104 * The admin's whole answer (#12071). `ok` is "serving and nothing broken now":
105 * not draining, no platform incident, and no `broken` vital. What the forge
106 * would like done is `todo`, and never makes `ok` false.
107 */
108 export function whole(forge: ForgeHealth, v: Vitals): Vitals & ForgeHealth & { says: string } {
109 const broken = [
110 ...(forge.draining ? ["The forge is draining: it is handing over and will stop serving."] : []),
111 ...forge.incidents.map((i) => `${i.key}: ${i.message}`),
112 ...v.broken,
113 ];
114 const todo = [...(forge.stale ? [forge.rollout.reason] : []), ...v.todo];
115 const ok = broken.length === 0;
116 const says = ok
117 ? `The forge is serving and nothing is broken now${todo.length === 0 ? "" : `; ${todo.length} thing${todo.length === 1 ? "" : "s"} would like doing, under todo`}.`
118 : `The forge is not well: ${broken.length} thing${broken.length === 1 ? " is" : "s are"} broken now, under broken${todo.length === 0 ? "" : `; ${todo.length} more would like doing, under todo`}.`;
119 return { ...v, ...forge, ok, broken, todo, says };
102120 }
103121
104122 /**
src/kernel/boots.ts +8
@@ -152,3 +152,11 @@ export function uncleanInFirstMinutes(dataDir: string, windowMs = FIRST_MINUTES_
152152 if (firstAt === undefined) return null;
153153 return ledger.starts.slice(0, -1).filter((s) => !s.clean && s.at - firstAt <= windowMs && now - s.at < memoryMs).length;
154154 }
155
156 /**
157 * Starts in the last `windowMs` that never exited cleanly, this process's own start left out;
158 * 0 when there is no ledger.
159 */
160 export function recentUncleanStarts(dataDir: string, windowMs: number, now = Date.now(), id = thisStart): number {
161 return read(dataDir).starts.filter((s) => s.id !== id && !s.clean && now - s.at < windowMs).length;
162 }
src/kernel/vitals.ts +52 −13
@@ -30,6 +30,7 @@ import { BUDGETS } from "./budgets.ts";
3030 import { openDbFiles } from "./file_modes.ts";
3131 import { dbFile, dbGrowth, dbSize, dbSizeNeed, fileBytes, type DbWalk } from "../system/db_size.ts";
3232 import { backupVerdict, isWatched } from "../snapshot/bucket.ts";
33 import { recentUncleanStarts } from "./boots.ts";
3334 import { lastDrill } from "../snapshot/drills.ts";
3435 import { lastMirror, mirrorNeed } from "../snapshot/mirror.ts";
3536 import { lastSnapshotOutcome, snapshotNeed } from "../snapshot/outcome.ts";
@@ -38,11 +39,8 @@ import { proofNeed } from "../release/prove.ts";
3839 import { running as runningVersion } from "./version.ts";
3940 import { rollbackNeed } from "../release/launch.ts";
4041 import { behindStanding } from "../release/behind.ts";
41 import { newestDrills } from "../core/domain_drills.ts";
4242 import { capacityValue } from "../core/capacity.ts";
4343 import { unwrittenFor, SILENT_AFTER_S } from "../http/access_log.ts";
44 import { DOMAINS } from "./domains.ts";
45 import { domainDrillNeeds } from "./domain_drill.ts";
4644 import { freeChecks, heldChecks, redHref, redSentence } from "../checks/red_main.ts";
4745 import { diskRedSentence, diskReds } from "../checks/disk_red.ts";
4846 import { flakeList, type FlakeRow } from "../checks/flake.ts";
@@ -100,8 +98,17 @@ export interface Lane {
10098 }
10199
102100 export interface Vitals {
101 /** True when nothing is broken now; a standing `todo` does not make it false (#12071). */
103102 readonly ok: boolean;
103 /** Every sentence, `broken` then `todo` in the order found. */
104104 readonly needs: string[];
105 /**
106 * Act now: the disk under its floor, a red main, a database that does not answer, memory gone,
107 * a crash loop.
108 */
109 readonly broken: string[];
110 /** Would like done: everything else that is off. Never makes `ok` false. */
111 readonly todo: string[];
105112 readonly degraded: Degraded[];
106113 readonly disk: { freeBytes: number; totalBytes: number };
107114 readonly memory: {
@@ -319,10 +326,32 @@ export function laneSentence(
319326 return `${head}; the longest running is ${name(longest)} at ${minutes(longest)} min (limit ${BUDGETS.gate / 60_000})${more}.`;
320327 }
321328
329 /** Memory the host has left, under which the forge is broken: 64 MiB. */
330 export const MEMORY_FLOOR_BYTES = 64 * 1024 * 1024;
331
332 /** Unclean starts in the quarter hour that make a crash loop. */
333 export const CRASH_LOOP = 3;
334
335 /** Whether a cause is broken now (act) rather than a thing to do. */
336 export function isBroken(cause: string): boolean {
337 return (
338 cause === "db-down" ||
339 cause === "disk" ||
340 cause === "disk-floor" ||
341 cause === "disk-red" ||
342 cause === "memory" ||
343 cause === "crash-loop" ||
344 cause.startsWith("red:") ||
345 cause.startsWith("file:")
346 );
347 }
348
322349 export function vitals(input: VitalsInput): Vitals {
323350 const now = input.now ?? Date.now();
324351 const at = new Date(now).toISOString();
325352 const needs: string[] = [];
353 const broken: string[] = [];
354 const todo: string[] = [];
326355 const degraded: Degraded[] = [];
327356 let firstSeen = firstSeenByForge.get(input.signals.errors);
328357 if (!firstSeen) firstSeenByForge.set(input.signals.errors, (firstSeen = new Map()));
@@ -338,9 +367,17 @@ export function vitals(input: VitalsInput): Vitals {
338367 firstSeen.set(cause, since);
339368 }
340369 needs.push(sentence);
370 (isBroken(cause) ? broken : todo).push(sentence);
341371 degraded.push({ cause, sentence, since, href });
342372 };
343373
374 // The database answers, or nothing else here is worth reading.
375 try {
376 input.db.query("select 1").get();
377 } catch {
378 need("db-down", "The database does not answer.", undefined, "/system");
379 }
380
344381 const disk = (input.disk ?? readDisk)(input.dataDir);
345382 // Room to spare (#11940): at 100 GiB free no share-of-the-disk guard speaks,
346383 // the floor and the marks alike.
@@ -372,6 +409,13 @@ export function vitals(input: VitalsInput): Vitals {
372409 );
373410 }
374411
412 const hostFree = freemem();
413 if (hostFree < MEMORY_FLOOR_BYTES)
414 need("memory", `The host has ${Math.round(hostFree / 1024 / 1024)} MiB of memory left (the floor is ${MEMORY_FLOOR_BYTES / 1024 / 1024} MiB).`, undefined, "/system");
415 const crashes = recentUncleanStarts(input.dataDir, 15 * 60_000, now);
416 if (crashes >= CRASH_LOOP)
417 need("crash-loop", `The forge started ${crashes} times in 15 minutes without exiting cleanly.`, undefined, "/system");
418
375419 for (const file of openDbFiles(input.dataDir))
376420 need(`file:${file.name}`, file.sentence, undefined, "/settings/capacity");
377421
@@ -520,15 +564,8 @@ export function vitals(input: VitalsInput): Vitals {
520564 if (owed !== undefined)
521565 need("drill", owed.sentence, owed.since, "/settings/backups");
522566
523 // A domain whose drill is red or eight days old is a card with the command that runs it.
524 for (const owed of domainDrillNeeds(
525 newestDrills(input.db),
526 now,
527 drillFirstSeen(input.dataDir),
528 input.forgeUrl ?? "http://localhost",
529 DOMAINS,
530 ))
531 need(owed.cause, owed.sentence, owed.since, "/");
567 // No domain-drill need (#12071): nothing runs a drill by itself yet, so "never drilled" was a
568 // standing need no one could meet.
532569
533570 // A snapshot that failed is a card from that morning until one lands.
534571 const failing = snapshotNeed(lastSnapshotOutcome(input.dataDir));
@@ -596,8 +633,10 @@ export function vitals(input: VitalsInput): Vitals {
596633 if (!degraded.some((d) => d.cause === cause)) firstSeen.delete(cause);
597634
598635 return {
599 ok: needs.length === 0,
636 ok: broken.length === 0,
600637 needs,
638 broken,
639 todo,
601640 degraded,
602641 disk,
603642 memory: {
src/release/journey.ts +11 −1
@@ -39,6 +39,11 @@ export interface JourneyOptions {
3939 readonly pollMs?: number;
4040 /** Waits `ms`; `Bun.sleep` when left out. */
4141 readonly sleep?: (ms: number) => Promise<void>;
42 /**
43 * The forge's probe header, sent to `base` only: the walk is the forge's own, not a stranger's,
44 * and spends no stranger's allowance.
45 */
46 readonly probe?: Readonly<Record<string, string>>;
4247 }
4348
4449 export interface JourneyResult {
@@ -100,7 +105,12 @@ export async function walkJourney(options: JourneyOptions): Promise<JourneyResul
100105 const hostUrl = host;
101106
102107 const call = (url: URL, init: RequestInit = {}): Promise<Response> =>
103 doFetch(url.href, { redirect: "manual", signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS), ...init });
108 doFetch(url.href, {
109 redirect: "manual",
110 signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
111 ...init,
112 ...(options.probe !== undefined && url.origin === hostUrl.origin ? { headers: { ...options.probe, ...(init.headers as Record<string, string> | undefined) } } : {}),
113 });
104114 const form = (url: URL, fields: Record<string, string>, extra: Record<string, string> = {}): Promise<Response> =>
105115 call(url, {
106116 method: "POST",
src/release/prove.ts +1 −1
@@ -225,7 +225,7 @@ export async function proveRelease(o: ProveOptions): Promise<Proof | undefined>
225225 if (failures[0] !== undefined || o.journey === undefined)
226226 return finish(failures[0] === undefined ? undefined : checkLine(failures[0]), failures[0]?.slow === true || failures[0]?.empty === true || failures[0]?.hung === true);
227227 // The stranger's journey, the last check: a failed walk is a failed proof, retried on `retryAfter` like any other (one card, paged once).
228 const walked = await o.journey({ base: o.url, fetch: doFetch, ...(o.token ? { adminToken: o.token } : {}) });
228 const walked = await o.journey({ base: o.url, fetch: doFetch, probe: ownProbeHeaders(o.dataDir), ...(o.token ? { adminToken: o.token } : {}) });
229229 return finish(walked.ok ? undefined : `a stranger's journey failed: ${walked.failure ?? "it did not finish"}`, false, false, walked);
230230 } catch (error) {
231231 return finish(`the smoke checks could not run: ${String(error)}`);
src/spawn/door.ts +7 −3
@@ -35,6 +35,7 @@ import { dryRun, planSpawn, KEY_BUDGET_NOTE, MAX_APPS, type CatalogApp, type Cre
3535 import { bootHostedChild } from "./host.ts";
3636 import { cellPlacement, ownsBody } from "./cell.ts";
3737 import { cellsAvailable } from "../apps/contain.ts";
38 import { isProbe } from "../kernel/probe.ts";
3839 import { ANON_SPAWNS_PER_DAY, checkAnonSpawn, noteAnonSpawn } from "./rate.ts";
3940 import { readdirSync, readFileSync } from "node:fs";
4041 import { readdir, stat } from "node:fs/promises";
@@ -188,12 +189,15 @@ export async function spawnDoor(
188189 ): Promise<Door> {
189190 const paid = opts.paid === true;
190191 const anon = user === undefined;
192 // The forge's own journey prober (#12071) is not a stranger: it spends neither the per-minute
193 // plan limit nor the day's allowance.
194 const prober = isProbe(ctx.request, ctx.app.config.dataDir);
191195 if (!anon && user.kind !== "user") return spawnWords({ kind: "forbidden" });
192196 // A forge asked for in order to contribute is never made: the fork path costs the host no cell.
193197 if (wantsToContribute(raw)) return { status: 200, body: contributeAnswer() };
194198 // A plan is free of children but not of work — it reads every catalog
195199 // app it names — so a stranger's are counted per address and per forge.
196 if (anon && !paid) {
200 if (anon && !paid && !prober) {
197201 const verdict = takeDoor(ctx.app, "plan", ctx.request);
198202 if (!verdict.allowed)
199203 return {
@@ -341,7 +345,7 @@ export async function spawnDoor(
341345 };
342346 }
343347 // A stranger may start only a few children a day; the plan above is free.
344 if (anon && !paid) {
348 if (anon && !paid && !prober) {
345349 const limit = checkAnonSpawn(ctx.app.db, ctx.request);
346350 if (!limit.allowed)
347351 return {
@@ -380,7 +384,7 @@ export async function spawnDoor(
380384 if (gift !== undefined && !settled) unclaimGift(ctx.app, gift);
381385 }
382386 if (!made.ok) return spawnWords(made.error);
383 if (anon && !paid && !made.value.existed) noteAnonSpawn(ctx.app.db, ctx.request);
387 if (anon && !paid && !prober && !made.value.existed) noteAnonSpawn(ctx.app.db, ctx.request);
384388 // The visitor who started (or was given) this forge becomes someone, on the host's side (#11265).
385389 if (!made.value.existed && !paid) linkRequestVisitor(ctx.app, ctx.request, made.value.name, gift === undefined ? "started" : "paid");
386390 // Its apps come up now, so the first visit after a claim finds them awake.
test/backup-truth.test.ts +1 −1
@@ -295,7 +295,7 @@ test("the check records each run; stopped past its interval, the verdict, tile,
295295 const card = vitals({ db: own.db, signals: own.signals, dataDir: dir, now: later }).degraded.find((d) => d.cause === "backup");
296296 expect(card?.sentence).toContain(`last ran ${ranAt}`);
297297 const health = readHealth(own, { isAdmin: true } as User) as { ok: boolean; degraded: { cause: string; sentence: string }[] };
298 expect(health.ok).toBe(false);
298 expect(health.ok).toBe(true); // a backup that stopped is a thing to do (#12071), not a forge that is down
299299 expect(health.degraded.find((d) => d.cause === "backup")?.sentence).toContain(`last ran ${ranAt}`);
300300 expect(verdictLines({ app: own } as never).join("\n")).toContain("runs on record");
301301 } finally {
test/health-broken.test.ts added +109
@@ -0,0 +1,109 @@
1 /**
2 * Health says whether the forge is serving (#12071): `ok` is false only for what is
3 * broken now, and what the forge would like done is `todo`.
4 */
5 import { beforeEach, describe, expect, test } from "bun:test";
6 import type { Database } from "bun:sqlite";
7 import { mkdtempSync } from "node:fs";
8 import { tmpdir } from "node:os";
9 import { join } from "node:path";
10 import { migrations } from "../src/core/schema.ts";
11 import { openDb } from "../src/kernel/db.ts";
12 import { claimRun, createRun, finishRun } from "../src/core/runs.ts";
13 import { isBroken, vitals } from "../src/kernel/vitals.ts";
14 import { whole } from "../src/actions/health.ts";
15 import type { ForgeHealth } from "../src/kernel/guard.ts";
16 import { ErrorLedger } from "../src/kernel/log.ts";
17 import { RefusedLedger } from "../src/kernel/internal_refused.ts";
18 import { walkJourney } from "../src/release/journey.ts";
19
20 let db: Database;
21 let dir: string;
22 beforeEach(() => {
23 db = openDb(":memory:", migrations);
24 dir = mkdtempSync(join(tmpdir(), "hb-"));
25 });
26 const read = (disk?: { freeBytes: number; totalBytes: number }) =>
27 vitals({
28 db,
29 dataDir: dir,
30 signals: { errors: new ErrorLedger(), refused: new RefusedLedger() },
31 ...(disk ? { disk: () => disk } : {}),
32 });
33 const forge = (over: Partial<ForgeHealth> = {}): ForgeHealth => ({
34 ok: true,
35 version: "1",
36 commit: "abc",
37 draining: false,
38 rollout: { state: "ok", reason: "" },
39 incidents: [],
40 stale: false,
41 checkedAt: null,
42 ...over,
43 });
44
45 describe("ok is serving and nothing broken", () => {
46 test("a well forge is ok, with a sentence that says so", () => {
47 const h = whole(forge(), read());
48 expect(h.ok).toBe(true);
49 expect(h.broken).toEqual([]);
50 expect(h.says).toContain("serving and nothing is broken");
51 });
52
53 test("a draining forge is not ok, and says why under broken", () => {
54 const h = whole(forge({ draining: true }), read());
55 expect(h.ok).toBe(false);
56 expect(h.broken[0]).toContain("draining");
57 expect(h.says).toContain("not well");
58 });
59
60 test("a full disk is not ok, and is under broken", () => {
61 const h = whole(forge(), read({ freeBytes: 5, totalBytes: 100 }));
62 expect(h.ok).toBe(false);
63 expect(h.broken.join(" ")).toContain("Disk is nearly full");
64 expect(h.todo.join(" ")).not.toContain("Disk is nearly full");
65 });
66
67 test("a red main is not ok, and is under broken", () => {
68 db.run("INSERT INTO user (id, username, email, password_hash) VALUES ('u1', 'trevato', 't@x', '')");
69 db.run("INSERT INTO repo (id, owner_id, name) VALUES ('r1', 'u1', 'forge')");
70 db.run("INSERT INTO issue (id, repo_id, number, kind, title, author_id) VALUES ('i1', 'r1', 7, 'pull', 'p', 'u1')");
71 const run = createRun(db, { repoId: "r1", kind: "check", env: "main", commitOid: "b".repeat(40), reason: "push" });
72 claimRun(db, run.id);
73 finishRun(db, run.id, { state: "failed", summary: "check failed", checkDetail: { passed: 1, failed: 1, names: ["one"] } });
74 createRun(db, { repoId: "r1", kind: "check", env: "pull-7", issueId: "i1", commitOid: "a".repeat(40), reason: "push" });
75 const h = whole(forge(), read());
76 expect(h.ok).toBe(false);
77 expect(h.broken.join(" ")).toContain("main is red");
78 });
79
80 test("a platform incident is broken; a stale view and the database size are todo", () => {
81 const h = whole(forge({ incidents: [{ key: "stuck", message: "x" }] }), read());
82 expect(h.ok).toBe(false);
83 const stale = whole(forge({ stale: true, rollout: { state: "ok", reason: "the platform's view is stale" } }), read());
84 expect(stale.ok).toBe(true);
85 expect(stale.todo).toEqual(["the platform's view is stale"]);
86 expect(isBroken("db-size")).toBe(false);
87 expect(isBroken("db-growth")).toBe(false);
88 expect(isBroken("release")).toBe(false);
89 expect(isBroken("disk-floor")).toBe(true);
90 });
91
92 test("no drill need is raised for a forge that never drilled", () => {
93 db.run("INSERT INTO user (id, username, email, password_hash) VALUES ('u1', 'a', 'a@x', '')");
94 expect(read().needs.join(" ")).not.toContain("drill");
95 });
96 });
97
98 describe("the journey prober", () => {
99 test("sends the probe header to the forge it walks, and to no other host", async () => {
100 const seen: { url: string; probe: string | null }[] = [];
101 const fake = (async (url: string, init?: RequestInit) => {
102 const h = new Headers(init?.headers);
103 seen.push({ url: String(url), probe: h.get("x-probe") });
104 return new Response("", { status: 500 });
105 }) as unknown as typeof fetch;
106 await walkJourney({ base: "https://forge.example", fetch: fake, probe: { "x-probe": "k" } });
107 expect(seen[0]).toEqual({ url: "https://forge.example/", probe: "k" });
108 });
109 });
test/spawn-anon.test.ts +12 −1
@@ -18,6 +18,7 @@ import { createUser } from "../src/core/users.ts";
1818 import { serve, type Servers } from "../src/http/server.ts";
1919 import { childDirOf } from "../src/actions/spawn.ts";
2020 import { bootHostedChild } from "../src/spawn/host.ts";
21 import { probeHeaders } from "../src/kernel/probe.ts";
2122 import { ok } from "../src/kernel/result.ts";
2223
2324 describe("anonymous spawn", () => {
@@ -184,6 +185,16 @@ describe("anonymous spawn", () => {
184185 // A dry run is free: the plan still comes back.
185186 const dry = await post({ name: "kid5" });
186187 expect(dry.status).toBe(200);
188 // The forge's own journey prober is not a stranger (#12071): it passes the limit and is not
189 // counted.
190 const probe = await fetch(`${base}/api/v1/forges`, {
191 method: "POST",
192 headers: { "content-type": "application/json", ...probeHeaders(dataDir) },
193 body: JSON.stringify({ name: "kidp", dryRun: false }),
194 });
195 expect(probe.status).toBe(201);
196 await settle("kidp");
197 expect((await post({ name: "kidq", dryRun: false })).status).toBe(429);
187198 resetAnonSpawns(app.db);
188199 });
189200
@@ -221,6 +232,6 @@ describe("anonymous spawn", () => {
221232 } finally {
222233 child.close();
223234 }
224 expect(await readdir(join(dataDir, "children")).catch(() => [])).toHaveLength(4);
235 expect(await readdir(join(dataDir, "children")).catch(() => [])).toHaveLength(5);
225236 });
226237 });
test/vitals-domain-drill.test.ts +3 −9
@@ -68,19 +68,13 @@ test("a verdict that is not a quoted phrase is quoted whole, and bounded", () =>
6868 expect(n[0]!.sentence.length).toBeLessThan(400);
6969 });
7070
71 test("vitals raises them from the newest drill of each domain, in one query", async () => {
71 test("vitals raises none of them: nothing runs a drill by itself yet (#12071)", async () => {
7272 const { vitals } = await import("../src/kernel/vitals.ts");
73 const { newestDrills, recordDrill } = await import("../src/core/domain_drills.ts");
73 const { recordDrill } = await import("../src/core/domain_drills.ts");
7474 const { createApp } = await import("../src/app.ts");
7575 const dir = mkdtempSync(join(tmpdir(), "vdd-"));
7676 const app = createApp({ dataDir: dir, port: 0 });
7777 const seen = { health: "", board: "" };
7878 recordDrill(app.db, "u", "compute", seen, 1, { green: false, why: 'the forge never said "x"' });
79 const sentence = () =>
80 vitals({ db: app.db, signals: app.signals, dataDir: dir, forgeUrl: URL_ }).needs.find((s) => s.includes("compute drill"));
81 expect(sentence()).toContain(`bun scripts/drills/run.ts compute --forge ${URL_}`);
82 app.db.query("UPDATE domain_drill SET at = '2020-01-01T00:00:00.000Z'").run();
83 recordDrill(app.db, "u", "compute", seen, 1, { green: true, why: "ok" });
84 expect(sentence()).toBeUndefined();
85 expect(newestDrills(app.db).length).toBe(1);
79 expect(vitals({ db: app.db, signals: app.signals, dataDir: dir, forgeUrl: URL_ }).needs.join(" ")).not.toContain("drill");
8680 });
test/vitals.test.ts +10 −6
@@ -94,9 +94,9 @@ test("a site admin with a read-only token gets the shape; others get the short o
9494 expect(Object.keys(v).sort()).toEqual(
9595 [
9696 "accessLog",
97 "apps", "at", "checkedAt", "commit", "degraded", "disk", "draining", "errors", "flakes",
98 "incidents", "lane", "memory", "needs", "ok", "queue", "rollout", "stale", "stuck",
99 "version",
97 "apps", "at", "broken", "checkedAt", "commit", "degraded", "disk", "draining", "errors", "flakes",
98 "incidents", "lane", "memory", "needs", "ok", "queue", "rollout", "says", "stale", "stuck",
99 "todo", "version",
100100 ].sort(),
101101 );
102102 expect(v.disk.totalBytes).toBeGreaterThan(0);
@@ -129,7 +129,9 @@ test("a full queue shows in queue, and an old one in needs", async () => {
129129 // Process-wide signals (errors, refused calls) from other suites may speak too.
130130 expect(v.needs.join(" ")).not.toContain("queue");
131131 const later = vitals({ db: app.db, signals: app.signals, dataDir, disk: roomy, now: old + 2 * 3_600_000 + 3_600_000 });
132 expect(later.ok).toBe(false);
132 expect(later.ok).toBe(true);
133 expect(later.broken).toEqual([]);
134 expect(later.todo.join(" ")).toContain("queue");
133135 expect(later.needs.join(" ")).toContain("agent queue");
134136 });
135137
@@ -143,7 +145,8 @@ test("a running run with a lapsed lease is stuck, and needs says so", async () =
143145 const v = (await (await health(admin)).json()) as ReturnType<typeof vitals>;
144146 expect(v.stuck.map((s) => s.runId)).toEqual([run.id]);
145147 expect(v.stuck[0]!.repo).toBe("alice/r");
146 expect(v.ok).toBe(false);
148 expect(v.ok).toBe(true);
149 expect(v.todo.join(" ")).toContain("stuck");
147150 expect(v.needs.some((n) => n.includes("stuck"))).toBe(true);
148151 // A fresh heartbeat clears it.
149152 app.db
@@ -466,7 +469,8 @@ test("a lane older than its budget is degraded with its cause; a silent run is s
466469 expect(lane?.sentence).toMatch(
467470 /^3 checks wait behind one lane; the oldest since \d\d:\d\d; the lane runs a check for 31 min \(limit 60\)\.$/,
468471 );
469 expect(v.ok).toBe(false);
472 expect(v.ok).toBe(true);
473 expect(v.todo.join(" ")).toContain("wait");
470474 // Five minutes in, the oldest is under its budget: nothing to say.
471475 app.db.query("UPDATE run SET created_at=?1 WHERE state='queued'").run(iso(now - 5 * 60_000));
472476 expect(vitals({ db: app.db, signals: app.signals, dataDir, disk: roomy, now }).degraded.map((d) => d.cause)).toEqual([]);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs