fix(cli): send runtime bundles to sdk-gen-api (FSDK-1116) - #17505
Conversation
Docs Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on
Docs generation runs |
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
… FSDK-1116-fern-runtime-bundle # Conflicts: # packages/cli/generation/remote-generation/remote-workspace-runner/package.json # pnpm-lock.yaml
…-1116-fern-runtime-bundle
…-1116-fern-runtime-bundle
|
@nitpickybot can you look at this pr? |
|
Sure — here's what stands out. Note the diff is truncated for the biggest new files ( OverallThe direction makes sense: Fern owns Fern-specific prep (config + IR migration), sdk-gen-api treats the bundle as opaque bytes. That's a much cleaner boundary than having sdk-gen-api reconstruct Things worth a second look1. Dependency direction: local → remote
export { getGeneratorConfig, getGithubPublishConfig, getLicensePathFromConfig }
from "@fern-api/remote-workspace-runner";Local generation now depends on the remote generation package to build a config for a local Docker run. That's a bit backwards, and it drags 2. Tests now call it with a second positional arg (
3. Bundle ↔ target association The PR says "Bundle order is aligned to request target order," but files are named 4. No v1 fallback
5. Secret stripping The test asserting Smaller notes
Nothing here looks blocking; the dependency direction and the boolean flag are the two I'd want addressed before merge. |
|
Addressed the concrete review items:
The local-to-remote dependency extraction remains outside this PR: Protocol v2 remains intentionally flag-gated and deploy-ordered after sdk-gen-api #569. An older API rejects the versioned request rather than silently falling back. Client limits mirror the API contract locally for early feedback; sdk-gen-api remains authoritative and revalidates every limit. Sent by Claude on behalf of Adam |
Why this PR exists
The first sdk-gen-api CLI integration sent Fern source specifications plus high-level generator invocation metadata, then expected sdk-gen-api to translate that metadata into
SdkConfigIrV1. That is not sufficient for a wrapped Fern generator runtime: the Fern runtime listener executes a generator from its native{ config, ir }input, and the IR must already be migrated to the exact schema version expected by the requested Fern generator ID and version.This PR moves ownership of that Fern-specific preparation back to the Fern CLI. sdk-gen-api remains responsible for authentication, build state, idempotency, orchestration, artifact status, and dispatch, but it treats each runtime bundle as opaque bytes.
Behavior before and after
FERN_USE_SDK_GEN_APIunset or false.fernignorehandling.fernignorehandlingThere is no intended change to the SDK configuration or IR semantics supplied to the generator. The new bundle is built with Fern’s existing generator configuration and IR migration helpers, including the exact requested generator identity/version and any explicit IR-version override. When the feature flag is enabled, execution moves to the image selected by the deployed generator-version index; that runtime/environment change is the purpose of this route.
Exact data flow
Fern resolves the generator invocation, SDK version, sources, audiences, output mode, and enriched IR as it does today.
Eligibility is checked before selecting sdk-gen-api:
AUTO);Fern resolves the generator IR schema version from FDR or the explicit override and migrates the enriched IR for the exact generator ID/version.
Fern builds the native
GeneratorConfigwith:/tmp/fern-runtime/ir.jsonand/fern/output;publishToRegistry: false;Fern gzips exactly:
{ "config": { "...": "serialized native GeneratorConfig" }, "ir": { "...": "generator-version-compatible Fern IR" } }A protocol v2 multipart request is submitted to
/v1/fern/buildcontaining:specs.tar.gzsource archive;<targetId>.json.gzruntime bundle per target;sdk-gen-api validates and stores transient build state, then uploads each bundle unchanged and emits one grouped
OrchestratorRequestV1.sdk-gen-core resolves the exact generator version through the deployed index and dispatches the bundle to the selected runtime image.
The wrapped Fern listener downloads the opaque bundle, verifies its checksum, writes
config.json/ir.json, invokes the generator, uploads the artifact, and publishes formatter completion.Fern polls per-target status and uses the existing artifact download/output handling after success.
What this changes in existing Fern SDK generation
Only feature-flagged remote SDK generation for recognized first-party generators changes route and execution environment. The generator receives the same class of native inputs it receives through the existing Fern pipeline, prepared by the same config and IR migration code rather than reconstructed by sdk-gen-api.
The following remain unchanged:
.fernignorebehavior.Once the sdk-gen-api route is selected for a recognized generator, unsupported route capabilities fail explicitly rather than silently falling back after preparation. Replay, whitelabel generation,
AUTOSDK versions, and full-project generation are not enabled by this PR.Output and publication behavior
publishToRegistryis false and raw registry credentials are stripped.Request determinism and validation
2.Deployment and rollout
postman-eng/sdk-gen-api#569must deploy before this route is enabled. Protocol v1 does not contain listener-compatible runtime bundles and is intentionally not accepted as a fallback.Recommended rollout order:
FERN_USE_SDK_GEN_APIonly for the intended beta environment/cohort.Non-goals
AUTOversioning, or full-project generation.Verification
main.Jira: https://postmanlabs.atlassian.net/browse/FSDK-1116
API PR: https://github.com/postman-eng/sdk-gen-api/pull/569
Cutover validation
Every protocol-v2 target is validated as
legacy-fernbefore any sdk-gen-api request. The generator compatibility validator and private cutover policy are colocated with the remote workspace runner.Fern preserves the internal diagnostic and adds CLI remediation, including
fern sdk-config migratewhen sdk-config/v1 is required. Unknown generators, language mismatches, invalid versions, exact cutover behavior, and multi-target fail-closed behavior are covered without duplicating the cutover matrix.No private npm package, registry credentials, lockfile entry, or trust exception is required.
Tracked by FSDK-1155 and FSDK-1154.