Skip to content

feat(generator): preserve the vended SDK layout and gate generation drift - #14

Merged
nmorgan-cb merged 4 commits into
feat/generator-2-emissionfrom
feat/generator-3-vended-layout
Nov 24, 2026
Merged

nmorgan-cb merged 4 commits into
feat/generator-2-emissionfrom
feat/generator-3-vended-layout

Conversation

@nmorgan-cb

@nmorgan-cb nmorgan-cb commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

Stack: #12 → #13 → #14 → #15 (merge in order; each PR is based on the previous branch).

Part 3 of 4 (based on part 2). Makes regenerating from the unchanged spec leave the vended SDK as it is.

  • Templates reproduce the vended conventions: file header, @JsonProperty use, build() throws, empty-request shape, boxed Boolean.
  • SourceLayout keeps the field order, docs and method order of existing classes. Linear scans, no backtracking regexes.
  • List<T> response overrides and opt-in error enums (generateErrorEnums, off by default like the vended SDK).
  • Success status codes pinned per operation (201, 200 for the staking calls that use it), in configured order. operation-inventory.json now locks them for all 111 operations.
  • make check-surface and expected-generation-changes.txt: generation from the committed spec may change only the listed files. CI runs it in the generated-sdk job.

Tests: 49 generator tests, 287 SDK tests; make check-surface passes.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Dependency update
  • Refactor / cleanup
  • Other (describe below)

Checklist

  • Tests included / updated
  • Changelog updated
  • Version bump if needed

Regenerating from the unchanged committed spec used to rewrite 261 existing
SDK files. Make the templates reproduce the vended conventions so only real
spec updates and the intended alias renames produce a diff:

- License header, @JsonProperty form, required only on path parameters,
  build() throws CoinbaseClientException, validate() visibility (protected
  only for classes with deprecated aliases), and the parameterless request
  shape now match the vended sources.
- Builders expose limit() and pagination(); cursor()/sortDirection() only
  where the vended class already has them.
- SourceLayout reads an existing class and keeps its field order, field and
  class documentation, and service method order/Javadoc. New members append
  in spec order with spec documentation. A canonical class that renames a
  vended one inherits the legacy class's layout.
- responseTypeOverrides keep the vended List<T> (not T[]) for the cross
  margin risk parameters and market data responses; configured types may now
  be generic.
- ErrorCode/Subcode enums are opt-in (generateErrorEnums, default false),
  matching the vended SDK and the previous behavior of main.
- --check --expect-changes=<file> fails on any change not in an allowlist.
…early

Comparing regenerated services method by method with the vended ones found
seven operations whose accepted success codes changed: createStake,
createUnstake, portfolioStakingInitiate, portfolioStakingUnstake and
claimRewards expect 201 then 200, while createWalletTransfer and
createWalletWithdrawal expect only 200. The Create/Claim heuristic did not
match them.

- Pin the vended codes with statusCodes overrides, and keep the configured
  order instead of sorting it (201 must stay before 200).
- operation-inventory.json now also locks the accepted status codes of all
  111 operations, taken from the vended implementations.
- SourceLayout reads classes, fields and service methods with linear scans
  instead of backtracking regular expressions (CodeQL flagged the class
  Javadoc pattern as potentially exponential).
