Repository navigation
feat(core): add CurrentModule.asSDK for SDK-owned module discovery - #13522
Merged
grouville merged 7 commits intoJun 20, 2026
Merged
Conversation
dagger generate dispatches to an SDK module's generator (e.g. go-sdk:generate-all), which must know which workspace modules and clients it manages. On design/cli-1.0 that source of truth is the engine's workspace config ([[modules.<name>.as-sdk.modules]] / .clients), but SDK modules had no way to read it, so they fell back to scanning the filesystem for legacy dagger.json modules and silently found nothing for dagger-module.toml workspace modules (empty changeset). Add CurrentModule.asSDK, exposing the currently executing module's as-sdk role data (name, managed modules, generated clients) resolved from workspace config, per future/current-module-as-sdk.md. SDK generators can now discover their modules via dag.CurrentModule().AsSDK() instead of scanning the workspace themselves. The field is unversioned, matching the other workspace-introspection primitives SDK modules rely on (currentWorkspace, Workspace.directory/ file/findUp), so SDK modules pinned to older engine versions can consume it. The current module is matched to its workspace install entry by name (the same convention generators() uses for skip patterns), falling back to the sole installed SDK entry and erroring on ambiguity or when the current module is not installed as an SDK. Signed-off-by: Yves Brissaud <[email protected]>
Regenerated via 'dagger generate docs:references': adds the schema.graphqls entries and reference stubs for CurrentModule.asSDK and the CurrentModuleAsSDK / CurrentModuleAsSDKModule / CurrentModuleAsSDKClient types, and renumbers sidebar positions for the inserted types. Signed-off-by: Yves Brissaud <[email protected]>
This was referenced Jun 19, 2026
Member
Author
|
Related PRs for the cli-1.0
The SDK PRs depend on this engine API being available in the engine they run against; verified end-to-end against a dev engine (deleting a Go SDK module's |
eunomie
force-pushed
the
fix-generate-empty-changeset
branch
from
June 19, 2026 16:38
926cb17 to
a39591a
Compare
Signed-off-by: Yves Brissaud <[email protected]>
eunomie
force-pushed
the
fix-generate-empty-changeset
branch
from
June 19, 2026 17:43
a39591a to
8e75caa
Compare
CurrentModule.asSDK and the CurrentModuleAsSDK* types were unversioned, so
they leaked into the base (oldest module) schema and failed
TestBaseSchemaAllowlist. Gate the field and the object types with
View(AfterVersion("v1.0.0-0")), matching the rest of the cli-1.0 workspace
API, so they (and their auto-generated Binding.as* accessors) stay out of
older module views. SDK modules consume it by declaring engineVersion
>= v1.0.0-0.
Signed-off-by: Yves Brissaud <[email protected]>
CurrentModule.asSDK should only succeed when the currently executing module is the workspace entry installed as an SDK. The old resolver had a fallback for workspaces with exactly one SDK install. If a normal module called CurrentModule.asSDK and its name did not match that SDK, the resolver still returned the SDK because it was the only SDK in the workspace. That was wrong because the current module was not installed as an SDK. It should receive the documented "not installed as an SDK" error. Fix this by only resolving `cfg.Modules[curName]` when that exact workspace entry is marked `AsSDK`. Otherwise return the not-installed error. Add a regression test where `my-module` runs in a workspace that also has one installed `go-sdk`. Before this fix, `my-module` resolved as `go-sdk`. Now it returns the not-installed error. Validated with the focused resolver unit test and a dev-engine smoke test with go and python installed as SDKs. Signed-off-by: Guillaume de Rouville <[email protected]>
CurrentModule.asSDK only succeeds for modules installed as SDKs. That is the intended CLI flow: `dagger sdk install` writes the workspace as-sdk marker, while plain `dagger install` leaves a normal module install. TestGeneratePrivateGitDependency was still installing go-sdk with the generic module install command. With the stricter asSDK resolver, go-sdk then ran as a normal module and correctly got the "not installed as an SDK" error. Update the test setup to use `dagger sdk install go`, matching the SDK-owned generator path that the test expects to exercise. Validated with the focused resolver unit test and the failing integration subtest. Signed-off-by: Guillaume de Rouville <[email protected]>
CurrentModule.asSDK now requires the current module to be installed with an as-sdk marker. That is the intended workspace shape for SDK-owned generator tests. TestGeneratorGroupChangesSyncWithNestedSDKCodegen writes a dagger.toml fixture by hand. It installed go-sdk as a normal workspace module, then expected go-sdk:generate-all to call CurrentModule.asSDK successfully. With the stricter resolver, that fixture correctly failed as "not installed as an SDK". Add the go-sdk as-sdk marker to the fixture so it matches the SDK install shape under test. Validated with the focused integration subtest. Signed-off-by: Guillaume de Rouville <[email protected]>
grouville
approved these changes
Jun 20, 2026
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.
Problem
On
design/cli-1.0, afterdagger sdk install go+dagger module init go my-module --template=legacy, deleting.dagger/modules/my-module/internaland runningdagger generate(a.k.a.go-sdk:generate-all) returns an empty changeset and does not restoreinternal/.Root cause
dagger generatediscovers and dispatches to an SDK module's generator (e.g.go-sdk:generate-all), which must know which workspace modules it manages. On cli-1.0 that source of truth is the engine's workspace config ([[modules.<name>.as-sdk.modules]]), but SDK modules had no way to read it — so they fall back to scanning the filesystem for legacydagger.jsonmodules and silently find nothing fordagger-module.tomlworkspace modules, producing an empty changeset.This is the engine half of the fix described in
future/current-module-as-sdk.md.This PR
Adds
CurrentModule.asSDK, exposing the currently executing module's as-sdk role data resolved from workspace config:SDK generators can now discover their managed modules via
dag.CurrentModule().AsSDK()instead of scanning the workspace themselves.Notes:
currentWorkspace,Workspace.directory/file/findUp), so SDK modules pinned to older engine versions can consume it.generators()already uses for skip patterns), falling back to the sole installed SDK entry and erroring on ambiguity / when the current module is not installed as an SDK.modules/clientsexpose only the persisted fields the SDKs need); the design's derivedsource/moduleSourcefields are deferred until a consumer needs them.docs/docs-graphql/schema.graphqlsand the API reference stubs were regenerated viadagger generate docs:references.Follow-up (separate PRs)
This is the engine discovery primitive. The full user-visible fix also needs the SDK modules to use it:
dagger/go-sdk,dagger/typescript-sdk,dagger/python-sdk:generateAlldiscovers viacurrentModule.asSDK.modulesinstead of scanningdagger.json.dagger/sdk-sdk: the sharedpolyfillcodegen helper needs to recognizedagger-module.toml(it currently hardcodesdagger.json).