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

/status answers in one sentence whether the forge is working, and names what is not #13215

Merged opened this

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

Merged

scout/forge:scout/13211-status-answers-in-one-sentence-whether-t → main 9 commits fork 3 threads · 3 unresolved

  • Merged. scout/13211-status-answers-in-one-sentence-whether-t was merged into main as 5a6cb3f.

Review

Sign in to review this change.
18 files changed +505 −40
docs/STATUS.md +1
@@ -139,6 +139,7 @@ cannot confirm. A package registry is not shipped yet.
139139 working issues in the background with Claude Code and proposing through
140140 pulls a person merges.
141141 - **The `flow` label**: ready issues labelled `flow` go first; no switch, no state.
142 - **`/status`**: one sentence, signed out, always 200: `All working.`, `Slowed: <cause>.` or `Down since <time>.`, over three rows (pages and sign-in, building, billing records), each `ok`, `slow` or `down` from a real signal. `Accept: application/json` gives the same words as data; the palette's *Status* shows them in the terminal. Words come from a fixed table (`src/core/status_words.ts`), never copied from errors.
142143
143144 Pages render without a line of JavaScript and are designed thumb-first. Six
144145 premade themes (from warm paper to polar night) switch instantly and persist in
docs/design/audit.md +1
@@ -102,6 +102,7 @@ Machine routes are not pages and have no entry: `/audit.csv`,
102102 - `/claim` — `pages/claim.ts` · claim a forge that was sent to me · none · colour 1.
103103 - `/welcome` — `pages/claim.ts` (`welcomePage`) · the account screen of a forge you just started: make your account · none · none seen.
104104 - `/privacy` — `pages/privacy.ts` · what the forge keeps about a visitor, three plain lines, open to anyone · none · none seen.
105 - `/status` — `pages/status.ts` · is the forge working, one sentence and five rows, open to anyone · none · none seen.

Non-blocking: says 'five rows'; the page ships three. Say three.

