Repository navigation
feat(aws): a curated enum overlay, so the highest-traffic properties stop being bare strings (#1497) - #2209
Merged
Conversation
…stop being bare strings (#1497) The CloudFormation Registry spec declares AllowedValues on some properties and not on others, and the split does not follow how often a property is written: AWS::SageMaker::NotebookInstance.InstanceType was a union while AWS::EC2::Instance.InstanceType was a bare string. Where the spec is silent the generated type stops teaching the API, and a wrong value survives tsc and chant build to fail at deploy, the most expensive tier there is. src/codegen/enum-overlay.json is a checked-in list of (CFN type, JSON pointer, values) entries merged into the raw schema before parsing, so a curated enum reaches the .d.ts and the lexicon registry by exactly the path a spec enum reaches them. It mints a named definition and points the property at it, so the union is also an exported type a composite can name. Nothing is fetched at build time. The overlay runs in parseSchema rather than augmentSchemas because augmentSchemas is skipped for a caller-supplied schema set, and the overlay fetches nothing, so a fixture run and a real run stay on one code path. The first set is chosen by counting property occurrences across examples/, docs/src/content/docs, lexicons/aws/examples, src/skills, src/lint and src/composites: Lambda Runtime (32), ELBv2 TargetGroup Protocol (28), ApplicationAutoScaling ServiceNamespace (13) and ScalableDimension (12), EC2 InstanceType (12), DynamoDB KeyType (9) and its four siblings, RDS Engine (7), ELBv2 TargetType and Scheme (3 each), SNS Subscription Protocol, plus EC2 Tenancy and VolumeType, which #1497 names and which the spec already types as unions on other resources. Precedence: the overlay only fills gaps. An entry whose property already declares enum leaves the spec alone and warns that it is redundant, because upstream is refreshed on every generate and a hand list allowed to win would rot invisibly. An entry that matches nothing fails the generate. Narrowing is breaking for anyone passing a value the union omits, so this ships in the next lockstep release rather than carrying its own bump. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FoXyD9UvKQ5ZdhiR9JT1yB
…nst botocore (#1497) Each overlay entry records the botocore service model or AWS documentation page its values came from and the date they were read. This script reads that back: it fetches the named service-2.json from botocore's develop branch, diffs the enum shape against the checked-in values, and with --write applies the difference and restamps the reviewed date. Entries sourced from a documentation page are printed with their URL, since no machine-readable form of those lists exists. It reaches the network, so it is deliberately not a package script and nothing in generate, bundle, validate or build calls it. `just refresh-enum-overlay` is the only wiring. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FoXyD9UvKQ5ZdhiR9JT1yB
… overlay does (#1497) The CloudFormation Concepts page said only "browse the generated TypeScript types". It now says where a union comes from when the Registry schema has one, the two things that add unions the Registry lacks (the cfn-lint patch set and the curated overlay), the two rules the overlay follows, and that narrowing a property is breaking and ships with a release of the lexicon. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FoXyD9UvKQ5ZdhiR9JT1yB
`test/no-egress.test.ts` closes the set of modules that call a network primitive from both sides, so adding a `fetch` without a row fails CI. The overlay refresh script fetches botocore service models and had no row, which is the check working as designed. Filed under codegen rather than maintenance: it sits with `lexicons/cpln/src/spec/snapshot-cli.ts` and `lexicons/azure/scripts/fetch-quickstart-templates.ts`, maintainer commands that refresh a committed input to generation on a networked machine, so that everything downstream reads the committed file. The maintenance phase is this repository's own CI freshness checks against `api.github.com`, and this runs in neither. The generated docs twin is `npm run generate:egress-catalogue` output: one table row and the module count moving 31 to 32. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FoXyD9UvKQ5ZdhiR9JT1yB
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.
Closes #1497. Follow-up for the
anyhalf: #2205.The problem
The generator emits literal unions only where the CFN spec declares AllowedValues, so
InstanceTypeon EC2 is a bare string while the same property is a union on another resource in the same file, and a wrong enum fails at deploy rather than at tsc.What this lands
A curated enum overlay, checked in at
lexicons/aws/src/codegen/enum-overlay.jsonand merged over the spec at codegen time, sonpm run generateneeds no network. Eighteen entries, chosen by counting property usage across the examples, docs, skills, lint rules and composites and intersecting with what is bare today. The top of the list by traffic: LambdaRuntime, ELBv2Protocol, AppAutoScalingServiceNamespaceandScalableDimension, EC2InstanceType, the five DynamoDB enums, RDSEngine, ELBv2SchemeandTargetType, SNSProtocol. Three entries the issue names by hand have no corpus use but are included because the spec already types the identical property as a union elsewhere.Each entry records its source and date: botocore service, apiVersion and shape, or a docs URL. A manual refresh script under
lexicons/aws/scripts, wired asjust refresh-enum-overlay, diffs the overlay against botocore's public JSON. It is not in package.json scripts, so no build step can reach it.Precedence: the overlay only fills gaps and the spec wins. An entry whose property already declares an enum leaves the schema untouched and emits a warning naming it for retirement. An entry matching nothing is a hard error. Twenty codegen tests, including one asserting every literal the corpus writes is a member of its union.
Deliberately excluded, with reasons in the module doc:
IpProtocol, which accepts any IANA protocol number;DBInstanceClassandEngineVersion, which are open fast-moving sets; andType, which is polysemous across hundreds of declarations.Version
Narrowing is breaking. The branch originally bumped the aws lexicon to 0.58.0, but chant-v0.58.0 was cut in lockstep before this merged, so that bump was dropped and the narrowing ships in the next lockstep release. The surface snapshot records names and required flags, not types, so
surface-diffwill not flag it; the release notes need a line.For the reviewer
lexicons/aws/src/generated/is gitignored, so the narrowed types are not in the diff. Runnpm run generateinlexicons/awsand look atsrc/generated/index.d.ts; expect 18 overlay entries applied and 1626 enums, up from 1608.Two adjacent findings, written up in the follow-up issue: cfn-lint's
boto.jsonpatch is fetched and never applied, and the narrowed declarations ship only behind the./typesexport that nothing imports.Gates
Run by the orchestrator on the rebased head after the agent's own run.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FoXyD9UvKQ5ZdhiR9JT1yB