You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generators do not have enough power to resolve their dependency graph that require more generation. For example, a module with a local dependency, which may be using a different SDK
Brief description of the issue, but more thorough recount of discussions below in sipsma's comment:
Module codegen responsibility has shifted from the runtime to the SDK module. Codegen is exposed as a normal generator
To complete codegen, a module's dependencies must have up to date codegen
If you are developing a module with a local dependency which you have made changes to such that both module's codegen are out of date, the dependent module's codegen must be run first so that the module that depends on it can codegen
Generators have no concept of ordering or layering, they're all run concurrently and independently
The SDK module has no mechanism to request the codegen of a dependency
I was trying to get more concrete details on this, summary below. Disclaimer that it's AI generated from spelunking github+discord but was useful to me.
Details
The core problem is not merely “the list is in the wrong order.” Dagger currently has no dependency model for generate functions:
@generate/+generate is only a boolean marker on a module function.
dagger generate flattens all selected generators into one group and runs them concurrently.
Each generator returns a Changeset; Dagger merges and applies those changes only after every generator has finished.
Module dependencies live in a separate graph. The generator scheduler does not connect that graph to generator functions or arrange for one generator’s output to become another’s input.
This is particularly visible after dagger-module.toml disabled runtime codegen: a dependent module may need its dependency’s committed generated bindings before it can even load. Ordering alone is insufficient unless the earlier changes are also staged into the workspace seen by the later generator.
Yves’s draft #13661 addresses one narrow part—leaf-first ordering inside one SDK’s managed-module list—but does not yet solve cross-SDK dependencies or establish staged output visibility.
What “generate functions” means here
The discussion is about ordinary module functions annotated @generate or +generate, especially SDK modules’ functions such as go-sdk:generate-all, python-sdk:generate-all, and typescript-sdk:generate-all.
Those generator functions subsequently invoke module codegen and produce generated bindings. This is not primarily the generated-client feature or the engine’s CodeGenerator.Codegen interface, though both are downstream parts of the execution path. The distinction matches the repository’s codegen architecture documentation.
Current technical model
A generated API/schema marks a function as a generator by setting Function.IsGenerator. There is no dependency, predecessor, module path, or ordering metadata. Function.WithGenerator takes no arguments, and the GraphQL schema describes it only as a flag in core/schema/module.go.
Workspace.generators best-effort loads modules, discovers their annotated functions, and concatenates them into a flat allGenerators slice. core/schema/workspace.go
GeneratorGroup.Run creates one parallel job per generator. There is no topological sort or edge between jobs. core/generators.go
Generating one module’s context loads all of its dependencies as actual modules before invoking SDK codegen. runCodegen and loadDependencyModules
For dagger-module.toml, a dependency runtime cannot repair missing bindings while loading: it must build from committed generated files. That rule is explicit in core/sdk/utils.go and its focused missing-generated-files test.
The DagQL/cache graph cannot infer the missing generator edge. It only records dependencies when one call consumes another call’s result or ID. Both generators currently consume the original workspace; neither consumes the other’s returned Changeset. Merging patches afterward is output composition, not an execution dependency.
Minimal concrete example
Consider two local modules owned by different SDKs:
Bare dagger generate discovers go-sdk:generate-all and python-sdk:generate-all.
GeneratorGroup.Run starts both in parallel against W0.
Go codegen can produce Δlib.
Python codegen for app-py calls loadDependencyModules and tries to load lib-go as a module.
lib-go is still being loaded from W0, where its committed generated Go files are missing. Because it is TOML-configured, runtime codegen cannot repair them, so the Python generator fails.
Even if the Go generator happens to finish first, Δlib is only a returned value. It is not applied until after the Python generator has also succeeded.
If the Go files are stale but buildable, the more dangerous outcome is that Python generation may succeed against a stale dependency schema. A retry-on-failure scheme would not detect that.
Leaf-first ordering of CurrentModule.asSDK.modules cannot solve this mixed-SDK example: the Go SDK sees a one-element list containing lib-go, while the Python SDK sees a separate one-element list containing app-py. Neither list contains the cross-SDK edge.
That is why this cannot be expressed today.
Why the obvious workarounds are insufficient
Manually run SDK generators in separate CLI invocations: This can work if each invocation applies its changes before the next, but the operator must discover and maintain the order. It is not represented or enforced by dagger generate. Yves also hit the prerequisite problem that targeted api call/functions loaded the whole broken workspace; open #13574 addresses that escape hatch.
Call one generator from another: A bespoke orchestrator could hard-code calls and use a changed Workspace value, but there is no standard per-module SDK generation operation. Meanwhile the top-level scheduler will still independently run every annotated generator unless those annotations are removed. That loses generic discovery and creates ownership/duplication questions.
Return/chaining Changesets: Returning A’s patch does not make it B’s workspace. B must explicitly receive something like W0.withChanges(ΔA), and the current scheduler never constructs that data edge.
Constructors: Constructors configure a call or module instance; they do not add scheduler metadata and may themselves require the module to load.
Hidden filesystem side effects: Generators are modeled as immutable computations returning Changesets. Host application happens afterward, so side-effect ordering would fight both cache correctness and Dagger’s current execution model.
SDK-local generateAll: Current Go, Python, and TypeScript SDKs iterate their own currentModule.asSDK.modules list. For example, Go’s generateAll maps every module from the same ws and merges their generated forks. It has no global view of modules owned by other SDKs.
Recent chronology
June 19–20: Yves opened and merged #13522, adding the minimal CurrentModule.asSDK API so SDK generators could discover the modules they own. Its module entries contain only a path; there is no dependency or generator handle. The corresponding Go SDK PR #4 switched generateAll from filesystem scanning to that API.
July 9–13:#13598 established that TOML modules do not perform runtime codegen. Generated files must be committed and repaired through dagger generate, making generation order materially important.
July 10: Solomon opened #13605, a related but distinct self-bootstrap cycle: Go codegen imports the generated Go SDK that it is trying to regenerate. A module topological sort cannot fix that; the proposed remedies are a minimal bootstrap client or prebuilt codegen binary.
July 13–16:#13620 migrated transitive local modules and registered each under its runtime SDK; #13653 fixed the resulting SDK installs. This exposed real multi-module and potentially mixed-SDK generation graphs.
July 15:#13575 made bare generation tolerate modules that cannot yet load. That lets SDK generators attempt repairs, but does not order those repairs.
July 16, Discord: In #maintainers, Yves said the flat list is actually a tree and that leaf-first ordering inside one SDK still does not solve a Go → Python → TypeScript chain. He asked whether artifacts or collections could model it. Message 1527197113111543859
Minutes later, Yves described being unable to manually generate modules because targeted API calls loaded the entire not-yet-generated workspace. Message 1527198914455928843
In #random, Yves characterized one-SDK ordering as tractable but multi-SDK orchestration as unknown. Message 1527304835450405007
Solomon proposed walking the workspace dependency DAG, finding the owning SDK for each local module, and recursively invoking that SDK. Message 1527305273046335498
After Yves asked who should orchestrate that traversal, Solomon proposed a standard SDK operation such as generateModule(path), alongside initModule and initClient. Message 1527307928250351829 Yves noted that this resembles older, tighter SDK contracts and might be viable. Message 1527308353049727077
July 16, GitHub: Yves opened draft #13661, followed shortly by this issue. In the #1.0 sync channel Yves also recalled an earlier declarative form resembling +generate("some/path"). Message 1527353855619240066
Does not order different SDK generator functions or define staged visibility; its current integration test asserts path order rather than dependent codegen
Global workspace dependency-DAG traversal
Correct cross-SDK module order
Engine/CLI must map each module to an SDK-specific action and carry workspace state forward
Standard generateModule(path) SDK contract
Gives a central orchestrator a per-module primitive
Tightens the SDK contract; requires versioning, custom-SDK adoption, and a decision about arbitrary generators
Generatable module tree / artifacts / collections
Could represent the graph as typed data
Only speculative in Discord; no concrete scheduling or application semantics yet
Manual targeted generation
Useful recovery/debug path
Not automatic, declarative, or cache-enforced
Retry failed generators after dependencies
May make missing-file cases eventually pass
Nondeterministic, inefficient, and cannot detect stale-but-loadable schemas
Separate problem; does not solve workspace generator dependencies
A likely necessary execution primitive is to feed each successful changeset into an immutable workspace overlay before generating its dependents. No concrete design in the discussion has committed to that model yet.
@shykes discussed live at the 1.0 sync today. In theory today you should only get stuck if you make changes to multiple inter-dependent local modules at the same time without doing codegen in between. Here's the path forward:
SDK modules will be CWD aware so that I can cd .dagger/modules/modA && dagger generate and it will only do codegen for that module. Generally this means that rather than searching for modules from / we search from .. This will at least let you get unstuck if you have layers of outdated codegen because you can codegen one by one in the correct order.
In the future, this feeds into the Collections feature because I can call generate on a specified path regardless of CWD
In the later future, maybe I can request a Directory from the Workspace with generators applied
SDK modules will be CWD aware so that I can cd .dagger/modules/modA && dagger generate and it will only do codegen for that module. Generally this means that rather than searching for modules from / we search from .. This will at least let you get unstuck if you have layers of outdated codegen because you can codegen one by one in the correct order.
Correct - I'm preparing an issue now to track thishere's the issue
In the future, this feeds into the Collections feature because I can call generate on a specified path regardless of CWD
Correct (we think - need to ship Collections to be sure)
In the later future, maybe I can request a Directory from the Workspace with generators applied
To clarify, my thinking is that we would do this sooner than collections, because we have all the required plumbing already - it's likely easier and safer to ship. But of course I would love to ship Collections fast enough that this isn't needed.
EDIT: also, even with Collections support, there is the question of whether we always want to unilaterally pre-generate any workspace directory as it is accessed - or if we want consuming modules to opt into that.
even with Collections support, there is the question of whether we always want to unilaterally pre-generate any workspace directory as it is accessed - or if we want consuming modules to opt into that.
Yeah I could see that as an optional argument for selecting a directory from a workspace
After discussion, we feel there are 3 good options:
A new optional argument for Workspace.Directory(), so that you can call Workspace.Directory(path, { generate: true}) which will run the generators on that directory before returning it, and those generators that we care about are CWD aware. It returns a Workspace that can be overlaid on the current Workspace.
A new API for Workspaces for Generators. This could possibly lead into Collections/Artifacts APIs better. This would be something like Workspace.Generate( { path: path } ). Generate() can take no arguments or filters like path and other things that come later with Collections. It returns a Workspace that can be overlaid on the current Workspace.
A new api in ModuleSource. Something like ModuleSource.GenerateLocalDependencies(). This would be a minimal change for the SDK modules to use and introduces a higher level solution than 1 and 2
Activity
sipsma commentedon Jul 16, 2026
I was trying to get more concrete details on this, summary below. Disclaimer that it's AI generated from spelunking github+discord but was useful to me.
Details
The core problem is not merely “the list is in the wrong order.” Dagger currently has no dependency model for generate functions:@generate/+generateis only a boolean marker on a module function.dagger generateflattens all selected generators into one group and runs them concurrently.Changeset; Dagger merges and applies those changes only after every generator has finished.This is particularly visible after
dagger-module.tomldisabled runtime codegen: a dependent module may need its dependency’s committed generated bindings before it can even load. Ordering alone is insufficient unless the earlier changes are also staged into the workspace seen by the later generator.Yves’s draft #13661 addresses one narrow part—leaf-first ordering inside one SDK’s managed-module list—but does not yet solve cross-SDK dependencies or establish staged output visibility.
What “generate functions” means here
The discussion is about ordinary module functions annotated
@generateor+generate, especially SDK modules’ functions such asgo-sdk:generate-all,python-sdk:generate-all, andtypescript-sdk:generate-all.Those generator functions subsequently invoke module codegen and produce generated bindings. This is not primarily the generated-client feature or the engine’s
CodeGenerator.Codegeninterface, though both are downstream parts of the execution path. The distinction matches the repository’s codegen architecture documentation.Current technical model
A generated API/schema marks a function as a generator by setting
Function.IsGenerator. There is no dependency, predecessor, module path, or ordering metadata.Function.WithGeneratortakes no arguments, and the GraphQL schema describes it only as a flag incore/schema/module.go.Workspace.generatorsbest-effort loads modules, discovers their annotated functions, and concatenates them into a flatallGeneratorsslice.core/schema/workspace.goGeneratorGroup.Runcreates one parallel job per generator. There is no topological sort or edge between jobs.core/generators.goOnly after all jobs succeed does the CLI request the combined changes and apply them.
internal/cmd/dagger/generators.goandChangeset.WithChangesetsGenerating one module’s context loads all of its dependencies as actual modules before invoking SDK codegen.
runCodegenandloadDependencyModulesFor
dagger-module.toml, a dependency runtime cannot repair missing bindings while loading: it must build from committed generated files. That rule is explicit incore/sdk/utils.goand its focused missing-generated-files test.The DagQL/cache graph cannot infer the missing generator edge. It only records dependencies when one call consumes another call’s result or ID. Both generators currently consume the original workspace; neither consumes the other’s returned
Changeset. Merging patches afterward is output composition, not an execution dependency.Minimal concrete example
Consider two local modules owned by different SDKs:
The workspace registers
lib-gounder the Go SDK’sas-sdk.modulesandapp-pyunder the Python SDK’s list.The important artifacts are:
lib-go/dagger.gen.goandlib-go/internal/dagger/*.gen.go, which are missing or stale.app-py’s generated Python bindings, whose schema must incorporate thelib-godependency.The required execution is:
What happens today:
dagger generatediscoversgo-sdk:generate-allandpython-sdk:generate-all.GeneratorGroup.Runstarts both in parallel againstW0.Δlib.app-pycallsloadDependencyModulesand tries to loadlib-goas a module.lib-gois still being loaded fromW0, where its committed generated Go files are missing. Because it is TOML-configured, runtime codegen cannot repair them, so the Python generator fails.Δlibis only a returned value. It is not applied until after the Python generator has also succeeded.If the Go files are stale but buildable, the more dangerous outcome is that Python generation may succeed against a stale dependency schema. A retry-on-failure scheme would not detect that.
Leaf-first ordering of
CurrentModule.asSDK.modulescannot solve this mixed-SDK example: the Go SDK sees a one-element list containinglib-go, while the Python SDK sees a separate one-element list containingapp-py. Neither list contains the cross-SDK edge.That is why this cannot be expressed today.
Why the obvious workarounds are insufficient
Manually run SDK generators in separate CLI invocations: This can work if each invocation applies its changes before the next, but the operator must discover and maintain the order. It is not represented or enforced by
dagger generate. Yves also hit the prerequisite problem that targetedapi call/functionsloaded the whole broken workspace; open #13574 addresses that escape hatch.Call one generator from another: A bespoke orchestrator could hard-code calls and use a changed
Workspacevalue, but there is no standard per-module SDK generation operation. Meanwhile the top-level scheduler will still independently run every annotated generator unless those annotations are removed. That loses generic discovery and creates ownership/duplication questions.Return/chaining
Changesets: Returning A’s patch does not make it B’s workspace. B must explicitly receive something likeW0.withChanges(ΔA), and the current scheduler never constructs that data edge.Constructors: Constructors configure a call or module instance; they do not add scheduler metadata and may themselves require the module to load.
Hidden filesystem side effects: Generators are modeled as immutable computations returning
Changesets. Host application happens afterward, so side-effect ordering would fight both cache correctness and Dagger’s current execution model.SDK-local
generateAll: Current Go, Python, and TypeScript SDKs iterate their owncurrentModule.asSDK.moduleslist. For example, Go’sgenerateAllmaps every module from the samewsand merges their generated forks. It has no global view of modules owned by other SDKs.Recent chronology
June 19–20: Yves opened and merged #13522, adding the minimal
CurrentModule.asSDKAPI so SDK generators could discover the modules they own. Its module entries contain only a path; there is no dependency or generator handle. The corresponding Go SDK PR #4 switchedgenerateAllfrom filesystem scanning to that API.July 9–13: #13598 established that TOML modules do not perform runtime codegen. Generated files must be committed and repaired through
dagger generate, making generation order materially important.July 10: Solomon opened #13605, a related but distinct self-bootstrap cycle: Go codegen imports the generated Go SDK that it is trying to regenerate. A module topological sort cannot fix that; the proposed remedies are a minimal bootstrap client or prebuilt codegen binary.
July 13–16: #13620 migrated transitive local modules and registered each under its runtime SDK; #13653 fixed the resulting SDK installs. This exposed real multi-module and potentially mixed-SDK generation graphs.
July 15: #13575 made bare generation tolerate modules that cannot yet load. That lets SDK generators attempt repairs, but does not order those repairs.
July 16, Discord: In
#maintainers, Yves said the flat list is actually a tree and that leaf-first ordering inside one SDK still does not solve a Go → Python → TypeScript chain. He asked whether artifacts or collections could model it. Message 1527197113111543859Minutes later, Yves described being unable to manually generate modules because targeted API calls loaded the entire not-yet-generated workspace. Message 1527198914455928843
In
#random, Yves characterized one-SDK ordering as tractable but multi-SDK orchestration as unknown. Message 1527304835450405007Solomon proposed walking the workspace dependency DAG, finding the owning SDK for each local module, and recursively invoking that SDK. Message 1527305273046335498
After Yves asked who should orchestrate that traversal, Solomon proposed a standard SDK operation such as
generateModule(path), alongsideinitModuleandinitClient. Message 1527307928250351829 Yves noted that this resembles older, tighter SDK contracts and might be viable. Message 1527308353049727077July 16, GitHub: Yves opened draft #13661, followed shortly by this issue. In the
#1.0 syncchannel Yves also recalled an earlier declarative form resembling+generate("some/path"). Message 1527353855619240066Active options and tradeoffs
asSDK.modulesgenerateModule(path)SDK contractA likely necessary execution primitive is to feed each successful changeset into an immutable workspace overlay before generating its dependents. No concrete design in the discussion has committed to that model yet.
kpenfound commentedon Jul 17, 2026
@shykes discussed live at the 1.0 sync today. In theory today you should only get stuck if you make changes to multiple inter-dependent local modules at the same time without doing codegen in between. Here's the path forward:
cd .dagger/modules/modA && dagger generateand it will only do codegen for that module. Generally this means that rather than searching for modules from/we search from.. This will at least let you get unstuck if you have layers of outdated codegen because you can codegen one by one in the correct order.shykes commentedon Jul 18, 2026
Correct -
I'm preparing an issue now to track thishere's the issueCorrect (we think - need to ship Collections to be sure)
To clarify, my thinking is that we would do this sooner than collections, because we have all the required plumbing already - it's likely easier and safer to ship. But of course I would love to ship Collections fast enough that this isn't needed.
EDIT: also, even with Collections support, there is the question of whether we always want to unilaterally pre-generate any workspace directory as it is accessed - or if we want consuming modules to opt into that.
kpenfound commentedon Jul 20, 2026
Yeah I could see that as an optional argument for selecting a directory from a workspace
marcosnils commentedon Jul 20, 2026
Consensus is that we'll wait for #13688. and then come back here to settle on the final API / UX
kpenfound commentedon Jul 21, 2026
After discussion, we feel there are 3 good options:
Workspace.Directory(), so that you can callWorkspace.Directory(path, { generate: true})which will run the generators on that directory before returning it, and those generators that we care about are CWD aware. It returns a Workspace that can be overlaid on the current Workspace.Workspace.Generate( { path: path } ).Generate()can take no arguments or filters like path and other things that come later with Collections. It returns a Workspace that can be overlaid on the current Workspace.ModuleSource.GenerateLocalDependencies(). This would be a minimal change for the SDK modules to use and introduces a higher level solution than 1 and 2cc @shykes @TomChv
kpenfound commentedon Jul 21, 2026
We have agreed on option 3, described in more detail here: #13706
We also believe there is a good reason to build option 2 as well, however it is not required at the moment to unblock the codegen issue.
feat: ModuleSource.generateLocalDependencies
feat: ModuleSource.generateLocalDependencies
feat: ModuleSource.generateLocalDependencies
feat: ModuleSource.generateLocalDependencies (#13715)