Public: anyone can read this; the crew can change it.
The weekly production probe fails when /changelog.atom has no entries and files the defect with the byte count it saw #13083
Parked 17d 11h ago
scout/forge:scout/13072-the-weekly-production-probe-fails-when-c → main 3 commits fork
3 files
changed +46
−4
src/core/v1_proof.ts +14
| @@ -187,6 +187,20 @@ export const probes: readonly Probe[] = [ | ||
| 187 | 187 | return "/api/v1/health: no schedule is overdue"; |
| 188 | 188 | }, |
| 189 | 189 | }, |
| 190 | { | |
| 191 | issue: 13072, | |
| 192 | item: "the changelog feed has at least one entry", | |
| 193 | run: async (get) => { | |
| 194 | const started = performance.now(); | |
| 195 | const got = await get("/changelog.atom"); | |
| 196 | const ms = Math.round(performance.now() - started); | |
| 197 | // What a defect filed from this line needs: where, what status, how many bytes, how long. | |
| 198 | const seen = `/changelog.atom: status ${got.status}, ${new TextEncoder().encode(got.text).length} bytes, ${ms} ms`; | |
| 199 | expect(got.status === 200, `${seen}; not 200`); | |
| 200 | expect(/<entry[\s>]/.test(got.text), `${seen}; the feed has no <entry>`); | |
| 201 | return `${seen}; it has an entry`; | |
| 202 | }, | |
| 203 | }, | |
| 190 | 204 | { |
| 191 | 205 | issue: 10441, |
| 192 | 206 | item: "the security headers are on the page and on a machine answer", |
test/security-floor-paths.test.ts +14
| @@ -18,6 +18,8 @@ import { afterAll, beforeAll, expect, test } from "bun:test"; | ||
| 18 | 18 | import { newApp } from "../src/actions/apps.ts"; |
| 19 | 19 | import type { EnvStatus } from "../src/apps/runtime.ts"; |
| 20 | 20 | import type { AppRecord } from "../src/core/apps.ts"; |
| 21 | import { createRepo } from "../src/actions/repos.ts"; | |
| 22 | import { keepLive } from "../src/release/landings.ts"; | |
| 21 | 23 | import { line, prove } from "../src/core/v1_proof.ts"; |
| 22 | 24 | import { |
| 23 | 25 | fetchAsHost, |
| @@ -209,6 +211,18 @@ test("the proxy's 304 of an app's page keeps the headers the app's 200 left with | ||
| 209 | 211 | }); |
| 210 | 212 | |
| 211 | 213 | test("`bun scripts/v1-proven.ts`'s proof passes 20 times in a row against a booted forge", async () => { |
| 214 | // A fresh forge has shipped nothing; the proof wants one entry in the changelog feed | |
| 215 | // (#13072). | |
| 216 | const repo = await createRepo(forge.app, forge.alice, { name: "forge", visibility: "public" }); | |
| 217 | if (!repo.ok) throw new Error(String(repo.error)); | |
| 218 | forge.app.db.query( | |
| 219 | `INSERT INTO issue (id, repo_id, number, kind, title, author_id, state) VALUES ('shipped', ?1, 1, 'pull', 'Shipped', ?2, 'closed')`, | |
| 220 | ).run(repo.value.id, forge.alice.id); | |
| 221 | forge.app.db.query( | |
| 222 | `INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, merged_at, merged_oid) VALUES ('shipped', ?1, 'b', 'base', '', '2026-10-01T10:00:00.000Z', 'oid-live')`, | |
| 223 | ).run(repo.value.defaultBranch); | |
| 224 | keepLive(forge.app.db, "alice/forge", ["oid-live"], 0); | |
| 225 | (forge.app.config as { forgeRepo?: string }).forgeRepo = "alice/forge"; | |
| 212 | 226 | const failed: string[] = []; |
| 213 | 227 | for (let run = 0; run < 20; run++) |
| 214 | 228 | for (const r of await prove(forge.servers.url, fetch)) |
test/v1-proven.test.ts +18 −4
| @@ -27,6 +27,9 @@ const rule = (days: number, words = days) => | ||
| 27 | 27 | const health = (schedules?: unknown) => |
| 28 | 28 | Response.json({ ok: true, version: "1.0.0", commit: "058b6cf", draining: false, ...(schedules === undefined ? {} : { schedules }) }); |
| 29 | 29 | |
| 30 | const FEED_WITH_ENTRY = '<?xml version="1.0"?><feed xmlns="http://www.w3.org/2005/Atom"><title>t</title><entry><title>v1</title></entry></feed>'; | |
| 31 | const FEED_EMPTY = '<?xml version="1.0"?><feed xmlns="http://www.w3.org/2005/Atom"><title>t</title></feed>'; | |
| 32 | ||
| 30 | 33 | type Over = Record<string, () => Response>; |
| 31 | 34 | function stub(over: Over = {}, seen: string[] = []): Fetch { |
| 32 | 35 | const routes: Over = { |
| @@ -41,6 +44,7 @@ function stub(over: Over = {}, seen: string[] = []): Fetch { | ||
| 41 | 44 | "/settings/billing": () => new Response(null, { status: 303, headers: { location: "/signin?next=%2Fsettings%2Fbilling" } }), |
| 42 | 45 | "/settings/crew": () => new Response(null, { status: 303, headers: { location: "/signin?next=%2Fsettings%2Fcrew" } }), |
| 43 | 46 | "/api/v1/health": () => health({ overdue: 0, oldestSeconds: 0 }), |
| 47 | "/changelog.atom": () => new Response(FEED_WITH_ENTRY), | |
| 44 | 48 | ...over, |
| 45 | 49 | }; |
| 46 | 50 | return async (url, init) => { |
| @@ -54,9 +58,9 @@ describe("v1-proven", () => { | ||
| 54 | 58 | test("every list item has a probe, and all pass on a healthy forge", async () => { |
| 55 | 59 | const results = await prove("https://f.test/", stub()); |
| 56 | 60 | expect(results.map((r) => r.issue).sort()).toEqual( |
| 57 | [11541, 11539, 11158, 11573, 10304, 11507, 11138, 11140, 11141, 11515, 11595, 10441].sort(), | |
| 61 | [11541, 11539, 11158, 11573, 10304, 11507, 11138, 11140, 11141, 11515, 11595, 10441, 13072].sort(), | |
| 58 | 62 | ); |
| 59 | expect(probes.length).toBe(12); | |
| 63 | expect(probes.length).toBe(13); | |
| 60 | 64 | const status = (n: number) => results.find((r) => r.issue === n)?.status; |
| 61 | 65 | // What no public read can show is unproven, never a pass. |
| 62 | 66 | expect(results.filter((r) => r.status === "unproven").map((r) => r.issue).sort()).toEqual([]); |
| @@ -92,6 +96,8 @@ describe("v1-proven", () => { | ||
| 92 | 96 | [11141, { "/pricing": pricing(ldWith(props().slice(0, 2))) }, [11141]], |
| 93 | 97 | [11515, { "/settings/crew": () => new Response("x", { status: 500 }) }, [11515]], |
| 94 | 98 | [11595, { "/api/v1/health": () => health({ overdue: 2, oldestSeconds: 86_400 }) }, [11595]], |
| 99 | [13072, { "/changelog.atom": () => new Response(FEED_EMPTY) }, [13072]], | |
| 100 | [13072, { "/changelog.atom": () => new Response("gone", { status: 404 }) }, [13072]], | |
| 95 | 101 | [10441, { "/healthz": () => new Response("ok") }, [10441]], |
| 96 | 102 | ]; |
| 97 | 103 | for (const [issue, over, expected] of breaks) |
| @@ -103,6 +109,14 @@ describe("v1-proven", () => { | ||
| 103 | 109 | expect(line(results.find((r) => r.issue === issue)!)).toStartWith(`fail #${issue}`); |
| 104 | 110 | }); |
| 105 | 111 | |
| 112 | test("an empty changelog feed fails with its URL, status, bytes and time; a populated one passes", async () => { | |
| 113 | const empty = (await prove("https://f.test", stub({ "/changelog.atom": () => new Response(FEED_EMPTY) }))).find((x) => x.issue === 13072)!; | |
| 114 | expect(empty.status).toBe("fail"); | |
| 115 | expect(empty.detail).toMatch(new RegExp(`^/changelog\\.atom: status 200, ${FEED_EMPTY.length} bytes, \\d+ ms; the feed has no <entry>$`)); | |
| 116 | const full = (await prove("https://f.test", stub())).find((x) => x.issue === 13072)!; | |
| 117 | expect(full.status).toBe("pass"); | |
| 118 | }); | |
| 119 | ||
| 106 | 120 | test("the schedule probe fails naming the oldest age, is unproven without the field, and a network error is a fail", async () => { |
| 107 | 121 | const late = (await prove("https://f.test", stub({ "/api/v1/health": () => health({ overdue: 2, oldestSeconds: 3 * 3600 + 720 }) }))).find((x) => x.issue === 11595)!; |
| 108 | 122 | expect(line(late)).toBe("fail #11595 no schedule is past its period: 2 schedule(s) overdue, the oldest by 3 h 12 min"); |
| @@ -137,7 +151,7 @@ describe("v1-proven", () => { | ||
| 137 | 151 | const { code, out } = await run(async () => new Response("down", { status: 503 })); |
| 138 | 152 | expect(code).toBe(1); |
| 139 | 153 | expect(out).toContain("fail #11539"); |
| 140 | expect(out).toContain("v1.0.0 is not proven: 12 of 12 fail, 0 unproven"); | |
| 154 | expect(out).toContain("v1.0.0 is not proven: 13 of 13 fail, 0 unproven"); | |
| 141 | 155 | }); |
| 142 | 156 | |
| 143 | 157 | test("the script exits 3, not 0, when nothing fails but some items are unproven", async () => { |
| @@ -145,7 +159,7 @@ describe("v1-proven", () => { | ||
| 145 | 159 | expect(out).not.toContain("fail #"); |
| 146 | 160 | expect(code).toBe(3); |
| 147 | 161 | expect(out).toContain("unproven #11595"); |
| 148 | expect(out).toContain("v1.0.0 is not proven: none fail, 1 of 12 unproven"); | |
| 162 | expect(out).toContain("v1.0.0 is not proven: none fail, 1 of 13 unproven"); | |
| 149 | 163 | }); |
| 150 | 164 | |
| 151 | 165 | test("the script exits 2 on bad usage", () => { |
new above
offline