Skip to content

Add canonical format schema resolver CI coverage - #5144

Merged
bokelley merged 1 commit into
mainfrom
issue-4591-format-schema-storyboards
May 29, 2026
Merged

bokelley merged 1 commit into
mainfrom
issue-4591-format-schema-storyboards

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

  • Add a Node test runner for all static/examples/format-schemas canonical format_schema resolver fixtures.
  • Wire the resolver fixture runner into npm test and the build-check workflow.
  • Bump @adcp/sdk to 8.1.0-beta.16 so CI exercises the upstream resolver fixes, including catastrophic-regex rejection.
  • Update the training agent's advertised/supported 3.1 beta wire versions to include the current 3.1-beta.7 while preserving 3.1-beta.5 compatibility.

Why

The 3.1 storyboards require sellers to emit canonical format_schema references. 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, $ref sandboxing, regex budget rejection, invalid schema handling, and cached uri@digest fallback.

Expert review

  • Protocol review: no blocking issues.
  • Node/testing review: no blocking issues.
  • Code review: no blockers; addressed both should-fix items by preserving fixture response metadata in mock routes and adding an explicit fixture coverage guard.

Validation

  • npm run test:canonical-reference-resolver - 19/19 pass
  • npx 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 pass
  • npm run typecheck - pass
  • git diff --check - pass
  • Precommit hook: npm run test:unit, npm run test:test-dynamic-imports, npm run test:callapi-state-change, npm run typecheck - pass
  • Pre-push hook current storyboards - all tenants meet floors
  • Pre-push hook 3.0 compatibility storyboards - all tenants meet floors

@bokelley
bokelley force-pushed the issue-4591-format-schema-storyboards branch 2 times, most recently from 381e182 to 02d739c Compare May 29, 2026 00:47
@bokelley
bokelley marked this pull request as ready for review May 29, 2026 00:53
aao-release-bot[bot]
aao-release-bot Bot previously approved these changes May 29, 2026

@aao-release-bot aao-release-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 to EXPECTED_FIXTURES; a new fixture without a list entry fails the build.
  • server/src/training-agent/task-handlers.ts:518-519 and tenants/router.ts:50 — SUPPORTED_RELEASE_VERSIONS change is additive (3.0, 3.1-beta.5, 3.1-beta.7); existing 3.1-beta.5 pins still resolve. Matches the exact-match pre-release rule at docs/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). No static/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)

  1. Wire-vs-SDK error-code parity. The runner asserts the SDK's internal result.error.code vocabulary — digest_mismatch, non_https_url, redirect_blocked, body_too_large, unsafe_url, ref_sandbox_violation, budget_exceeded, unsupported_schema_draft, http_error. None appear in static/schemas/source/enums/error-code.json (SCREAMING_SNAKE_CASE). The fixtures themselves declare expected_error_code: FORMAT_PROJECTION_FAILED (the wire code) and the runner doesn't read it. Add a wire-surfaced assertion against expected_error_code so an SDK rename can't desync from the catalog silently. See static/examples/format-schemas/negative/01_digest_mismatch.json:33-34 and static/schemas/source/enums/error-code.json:81-83.
  2. Missing fetch-contract fixtures. docs/creative/canonical-formats.mdx:220-221 names 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.
  3. Scenario count silently grew 13→18 at server/tests/unit/comply-test-controller.test.ts:178-195. Five new seed_* 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.16 bump — 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.
  4. Asymmetric drift detection at server/src/training-agent/tenants/tenant-smoke.test.ts:237. Switching toEqual(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.
  5. --test-force-exit in package.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 call server.closeAllConnections() before server.close() or expose a dispatcher close on the resolver. A one-line comment in package.json explaining why the flag is load-bearing would help in the meantime.
  6. DNS monkeypatch scope at tests/canonical-reference-resolver.test.cjs:312-323, 341-351. dns.lookup is the only surface patched. If the SDK ever flips the underlying undici Agent to autoSelectFamily with resolve4/resolve6, the SSRF subtests start false-greening — the connect succeeds, and the test passes on an unrelated rejection. Inject a lookup on the resolver or expand the patch across dns.promises.*.
  7. Local CURRENT_ADCP_VERSION redeclaration at server/tests/integration/training-agent-3-0-compat-tools.test.ts:21. Duplicates the source-of-truth at server/src/training-agent/task-handlers.ts:518. Import instead — next bump touches one site.

Minor nits (non-blocking)

  1. 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 a test() actually exercises each fixture. Rename to "are listed in the resolver runner" or add a runtime check that each path appears in some cases array.
  2. Cache hits bound is tautological. Same file, positive/03_cached_after_404.json block — assert.equal(hits >= 1 && hits <= 2, true, ...). The second.fromCache === true assertion above already enforces the load-bearing invariant. Tighten to assert.equal(hits, 1) or drop it.

Approving on the strength of the fixture-coverage guard plus the additive version-negotiation change.

@bokelley
bokelley force-pushed the issue-4591-format-schema-storyboards branch from 02d739c to b10cbd6 Compare May 29, 2026 07:59

@aao-release-bot aao-release-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:184 asserts directory parity, so new fixtures fail loud.
  • Server teardown in withRoutes (tests/canonical-reference-resolver.test.cjs:94-104) and dns.lookup restoration in finally (lines 320 / 348) are exception-safe.
  • 3.1-beta.7 added everywhere 3.1-beta.5 was advertised: task-handlers.ts:518, tenants/router.ts:50, plus the four assertion sites in server/tests/unit/training-agent.test.ts and the unsupported-version details.supported_versions arrays. 3.1-beta.5 is preserved — additive, not breaking.
  • Changeset present with empty frontmatter — matches established convention for non-versioning CI/test changes (.changeset/2303-policy-attribution-pattern.md and 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-348 monkey-patches require('node:dns/promises').lookup. In modern Node node:dns/promises and node:dns.promises are the same object, but the callback dns.lookup from node:dns is a separate reference. If the SDK ever falls back to the callback form, both subtests will still hit unsafe_url via real-DNS NXDOMAIN on internal-adcp-fixture.net / off-GCE metadata.google.internal rather than the private-IP policy. Add a spy that asserts the mock was invoked.
  • --test-force-exit is 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=30000 bounds 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,404 softening. .toEqual(SALES_CURRENT_SCENARIOS) → expect.arrayContaining(...). The strict 18-count guard in server/tests/unit/comply-test-controller.test.ts:194 still catches enum-level drift, but the smoke test no longer notices a seed_* scenario leaking into the wrong tenant. Tighten with a .not.toContain(...) mirroring lines 405-406 once the canonical set stabilizes.

Minor nits (non-blocking)

  1. assert.equal(bool, true) → assert.ok. tests/canonical-reference-resolver.test.cjs:553. Reads better in node:test idiom.
  2. test:canonical-reference-resolver ordering in npm test. package.json:68 — inserted between test:json-schema and test:composed rather than grouped with the other test: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.

@bokelley
bokelley merged commit 5f8d259 into main May 29, 2026
28 checks passed
@bokelley
bokelley deleted the issue-4591-format-schema-storyboards branch May 29, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant