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

The daily proof runs only on the forge that holds the repository it proves #16358

Closed opened this
Closed without merging

sold/proof-only-at-home → main 1 commit

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
2 files changed +39 −0
src/maintain/duties/daily_proof.ts +10
@@ -13,6 +13,7 @@
1313 */
1414
1515 import { ownRepoPath } from "../../kernel/own_repo.ts";
16 import { getRepo } from "../../core/repos.ts";
1617 import { publicOrigin } from "../../core/public_origin.ts";
1718 import { shortOf } from "../../kernel/version.ts";
1819 import { BUDGET_MS, lastRelease, proveDaily, recordRun, releaseDue, releaseId } from "../../release/daily_proof.ts";
@@ -63,6 +64,15 @@ export function dailyProof(
6364 const fresh = release !== null && lastRelease(db) !== release;
6465 const base = publicOrigin(url, "");
6566 const repo = app?.config.forgeRepo || ownRepoPath();
67 // The proof is of the forge whose repository this is: a forge deployed from it (a pinned or
68 // sold forge) holds no such repository and has no release of it, and its closed sign-up is
69 // its owner's choice, so proving production there would only ever fail (test1, 2026-11-24).
70 const [owner = "", name = ""] = repo.split("/");
71 if (!owner || !name || getRepo(db, owner, name) === undefined) {
72 // An ask raised before this rule (a sold forge's first boots) would otherwise stand for ever.
73 db.run("DELETE FROM daily_proof_ask");
74 return { findings: [], actions: [`skipped: this forge does not hold ${repo}, the repository whose production this proves`] };
75 }
6676 let lines: Line[];
6777 if (fetcher !== undefined || app === undefined) lines = await proveDaily(base, repo, fetcher ?? fetch, now.getTime(), budget());
6878 else {
test/daily-proof.test.ts +29
@@ -12,6 +12,8 @@ import { mkdtemp, rm } from "node:fs/promises";
1212 import { tmpdir } from "node:os";
1313 import { join } from "node:path";
1414 import { createApp, type App } from "../src/app.ts";
15 import { createRepo } from "../src/core/repos.ts";
16 import { createUser } from "../src/core/users.ts";
1517 import { firedAlarms, FORGE_BROKEN } from "../src/flow/alarms.ts";
1618 import { serve, type Servers } from "../src/http/server.ts";
1719 import { dailyProof } from "../src/maintain/duties/daily_proof.ts";
@@ -90,6 +92,12 @@ let servers: Servers;
9092 let world: World = {};
9193 let now = T0;
9294 const calls: Calls[] = [];
95 /** The proof is of the forge that holds `o/forge`: give a test forge that repository. */
96 async function holdOwn(a: App): Promise<void> {
97 const u = await createUser(a.db, { origin: "seed", trusted: true, username: "o", email: "[email protected]", password: "a-good-passphrase", isAdmin: true });
98 const id = (u as any).ok === false ? undefined : ((u as any).value?.id ?? (u as any).id);
99 await createRepo(a.db, a.reposRoot, { ownerId: id, name: "forge", visibility: "public" } as any);
100 }
93101 const fakeApp = () => ({ config: { url: `${BASE}/`, forgeRepo: "o/forge" } }) as unknown as App;
94102 const runDay = async (day: number, w: World = {}): Promise<DutyResult> => {
95103 world = w;
@@ -103,6 +111,7 @@ const verdicts = () => Object.fromEntries((lastRun(app.db)?.lines ?? []).map((l)
103111 beforeAll(async () => {
104112 dir = await mkdtemp(join(tmpdir(), "daily-proof-"));
105113 app = createApp({ dataDir: dir, port: 0 });
114 await holdOwn(app);
106115 servers = await serve(app);
107116 });
108117 afterAll(async () => {
@@ -219,6 +228,7 @@ describe("once after each release goes live (#15937)", () => {
219228
220229 test("a new release id runs the proof exactly once after it settles; an unchanged one none", async () => {
221230 const sub = createApp({ dataDir: join(dir, "release-app"), port: 0, url: `${BASE}/`, forgeRepo: "o/forge" });
231 await holdOwn(sub);
222232 let clock = T0;
223233 const runs = () => (sub.db.query("SELECT COUNT(*) AS n FROM daily_proof_run").get() as { n: number }).n;
224234 const boot = (release: string, bootedAt: number) => {
@@ -312,6 +322,7 @@ describe("the forge's own origin, read in process (#15936)", () => {
312322
313323 test("with the gate refusing every outside fetch, the duty still reads real lines from its own router", async () => {
314324 const own = createApp({ dataDir: join(dir, "own"), port: 0, url: `${BASE}/`, forgeRepo: "o/forge" });
325 await holdOwn(own);
315326 const real = globalThis.fetch;
316327 const outside: string[] = [];
317328 globalThis.fetch = (async (input: string | URL | Request) => {
@@ -389,3 +400,21 @@ describe("recording a run", () => {
389400 expect(e.length).toBeLessThanOrEqual(240);
390401 });
391402 });
403
404 describe("a forge that does not hold the repository (a deployed or sold forge)", () => {
405 test("proves nothing and asks nothing: its closed sign-up and missing releases are not production failing", async () => {
406 const other = createApp({ dataDir: join(dir, "sold"), port: 0, url: `${BASE}/`, forgeRepo: "o/forge" });
407 try {
408 other.db.run("INSERT INTO daily_proof_ask (item, raised_at, verdict, url, evidence) VALUES ('sign-up page', '2026-11-24T00:00:00.000Z', 'FAIL', 'u', '403')");
409 const calls: string[] = [];
410 const r = await dailyProof(async (u) => (calls.push(String(u)), new Response("x")), undefined, { release: null }).run({ db: other.db, bus: other.bus, now: new Date(), app: other });
411 expect(calls).toEqual([]);
412 expect(r.findings).toEqual([]);
413 expect(r.actions.join(" ")).toContain("does not hold o/forge");
414 expect((other.db.query("SELECT COUNT(*) AS n FROM daily_proof_run").get() as { n: number }).n).toBe(0);
415 expect((other.db.query("SELECT COUNT(*) AS n FROM daily_proof_ask").get() as { n: number }).n).toBe(0);
416 } finally {
417 other.close();
418 }
419 });
420 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs