feat: make module discovery cwd-aware#8
Merged
Conversation
Discovery is now anchored at the client's cwd instead of the workspace root: modules() and generateAll() see the nearest enclosing module plus every Dang module at or below the cwd, so running from a subdirectory acts on the project you're in and the projects beneath it — not the whole workspace. Lookup and discovery both recognize the CLI 1.0 dagger-module.toml in addition to the legacy dagger.json; in a partially migrated tree the nearest config wins. Mod.rootPath is the module's stable workspace-root-relative identity used for generation and configuration, while the public Mod.path is now relative to the caller cwd. The e2e module is bumped to v1.0.0-0 for asWorkspace(cwd:); the root dang-sdk module stays on v0.20.8 by resolving the cwd through the polyfill's findUp helper rather than Workspace.cwd. Part of dagger/dagger#13688 Signed-off-by: Tom Chauveau <tom@dagger.io>
24 tasks
tiborvass
approved these changes
Jul 22, 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.
What
Makes Dang SDK module discovery follow the cwd-aware convention from
dagger/dagger#13688, and teaches lookup + discovery the CLI 1.0
dagger-module.tomlconfig in addition to the legacydagger.json.Companion to the same change in the other official SDKs:
Behavior after this change
Discovery is anchored at the client's cwd, not the workspace root.
modules()and
generateAll()now return the nearest enclosing module plus every Dangmodule at or below the cwd — running from a subdirectory acts on the project
you're in and the projects beneath it, not the whole workspace.
modules/generateAllBoth
dagger-module.toml([runtime] source = "dang") and legacydagger.json(
sdk.source = "dang") participate in discovery and inmod(...)find-up. In apartially migrated tree the nearest config wins.
How discovery differs from go/python/typescript
All of these SDKs, including this one, validate a single
mod(...)lookup bycontent search — does the found config declare the SDK's runtime. The
difference is only in the bulk
modules()discovery path:findConfigDirswithcurrentModule.asSDK.modules;python with
ws.sdk(...).modules— i.e. the workspace's managed-SDK list.findConfigDirsby content search (does theconfig declare the built-in
dangruntime).dangis an engine runtime, notan installed SDK, so there is no managed-SDK list to intersect against — a
module is Dang because of what its config says, matching this module's
existing discovery model.
Internal model
Mod.rootPathis the workspace-root-relative identity used for generation andconfiguration. The public
Mod.pathis now relative to the caller cwd (.forthe module itself,
sub/modbeneath,..for an enclosing one), so listingsread the way a shell user would.
Scope / notes
engineVersion: v1.0.0-0(required forasWorkspace(cwd:)in the discovery tests).dang-sdkmodule stays onv0.20.8: the cwd is resolved through thepolyfill's
findUp(".", ".")helper instead ofWorkspace.cwd, so no newengine floor is required.
dagger/polyfill@main(providesfindConfigDirs).Tests
New/updated e2e checks:
module-lookup-toml-check— find-up + exact lookup through adagger-module.toml.module-lookup-non-dang-toml-check— a toml module owned by another runtime is rejected.mixed-config-lookup-check— a nearerdagger-module.tomlbeats an ancestordagger.json.modules-check— root discovery lists both config formats, excludes other-runtime modules.modules-cwd-check— re-anchors the workspace viaasWorkspace(cwd:)and verifieswalk-down scoping, find-up (
..), and toml-cone discovery. The snapshot is scoped to thefixture tree so the repo's own Dang modules (this e2e module, the root module) don't leak
into find-up under content-search discovery.
Verified with
dagger --x-release=v1.0.0-beta.7 -m .dagger/modules/e2e check: 15/15 pass.