Adds tools/model-generator/config/expected-generation-changes.txt, the exact
set of vended files that generating from the committed spec may add or
change: the 11 canonical/alias renames, the real spec updates to
CreateQuote and EditOrder, the /v2 base URL change, and the hand-maintained
portfolio files. `make check-surface` fails on any other change and on any
entry that stops applying, and runs in the generated-sdk CI job. The list
shrinks to empty once a generated baseline is committed.
…ript SDKs (#15)

Where at least two of the Go, Python and TypeScript SDKs agree on a name
that differs from Java, the Java canonical name now follows them. The
previous Java names stay as @deprecated subclasses and forwarding
methods, so existing callers keep compiling.

Renamed (canonical <- deprecated alias):
- getProductCandles <- getCandles
- getOrderEditHistory <- listOrderEditHistory
- getCounterpartyId <- getPortfolioCounterpartyId
- listProducts <- listPortfolioProducts
- getEntityPositions <- getPositions
- queryTransactionValidators <- listTransactionValidators
- createOrderPreview <- getOrderPreview
- setFundingSettings <- updateFundingSettings
- createPortfolioAllocations <- createAllocation
- createPortfolioNetAllocations <- createNetAllocation
- listOrders <- listPortfolioOrders
- listPortfolioInterestAccruals <- listInterestAccrualsForPortfolio
- getPortfolioCredit <- getPortfolioCreditInformation
- getTieredPricingFees <- getTradeFinanceTieredPricingFees

getActivity/getPortfolioActivity are left as is: following Go and
Python would reuse getActivity for a different operation.
@nmorgan-cb
nmorgan-cb merged commit fb80650 into feat/generator-2-emission Nov 24, 2026
8 checks passed
@nmorgan-cb
nmorgan-cb deleted the feat/generator-3-vended-layout branch November 24, 2026 19:20
nmorgan-cb added a commit that referenced this pull request Nov 24, 2026
…d aliases (#13)

* feat(generator): generate requests, responses, services, and factory

Emit the client surface from operation bindings: request DTOs with
builders, validation, and PrimeListRequest pagination; response DTOs;
service interfaces and implementations with /v1 and /v2 routing; and
PrimeServiceFactory. Main renders and validates the whole surface before
writing any file, and adds isolated --check and --live-diff modes that
never mutate the checkout (make check-generated, make generate-live-diff).

CoinbasePrimeClient exposes its base URL and keeps an injected HttpClient
in withBaseUrl, which generated /v2 calls use.

* feat(generator): generate deprecated Java aliases for canonical names

Converge Java method and type names on the canonical names shared with
the .NET, TypeScript, Python, and Go Prime SDKs. Each rename is declared
in operations-overrides.json with deprecatedAliases; the generator emits a
@deprecated request subclass with a covariant Builder, a @deprecated
response subclass, and @deprecated forwarding service methods, so existing
callers keep compiling.

naming-parity.json and NamingParityTest lock the cross-SDK mapping, and
the operation inventory records the 11 renames with their aliases.

* ci: gate generator tests and generated SDK compilation

Run the model-generator test suite in CI, and add a generated-sdk job
that regenerates from the committed spec in the disposable checkout,
compiles, and runs the SDK tests. make check-generated replaces this
job once a generated baseline is committed.

* feat(generator): preserve the vended SDK layout and gate generation drift (#14)

* feat(generator): match vended conventions and preserve existing layout

Regenerating from the unchanged committed spec used to rewrite 261 existing
SDK files. Make the templates reproduce the vended conventions so only real
spec updates and the intended alias renames produce a diff:

- License header, @JsonProperty form, required only on path parameters,
  build() throws CoinbaseClientException, validate() visibility (protected
  only for classes with deprecated aliases), and the parameterless request
  shape now match the vended sources.
- Builders expose limit() and pagination(); cursor()/sortDirection() only
  where the vended class already has them.
- SourceLayout reads an existing class and keeps its field order, field and
  class documentation, and service method order/Javadoc. New members append
  in spec order with spec documentation. A canonical class that renames a
  vended one inherits the legacy class's layout.
- responseTypeOverrides keep the vended List<T> (not T[]) for the cross
  margin risk parameters and market data responses; configured types may now
  be generic.
- ErrorCode/Subcode enums are opt-in (generateErrorEnums, default false),
  matching the vended SDK and the previous behavior of main.
- --check --expect-changes=<file> fails on any change not in an allowlist.

* fix(generator): keep vended success status codes and scan layouts linearly

Comparing regenerated services method by method with the vended ones found
seven operations whose accepted success codes changed: createStake,
createUnstake, portfolioStakingInitiate, portfolioStakingUnstake and
claimRewards expect 201 then 200, while createWalletTransfer and
createWalletWithdrawal expect only 200. The Create/Claim heuristic did not
match them.

- Pin the vended codes with statusCodes overrides, and keep the configured
  order instead of sorting it (201 must stay before 200).
- operation-inventory.json now also locks the accepted status codes of all
  111 operations, taken from the vended implementations.
- SourceLayout reads classes, fields and service methods with linear scans
  instead of backtracking regular expressions (CodeQL flagged the class
  Javadoc pattern as potentially exponential).

* ci: gate generation drift with an expected-changes allowlist

Adds tools/model-generator/config/expected-generation-changes.txt, the exact
set of vended files that generating from the committed spec may add or
change: the 11 canonical/alias renames, the real spec updates to
CreateQuote and EditOrder, the /v2 base URL change, and the hand-maintained
portfolio files. `make check-surface` fails on any other change and on any
entry that stops applying, and runs in the generated-sdk CI job. The list
shrinks to empty once a generated baseline is committed.

* feat(generator): align 14 method names with the Go, Python and TypeScript SDKs (#15)

Where at least two of the Go, Python and TypeScript SDKs agree on a name
that differs from Java, the Java canonical name now follows them. The
previous Java names stay as @deprecated subclasses and forwarding
methods, so existing callers keep compiling.

Renamed (canonical <- deprecated alias):
- getProductCandles <- getCandles
- getOrderEditHistory <- listOrderEditHistory
- getCounterpartyId <- getPortfolioCounterpartyId
- listProducts <- listPortfolioProducts
- getEntityPositions <- getPositions
- queryTransactionValidators <- listTransactionValidators
- createOrderPreview <- getOrderPreview
- setFundingSettings <- updateFundingSettings
- createPortfolioAllocations <- createAllocation
- createPortfolioNetAllocations <- createNetAllocation
- listOrders <- listPortfolioOrders
- listPortfolioInterestAccruals <- listInterestAccrualsForPortfolio
- getPortfolioCredit <- getPortfolioCreditInformation
- getTieredPricingFees <- getTradeFinanceTieredPricingFees

getActivity/getPortfolioActivity are left as is: following Go and
Python would reuse getActivity for a different operation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants