Skip to content

feat(scripts): extract a baseline API surface for every extractable language - #244

Merged
gjtorikian merged 2 commits into
mainfrom
gjtorikian/sdk-generate-baseline-surface
Oct 28, 2026
Merged

gjtorikian merged 2 commits into
mainfrom
gjtorikian/sdk-generate-baseline-surface

Conversation

@gjtorikian

@gjtorikian gjtorikian commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Why

sdk-generate.sh extracted a baseline API surface for Node only, so every other emitter generated blind: nothing stopped a parameter from shifting position or a method from changing name between releases. PHP paid for that with the Pipes bodies. The compatibility code in workos/oagen-emitters#284 only acts when ctx.apiSurface is present, and this pipeline never supplied one.

What changes

  • Extraction runs for any language oagen extract supports (node, php, python, ruby, go, rust, kotlin, dotnet) whenever --output is a live checkout. A scratch directory still gets no surface. The Node-only manifest recovery step stays Node-only.
  • --baseline-ref <git-ref> (default HEAD) chooses the commit to extract. A tag missing from a shallow checkout is fetched on demand. An explicit ref that cannot be honored, because the output is not a git checkout, the language has no extractor, or the ref does not exist, fails the run instead of silently generating without it.
  • generate-prs.yml and validate-sdks.yml pass --baseline-ref from an optional baseline_ref in sdk-matrix.json, so pre-merge validation exercises the same signatures the release path ships. PHP is set to v9.4.0 for its repair release, since 9.5.0 shipped the Pipes methods with every body parameter dropped. Remove that entry once the repaired PHP release is tagged.

Proof

  • Before enabling this for everyone, I generated each SDK into a worktree of its own HEAD, with and without a surface extracted from that same HEAD. Ruby, Go, .NET, PHP (on emitters main): 0 files differ. Kotlin: 0 source files, only Gradle caches. Python: 88 files, the baseline enum compat aliases and their barrel re-exports, by design. Rust: 7 model files renamed toward the shipped names plus a few added or removed, because the overlay elects baseline names for deduplicated models; intended, but the Rust owner should see it before relying on it.
  • End to end with the oagen-emitters#284 emitter: --lang php --baseline-ref v9.4.0 against a worktree of workos-php HEAD extracted from v9.4.0, passed the surface, and emitted authorizeDataIntegration(slug, userId, organizationId, connectionOwner, returnTo, config, options, accountDisplayName, connectionIntent, connectedAccountId): 9.4.0's order through $options, the new optionals appended. The two organization writes, where the API now requires user_id, fell back to the schema signature with a named warning, as that PR now does.
  • Scratch output: no surface, generation unchanged. --baseline-ref on a scratch output, on a language without an extractor, and with an unknown tag: each exits 1 with a one-line reason. Ruby live checkout with the default baseline: surface passed, extracted at HEAD. Elixir: no extractor, generates as before.

Related to PIPES-900

…anguage

Only Node was handed its shipped surface at generation time, so every
other emitter generated blind and nothing stopped a parameter from
shifting position or a method from changing name between releases. The
Pipes bodies did exactly that to PHP: the emitter's compatibility code
in oagen-emitters#284 only acts when a surface is present, and the
pipeline never gave it one.

The extraction now runs for any language oagen can extract whenever the
output is a live checkout; a scratch directory has no history worth
preserving and gets none. --baseline-ref (default HEAD) picks the commit
to extract when HEAD is not the surface to preserve, which is PHP's case
today: 9.5.0 shipped without the Pipes parameters, so the repair release
baselines on v9.4.0 through the matrix. An explicit ref that cannot be
honored is an error, never a silent no-op.
@linear-code

linear-code Bot commented Oct 28, 2026

Copy link
Copy Markdown

PIPES-900

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge; all three previous findings are addressed.

Summary

The PR extends API baseline extraction to all supported languages and adds --baseline-ref for repair releases.

  • SDK generation uses existing API surfaces across supported languages.
  • PHP generation and validation use the API surface from v9.4.0.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[SDK generation] --> B{Explicit baseline ref?}
  B -->|Yes| C[Require supported language and checkout root]
  B -->|No| D{Live SDK output?}
  C --> D
  D -->|Yes| E[Extract selected commit]
  E --> F[Generate with API surface]
  D -->|No| G[Generate without API surface]
Loading

Reviews (2) · Last reviewed commit: "fix(scripts): only a checkout root is a ..." · Reviewed by Greptile

Comment thread scripts/sdk-generate.sh Resolved
Comment thread scripts/sdk-generate.sh Resolved
Comment thread .github/workflows/generate-prs.yml Resolved
…baseline counts

A scratch directory inside this repository, such as .oagen/python/sdk,
sits inside a git work tree, so the first cut would have made a
worktree of openapi-spec itself and extracted that as the baseline on
every repeat run. Only a directory that is the root of its own checkout
is a live SDK now. --baseline-ref HEAD was also indistinguishable from
the default and so slipped past the checks that make an unhonorable
request fail; the flag is tracked separately from its value. The
validation workflow passes the matrix baseline too, so pre-merge checks
exercise the signatures the release path will ship.
@gjtorikian
gjtorikian merged commit b52b24c into main Oct 28, 2026
9 checks passed
@gjtorikian
gjtorikian deleted the gjtorikian/sdk-generate-baseline-surface branch October 28, 2026 20:58
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.

1 participant