105106 - `/first-admin` — `pages/first-admin.ts` · the first person becomes admin · none · none seen.
106107 - `/fleet/graph` — `pages/fleet-graph.ts` · the fleet as a graph · `/family`, `/forges` · none seen.
107108 - `/fleet` — `pages/fleet.ts` · the rows a fleet query line selects, as a table · `/fleet/graph` · none seen.
docs/features/README.md +15
@@ -24,12 +24,14 @@ Read with the guide page [What a forge is](../guide-what-a-forge-is.md).
2424 - [Engine shape](engine-shape.md)
2525 - [Feed fold](feed-fold.md)
2626 - [A feed post has a permalink](feed-permalink.md)
27 - [A run post opens its log](feed-run-log.md)
2728 - [Feed likes: the ledger](feed-like-ledger.md)
2829 - [Forge packs: a premade forge to deploy (`/packs`)](packs.md)
2930 - [Home paints its frame first](home-frame.md)
3031 - [Is v1.0.0 proven?](v1-proven.md)
3132 - [Looks of `/` signed out](home-looks.md)
3233 - [Milestones at the front door](front-milestones.md)
34 - [Migration mode: a crew whose standing job is parity](migration-mode.md)
3335 - [Now pages and Repositories](now-pages.md)
3436 - [Pixel art: the crew's faces](pixel.md)
3537 - [Plans on the home](home-plans.md)
@@ -37,6 +39,7 @@ Read with the guide page [What a forge is](../guide-what-a-forge-is.md).
3739 - [Template mark](repo-template.md)
3840 - [Who changed a setting, and when](setting-history.md)
3941 - [A new forge can start from a template repository](new-forge-template.md)
42 - [Made from: the template a forge came from](made-from.md)
4043 - [The explorer's sorts](explore.md)
4144 - [The feed pages by cursor](feed-cursor.md)
4245 - [The fork tree](fork-tree.md)
@@ -78,6 +81,7 @@ Read with the guide page [Your first app in five minutes](../guide-first-app.md)
7881
7982 Read with the guide page [Tell the crew](../guide-tell-the-crew.md).
8083
84 - [Dictate into the tell box](speak.md)
8185 - [A bug closes with a reason](bug-close.md)
8286 - [A business, as a map](atlas-plan.md)
8387 - [A maintainer keeps the code easy to change, and nothing else](crew-maintainer.md)
@@ -89,6 +93,7 @@ Read with the guide page [Tell the crew](../guide-tell-the-crew.md).
8993 - [A tell from a preview's toolbar carries its pull](toolbar-tell.md)
9094 - [A write the restart cut short, in a conversation](talk-resume-writes.md)
9195 - [Actions that answer at once](act-now.md)
96 - [A thread folds its settled history](thread-fold.md)
9297 - [An agent says what it does; a repo's team is three lists](crew-roles.md)
9398 - [An assigned ask can be settled where it stands](ask-settles.md)
9499 - [Ask filters](ask-filters.md)
@@ -141,6 +146,7 @@ Read with the guide page [Tell the crew](../guide-tell-the-crew.md).
141146 - [The week is one budget for the whole crew](crew-week.md)
142147 - [The week's pace](week-pace.md)
143148 - [Walking a wave](wave-walk.md)
149 - [The wave-standing line](wave-standing.md)
144150 - [What became of the first ask](ask-status.md)
145151 - [When a setting or a permission stands in the way](blocked-by.md)
146152 - [The map's growth line](map-growth.md)
@@ -190,6 +196,7 @@ Read with the guide page [Ship and undo](../guide-ship-and-undo.md).
190196 Read with the guide page [Your apps](../guide-your-apps.md).
191197
192198 - [An app refused an outside host says so in the forge's words](app-egress-refused.md)
199 - [What the crew is doing, as one sentence per app](apps-crew-sentence.md)
193200 - [A child forge's own source](own-source.md)
194201 - [A forge that runs its own code](own-code.md)
195202 - [Absorb, reviewed from several angles](absorb-review.md)
@@ -246,6 +253,7 @@ Read with the guide page [Your apps](../guide-your-apps.md).
246253 - [An OpenAPI document opens as its operations](file-openapi.md)
247254 - [Calendar files (.ics) as a list of events](ics.md)
248255 - [Config files as a form](config-form.md)
256 - [A refused form keeps what was typed](form-keeps-input.md)
249257 - [Contacts files (.vcf) as a list of people](vcf-view.md)
250258 - [CSV and TSV as a table](csv-view.md)
251259 - [Video-edit timelines (.otio, .edl, .fcpxml) as a cut list](timeline-cut-list.md)
@@ -256,6 +264,7 @@ Read with the guide page [Your apps](../guide-your-apps.md).
256264 - [GeoJSON (.geojson) as an outline and a properties table](geojson.md)
257265 - [GPS tracks (.gpx) as a route outline](gpx.md)
258266 - [HTML preview](html-preview.md)
267 - [A half-written tell is kept](kept-tell.md)
259268 - [Jupyter notebooks](notebook.md)
260269 - [Markdown relative images and links](markdown-relative.md)
261270 - [Notebooks, JSON Lines and logs in the terminal](terminal-workspace-kinds.md)
@@ -284,6 +293,7 @@ Read with the guide page [Hosting forges for others, and getting paid](../guide-
284293 - [A pinned forge](pinned-forge.md)
285294 - [Billing](billing.md)
286295 - [Buy a forge at /pricing](pricing.md)
296 - [What a paid forge is, at /terms](billing.md#what-a-paid-forge-is-at-terms-13207)
287297 - [Buy links](billing-links.md)
288298 - [Capacity flags a count set below its ceiling](capacity.md)
289299 - [Cloud accounts](cloud.md)
@@ -314,6 +324,7 @@ Read with the guide page [Hosting forges for others, and getting paid](../guide-
314324 - [The page that answers "make me a forge"](forge-made.md)
315325 - [The Plan row in a forge's settings](plan-row.md)
316326 - [The selling funnel](selling-funnel.md)
327 - [A taken forge name: refused with two free ones](spawn-name-taken.md)
317328 - [The spawner's claim link](spawner-claim-link.md)
318329 - [The statement — what the forge would charge an app](statement.md)
319330 - [Ways to the fleet graph](fleet-graph-doors.md)
@@ -364,6 +375,7 @@ Read with the guide page [Agents: MCP, git, or the terminal](../guide-agents.md)
364375 - [The Muse test: how an outsider reports a problem](muse-test.md)
365376 - [Offering a patch with no account](offer.md)
366377 - [The report form for outsiders](report-form.md)
378 - [The receipt an outsider is handed for a report](report-receipt.md)
367379 - [Which harness holds a token](tokens-harness.md)
368380
369381 ### Backups and moving
@@ -397,6 +409,7 @@ Read with the guide page [Backups and moving](../guide-backups-moving.md).
397409 Read with the guide page [Every setting, by topic](../guide-settings.md).
398410
399411 - [Account settings help](account-help.md)
412 - [Security, for a visitor](security.md)
400413 - [Devices](devices.md)
401414 - [Edge-only accounts](edge-only-accounts.md)
402415 - [Knobs](knobs.md)
@@ -454,3 +467,5 @@ Read with the guide page [When something is wrong](../guide-when-wrong.md).
454467 - [The rule watcher](rule-watcher.md)
455468 - [Try again on an issue the crew parked twice](crew-try-again.md)
456469 - [What holds a ready issue](map-held.md)
470 - [Who liked a post](likers.md)
471 - [The price of a forge, first on /pricing](pricing-price-line.md)
src/actions/health.ts +1 −1
@@ -104,7 +104,7 @@ export function withHeavyAskers(v: Vitals, app: App, now: number = Date.now()):
104104 ...v,
105105 needs: [...v.needs, ...heavy.map((a) => a.sentence)],
106106 todo: [...v.todo, ...heavy.map((a) => a.sentence)],
107 degraded: [...v.degraded, ...heavy.map((a) => ({ cause: `asking:${a.token}`, sentence: a.sentence, since, href: "/system#asking" }))],
107 degraded: [...v.degraded, ...heavy.map((a) => ({ cause: `asking:${a.token}`, sentence: a.sentence, since, href: "/system#asking", broken: false }))],
108108 };
109109 }
110110
src/core/status_words.ts added +145
@@ -0,0 +1,145 @@
1 /**
2 * What the forge says about itself to anyone who asks "is it down or is it me?"
3 * (#13211): one sentence, then three rows. The page (`web/pages/status.ts`), its
4 * JSON answer and the terminal screen (`tui/screens/status.ts`) read this one
5 * function, so they cannot disagree.
6 *
7 * A row is shown only where the forge has a real signal behind it:
8 * - "pages and sign-in": the forge's own health (it answers, the database
9 * answers, it is not restarting) and the vitals that stop or slow serving
10 * (memory, disk, crash loop, error burst);
11 * - "building": the check lane (queue, stuck runs, a red main);
12 * - "billing records": the cost ledger's chain.
13 * There is no row for previews or apps: nothing here measures them, and an
14 * "ok" nobody checked is worse than no row.
15 *
16 * Every word comes from a fixed table below. A cause's own sentence, an app's
17 * name, a host or an error line is never copied.
18 */
19
20 import type { App } from "../app.ts";
21 import { forgeVitals } from "../actions/health.ts";
22 import { ledgerNeed } from "./ledger.ts";
23 import { forgeHealth } from "../kernel/guard.ts";
24
25 export type Row = "pages and sign-in" | "building" | "billing records";
26 export type RowState = "ok" | "slow" | "down";
27
28 /** The rows, in the order they are shown. */
29 export const ROWS: readonly Row[] = ["pages and sign-in", "building", "billing records"];
30
31 export interface StatusWords {
32 /** `All working.`, `Slowed: <cause>.`, `Down since <time>.` or `Down.` */
33 readonly sentence: string;
34 readonly state: "working" | "slowed" | "down";
35 readonly rows: readonly { readonly name: Row; readonly state: RowState }[];
36 }
37
38 /** What the forge was told, reduced to the plain facts: no sentence of its own survives. */
39 export interface StatusInput {
40 readonly ok: boolean;
41 readonly draining: boolean;
42 /**
43 * Each cause key the forge is degraded by, whether it stops serving, and since when it was first
44 * seen (ISO).
45 */
46 readonly causes: readonly { readonly cause: string; readonly broken: boolean; readonly since: string }[];
47 readonly ledgerBroken: boolean;
48 }
49
50 const starts = (...p: string[]) => (c: string) => p.some((x) => c === x || c.startsWith(`${x}:`));
51
52 /**
53 * Standing wishes the forge serves through: a drill owed, a backup place, a setting. Never a
54 * slowdown.
55 */
56 const WISHES = starts(
57 "disk-80", "disk-70", "db-size", "db-growth", "forges-memory", "access-log", "alarm", "backup", "drill",
58 "mirror", "snapshots", "snapshot-failed", "budget", "file", "probe", "asking", "release",
59 );
60 /** What touches the check lane. */
61 const BUILDING = starts("queue", "stuck", "red", "shared");
62
63 const PLAIN: Readonly<Record<Row, string>> = {
64 "pages and sign-in": "pages are slower than usual",
65 building: "building is slower than usual",
66 "billing records": "billing records need a look",
67 };
68 /** A cause this table has never heard of is said, not hidden. */
69 const GENERIC = "something is slower than usual";
70
71 /** `14:05 UTC` from an ISO instant, or null when it is not one. */
72 function at(iso: string): string | null {
73 const t = Date.parse(iso);
74 return Number.isNaN(t) ? null : `${new Date(t).toISOString().slice(11, 16)} UTC`;
75 }
76
77 /** The pure part: facts in, words out. */
78 export function statusOf(input: StatusInput): StatusWords {
79 const state = new Map<Row, RowState>(ROWS.map((r) => [r, "ok"]));
80 const raise = (row: Row, s: RowState) => {
81 if (state.get(row) === "ok" || s === "down") state.set(row, s);
82 };
83 const slow: string[] = [];
84 const brokenSince: string[] = [];
85 for (const c of input.causes) {
86 if (!c.broken && WISHES(c.cause)) continue;
87 const row: Row = BUILDING(c.cause) ? "building" : "pages and sign-in";
88 raise(row, c.broken ? "down" : "slow");
89 if (c.broken) brokenSince.push(c.since);
90 else slow.push(starts("queue", "stuck", "red", "shared", "memory", "memory-growth", "disk", "disk-floor", "errors", "internal", "crash-loop")(c.cause) ? PLAIN[row] : GENERIC);
91 }
92 if (input.ledgerBroken) {
93 raise("billing records", "slow");
94 slow.push(PLAIN["billing records"]);
95 }
96 if (input.draining) {
97 raise("pages and sign-in", "slow");
98 slow.unshift("the forge is restarting");
99 }
100
101 if (!input.ok || brokenSince.length > 0) {
102 raise("pages and sign-in", "down");
103 const first = brokenSince.filter((s) => at(s) !== null).sort()[0];
104 // The time is when the forge first saw the cause; with none to name, no time is made up.
105 return { sentence: first === undefined ? "Down." : `Down since ${at(first)}.`, state: "down", rows: rowsOf(state) };
106 }
107 if (slow.length > 0) return { sentence: `Slowed: ${slow[0]}.`, state: "slowed", rows: rowsOf(state) };
108 return { sentence: "All working.", state: "working", rows: rowsOf(state) };
109 }
110
111 const rowsOf = (m: Map<Row, RowState>) => ROWS.map((name) => ({ name, state: m.get(name)! }));
112
113 /** Each row's one word: `ok`, or why not. */
114 export const WORD: Readonly<Record<RowState, string>> = { ok: "ok", slow: "slow", down: "down" };
115
116 /**
117 * The words for this forge now, held at most `statusReuse.ms` (10 s; none under `bun test` unless a
118 * test sets it).
119 */
120 export const statusReuse = { ms: process.env["NODE_ENV"] === "test" ? 0 : 10_000 };
121 const kept = new WeakMap<App, { at: number; words: StatusWords }>();
122
123 export function statusWords(app: App, now: number = Date.now()): StatusWords {
124 const hit = kept.get(app);
125 if (statusReuse.ms > 0 && hit !== undefined && now - hit.at < statusReuse.ms) return hit.words;
126 const health = forgeHealth();
127 const v = forgeVitals(app);
128 const words = statusOf({
129 ok: health.ok && v.ok,
130 draining: health.draining,
131 causes: v.degraded.map((d) => ({ cause: d.cause, broken: d.broken, since: d.since })),
132 ledgerBroken: ledgerNeed() !== null,
133 });
134 kept.set(app, { at: now, words });
135 return words;
136 }
137
138 /** The JSON answer: the same words, as data. */
139 export function statusJson(w: StatusWords): { status: string; sentence: string; rows: Record<string, string> } {
140 return {
141 status: w.state,
142 sentence: w.sentence,
143 rows: Object.fromEntries(w.rows.map((r) => [r.name, WORD[r.state]])),
144 };
145 }
src/http/route_marks.ts +13 −3
@@ -16,7 +16,10 @@ import { Router } from "./router.ts";
1616
1717 export type Mark = "admin" | "open";
1818
19 /** Every head of a registered route: one mark for all of it, or `mixed` when each route is listed below. */
19 /**
20 * Every head of a registered route: one mark for all of it, or `mixed` when each route is listed
21 * below.
22 */
2023 export const HEADS: Readonly<Record<string, Mark | "mixed">> = {
2124 "/": "open",
2225 "/-": "open",
@@ -158,6 +161,7 @@ export const HEADS: Readonly<Record<string, Mark | "mixed">> = {
158161 "/plugins": "open",
159162 "/pricing": "open",
160163 "/privacy": "open",
164 "/status": "open",
161165 "/recover": "open",
162166 "/releases": "admin",
163167 "/releases.json": "open",
@@ -422,7 +426,10 @@ export function markOf(pattern: string): Mark | undefined {
422426 }
423427
424428 let listed: Router<Mark> | undefined;
425 /** ROUTES as a matcher, literal segments before parameters so `/packs/new` is not read as `/packs/:name`. */
429 /**
430 * ROUTES as a matcher, literal segments before parameters so `/packs/new` is not read as
431 * `/packs/:name`.
432 */
426433 function listedRoutes(): Router<Mark> {
427434 if (listed !== undefined) return listed;
428435 const params = (p: string) => p.split("/").filter((s) => s.startsWith(":") || s.startsWith("*")).length;
@@ -432,7 +439,10 @@ function listedRoutes(): Router<Mark> {
432439 return (listed = matcher);
433440 }
434441
435 /** Whether a request path falls on a route marked `admin`; unlisted under a `mixed` head counts as `admin`. */
442 /**
443 * Whether a request path falls on a route marked `admin`; unlisted under a `mixed` head counts as
444 * `admin`.
445 */
436446 export function isAdminRoute(path: string): boolean {
437447 const own = listedRoutes().match("*", path);
438448 if (own !== undefined) return own.handler === "admin";
src/http/server.ts +11 −5
@@ -24,6 +24,7 @@ import { secureFor } from "./cookie_secure.ts";
2424 import { refusedByDatabase, shownRefusal } from "./refusal.ts";
2525 import { NOT_A_MEMBER } from "../core/roles.ts";
2626 import { privacyPage } from "../web/pages/privacy.ts";
27 import { statusPage } from "../web/pages/status.ts";
2728 import { startClaimAccountSubmit, startClaimPage, startClaimSubmit } from "../web/pages/start_claim.ts";
2829 import { signupOptions, signupPasskey } from "../web/pages/signup-passkey.ts";
2930 import { toolbarComment, toolbarPage } from "../web/studio/toolbar.ts";
@@ -912,7 +913,8 @@ export function buildRouter(): Router<Handler> {
912913 router.add("GET", "/", home);
913914 // The home is `/`; its old address goes there (web/pages/home_flow.ts). Literal, above /:owner.
914915 router.add("GET", "/home", homeRedirect);
915 // The new home's action bar: preview or apply one bulk action over the rows picked (web/pages/home_table.ts).
916 // The new home's action bar: preview or apply one bulk action over the rows picked
917 // (web/pages/home_table.ts).
916918 router.add("POST", "/home/act", homeActPost);
917919 router.add("POST", "/desk", deskLeave);
918920 router.add("POST", "/desk/clear", deskClear);
@@ -1044,7 +1046,8 @@ export function buildRouter(): Router<Handler> {
10441046 router.add("GET", "/new/issue", newIssueAnywhere);
10451047 router.add("GET", "/repos", myReposPage);
10461048 router.add("GET", "/displays", displaysPage);
1047 // A repository's display, read only (`display.ts`): 404 without a display.json or without read access.
1049 // A repository's display, read only (`display.ts`): 404 without a display.json or without read
1050 // access.
10481051 router.add("GET", "/:owner/:name/display", displayPage);
10491052 router.add("POST", "/:owner/:name/display", displayChoose);
10501053 router.add("GET", "/now/:stage", nowPage);
@@ -1052,6 +1055,7 @@ export function buildRouter(): Router<Handler> {
10521055 router.add("GET", "/releases", releasesPage);
10531056 // The forge's own documentation: a redirect built from configuration only.
10541057 router.add("GET", "/privacy", privacyPage);
1058 router.add("GET", "/status", statusPage);
10551059 router.add("GET", "/docs", docsFolder);
10561060 router.add("GET", "/docs/:file", docsFile);
10571061 router.add("GET", "/docs/features/:file", docsFeature);
@@ -1080,8 +1084,9 @@ export function buildRouter(): Router<Handler> {
10801084 router.add("GET", "/migrate/jobs/:job", migrationJobPage);
10811085 // Every app on one canvas; a literal route, so it must sit above /:owner.
10821086 router.add("GET", "/map", globalMapPage);
1083 // The pipeline moved to a panel on /boards (#2774); the old address follows it. Literal, above /:owner.
1084 // /flow is the week's valves (#8698); a query string is an old pipeline drill, which went to /boards.
1087 // The pipeline moved to a panel on /boards (#2774); the old address follows it. Literal, above
1088 // /:owner. /flow is the week's valves (#8698); a query string is an old pipeline drill, which
1089 // went to /boards.
10851090 router.add("GET", "/flow", flowPage);
10861091 router.add("POST", "/flow/valve", valveSet);
10871092 router.add("POST", "/flow/backup/retry", backupRetry);
@@ -2733,7 +2738,8 @@ export async function serve(app: App): Promise<Servers> {
27332738 });
27342739 // The minute ledger's history: one write a minute, never on a request.
27352740 const trafficWriter = createTrafficWriter(app.db, liveOf(app).perfRecord.ledger, app.log);
2736 // Page views are buffered by the beacon doors and written here; GitHub's traffic is pulled daily when a token is set.
2741 // Page views are buffered by the beacon doors and written here; GitHub's traffic is pulled daily
2742 // when a token is set.
27372743 const viewWriter = createViewWriter(app.db, app.log);
27382744 const githubPull = startGithubPull(app.db, app.log);
27392745 const featureSchedule = startFeatureSchedule(app);
src/kernel/vitals.ts +24 −10
@@ -54,7 +54,10 @@ import { diskRedSentence, diskReds } from "../checks/disk_red.ts";
5454 import { flakeList, type FlakeRow } from "../checks/flake.ts";
5555 import { flakeHref, sharedCause, sharedSentence, sharedTests } from "../checks/shared_red.ts";
5656
57 /** A red in a repository other than the forge's own is not fixable from here: say so, so it reads as known. */
57 /**
58 * A red in a repository other than the forge's own is not fixable from here: say so, so it reads as
59 * known.
60 */
5861 function foreignNote(repo: string): string {
5962 return repo === ownRepoPath() ? "" : " Not fixable from this forge: it is another repository's to fix.";
6063 }
@@ -101,16 +104,20 @@ export type NeedKind = "broken" | "todo";
101104 * One cause of the forge being off: the `needs` sentence, a `cause` key that
102105 * holds for as long as its condition does (`memory`, `disk`, `disk-floor`, `disk-80`, `disk-70`,
103106 * `db-size`, `db-growth`, `forges-memory`, `errors`, `internal`,
104 * `queue:<kind>`, `release`, `stuck:<runId>`, `red:<repoId>`, `shared:<repoId>:<test>`), when it began by the forge's own evidence
105 * (the oldest evidence the forge holds, else the first time this process saw
106 * it, held until the cause clears; `at` is never the answer to a repeat
107 * call), and where to look.
107 * `queue:<kind>`, `release`, `stuck:<runId>`, `red:<repoId>`, `shared:<repoId>:<test>`), when it
108 * began by the forge's own evidence (the oldest evidence the forge holds, else the first time this
109 * process saw it, held until the cause clears; `at` is never the answer to a repeat call), and
110 * where to look.
108111 */
109112 export interface Degraded {
110113 readonly cause: string;
111114 readonly sentence: string;
112115 readonly since: string;
113116 readonly href: string;
117 /**
118 * The forge is not serving as it should because of this: it was raised as `broken`, not `todo`.
119 */
120 readonly broken: boolean;
114121 /**
115122 * The repository the card is about, and a link each for what in it to act on (a broken
116123 * branch's delete).
@@ -206,7 +213,10 @@ export interface VitalsInput {
206213 readonly runLimits?: BudgetLimits;
207214 /** One forge's own signals (`App.signals`). */
208215 readonly signals: { errors: ErrorLedger; refused: RefusedLedger };
209 /** Where snapshots go: the directory, when the store is one, and whether an off-box mirror copies them. */
216 /**
217 * Where snapshots go: the directory, when the store is one, and whether an off-box mirror copies
218 * them.
219 */
210220 readonly snapshots?: { readonly dir?: string; readonly mirrored: boolean } | undefined;
211221 /**
212222 * The one line said while the hosted forges' sizes together pass the
@@ -343,7 +353,9 @@ export interface LaneRun {
343353 }
344354
345355
346 /** Agent slots are held per issue (`pump` in crew/dispatch.ts); any other kind holds one per run. */
356 /**
357 * Agent slots are held per issue (`pump` in crew/dispatch.ts); any other kind holds one per run.
358 */
347359 function holders(issues: (string | null)[], perIssue: boolean): number {
348360 return perIssue ? new Set(issues).size : issues.length;
349361 }
@@ -443,7 +455,7 @@ export function vitals(input: VitalsInput): Vitals {
443455 }
444456 needs.push(sentence);
445457 (kind === "broken" ? broken : todo).push(sentence);
446 degraded.push({ cause, sentence, since, href, ...(about === undefined ? {} : { repo: about.repo, links: about.links }) });
458 degraded.push({ cause, sentence, since, href, broken: kind === "broken", ...(about === undefined ? {} : { repo: about.repo, links: about.links }) });
447459 };
448460
449461 // Free memory under the floor the forge keeps for itself: what it serves with is gone.
@@ -675,7 +687,8 @@ export function vitals(input: VitalsInput): Vitals {
675687 for (const left of leftOutNeeds(lastSnapshotOutcome(input.dataDir)))
676688 need("todo", left.cause, left.sentence, left.since, left.href, left.links === undefined ? undefined : { repo: left.repo, links: left.links });
677689
678 // The bucket itself, read by this process: late, unreadable, a failed drill, or a check that stopped is one card.
690 // The bucket itself, read by this process: late, unreadable, a failed drill, or a check that
691 // stopped is one card.
679692 if (isWatched(input.dataDir)) {
680693 const backup = backupVerdict(input.dataDir, lastDrill(input.db), now);
681694 if (backup.state === "red") need("todo", "backup", [...backup.reasons, ...(backup.reasons.some((r) => r.includes("last ran")) ? [] : [backup.checkLine])].join(" "), backup.checkedAt ?? undefined, "/settings/backups");
@@ -702,7 +715,8 @@ export function vitals(input: VitalsInput): Vitals {
702715 const undone = rollbackNeed(input.dataDir);
703716 if (undone !== undefined) need("todo", "release:rolled-back", redactSecrets(undone.sentence), undone.since, "/board");
704717
705 // Production serving a version older than a release main has had over an hour is a card until they match.
718 // Production serving a version older than a release main has had over an hour is a card until
719 // they match.
706720 const lagging = behindStanding(now);
707721 if (lagging !== undefined) need("todo", "release:behind", `${lagging.sentence}.`, lagging.since, "/board");
708722
src/tui/forge.ts +12 −5
@@ -18,6 +18,7 @@ import { sourceFor } from "../view/source.ts";
1818 import { fleetCommand } from "./screens/fleet.ts";
1919 import { dataCommand } from "./screens/data.ts";
2020 import { packsCommand } from "./screens/packs.ts";
21 import { statusCommand } from "./screens/status.ts";
2122 import { needsCommands } from "./screens/needs.ts";
2223 import { asksAdminCommands } from "./screens/asks_admin.ts";
2324 import { shareTellCommand } from "./screens/share_tell.ts";
@@ -264,6 +265,7 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
264265 ...needsCommands(session, ctx),
265266 ...asksAdminCommands(session, ctx),
266267 packsCommand(session, ctx),
268 statusCommand(session, ctx),
267269 shareTellCommand(session, ctx),
268270 sendChangeCommand(ctx),
269271 interruptedOutCommand(session, ctx),
@@ -359,7 +361,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
359361 hint: "paste a link from another forge; it runs here",
360362 run: () => ctx.push(bringScreen(session, ctx, blank("Bring an app"))),
361363 });
362 // An organization you own, as /organizations/new and MCP `org_create` make it: a person's, never an agent's (#7260).
364 // An organization you own, as /organizations/new and MCP `org_create` make it: a person's,
365 // never an agent's (#7260).
363366 if (session.user !== undefined && session.user.kind !== "agent")
364367 commands.push({
365368 id: "new-org",
@@ -543,7 +546,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
543546 hint: "concurrency and guards, live; e changes a settable one",
544547 run: () => ctx.push(capacityScreen(session, ctx)),
545548 });
546 // What crawlers cost and who was refused, as GET /api/v1/admin/crawlers: the capacity screen's readers.
549 // What crawlers cost and who was refused, as GET /api/v1/admin/crawlers: the capacity screen's
550 // readers.
547551 if (mayCapacity(session))
548552 commands.push({
549553 id: "crawlers",
@@ -572,7 +576,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
572576 hint: "the last 30 releases and their pulls",
573577 run: () => ctx.push(changelogScreen(session, ctx)),
574578 });
575 // The live release and the kept ones, as /releases gates them: a site admin or a reader of FORGE_REPO.
579 // The live release and the kept ones, as /releases gates them: a site admin or a reader of
580 // FORGE_REPO.
576581 if (mayRead(session.app, session.user))
577582 commands.push({
578583 id: "releases",
@@ -620,7 +625,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
620625 hint: "internal hosts an origin may reach",
621626 run: () => ctx.push(trustedHostsPrompt(session, ctx, blank("Trusted hosts"))),
622627 });
623 // Usage: the forge's spend for any signed-in user (#8308); the route list stays the page's gate, the same as Flags (#1565).
628 // Usage: the forge's spend for any signed-in user (#8308); the route list stays the page's
629 // gate, the same as Flags (#1565).
624630 if (session.user !== undefined)
625631 commands.push({
626632 id: "usage",
@@ -652,7 +658,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
652658 hint: "what your crew may spend, and add your own subscription",
653659 run: () => ctx.push(modelScreen(session, ctx)),
654660 });
655 // The caller's own role and row of the roles table, as /settings and `whoami_can` have it (#2304).
661 // The caller's own role and row of the roles table, as /settings and `whoami_can` have it
662 // (#2304).
656663 if (session.user !== undefined)
657664 commands.push({
658665 id: "can",
src/tui/screens/status.ts added +44
@@ -0,0 +1,44 @@
1 /**
2 * `/status` in the terminal (#13211): the one sentence and the rows the page
3 * shows, from the same `statusWords`. Anyone may open it; read-only.
4 */
5
6 import { statusWords, WORD } from "../../core/status_words.ts";
7 import type { Ctx, Screen } from "../app/app.ts";
8 import { binding } from "../app/keys.ts";
9 import type { Session } from "../session.ts";
10 import { style } from "../term/style.ts";
11 import { pad } from "../term/width.ts";
12
13 /** The screen's lines: the sentence, then each row's name and word. */
14 export function statusLines(session: Session): string[] {
15 const w = statusWords(session.app);
16 return [w.sentence, "", ...w.rows.map((r) => `${pad(r.name, 20)}${WORD[r.state]}`)];
17 }
18
19 export function statusScreen(session: Session, ctx: Ctx): Screen {
20 return {
21 title: "Status",
22 keys: [binding(["esc", "q"], "back")],
23 render(area, s) {
24 const c = ctx.theme.c;
25 statusLines(session).forEach((text, i) => {
26 if (i < area.h) s.text(area.x + 1, area.y + i, text, style(i === 0 ? c.fg : c.mutedFg, c.bg), area.x + area.w);
27 });
28 },
29 key(e) {
30 if (e.key === "esc" || e.key === "q") {
31 ctx.pop();
32 return true;
33 }
34 return false;
35 },
36 };
37 }
38
39 export const statusCommand = (session: Session, ctx: Ctx) => ({
40 id: "status",
41 title: "Status",
42 hint: "is the forge working, in one sentence",
43 run: () => ctx.push(statusScreen(session, ctx)),
44 });
src/web/layout.ts +22 −6
@@ -222,7 +222,10 @@ export interface PageOptions {
222222
223223 // ---- topbar pieces ----
224224
225 /** The theme a mode button sends: the viewer's own named theme while it is of that mode, else the default of the pair. */
225 /**
226 * The theme a mode button sends: the viewer's own named theme while it is of that mode, else the
227 * default of the pair.
228 */
226229 const modeTheme = (mode: "light" | "dark", active: ThemeName | undefined): ThemeName =>
227230 active !== undefined && THEMES[active].appearance === mode ? active : mode;
228231
@@ -413,10 +416,15 @@ const STATIC_PALETTE: PaletteItem[] = [
413416 { t: "Your shells", h: "/settings/shells", c: "Settings" },
414417 ];
415418
416 /** What a signed-out visitor can reach: places to go, not Create and Settings rows that end at a sign-in wall. */
419 /**
420 * What a signed-out visitor can reach: places to go, not Create and Settings rows that end at a
421 * sign-in wall.
422 */
417423 const VISITOR_PALETTE = new Set(goPaletteRows().filter((r) => r.visitor).map((r) => r.t));
418424
419 /** First path segments that are the forge's own pages, never an owner: no repository read for them. */
425 /**
426 * First path segments that are the forge's own pages, never an owner: no repository read for them.
427 */
420428 const NOT_AN_OWNER = new Set([
421429 ...STATIC_PALETTE.map((p) => p.h.split("/")[1] ?? ""),
422430 "api", "releases", "audit", "admin", "tell", "login", "logout", "signup", "feed", "boards", "organizations", "static", "assets",
@@ -529,7 +537,8 @@ function paletteIndex(ctx: Ctx, extra: PaletteItem[]): Html {
529537 }),
530538 };
531539 }),
532 // A "Go to" row is the viewer's own: an admin's page is not listed to anyone else (it would end at a 403 or a 404).
540 // A "Go to" row is the viewer's own: an admin's page is not listed to anyone else (it would end
541 // at a 403 or a 404).
533542 ...(ctx.auth.user
534543 ? STATIC_PALETTE.filter((p) => {
535544 const row = GO_ROWS.find((r) => r.t === p.t && r.h === p.h);
@@ -631,7 +640,9 @@ function flashToast(flash: Flash): Html {
631640
632641 // ---- the chrome ----
633642
634 /** Where a signed-out visitor's way in leads: the topbar button and the palette's Sign in share it. */
643 /**
644 * Where a signed-out visitor's way in leads: the topbar button and the palette's Sign in share it.
645 */
635646 export function signInHref(ctx: Ctx): string {
636647 const token = activeEdgeToken(ctx.app);
637648 if (edgeStrangerLogin(ctx.request, token, ctx.auth.user) !== undefined) return "/signup";
@@ -653,7 +664,10 @@ export function signUpHref(ctx: Ctx): string | undefined {
653664 return mode === "open" || mode === "request" ? withReturn("/signup", returnTo(ctx)) : "/";
654665 }
655666
656 /** The Talk button; the count of confirms waiting on the viewer's yes is asked only here, where the button renders. */
667 /**
668 * The Talk button; the count of confirms waiting on the viewer's yes is asked only here, where the
669 * button renders.
670 */
657671 function talkButton(ctx: Ctx, user: User, about?: string): Html {
658672 const waiting = waitingCount(ctx, user);
659673 const label = waiting > 0 ? `Talk to the forge, ${waiting} waiting` : "Talk to the forge";
@@ -739,6 +753,8 @@ function footer(ctx: Ctx, own?: Html): Html {
739753 <a href="/docs">Docs</a>
740754 <a href="/pricing">Pricing</a>
741755 <a href="/changelog">Changelog</a>
756 <a href="/status">Status</a>
757 <a href="/privacy">Privacy</a>
742758 <a href="/api">API</a>
743759 ${ctx.auth.user !== undefined && ctx.auth.user.kind !== "org"
744760 ? html`<a class="btn" data-variant="link" data-size="sm" href="/feed#composer">Tell the crew</a>`
src/web/pages/security.ts +12 −4
@@ -79,7 +79,9 @@ const SHIELD_WORDS: Record<ShieldState, { name: string; does: string }> = {
7979 };
8080
8181 /** The form that moves the Shield: one button, one state, so undoing is one click. */
82 /** Who came in today, and the one setting that stops more: `/admin/signup`, as on the limits page. */
82 /**
83 * Who came in today, and the one setting that stops more: `/admin/signup`, as on the limits page.
84 */
8385 function newAccountsRow(db: Database, nowMs: number): Html {
8486 const today = new Date(nowMs);
8587 today.setUTCHours(0, 0, 0, 0);
@@ -105,7 +107,7 @@ function newAccountsRow(db: Database, nowMs: number): Html {
105107 }
106108
107109 /** One line of the page: what it is, how it stands, what you can do. */
108 function statusRow(label: string, state: Html, action: Html | null = null, id?: string): Html {
110 export function statusRow(label: string, state: Html, action: Html | null = null, id?: string): Html {
109111 return html`<div class="status-row" ${id === undefined ? null : html`id="${id}"`}>
110112 <dt>${label}</dt>
111113 <dd>${state}</dd>
@@ -240,7 +242,10 @@ function reportRow(dataDir: string, nowMs: number): Html {
240242 );
241243 }
242244
243 /** What browsers said the Content-Security-Policy blocked this week, by directive; nothing when nothing was. */
245 /**
246 * What browsers said the Content-Security-Policy blocked this week, by directive; nothing when
247 * nothing was.
248 */
244249 function cspRow(db: Database, nowMs: number): Html | null {
245250 const week = violationsByDirective(db, 7 * 24, new Date(nowMs));
246251 if (week.length === 0) return null;
@@ -252,7 +257,10 @@ function cspRow(db: Database, nowMs: number): Html | null {
252257 );
253258 }
254259
255 /** Uncaught script errors browsers reported this week: page, where, message, count, last seen; nothing when none. */
260 /**
261 * Uncaught script errors browsers reported this week: page, where, message, count, last seen;
262 * nothing when none.
263 */
256264 function scriptErrorRow(db: Database, nowMs: number): Html | null {
257265 const rows = scriptErrorCounts(db, 7 * 24, new Date(nowMs));
258266 if (rows.length === 0) return null;
src/web/pages/status.ts added +40
@@ -0,0 +1,40 @@
1 /**
2 * GET /status: is the forge working, in one sentence and three rows (#13211).
3 * Signed out, always 200. Asked with `Accept: application/json` it answers the
4 * same words as data. Server-rendered in the shell, held 10 s (`statusWords`).
5 */
6
7 import { statusJson, statusWords, WORD } from "../../core/status_words.ts";
8 import type { Ctx } from "../../http/context.ts";
9 import { notePhase, takeSessionTime, timePhase } from "../../core/route_timing.ts";
10 import { html } from "../html.ts";
11 import { page } from "../layout.ts";
12 import { badge } from "../ui.ts";
13 import { statusRow } from "./security.ts";
14
15 export function statusPage(ctx: Ctx): Response {
16 notePhase(ctx.request, "session", takeSessionTime(ctx.request));
17 const words = statusWords(ctx.app);
18 const accept = ctx.request.headers.get("accept") ?? "";
19 if (accept.includes("application/json"))
20 return timePhase(
21 ctx.request,
22 "render",
23 () =>
24 new Response(JSON.stringify(statusJson(words)), {
25 headers: { "cache-control": "public, max-age=10", vary: "accept", "content-type": "application/json" },
26 }),
27 );
outdated

DESIGN.md 7: a fact is a dl row, not <li>name: <strong>word</strong></li>. Use the named row component.

28 return timePhase(ctx.request, "render", () => {
29 const tone = { ok: "success", slow: "attn", down: "danger" } as const;
30 const rows = words.rows.map((r) => statusRow(r.name, badge(WORD[r.state], { tone: tone[r.state] })));
31 const res = page({
32 ctx,
33 title: "Status",
34 body: html`<div class="page-head"><h1>${words.sentence}</h1></div>
35 <dl class="status-rows">${rows}</dl>`,
36 });
37 res.headers.set("vary", "accept");
38 return res;
39 });
40 }
test/forge-looks.test.ts +5 −1
@@ -82,6 +82,7 @@ const NOT_A_PAGE: Record<string, string> = {
8282 "/search": "a search box; its slot went to the preview seed's /next as its owner (#8866)",
8383 "/contribute": "a static page about how to help; its slot went to the preview seed's /bets as its owner (#8866)",
8484 "/privacy": "three static lines on what the forge keeps about a visitor (#11265); covered by test/visitors.test.ts",
85 "/status": "one sentence and five rows on whether the forge works (#13211); covered by test/status-page.test.ts",

Non-blocking: 'five rows' is stale; there are three.

8586 "/migrate": "an import form, nothing to picture until a job runs; its slot went to /repos, and that one to /maintenance (#12692)",
8687 };
8788
@@ -122,7 +123,10 @@ const manifest = (): { looks: string[]; looksAsOwner: string[] } =>
122123 const isTopLevel = (p: string) => p === "/" || /^\/[^/?]+$/.test(p);
123124 /** A page's `?help` look: the page with its help open and focused (#11170). */
124125 const isHelpLook = (p: string) => p.endsWith("?help") && (isTopLevel(p.slice(0, -5)) || p === "/settings/crew?help");
125 /** The top-level pages; a deeper one is the preview seed's, taken as the owner (test/looks-owner.test.ts). */
126 /**
127 * The top-level pages; a deeper one is the preview seed's, taken as the owner
128 * (test/looks-owner.test.ts).
129 */
126130 const declared = (): string[] => manifest().looks.filter(isTopLevel);
127131
128132 const get = (path: string) =>
test/palette-roster.test.ts +6 −1
@@ -53,6 +53,7 @@ test("a site-admin person is offered the whole roster", () => {
5353 ["packs", "Forge packs", "premade forges to deploy, and how to help build their apps"],
5454 ["mirror-packs", "Mirror the packs' upstreams", "bring each pack's upstream projects in as read-only repositories"],
5555 ["pack-repos", "Pack repositories", "which repositories /packs lists"],
56 ["status", "Status", "is the forge working, in one sentence"],
5657 ["share-tell", "Share a link or text with the crew", "a draft, then where; nothing is sent until you confirm"],
5758 ["send-change", "Send a change", "fork, patch, pull: no forge of your own"],
5859 ["interrupted-out", "Stopped runs", "runs the host stopped five times, with Try again"],
@@ -225,6 +226,7 @@ test("a site-admin agent is offered the roster without the person-only entries",
225226 ["needs", "How is my forge?", "what needs you, with a recommendation each; a takes a safe one"],
226227 ["asks-admin", "What stands in the way", "what waits on you and what stands in your way; a asks whoever can, o opens the control"],
227228 ["packs", "Forge packs", "premade forges to deploy, and how to help build their apps"],
229 ["status", "Status", "is the forge working, in one sentence"],
228230 ["share-tell", "Share a link or text with the crew", "a draft, then where; nothing is sent until you confirm"],
229231 ["send-change", "Send a change", "fork, patch, pull: no forge of your own"],
230232 ["interrupted-out", "Stopped runs", "runs the host stopped five times, with Try again"],
@@ -319,6 +321,7 @@ test("a member person is offered the signed-in roster without the admin entries"
319321 ["needs", "How is my forge?", "what needs you, with a recommendation each; a takes a safe one"],
320322 ["asks-admin", "What stands in the way", "what waits on you and what stands in your way; a asks whoever can, o opens the control"],
321323 ["packs", "Forge packs", "premade forges to deploy, and how to help build their apps"],
324 ["status", "Status", "is the forge working, in one sentence"],
322325 ["share-tell", "Share a link or text with the crew", "a draft, then where; nothing is sent until you confirm"],
323326 ["send-change", "Send a change", "fork, patch, pull: no forge of your own"],
324327 ["interrupted-out", "Stopped runs", "runs the host stopped five times, with Try again"],
@@ -408,6 +411,7 @@ test("signed out, the palette offers sign-in and the public entries", () => {
408411 ["explore", "Explore", "on the web"],
409412 ["explore-feed", "Explore feed", "Atom address"],
410413 ["packs", "Forge packs", "premade forges to deploy, and how to help build their apps"],
414 ["status", "Status", "is the forge working, in one sentence"],
411415 ["share-tell", "Share a link or text with the crew", "a draft, then where; nothing is sent until you confirm"],
412416 ["send-change", "Send a change", "fork, patch, pull: no forge of your own"],
413417 ["interrupted-out", "Stopped runs", "runs the host stopped five times, with Try again"],
@@ -539,7 +543,8 @@ describe("on a pull's Files step the palette lists what the page offers this rea
539543 for (const [tab, path] of [["Conversation", thread], ["Files", `${thread}/files`]] as const) {
540544 test(`on the ${tab} tab a ${who}'s action rows are exactly the page's forms`, async () => {
541545 const { rows, forms } = await read(path, kind());
542 // The Files tab has no comment form of its own: its Comment row links to the Conversation's.
546 // The Files tab has no comment form of its own: its Comment row links to the
547 // Conversation's.
543548 const acts = rows.map((r) => r.t).filter((t) => !READING.includes(t) && !(tab === "Files" && t === "Comment"));
544549 const same = (t: string) => (t === "Bring up to date" ? "Ship" : t);
545550 expect(acts.map(same).sort()).toEqual([...new Set(forms)].sort());
test/status-page.test.ts added +146
@@ -0,0 +1,146 @@
1 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
2 import { mkdtemp, rm } from "node:fs/promises";
3 import { tmpdir } from "node:os";
4 import { join } from "node:path";
5 import { createApp, type App } from "../src/app.ts";
6 import { serve, type Servers } from "../src/http/server.ts";
7 import { statusJson, statusOf, statusReuse, statusWords, type StatusInput } from "../src/core/status_words.ts";
8 import { createForgeApp, forgeCommands, Session } from "../src/tui/forge.ts";
9 import { statusLines } from "../src/tui/screens/status.ts";
10 import { headlessTerminal } from "../src/tui/term/terminal.ts";
11
12 let dir: string;
13 let app: App;
14 let failing: App;
15 let servers: Servers;
16 let base: string;
17
18 beforeAll(async () => {
19 dir = await mkdtemp(join(tmpdir(), "status-"));
20 app = createApp({ dataDir: dir, port: 0 });
21 failing = createApp({ dataDir: join(dir, "failing"), port: 0, hostFree: () => 0 });
22 servers = await serve(app);
23 base = `http://127.0.0.1:${servers.port}`;
24 });
25 afterAll(async () => {
26 await servers.stop();
27 await rm(dir, { recursive: true, force: true });
28 });
29
30 const healthy: StatusInput = { ok: true, draining: false, causes: [], ledgerBroken: false };
31 const cause = (c: string, broken: boolean, since = "2026-11-15T09:00:00Z") => ({ cause: c, broken, since });
32
33 describe("status words", () => {
34 test("healthy says all working with three ok rows", () => {
35 const w = statusOf(healthy);
36 expect(w.sentence).toBe("All working.");
37 expect(w.rows.map((r) => r.name)).toEqual(["pages and sign-in", "building", "billing records"]);
38 expect(w.rows.every((r) => r.state === "ok")).toBe(true);
39 });
40
41 test("a slow cause is named in plain words on its row", () => {
42 const w = statusOf({ ...healthy, causes: [cause("stuck:run1", false)] });
43 expect(w.sentence).toBe("Slowed: building is slower than usual.");
44 expect(w.rows.find((r) => r.name === "building")!.state).toBe("slow");
45 });
46
47 test("down names when the cause was first seen, never the time of the check", () => {
48 const b = statusOf({ ...healthy, causes: [cause("disk-full", true, "2026-11-15T08:30:00Z")] });
49 expect(b.sentence).toBe("Down since 08:30 UTC.");
50 expect(b.rows[0]!.state).toBe("down");
51 expect(statusOf({ ...healthy, causes: [cause("disk-full", true, "2026-11-15T08:30:00Z")] })).toEqual(b);
52 });
53
54 test("not ok with no cause to name says Down. with no time", () => {
55 expect(statusOf({ ...healthy, ok: false }).sentence).toBe("Down.");
56 });
57
58 test("broken is a key, not a sentence: a broken cause with any key is down", () => {
59 expect(statusOf({ ...healthy, causes: [cause("something-new", true)] }).state).toBe("down");
60 });
61
62 test("a cause the table does not know is said generically, a standing wish is not", () => {
63 const secret = "ECONNREFUSED 10.0.0.7:5432 /data/secret.key";
64 const w = statusOf({ ...healthy, causes: [cause(secret, false, secret)] });
65 expect(JSON.stringify(w)).not.toContain("ECONNREFUSED");
66 expect(w.sentence).toBe("Slowed: something is slower than usual.");
67 expect(statusOf({ ...healthy, causes: [cause("drill", false), cause("snapshots", false)] }).sentence).toBe("All working.");
68 const d = statusOf({ ...healthy, causes: [cause(secret, true, secret)] });
69 expect(JSON.stringify(d)).not.toContain("10.0.0.7");
70 expect(d.sentence).toBe("Down.");
71 });
72
73 test("a broken ledger slows the billing row and the sentence", () => {
74 const w = statusOf({ ...healthy, ledgerBroken: true });
75 expect(w.sentence).toBe("Slowed: billing records need a look.");
76 expect(w.rows.find((r) => r.name === "billing records")!.state).toBe("slow");
77 });
78 });
79
80 describe("statusWords", () => {
81 test("a real failing vital turns the words, the page, the JSON and the terminal", async () => {
82 const w = statusWords(failing);
83 expect(w.state).toBe("down");
84 expect(w.sentence).toMatch(/^Down since \d\d:\d\d UTC\.$/);
85 expect(w.rows[0]).toEqual({ name: "pages and sign-in", state: "down" });
86 expect(statusWords(app).state).toBe("working");
87 const user = { sshUsername: "git", remoteAddress: "127.0.0.1", fingerprint: "SHA256:test", user: undefined };
88 expect(statusLines(new Session(failing, user))[0]).toBe(w.sentence);
89 });
90
91 test("inside the reuse window a second call returns the same words, after it a fresh read", () => {
92 const was = statusReuse.ms;
93 statusReuse.ms = 10_000;
94 try {
95 const fresh = createApp({ dataDir: join(dir, "reuse"), port: 0 });
96 const t = Date.now();
97 const first = statusWords(fresh, t);
98 expect(statusWords(fresh, t + 9_000)).toBe(first);
99 expect(statusWords(fresh, t + 10_001)).not.toBe(first);
100 } finally {
101 statusReuse.ms = was;
102 }
103 });
104 });
105
106 describe("GET /status", () => {
107 test("answers 200 signed out with the floor, rows as a dl, and a body of bounded size", async () => {
108 const r = await fetch(`${base}/status`);
109 const text = await r.text();
110 expect(r.status).toBe(200);
111 expect(text).toContain("All working.");
112 expect(text).toContain('<dl class="status-rows">');
113 expect(text).not.toContain("<li>pages");
114 expect(r.headers.get("content-security-policy")).toBeTruthy();
115 expect(r.headers.get("x-content-type-options")).toBe("nosniff");
116 expect(text.length).toBeLessThan(24_576);
117 });
118
119 test("JSON carries the same words as the page, in a small body", async () => {
120 const page = await (await fetch(`${base}/status`)).text();
121 const r = await fetch(`${base}/status`, { headers: { accept: "application/json" } });
122 expect(r.headers.get("content-type")).toContain("application/json");
123 const raw = await r.text();
124 expect(raw.length).toBeLessThan(512);
125 const j = JSON.parse(raw) as ReturnType<typeof statusJson>;
126 expect(page).toContain(j.sentence);
127 for (const [name, word] of Object.entries(j.rows)) expect(page).toMatch(new RegExp(`<dt>${name}</dt>\\s*<dd>[^]*?${word}`));
128 expect(Object.keys(j.rows)).toHaveLength(3);
129 });
130
131 test("the footer links to it, beside Privacy", async () => {
132 const home = await (await fetch(`${base}/pricing`)).text();
133 expect(home).toMatch(/<a href="\/status">Status<\/a>\s*<a href="\/privacy">Privacy<\/a>/);
134 });
135 });
136
137 describe("the terminal's door", () => {
138 test("Status is in the palette for a signed-out visitor, and its lines are the page's words", () => {
139 const user = { sshUsername: "git", remoteAddress: "127.0.0.1", fingerprint: "SHA256:test", user: undefined };
140 const { app: tui, session } = createForgeApp(app, user, { terminal: headlessTerminal(80, 24), exitHooks: false });
141 expect(forgeCommands(session)(tui.ctx).map((c) => c.id)).toContain("status");
142 const lines = statusLines(session);
143 expect(lines[0]).toBe("All working.");
144 expect(lines.join("\n")).toContain("building");
145 });
146 });
test/vitals.test.ts +1 −1
@@ -426,7 +426,7 @@ test("since is said as a person would", async () => {
426426 expect(sinceWords("2026-10-15T08:00:00Z", now)).toBe("4 h ago");
427427 expect(sinceWords("2026-10-15T11:59:50Z", now)).toBe("just now");
428428 expect(sinceWords("2020-01-01T00:00:00.000Z", now)).toBe("2020-01-01");
429 const line = needLine({ cause: "errors", sentence: "S.", since: "2020-01-01T00:00:00.000Z", href: "/x" }, now);
429 const line = needLine({ cause: "errors", sentence: "S.", since: "2020-01-01T00:00:00.000Z", href: "/x", broken: false }, now);
430430 expect(line).toBe("S. Since 2020-01-01.");
431431 expect(line).not.toContain("T00:00");
432432 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs