Skip to content

[Endpoints BDD 2/5] Codegen baseline BDD Resolver - #7303

Draft
alextwoods wants to merge 1 commit into
feature/master/endpoints-bddfrom
alexwoo/endpoints-bdd-pr2
Draft

[Endpoints BDD 2/5] Codegen baseline BDD Resolver#7303
alextwoods wants to merge 1 commit into
feature/master/endpoints-bddfrom
alexwoo/endpoints-bdd-pr2

Conversation

@alextwoods

@alextwoods alextwoods commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

[Endpoints BDD 2/5] Codegen baseline BDD Resolver

This PR is 2/5 for the Endpoints BDD. This is part of a Github PR Stack - to see all of the PRs in the stack, see the "2/5" at the top of the PR.

Note: This PR merges to the feature/master/endpoints-bdd feature branch and NOT to master.

Modifications

Adds code generation visitors that transform a BDD (Binary Decision Diagram) endpoint model into a Java endpoint provider. When an endpoint-bdd-1.json is present in a service's codegen-resources, the codegen emits a BDD-based resolver instead of the tree-based rules resolver. Each BDD node becomes a method that evaluates its condition and branches to child nodes or results, returning Endpoint directly. The generated resolver is validated end-to-end against 32 Connect endpoint test cases in codegen-generated-classes-test.

Changes by area:

  • bdd/BddEndpointProviderSpec — Main spec: builds the evaluator inner class with per-call allocation, emits nodeP<i> methods for each BDD node, cond<i> for complex conditions, and result<i> for endpoint/error leaves. Gates on BDD model presence (no customization flag required).
  • bdd/BddResultCodeGeneratorVisitor — Walks the result RuleModel expressions to emit endpoint construction (URL, headers, auth scheme attributes) or error throws.
  • bdd/ConditionFnCodeGeneratorVisitor — Emits condition evaluation code: function calls (awsPartition, substring, isValidHostLabel, etc.), getAttr member access, and assigns to evaluator registers.
  • bdd/AssignTypeInferringVisitor — Infers types for BDD register variables from condition/result expressions so the evaluator fields can be declared with concrete types.
  • bdd/RegistryInfo — Metadata per BDD register: Java field name, type, source expression, nullability, and whether it maps to an endpoint parameter.
  • EndpointProviderTasks — Wiring: selects BddEndpointProviderSpec when BDD model is present, compiled rules otherwise.
  • ClientTestModels + test fixtures — Adds queryServiceModelsWithBddEndpoints (S3 BDD) and queryServiceModelsWithSimpleBddEndpoints (simple regional service-like BDD) with corresponding JSON fixtures.
  • BddEndpointProviderSpecTest — Golden-file fixture test against the small BDD, plus assertion tests for dynamic auth scheme codegen and the fail-fast on missing S3Express customization.
  • test/codegen-generated-classes-test/bddendpoints — New test service with Connect's BDD + endpoint tests; auto-generated provider test validates all 32 endpoint test cases pass at runtime.

Testing

  • Codegen unit tests that use golden cases

  • TokenizerTest — 9 cases covering template expression tokenization including hyphen and negative-index edge cases

  • BddEndpointsEndpointProviderTests (codegen-generated-classes-test, auto-generated)

    • Runs all 32 Connect endpoint test cases against the BDD-generated resolver at runtime (regions, FIPS, DualStack, custom endpoint, error cases)

Screenshots (if appropriate)

License

  • I confirm that this pull request can be released under the Apache 2 license

@alextwoods
alextwoods force-pushed the alexwoo/endpoints-bdd-pr2 branch from ad75759 to cd84f83 Compare August 21, 2026 19:46
@alextwoods
alextwoods force-pushed the alexwoo/endpoints-bdd-pr2 branch from cd84f83 to ecfe0b1 Compare August 21, 2026 19:53
Base automatically changed from alexwoo/endpoints-bdd-pr1 to feature/master/endpoints-bdd August 21, 2026 20:28
@alextwoods
alextwoods force-pushed the alexwoo/endpoints-bdd-pr2 branch 3 times, most recently from d82c3d1 to faff5ae Compare August 21, 2026 21:36
Implement the BDD endpoint resolver code generation visitors that
transform a Binary Decision Diagram into a Java endpoint provider.

Code generation visitors:
- BddEndpointProviderSpec: main spec emitting the provider class with
  nodeP/nodeN method dispatch — each BDD node becomes a method
  returning Endpoint directly (null = no match, throw = error)
- BddResultCodeGeneratorVisitor: traverses the BDD node graph and
  emits node methods with condition checks and edge traversal
- ConditionFnCodeGeneratorVisitor: emits condition evaluations
  (isSet, booleanEquals, stringEquals, function calls, getAttr)
- ResultFnCodeGeneratorVisitor: emits endpoint construction and error
  results from BDD result nodes
- AssignTypeInferringVisitor: infers types for BDD register variables
  from the condition/result expressions
- RegistryInfo: metadata for BDD registers (name, type, index)

Wiring:
- EndpointProviderTasks: when EndpointBddModel is present, generate
  BddEndpointProvider instead of rules-based provider

The generated resolver uses direct method dispatch per BDD node,
with simple conditions inlined as ternary expressions for
branch-predictor-friendly code paths.
@alextwoods
alextwoods force-pushed the alexwoo/endpoints-bdd-pr2 branch from faff5ae to 0c21e3b Compare August 21, 2026 22:37
@alextwoods alextwoods changed the title perf(codegen): Optimize rules-based codegen to eliminate RuleResult [Endpoints BDD 2/5] Codegen baseline BDD Resolver Aug 21, 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.

1 participant