Repository navigation
Conversation
grouville
force-pushed
the
workspace
branch
2 times, most recently
from
May 22, 2026 23:01
d9e8204 to
b1caab7
Compare
eunomie
force-pushed
the
workspace-go-no-codegen-at-runtime
branch
3 times, most recently
from
May 26, 2026 09:27
400a8d0 to
1107213
Compare
eunomie
marked this pull request as ready for review
May 26, 2026 11:30
eunomie
force-pushed
the
workspace-go-no-codegen-at-runtime
branch
from
May 27, 2026 10:03
93bf755 to
cc40189
Compare
grouville
self-requested a review
May 27, 2026 19:24
eunomie
force-pushed
the
workspace-go-no-codegen-at-runtime
branch
2 times, most recently
from
May 28, 2026 17:44
9abdda9 to
a383ce1
Compare
eunomie
force-pushed
the
workspace-go-no-codegen-at-runtime
branch
from
May 29, 2026 07:55
a383ce1 to
4b796e0
Compare
tiborvass
force-pushed
the
workspace
branch
2 times, most recently
from
May 30, 2026 05:10
b9b4b5f to
4e36540
Compare
eunomie
force-pushed
the
workspace-go-no-codegen-at-runtime
branch
2 times, most recently
from
May 30, 2026 08:30
7a16535 to
c9932d8
Compare
eunomie
force-pushed
the
workspace
branch
2 times, most recently
from
May 30, 2026 20:53
74f8372 to
70d629a
Compare
eunomie
force-pushed
the
workspace-go-no-codegen-at-runtime
branch
from
June 2, 2026 15:16
1c77309 to
b753f71
Compare
eunomie
force-pushed
the
workspace-go-no-codegen-at-runtime
branch
3 times, most recently
from
June 4, 2026 11:36
81f1be4 to
ad74b21
Compare
eunomie
force-pushed
the
workspace-go-no-codegen-at-runtime
branch
from
June 5, 2026 09:41
ad74b21 to
a5d3be7
Compare
Member
Author
|
Benefit examples:
dagger ~/src/empty $ dagger -m .dagger/modules/my-module/ call container-echo --string-arg plop stdout
✔ connect 0.0s
✔ load workspace: . 0.2s
✔ parsing command line arguments 0.0s
✔ myModule: MyModule! 0.0s
✔ .containerEcho(stringArg: "plop"): Container! 2.8s
✔ .stdout: String! 1.0s
plop
dagger ~/src/empty $ vi .dagger/modules/my-module/main.go
dagger ~/src/empty $ dagger -m .dagger/modules/my-module/ call container-echo --string-arg bla stdout
✔ connect 0.0s
✔ load workspace: . 0.7s
✔ parsing command line arguments 0.0s
✔ myModule: MyModule! 0.0s
✔ .containerEcho(stringArg: "bla"): Container! 1.4s
✔ .stdout: String! 0.1s
plop: bla
dagger ~/src/empty $ vi .dagger/modules/my-module/main.go
dagger ~/src/empty $ dagger generate
● ✔ go-sdk:generate-all 2.7s ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡆⣿⣿⣿⡆⡄⡀⣿⡇
┃ Apply changes?
┃ .dagger/modules/my-module/dagger.gen.go +22 -3
┃
┃ 1 file changed, +22 -3 lines
┃
┃ Apply Discard
dagger ~/src/empty $ dagger -m .dagger/modules/my-module/ call echo --string-arg hello
✔ connect 0.0s
✔ load workspace: . 0.7s
✔ parsing command line arguments 0.0s
✔ myModule: MyModule! 0.0s
✔ .echo(stringArg: "hello"): String! 0.1s
hello
dagger ~/src/empty $ vi .dagger/modules/my-module/main.go
dagger ~/src/empty $ vi .dagger/modules/my-module/dagger.json
dagger ~/src/empty $ dagger generate
● ✔ go-sdk:generate-all 2.7s ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⡆⡄⡀⣿⡇
┃ Apply changes?
┃ .dagger/modules/my-module/dagger.gen.go +22 -3
┃ .dagger/modules/my-module/internal/dagger/my-module.gen.go +92
┃
┃ 2 files changed, +114 -3 lines
┃
┃ Apply Discard
dagger ~/src/empty $ dagger -m .dagger/modules/my-module/ call print --string-arg foo
✔ connect 0.0s
✔ load workspace: . 1.2s
✔ parsing command line arguments 0.0s
✔ myModule: MyModule! 0.0s
✔ .print(stringArg: "foo"): String! 1.2s
plop: fooCode with the self call is just this: package main
import (
"context"
"dagger/my-module/internal/dagger"
)
type MyModule struct{}
// Returns a container that echoes whatever string argument is provided
func (m *MyModule) ContainerEcho(stringArg string) *dagger.Container {
return dag.Container().From("alpine:latest").WithExec([]string{"echo", "plop:", stringArg})
}
func (m *MyModule) Echo(stringArg string) string {
return stringArg
}
func (m *MyModule) Print(ctx context.Context, stringArg string) (string, error) {
return dag.MyModule().ContainerEcho(stringArg).Stdout(ctx)
}
// Returns lines that match a pattern in the files of the provided Directory
func (m *MyModule) GrepDir(ctx context.Context, directoryArg *dagger.Directory, pattern string) (string, error) {
return dag.Container().
From("alpine:latest").
WithMountedDirectory("/mnt", directoryArg).
WithWorkdir("/mnt").
WithExec([]string{"grep", "-R", pattern, "."}).
Stdout(ctx)
} |
eunomie
force-pushed
the
workspace-go-no-codegen-at-runtime
branch
from
June 8, 2026 08:43
bc46928 to
549f8db
Compare
Introduce codegen.legacyCodegenAtRuntime in dagger.json. When false, the Go SDK trusts the committed dagger.gen.go + internal/dagger files and skips the runtime codegen pass. Validated at module load: false requires automaticGitignore=false (generated files must be committed). Defaults (nil/true) preserve the legacy behavior. Signed-off-by: Yves Brissaud <[email protected]>
Add an engine-side schemaTools surface exposed over dagql: load an introspection schema (dag.schema(json)) and merge a module's introspection-shaped types into it (merge(moduleTypes, moduleName)), reading the result back via .contents. The merge stamps @sourceModuleName and @sourcemap on the merged types so SDK file-splitters can place them. Kept minimal — only schema(json).merge(...).contents, which is all the codegen needs. Provided by the engine so every SDK reasons about schemas through one implementation. Includes the regenerated SDK clients and reference docs for the new Schema type. Signed-off-by: Yves Brissaud <[email protected]>
When dagger.json sets codegen.legacyCodegenAtRuntime=false, Go SDK's Runtime() skips the in-container codegen pass and builds straight from the committed dagger.gen.go + internal/dagger files. A baseWithoutCodegen helper mounts the source as-is (with gitconfig + SSH parity for private modules) and returns the SSH-unset selectors to bracket the go build. A precheck errors with an actionable message (self-calls aware) when the committed files are missing. Codegen() and the default Runtime() path are unchanged. Signed-off-by: Yves Brissaud <[email protected]>
Restore the typedef-registration branch generate-module emitted before moduleTypes was split out. The generated invoke() dispatcher now handles parentName == "" by returning a *dagger.Module built via dag.Module().WithObject(...) from baked-in TypeDefCode, so the engine can materialise the module's typedefs via the Runtime + empty-function-name path. Adds TypeDefCode() to the parsed object/interface/enum/function/ type-spec types alongside the existing TypeDef() helpers. Signed-off-by: Yves Brissaud <[email protected]>
Make codegen generate-module run once for Go modules, including self-calls. The Go codegen emits its own module's types as introspection JSON (new introspect_emit.go, reusing the packages.Load-parsed types) and, when --self-calls is set, merges them into the deps schema via the engine's schemaTools (dag.schema(deps).merge(...)) in a single pass. Drops the Go SDK's moduleTypes implementation (AsModuleTypes returns nil,false; ModuleTypes method removed). The engine's runCodegen keeps its self-append only for SDKs that implement moduleTypes (Python, TS); Go discovers its types via the empty-parentName dispatcher and merges codegen-side, so the engine no longer builds+runs the module via asModule during codegen. Adds the --self-calls flag, SelfCalls config field, and experimentalPrivilegedNesting on the codegen exec so the in-container dag client can call schemaTools. Signed-off-by: Yves Brissaud <[email protected]>
Cover the Go SDK no-codegen-at-runtime feature end to end: - the config guardrail rejecting codegen.legacyCodegenAtRuntime=false unless codegen.automaticGitignore is also false, enforced during module load. - the missing-generated-files error surfaced by the no-codegen runtime path, which points the user at `dagger generate`. Signed-off-by: Yves Brissaud <[email protected]>
Add a WorkspaceModulesInclude client-metadata hint. When set, the engine narrows the pending workspace modules to those named by the patterns (the segment before ':' in each, e.g. "go-sdk" in "go-sdk:generate") before loading them, so an unrelated broken or stale workspace module cannot block the operation. A module's own dependencies still load transitively; a bare pattern (no module segment) or one matching no module disables the narrowing and loads everything. This complements the single-query lazy-load (which is gated on SingleQuery and the peeked root fields): `dagger generate` keeps the session open and roots its query at currentWorkspace, so it needs an explicit hint rather than the document peek. Signed-off-by: Yves Brissaud <[email protected]>
`dagger generate <module:generator>` now passes the patterns to the engine as WorkspaceModulesInclude, so only the named generators' modules (plus their dependencies) are loaded. Previously every primary workspace module was loaded just to enumerate generators, so one stale/broken module blocked regenerating any other — including the very module you wanted to fix. Signed-off-by: Yves Brissaud <[email protected]>
* go: fix self-call field names Problem: When a Go module has SELF_CALLS enabled, the Go SDK writes the module schema that is then used to generate the module's own Go client. For exported fields, that schema was using the Go name directly. So a field called Message was exposed as Message. The engine exposes that same field as message. Because of that mismatch, the generated Go client could be wrong. In the case we found, it could generate a field and a method with the same Go name, which does not compile. Fix: Emit exported fields with the same name the engine uses. Message now becomes message. Test: Add a Message field to the existing Go self-call fixture and query message from the integration test. This proves the generated Go code compiles and the field is available under the expected name. Signed-off-by: Guillaume de Rouville <[email protected]> * tests: cover self-calls from dependencies Problem: The review raised a possible failure where a Go module with SELF_CALLS works when called directly, but breaks when another module depends on it. If that happened, the caller could still generate Go code for dag.Dep(), but the running engine would not expose dep at runtime. The user would only see the failure when calling the function. We did not reproduce that exact failure, but this is still a useful area to cover because it is easy to miss. A module dependency is loaded through a different path than the module being called directly. Solution: Add two small Go fixtures: - self-calls-as-dep: caller -> dep - self-calls-transitive: caller -> middle -> dep Only dep has SELF_CALLS enabled. That keeps the tests focused on the dependency case from the review. Tests: viaDep calls a dependency function that calls itself through dag.Dep(). viaDepContainer returns a container created by that self-call and then reads stdout from the caller. This proves the returned object is still usable. viaDepWorker calls back into dag.Dep() from a secondary object. This proves the case is not limited to methods on the root object. viaTransitiveDep calls through caller -> middle -> dep. This proves the self-call still works when the module with SELF_CALLS is a dependency of a dependency. Signed-off-by: Guillaume de Rouville <[email protected]> --------- Signed-off-by: Yves Brissaud <[email protected]>
The self-call introspection emitter must reproduce exactly the names the engine exposes (the TypeDef path passes raw Go names and lets the engine normalize them). PR #2 fixed exported struct fields. Apply the same to the remaining names: - enum values -> ToScreamingSnake (Active -> ACTIVE); previously always mismatched, so a self-called enum value sent the wrong wire name. - function/constructor arguments -> ToLowerCamel (matches the engine; only bit non-lowerCamel params such as acronyms). - object/interface/enum type names and their type references -> ToCamel (only bit acronym type names, e.g. HTTPProxy -> HttpProxy). Add a Color enum to the Go self-calls fixture and a self-call that passes an enum argument, covering the enum-value casing end to end. Signed-off-by: Yves Brissaud <[email protected]>
Rebasing onto 1.0-beta hit a conflict in the generated PHP reference (Binding/Client/Env.html), which was resolved to the 1.0-beta side and so dropped the Schema type entries added by the schema-merge-tool patch. Re-run `dagger generate` (engine built from source, so the schema includes the new Schema type) to restore them: Client.schema()/ loadSchemaFromID and the Binding/Env schema accessors. Also refreshes the doctum traits.html so php-sdk:api matches. Signed-off-by: Yves Brissaud <[email protected]>
…enAtRuntime The Go SDK no-codegen-at-runtime opt-in was a separate codegen.legacyCodegenAtRuntime flag that was only valid alongside codegen.automaticGitignore=false, enforced by a load-time guardrail. That coupling was redundant: opting out of the generated .gitignore already means the module commits its generated files, so the runtime can trust them instead of regenerating. Collapse the two into a single signal. The Go SDK now skips the runtime codegen pass when codegen.automaticGitignore=false and builds straight from the committed dagger.gen.go + internal/dagger; unset/true keeps the legacy runtime-codegen behavior. This also makes the committed files honest: what is committed is what runs, instead of being regenerated at call time and possibly differing from what the user sees in git. - core/modules: drop the LegacyCodegenAtRuntime field, its Clone entry and the Validate guardrail; document the dual meaning of AutomaticGitignore. - core/schema/modulesource: drop the now-empty codegen Validate call. - core/sdk/go_sdk: key useRuntimeCodegen off AutomaticGitignore and reword the missing-generated-files prechecks. - tests + generated config schema: follow the rename. Signed-off-by: Yves Brissaud <[email protected]>
useRuntimeCodegen previously skipped the runtime codegen pass for any Go module with codegen.automaticGitignore=false, trusting the committed generated files as-is. But the Go SDK's generated module dispatch is engine-version specific: the empty-parentName typedef registration is only emitted by the current codegen, so files generated by an older engine fail to load against a newer one with "unknown object". The repo's own dev modules pin engineVersion v0.21.4 (the last stable release) yet run against the in-development engine, so their committed files don't speak the running engine's module protocol. Keying skip-codegen purely off automaticGitignore therefore broke every check that loads those modules (php-sdk:api, ci:bootstrap, the test-split suite, release). Only honor the opt-out when the module's pinned engineVersion is at least as new as the running engine; on version skew, fall back to runtime codegen so the committed files are regenerated to match. This keeps the single-flag model while making it safe by construction: stale or mismatched committed files can never silently run. Signed-off-by: Yves Brissaud <[email protected]>
eunomie
force-pushed
the
workspace-go-no-codegen-at-runtime
branch
from
June 8, 2026 08:53
549f8db to
dcaa047
Compare
7 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Reworks the Go SDK codegen path so that:
codegen.legacyCodegenAtRuntime=falseindagger.json, the Go SDK truststhe committed
dagger.gen.go+internal/daggerfiles and skips thein-container codegen pass at runtime (it errors with an actionable message
if the committed files are missing).
generate-moduleruns once for Go modules, including self-calls.Previously self-calls modules ran it twice (the engine built+ran the module
via
asModulejust to discover its own types, then ran codegen again). Nowthe Go codegen discovers its own types from the existing
packages.Loadanalysis, emits them as introspection JSON, and merges them into the deps
schema via the engine's new
schema(json).merge(...)tool — in a singlepass. No AST analyzer;
packages.Loadis retained.moduleTypesis dropped from the Go SDK. Type discovery happens throughthe generated
invoke()dispatcher's empty-parentName arm. Other SDKs(Python, TS) keep
moduleTypesand the engine-side self-append.dagger generate <module>no longer eagerly loads unrelated modules.A workspace
generatescoped to one module narrows the pending module setby the requested include patterns, so a broken/stale sibling module no
longer blocks regenerating a good one.
Commits (read in order)
core/modules: add legacyCodegenAtRuntime codegen config fieldfeat: add schema merge tool for codegen— engine-sideschema(json).merge(...).contents, exposed over dagql for all SDKs. Keptminimal: only the
schema/merge/contentsthe codegen needs (nolistTypes/hasType/describeTypeorIntrospectionTypegraph).core/sdk/go_sdk: skip codegen at runtime when opted incmd/codegen/generator/go: emit empty-parentName module dispatchcmd/codegen + core: single-pass Go codegen, drop moduleTypestest: add e2e tests for legacyCodegenAtRuntime config— config guardrailengine/server: narrow workspace module loading by include patternscmd/dagger: scope generate module loading to requested generatorsgo: fix Go self-call schema names and cover dependency use (#2)go: match engine name casing for self-call enum values, args and types—enum values → SCREAMING_SNAKE, args → lowerCamel, type names/refs → Camel,
matching what the engine exposes from the same Go source.
Status / notes
workspace. Engine builds;core/...,cmd/codegen/...andengine/serverunit tests pass;TestSelfCallspasses (18/18) against a dev engine built from this branch.
Schemaobject exposingmerge/contents(plus theschema(json)constructor) surfaces in theSDKs, so the SDK regen diff is correspondingly small.
dagger generateof a good one) is now addressed by commits 7–8.to share separately.
Test plan
dagger generateruns codegen once (noasModulebuild/run), produces a compilable
dag.MyModule()self binding, self typesland in
internal/dagger/<module>.gen.go.moduleTypes).legacyCodegenAtRuntime=falsewith committed files: runtime skips codegen.schemaToolsmerge — unit (core/schematool_test.go) + integration(
TestSchemaTools) cover merge, idempotency, conflict, contents round-trip,and the live engine schema.
legacyCodegenAtRuntimee2e (TestRuntimeCodegen): config guardrail andthe missing-generated-files error.
(
TestFilterPendingWorkspaceModulesByInclude) covers narrowing the pendingmodule set by include patterns.