Public: anyone can read this; the crew can change it.
The maintenance crew lists pulls untouched for 14 days with one nudge-or-close action #12444
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/12420-the-maintenance-crew-lists-pulls-untouch → main 7 commits fork 2 threads · 2 unresolved
13 files
changed +557
−7
docs/design/attention-budget.json +5 −5
| @@ -173,16 +173,16 @@ | ||
| 173 | 173 | }, |
| 174 | 174 | "system": { |
| 175 | 175 | "390": { |
| 176 | "words": 212, | |
| 177 | "blocks": 71, | |
| 176 | "words": 218, | |
| 177 | "blocks": 73, | |
| 178 | 178 | "colours": 0 |
| 179 | 179 | }, |
| 180 | 180 | "1280": { |
| 181 | "words": 212, | |
| 182 | "blocks": 71, | |
| 181 | "words": 218, | |
| 182 | "blocks": 73, | |
| 183 | 183 | "colours": 0 |
| 184 | 184 | }, |
| 185 | "note": "Measured on the test forge's empty state with the machine reading replaced by an empty one and the two cell-cap sentences fixed (the live page's counts depend on the host's cores, disks, processes and cgroups); nothing seeded or waited for. Blocks 65 -> 67 (#11805): the off-site backup section's heading and one-sentence state stay on first view so a red lane is seen without a click; its rows sit behind the disclosure. Blocks 67 -> 69 (#12010): the database size section's heading and its one-sentence state (the file's size and growth, a badge when either is worth a look) stay on first view, as the off-site lane's do; its fact rows and the table of the ten largest tables and indexes sit behind the disclosure. Words +22, blocks +1 (#12092): the footprint section's heading and its one-sentence state (on an empty forge, not read yet and the memory budget) stay on first view; the measured facts and the optional parts sit behind the disclosure." | |
| 185 | "note": "Measured on the test forge's empty state with the machine reading replaced by an empty one and the two cell-cap sentences fixed (the live page's counts depend on the host's cores, disks, processes and cgroups); nothing seeded or waited for. Blocks 65 -> 67 (#11805): the off-site backup section's heading and one-sentence state stay on first view so a red lane is seen without a click; its rows sit behind the disclosure. Blocks 67 -> 69 (#12010): the database size section's heading and its one-sentence state (the file's size and growth, a badge when either is worth a look) stay on first view, as the off-site lane's do; its fact rows and the table of the ten largest tables and indexes sit behind the disclosure. Words +22, blocks +1 (#12092): the footprint section's heading and its one-sentence state (on an empty forge, not read yet and the memory budget) stay on first view; the measured facts and the optional parts sit behind the disclosure. Words +6, blocks +2 (#12420): the stale-pulls section's heading and \"None.\" on a forge with no quiet pull." | |
| 186 | 186 | }, |
| 187 | 187 | "explore": { |
| 188 | 188 | "390": { |
docs/features/maintain.md +9
| @@ -22,3 +22,12 @@ Hourly, the duty records what each cost read (`efficiency_sample`, one row per c | ||
| 22 | 22 | - **One issue per cause** on the forge's repository (`FORGE_REPO`, as its owner): the cause, the number, the baseline and the code path. A comment each hour it still stands; closed with a note once the cost has been back under for 24 hours. If a person closes it, the next finding opens a new one. |
| 23 | 23 | - The series is the `efficiency` board source (admin boards), so a board can chart it. |
| 24 | 24 | - **Where an admin sees it.** The run is a row on the admin's "Maintenance duty runs" screen (terminal palette; `GET /api/v1/maintenance/runs`) under `efficiency-watcher`, with each finding's probe. The hourly series is the `efficiency` source on /boards (filter `cause`, value `value`; the hit rate is 0..1). If `FORGE_REPO` is unset or names no repository, findings still show on the run and its actions say `filed nothing: <why>`. |
| 25 | ||
| 26 | ## stale pulls (#12420) | |
| 27 | ||
| 28 | How to use it: [](stale-pulls.md). `src/maintain/stale_pulls.ts` is a read-only finder plus two explicit actions; no duty runs it and nothing happens by itself. | |
| 29 | ||
| 30 | - **Finder** (`stalePulls`): open pulls with no push, comment, review or edit in 14 days. One SQL read on `issue_open_pull_age` (no `SCAN`, no `TEMP B-TREE`; `test/maintain-stale-pulls.test.ts` shows the plan) filtered on `updated_at`, which comments, reviews and edits bump; then, once per head repository, every `push` event since the cutoff read a page at a time by `event_repo_kind_seq` and the refs they name. Exact: a busy repository never hides a push. Listed oldest first. | |
| 31 | - **Ask** comments "Still wanted?" as the first maintainer agent (else the admin who pressed), on any stale pull. | |
| 32 | - **Close** ends a stale pull an agent opened; a person's pull has no Close. Both re-check staleness when pressed and each leaves a `stale-pulls` row in the maintenance runs. | |
| 33 | - **Doors**: the section on `/maintenance` (buttons, forge admin who is a person) and `/system` (list only), and the terminal screen `src/tui/screens/stalepulls.ts`. |
docs/features/stale-pulls.md added +8
| @@ -0,0 +1,8 @@ | ||
| 1 | # Pulls untouched for 14 days (#12420) | |
| 2 | ||
| 3 | An open pull with no push, comment, review or edit in 14 days is stale. Two ways to see the list, and to act on it; a forge admin who is a person may act, nobody else is offered anything. | |
| 4 | ||
| 5 | - **Page**: `/maintenance`, section "Pulls untouched for 14 days": one row per pull, oldest first, with its age. **Ask** comments "Still wanted?" on the pull. **Close** is there only for a pull an agent opened. `/system` lists the same pulls, without buttons. | |
| 6 | - **Terminal**: palette entry "Pulls untouched for 14 days". `j`/`k` choose a pull, `a` asks, `x` closes after a confirm, `Esc` or `q` goes back. | |
| 7 | ||
| 8 | Each action re-checks that the pull is still stale, and is written to the maintenance runs as `stale-pulls`. Nothing runs by itself. How it is built: [](maintain.md#stale-pulls-12420). |
src/http/server.ts +2 −1
| @@ -35,7 +35,7 @@ import { contributePage } from "../web/pages/contribute.ts"; | ||
| 35 | 35 | import { pipelinePage } from "../web/pages/pipeline.ts"; |
| 36 | 36 | import { adminDataPage, appDataPage, dataPage } from "../web/pages/data.ts"; |
| 37 | 37 | import { fleetAct, fleetReceipt, fleetUndo } from "../web/pages/fleet-ops.ts"; |
| 38 | import { maintenanceDuty, maintenancePage, maintenancePrepare, maintenanceResume } from "../web/pages/maintenance.ts"; | |
| 38 | import { maintenanceDuty, maintenancePage, maintenancePrepare, maintenanceResume, staleAction } from "../web/pages/maintenance.ts"; | |
| 39 | 39 | import { maintenanceBudget } from "../web/pages/maintenance_budgets.ts"; |
| 40 | 40 | import { nightlyOutputPage, resiliencePage } from "../web/pages/resilience.ts"; |
| 41 | 41 | import { agentStartSet, billingLinksSet, limitsPage, limitsSet, quotasSet, signupSet, inviteMint, inviteRevoke } from "../web/pages/admin-limits.ts"; |
| @@ -1084,6 +1084,7 @@ export function buildRouter(): Router<Handler> { | ||
| 1084 | 1084 | router.add("POST", "/maintenance/resume", maintenanceResume); |
| 1085 | 1085 | router.add("POST", "/maintenance/budget", maintenanceBudget); |
| 1086 | 1086 | router.add("POST", "/maintenance/duties/:name", maintenanceDuty); |
| 1087 | router.add("POST", "/maintenance/stale/:id/:what", staleAction); | |
| 1087 | 1088 | router.add("GET", "/resilience/nightly/:job", nightlyOutputPage); |
| 1088 | 1089 | // A selection's spend and runs over time; literal, above /:owner. |
| 1089 | 1090 | router.add("GET", "/fleet", fleetPage); |
src/maintain/stale_pulls.ts added +164
| @@ -0,0 +1,164 @@ | ||
| 1 | /** | |
| 2 | * Pulls untouched for 14 days (#12420): a read-only finder and two explicit actions, | |
| 3 | * each receipted. | |
| 4 | * Nothing here runs by itself: a forge admin presses "Nudge" or "Close" on one row. | |
| 5 | * "Touched" is a comment, a review, an edit (all bump `issue.updated_at`) or a push to the | |
| 6 | * pull's head branch. | |
| 7 | */ | |
| 8 | ||
| 9 | import type { Database } from "bun:sqlite"; | |
| 10 | import type { App } from "../app.ts"; | |
| 11 | import { addComment, setIssueState } from "../actions/issues.ts"; | |
| 12 | import { getIssue } from "../core/issues.ts"; | |
| 13 | import { getRepoById } from "../core/repos.ts"; | |
| 14 | import { getUserById, type User } from "../core/users.ts"; | |
| 15 | import { err, ok, type Result } from "../kernel/result.ts"; | |
| 16 | import { record } from "./runs.ts"; | |
| 17 | ||
| 18 | export const STALE_DAYS = 14; | |
| 19 | const DAY_MS = 24 * 3_600_000; | |
| 20 | /** Push events read a page at a time. */ | |
| 21 | const PUSHES_PAGE = 500; | |
| 22 | export const NUDGE = "Still wanted? This pull has had no push, comment or review in 14 days. Say so here, or it may be closed."; | |
| 23 | ||
| 24 | /** | |
| 25 | * Walks `issue_open_pull_age` (created_at, id: open pulls only), then the primary key of `pull` | |
| 26 | * and of `repo` and `user`. No SCAN, no TEMP B-TREE: ordering is done after the read. | |
| 27 | */ | |
| 28 | export const STALE_SQL = `SELECT issue.id, issue.number, issue.title, issue.created_at, issue.updated_at, issue.author_id, | |
| 29 | o.username || '/' || r.name AS repo, COALESCE(pull.head_repo_id, issue.repo_id) AS head_repo, pull.head_branch, | |
| 30 | u.is_agent AS agent | |
| 31 | FROM issue INDEXED BY issue_open_pull_age | |
| 32 | JOIN pull ON pull.issue_id = issue.id | |
| 33 | JOIN repo r ON r.id = issue.repo_id JOIN user o ON o.id = r.owner_id | |
| 34 | JOIN user u ON u.id = issue.author_id | |
| 35 | WHERE issue.state = 'open' AND issue.kind = 'pull' AND issue.created_at < ?1 AND issue.updated_at < ?1`; | |
| 36 | ||
| 37 | export interface StalePull { | |
| 38 | readonly id: string; | |
| 39 | readonly repo: string; | |
| 40 | readonly number: number; | |
| 41 | readonly title: string; | |
| 42 | /** ISO time of the last push, comment or review (or the pull's opening). */ | |
| 43 | readonly lastTouched: string; | |
| 44 | readonly ageDays: number; | |
| 45 | /** An agent opened it: only then may "close" be pressed. */ | |
| 46 | readonly byAgent: boolean; | |
| 47 | } | |
| 48 | ||
| 49 | interface Row { | |
| 50 | id: string; number: number; title: string; created_at: string; updated_at: string; author_id: string; | |
| 51 | repo: string; head_repo: string; head_branch: string; agent: number; | |
| 52 | } | |
| 53 | ||
| 54 | /** | |
| 55 | * Every ref pushed to `repoId` since `cutoff`, exact: the push events newest first, a page at a | |
| 56 | * time by `event_repo_kind_seq`, until one is older than the cutoff. Cost follows the pushes of | |
| 57 | * the window, not a guess at them. | |
| 58 | */ | |
| 59 | function pushedRefs(db: Database, repoId: string, cutoff: string): Set<string> { | |
| 60 | const refs = new Set<string>(); | |
| 61 | const page = db.query<{ seq: number; created_at: string; payload: string }, [string, number, number]>( | |
| 62 | "SELECT seq, created_at, payload FROM event WHERE repo_id = ?1 AND kind = 'push' AND seq < ?2 ORDER BY seq DESC LIMIT ?3", | |
| 63 | ); | |
| 64 | let before = Number.MAX_SAFE_INTEGER; | |
| 65 | for (;;) { | |
| 66 | const events = page.all(repoId, before, PUSHES_PAGE); | |
| 67 | for (const e of events) { | |
| 68 | if (e.created_at < cutoff) return refs; | |
| 69 | try { | |
| 70 | for (const u of (JSON.parse(e.payload) as { updates?: { ref?: unknown }[] }).updates ?? []) | |
| 71 | if (typeof u.ref === "string") refs.add(u.ref); | |
| 72 | } catch { | |
| 73 | // An unreadable payload names no ref. | |
| 74 | } | |
| 75 | } | |
| 76 | if (events.length < PUSHES_PAGE) return refs; | |
| 77 | before = events[events.length - 1]!.seq; | |
| 78 | } | |
| 79 | } | |
| 80 | ||
| 81 | /** Open pulls with no push, comment or review for `days`, oldest first. Reads only. */ | |
| 82 | export function stalePulls(db: Database, now: Date, days = STALE_DAYS): StalePull[] { | |
| 83 | const cutoff = new Date(now.getTime() - days * DAY_MS).toISOString(); | |
| 84 | const out: StalePull[] = []; | |
| 85 | const pushed = new Map<string, Set<string>>(); | |
| 86 | for (const row of db.query<Row, [string]>(STALE_SQL).all(cutoff)) { | |
| 87 | let refs = pushed.get(row.head_repo); | |
| 88 | if (refs === undefined) pushed.set(row.head_repo, (refs = pushedRefs(db, row.head_repo, cutoff))); | |
| 89 | if (refs.has(`refs/heads/${row.head_branch}`)) continue; | |
| 90 | out.push({ | |
| 91 | id: row.id, | |
| 92 | repo: row.repo, | |
| 93 | number: row.number, | |
| 94 | title: row.title, | |
| 95 | lastTouched: row.updated_at, | |
| 96 | ageDays: Math.floor((now.getTime() - Date.parse(row.updated_at)) / DAY_MS), | |
| 97 | byAgent: row.agent === 1, | |
| 98 | }); | |
| 99 | } | |
| 100 | return out.sort((a, b) => a.lastTouched.localeCompare(b.lastTouched) || a.id.localeCompare(b.id)); | |
| 101 | } | |
| 102 | ||
| 103 | export type StaleError = "forbidden" | "not_found" | "not_stale" | "person_opened" | "failed"; | |
| 104 | ||
| 105 | export interface Receipt { | |
| 106 | readonly says: string; | |
| 107 | } | |
| 108 | ||
| 109 | /** The maintenance identity: the first agent seated as a maintainer, else the admin who pressed. */ | |
| 110 | function maintenanceIdentity(db: Database, admin: User): User { | |
| 111 | const row = db | |
| 112 | .query<{ user_id: string }, []>("SELECT user_id FROM agent WHERE instr(',' || roles || ',', ',maintainer,') > 0 ORDER BY user_id LIMIT 1") | |
| 113 | .get(); | |
| 114 | return (row ? getUserById(db, row.user_id) : undefined) ?? admin; | |
| 115 | } | |
| 116 | ||
| 117 | /** A row's pull, as long as it is still stale, in the shape the actions take. */ | |
| 118 | function target(app: App, admin: User | undefined, pullId: string, now: Date) { | |
| 119 | if (admin === undefined || !admin.isAdmin) return err<StaleError>("forbidden"); | |
| 120 | const stale = stalePulls(app.db, now).find((p) => p.id === pullId); | |
| 121 | if (stale === undefined) return err<StaleError>("not_stale"); | |
| 122 | const idRow = app.db.query<{ repo_id: string; number: number }, [string]>("SELECT repo_id, number FROM issue WHERE id = ?1").get(pullId); | |
| 123 | const repo = idRow && getRepoById(app.db, idRow.repo_id); | |
| 124 | const issue = repo && getIssue(app.db, repo.id, idRow.number); | |
| 125 | if (!repo || !issue) return err<StaleError>("not_found"); | |
| 126 | return ok({ stale, repo, issue }); | |
| 127 | } | |
| 128 | ||
| 129 | function receipt(app: App, said: string, now: Date): void { | |
| 130 | record(app.db, { duty: "stale-pulls", started: now, finished: now, findings: [], actions: [said], outcome: "ok" }); | |
| 131 | } | |
| 132 | ||
| 133 | /** Comment "still wanted?" on a stale pull, as the maintenance identity. Allowed on any pull. */ | |
| 134 | export function nudge(app: App, admin: User | undefined, pullId: string, now = new Date()): Result<Receipt, StaleError> { | |
| 135 | const t = target(app, admin, pullId, now); | |
| 136 | if (!t.ok) return t; | |
| 137 | const identity = maintenanceIdentity(app.db, admin!); | |
| 138 | let said = addComment(app, identity, t.value.repo, t.value.issue, NUDGE); | |
| 139 | if (!said.ok && identity.id !== admin!.id) said = addComment(app, admin, t.value.repo, t.value.issue, NUDGE); | |
| 140 | if (!said.ok) return err("failed"); | |
| 141 | const line = `asked "still wanted?" on ${t.value.stale.repo}#${t.value.stale.number} as ${identity.username}, quiet ${t.value.stale.ageDays} days (pressed by ${admin!.username})`; | |
| 142 | receipt(app, line, now); | |
| 143 | return ok({ says: line }); | |
| 144 | } | |
| 145 | ||
| 146 | /** Close a stale pull an agent opened; a person's pull is only ever nudged. */ | |
| 147 | export function closeStale(app: App, admin: User | undefined, pullId: string, now = new Date()): Result<Receipt, StaleError> { | |
| 148 | const t = target(app, admin, pullId, now); | |
| 149 | if (!t.ok) return t; | |
| 150 | if (!t.value.stale.byAgent) return err("person_opened"); | |
| 151 | const closed = setIssueState(app, admin, t.value.repo, t.value.issue, "closed", { note: `Closed: untouched for ${t.value.stale.ageDays} days.`, system: true }); | |
| 152 | if (!closed.ok) return err("failed"); | |
| 153 | const line = `closed ${t.value.stale.repo}#${t.value.stale.number}, untouched ${t.value.stale.ageDays} days (pressed by ${admin!.username})`; | |
| 154 | receipt(app, line, now); | |
| 155 | return ok({ says: line }); | |
| 156 | } | |
| 157 | ||
| 158 | export const STALE_WORDS: Record<StaleError, string> = { | |
| 159 | forbidden: "Only a forge admin may do this.", | |
| 160 | not_found: "That pull is gone.", | |
| 161 | not_stale: "That pull has been touched since the list was drawn.", | |
| 162 | person_opened: "A person opened that pull: it can be nudged, not closed.", | |
| 163 | failed: "The forge refused the change.", | |
| 164 | }; |
src/tui/screens/entries.ts +2
| @@ -70,6 +70,7 @@ import { entry as slowPagesEntry } from "./slowpages.ts"; | ||
| 70 | 70 | import { entry as maintenance } from "./maintenance.ts"; |
| 71 | 71 | import { entry as maintainRuns } from "./maintainruns.ts"; |
| 72 | 72 | import { entry as dutyBudgets } from "./dutybudgets.ts"; |
| 73 | import { entry as stalePulls } from "./stalepulls.ts"; | |
| 73 | 74 | import { entry as dutySwitch } from "./dutyswitch.ts"; |
| 74 | 75 | import { entry as mirrorPacksEntry } from "./mirrorpacks.ts"; |
| 75 | 76 | import { entry as packReposEntry } from "./packrepos.ts"; |
| @@ -138,6 +139,7 @@ export const ENTRIES: readonly PaletteEntry[] = [ | ||
| 138 | 139 | telemetry, |
| 139 | 140 | resilience, |
| 140 | 141 | maintenance, |
| 142 | stalePulls, | |
| 141 | 143 | maintainRuns, |
| 142 | 144 | dutySwitch, |
| 143 | 145 | dutyBudgets, |
src/tui/screens/stalepulls.ts added +88
| @@ -0,0 +1,88 @@ | ||
| 1 | /** | |
| 2 | * Pulls untouched for 14 days in the terminal (#12420): the /maintenance list through the same | |
| 3 | * finder (`stalePulls`) and the same actions (`nudge`, `closeStale`), behind the same gate, a | |
| 4 | * forge admin who is a person, for reads and writes alike. j/k choose a pull, `a` asks "still | |
| 5 | * wanted?", `x` closes (after a confirm; only a pull an agent opened). Esc or q closes it. | |
| 6 | */ | |
| 7 | ||
| 8 | import { STALE_DAYS, STALE_WORDS, closeStale, nudge, stalePulls, type StalePull } from "../../maintain/stale_pulls.ts"; | |
| 9 | import type { Ctx, Screen } from "../app/app.ts"; | |
| 10 | import { binding } from "../app/keys.ts"; | |
| 11 | import type { Session } from "../session.ts"; | |
| 12 | import { style } from "../term/style.ts"; | |
| 13 | import { Scroll, confirmScreen, drawLines } from "./common.ts"; | |
| 14 | import type { PaletteEntry } from "./entries.ts"; | |
| 15 | ||
| 16 | const mayAct = (session: Session): boolean => session.user?.isAdmin === true && session.user.kind !== "agent"; | |
| 17 | ||
| 18 | /** The stale pulls; none for anyone the gate refuses. */ | |
| 19 | export function stale(session: Session): StalePull[] { | |
| 20 | return mayAct(session) ? stalePulls(session.db, new Date()) : []; | |
| 21 | } | |
| 22 | ||
| 23 | /** One pull a line, the chosen one marked, oldest first. */ | |
| 24 | export function staleLines(session: Session, chosen: number): string[] { | |
| 25 | const pulls = stale(session); | |
| 26 | if (!mayAct(session)) return []; | |
| 27 | if (pulls.length === 0) return ["None."]; | |
| 28 | return pulls.map((p, i) => `${i === chosen ? ">" : " "} ${p.repo}#${p.number} ${p.title} (${p.ageDays} days)`); | |
| 29 | } | |
| 30 | ||
| 31 | /** Ask or close the chosen pull; what it says, or nothing for anyone the gate refuses. */ | |
| 32 | export function actOnStale(session: Session, chosen: number, what: "nudge" | "close"): string { | |
| 33 | if (!mayAct(session)) return ""; | |
| 34 | const p = stale(session)[chosen]; | |
| 35 | if (p === undefined) return ""; | |
| 36 | const done = (what === "nudge" ? nudge : closeStale)(session.app, session.user, p.id); | |
| 37 | return done.ok ? done.value.says : STALE_WORDS[done.error]; | |
| 38 | } | |
| 39 | ||
| 40 | export function stalePullsScreen(session: Session, ctx: Ctx): Screen { | |
| 41 | let chosen = 0; | |
| 42 | let note = ""; | |
| 43 | const screen: Screen = { | |
| 44 | title: `Pulls untouched for ${STALE_DAYS} days`, | |
| 45 | keys: [binding(["j", "k"], "choose"), binding(["a"], "ask: still wanted?"), binding(["x"], "close"), binding(["esc", "q"], "back")], | |
| 46 | render(area, s) { | |
| 47 | const c = ctx.theme.c; | |
| 48 | const lines = [...staleLines(session, chosen), ...(note === "" ? [] : ["", note])]; | |
| 49 | drawLines(s, area, c, new Scroll(), lines.map((text) => [{ text, style: style(c.fg, c.bg) }])); | |
| 50 | }, | |
| 51 | key(e) { | |
| 52 | if (e.ctrl || e.alt) return true; | |
| 53 | const count = stale(session).length; | |
| 54 | if (e.key === "esc" || e.key === "q") ctx.pop(); | |
| 55 | else if (e.key === "j" || e.key === "down") chosen = Math.min(chosen + 1, Math.max(count - 1, 0)); | |
| 56 | else if (e.key === "k" || e.key === "up") chosen = Math.max(chosen - 1, 0); | |
| 57 | else if (e.key === "a") note = actOnStale(session, chosen, "nudge"); | |
| 58 | else if (e.key === "x") { | |
| 59 | if (!mayAct(session)) return true; | |
| 60 | ctx.push( | |
| 61 | confirmScreen(ctx, screen, { | |
| 62 | title: "Close this pull?", | |
| 63 | body: ["Only a pull an agent opened can be closed."], | |
| 64 | actions: [{ label: "Cancel", variant: "ghost" }, { label: "Close", variant: "danger" }], | |
| 65 | onChoose: (i) => { | |
| 66 | if (i !== 1) return; | |
| 67 | note = actOnStale(session, chosen, "close"); | |
| 68 | ctx.invalidate(); | |
| 69 | }, | |
| 70 | }), | |
| 71 | ); | |
| 72 | return true; | |
| 73 | } else return false; | |
| 74 | ctx.invalidate(); | |
| 75 | return true; | |
| 76 | }, | |
| 77 | }; | |
| 78 | return screen; | |
| 79 | } | |
| 80 | ||
| 81 | export const entry: PaletteEntry = { | |
| 82 | id: "stale-pulls", | |
| 83 | title: "Pulls untouched for 14 days", | |
| 84 | hint: "ask whether a stale pull is still wanted, or close one an agent opened", | |
| 85 | after: ["maintenance", "maintenance-runs"], | |
| 86 | offered: mayAct, | |
| 87 | run: (session, ctx) => ctx.push(stalePullsScreen(session, ctx)), | |
| 88 | }; |
src/web/pages/maintenance.ts +38
| @@ -15,6 +15,7 @@ import { field as formField, readForm } from "../form.ts"; | ||
| 15 | 15 | import { html, type Html } from "../html.ts"; |
| 16 | 16 | import { flashTo, page } from "../layout.ts"; |
| 17 | 17 | import { badge, btn, field } from "../ui.ts"; |
| 18 | import { STALE_DAYS, STALE_WORDS, closeStale, nudge, stalePulls } from "../../maintain/stale_pulls.ts"; | |
| 18 | 19 | import { budgetOfRow } from "./maintenance_budgets.ts"; |
| 19 | 20 | |
| 20 | 21 | function admin(ctx: Ctx): Response | undefined { |
| @@ -43,6 +44,7 @@ export async function maintenancePage(ctx: Ctx): Promise<Response> { | ||
| 43 | 44 | </form>`)}${budgetOfRow(ctx.app, d.name)}`, |
| 44 | 45 | )} |
| 45 | 46 | </dl> |
| 47 | ${stalePullsSection(ctx, ctx.auth.user!.kind !== "agent")} | |
| 46 | 48 | ${s.phase === "idle" ? html`<p id="maintenance-standby" class="muted">${s.standby.says}</p>` : null} |
| 47 | 49 | ${s.phase === "idle" |
| 48 | 50 | ? html`<p class="muted">Get the forge ready for a planned power-off. What stops:</p> |
| @@ -107,3 +109,39 @@ export async function maintenanceDuty(ctx: Ctx): Promise<Response> { | ||
| 107 | 109 | const r = switchDuty(ctx.app.db, ctx.params["name"], want === "yes", ctx.auth.user!.username); |
| 108 | 110 | return flashTo(ctx, "/maintenance", r.ok ? { message: r.says } : { tone: "danger", message: r.says }); |
| 109 | 111 | } |
| 112 | ||
| 113 | /** | |
| 114 | * The section: one row per stale pull with its age; the buttons only for a forge admin who is a | |
| 115 | * person. | |
| 116 | */ | |
| 117 | export function stalePullsSection(ctx: Ctx, withActions: boolean): Html { | |
| 118 | const pulls = stalePulls(ctx.app.db, new Date()); | |
| 119 | const form = (id: string, what: "nudge" | "close", label: string): Html => | |
| 120 | html`<form method="post" action="/maintenance/stale/${id}/${what}" class="inline">${btn(label, { variant: "outline" })}</form>`; | |
| 121 | return html`<section class="settings-block" id="stale-pulls"><h2>Pulls untouched for ${String(STALE_DAYS)} days</h2> | |
| 122 | ${pulls.length === 0 | |
| 123 | ? html`<p class="muted">None.</p>` | |
| 124 | : html`<dl class="status-rows">${pulls.map( | |
| 125 | (p) => html`<div class="status-row" data-pull="${p.repo}#${String(p.number)}"><dt><a href="/${p.repo}/pulls/${String(p.number)}">${p.repo}#${String(p.number)}</a></dt> | |
| 126 | <dd>${p.title} <span class="muted">${String(p.ageDays)} days</span> | |
| 127 | ${withActions | |
| 128 | ? html`${form(p.id, "nudge", "Ask")}${p.byAgent ? form(p.id, "close", "Close") : null}` | |
| 129 | : null}</dd></div>`, | |
| 130 | )}</dl>`}</section>`; | |
| 131 | } | |
| 132 | ||
| 133 | /** | |
| 134 | * POST /maintenance/stale/:id/(nudge|close): one explicit action on one row, receipted in the | |
| 135 | * flash and the maintenance runs. | |
| 136 | */ | |
| 137 | export async function staleAction(ctx: Ctx): Promise<Response> { | |
| 138 | const user = ctx.auth.user; | |
| 139 | if (user === undefined || !user.isAdmin || user.kind === "agent") | |
| 140 | return flashTo(ctx, "/maintenance", { tone: "danger", message: STALE_WORDS.forbidden }); | |
| 141 | const form = await readForm(ctx, "admin"); | |
| 142 | if (form instanceof Response) return form; | |
| 143 | const what = ctx.params["what"]; | |
| 144 | if (what !== "nudge" && what !== "close") return flashTo(ctx, "/maintenance", { tone: "danger", message: "Nudge or close." }); | |
| 145 | const done = (what === "nudge" ? nudge : closeStale)(ctx.app, user, ctx.params["id"] ?? ""); | |
| 146 | return flashTo(ctx, "/maintenance", done.ok ? { message: done.value.says } : { tone: "danger", message: STALE_WORDS[done.error] }); | |
| 147 | } |
src/web/pages/system.ts +3 −1
| @@ -54,6 +54,7 @@ import { lastFootprint, footprintFacts, footprintVerdict, BUDGET, type Footprint | ||
| 54 | 54 | import { lastProof } from "../../release/prove.ts"; |
| 55 | 55 | import { BREAK_STEPS, MACHINES, declaredFooting, footing, offMachine, whereWords, type Footing, type Machine } from "../../system/footing.ts"; |
| 56 | 56 | import { laneWords, readOffsiteLane, type OffsiteLane } from "../../snapshot/offsite_lane.ts"; |
| 57 | import { stalePullsSection } from "./maintenance.ts"; | |
| 57 | 58 | import { shapeWords } from "../../engine/mode.ts"; |
| 58 | 59 | import { badge, chartBox, disclosure, meter, pill, row, time } from "../ui.ts"; |
| 59 | 60 | import { LARGEST_DIRS, largestDirs, type LargestDirs } from "../../system/largest_dirs.ts"; |
| @@ -620,7 +621,8 @@ export async function systemPage(ctx: Ctx): Promise<Response> { | ||
| 620 | 621 | <div id="sys-slow-pages">${slowPagesSection(timePhase(ctx.request, "slowpages", () => slowPagesCached(ctx.app.db)))}</div> |
| 621 | 622 | <div id="sys-readers">${readersSection(readerPaces())}</div> |
| 622 | 623 | <div id="sys-caches">${cachesSection(pageCaches())}</div> |
| 623 | ${memory}`; | |
| 624 | ${memory} | |
| 625 | ${stalePullsSection(ctx, false)}`; | |
| 624 | 626 | const response = page({ ctx, title: "System", body, wide: true, scriptJs: systemLiveJs }); |
| 625 | 627 | notePhase(ctx.request, "render", performance.now() - rendering); |
| 626 | 628 | return response; |
test/maintain-stale-pulls.test.ts added +125
| @@ -0,0 +1,125 @@ | ||
| 1 | /** Pulls untouched for 14 days (#12420): the finder, and one test per action. */ | |
| 2 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 3 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 4 | import { tmpdir } from "node:os"; | |
| 5 | import { join } from "node:path"; | |
| 6 | import { createApp, type App } from "../src/app.ts"; | |
| 7 | import { addCrew, createAgentRow } from "../src/core/agents.ts"; | |
| 8 | import { getIssueById, listComments } from "../src/core/issues.ts"; | |
| 9 | import { createRepo, type Repo } from "../src/core/repos.ts"; | |
| 10 | import { createUser, type User } from "../src/core/users.ts"; | |
| 11 | import { id } from "../src/kernel/id.ts"; | |
| 12 | import { STALE_SQL, closeStale, nudge, stalePulls } from "../src/maintain/stale_pulls.ts"; | |
| 13 | import { latest } from "../src/maintain/runs.ts"; | |
| 14 | import { quietLogs } from "./helpers/globals.ts"; | |
| 15 | ||
| 16 | quietLogs(); | |
| 17 | let dir = "", app: App, admin: User, person: User, agent: User, maintainer: User, repo: Repo, seq = 0; | |
| 18 | const NOW = new Date("2026-11-14T12:00:00Z"); | |
| 19 | const ago = (days: number): string => new Date(NOW.getTime() - days * 86_400_000).toISOString(); | |
| 20 | ||
| 21 | async function user(name: string, isAgent = false): Promise<User> { | |
| 22 | const made = await createUser(app.db, { username: name, email: `${name}@forge.test`, ...(isAgent ? { agent: true, origin: "agent" as const } : { password: "a-good-passphrase", origin: "seed" as const, trusted: true, ...(name === "boss" ? { isAdmin: true } : {}) }) }); | |
| 23 | if (!made.ok) throw new Error(name); | |
| 24 | if (isAgent) createAgentRow(app.db, { userId: made.value.id, brief: name, ...(name === "maint" ? { roles: ["maintainer" as const] } : {}) }); | |
| 25 | return made.value; | |
| 26 | } | |
| 27 | ||
| 28 | /** An open pull whose last touch was `days` ago. */ | |
| 29 | function pull(author: User, days: number): string { | |
| 30 | const issue = id(); | |
| 31 | const n = ++seq; | |
| 32 | app.db.query("INSERT INTO issue (id, repo_id, number, kind, title, body, author_id, state, created_at, updated_at) VALUES (?1, ?2, ?3, 'pull', ?4, '', ?5, 'open', ?6, ?6)").run(issue, repo.id, n, `Pull ${n}`, author.id, ago(days)); | |
| 33 | app.db.query("INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, head_repo_id) VALUES (?1, 'main', ?2, ?3, ?3, ?4)").run(issue, `b/${n}`, "0".repeat(40), repo.id); | |
| 34 | return issue; | |
| 35 | } | |
| 36 | ||
| 37 | beforeAll(async () => { | |
| 38 | dir = await mkdtemp(join(tmpdir(), "forge-stale-pulls-")); | |
| 39 | app = createApp({ dataDir: dir, port: 0 }); | |
| 40 | admin = await user("boss"); | |
| 41 | person = await user("pat"); | |
| 42 | agent = await user("builder", true); | |
| 43 | maintainer = await user("maint", true); | |
| 44 | const made = await createRepo(app.db, app.reposRoot, { ownerId: admin.id, name: "r", visibility: "public", description: "r" }); | |
| 45 | if (!made.ok) throw new Error("repo"); | |
| 46 | repo = made.value; | |
| 47 | addCrew(app.db, repo.id, maintainer.id, admin.id); | |
| 48 | }); | |
| 49 | afterAll(async () => { | |
| 50 | app.close(); | |
| 51 | await rm(dir, { recursive: true, force: true }); | |
| 52 | }); | |
| 53 | ||
| 54 | test("the finder lists the stale pull with its age and leaves the fresh one", () => { | |
| 55 | const stale = pull(agent, 20); | |
| 56 | const fresh = pull(agent, 2); | |
| 57 | const found = stalePulls(app.db, NOW); | |
| 58 | expect(found.map((p) => p.id)).toContain(stale); | |
| 59 | expect(found.map((p) => p.id)).not.toContain(fresh); | |
| 60 | expect(found.find((p) => p.id === stale)).toMatchObject({ ageDays: 20, byAgent: true }); | |
| 61 | }); | |
| 62 | ||
| 63 | test("a push to the head branch since the cutoff keeps a pull off the list", () => { | |
| 64 | const issue = pull(agent, 30); | |
| 65 | const branch = (app.db.query("SELECT head_branch AS b FROM pull WHERE issue_id = ?1").get(issue) as { b: string }).b; | |
| 66 | expect(stalePulls(app.db, NOW).map((p) => p.id)).toContain(issue); | |
| 67 | app.db.query("INSERT INTO event (kind, repo_id, payload, created_at) VALUES ('push', ?1, ?2, ?3)").run(repo.id, JSON.stringify({ updates: [{ ref: `refs/heads/${branch}` }] }), ago(1)); | |
| 68 | expect(stalePulls(app.db, NOW).map((p) => p.id)).not.toContain(issue); | |
| 69 | }); | |
| 70 | ||
| 71 | test("the finder walks the open-pull index with no scan and no sort", () => { | |
| 72 | const plan = app.db.query(`EXPLAIN QUERY PLAN ${STALE_SQL}`).all(ago(14)).map((r) => (r as { detail: string }).detail); | |
| 73 | expect(plan.join("\n")).toContain("issue_open_pull_age"); | |
| 74 | for (const line of plan) { | |
| 75 | expect(line).not.toMatch(/^SCAN (?!.*USING (COVERING )?INDEX)/); | |
| 76 | expect(line).not.toContain("TEMP B-TREE"); | |
| 77 | } | |
| 78 | }); | |
| 79 | ||
| 80 | test("nudge comments 'still wanted?' as the maintenance identity, receipted, on a person's pull too", () => { | |
| 81 | const issue = pull(person, 25); | |
| 82 | const r = nudge(app, admin, issue, NOW); | |
| 83 | expect(r.ok).toBe(true); | |
| 84 | const comments = listComments(app.db, issue); | |
| 85 | expect(comments).toHaveLength(1); | |
| 86 | expect(comments[0]!.body).toContain("Still wanted?"); | |
| 87 | expect(comments[0]!.authorId).toBe(maintainer.id); | |
| 88 | expect(getIssueById(app.db, issue)!.state).toBe("open"); | |
| 89 | expect(latest(app.db, 5).some((x) => x.duty === "stale-pulls" && x.actions[0]!.includes("still wanted"))).toBe(true); | |
| 90 | }); | |
| 91 | ||
| 92 | test("a nudge or close from anyone but an admin does nothing", () => { | |
| 93 | const issue = pull(agent, 25); | |
| 94 | expect(nudge(app, person, issue, NOW)).toMatchObject({ ok: false, error: "forbidden" }); | |
| 95 | expect(closeStale(app, undefined, issue, NOW)).toMatchObject({ ok: false, error: "forbidden" }); | |
| 96 | expect(listComments(app.db, issue)).toHaveLength(0); | |
| 97 | expect(getIssueById(app.db, issue)!.state).toBe("open"); | |
| 98 | }); | |
| 99 | ||
| 100 | test("close ends a stale pull an agent opened, receipted", () => { | |
| 101 | const issue = pull(agent, 25); | |
| 102 | const r = closeStale(app, admin, issue, NOW); | |
| 103 | expect(r.ok).toBe(true); | |
| 104 | expect(getIssueById(app.db, issue)!.state).toBe("closed"); | |
| 105 | expect(latest(app.db, 5).some((x) => x.actions[0]?.startsWith("closed "))).toBe(true); | |
| 106 | }); | |
| 107 | ||
| 108 | test("close refuses a pull a person opened, and a pull that is no longer stale", () => { | |
| 109 | const theirs = pull(person, 25); | |
| 110 | expect(closeStale(app, admin, theirs, NOW)).toMatchObject({ ok: false, error: "person_opened" }); | |
| 111 | expect(getIssueById(app.db, theirs)!.state).toBe("open"); | |
| 112 | const fresh = pull(agent, 1); | |
| 113 | expect(closeStale(app, admin, fresh, NOW)).toMatchObject({ ok: false, error: "not_stale" }); | |
| 114 | }); | |
| 115 | ||
| 116 | test("a push to the head branch is found however many pushes to other branches came after it", () => { | |
| 117 | const issue = pull(agent, 30); | |
| 118 | const branch = (app.db.query("SELECT head_branch AS b FROM pull WHERE issue_id = ?1").get(issue) as { b: string }).b; | |
| 119 | const add = app.db.query("INSERT INTO event (kind, repo_id, payload, created_at) VALUES ('push', ?1, ?2, ?3)"); | |
| 120 | add.run(repo.id, JSON.stringify({ updates: [{ ref: `refs/heads/${branch}` }] }), ago(3)); | |
| 121 | for (let i = 0; i < 1200; i++) add.run(repo.id, JSON.stringify({ updates: [{ ref: "refs/heads/busy" }] }), ago(2)); | |
| 122 | expect(stalePulls(app.db, NOW).map((p) => p.id)).not.toContain(issue); | |
| 123 | expect(closeStale(app, admin, issue, NOW)).toMatchObject({ ok: false, error: "not_stale" }); | |
| 124 | expect(getIssueById(app.db, issue)!.state).toBe("open"); | |
| 125 | }); |
test/maintain-stale-web.test.ts added +111
| @@ -0,0 +1,111 @@ | ||
| 1 | /** Pulls untouched for 14 days (#12420): the page section, its action and the terminal screen. */ | |
| 2 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 3 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 4 | import { tmpdir } from "node:os"; | |
| 5 | import { join } from "node:path"; | |
| 6 | import { createApp, type App } from "../src/app.ts"; | |
| 7 | import { getIssueById, listComments } from "../src/core/issues.ts"; | |
| 8 | import { createRepo, type Repo } from "../src/core/repos.ts"; | |
| 9 | import { createUser, type User } from "../src/core/users.ts"; | |
| 10 | import { id } from "../src/kernel/id.ts"; | |
| 11 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 12 | import { Session } from "../src/tui/session.ts"; | |
| 13 | import { actOnStale, staleLines } from "../src/tui/screens/stalepulls.ts"; | |
| 14 | import { quietLogs } from "./helpers/globals.ts"; | |
| 15 | ||
| 16 | quietLogs(); | |
| 17 | let dir = "", app: App, servers: Servers, admin: User, person: User, repo: Repo, seq = 0; | |
| 18 | let adminCookie = "", personCookie = ""; | |
| 19 | ||
| 20 | async function user(name: string, isAdmin: boolean): Promise<User> { | |
| 21 | const made = await createUser(app.db, { username: name, email: `${name}@forge.test`, password: "a-good-passphrase", origin: "seed", trusted: true, ...(isAdmin ? { isAdmin: true } : {}) }); | |
| 22 | if (!made.ok) throw new Error(name); | |
| 23 | return made.value; | |
| 24 | } | |
| 25 | async function login(username: string): Promise<string> { | |
| 26 | const res = await fetch(`${servers.url}/signin`, { | |
| 27 | method: "POST", | |
| 28 | redirect: "manual", | |
| 29 | headers: { "content-type": "application/x-www-form-urlencoded", origin: servers.url }, | |
| 30 | body: new URLSearchParams({ username, password: "a-good-passphrase" }), | |
| 31 | }); | |
| 32 | return (res.headers.get("set-cookie") ?? "").split(";")[0] ?? ""; | |
| 33 | } | |
| 34 | /** An open pull, quiet for 30 days, opened by `author`. */ | |
| 35 | function stalePull(author: User): string { | |
| 36 | const issue = id(); | |
| 37 | const n = ++seq; | |
| 38 | const at = new Date(Date.now() - 30 * 86_400_000).toISOString(); | |
| 39 | app.db.query("INSERT INTO issue (id, repo_id, number, kind, title, body, author_id, state, created_at, updated_at) VALUES (?1, ?2, ?3, 'pull', ?4, '', ?5, 'open', ?6, ?6)").run(issue, repo.id, n, `Quiet <b>${n}</b>`, author.id, at); | |
| 40 | app.db.query("INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, head_repo_id) VALUES (?1, 'main', ?2, ?3, ?3, ?4)").run(issue, `b/${n}`, "0".repeat(40), repo.id); | |
| 41 | return issue; | |
| 42 | } | |
| 43 | const post = (path: string, cookie: string, origin = servers.url): Promise<Response> => | |
| 44 | fetch(`${servers.url}${path}`, { method: "POST", redirect: "manual", headers: { "content-type": "application/x-www-form-urlencoded", origin, cookie }, body: "" }); | |
| 45 | ||
| 46 | beforeAll(async () => { | |
| 47 | dir = await mkdtemp(join(tmpdir(), "forge-stale-web-")); | |
| 48 | app = createApp({ dataDir: dir, port: 0 }); | |
| 49 | servers = await serve(app); | |
| 50 | admin = await user("boss", true); | |
| 51 | person = await user("pat", false); | |
| 52 | const made = await createRepo(app.db, app.reposRoot, { ownerId: admin.id, name: "r", visibility: "public", description: "r" }); | |
| 53 | if (!made.ok) throw new Error("repo"); | |
| 54 | repo = made.value; | |
| 55 | adminCookie = await login("boss"); | |
| 56 | personCookie = await login("pat"); | |
| 57 | }); | |
| 58 | afterAll(async () => { | |
| 59 | servers.stop(); | |
| 60 | app.close(); | |
| 61 | await rm(dir, { recursive: true, force: true }); | |
| 62 | }); | |
| 63 | ||
| 64 | test("the section lists a stale pull escaped, with Ask for the admin only on /maintenance and no buttons on /system", async () => { | |
| 65 | const mine = stalePull(person); | |
| 66 | const page = await (await fetch(`${servers.url}/maintenance`, { headers: { cookie: adminCookie } })).text(); | |
| 67 | expect(page).toContain("Pulls untouched for 14 days"); | |
| 68 | expect(page).toContain("Quiet <b>"); | |
| 69 | expect(page).not.toContain("Quiet <b>"); | |
| 70 | expect(page).toContain(`/maintenance/stale/${mine}/nudge`); | |
| 71 | expect(page).not.toContain(`/maintenance/stale/${mine}/close`); | |
| 72 | expect(page).not.toContain("a person opened it"); | |
| 73 | const system = await (await fetch(`${servers.url}/system`, { headers: { cookie: adminCookie } })).text(); | |
| 74 | expect(system).toContain("Pulls untouched for 14 days"); | |
| 75 | expect(system).not.toContain("/maintenance/stale/"); | |
| 76 | }); | |
| 77 | ||
| 78 | test("the action refuses a non-admin, a cross-origin post and a bad verb; an admin's ask comments once", async () => { | |
| 79 | const issue = stalePull(person); | |
| 80 | const asNobody = await post(`/maintenance/stale/${issue}/nudge`, personCookie); | |
| 81 | expect(asNobody.status).toBe(403); | |
| 82 | expect(listComments(app.db, issue)).toHaveLength(0); | |
| 83 | expect((await post(`/maintenance/stale/${issue}/nudge`, adminCookie, "https://evil.example")).status).toBe(403); | |
| 84 | await post(`/maintenance/stale/${issue}/delete`, adminCookie); | |
| 85 | expect(listComments(app.db, issue)).toHaveLength(0); | |
| 86 | expect(getIssueById(app.db, issue)!.state).toBe("open"); | |
| 87 | await post(`/maintenance/stale/${issue}/nudge`, adminCookie); | |
| 88 | expect(listComments(app.db, issue)).toHaveLength(1); | |
| 89 | await post(`/maintenance/stale/${issue}/close`, adminCookie); | |
| 90 | expect(getIssueById(app.db, issue)!.state).toBe("open"); | |
| 91 | }); | |
| 92 | ||
| 93 | test("the terminal screen lists, asks and closes for an admin who is a person, and gives anyone else nothing", () => { | |
| 94 | const issue = stalePull(admin); | |
| 95 | const agentOpened = stalePull(admin); | |
| 96 | app.db.query("UPDATE user SET is_agent = 1 WHERE id = ?1").run(admin.id); | |
| 97 | app.db.query("UPDATE issue SET author_id = (SELECT id FROM user WHERE username = 'pat') WHERE id = ?1").run(agentOpened); | |
| 98 | app.db.query("UPDATE user SET is_agent = 0 WHERE id = ?1").run(admin.id); | |
| 99 | const as = (user: User | undefined) => | |
| 100 | new Session(app, { sshUsername: "t", remoteAddress: "127.0.0.1", fingerprint: "SHA256:t", user }); | |
| 101 | const boss = as({ ...admin, isAdmin: true, kind: "user" }); | |
| 102 | expect(staleLines(boss, 0).some((l) => l.startsWith("> ") && l.includes("days"))).toBe(true); | |
| 103 | for (const who of [as(person), as({ ...admin, isAdmin: true, kind: "agent" }), as(undefined)]) { | |
| 104 | expect(staleLines(who, 0)).toEqual([]); | |
| 105 | expect(actOnStale(who, 0, "nudge")).toBe(""); | |
| 106 | } | |
| 107 | const before = listComments(app.db, issue).length; | |
| 108 | expect(actOnStale(boss, 0, "nudge")).toContain("asked"); | |
| 109 | const total = app.db.query("SELECT COUNT(*) AS n FROM comment").get() as { n: number }; | |
| 110 | expect(total.n).toBeGreaterThan(before); | |
| 111 | }); |
test/palette-roster.test.ts +1
| @@ -127,6 +127,7 @@ test("a site-admin person is offered the whole roster", () => { | ||
| 127 | 127 | ["capacity", "Capacity", "concurrency and guards, live; e changes a settable one"], |
| 128 | 128 | ["resilience", "Resilience", "where snapshots go and the mirror; each protection green, red or untested"], |
| 129 | 129 | ["maintenance", "Maintenance", "prepare the forge for a power-off, check the drain, or end maintenance"], |
| 130 | ["stale-pulls", "Pulls untouched for 14 days", "ask whether a stale pull is still wanted, or close one an agent opened"], | |
| 130 | 131 | ["maintenance-runs", "Maintenance duty runs", "what each duty found, did and probed"], |
| 131 | 132 | ["maintenance-duties", "Pause or resume a maintenance duty", "switch a duty off, or on again after it paused itself"], |
| 132 | 133 | ["maintenance-budgets", "Set a maintenance duty's budget", "runs per day and dollars per day a duty may use"], |
test/system-parts.test.ts +1
| @@ -62,6 +62,7 @@ test("one <h2> per part, each in a settings-block, and no card", async () => { | ||
| 62 | 62 | "Telemetry readers", |
| 63 | 63 | "Code page caches, since start", |
| 64 | 64 | "Forge memory", |
| 65 | "Pulls untouched for 14 days", | |
| 65 | 66 | ]); |
| 66 | 67 | expect(main.match(/<section class="settings-block"/g)?.length).toBe(heads.length); |
| 67 | 68 | for (const id of ["sys-dup", "summary", "cores", "mem", "temps", "sys-disks", "sys-procs", "sys-lag", "sys-stalls", "sys-readers", "sys-caches"]) { |
new above
offline
High: only the newest 100 push events of the head repo are read. On a busy repo an active pull is listed stale, and Close (destructive) can end it. Make the check exact, or refuse the action when the window was exhausted without reaching the cutoff.