Skip to content

Go SDK: no-codegen-at-runtime + single-pass codegen - #13381

Merged
eunomie merged 3 commits into
dagger:mainfrom
eunomie:workspace-go-no-codegen-at-runtime
Jul 7, 2026
Merged

eunomie merged 3 commits into
dagger:mainfrom
eunomie:workspace-go-no-codegen-at-runtime

Conversation

@eunomie

@eunomie eunomie commented Jun 9, 2026 •

Copy link
Copy Markdown
Member

Replaces #13210.

Reworks the Go SDK codegen path:

  • A module can opt out of codegen at runtime. With
    codegen.automaticGitignore=false the SDK trusts the committed
    dagger.gen.go + internal/dagger files instead of regenerating them on
    every load. Only honored when the module's engineVersion is at least as
    new as the running engine; on skew it falls back to runtime codegen so
    stale files never silently run.
  • generate-module runs once. The generator emits the module's own types
    from its packages.Load analysis and merges them into the deps schema via
    the engine's schema tool, instead of building and running the module first.
    moduleTypes is dropped from the Go SDK.
  • Self calls are always on for Go. No SELF_CALLS flag: every module gets
    bindings for its own types, generated into their own <module>.gen.go like
    any dependency.

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@eunomie
eunomie force-pushed the workspace-go-no-codegen-at-runtime branch 2 times, most recently from 1ce7e3c to d861b65 Compare June 25, 2026 10:05
@eunomie
eunomie force-pushed the workspace-go-no-codegen-at-runtime branch 17 times, most recently from 0fb26f5 to cfcd657 Compare July 7, 2026 10:43
@eunomie
eunomie force-pushed the workspace-go-no-codegen-at-runtime branch 2 times, most recently from fe9304c to cc4ee87 Compare July 7, 2026 13:29
eunomie added 3 commits July 7, 2026 15:39
When codegen.automaticGitignore=false, the Go SDK trusts the committed
dagger.gen.go + internal/dagger files and skips the codegen pass at
runtime. Codegen still runs at init/develop/generate time.

The opt-out is only honored when the module's engineVersion is at least
as new as the running engine; on version skew we fall back to runtime
codegen so stale committed files never silently run.

Signed-off-by: Yves Brissaud <[email protected]>
… SDK

The Go generator used to build and run the module once just to discover
its own types (moduleTypes), then run codegen again. It now emits those
types from its existing packages.Load analysis and merges them into the
deps schema with the engine's schema-merge tool: one pass. moduleTypes
is dropped from the Go SDK; type discovery goes through the generated
invoke() empty-parentName arm, and sources persisted by an older engine
fall back to the runtime path instead of erroring.

Self calls are always enabled for Go, no SELF_CALLS flag: every module
gets bindings for its own types, generated into their own <module>.gen.go
like any dependency. A dependency installed under the module's own name
is rejected.

Compatibility notes:
- schema views < v0.12.0 skip the merge: their layout puts everything in
  package main, where self types would collide with user code
- user-declared "id" members are not emitted (engine-reserved)
- a module type shadowing a core or dependency type is skipped in the
  bindings and no longer fails the load; the name keeps resolving to the
  original type
- Go keywords and predeclared identifiers used as field/argument names
  get a trailing underscore in the bindings ("error" excepted: already
  shipped by the core API, never collides)
- the emitted introspection mirrors the engine schema: namespaced type
  names, synthetic id fields (plus legacy <T>ID scalars pre-v0.21),
  object/interface args passed as ID with @expectedType, engine enum
  member naming, NON_NULL stripped only for +optional args
- the legacy-dagger.json workspace warning is only emitted for clients
  that load modules, so the codegen client (which now always connects)
  doesn't leak it into the caller's output

Signed-off-by: Yves Brissaud <[email protected]>
Direct self-calls (arguments, defaults, exported fields, enums,
secondary objects, objects passed by ID), self-calls through a
dependency, and through a transitive dependency.

Signed-off-by: Yves Brissaud <[email protected]>
@eunomie
eunomie force-pushed the workspace-go-no-codegen-at-runtime branch from cc4ee87 to c16fd22 Compare July 7, 2026 13:39
Comment thread core/sdk/go_sdk.go Resolved

@TomChv TomChv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHIP IT 🚀

@eunomie
eunomie merged commit ba4829c into dagger:main Jul 7, 2026
79 checks passed
kpenfound added a commit to kpenfound/dagger that referenced this pull request Jul 14, 2026
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]>
kpenfound added a commit to kpenfound/dagger that referenced this pull request Jul 14, 2026
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]>
kpenfound added a commit to kpenfound/dagger that referenced this pull request Jul 20, 2026
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 pushed a commit to kpenfound/dagger that referenced this pull request Jul 22, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants