Repository navigation
fix(generator): typeless JSON Schema → unknown; iterate dedup - #621
Merged
Merged
Conversation
…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]>
…cache Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
check_governanceconditions[].required_value) toRecord<string, unknown>/z.record(...), rejecting scalar responses from compliant agents.unknown/z.unknown(). Recursion reachespatternProperties, schema-valuedadditionalProperties, and the 2020-12 applicator keywords that were silently missed.CatalogFieldMapping2→ExtensionObject32), cutting ~7000 lines fromcore.generated.ts.fixed_priceset (waspricing_options[0], which broke when the training agent ordered an auction option first). Removed the staleshould track campaign breakdowntest —plan.campaignsisn't inget-plan-audit-logs-response.json.Root cause
schemas/cache/latest/governance/check-governance-response.json:88-90declaresrequired_valuewith 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-typescriptdefaults typeless nodes to{ [k: string]: unknown }, which downstream Zod narrowed.enforceStrictSchemanow annotates withtsType: '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 literaladditionalPropertiesfield on the extension-meta meta-schema.Test plan
npm run generate-types— clean, 7k fewer linesnpm run build:lib— no TS errorsnpm run test:lib— 3384 pass, 2 skip, 0 fail🤖 Generated with Claude Code