Skip to content

feat(checks): cover workspace configs in a git subdirectory - #17

Merged
TomChv merged 2 commits into
mainfrom
monorepo-subdir-config-checks
Aug 21, 2026
Merged

feat(checks): cover workspace configs in a git subdirectory#17
TomChv merged 2 commits into
mainfrom
monorepo-subdir-config-checks

Conversation

@TomChv

@TomChv TomChv commented Aug 13, 2026

Copy link
Copy Markdown
Member

Every workspace the checks built put dagger.toml at the git root, so nothing covered the monorepo layout where several project workspaces sit in subdirectories of one repository. That is the shape dagger/dagger#13889 is about: the workspace root is the git root, so the caller's cwd sits below it, init changesets are applied at the root, and module paths reach the SDK relative to that root.

Adds a monorepo group building a third workspace — dagger.toml in common/, the SDK vendored under it, every command driven from common/.

Rebased on main, which drives 1.0.0-beta.10.

Checks

Check Asserts beta.9 beta.10
installs-from-subdir-config sdk install registers the SDK in common/dagger.toml
scaffolds-module-from-subdir-config module init writes common/.dagger/modules/subdir-mod/dagger-module.toml
keeps-module-under-subdir-config module init writes nothing outside the module directory
subdir-module-loads the scaffolded module generates and serves its API
explicit-path-keeps-module-whole a relative module init --path keeps the module whole under the caller's cwd
rooted-path-anchors-module-at-root --path /<name> anchors the module at the workspace root

Five of the six fail on the pre-fix engine and all six pass on beta.10, so none of them are vacuous. The full suite is green: 31 checks.

What the engine fix changed

dagger/dagger#13890 closes the defect this branch opened red. Init now applies both changesets at the workspace root and hands the SDK a workspace whose cwd matches, so the two halves of a new module stop landing in different directories, and the default module path is anchored at the directory holding the dagger.toml being edited rather than at the workspace root — which is what [modules.<name>].source was already resolved against.

That fixes scaffolds-module-from-subdir-config, keeps-module-under-subdir-config and subdir-module-loads unchanged. On beta.9 they still fail exactly as this branch described:

$ git status --porcelain -uall
 M common/dagger.toml
?? .dagger/modules/subdir-mod/dagger-module.toml
?? .dagger/modules/subdir-mod/main.dang

$ dagger api functions subdir-mod
Error: local path "/work/common/.dagger/modules/subdir-mod" does not exist

The --path checks moved

The fix also changed module init --path deliberately: it now resolves against the caller's cwd, with a leading / meaning the workspace root, like every other workspace path a user types. It used to be workspace-root-relative.

explicit-path-keeps-module-whole passed common/subdir-path-mod — a root-relative path naming the config directory. Under the new resolver that means a common/ below common/, so the check was asserting the old spelling and failed on beta.10 by landing the module at common/common/subdir-path-mod. It now passes a relative path and asserts the module lands under the caller's cwd. Note this flips its beta.9 result: in its old form it passed there, because the old spelling was the correct one for the old resolver.

rooted-path-anchors-module-at-root is new, and covers the other half of the resolver. With the default path now anchored beside its dagger.toml and a relative --path resolved against the caller, a leading / is the only remaining way to hand the SDK a module path the caller's cwd does not contain — the shape a cwd-scoped SDK cannot stage at all. beta.9 rejected it outright:

Error: --path "/subdir-rooted-mod" must be workspace-relative, not absolute

Note on --path

Unchanged by the fix: an explicit --path deliberately skips the [modules.<name>] entry — usingDefaultPath still gates it — so the module is authored rather than installed and there is nothing to load by name. Both --path checks therefore assert co-location rather than installation, which is what the issue actually reports there: the engine's module config and the SDK's files landing in two different directories.

@TomChv
TomChv force-pushed the monorepo-subdir-config-checks branch from e75bffb to 9781f84 Compare August 13, 2026 12:28
TomChv added 2 commits August 20, 2026 18:00
Every workspace the checks built put dagger.toml at the git root, so nothing
covered the monorepo layout where several project workspaces sit in
subdirectories of one repository. That is the shape dagger/dagger#13889 is
about: the workspace root is the git root, so the caller's cwd sits below it
and module paths cross the engine <-> SDK boundary root-relative while the
selected config reads them relative to itself.

Add a `monorepo` group building a third workspace: dagger.toml in `common/`,
the SDK vendored under it, every command driven from `common/`.

- installs-from-subdir-config: `sdk install` registers the SDK in
  common/dagger.toml.
- scaffolds-module-from-subdir-config: `module init` writes
  common/.dagger/modules/subdir-mod/dagger-module.toml.
- keeps-module-under-subdir-config: `module init` writes nothing outside the
  module directory.
- subdir-module-loads: the scaffolded module generates and serves its API.
- explicit-path-keeps-module-whole: `module init --path` writes the module
  config at the requested path and nothing outside it.

