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

A maintenance finding can be dismissed for seven days with a reason, and the reason is kept #13984

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/forge:mason/13967-a-maintenance-finding-can-be-dismissed-f → main 11 commits fork 2 threads · 2 unresolved

  • Merged. mason/13967-a-maintenance-finding-can-be-dismissed-f was merged into main as 4f7a51e.

Review

Sign in to review this change.
13 files changed +248 −20
docs/features/README.md +1
@@ -270,6 +270,7 @@ Read with the guide page [Your apps](../guide-your-apps.md).
270270 - [New app from a template](app-template.md)
271271 - [One place for a secret (`Settings → App → Secrets this app uses`)](app-secrets.md)
272272 - [Pause and resume a maintenance duty](maintenance-duties.md)
273 - [Dismiss a duty's finding for seven days](duty-dismiss.md)
273274 - [Pinned toolchains (rust)](toolchains.md)
274275 - [A run's page folds its steps and its log](run-folds.md)
275276 - [A run's cost line shows tokens and the price per million](run-price.md)
docs/features/duty-dismiss.md added +10
@@ -0,0 +1,10 @@
1 # Dismiss a maintenance duty's finding for seven days (#13967)
2
3 A forge admin who is a person can set a duty's finding aside for seven days, with a reason. The reason is required (at most 200 characters) and stays on the duty's row in `maintenance_duty_state` (`dismissed_until`, `dismissed_reason`): shown while the finding is hidden ("dismissed until <day>: <why>") and again once it returns ("dismissed until <day>, now back: <why>"). The weekly line reads `maintenance_run`, never this, so a dismissed finding still counts there. Both doors call `dismiss` in `src/maintain/dismiss.ts`, so they say the same words.
4
5 - **On the web.** `/maintenance`, under the duties: one control, a duty to choose (only duties that are on and not already dismissed), a reason and **Dismiss 7 days** (`POST /maintenance/dismiss`, same-origin only, admin).
6 - **In the terminal.** Ctrl-K, **Pause, resume or dismiss a maintenance duty**: `j`/`k` choose, `d` asks for the reason, Enter saves. It writes the same row, so a web viewer sees it on its next load.
7
8 A missing reason, a reason over 200 characters or an unknown duty is refused and stores nothing.
9
10 Tests: `test/maintain-dismiss.test.ts`.
docs/features/maintenance-duties.md +1 −1
@@ -5,7 +5,7 @@ Each duty the forge's maintenance runner runs (`src/maintain/registry.ts`) has a
55 All doors are for a forge admin and call one function, `switchDuty` in `src/maintain/pause.ts`, so they say the same words.
66
77 - **On the web.** `/maintenance` lists each duty once; the ones the runner runs carry their state ("on", or "paused since … ; why") and one **Pause** / **Resume** button (`POST /maintenance/duties/:name`, same-origin only, form body bounded, `paused` is `yes` or `no`).
8 - **In the terminal.** Ctrl-K, **Pause or resume a maintenance duty** (an admin who is a person): `j`/`k` choose, Enter or Space flips, Esc closes. It writes the same row, so a web viewer sees it on its next load.
8 - **In the terminal.** Ctrl-K, **Pause, resume or dismiss a maintenance duty** (an admin who is a person): `j`/`k` choose, Enter or Space flips, `d` dismisses its finding for seven days (see duty-dismiss.md), Esc closes. It writes the same row, so a web viewer sees it on its next load.
99 - **Over the API.** `GET /api/v1/maintenance/duties` lists the states; `POST /api/v1/maintenance/duties/:name` with `{"paused": true|false}` needs an `admin`-scope token.
1010 - **In the MCP.** The `maintenance` tool: `pause-duty` and `resume-duty` with `duty`.
1111
src/core/migration-pins/20261116110000-duty-dismissed.pin added +1
@@ -0,0 +1,1 @@
1 f87739dfda72625a5bd3946b6fa10e458d1c668327e9a232548993b9d14a397c
src/core/migrations/20261116110000-duty-dismissed.ts added +6
@@ -0,0 +1,6 @@
1 // A maintenance duty's finding dismissed for seven days with a reason (#13967): the time it
2 // returns and why it was set aside, on the duty's own row. Empty reads as not dismissed. Additive.
3 export default `
4 ALTER TABLE maintenance_duty_state ADD COLUMN dismissed_until TEXT NOT NULL DEFAULT '';
5 ALTER TABLE maintenance_duty_state ADD COLUMN dismissed_reason TEXT NOT NULL DEFAULT '';
6 `;
src/http/server.ts +2 −1
@@ -43,7 +43,7 @@ import { contributePage } from "../web/pages/contribute.ts";
4343 import { pipelinePage } from "../web/pages/pipeline.ts";
4444 import { adminDataPage, appDataCsv, appDataPage, dataPage } from "../web/pages/data.ts";
4545 import { fleetAct, fleetReceipt, fleetUndo } from "../web/pages/fleet-ops.ts";
46 import { maintenanceDuty, maintenancePage, maintenancePrepare, maintenanceResume, staleAction, mergedAction, previewAction } from "../web/pages/maintenance.ts";
46 import { maintenanceDuty, maintenanceDismiss, maintenancePage, maintenancePrepare, maintenanceResume, staleAction, mergedAction, previewAction } from "../web/pages/maintenance.ts";
4747 import { maintenanceBudget } from "../web/pages/maintenance_budgets.ts";
4848 import { nightlyOutputPage, resiliencePage } from "../web/pages/resilience.ts";
4949 import { agentStartSet, billingLinksSet, limitsPage, limitsSet, quotasSet, signupSet, inviteMint, inviteRevoke } from "../web/pages/admin-limits.ts";
@@ -1146,6 +1146,7 @@ export function buildRouter(): Router<Handler> {
11461146 router.add("POST", "/maintenance/resume", maintenanceResume);
11471147 router.add("POST", "/maintenance/budget", maintenanceBudget);
11481148 router.add("POST", "/maintenance/duties/:name", maintenanceDuty);
1149 router.add("POST", "/maintenance/dismiss", maintenanceDismiss);
11491150 router.add("POST", "/maintenance/stale/:id/:what", staleAction);
11501151 router.add("POST", "/maintenance/branches/delete", mergedAction);
11511152 router.add("POST", "/maintenance/previews/remove", previewAction);
src/maintain/dismiss.ts added +56
@@ -0,0 +1,56 @@
1 /**

Both doors: dismissal is only writable from the page. Add a src/tui/ screen (admin-gated write, live to web viewers) and docs/features/duty-dismiss.md.

2 * A duty's finding set aside for seven days with a reason (#13967). The reason stays on the duty's
3 * row: shown while the finding is hidden and again when it returns. The weekly line reads
4 * `maintenance_run`, never this, so a dismissed finding still counts there. Plain data in and out.
5 */
6
7 import type { Database } from "bun:sqlite";
8 import { clip } from "./duty.ts";
9 import { knownDuty } from "./pause.ts";
10
11 export const DISMISS_DAYS = 7;
12 export const DISMISS_MS = DISMISS_DAYS * 24 * 60 * 60 * 1000;
13 export const REASON_MAX = 200;
14
15 export interface Dismissal {
16 readonly until: string;
17 readonly reason: string;
18 /** True while the finding is hidden; false once it has returned. */
19 readonly active: boolean;
20 }
21
22 const day = (iso: string): string => iso.slice(0, 10);
23
24 /** The stored dismissal of a duty, or undefined when it never had one. */
25 export function dismissal(db: Database, duty: string, now = new Date()): Dismissal | undefined {
26 const r = db.query("SELECT dismissed_until AS until, dismissed_reason AS reason FROM maintenance_duty_state WHERE duty = ?1").get(duty) as { until: string; reason: string } | null;
27 if (r === null || r.until === "") return undefined;
28 return { until: r.until, reason: r.reason, active: r.until > now.toISOString() };
29 }
30
31 /** Every stored dismissal by duty name, in one query (the page reads all duties at once). */
32 export function dismissals(db: Database, now = new Date()): Map<string, Dismissal> {
33 const rows = db.query("SELECT duty, dismissed_until AS until, dismissed_reason AS reason FROM maintenance_duty_state WHERE dismissed_until <> ''").all() as { duty: string; until: string; reason: string }[];
34 const iso = now.toISOString();
35 return new Map(rows.map((r) => [r.duty, { until: r.until, reason: r.reason, active: r.until > iso }]));
36 }
37
38 /** The dismissal in words, for the duty's row. */
39 export function dismissalWords(d: Dismissal): string {
40 const why = d.reason === "" ? "" : `: ${d.reason}`;
41 return d.active ? `dismissed until ${day(d.until)}${why}` : `dismissed until ${day(d.until)}, now back${why}`;
42 }
43
44 /** Hides the duty's finding for seven days; the reason is required and kept. */
45 export function dismiss(db: Database, name: unknown, reason: unknown, now = new Date()): { ok: true; says: string } | { ok: false; says: string } {
46 if (typeof name !== "string" || !knownDuty(name)) return { ok: false, says: "No such maintenance duty." };
47 const why = typeof reason === "string" ? reason.trim() : "";
48 if (why === "") return { ok: false, says: "Say why: a dismissal keeps its reason." };
49 if (why.length > REASON_MAX) return { ok: false, says: `The reason is at most ${String(REASON_MAX)} characters.` };
50 const until = new Date(now.getTime() + DISMISS_MS).toISOString();
51 db.query(
52 `INSERT INTO maintenance_duty_state (duty, dismissed_until, dismissed_reason) VALUES (?1, ?2, ?3)
53 ON CONFLICT(duty) DO UPDATE SET dismissed_until = ?2, dismissed_reason = ?3`,
54 ).run(name, until, clip(why));
55 return { ok: true, says: `${name} is dismissed until ${day(until)}.` };
56 }
src/perf/page_budget.ts +1 −1
@@ -45,7 +45,7 @@ export const PAGE_BUDGETS: readonly PageBudget[] = [
4545 // runs, so the count moves with duty state and background ticks; an N+1 over the duties would
4646 // still show. Four more duties (flaky-tests #13937, red apps #13938, chapter stall #14057,
4747 // dead-doc-paths #13977) each
48 // read their own state.
48 // read their own state. One query reads every dismissal (#13967).
4949 { page: "maintenance", pattern: "/maintenance", medianMs: 50, statements: 72 },
5050 // A stranger's way to a forge (#11410): walked signed out. `/claim` is
5151 // measured on a spawned forge with a live link, as the child's owner sees it.
src/tui/screens/dutyswitch.ts +39 −10
@@ -1,25 +1,30 @@
11 /**
2 * Pause and resume a maintenance duty in the terminal (#11205): the switches
2 * Pause, resume and dismiss a maintenance duty in the terminal (#11205, #13967): the switches
33 * of the /maintenance page, through the same `switchDuty`, behind the same
44 * gate (a forge admin who is a person). j/k choose a duty, Enter or Space
5 * flips it, Esc or q closes. The write is to the forge's own database, so a
6 * web viewer sees it on its next load.
5 * flips it, d dismisses its finding for seven days with a reason, Esc or q closes. The write is to
6 * the forge's own database, so a web viewer sees it on its next load.
77 */
88
9 import { dismiss, dismissals, dismissalWords } from "../../maintain/dismiss.ts";
910 import { dutyStates, switchDuty } from "../../maintain/pause.ts";
1011 import type { Ctx, Screen } from "../app/app.ts";
1112 import { binding } from "../app/keys.ts";
1213 import type { Session } from "../session.ts";
1314 import { style } from "../term/style.ts";
14 import { drawLines, Scroll } from "./common.ts";
15 import { drawLines, promptScreen, Scroll } from "./common.ts";
1516 import type { PaletteEntry } from "./entries.ts";
1617
17 const mayAct = (session: Session): boolean => session.user?.isAdmin === true && session.user.kind !== "agent";
18 const mayAct = (session: { readonly user: { readonly isAdmin: boolean; readonly kind: string } | undefined }): boolean => session.user?.isAdmin === true && session.user.kind !== "agent";
1819
1920 /** One duty a line, the chosen one marked; empty for anyone the gate refuses. */
2021 export function dutyLines(session: Session, chosen: number): string[] {
2122 if (!mayAct(session)) return [];
22 return dutyStates(session.db).map((d, i) => `${i === chosen ? ">" : " "} ${d.says}`);
23 const kept = dismissals(session.db);
24 return dutyStates(session.db).map((d, i) => {
25 const dm = kept.get(d.name);
26 return `${i === chosen ? ">" : " "} ${d.says}${dm === undefined ? "" : `; ${dismissalWords(dm)}`}`;
27 });
2328 }
2429
2530 /** Flip the chosen duty; what it says, or nothing for anyone the gate refuses. */
@@ -31,13 +36,25 @@ export function flipDuty(session: Session, chosen: number): string {
3136 return r.says;
3237 }
3338
39 /**
40 * Dismiss the chosen duty's finding for seven days with a reason; what it says, or nothing for
41 * anyone the gate refuses.
42 */
43 export function dismissChosen(session: { readonly db: Session["db"]; readonly user: { readonly isAdmin: boolean; readonly kind: string } | undefined }, chosen: number, reason: string): string {
44 if (!mayAct(session)) return "";
45 const d = dutyStates(session.db)[chosen];
46 if (d === undefined) return "";
47 return dismiss(session.db, d.name, reason).says;
48 }
49
3450 export function dutySwitchScreen(session: Session, ctx: Ctx): Screen {
3551 let chosen = 0;
3652 let note = "";
53 let self: Screen;
3754 const count = (): number => dutyStates(session.db).length;
38 return {
55 self = {
3956 title: "Maintenance duties",
40 keys: [binding(["j", "k"], "choose"), binding(["enter", "space"], "pause or resume"), binding(["esc", "q"], "back")],
57 keys: [binding(["j", "k"], "choose"), binding(["enter", "space"], "pause or resume"), binding(["d"], "dismiss 7 days"), binding(["esc", "q"], "back")],
4158 render(area, s) {
4259 const c = ctx.theme.c;
4360 const lines = [...dutyLines(session, chosen), ...(note === "" ? [] : ["", note])];
@@ -48,17 +65,29 @@ export function dutySwitchScreen(session: Session, ctx: Ctx): Screen {
4865 if (e.key === "esc" || e.key === "q") ctx.pop();
4966 else if (e.key === "j" || e.key === "down") chosen = Math.min(chosen + 1, count() - 1);
5067 else if (e.key === "k" || e.key === "up") chosen = Math.max(chosen - 1, 0);
51 else if (e.key === "enter" || e.key === " " || e.key === "space") note = flipDuty(session, chosen);
68 else if (e.key === "d") {
69 ctx.push(promptScreen(ctx, self, {
70 title: "Dismiss for 7 days",
71 label: "Why (kept with the duty)",
72 onSubmit: (why) => {
73 if (why === "") return "Say why: a dismissal keeps its reason.";
74 note = dismissChosen(session, chosen, why);
75 ctx.invalidate();
76 return undefined;
77 },
78 }));
79 } else if (e.key === "enter" || e.key === " " || e.key === "space") note = flipDuty(session, chosen);
5280 else return false;
5381 ctx.invalidate();
5482 return true;
5583 },
5684 };
85 return self;
5786 }
5887
5988 export const entry: PaletteEntry = {
6089 id: "maintenance-duties",
61 title: "Pause or resume a maintenance duty",
90 title: "Pause, resume or dismiss a maintenance duty",
6291 hint: "switch a duty off, or on again after it paused itself",
6392 after: ["maintenance-runs", "maintenance"],
6493 offered: mayAct,
src/web/pages/maintenance.ts +27 −5
@@ -6,6 +6,7 @@
66
77 import { notePhase, takeSessionTime } from "../../core/route_timing.ts";
88 import { dutyStates, switchDuty } from "../../maintain/pause.ts";
9 import { DISMISS_DAYS, REASON_MAX, dismiss, dismissals, dismissalWords } from "../../maintain/dismiss.ts";
910 import { duties } from "../../maintenance/duties.ts";
1011 import { statusWithStandby } from "../../maintenance/standby.ts";
1112 import { ABOUT_TO_STOP_ROWS, prepare, resumeNow, status } from "../../maintenance/service.ts";
@@ -55,12 +56,14 @@ export async function maintenancePage(ctx: Ctx): Promise<Response> {
5556 const rendering = performance.now();
5657 const s = await statusWithStandby(status(ctx.app));
5758 const ran = duties(ctx.app.config.dataDir);
59 const dismissed = dismissals(ctx.app.db);
5860 const states = dutyStates(ctx.app.db);
5961 const mergedPending = await mergedBranches(ctx.app, new Date());
6062 const previewPending = previewDirs(ctx.app, new Date());
6163 const stalePending = stalePulls(ctx.app.db, new Date());
6264 const stale = stalePending.length;
6365 const overdue = ran.filter((d) => d.overdue).length;
66 const dismissable = states.filter((d) => !d.paused && dismissed.get(d.name)?.active !== true).map((d) => d.name);
6467 const paused = states.filter((d) => d.paused).length;
6568 const waiting = needsYou({ phase: s.phase, ...(s.healthy === undefined ? {} : { healthy: s.healthy }), overdue, paused, stale });
6669 const idle = s.phase === "idle";
@@ -74,13 +77,19 @@ export async function maintenancePage(ctx: Ctx): Promise<Response> {
7477 ${fold("maintenance-duties-fold", "Duties", `${String(ran.length)}${overdue + paused > 0 ? `, ${String(overdue + paused)} need you` : ""}`, overdue + paused > 0,
7578 html`<dl id="maintenance-duties" class="status-rows">
7679 ${ran.map((d) => fact(d.name, html`${d.detail}${d.overdue ? html` ${badge("overdue", { tone: "danger" })}` : null}`))}
77 ${states.map((d) =>
78 fact(d.name, html`${d.detail}
80 ${states.map((d) => {
81 const dm = dismissed.get(d.name);
82 const detail = dm === undefined ? d.detail : dm.active && !d.paused ? `on; ${dismissalWords(dm)}` : `${d.detail}; ${dismissalWords(dm)}`;
83 return fact(d.name, html`${detail}
7984 <form method="post" action="/maintenance/duties/${d.name}" class="inline">
8085 <input type="hidden" name="paused" value="${d.paused ? "no" : "yes"}">${btn(d.paused ? "Resume" : "Pause", { variant: "outline" })}
81 </form>`),
82 )}
83 </dl>`)}
86 </form>`);
87 })}
88 </dl>
outdated

Design principles 3 and 7: a text input plus a button inside every duty row repeats the same form on every row, crowding the dl row. Offer one dismiss control for the duty needing it (the one with a finding), or fold it, rather than a field on every on duty.

89 ${dismissable.length === 0 ? null : html`<form method="post" action="/maintenance/dismiss" id="maintenance-dismiss" class="inline">
90 <select class="input" name="duty" aria-label="Duty whose finding to dismiss">${dismissable.map((n) => html`<option value="${n}">${n}</option>`)}</select>
91 <input type="text" name="reason" required maxlength="${String(REASON_MAX)}" autocomplete="off" placeholder="Why (kept)" aria-label="Why dismiss it for ${String(DISMISS_DAYS)} days">${btn(`Dismiss ${String(DISMISS_DAYS)} days`, { variant: "outline" })}
92 </form>`}`)}
8493 ${fold("maintenance-budgets", "Budgets", String(states.length), false, html`<dl class="status-rows">${budgetRows(ctx.app, states.map((d) => d.name))}</dl>`)}
8594 ${writePauseFold(ctx.app.db)}
8695 ${stale > 0
@@ -157,6 +166,19 @@ export async function maintenanceDuty(ctx: Ctx): Promise<Response> {
157166 return flashTo(ctx, "/maintenance", r.ok ? { message: r.says } : { tone: "danger", message: r.says });
158167 }
159168
169 /**
170 * POST /maintenance/dismiss (fields duty, reason): hide the duty's finding for seven days, with a
171 * reason.
172 */
173 export async function maintenanceDismiss(ctx: Ctx): Promise<Response> {
174 const denied = admin(ctx);
175 if (denied) return denied;
176 const form = await readForm(ctx, "admin");
177 if (form instanceof Response) return form;
178 const r = dismiss(ctx.app.db, formField(form, "duty"), formField(form, "reason"));
179 return flashTo(ctx, "/maintenance", r.ok ? { message: r.says } : { tone: "danger", message: r.says });
180 }
181
160182 /** The stale pulls as rows with their age; the buttons only for a forge admin who is a person. */
161183 function staleRows(withActions: boolean, pulls: ReturnType<typeof stalePulls>): Html {
162184 const form = (id: string, what: "nudge" | "close", label: string): Html =>
test/maintain-dismiss.test.ts added +102
@@ -0,0 +1,102 @@
1 /**
2 * A duty's finding dismissed for seven days with a reason (#13967): hidden, returned, same-origin
3 * only.
4 */
5 import { afterAll, beforeAll, expect, test } from "bun:test";
6 import { mkdtemp, rm } from "node:fs/promises";
7 import { tmpdir } from "node:os";
8 import { join } from "node:path";
9 import { createApp, type App } from "../src/app.ts";
10 import { createUser } from "../src/core/users.ts";
11 import { serve, type Servers } from "../src/http/server.ts";
12 import { dutyStates } from "../src/maintain/pause.ts";
13 import { dismissChosen } from "../src/tui/screens/dutyswitch.ts";
14 import { DISMISS_MS, dismiss, dismissal, dismissalWords } from "../src/maintain/dismiss.ts";
15 import { weekRows } from "../src/maintain/week_line.ts";
16 import { quietLogs } from "./helpers/globals.ts";
17
18 quietLogs();
19 let dir = "", app: App, servers: Servers, cookie = "";
20 const DUTY = "disk-free";
21
22 beforeAll(async () => {
23 dir = await mkdtemp(join(tmpdir(), "forge-dismiss-"));
24 app = createApp({ dataDir: dir, port: 0 });
25 servers = await serve(app);
26 const made = await createUser(app.db, { username: "boss", email: "[email protected]", password: "a-good-passphrase", origin: "seed", trusted: true, isAdmin: true });
27 if (!made.ok) throw new Error("user");
28 const res = await fetch(`${servers.url}/signin`, {
29 method: "POST", redirect: "manual",
30 headers: { "content-type": "application/x-www-form-urlencoded", origin: servers.url },
31 body: new URLSearchParams({ username: "boss", password: "a-good-passphrase" }),
32 });
33 cookie = (res.headers.get("set-cookie") ?? "").split(";")[0] ?? "";
34 });
35 afterAll(async () => {
36 servers.stop();
37 app.close();
38 await rm(dir, { recursive: true, force: true });
39 });
40
41 const post = (origin: string, reason: string) =>
42 fetch(`${servers.url}/maintenance/dismiss`, {
43 method: "POST", redirect: "manual",
44 headers: { "content-type": "application/x-www-form-urlencoded", origin, cookie },
45 body: new URLSearchParams({ duty: DUTY, reason }),
46 });
47 const row = async (): Promise<string> => {
48 const text = await (await fetch(`${servers.url}/maintenance`, { headers: { cookie } })).text();
49 const at = text.indexOf(`<dt>${DUTY}</dt>`);
50 return text.slice(at, text.indexOf("</div>", at));
51 };
52
53 test("a cross-origin dismissal is refused and keeps nothing", async () => {
54 const res = await post("https://evil.example", "because");
55 expect(res.status).toBeGreaterThanOrEqual(400);
56 expect(dismissal(app.db, DUTY)).toBeUndefined();
57 });
58
59 test("a dismissal needs a reason and a known duty", () => {
60 expect(dismiss(app.db, DUTY, " ").ok).toBe(false);
61 expect(dismiss(app.db, DUTY, "x".repeat(201)).ok).toBe(false);
62 expect(dismiss(app.db, "nope", "why").ok).toBe(false);
63 });
64
65 test("a same-origin dismissal hides the finding for seven days, then it returns with the reason", async () => {
66 app.db.query("INSERT INTO maintenance_run (duty, started, finished, outcome) VALUES (?1, ?2, ?2, 'failed: disk gone')").run(DUTY, new Date().toISOString());
67 expect(await row()).toContain("last run errored: failed: disk gone");
68 expect(await (await fetch(`${servers.url}/maintenance`, { headers: { cookie } })).text()).toContain(`<option value="${DUTY}">`);
69 const before = weekRows(app.db, [DUTY]);
70 const res = await post(servers.url, "known, replacing the disk");
71 expect(res.status).toBe(303);
72 const hidden = await row();
73 expect(hidden).not.toContain("last run errored");
74 expect(hidden).toContain("known, replacing the disk");
75 const page = await (await fetch(`${servers.url}/maintenance`, { headers: { cookie } })).text();
76 expect(page).not.toContain(`<option value="${DUTY}">`);
77 // The weekly line still counts it.
78 expect(weekRows(app.db, [DUTY])).toEqual(before);
79
80 const d = dismissal(app.db, DUTY)!;
81 expect(Date.parse(d.until) - Date.now()).toBeGreaterThan(DISMISS_MS - 60_000);
82 const later = new Date(Date.parse(d.until) + 1000);
83 expect(dismissal(app.db, DUTY, later)!.active).toBe(false);
84 expect(dismissalWords(dismissal(app.db, DUTY, later)!)).toContain("now back: known, replacing the disk");
85 app.db.query("UPDATE maintenance_duty_state SET dismissed_until = ?1 WHERE duty = ?2").run(new Date(Date.now() - 1000).toISOString(), DUTY);
86 const back = await row();
87 expect(back).toContain("last run errored");
88 expect(back).toContain("now back: known, replacing the disk");
89 });
90
91 test("the terminal dismisses with the same gate and reason, and the page sees it", async () => {
92 app.db.query("DELETE FROM maintenance_duty_state WHERE duty = ?1").run(DUTY);
93 const at = dutyStates(app.db).findIndex((d) => d.name === DUTY);
94 const admin = { isAdmin: true, kind: "person" };
95 const session = (user: { isAdmin: boolean; kind: string }) => ({ user, db: app.db });
96 expect(dismissChosen(session({ ...admin, isAdmin: false }), at, "why")).toBe("");
97 expect(dismissal(app.db, DUTY)).toBeUndefined();
98 expect(dismissChosen(session(admin), at, " ")).toContain("Say why");
99 expect(dismissal(app.db, DUTY)).toBeUndefined();
100 expect(dismissChosen(session(admin), at, "from the terminal")).toContain("is dismissed until");
101 expect(await row()).toContain("from the terminal");
102 });
test/pages-budget.test.ts +1 −1
@@ -56,7 +56,7 @@ const HEAVIER: Record<string, { statements?: number; git?: number }> = {
5656 "/api/v1/asks": { statements: 61 }, // +1: the stopped apps someone asked for, one read of the viewer's archived repositories (#12277)
5757 "/board": { statements: 72 }, // +1: the forge-copy read for the tell box (#12037); +1: the vitals read the database's growth (#12025); +6: the money line (#510) — one settings read, then the month's and the 30 days' meter, storage and ledger reads; constant in the number of apps
5858 "/settings/capacity": { statements: 70 },
59 "/maintenance": { statements: 72 }, // +4: the flaky-tests (#13937), red apps (#13938) and chapter stall (#14057) and dead-doc-paths (#13977) duties each read their own state and run
59 "/maintenance": { statements: 72 }, // main's 72 already had a statement to spare, which the one dismissal query (#13967) takes; +4: the flaky-tests (#13937), red apps (#13938) and chapter stall (#14057) and dead-doc-paths (#13977) duties each read their own state and run
6060 };
6161
6262 /** Patterns with no fixture today: lower this as fixtures are added, never raise it silently. */
test/palette-roster.test.ts +1 −1
@@ -144,7 +144,7 @@ test("a site-admin person is offered the whole roster", () => {
144144 ["merged-branches", "Branches of pulls merged over 7 days ago", "delete the merged pulls' branches in one receipted step"],
145145 ["preview-dirs", "Preview data of pulls closed over 7 days ago", "remove the old previews' data in one receipted step"],
146146 ["maintenance-runs", "Maintenance duty runs", "what each duty found, did and probed"],
147 ["maintenance-duties", "Pause or resume a maintenance duty", "switch a duty off, or on again after it paused itself"],
147 ["maintenance-duties", "Pause, resume or dismiss a maintenance duty", "switch a duty off, or on again after it paused itself"],
148148 ["maintenance-budgets", "Set a maintenance duty's budget", "runs per day and dollars per day a duty may use"],
149149 ["crawlers", "Crawlers", "their share of answering time, and who was refused"],
150150 ["scrapes", "Scrapes", "what was read by repository, and groups in a running capture"],

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs