Skip to content

fix(generator): typeless JSON Schema → unknown; iterate dedup - #621

Merged
bokelley merged 2 commits into
mainfrom
bokelley/check-main-tests
Apr 19, 2026
Merged

bokelley merged 2 commits into
mainfrom
bokelley/check-main-tests

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

  • Fixes Governance E2E test suite: 20 failures + 8 cancellations on main #613's remaining failures. The generator narrowed JSON Schema properties that legitimately accept any JSON value (e.g. check_governance conditions[].required_value) to Record<string, unknown> / z.record(...), rejecting scalar responses from compliant agents.
  • Metadata-only schema nodes now compile to unknown / z.unknown(). Recursion reaches patternProperties, schema-valued additionalProperties, and the 2020-12 applicator keywords that were silently missed.
  • Multi-pass dedup collapses nested numbered duplicates (CatalogFieldMapping2 → ExtensionObject32), cutting ~7000 lines from core.generated.ts.
  • Fixture: governance E2E approve test now picks a pricing option with fixed_price set (was pricing_options[0], which broke when the training agent ordered an auction option first). Removed the stale should track campaign breakdown test — plan.campaigns isn't in get-plan-audit-logs-response.json.

Root cause

schemas/cache/latest/governance/check-governance-response.json:88-90 declares required_value with only a description. Per JSON Schema draft-07 / 2020-12, annotation-only schemas validate every instance — training agent returning a number for an auto-applied budget cap is spec-correct. json-schema-to-typescript defaults typeless nodes to { [k: string]: unknown }, which downstream Zod narrowed. enforceStrictSchema now annotates with tsType: 'unknown' before compilation.

Protocol expert confirmed the spec interpretation. The heuristic fires only when a node has zero assertive keywords, so it's self-deactivating if a future AdCP version tightens any of these fields.

Other sites corrected: CatalogFieldMapping.value / .default, Response.data, and the literal additionalProperties field on the extension-meta meta-schema.

Test plan

  • npm run generate-types — clean, 7k fewer lines
  • npm run build:lib — no TS errors
  • npm run test:lib — 3384 pass, 2 skip, 0 fail
  • Reviewed by code-reviewer + ad-tech-protocol-expert
  • Verify CI (schema check, changeset check, protocol tests)

🤖 Generated with Claude Code

bokelley and others added 2 commits April 19, 2026 11:48
…dedup

JSON Schema properties declared with only a description (no type, $ref,
combinator, enum, or structural keyword) accept any JSON value per spec.
json-schema-to-typescript defaults these to { [k: string]: unknown },
which Zod generation narrowed to z.record(z.string(), z.unknown()) —
rejecting scalar values the spec allows (e.g. check_governance
conditions[].required_value returning a number).

enforceStrictSchema now annotates metadata-only schema nodes with
tsType: 'unknown' before compilation. Recursion extended to reach
patternProperties, schema-valued additionalProperties, not/if/then/else,
contains, propertyNames, unevaluatedItems/Properties, and dependencies.

Side fix: removeNumberedTypeDuplicates iterates passes so chained
numbered references (e.g. CatalogFieldMapping2 → ExtensionObject32)
collapse once the inner reference resolves. Drops ~7000 duplicate-type
lines from core.generated.ts.

Also fixes one governance E2E test picking pricing_options[0] without
filtering for fixed_price (training agent returns an auction option
first for 'display advertising'; auction options require bid_price).
Removes 'should track campaign breakdown' — plan.campaigns isn't in
get-plan-audit-logs-response.json, stale since the test was introduced.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@bokelley
bokelley merged commit 5d81fe9 into main Apr 19, 2026
14 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 19, 2026
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.

Governance E2E test suite: 20 failures + 8 cancellations on main

1 participant