Repository navigation
Add canonical format schema resolver CI coverage - #5144
Conversation
381e182 to
02d739c
Compare
There was a problem hiding this comment.
Approving. Adds load-bearing CI coverage for the fetch contract that 3.1 storyboards depend on — the canonical format_schema references only matter if the resolver enforces them, and that enforcement now lives in npm test and build-check.yml.
Things I checked
tests/canonical-reference-resolver.test.cjs:181-189— fixture-coverage guard pins 14 canonical fixtures toEXPECTED_FIXTURES; a new fixture without a list entry fails the build.server/src/training-agent/task-handlers.ts:518-519andtenants/router.ts:50—SUPPORTED_RELEASE_VERSIONSchange is additive (3.0,3.1-beta.5,3.1-beta.7); existing3.1-beta.5pins still resolve. Matches the exact-match pre-release rule atdocs/reference/versioning.mdx:43-58..changeset/4591-format-schema-resolver-ci.md— empty-frontmatter form, matching prior precedent (3570-version-negotiation-docs-and-storyboard.md). Nostatic/schemas/source/**changes; no schema drift..github/workflows/build-check.yml:65-66— CI step wired into the validate-schemas job. Failure in the new runner blocks the build.- PR body test plan — all items checked, including 473/473 server vitest and 19/19 resolver runs.
Follow-ups (non-blocking — file as issues)
- Wire-vs-SDK error-code parity. The runner asserts the SDK's internal
result.error.codevocabulary —digest_mismatch,non_https_url,redirect_blocked,body_too_large,unsafe_url,ref_sandbox_violation,budget_exceeded,unsupported_schema_draft,http_error. None appear instatic/schemas/source/enums/error-code.json(SCREAMING_SNAKE_CASE). The fixtures themselves declareexpected_error_code: FORMAT_PROJECTION_FAILED(the wire code) and the runner doesn't read it. Add a wire-surfaced assertion againstexpected_error_codeso an SDK rename can't desync from the catalog silently. Seestatic/examples/format-schemas/negative/01_digest_mismatch.json:33-34andstatic/schemas/source/enums/error-code.json:81-83. - Missing fetch-contract fixtures.
docs/creative/canonical-formats.mdx:220-221names two cases not fixtured: timeout-as-5xx-transient ("Timeout treated as a 5xx — transient — retry or skip") and DNS-rebinding ("Connection MUST be pinned to the resolved IP"). Worth closing the gap. - Scenario count silently grew 13→18 at
server/tests/unit/comply-test-controller.test.ts:178-195. Five newseed_*scenarios (seed_product,seed_pricing_option,seed_creative,seed_plan,seed_media_buy) ride along with the@adcp/sdk^8.1.0-beta.14→^8.1.0-beta.16bump — a real protocol-surface expansion arriving under a PR titled "Add canonical format schema resolver CI coverage." Notable. One bullet in the PR body would have flagged it. - Asymmetric drift detection at
server/src/training-agent/tenants/tenant-smoke.test.ts:237. SwitchingtoEqual(SALES_CURRENT_SCENARIOS)→toEqual(expect.arrayContaining(SALES_CURRENT_SCENARIOS))removes the upper-bound check on current-version scenarios. The 3.0-compat block at L400-L405 adds compensating.not.toContain(...)for two named scenarios; the current-version block has no equivalent. The same PR's 13→18 count change proves this drift class is live. Restore strict equality (and update the constant) or add symmetric negative assertions. --test-force-exitinpackage.json:38. Likely masking the undici keep-alive socket pool inside@adcp/sdk/canonical-references— 14 ephemeral local servers spun up across subtests,server.close()only stops accepting new connections, the SDK's pool keeps half-open sockets to dead listeners. Either callserver.closeAllConnections()beforeserver.close()or expose a dispatcher close on the resolver. A one-line comment inpackage.jsonexplaining why the flag is load-bearing would help in the meantime.- DNS monkeypatch scope at
tests/canonical-reference-resolver.test.cjs:312-323, 341-351.dns.lookupis the only surface patched. If the SDK ever flips the underlying undici Agent toautoSelectFamilywithresolve4/resolve6, the SSRF subtests start false-greening — the connect succeeds, and the test passes on an unrelated rejection. Inject alookupon the resolver or expand the patch acrossdns.promises.*. - Local
CURRENT_ADCP_VERSIONredeclaration atserver/tests/integration/training-agent-3-0-compat-tools.test.ts:21. Duplicates the source-of-truth atserver/src/training-agent/task-handlers.ts:518. Import instead — next bump touches one site.
Minor nits (non-blocking)
- Fixture-coverage test name oversells what it proves.
tests/canonical-reference-resolver.test.cjs:181— "all format_schema fixtures are covered by this resolver runner" only verifies the fixture directory equals an allow-list. It does not verify atest()actually exercises each fixture. Rename to "are listed in the resolver runner" or add a runtime check that each path appears in somecasesarray. - Cache
hitsbound is tautological. Same file,positive/03_cached_after_404.jsonblock —assert.equal(hits >= 1 && hits <= 2, true, ...). Thesecond.fromCache === trueassertion above already enforces the load-bearing invariant. Tighten toassert.equal(hits, 1)or drop it.
Approving on the strength of the fixture-coverage guard plus the additive version-negotiation change.
02d739c to
b10cbd6
Compare
There was a problem hiding this comment.
LGTM. Right shape — pin the upstream resolver contract in CI so the storyboards can keep relying on canonical format_schema refs. Follow-ups noted.
Things I checked
- 14 fixtures × 14 EXPECTED_FIXTURES — discovery test at
tests/canonical-reference-resolver.test.cjs:184asserts directory parity, so new fixtures fail loud. - Server teardown in
withRoutes(tests/canonical-reference-resolver.test.cjs:94-104) and dns.lookup restoration infinally(lines 320 / 348) are exception-safe. 3.1-beta.7added everywhere3.1-beta.5was advertised:task-handlers.ts:518,tenants/router.ts:50, plus the four assertion sites inserver/tests/unit/training-agent.test.tsand the unsupported-versiondetails.supported_versionsarrays.3.1-beta.5is preserved — additive, not breaking.- Changeset present with empty frontmatter — matches established convention for non-versioning CI/test changes (
.changeset/2303-policy-attribution-pattern.mdand friends). - No
static/schemas/source/**touched — no wire-shape change to audit.
Follow-ups (non-blocking — file as issues)
- SSRF subtests may pass for the wrong reason.
tests/canonical-reference-resolver.test.cjs:307-348monkey-patchesrequire('node:dns/promises').lookup. In modern Nodenode:dns/promisesandnode:dns.promisesare the same object, but the callbackdns.lookupfromnode:dnsis a separate reference. If the SDK ever falls back to the callback form, both subtests will still hitunsafe_urlvia real-DNS NXDOMAIN oninternal-adcp-fixture.net/ off-GCEmetadata.google.internalrather than the private-IP policy. Add a spy that asserts the mock was invoked. --test-force-exitis load-bearing.package.json:38— the resolver may leak undici Agents per call. Worth a follow-up to either expose a teardown on the resolver or drop the flag and see what hangs.- Timeouts 1s/2s are tight for shared GH runners.
tests/canonical-reference-resolver.test.cjs:88-89— outer--test-timeout=30000bounds the worst case, but the catastrophic-regex test (negative/09) and the SSRF connect-then-fail paths are the likely flake candidates. Make env-overridable if you see noise. tenant-smoke.test.ts:241,404softening..toEqual(SALES_CURRENT_SCENARIOS)→expect.arrayContaining(...). The strict 18-count guard inserver/tests/unit/comply-test-controller.test.ts:194still catches enum-level drift, but the smoke test no longer notices aseed_*scenario leaking into the wrong tenant. Tighten with a.not.toContain(...)mirroring lines 405-406 once the canonical set stabilizes.
Minor nits (non-blocking)
assert.equal(bool, true)→assert.ok.tests/canonical-reference-resolver.test.cjs:553. Reads better in node:test idiom.test:canonical-reference-resolverordering innpm test.package.json:68— inserted betweentest:json-schemaandtest:composedrather than grouped with the othertest:canonical-*entries.
One observation: the test file does the work of three reviewers — fixture parity guard, response-metadata preservation, and an explicit cache-shape probe at positive/03. That's the right amount of paranoia for an SDK contract this load-bearing.
Approving on the strength of the fixture-parity guard plus the additive 3.1-beta.7 fan-out.
Summary
static/examples/format-schemascanonicalformat_schemaresolver fixtures.npm testand the build-check workflow.@adcp/sdkto8.1.0-beta.16so CI exercises the upstream resolver fixes, including catastrophic-regex rejection.3.1-beta.7while preserving3.1-beta.5compatibility.Why
The 3.1 storyboards require sellers to emit canonical
format_schemareferences. This adds CI coverage that the upstream SDK resolver still enforces the fetch contract those references depend on: digest mismatch, transport blocking, SSRF blocking, redirect refusal, body limits,$refsandboxing, regex budget rejection, invalid schema handling, and cacheduri@digestfallback.Expert review
Validation
npm run test:canonical-reference-resolver- 19/19 passnpx vitest run server/tests/unit/training-agent.test.ts server/src/training-agent/tenants/tenant-smoke.test.ts --config server/vitest.config.ts- 473/473 passnpm run typecheck- passgit diff --check- passnpm run test:unit,npm run test:test-dynamic-imports,npm run test:callapi-state-change,npm run typecheck- pass