Skip to content

Drop the polyfill for the engine's findRoots - #42

Merged
eunomie merged 4 commits into
dagger:mainfrom
grouville:polyfill-removal
Aug 26, 2026
Merged

eunomie merged 4 commits into
dagger:mainfrom
grouville:polyfill-removal

Conversation

@grouville

@grouville grouville commented Aug 7, 2026 •

Copy link
Copy Markdown
Member

The Go module used dagger/polyfill for one job: choosing which Go projects are in scope when a command runs. From a repository root it should find projects below; from inside a project it should select the nearest enclosing go.mod.

Workspace.findRoots in dagger/dagger#13854 is the native form of that behavior, shipped in v1.0.0-beta.10. Replacing the wrapper with findRoots(markers: ["go.mod"]) keeps the module's user-facing selection rules in one engine call.

Four patches:

1. Drop the polyfill for the engine's findRoots. The call swap, the engineVersion bump, and the dependency removal, together.

2. Move the e2e module to Dang v2 and the engine under test. The harness still declared engineVersion = "v0.20.6", which pins it to Dang v1 semantics where .{ } is a GraphQL selection; Dang v2 spells that .{{ }}. go.dang was migrated in 538bb62 but the module that tests it was left behind, so it was exercising the module through an older language and schema view than the one it ships against. Under v2 a stray .{ x } resolves x in the enclosing scope instead of on the element, which is how the wrong pin turns into confusing "not found" errors rather than an honest failure.

This also deletes .dagger/modules/e2e/dagger.json. When both files are present the TOML wins, so that file's engineVersion: v1.0.0-beta.9 read as a version pin without being one.

3. Resolve discovered module roots from the workspace cwd. findRoots answers relative to the workspace cwd — "." for the cwd itself, ".." for an enclosing project — while every other path this module handles is workspace-root-relative. Discovery has been cwd-relative since 4533f42 adopted the polyfill's findConfigDirs, whose comment already called for this resolution but never did it, so any command driving discovery failed outside the workspace root:

$ cd fixtures/go-module-with-nested-module
$ dagger -m ../.. call test-all
stat _root_.inc: no such file or directory

This predates the migration and reproduces identically on main; it is fixed here because the native call inherits the same contract, and because the comment this PR removes was the only record of it.

4. Cover regenerating a module whose output already exists. Every generate fixture here started without its generated file, so the suite only ever exercised a first run — and a changeset built against an empty baseline is indistinguishable from a correct one in that case, since both report the generated file as added. They diverge only on the second run. This adds a fixture whose generated output is committed and current, and asserts that regenerating it reports nothing at all.

Test

dagger check

Bare dagger check with no pattern, which dagger check -l confirms is the full set. All checks pass, including the two new ones. discovery-from-subdir-check runs discovery from a module root and from a directory inside a module, then mounts and tests the module it found; it fails without patch 3 (discovery from a module root missed that module). regenerate-check fails in both directions — re-added if the changeset baseline stops seeing files that exist on disk, rewrote if generation is not idempotent. Each patch in the stack was verified green on its own.

grouville and others added 3 commits August 21, 2026 10:44
The engine now ships Workspace.findRoots (dagger/dagger#13854): the same
cwd-aware project discovery this module got from github.com/dagger/polyfill
as findConfigDirs — same semantics, ported from the polyfill's own design
and test matrix. Swap the call, drop the dependency, and require the engine
release that ships it.

The engineVersion bump and the dependency removal have to land together:
the version gate is what keeps the engine's new changeset behavior scoped
to migrated modules.

Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Yves Brissaud <[email protected]>
The e2e module still declared engineVersion v0.20.6, which pins it to Dang
v1 semantics where `.{ }` is a GraphQL selection. Dang v2 spells that
`.{{ }}`; go.dang was migrated in 538bb62 but the harness that exercises it
was left behind, so it kept testing the module through an older language
and schema view than the one it ships against.

Declare the release the module now requires and convert the selections.
This also brings withWorkdir and the rest of the v1.0.0 Workspace surface
into reach for checks.

The dagger.json alongside dagger-module.toml is dead: the TOML wins when
both are present, so its stale v1.0.0-beta.9 engineVersion only reads as a
version pin that isn't one. Drop it.

Signed-off-by: Yves Brissaud <[email protected]>
findRoots answers relative to the workspace cwd: "." for the cwd itself,
".." for an enclosing project. Every other path this module handles is
workspace-root-relative, so a module root discovered from a subdirectory
named a directory that does not exist.

The result was that any command driving discovery failed outside the
workspace root. From fixtures/go-module-with-nested-module:

    $ dagger -m ../.. call test-all
    stat _root_.inc: no such file or directory

Discovery has been cwd-relative since 4533f42 adopted the polyfill's
findConfigDirs, whose comment already called for this resolution; the
engine's findRoots keeps the same contract, so resolve the results here.

Signed-off-by: Yves Brissaud <[email protected]>
@eunomie eunomie changed the title Drop the polyfill for the engine's findConfigDirs Drop the polyfill for the engine's findRoots Aug 21, 2026
Every generate fixture here starts without its generated file, so the suite
only ever exercised a first run. A changeset built against an empty baseline
looks identical to a correct one in that case: both report the generated
file as added. The two diverge only on the second run, which nothing covered.

Add a fixture whose generated output is committed and current, and assert
that regenerating it reports no changes at all — not added, modified, or
removed. The check fails in both directions: it reports "re-added" when the
baseline stops seeing files that exist, and "rewrote" when generation is not
idempotent.

Signed-off-by: Yves Brissaud <[email protected]>
@eunomie
eunomie marked this pull request as ready for review August 24, 2026 14:22
@eunomie
eunomie merged commit 8d29418 into dagger:main Aug 26, 2026
14 checks passed
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.

3 participants