The --path check asserts co-location, not installation. The engine gates the
[modules.<name>] entry on `usingDefaultPath`, so an explicit path authors a
module without installing it — the same at a git-root workspace, so it is not
a monorepo defect. What the issue reports there is a split: the engine's
module config and the SDK's files landing in two different directories.

Two of the five pass. The other three are one engine defect and stay red until
it is fixed: initModuleChanges computes relPath workspace-root-relative, writes
the module's dagger-module.toml there, then records `source = relPath` in a
config whose sources resolve relative to its own directory. They assert the
contract, not a convention, so they hold whichever side is reconciled.

sdk-sdk stages files without the cwd-scoped polyfill fork, so it shows the
failure the issue does not: `module init` raises nothing and writes the whole
module — config and sources — at the git root, while common/dagger.toml
registers it at common/.dagger/modules/subdir-mod. Every later command that
loads the workspace fails. No SDK-side fix reaches this; prefixing the SDK's
changeset with ws.cwd moves only its half and splits the module, leaving the
engine's dagger-module.toml stranded at the git root.

Signed-off-by: Tom Chauveau <tom@dagger.io>
dagger/dagger#13890 landed in 1.0.0-beta.10 and fixes the three checks this
group added red: init changesets are now applied at the workspace root with
the SDK shown a matching cwd, and the default module path is anchored at the
directory holding the dagger.toml being edited.

It also changed `module init --path` deliberately. The path now resolves
against the caller's cwd, with a leading slash meaning the workspace root,
like every other workspace path a user types. explicit-path-keeps-module-whole
passed a workspace-root-relative path naming the config directory, which under
the new resolver means a directory of that name *below* the config directory,
so it asserted the old spelling. Pass a relative path instead and assert it
lands under the caller's cwd.

Add rooted-path-anchors-module-at-root for the other half of the resolver.
With the default path now anchored beside its dagger.toml and a relative
--path resolved against the caller, a leading slash is the only remaining way
to hand the SDK a module path the caller's cwd does not contain — the shape a
cwd-scoped SDK cannot stage at all. beta.9 rejected it outright as absolute.

Five of the six now fail on beta.9 and all six pass on beta.10.

Signed-off-by: Tom Chauveau <tom@dagger.io>
@TomChv
TomChv force-pushed the monorepo-subdir-config-checks branch from 9781f84 to 4185901 Compare August 20, 2026 16:12
@TomChv
TomChv merged commit 3344489 into main Aug 21, 2026
32 checks passed
eunomie added a commit to grouville/php-sdk that referenced this pull request Aug 21, 2026
The committed lock was still in the v1 format, whose `float` entry the current
CLI no longer honors: every run silently re-resolved sdk-sdk to whatever main
pointed at and rewrote the file. Recording it in v2 makes the revision the
checks actually run against explicit again.

Pinning it here also matters for what it contains. The old entry named
`e1747f4`, which still declared `daggerCliVersion = "1.0.0-beta.9"`, and a
beta.9 CLI cannot drive a beta.10 engine — beta.10 moved registering a
function's required `Workspace` argument as a CLI flag out of the engine and
into the CLI, so the older CLI never sees `initModule` and the contract checks
fail with `unknown command "init-module"`. dagger/sdk-sdk#14 fixed that pin,
and dagger/sdk-sdk#17 then added the `monorepo` group, which drives a workspace
whose dagger.toml sits in a git subdirectory — the layout where module paths
cross the engine/SDK boundary root-relative while the selected config reads
them relative to itself. That is exactly what this module's path anchoring has
to get right, so it is worth being on.

Signed-off-by: Yves Brissaud <yves@dagger.io>
eunomie added a commit to grouville/php-sdk that referenced this pull request Aug 21, 2026
The committed lock was still in the v1 format, whose `float` entry the current
CLI no longer honors: every run silently re-resolved sdk-sdk to whatever main
pointed at and rewrote the file. Recording it in v2 makes the revision the
checks actually run against explicit again.

Pinning it here also matters for what it contains. The old entry named
`e1747f4`, which still declared `daggerCliVersion = "1.0.0-beta.9"`, and a
beta.9 CLI cannot drive a beta.10 engine — beta.10 moved registering a
function's required `Workspace` argument as a CLI flag out of the engine and
into the CLI, so the older CLI never sees `initModule` and the contract checks
fail with `unknown command "init-module"`. dagger/sdk-sdk#14 fixed that pin,
and dagger/sdk-sdk#17 then added the `monorepo` group, which drives a workspace
whose dagger.toml sits in a git subdirectory — the layout where module paths
cross the engine/SDK boundary root-relative while the selected config reads
them relative to itself. That is exactly what this module's path anchoring has
to get right, so it is worth being on.

Signed-off-by: Yves Brissaud <yves@dagger.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant