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

A test that reads an /api/v1 answer disagreeing with openapi.json goes red #18013

opened this

Merged 10h 50m ago, live in production

The suite's /api/v1 contract check now fails a test by default. Any answer a test reads through fetch that disagrees with openapi.json throws, naming the field. Collect mode is still there, but only behind FORGECONTRACTCOLLECT=1, for the next schema audit.

Notes

opened this

The suite's /api/v1 contract check now fails a test by default. Any answer a test reads through fetch that disagrees with openapi.json throws, naming the field. Collect mode is still there, but only behind FORGE_CONTRACT_COLLECT=1, for the next schema audit.

  • test/helpers/contract-fetch.ts: the mode a process starts in comes from the new STRICT_BY_DEFAULT, which is strict unless FORGE_CONTRACT_COLLECT=1. contractStrict(on) still switches the mode within a test file. The header comment now describes strict as the default.
  • test/support/conforms.test.ts: a new first case in the block fetches the approvedAt-as-object stub without calling contractStrict, and expects the rejection $.approvedAt: is object, declared string|null. It would fail on the old collect default. It is skipped when the run sets FORGE_CONTRACT_COLLECT=1. afterAll now puts back the starting mode instead of forcing collect.
  • docs/features/api-shape-changes.md: "A route's tests add the same check as they gain samples" now says every /api/v1 answer a test reads is checked by the preload's wrapped fetch, and names FORGE_CONTRACT_COLLECT=1 for audits.

No schema fixes are in this pull, because none turned up. Parts 2 and 3 (#18001 and the one before it) audited the suite. I ran 120 of the 1163 test files that read /api/v1 in collect mode, about 1061 tests, and none printed a CONTRACT line. One test in that run failed: test/mcp/forks.test.ts "the private fork's owner sees it". The fork answer has a words line the test's fixed value doesn't list. It fails the same way with this change stashed, so this pull doesn't cause it and doesn't fix it. If the forge's full check turns any test red on a contract disagreement, the fix is to declare the type the route already serves in src/contract/openapi/schemas/*, in this pull.

No production code or served shape changes. "No door" because this touches only the test harness and its doc.

Checks run: bun scripts/gate.ts is clean and bun x tsc --noEmit passes. test/support/conforms.test.ts and test/approval-base.test.ts pass: 7 of 7 conforms cases by default, and 6 plus 1 skipped under FORGE_CONTRACT_COLLECT=1.

To try it: bun test test/support/conforms.test.ts, then FORGE_CONTRACT_COLLECT=1 bun test <files> to list disagreements without failing.

🤖 Generated with Claude Code

Closes #17988

commented

The suite's /api/v1 contract check now fails a test by default. Any answer a test reads through fetch that disagrees with openapi.json throws, naming the field. Collect mode is still there, but only behind FORGE_CONTRACT_COLLECT=1, for the next schema audit.

  • test/helpers/contract-fetch.ts: the mode a process starts in comes from the new STRICT_BY_DEFAULT, which is strict unless FORGE_CONTRACT_COLLECT=1. contractStrict(on) still switches the mode within a test file. The header comment now describes strict as the default.
  • test/support/conforms.test.ts: a new first case in the block fetches the approvedAt-as-object stub without calling contractStrict, and expects the rejection $.approvedAt: is object, declared string|null. It would fail on the old collect default. It is skipped when the run sets FORGE_CONTRACT_COLLECT=1. afterAll now puts back the starting mode instead of forcing collect.
  • docs/features/api-shape-changes.md: "A route's tests add the same check as they gain samples" now says every /api/v1 answer a test reads is checked by the preload's wrapped fetch, and names FORGE_CONTRACT_COLLECT=1 for audits.

No schema fixes are in this pull, because none turned up. Parts 2 and 3 (#18001 and the one before it) audited the suite. I ran 120 of the 1163 test files that read /api/v1 in collect mode, about 1061 tests, and none printed a CONTRACT line. One test in that run failed: test/mcp/forks.test.ts "the private fork's owner sees it". The fork answer has a words line the test's fixed value doesn't list. It fails the same way with this change stashed, so this pull doesn't cause it and doesn't fix it. If the forge's full check turns any test red on a contract disagreement, the fix is to declare the type the route already serves in src/contract/openapi/schemas/*, in this pull.

No production code or served shape changes. "No door" because this touches only the test harness and its doc.

Checks run: bun scripts/gate.ts is clean and bun x tsc --noEmit passes. test/support/conforms.test.ts and test/approval-base.test.ts pass: 7 of 7 conforms cases by default, and 6 plus 1 skipped under FORGE_CONTRACT_COLLECT=1.

To try it: bun test test/support/conforms.test.ts, then FORGE_CONTRACT_COLLECT=1 bun test <files> to list disagreements without failing.

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs