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

The v1 probe reads the morning paper's edition page by default, so the schedules line is proven without a flag #15475

Merged opened this

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

Merged

torque/forge:torque/15474-the-v1-probe-reads-the-morning-paper-s-e → main 4 commits fork 5 threads · 5 unresolved

  • Merged. torque/15474-the-v1-probe-reads-the-morning-paper-s-e was merged into main as 0272a1b.

Review

Sign in to review this change.
3 files changed +38 −34
docs/OPERATING.md +2 −2
@@ -364,9 +364,9 @@ of this check only, never loaded by the server: its rules need a rendered page
364364 and an accessibility tree, which nothing dependency-free gives.
365365
366366 `bun scripts/v1-probe.ts https://forge.open-platform.sh` reads production (GETs and one MCP initialize, never signed in) and prints PASS, FAIL or UNKNOWN per v1.0.0 item with its URL and evidence.
367 The `schedules ran in 24 h` line reads the newest `<time datetime>` on `<base-url>/edition` by default (#15474): PASS within 24 h, FAIL older, UNKNOWN when the page is not public, and UNKNOWN with `this release predates /edition` when it answers 404, as a release without the page does. `--edition <url>` replaces it and is only needed for a page on another host (the morning paper's latest edition printed by a scheduled app); it is the only extra host read.
outdated

This line still ends "No public page prints a dated edition yet ... #15393 adds one, and that page is the URL to pass." The next line says /edition exists and is the default. Delete that sentence so the two lines agree.

outdated

The --edition line and the next paragraph both say the default, the 24 h rule and UNKNOWN twice. Keep one: fold "--edition is only needed for a page on another host" into this line and drop the repeated PASS/FAIL/UNKNOWN wording from the second paragraph.

368 That page (`src/http/edition.ts`) prints when the newest morning paper ran and nothing of the thread it was posted in; before any paper has run it prints no `<time>`. Its ETag holds the newest run and the build, so a deploy never answers 304 to older markup; signed-in and flash responses are never tagged. The paper is written by the routine clock (`startRoutines` in `src/crew/routines.ts`, a pass every minute, the paper at 07:00 UTC), which starts only when the crew does: a preview, where the crew is held off, never prints one and its `/edition` stays without a `<time>`. Probe production, not a preview (#15405).
367369 The release it checks is the newest the MCP `releases` tool lists for the repository; when none is listed but the answer names the running `version` and `commit` (production live, `"live":[]`), that running build is the release, read from `GET /api/v1/repos/<repo>/commits/<sha>/check` and compared to what production announces, and its lines say `running v…`. Only an answer that lists none and names no running commit FAILs for a missing release (#15473).
368 `--edition <url>` names a public page a scheduled app prints (the morning paper's latest edition): its newest `<time datetime>` proves the schedules line, PASS within 24 h, FAIL older, UNKNOWN when the page is not public. Without it that line is UNKNOWN, because the schedules API answers 404 to an anonymous read. No public page prints a dated edition yet: the morning paper posts only in the signed-in Captain thread. #15393 adds one, and that page is the URL to pass.
369 The `schedules ran in 24 h` line reads a public page's newest `<time datetime>`: pass `--edition https://forge.open-platform.sh/edition`. That page (`src/http/edition.ts`) prints when the newest morning paper ran and nothing of the thread it was posted in; before any paper has run it prints no `<time>`. Its ETag holds the newest run and the build, so a deploy never answers 304 to older markup; signed-in and flash responses are never tagged. The paper is written by the routine clock (`startRoutines` in `src/crew/routines.ts`, a pass every minute, the paper at 07:00 UTC), which starts only when the crew does: a preview, where the crew is held off, never prints one and its `/edition` stays without a `<time>`. Probe production, not a preview (#15405).
370370 The owner tags v1.0.0 only when every line is PASS; an UNKNOWN line names what a person must check, and is not a pass.
371371
372372 ## Secrets in the terminal
scripts/v1-probe.ts +17 −27
@@ -10,9 +10,10 @@
1010 * also GETs `/api/v1/keeper` with that token, and only there, and prints `keeper's last beat`:
1111 * the release tick's newest outcome and reason, so a stopped release is named from a shell.
1212 *
13 * `--edition` is a public page a scheduled app prints, such as the morning paper's latest
14 * edition (#15388): its newest `<time datetime>` or `<updated>` is when the schedule last ran,
15 * because an anonymous read of the schedules API answers 404.
13 * The schedules line reads `<base-url>/edition` (#15474), the morning paper's edition page; a 404
14 * there is UNKNOWN, `this release predates /edition`. `--edition` is another public page a
15 * scheduled app prints, and wins (#15388): its newest `<time datetime>` or `<updated>` is when the
16 * schedule last ran, the schedules API answers 404 to an anonymous read.
1617 *
1718 * It prints one line per item, `PASS`, `FAIL` or `UNKNOWN`, with the URL and
1819 * the evidence, and exits 0 only when every line is PASS. UNKNOWN is what an
@@ -267,31 +268,20 @@ export async function probe(base: string, repo: string, fetcher: Fetcher = fetch
267268 else if (health.status === 200 && health.ms <= HEALTHZ_MS) say("healthz fast", "PASS", "/healthz", `200 in ${health.ms} ms`);
outdated

page_ is an awkward name that exists only to avoid clashing with page. Name it editionUrl (or target) and keep page for the response.

268269 else say("healthz fast", "FAIL", "/healthz", `${health.status} in ${health.ms} ms (limit ${HEALTHZ_MS} ms)`);
269270
270 // 6. Schedules (#11595) ran in the last 24 h: from the public page a scheduled app prints
271 // (#15388), else the schedules API, which answers 404 to an anonymous read.
271 // 6. Schedules (#11595) ran in the last 24 h: from `--edition`, else `<base>/edition` (#15474); a
outdated

This comment is mangled by the rewrap: it opens with a dangling "(#15388):", then says "(#15388), else the schedules API, which answers 404 to an anonymous read" — the fallback no longer exists. Replace the three lines with one sentence: "6. Schedules (#11595) ran in the last 24 h: from --edition, else <base>/edition (#15474); a 404 on the default is UNKNOWN."

272 // 404 on the default is UNKNOWN.
272273 const item = "schedules ran in 24 h";
273 const signedIn = `a person must open ${at(`/${repo}`)} signed in and read its Schedules card, or pass --edition <a public page the schedule prints>`;
274 if (edition) {
275 const page = await get(edition);
276 const stamp = typeof page === "string" || page.status !== 200 ? undefined : editionDate(page.body, now);
277 if (typeof page === "string" || page.status !== 200) say(item, "UNKNOWN", edition, `${typeof page === "string" ? page : page.status}, the page is not public; a person must open ${edition}`);
278 else if (!stamp) say(item, "UNKNOWN", edition, `200 with no <time datetime> or <updated>; a person must open ${edition} and read the edition's date`);
279 else {
280 const ago = Math.round((now - stamp.at) / 60_000);
281 say(item, now - stamp.at <= DAY_MS ? "PASS" : "FAIL", edition, `newest edition dated ${stamp.text}, ${ago} min ago`);
282 }
283 } else {
284 const schedPath = `${api}/schedules?runs=50`;
285 const sched = await get(schedPath);
286 const runs = typeof sched === "string" ? undefined : (json(sched) as { runs?: { startedAt?: unknown; name?: unknown }[] } | undefined)?.runs;
287 if (!Array.isArray(runs)) say(item, "UNKNOWN", schedPath, `${typeof sched === "string" ? sched : sched.status}; ${signedIn}`);
288 else if (runs.length === 0) say(item, "UNKNOWN", schedPath, `no runs visible to an anonymous read; ${signedIn}`);
289 else {
290 const newest = Math.max(...runs.map((r) => (typeof r.startedAt === "number" ? r.startedAt : 0)));
291 const ago = Math.round((now - newest) / 60_000);
292 if (now - newest <= DAY_MS) say(item, "PASS", schedPath, `newest run ${ago} min ago`);
293 else say(item, "FAIL", schedPath, newest > 0 ? `newest run ${ago} min ago` : "no run names when it started");
294 }
274 const byDefault = !edition;
275 const editionUrl = edition ?? at("/edition");
276 const page = await get(editionUrl);
277 const stamp = typeof page === "string" || page.status !== 200 ? undefined : editionDate(page.body, now);
278 if (typeof page === "string") say(item, "UNKNOWN", editionUrl, `${page}; a person must open ${editionUrl}`);
279 else if (page.status === 404 && byDefault) say(item, "UNKNOWN", editionUrl, `404, this release predates /edition; a person must open ${at(`/${repo}`)} signed in and read its Schedules card`);
280 else if (page.status !== 200) say(item, "UNKNOWN", editionUrl, `${page.status}, the page is not public; a person must open ${editionUrl}`);
281 else if (!stamp) say(item, "UNKNOWN", editionUrl, `200 with no <time datetime> or <updated>; a person must open ${editionUrl} and read the edition's date`);
282 else {
283 const ago = Math.round((now - stamp.at) / 60_000);
284 say(item, now - stamp.at <= DAY_MS ? "PASS" : "FAIL", editionUrl, `newest edition dated ${stamp.text}, ${ago} min ago`);
295285 }
296286
297287 // 7. Security headers and CSP on / and /pricing.
test/v1-probe.test.ts +19 −5
@@ -68,8 +68,8 @@ const server = Bun.serve({
6868 case "/api/v1/keeper":
6969 if (req.headers.get("authorization") !== "Bearer t") return json({ error: "forbidden" }, 403);
7070 return json({ blocked: null, releases: [], holds: [], heartbeat: world.beat ?? null });
71 case "/api/v1/repos/o/r/schedules":
72 return world.runs === null ? json({ error: "not_found" }, 404) : json({ items: [], runs: world.runs });
71 case "/edition":
72 return world.runs === null ? json({ error: "not_found" }, 404) : html(world.runs.map((r) => `<time datetime="${new Date(r.startedAt).toISOString()}"></time>`).join(""));
7373 }
7474 return json({ error: "not_found" }, 404);
7575 },
@@ -142,9 +142,23 @@ describe("v1 probe", () => {
142142 expect((await printed(200, "<p>no date</p>")).evidence).toContain(`a person must open ${editionUrl} and read the edition's date`);
143143 });
144144
145 test("without --edition the line names the page a person must open", async () => {
146 const r = await run({ runs: null });
147 expect(r["schedules ran in 24 h"]!.evidence).toContain(`a person must open ${base}/o/r signed in and read its Schedules card`);
145 test("without --edition the probe reads <base>/edition: fresh PASS, stale FAIL, 404 UNKNOWN as predating it (#15474)", async () => {
146 const fresh = (await run({}))["schedules ran in 24 h"]!;
147 expect(fresh.verdict).toBe("PASS");
148 expect(fresh.url).toBe(`${base}/edition`);
149 expect((await run({ runs: [{ startedAt: NOW - 25 * 3600_000 }] }))["schedules ran in 24 h"]!.verdict).toBe("FAIL");
150 const old = (await run({ runs: null }))["schedules ran in 24 h"]!;
151 expect(old.verdict).toBe("UNKNOWN");
152 expect(old.evidence).toContain("this release predates /edition");
153 expect(old.evidence).toContain(`a person must open ${base}/o/r signed in`);
154 });
155
156 test("an explicit --edition replaces the default: its page is read and /edition on the base is not", async () => {
157 seen.length = 0;
158 const line = await printed(200, "<p></p>");
159 expect(line.url).toBe(editionUrl);
outdated

This test passes on the old code too (the old code never read /edition when an edition was given), so it guards nothing. Also assert that the explicit URL was read (seen has that path) so it proves the explicit page replaces the default.

160 expect(seen.some((s) => s.path === "paper/editions/latest")).toBe(true);
161 expect(seen.some((s) => s.path === "/edition")).toBe(false);
148162 });
149163
150164 test("an edition's date: the newest stamp, a bare date as its day's end capped at now, none from the future", () => {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs