Public: anyone can read this; the crew can change it.
The v1 proof passes #11141: a public read states what each plan does at its CPU ceiling and when a lapsed forge sleeps #12576
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/12560-the-v1-proof-passes-11141-a-public-read → main 3 commits fork
6 files
changed +77
−12
scripts/v1-proven.ts +19 −2
| @@ -160,8 +160,25 @@ export const probes: readonly Probe[] = [ | ||
| 160 | 160 | { |
| 161 | 161 | issue: 11141, |
| 162 | 162 | item: "an owner's plan and billing page exists", |
| 163 | run: async (get) => | |
| 164 | unproven(`${await gated(get, "/settings/billing")}; CPU slowing, the first change landing and lapsed-payment sleep have no public read`), | |
| 163 | run: async (get) => { | |
| 164 | const gate = await gated(get, "/settings/billing"); | |
| 165 | const got = await bodyOk(get, "/pricing"); | |
| 166 | const m = /<script[^>]*application\/ld\+json[^>]*>([\s\S]*?)<\/script>/i.exec(got.text); | |
| 167 | expect(m !== null, "/pricing lists no plans"); | |
| 168 | type Prop = { name?: string; value?: unknown }; | |
| 169 | const offers = (JSON.parse(m?.[1] ?? "{}") as { offers?: { name?: string; additionalProperty?: Prop[] }[] }).offers ?? []; | |
| 170 | expect(offers.length > 0, "/pricing lists no plans"); | |
| 171 | const attr = /data-grace-days="(\d+)"/.exec(got.text)?.[1]; | |
| 172 | for (const o of offers) { | |
| 173 | const prop = (n: string): unknown => (o.additionalProperty ?? []).find((p) => p.name === n)?.value; | |
| 174 | const ceiling = prop("At its CPU ceiling"); | |
| 175 | expect(typeof ceiling === "string" && /slowed/i.test(ceiling), `the ${o.name ?? "?"} offer says nothing of what its CPU ceiling does`); | |
| 176 | const days = prop("Days of grace after a lapsed payment"); | |
| 177 | expect(attr !== undefined && String(days) === attr, `the ${o.name ?? "?"} offer says ${String(days)} days of grace, the page ${String(attr)}`); | |
| 178 | expect(/sleeps/i.test(String(prop("After the grace") ?? "")), `the ${o.name ?? "?"} offer does not say the forge sleeps after its grace`); | |
| 179 | } | |
| 180 | return `${gate}; each of ${offers.length} plans says what its CPU ceiling does and that a lapsed forge sleeps after ${attr} days of grace`; | |
| 181 | }, | |
| 165 | 182 | }, |
| 166 | 183 | { |
| 167 | 184 | issue: 11515, |
src/spawn/cores.ts +9
| @@ -76,6 +76,15 @@ export function coresWords(c: Cores): string { | ||
| 76 | 76 | return `${head} Nothing limits this forge to its cores. A build that stays above ${CPU_STOP_FACTOR === 2 ? "twice" : `${CPU_STOP_FACTOR}×`} its cores for ${minutes(CPU_STOP_HOLD_MS)} is stopped; the first ${minutes(CPU_STOP_GRACE_MS)} are safe.`; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | /** | |
| 80 | * What a plan's CPU ceiling does, for a public reader, from the same constants the watch uses. | |
| 81 | * Both holds are said because which one applies is the host's: slowed where the kernel or pinning | |
| 82 | * holds the cores, stopped only by the watch where neither does. | |
| 83 | */ | |
| 84 | export function ceilingWords(cpus: number): string { | |
| 85 | return `At ${coreWord(cpus)}, a busy build is slowed, never stopped, where the kernel or pinning holds the cores. Where neither does, a build above ${CPU_STOP_FACTOR === 2 ? "twice" : `${CPU_STOP_FACTOR}×`} its cores for ${minutes(CPU_STOP_HOLD_MS)} is stopped; the first ${minutes(CPU_STOP_GRACE_MS)} are safe.`; | |
| 86 | } | |
| 87 | ||
| 79 | 88 | /** The line, or undefined on a forge that is no cell child. */ |
| 80 | 89 | export function coresLine(s: CoresSource = realCores()): string | undefined { |
| 81 | 90 | const c = coresOf(s); |
src/web/offer.ts +10 −1
| @@ -4,12 +4,14 @@ | ||
| 4 | 4 | * from the plans setting so they cannot disagree with the pricing page. |
| 5 | 5 | */ |
| 6 | 6 | import { SIZES } from "../spawn/sizes.ts"; |
| 7 | import { ceilingWords } from "../spawn/cores.ts"; | |
| 8 | import type { LapseRule } from "../billing/lapse_rule.ts"; | |
| 7 | 9 | import type { Plan } from "../settings/plans.ts"; |
| 8 | 10 | |
| 9 | 11 | const gb = (mib: number): number => mib / 1024; |
| 10 | 12 | |
| 11 | 13 | /** One schema.org Offer per plan, with its size and monthly crew credit as plain properties. */ |
| 12 | export function offerData(plans: readonly Plan[], origin: string): object[] { | |
| 14 | export function offerData(plans: readonly Plan[], origin: string, rule?: LapseRule): object[] { | |
| 13 | 15 | return plans.map((p) => { |
| 14 | 16 | const s = SIZES[p.size]; |
| 15 | 17 | return { |
| @@ -24,6 +26,13 @@ export function offerData(plans: readonly Plan[], origin: string): object[] { | ||
| 24 | 26 | { "@type": "PropertyValue", name: "Memory (GB)", value: gb(s.memoryMiB) }, |
| 25 | 27 | { "@type": "PropertyValue", name: "Disk (GB)", value: gb(s.diskMiB) }, |
| 26 | 28 | { "@type": "PropertyValue", name: "Crew credit (USD a month)", value: p.creditUsd }, |
| 29 | ...(rule === undefined | |
| 30 | ? [] | |
| 31 | : [ | |
| 32 | { "@type": "PropertyValue", name: "At its CPU ceiling", value: ceilingWords(s.cpu) }, | |
| 33 | { "@type": "PropertyValue", name: "Days of grace after a lapsed payment", value: rule.graceDays }, | |
| 34 | { "@type": "PropertyValue", name: "After the grace", value: "The forge sleeps and keeps its data." }, | |
| 35 | ]), | |
| 27 | 36 | ], |
| 28 | 37 | }; |
| 29 | 38 | }); |
src/web/pages/pricing.ts +1 −1
| @@ -99,7 +99,7 @@ export function pricingPage(ctx: Ctx): Response { | ||
| 99 | 99 | ctx, |
| 100 | 100 | title: "Open Platform Forge: pricing and your own forge", |
| 101 | 101 | description: SITE_PATH(ctx.url.origin), |
| 102 | jsonLd: safeJson({ "@context": "https://schema.org", "@type": "Product", name: "Open Platform Forge", url: `${ctx.url.origin}/`, offers: offerData(plans, ctx.url.origin) }), | |
| 102 | jsonLd: safeJson({ "@context": "https://schema.org", "@type": "Product", name: "Open Platform Forge", url: `${ctx.url.origin}/`, offers: offerData(plans, ctx.url.origin, lapseRule(ctx.app.db)) }), | |
| 103 | 103 | body: plansView(ctx, { name: (ctx.url.searchParams.get("name") ?? "").slice(0, 38), email: "" }, {}), |
| 104 | 104 | }); |
| 105 | 105 | notePhase(ctx.request, "render", performance.now() - rendering); |
test/offer-lapse.test.ts added +16
| @@ -0,0 +1,16 @@ | ||
| 1 | import { expect, test } from "bun:test"; | |
| 2 | import { CPU_STOP_HOLD_MS } from "../src/apps/cpu_rule.ts"; | |
| 3 | import { offerData } from "../src/web/offer.ts"; | |
| 4 | import { SIZES } from "../src/spawn/sizes.ts"; | |
| 5 | import type { Plan } from "../src/settings/plans.ts"; | |
| 6 | ||
| 7 | const plan: Plan = { key: "free", name: "Free", says: "x", size: "small", priceUsd: 0, creditUsd: 0, forges: 1 }; | |
| 8 | ||
| 9 | test("each offer states its CPU ceiling and the grace before a lapsed forge sleeps, from the constants", () => { | |
| 10 | const [o] = offerData([plan], "https://f.test", { graceDays: 9, lapse: "sleep" }) as { additionalProperty: { name: string; value: unknown }[] }[]; | |
| 11 | const v = (n: string) => o!.additionalProperty.find((p) => p.name === n)?.value; | |
| 12 | expect(String(v("At its CPU ceiling"))).toContain(`${SIZES["small" as keyof typeof SIZES].cpu} CPU`); | |
| 13 | expect(String(v("At its CPU ceiling"))).toContain(`${CPU_STOP_HOLD_MS / 60_000} minutes`); | |
| 14 | expect(v("Days of grace after a lapsed payment")).toBe(9); | |
| 15 | expect(String(v("After the grace"))).toContain("sleeps"); | |
| 16 | }); |
test/v1-proven.test.ts +22 −8
| @@ -9,7 +9,19 @@ const HEADERS = { | ||
| 9 | 9 | "permissions-policy": "camera=()", |
| 10 | 10 | "cross-origin-opener-policy": "same-origin", |
| 11 | 11 | }; |
| 12 | const ld = JSON.stringify({ offers: [{ description: "A small forge that sleeps when idle" }, { description: "Small, awake" }] }); | |
| 12 | const props = (days = 7, ceiling = "At 1 CPU, a busy build is slowed, never stopped.") => [ | |
| 13 | { name: "At its CPU ceiling", value: ceiling }, | |
| 14 | { name: "Days of grace after a lapsed payment", value: days }, | |
| 15 | { name: "After the grace", value: "The forge sleeps and keeps its data." }, | |
| 16 | ]; | |
| 17 | const ld = JSON.stringify({ | |
| 18 | offers: [ | |
| 19 | { name: "Free", description: "A small forge that sleeps when idle", additionalProperty: props() }, | |
| 20 | { name: "Small", description: "Small, awake", additionalProperty: props() }, | |
| 21 | ], | |
| 22 | }); | |
| 23 | const ldWith = (additionalProperty: unknown[]) => JSON.stringify({ offers: [{ name: "Free", description: "sleeps", additionalProperty }, { name: "Small", description: "x", additionalProperty: props() }] }); | |
| 24 | const pricing = (json: string) => () => new Response(`<form method="post" action="/pricing/order"></form><script type="application/ld+json">${json}</script>${rule(7)}`); | |
| 13 | 25 | const rule = (days: number, words = days) => |
| 14 | 26 | `<p data-lapse="sleep" data-grace-days="${days}">If a payment lapses, you have ${words} days of grace. After that your forge sleeps and keeps its data.</p>`; |
| 15 | 27 | const health = (schedules?: unknown) => |
| @@ -47,7 +59,7 @@ describe("v1-proven", () => { | ||
| 47 | 59 | expect(probes.length).toBe(12); |
| 48 | 60 | const status = (n: number) => results.find((r) => r.issue === n)?.status; |
| 49 | 61 | // What no public read can show is unproven, never a pass. |
| 50 | expect(results.filter((r) => r.status === "unproven").map((r) => r.issue).sort()).toEqual([11141]); | |
| 62 | expect(results.filter((r) => r.status === "unproven").map((r) => r.issue).sort()).toEqual([]); | |
| 51 | 63 | expect(results.filter((r) => r.status === "fail")).toEqual([]); |
| 52 | 64 | expect(status(11595)).toBe("pass"); |
| 53 | 65 | expect(line(results[0]!)).toStartWith("pass #11541"); |
| @@ -68,13 +80,16 @@ describe("v1-proven", () => { | ||
| 68 | 80 | [11573, { "/readyz": () => new Response("draining", { status: 503 }) }, [11573]], |
| 69 | 81 | [10304, { "/api/v1/version": () => Response.json({ version: "dev" }) }, [10304]], |
| 70 | 82 | [11507, { "/llms.txt": () => new Response("Start my forge") }, [11507]], |
| 71 | [11138, { "/pricing": () => new Response("<p>none</p>") }, [11138, 11140]], | |
| 72 | [11140, { "/pricing": () => new Response('<form method="post" action="/pricing/order"></form><script type="application/ld+json">{"offers":[]}</script>') }, [11140]], | |
| 73 | [11140, { "/pricing": () => new Response(`<form method="post" action="/pricing/order"></form><script type="application/ld+json">${ld}</script>`) }, [11140]], | |
| 83 | [11138, { "/pricing": () => new Response("<p>none</p>") }, [11138, 11140, 11141]], | |
| 84 | [11140, { "/pricing": () => new Response('<form method="post" action="/pricing/order"></form><script type="application/ld+json">{"offers":[]}</script>') }, [11140, 11141]], | |
| 85 | [11140, { "/pricing": () => new Response(`<form method="post" action="/pricing/order"></form><script type="application/ld+json">${ld}</script>`) }, [11140, 11141]], | |
| 74 | 86 | [11140, { "/api/v1/plans": () => Response.json({ items: [], graceDays: 3, lapse: "sleep" }) }, [11140]], |
| 75 | 87 | [11140, { "/api/v1/plans": () => Response.json({ items: [] }) }, [11140]], |
| 76 | 88 | [11140, { "/pricing": () => new Response(`<form method="post" action="/pricing/order"></form><script type="application/ld+json">${ld}</script>${rule(7, 5)}`) }, [11140]], |
| 77 | 89 | [11141, { "/settings/billing": () => new Response("x", { status: 404 }) }, [11141]], |
| 90 | [11141, { "/pricing": pricing(ldWith(props().slice(1))) }, [11141]], | |
| 91 | [11141, { "/pricing": pricing(ldWith(props(5))) }, [11141]], | |
| 92 | [11141, { "/pricing": pricing(ldWith(props().slice(0, 2))) }, [11141]], | |
| 78 | 93 | [11515, { "/settings/crew": () => new Response("x", { status: 500 }) }, [11515]], |
| 79 | 94 | [11595, { "/api/v1/health": () => health({ overdue: 2, oldestSeconds: 86_400 }) }, [11595]], |
| 80 | 95 | [10441, { "/healthz": () => new Response("ok") }, [10441]], |
| @@ -126,11 +141,10 @@ describe("v1-proven", () => { | ||
| 126 | 141 | }); |
| 127 | 142 | |
| 128 | 143 | test("the script exits 3, not 0, when nothing fails but some items are unproven", async () => { |
| 129 | // Only the no-public-read item is unproven. | |
| 130 | const { code, out } = await run(stub()); | |
| 144 | const { code, out } = await run(stub({ "/api/v1/health": () => health() })); | |
| 131 | 145 | expect(out).not.toContain("fail #"); |
| 132 | 146 | expect(code).toBe(3); |
| 133 | expect(out).toContain("unproven #11141"); | |
| 147 | expect(out).toContain("unproven #11595"); | |
| 134 | 148 | expect(out).toContain("v1.0.0 is not proven: none fail, 1 of 12 unproven"); |
| 135 | 149 | }); |
| 136 | 150 |
new above
offline