Skip to content

aws: close the three resolver gaps behind 555 of the generated anys (#2205) - #2281

Merged
lex00 merged 2 commits into
mainfrom
fix/2205-aws-any-resolver-gaps
Sep 8, 2026
Merged

lex00 merged 2 commits into
mainfrom
fix/2205-aws-any-resolver-gaps

Conversation

@lex00

@lex00 lex00 commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2205.

Three gaps in packages/core/src/codegen/json-schema.ts, measured before and after against the pinned CloudFormation Registry archive (1,653 schemas, 44,260 spec properties).

resolveRef had no array case

A $ref to a definition whose type is array fell through to return "any". AWS::Panorama::ApplicationInstance writes Tags as a $ref to TagList, whose items are the Tag definition one hop away, and shipped as Tags?: any. Resolving through def.items the way the inline array case already did fixes 502 properties, plus 7 that reached one through items and got any[].

ApplicationInstance.Tags?: ApplicationInstance_Tag[], and ApplicationInstance_Tag is a real declared class with Key and Value.

oneOf/anyOf discarded everything beside it

resolvePropertyType checked the keyword first and returned any without reading prop.type. 44 of the 52 direct cases also declare a real type, and the branch list relaxes that type rather than summing shapes:

"EngineType": {
  "type": "string",
  "anyOf": [
    { "enum": ["ACTIVEMQ", "RABBITMQ"], "type": "string" },
    { "pattern": "^[Aa][Cc][Tt][Ii][Vv][Ee][Mm][Qq]$" },
    { "pattern": "^[Rr][Aa][Bb][Bb][Ii][Tt][Mm][Qq]$" }
  ]
}

Reading the sibling keywords types all 44; taking a string enum branch as the narrower answer makes 5 of them a union, all five on one resource. AWS::AmazonMQ::Broker.EngineType is "ACTIVEMQ" | "RABBITMQ", and DeploymentMode, StorageType, DataReplicationMode and MaintenanceWindow.DayOfWeek come with it. The other 39 become string, number or boolean.

A branch list with nothing beside it is a real sum type and still resolves to any. Those are #2278.

allOf was not handled

All nine occurrences are one $ref beside an annotation, which types as the $ref alone:

"ProtocolType": { "allOf": [ { "$ref": "#/definitions/GatewayProtocolType" }, { "default": "MCP" } ] }

AWS::BedrockAgentCore::Gateway.ProtocolType is BedrockAgentCoreGateway_GatewayProtocolType, which is = "MCP". An allOf that intersects two real shapes has no single answer and stays any.

Two things found while measuring

[] binds tighter than |, so the emitter's ${itemType}[] produced Architectures?: "arm64" | "x86_64"[] — a type that accepts the bare string "arm64" and rejects ["arm64"]. 62 declarations were already wrong that way before this branch and the array fix would have added 7 more, so item unions are now parenthesized. That is the only category of change in this PR where a property's old type was not any.

A list definition whose items reach the definition again would recurse without end, so the resolution path now carries the definition names it has already visited.

Counts

lexicons/aws/src/generated/index.d.ts, from npm run --prefix lexicons/aws generate on each side, counted with grep -c ': any;' and grep -c ': any\[\];':

before after
: any; 800 226
: any[]; 25 20
total 825 246
of those, constructor properties 787 216
readonly attributes + intrinsic return types (out of scope) 38 38

Replaying the resolver over the raw schemas, the same 1,653 the generator reads, with the same patches and enum overlay applied:

cause before after
$ref to an array definition 502 0
$ref to a definition that is only a oneOf/anyOf 161 161
direct oneOf/anyOf beside a real type 44 0
no type declared 20 20
allOf 9 0
$ref to an empty definition 8 8
direct oneOf/anyOf with nothing beside it 8 8
$ref to a definition the schema does not declare 1 1
$ref to a definition that is itself a bare $ref 1 1
total resolving to exactly any 754 199

Diffing every one of the 44,260 resolved types, 562 changed and every one of them went from any or any[] to something narrower. Nothing that had a type acquired a worse one.

azure is the only other lexicon that calls resolvePropertyType. Its count is 226 : any; and 500 : any[]; before and after, and chant dev surface-diff lexicons/azure reports no surface changes — ARM schemas do not write these three shapes. Every other lexicon imports only extractConstraints, primaryType and isEnumDefinition, none of which changed.

What remains

199 properties, all listed in the table above. The 161 definition-level oneOf/anyOf cases are genuine sum types across 61 resource types, and want a real TypeScript union, which is a change to the emitter rather than the resolver. Filed as #2278, with the residue and #2205's coverage-metric acceptance item carried over.

The surface snapshot

boundPropertyTypes seeds reachability from the resolved type strings, so a definition that was only ever reached through an any is now reachable and gets emitted. The surface gains 408 property-type entries and loses 7: DimensionMapping, DocumentAttributeTarget, FilesystemConfiguration, Lambda, LambdaAuthorizerConfig, OpenIDConnectConfig and SourceAlgorithm each held a bare name because exactly one resource emitted them; a second resource now does, and the naming strategy prefixes both. Nothing outside src/generated referenced them, and npx tsc --noEmit over the repo is clean.

chant dev surface-diff lexicons/aws reports severity breaking against the committed baseline. On main the same command reports severity none, so the whole delta is this branch. The release-time gate (#1473) would refuse to publish past it, so the snapshot re-baselines here, the way #1506 and #605 did. No --bump: packages ship in lockstep.

Gates

Run from the worktree root.

  • npm run --prefix lexicons/aws generate — 1662 resources, 6194 property types (was 5946), 1626 enums
  • npx tsc --noEmit — exit 0
  • npx tsc --noEmit -p lexicons/aws/tsconfig.build.json — exit 0
  • npx vitest run lexicons/aws packages/core/src/codegen — 170 files, 2246 passed, 2 skipped
  • npx vitest run packages lexicons examples — 1203 files, 16839 passed, 39 skipped, exit 0
  • npx tsx scripts/typecheck.ts — Repo-wide typecheck: 31 known failure(s), no regressions. (31 baselined)
  • npx tsx scripts/check-lexicons.ts — every lexicon 23/23 tier-1, No untracked tier-1 failures.
  • npx tsx packages/core/src/cli/main.ts dev check-lexicon lexicons/aws — Tier 1 — required (23/23), Tier 2 — recommended (16/17) (the one WARN is At least 3 initTemplates, 2 templates, pre-existing), Tier 3 — thoroughness (8/9), All tier-1 checks passed. No surface-snapshot check runs in check-lexicon; it is release-gated, and dev surface-diff lexicons/aws is the run quoted above.
  • npx eslint packages/ — 0 errors, 2 pre-existing warnings in packages/core/src/meta/publish-metadata.test.ts
  • node scripts/depcheck.mjs — ✓ no undeclared runtime dependencies

🤖 Generated with Claude Code

https://claude.ai/code/session_0148a4dPTErCBpmNy7J7933f

lex00 and others added 2 commits September 8, 2026 16:54
…gs (#2205)

Three gaps in `resolvePropertyType`/`resolveRef` account for 555 of the 754
CloudFormation Registry properties that resolved to `any`.

`resolveRef` had no `array` case, so a `$ref` to a definition whose `type` is
`array` fell through to `any`. CloudFormation names its list shapes constantly:
`AWS::Panorama::ApplicationInstance` writes `Tags` as a `$ref` to `TagList`,
whose items are the `Tag` definition one hop away. Resolve through `def.items`
the way the inline `array` case already does. 502 properties.

`resolvePropertyType` returned `any` on seeing `oneOf`/`anyOf` without reading
what sat beside it. 44 of those properties also declare a real `type`, and the
branch list relaxes that type rather than summing shapes: `AWS::AmazonMQ::Broker`
writes `EngineType` as `type: "string"` beside an enum branch and two
case-insensitive patterns for the same two values. Read the sibling keywords,
and take a string enum branch as the narrower answer. A branch list with nothing
beside it is a real sum type and still resolves to `any` (#2278).

`allOf` was not handled at all. All nine occurrences are one `$ref` beside an
annotation (`{ "default": "MCP" }`), which types as the `$ref` alone.

Two things found while measuring. `[]` binds tighter than `|`, so the emitter's
`${itemType}[]` produced `"arm64" | "x86_64"[]` — a type that accepts the bare
string `"arm64"` and rejects `["arm64"]`. 62 declarations were already wrong that
way and the array fix would have added more, so item unions are now
parenthesized. And a list definition whose items reach the definition again would
recurse without end, so the resolution path carries the definition names it has
already visited.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0148a4dPTErCBpmNy7J7933f
…any`s (#2205)

The resolver fix narrows 787 constructor properties to 216 and, because
`boundPropertyTypes` seeds reachability from the resolved type strings, brings
248 more property-type interfaces into the emitted set. The surface gains 408
entries and loses 7: `DimensionMapping`, `DocumentAttributeTarget`,
`FilesystemConfiguration`, `Lambda`, `LambdaAuthorizerConfig`,
`OpenIDConnectConfig` and `SourceAlgorithm` each had a bare name because only one
resource emitted them, and a second resource now does, so the naming strategy
prefixes both. Nothing outside `src/generated` referenced them.

`chant dev surface-diff lexicons/aws` reported severity breaking against the
committed baseline, which the release-time gate (#1473) would refuse to publish
past, so the snapshot re-baselines here. No `--bump`: packages ship in lockstep,
as in #1506.

The budget test asserts the count that is left, so the next drop is a deliberate
edit rather than a silent one, and checks the three properties #2205 named.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0148a4dPTErCBpmNy7J7933f
@lex00
lex00 merged commit b088133 into main Sep 8, 2026
6 checks passed
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.

aws: three gaps in one resolver account for 757 of the 787 generated anys

1 participant