Public: anyone can read this; the crew can change it.
The suite's fetch reports each /api/v1 answer that disagrees with openapi.json, without failing yet #17989
Merged 12h 11m ago, live in production
Under bun test, the suite's fetch now checks every /api/v1 answer a test reads against openapi.json. For now it only reports what disagrees and fails nothing (part 1 of #17961). test/helpers/contract-fetch.ts (new) wraps globalThis.fetch.
-
Reviews
ApprovedTest-only change: no page, route or served shape moves, so there is no door, preview or a11y surface to judge. The wrapper does what the issue says: lazy doc, most-literal route wins, GET + /api/v1/ + 200 + JSON only, silent pass for undeclared or non-JSON, collect by default with one CONTRACT line, and contractStrict throws the named error. It is installed only inside the preload's test-run try. Both new cases fail without the wrapper. Next, in order: (1) once #17986 and #17987 land, turn strict on and drop the collect mode so there is one way; (2) make the wrapper skip a relative or unparsable input instead of throwing from
new URL, so the test sees fetch's own error. -
Checks
shipped production is serving it deploy 5ce50ab
-
History
- Rewrap a comment in contract-fetch.ts (gate --fix) b3bea9f
- The suite's fetch reports each /api/v1 answer that disagrees with openapi.json (#17985) 2b12aa7
- Anonymous, opt-in app telemetry: a route to receive daily summaries, and an owner view (#17967) 973052e
- Runner jobs' git-upload-pack: count the work per job, then cut it so the serving thread is not held (#17984) ee5308f
- A `[loop]` stall line names what the serving thread was doing: the route or duty in flight (#17982) bb47d9a
- takeLook's loopback-only test stops failing checks for a missing prerequisite (56 reds last week) (#17979) 87f7f1b
- A Talk turn that reaches its limit says so and offers one tap to go on (#17981) 7ada34c
- Talk logs one line per model call: account, model, seconds, how it ended (#17980) 353f588
- Sentinel: The lane has stopped: nothing has merged and nothing said so (#17973) 010904c
- Full suite red: test/traffic-truth.test.ts (#17972) 13460d3
- Infrastructure: a game box container opens on its live log, with Restart, Stop and Start (#17946) db96b4c
- Full suite red: test/api-security-floor.test.ts (#17965) 091b8a0
- Public /privacy and /support pages (needed for the App Store listing) (#17948) 638aa4f
- A container in the cloud tree has a Logs tab with its recent lines (#17958) 07d8c64
- A join that freezes a lent job is recorded with how long the freeze took (#17956) 80543a4
- A lent job on a game box keeps the server's tps and mspt from before it and during it (#17957) a357207
- The /infra first page shows the costliest resources as a sortable table (#17955) e08c778
- Push to Apple devices (APNs): device registration and a sender (#17928) 19eaf78
- A machine's containers in the cloud tree read as a table: name, state, CPU, memory, started (#17954) ccd2925
- API shapes: no silent type changes (approvedAt became an object); contract-test responses against openapi.json (#17945) 1b196c6
Under bun test, the suite's fetch now checks every /api/v1 answer a test reads against openapi.json. For now it only reports what disagrees and fails nothing (part 1 of #17961).
test/helpers/contract-fetch.ts(new) wrapsglobalThis.fetch.- What it checks: after the real fetch, a GET whose path starts with
/api/v1/and that answers 200application/jsonis matched to its route. The route document is built once, on first use, fromopenapi("https://forge.test", "test", "admin"). Each{param}matches[^/]+, and when several routes match, the one with the most literal segments wins. - How: the body is read with
res.clone().json()and checked with the existingdisagreementsfromtest/support/conforms.ts. - What passes silently: no matching route, no declared 200 JSON schema, or a body that isn't valid JSON.
- Modes: by default each disagreement goes to stderr as one line,
CONTRACT GET <pathname>: <list>.contractStrict(true)throws `GET ${pathname} disagrees with openapi.json (#17944): …` instead.
- What it checks: after the real fetch, a GET whose path starts with
test/helpers/preload.tsinstalls the wrapper inside the sametrythat registers theafterEachguard. A child that loads the preload but isn't a test run never gets it.test/support/conforms.test.tsgains two cases against aBun.serve({ port: 0 })stub. Its valid PullDetail sample is generated from the declared schema.- Strict: an answer with
approvedAt: {at:"x"}rejects with$.approvedAt: is object, declared string|null. A valid sample, an undeclared route and a non-API path pass untouched. - Collect: the same bad answer gives exactly one
CONTRACTline on stderr and the test still reads the body.
- Strict: an answer with
Both cases fail when the wrapper isn't installed.
Left out on purpose: schema fixes (#17986, #17987), turning the throw on and the doc wording (#17988). There is no full-suite run and no change to production code or any served shape.
Checks:
bun test test/support/conforms.test.ts test/approval-base.test.ts: 7 pass.bun x tsc --noEmit: clean.bun scripts/gate.ts: 0 fail. It notes that the outer install function and the inner wrapper look alike; they are one wrapper and its installer.
To try it: bun test test/support/conforms.test.ts. To list the current disagreements, run any API test file and grep stderr for CONTRACT GET.
🤖 Generated with Claude Code
Under
bun test, the suite'sfetchnow checks every/api/v1answer a test reads againstopenapi.json. For now it only reports what disagrees and fails nothing (part 1 of #17961).test/helpers/contract-fetch.ts(new) wrapsglobalThis.fetch./api/v1/and that answers 200application/jsonis matched to its route. The route document is built once, on first use, fromopenapi("https://forge.test", "test", "admin"). Each{param}matches[^/]+, and when several routes match, the one with the most literal segments wins.res.clone().json()and checked with the existingdisagreementsfromtest/support/conforms.ts.CONTRACT GET <pathname>: <list>.contractStrict(true)throws `GET ${pathname} disagrees with openapi.json (#17944): …` instead.test/helpers/preload.tsinstalls the wrapper inside the sametrythat registers theafterEachguard. A child that loads the preload but isn't a test run never gets it.test/support/conforms.test.tsgains two cases against aBun.serve({ port: 0 })stub. Its valid PullDetail sample is generated from the declared schema.approvedAt: {at:"x"}rejects with$.approvedAt: is object, declared string|null. A valid sample, an undeclared route and a non-API path pass untouched.CONTRACTline on stderr and the test still reads the body.Both cases fail when the wrapper isn't installed.
Left out on purpose: schema fixes (#17986, #17987), turning the throw on and the doc wording (#17988). There is no full-suite run and no change to production code or any served shape.
Checks:
bun test test/support/conforms.test.ts test/approval-base.test.ts: 7 pass.bun x tsc --noEmit: clean.bun scripts/gate.ts: 0 fail. It notes that the outer install function and the inner wrapper look alike; they are one wrapper and its installer.To try it:
bun test test/support/conforms.test.ts. To list the current disagreements, run any API test file and grep stderr forCONTRACT GET.🤖 Generated with Claude Code
Closes #17985