Skip to content

core/sdk: regenerate pre-1.0 bindings at runtime - #13641

Closed
kpenfound wants to merge 1 commit into
dagger:mainfrom
kpenfound:fix-runtime-codegen-version-skew
Closed

kpenfound wants to merge 1 commit into
dagger:mainfrom
kpenfound:fix-runtime-codegen-version-skew

Conversation

@kpenfound

@kpenfound kpenfound commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Since f81f5d0, the runtime-codegen gate is decided by config format alone: dagger-module.toml modules never regenerate bindings at runtime — the runtime builds the committed generated files as-is.

But committed bindings can only serve module loading if they can describe the module's types. Type discovery (the engine's getModDef call) relies on the empty-parentName typedef-registration arm in the generated invoke() dispatcher — an arm that was removed from codegen in #10584 (when typedefs moved to SDK-side discovery) and only reintroduced in #13381, first released in v1.0.0-beta.6. A dagger-module.toml module whose committed dagger.gen.go was generated by anything older compiles fine, but its dispatcher falls into the default branch and every load fails with:

failed to call module "foo" to get functions: unknown object

(with an empty object name, since the parent name of a getModDef call is empty). If the module's source has drifted from the stale bindings, the failure is a go build error inside the runtime instead.

Worse, there is no way out from the CLI: the fix for stale committed bindings is dagger generate, but generate needs to load the module, which needs the typedefs, which the stale bindings can't provide.

Fix

Keep the config-format rule (dagger.json always regenerates; dagger-module.toml builds committed files), but gate the committed-files path on a fixed capability floor, MinimumSelfServingBindingsModuleVersion = "v1.0.0-beta.6":

  • modules pinned below the floor fall back to runtime codegen, so their bindings are regenerated to match — restoring loadability for pre-1.0-generated repos;
  • modules pinned at or above the floor keep the committed-files behavior regardless of how much newer the running engine is — the floor is a codegen capability marker, not a comparison against the running engine, so shipping v1.0.1 won't silently degrade every v1.0.0-pinned module back to runtime codegen.

The floor is compared with full prerelease precision (semver.Compare, not CheckVersionCompatibility): the arm landed in a beta, and base-version comparison would wrongly trust bindings from earlier betas.

This gates both the builtin Go SDK path and module-implemented SDKs (skipRuntimeCodegen).

Tests

  • TestOldEngineVersionKeepsRuntimeCodegen: a module pinned to v0.20.3 with nothing committed loads via runtime regeneration.
  • TestPostFloorEngineVersionTrustsCommittedFiles: a module pinned exactly at the floor (older than the running engine) still takes the committed-files path — nothing is committed, so it fails with the dagger generate hint instead of silently regenerating.
  • Existing suite (TestMissingGeneratedFiles, TestLegacyConfigKeepsRuntimeCodegen) unaffected.

🤖 Generated with Claude Code

@kpenfound
kpenfound force-pushed the fix-runtime-codegen-version-skew branch from af4e1ca to ca5793c Compare July 14, 2026 20:44
@kpenfound kpenfound changed the title core/sdk: fall back to runtime codegen on engine version skew core/sdk: regenerate pre-1.0 bindings at runtime Jul 14, 2026
@kpenfound
kpenfound requested a review from eunomie July 14, 2026 20:48
@kpenfound
kpenfound force-pushed the fix-runtime-codegen-version-skew branch from ca5793c to 9ce2a11 Compare July 14, 2026 21:07
@shykes shykes added this to the v1.0.0 milestone Jul 15, 2026
@marcosnils
marcosnils self-requested a review July 20, 2026 16:20
@kpenfound
kpenfound force-pushed the fix-runtime-codegen-version-skew branch from 9ce2a11 to b45db48 Compare July 20, 2026 21:40
f81f5d0 reduced the runtime-codegen gate to config format alone:
dagger-module.toml modules always build their committed generated
files as-is. But bindings generated before v1.0.0-beta.6 cannot serve
type discovery: the generated invoke() dispatcher's empty-parentName
typedef-registration arm — which module loading (getModDef) relies
on — was removed from codegen in dagger#10584 and only reintroduced in
dagger#13381, first released in v1.0.0-beta.6. Loading such a module fails
with "unknown object", and there is no way out from the CLI, since
regenerating the bindings requires loading the module first.

Gate the committed-files path on a fixed capability floor: modules
pinned below v1.0.0-beta.6 fall back to runtime codegen so their
bindings are regenerated to match; anything pinned at or above the
floor keeps the committed-files behavior regardless of how much newer
the running engine is. The floor is compared with full prerelease
precision — it landed in a beta, so base-version comparison would
wrongly trust bindings from earlier betas.

Co-Authored-By: Claude Fable 5 <[email protected]>
Signed-off-by: kpenfound <[email protected]>
@marcosnils
marcosnils force-pushed the fix-runtime-codegen-version-skew branch from b45db48 to 2b2df7b Compare July 22, 2026 14:29
@kpenfound

Copy link
Copy Markdown
Contributor Author

Repro — branch: kpenfound/greetings-api@repro

The branch captures a repo that migrated to the workspace format on v1.0.0-beta.6 with committed pre-1.0 bindings, in two commits:

  1. On v0.20.6, generate bindings and commit them (dagger develop with v0.20.6, then remove the generated-file entries from .gitignore). The committed dagger.gen.go is v0.20.6-vintage codegen: its invoke() dispatcher has
    no empty-parentName typedef-registration arm (removed in SDK: expose module type definitions #10584, reintroduced in Go SDK: no-codegen-at-runtime + single-pass codegen #13381 / beta.6).
  2. Run dagger setup with v1.0.0-beta.6 to migrate. This produces dagger.toml plus dagger-module.toml for the main module (engineVersion = "v0.20.6"), and leaves the committed bindings untouched.

From there:

DAGGER_X_RELEASE=v1.0.0-beta.6 dagger api functions # works
DAGGER_X_RELEASE=v1.0.0-beta.7 dagger api functions # fails
DAGGER_X_RELEASE=v1.0.0-beta.7 dagger generate # fails the same way

beta.7 fails with:

failed to call module "greetings" to get functions: unknown object

What's happening: beta.6 still regenerates bindings at runtime, so the stale committed files don't matter and the migration appears successful. beta.7 has the config-format gate — dagger-module.toml modules build their
committed files as-is — so getModDef's empty-parentName call falls into the stale dispatcher's default branch and every load fails. dagger generate, the documented fix for stale bindings, needs to load the module first,
so it fails with the same error: there's no way out from the CLI.

The practical impact is an upgrade cliff: migrating on beta.6 with committed bindings feels fine, and the repo breaks the first time anyone opens it with beta.7+.

@kpenfound

Copy link
Copy Markdown
Contributor Author

The real blocking path for this is resolved in beta.9. The remaining question is if we should automatically generate after migration, which would eliminate any confusing errors. That will be tracked separately

@kpenfound kpenfound closed this Aug 4, 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.

2 participants