Repository navigation
feat(schema): require workspace arg on asSDK - #13845
Merged
Merged
Conversation
currentModule.asSDK took the workspace as an optional argument and fell back to the ambient current workspace when omitted. That was a stopgap: dagger#13727 landed the argument as optional to avoid updating every SDK in lockstep, with FIXMEs marking the required argument as the end state. The rollout is done — the go, typescript, python and php SDK modules all call asSDK(workspace: ws) as of 2026-07-27 — so require it and drop the fallback. Nullable was also a lie in practice: since dagger#13229 a module driven as a dependency does not inherit its caller's workspace, so the fallback either failed with "no current workspace" or, for a synthetic or overlaid workspace, silently read the wrong config. It also forced the clunky CurrentModuleAsSDKOpts{Workspace: ws} call shape in Go, and the equivalent opts objects in TypeScript, Python and Rust. Signed-off-by: Tom Chauveau <[email protected]>
TomChv
marked this pull request as draft
August 5, 2026 16:16
TomChv
marked this pull request as ready for review
August 6, 2026 12:30
TomChv
added a commit
that referenced
this pull request
Aug 6, 2026
Workspace arguments on module functions were published as nullable no matter how they were declared, because the engine injects one when the caller leaves it unset. That made every signature a lie in the same way currentModule.asSDK's was before #13845: a function declaring `ws: Workspace!` advertised an optional argument. Drop the forcing, so a Workspace argument declared required is published required and one declared optional stays nullable and keeps its injection. The injection can no longer rescue a required argument: dagql rejects a missing non-null argument in preselect (dagql/objects.go) before it runs the GetDynamicInput hook that fills workspace args in. So the callers that relied on it now pass the workspace explicitly, resolving it the same way loadWorkspaceArg does — the workspace an enclosing group bound into the context, else the session's ambient one, and never inherited across a module function boundary: - generator, check and up leaves resolve through ModTreeNode.DagqlValue, which now puts the workspace on the selector — for the constructor at the root as well as the leaf function. The ambient fallback is what keeps Module.generator(name:) working, since it binds no workspace; that is the shape the scale-out check query builds, so scale-out needs no query change. - LLM tool dispatch fills a required Workspace from the LLM's bound workspace in buildObjectMethodSelector. - `dagger call` defaults it to currentWorkspace. The flag is still registered, via a new workspaceValue that resolves an address the way --dir does, so a caller can point a function at a different workspace; it just never gets MarkFlagRequired, which would otherwise reject the call before the default could be filled in. sdkInitArgIsWorkspace becomes modFunctionArg.IsWorkspace, now that more than one CLI path needs it. Signed-off-by: Tom Chauveau <[email protected]>
TomChv
added a commit
that referenced
this pull request
Aug 10, 2026
Workspace arguments on module functions were published as nullable no matter how they were declared, because the engine injects one when the caller leaves it unset. That made every signature a lie in the same way currentModule.asSDK's was before #13845: a function declaring `ws: Workspace!` advertised an optional argument. The modules already declared it required — the Go SDK registers a plain `ws *dagger.Workspace` with no `.WithOptional(true)`, unlike a `+optional` arg beside it — so this just stops the engine overriding them. A Workspace declared optional stays nullable and keeps its injection. Nothing regenerates: both edited files are on the module-runtime path, not the core schema, so schema.graphqls, the SDK clients and the vendored toolchain clients are unchanged. Requiring the argument broke three things, none of which were the wire type itself: Discovery. ModTreeNode.Children skips any function with a required argument, so generators, checks and services taking a workspace stopped being *found* rather than failing to run — `dagger generate` reported no generators and wrote nothing, and withScopedGeneration's empty-group no-op meant `dagger module init` succeeded while leaving a module with no generated code. The filter already carved out an @agent's required `base: LLM!`; a Workspace! is the same category, so functionRequiresArgsExceptAgentBase becomes functionRequiresCallerArgs. Hand-built selectors. dagql rejects a missing non-null argument in preselect, before the GetDynamicInput hook that fills workspace args in. So anything assembling a selector itself has to supply it first: the generator/check/up leaves in ModTreeNode.DagqlValue, the LLM tool dispatcher, and the entrypoint proxies — which build their inner constructor call from what `with` stored, and so failed `dagger call` on an entrypoint module with `missing required argument: "ws"`. Required of whom. The shell turns every required argument into a mandatory positional, so `run <assignment>` became `run <assignment> <ws>` with no way to name the current workspace. IsRequired stays the schema truth; IsCallerRequired asks whether the caller must supply it, which a Workspace never does. That drives both MarkFlagRequired and the shell's positional split, so `dagger call` and `dagger shell` agree — each defaulting an unset Workspace to currentWorkspace, and each letting an explicit one win. `dagger call` still registers the flag, via a new workspaceValue that resolves an address the way --dir does. Raw GraphQL is deliberately left explicit: a document omitting the argument fails validation before reaching the engine, so the dependency test drives its explicit-workspace case through `dagger call` instead. Signed-off-by: Tom Chauveau <[email protected]>
TomChv
added a commit
that referenced
this pull request
Aug 11, 2026
Workspace arguments on module functions were published as nullable no matter how they were declared, because the engine injects one when the caller leaves it unset. That made every signature a lie in the same way currentModule.asSDK's was before #13845: a function declaring `ws: Workspace!` advertised an optional argument. The modules already declared it required — the Go SDK registers a plain `ws *dagger.Workspace` with no `.WithOptional(true)`, unlike a `+optional` arg beside it — so this just stops the engine overriding them. A Workspace declared optional stays nullable and keeps its injection. Nothing regenerates: both edited files are on the module-runtime path, not the core schema, so schema.graphqls, the SDK clients and the vendored toolchain clients are unchanged. What actually needed fixing was never the wire type, but four places that treat "has required args" as a proxy for "needs something from the caller". argRequired already exempts contextual (defaultPath) args on the grounds that the engine supplies them; a Workspace is the same case, so it joins them there. That covers the @up and @generate contracts — both of which document themselves as "callable with no caller-supplied arguments" — plus @agent and no-arg enumeration, in one place. Discovery. ModTreeNode.Children skips any function with a required argument, so generators, checks and services taking a workspace stopped being *found* rather than failing to run: `dagger generate` reported no generators and wrote nothing, and withScopedGeneration's empty-group no-op meant `dagger module init` succeeded while leaving a module with no generated code. The filter already carved out an @agent's required `base: LLM!`, so functionRequiresArgsExceptAgentBase becomes functionRequiresCallerArgs. Hand-built selectors. dagql rejects a missing non-null argument in preselect, before the GetDynamicInput hook that fills workspace args in. So anything assembling a selector itself has to supply it first: the generator/check/up leaves in ModTreeNode.DagqlValue, the LLM tool dispatcher, and the entrypoint proxies — which build their inner constructor call from what `with` stored, and so failed `dagger call` on an entrypoint module with `missing required argument: "ws"`. Required of whom. The shell turns every required argument into a mandatory positional, so `run <assignment>` became `run <assignment> <ws>` with no way to name the current workspace. IsRequired stays the schema truth; IsCallerRequired — the CLI-side twin of argRequired — asks whether the caller must supply it, which a Workspace never does. That drives both MarkFlagRequired and the shell's positional split, so `dagger call` and `dagger shell` agree: each defaults an unset Workspace to currentWorkspace, and each lets an explicit one win. `dagger call` still registers the flag, via a new workspaceValue that resolves an address the way --dir does. Raw GraphQL is deliberately left explicit: a document omitting the argument fails validation before reaching the engine, so the dependency test drives its explicit-workspace case through `dagger call` instead. Signed-off-by: Tom Chauveau <[email protected]>
TomChv
added a commit
that referenced
this pull request
Aug 18, 2026
…13850) Workspace arguments on module functions were published as nullable no matter how they were declared, because the engine injects one when the caller leaves it unset. That made every signature a lie in the same way currentModule.asSDK's was before #13845: a function declaring `ws: Workspace!` advertised an optional argument. The modules already declared it required — the Go SDK registers a plain `ws *dagger.Workspace` with no `.WithOptional(true)`, unlike a `+optional` arg beside it — so this just stops the engine overriding them. A Workspace declared optional stays nullable and keeps its injection. Nothing regenerates: both edited files are on the module-runtime path, not the core schema, so schema.graphqls, the SDK clients and the vendored toolchain clients are unchanged. What actually needed fixing was never the wire type, but four places that treat "has required args" as a proxy for "needs something from the caller". argRequired already exempts contextual (defaultPath) args on the grounds that the engine supplies them; a Workspace is the same case, so it joins them there. That covers the @up and @generate contracts — both of which document themselves as "callable with no caller-supplied arguments" — plus @agent and no-arg enumeration, in one place. Discovery. ModTreeNode.Children skips any function with a required argument, so generators, checks and services taking a workspace stopped being *found* rather than failing to run: `dagger generate` reported no generators and wrote nothing, and withScopedGeneration's empty-group no-op meant `dagger module init` succeeded while leaving a module with no generated code. The filter already carved out an @agent's required `base: LLM!`, so functionRequiresArgsExceptAgentBase becomes functionRequiresCallerArgs. Hand-built selectors. dagql rejects a missing non-null argument in preselect, before the GetDynamicInput hook that fills workspace args in. So anything assembling a selector itself has to supply it first: the generator/check/up leaves in ModTreeNode.DagqlValue, the LLM tool dispatcher, and the entrypoint proxies — which build their inner constructor call from what `with` stored, and so failed `dagger call` on an entrypoint module with `missing required argument: "ws"`. Required of whom. The shell turns every required argument into a mandatory positional, so `run <assignment>` became `run <assignment> <ws>` with no way to name the current workspace. IsRequired stays the schema truth; IsCallerRequired — the CLI-side twin of argRequired — asks whether the caller must supply it, which a Workspace never does. That drives both MarkFlagRequired and the shell's positional split, so `dagger call` and `dagger shell` agree: each defaults an unset Workspace to currentWorkspace, and each lets an explicit one win. `dagger call` still registers the flag, via a new workspaceValue that resolves an address the way --dir does. Raw GraphQL is deliberately left explicit: a document omitting the argument fails validation before reaching the engine, so the dependency test drives its explicit-workspace case through `dagger call` instead. Signed-off-by: Tom Chauveau <[email protected]>
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
currentModule.asSDK(workspace:)is now required. The fallback to the ambient current workspace is gone.Part of #13790 — the
asSDKhalf only. The other half, module functions that declarews: Workspace!but are still published as nullable (core/typedef.go:252-256, which is what producesdagger.FooOpts{Ws: ws}when calling another module), is not addressed here.Why
#13727 landed the argument as optional to avoid updating every SDK in lockstep, leaving two
FIXMEs naming the required argument as the end state. That rollout is finished — every official SDK module passes a workspace explicitly, as of 2026-07-27:dagger/go-sdkgo-sdk.dang:32,116dagger/typescript-sdktypescript-sdk.dang:59,641dagger/python-sdkpython-sdk.dang:26dagger/php-sdkphp-sdk.dang:32Optional was also a lie in practice. Since #13229 a module driven as a dependency does not inherit its caller's workspace, so the fallback either failed with
no current workspace: workspace not loaded(the failure #13727 was filed for) or, when the caller held a syntheticasWorkspacevalue or a staged overlay reached outside a generator group, silently read the wrong config. And because the argument was nullable, Go codegen rendered it as opts, so the only correct call wasdag.CurrentModule().AsSDK(dagger.CurrentModuleAsSDKOpts{Workspace: ws})— same shape in TypeScript, Python and Rust.How
currentModuleAsSDKtakesdagql.ID[*core.Workspace]and loads it directly; thecurrentWorkspacefallback and bothFIXMEs are gone.core/integration/generators_test.godrop the opts wrapper (they already passed the workspace).CurrentModuleAsSDKOpts/CurrentModuleAsSdkOptsdisappear from Go, TypeScript and Rust; Go is nowAsSDK(workspace *Workspace).Compatibility
The field is gated to
AfterVersion("v1.0.0-0"), so this only touches pre-GA v1 surface. Breakage is limited to a workspace pinning an SDK module older than 2026-07-27 and running a newer engine; the error names the argument (missing required argument: "workspace") anddagger lock updatemoves the pin forward. No coordinated SDK release needed.Not included
toolchains/{engine-dev,cli-dev,go}/internal/dagger/dagger.gen.gostill carry the old optional signature — they only regenerate against a dev engine, and nothing in those toolchains callsAsSDK.toolchains/gois a separate matter: it pinsengineVersion = "v0.21.7"yet its client already carries v1-only surface (Workspace.Cwd), which predates this change.