Public: anyone can read this; the crew can change it.
/status names the proof lines that did not pass, each with its evidence in plain words, instead of "0 of 8 pass" #15944
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/15938-status-names-the-proof-lines-that-did-no → main 0 commits fork 3 threads · 3 unresolved
5 files
changed +94
−2
docs/features/status-proof-lines.md added +15
| @@ -0,0 +1,15 @@ | ||
| 1 | --- | |
| 2 | topic: When something is wrong | |
| 3 | row: /status names the daily-proof lines that did not pass, with their evidence | |
| 4 | --- | |
| 5 | # /status names the proof lines that did not pass | |
| 6 | ||
| 7 | Open `/status` (signed out) or choose **Status** in the terminal palette | |
| 8 | (`ssh` in, `ctrl+k`, Status). Under the `daily proof` row, a closed fold says | |
| 9 | `2 of 8 daily proof lines did not pass`; open it for one line each: the item, | |
| 10 | `FAIL` or `could not be read`, and its evidence in plain words. The terminal prints | |
| 11 | the same lines, indented under the row. | |
| 12 | ||
| 13 | The badge is danger only when a line says `FAIL`; when every line that did not pass | |
| 14 | could not be read, it is attention, not red. Nothing is shown beyond what | |
| 15 | `GET /api/v1/proof/daily` already serves anonymously. |
src/release/daily_proof.ts +4 −1
| @@ -203,6 +203,8 @@ export interface ProofStatus extends ProofTally { | ||
| 203 | 203 | readonly state: "pass" | "fail" | "unknown"; |
| 204 | 204 | /** `11 of 11 pass, 6 h ago`. */ |
| 205 | 205 | readonly says: string; |
| 206 | /** The lines that did not pass, evidence already plain. */ | |
| 207 | readonly open: readonly { item: string; verdict: Verdict; evidence: string }[]; | |
| 206 | 208 | } |
| 207 | 209 | |
| 208 | 210 | export function proofStatus(db: Database, now: number): ProofStatus | undefined { |
| @@ -210,7 +212,8 @@ export function proofStatus(db: Database, now: number): ProofStatus | undefined | ||
| 210 | 212 | if (run === undefined) return undefined; |
| 211 | 213 | const t = tally(run); |
| 212 | 214 | const state = run.lines.some((l) => l.verdict === "FAIL") ? "fail" : t.total > 0 && t.pass === t.total ? "pass" : "unknown"; |
| 213 | return { ...t, state, says: tallyWords(t, now) }; | |
| 215 | const open = run.lines.filter((l) => l.verdict !== "PASS").map((l) => ({ item: l.item, verdict: l.verdict, evidence: plainEvidence(l.evidence) })); | |
| 216 | return { ...t, state, says: tallyWords(t, now), open }; | |
| 214 | 217 | } |
| 215 | 218 | |
| 216 | 219 | /** The row's name on `/status` and its terminal screen. */ |
src/tui/screens/status.ts +2
| @@ -29,6 +29,8 @@ export function statusLines(session: Session, now = Date.now()): string[] { | ||
| 29 | 29 | "", |
| 30 | 30 | ...w.rows.map((r) => `${pad(r.name, 20)}${pad(rowWords(r), 24)}${strip.get(r.name) ?? ""}`), |
| 31 | 31 | ...(proof === undefined ? [] : [`${pad(PROOF_ROW, 20)}${proof.says}`]), |
| 32 | // The lines that did not pass, one each, as the page's fold names them (#15938). | |
| 33 | ...(proof?.open ?? []).map((l) => ` ${l.item}: ${l.verdict === "FAIL" ? "FAIL" : "could not be read"}${l.evidence === "" ? "" : ` · ${l.evidence}`}`), | |
| 32 | 34 | "", |
| 33 | 35 | `last 30 days, oldest first: # ok ~ degraded ! down . no data${starts === null ? "" : `; ${starts}`}`, |
| 34 | 36 | ]; |
src/web/pages/status.ts +12 −1
| @@ -59,8 +59,18 @@ function daysStrip(days: readonly Day[]): Html { | ||
| 59 | 59 | return html`<span class="status-days" aria-hidden="true" title="${STRIP_TITLE}">${days.map((d) => (d.state === "none" ? html`<i class="sd-none"></i>` : html`<i class="sd-${d.state}" title="${dayWords(d)}"></i>`))}</span><span class="sr-only">${said}</span>${worst === null ? null : html`<span class="hint" aria-hidden="true">worst ${dayWords(worst)}</span>`}`; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | /** | |
| 63 | * The proof lines that did not pass, one each: item, FAIL or "could not be read", evidence | |
| 64 | * (#15938). | |
| 65 | */ | |
| 66 | function proofFold(proof: ProofStatus): Html | null { | |
| 67 | if (proof.open.length === 0) return null; | |
| 68 | const items = proof.open.map((l) => statusRow(l.item, html`${l.verdict === "FAIL" ? "FAIL" : "could not be read"}${l.evidence === "" ? "" : html` · ${l.evidence}`}`)); | |
outdated
|
||
| 69 | return html`<details class="disclosure"><summary>${proof.open.length} of ${proof.total} daily proof lines did not pass</summary><dl class="status-rows">${items}</dl></details>`; | |
| 70 | } | |
| 71 | ||
| 62 | 72 | function markup(words: StatusWords, origin: string, proof: ProofStatus | undefined, read: () => StatusHistory): string { |
| 63 | const said = proof?.says ?? ""; | |
| 73 | const said = proof === undefined ? "" : `${proof.says}\n${JSON.stringify(proof.open)}`; | |
| 64 | 74 | const kept = built.get(words); |
| 65 | 75 | if (kept !== undefined && kept.origin === origin && kept.proof === said) return kept.text; |
| 66 | 76 | statusBuilds.count += 1; |
| @@ -86,6 +96,7 @@ ${themeColorHead(undefined)} | ||
| 86 | 96 | <main class="shell" id="main"> |
| 87 | 97 | <div class="page-head"><h1>${words.sentence}</h1><p class="hint">${asOfWords(words)}</p></div> |
| 88 | 98 | <dl class="status-rows">${rows}${proofRow}</dl> |
| 99 | ${proof === undefined ? null : proofFold(proof)} | |
| 89 | 100 | ${starts === null ? "" : html`<p class="hint">${starts}</p>`} |
| 90 | 101 | </main> |
| 91 | 102 | <footer class="foot"><a href="/">forge</a><span class="spacer"></span><a href="/status">Status</a><a href="/privacy">Privacy</a></footer> |
test/status-proof-lines.test.ts added +61
| @@ -0,0 +1,61 @@ | ||
| 1 | /** /status names the daily-proof lines that did not pass, with their evidence, escaped (#15938). */ | |
| 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 { serve, type Servers } from "../src/http/server.ts"; | |
| 8 | import { recordRun } from "../src/release/daily_proof.ts"; | |
| 9 | import { Session } from "../src/tui/forge.ts"; | |
| 10 | import { statusLines } from "../src/tui/screens/status.ts"; | |
| 11 | import type { Line } from "../src/release/v1_checks.ts"; | |
| 12 | ||
| 13 | let dir: string; | |
| 14 | let app: App; | |
| 15 | let servers: Servers; | |
| 16 | const T0 = Date.parse("2026-11-20T07:00:00Z"); | |
| 17 | const line = (item: string, verdict: Line["verdict"], evidence = "seen"): Line => ({ item, verdict, url: "https://forge.example/x", evidence }); | |
| 18 | const page = async () => (await fetch(`${servers.url}/status`)).text(); | |
| 19 | ||
| 20 | beforeAll(async () => { | |
| 21 | dir = await mkdtemp(join(tmpdir(), "status-proof-")); | |
| 22 | app = createApp({ dataDir: dir, port: 0 }); | |
| 23 | servers = await serve(app); | |
| 24 | }); | |
| 25 | afterAll(async () => { | |
| 26 | await servers.stop(); | |
| 27 | app.close(); | |
| 28 | await rm(dir, { recursive: true, force: true }); | |
| 29 | }); | |
| 30 | ||
| 31 | test("only UNKNOWN lines: listed as could not be read, badge not danger", async () => { | |
| 32 | recordRun(app.db, [line("a", "PASS"), line("b", "UNKNOWN", "no answer"), line("c", "UNKNOWN", "timed out")], new Date(T0)); | |
| 33 | const html = await page(); | |
| 34 | expect(html).toContain("2 of 3 daily proof lines did not pass"); | |
| 35 | expect(html).toContain("<dt>b</dt>\n <dd>could not be read · no answer</dd>"); | |
| 36 | expect(html).not.toContain("<dt>a</dt>"); | |
| 37 | expect(html).not.toMatch(/data-variant="danger"[^>]*>[^<]*pass/); | |
| 38 | }); | |
| 39 | ||
| 40 | test("a FAIL is named FAIL, its evidence escaped, and the badge turns danger", async () => { | |
| 41 | recordRun(app.db, [line("a", "FAIL", "<script>alert(1)</script>"), line("b", "UNKNOWN"), line("c", "UNKNOWN"), line("d", "PASS")], new Date(T0 + 86_400_000)); | |
| 42 | const html = await page(); | |
| 43 | expect(html).toContain("<dt>a</dt>\n <dd>FAIL · <script>alert(1)</script></dd>"); | |
| 44 | expect(html).not.toContain("<script>alert"); | |
| 45 | expect(html).toMatch(/data-variant="danger"[^>]*>[^<]*pass/); | |
outdated
|
||
| 46 | expect((html.match(/<dt>[abc]<\/dt>/g) ?? []).length).toBe(3); | |
| 47 | }); | |
| 48 | ||
| 49 | test("all passing shows no fold", async () => { | |
| 50 | recordRun(app.db, [line("a", "PASS")], new Date(T0 + 2 * 86_400_000)); | |
| 51 | expect(await page()).not.toContain("did not pass"); | |
| 52 | }); | |
| 53 | ||
| 54 | test("the terminal shows the same lines", () => { | |
| 55 | recordRun(app.db, [line("a", "FAIL", "boom"), line("b", "UNKNOWN", "no answer"), line("c", "PASS")], new Date(T0 + 3 * 86_400_000)); | |
| 56 | const user = { sshUsername: "git", remoteAddress: "127.0.0.1", fingerprint: "SHA256:test", user: undefined }; | |
| 57 | const lines = statusLines(new Session(app, user)); | |
| 58 | expect(lines).toContain(" a: FAIL · boom"); | |
| 59 | expect(lines).toContain(" b: could not be read · no answer"); | |
| 60 | expect(lines.join("\n")).not.toContain(" c:"); | |
| 61 | }); |
new above
offline
Principle 7 (rows over boxes): each line is a fact (item, verdict, evidence), so render it as a dl row rather than a hint paragraph per line.