Skip to content

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

Merged
TomChv merged 3 commits into
dagger:mainfrom
grouville:polyfill-removal
Aug 26, 2026
Merged

TomChv merged 3 commits into
dagger:mainfrom
grouville:polyfill-removal

Conversation

@grouville

@grouville grouville commented Aug 7, 2026 •

Copy link
Copy Markdown
Member

The Deno module uses dagger/polyfill to choose projects and workspace members relative to where Dagger was started. From above a workspace it should see the members below; from inside a project it should select the nearest enclosing project.

Workspace.findRoots in dagger/dagger#13854 is the native version of those rules, shipped in v1.0.0-beta.10. This PR uses it directly and removes the wrapper. Deno installation, permissions, formatting, and dependency behavior do not change.

The helper was called findConfigDirs while it was in review; it shipped as findRoots, taking markers instead of filenames. The contract is unchanged.

Three patches:

1. Drop the polyfill for the engine's findRoots. The call swap, the engineVersion bump, and the dependency removal, together. The e2e harness moves to the same version — it still declared v1.0.0-beta.6, so it would have exercised the module under test through an older schema view than the one it ships against.

2. Resolve discovered project roots from the workspace root. findRoots answers relative to the caller — "." for its own directory, ".." for an enclosing project — and the module read those back as if they were workspace-root-relative. From anywhere but the workspace root that names a directory that does not exist:

$ cd .dagger/modules/e2e/modules
$ dagger -m ../../.. call project --path hello workspace-root
workspace directory ".dagger/modules/e2e/modules/.dagger/modules/e2e/modules/hello": ... no such file or directory

This predates the migration and reproduces identically on main at v1.0.0-beta.6; it is fixed here because the native call inherits the same contract. Resolving discovery once is also what lets findWorkspaceRoot walk above the caller: from inside a member the enclosing workspace root is an ancestor, and discovery never sees it from below, so projects resolves each project's workspace root by walking up rather than from the roots it happened to discover. Without that a member is mounted as a standalone project and its cross-member imports do not resolve.

The caller's location still decides one thing: the CLI applies a generator's changeset from where the caller stands, so the generators key their directories there instead of at the workspace root.

3. Migrate the lockfile to the v2 format. v1.0.0-beta.10 writes lockfile format v2, so the first command run against the engine this module now requires rewrites dagger.lock. Landing it here keeps that churn out of the next unrelated change. It is not only a format bump: v1 recorded one floating git.head for dang-sdk, while v2 records the resolved git.ref plus a digest for every container.from the checks reach, so the deno and debian base images are now pinned by digest rather than re-resolved per run. The dang-sdk entry moves from 6c63cd0 to 5da2636 because the old pin floated and 5da2636 is where main sits today.

Test

dagger check

All 17 checks pass, including workspaces, subdirectories, permissions, installs, formatting, dependencies, and legacy Deno versions.

subdir-discovery-check is new and covers patch 2 from inside a workspace member: the lookup, the root above the caller surviving being mounted (the cross-member @ws/util import only resolves from there), the fan-out verbs, and the changeset keying. It fails without patch 2 with stat add/add: no such file or directory. The changeset-rooting behavior was confirmed against the CLI by applying a formatAll from a subdirectory and checking which file it landed on.

The lockfile in patch 3 is what that same dagger check writes; a second run reproduces it byte for byte.

The engine now ships Workspace.findRoots (dagger/dagger#13854): the
same cwd-aware project discovery this module got from
github.com/dagger/polyfill — 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 helper was called findConfigDirs while it was in review; it shipped
in v1.0.0-beta.10 as findRoots, taking markers instead of filenames.
The contract is unchanged: cwd-relative paths for the caller's own
project and everything below it, plus the nearest enclosing project as
a ".."-relative path, so inCone still tells the two apart.

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. The e2e harness moves to the same
version — it still declared v1.0.0-beta.6, which would have exercised
the module under test through an older schema view than the one it
ships against.

Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
@TomChv
TomChv marked this pull request as ready for review August 26, 2026 11:22
@TomChv
TomChv self-requested a review August 26, 2026 11:22
findRoots answers relative to the caller — "." for its own directory, ".."
for an enclosing project — and the module read those back as if they were
workspace-root-relative. From anywhere but the workspace root that names a
directory that does not exist, so every command driving discovery or a
lookup failed:

    $ cd .dagger/modules/e2e/modules
    $ dagger -m ../../.. call project --path hello workspace-root
    workspace directory ".dagger/modules/e2e/modules/.dagger/modules/e2e/modules/hello":
      ... no such file or directory

This predates the migration and reproduces identically on main at
v1.0.0-beta.6; the native call inherits the polyfill's contract, so fix it
where that contract is read. Discovery resolves each hit once, and reads go
through workspace-absolute paths, which is also what lets findWorkspaceRoot
walk above the caller: from inside a member the enclosing workspace root is
an ancestor, and only a walk terminating at "." can reach it. Discovery
alone never sees that root — it is out of range from below — so `projects`
resolves each project's workspace root by walking up rather than from the
roots it happened to discover. Without it a member is mounted as a
standalone project and its cross-member imports do not resolve.

The caller's location still decides one thing: the CLI applies a
generator's changeset from where the caller stands, so the generators key
their directories there instead of at the workspace root. Verified by
applying one from a subdirectory and confirming it landed on the intended
file.

subdir-discovery-check covers all of it from inside a workspace member: the
lookup, the root above the caller surviving being mounted (the cross-member
@ws/util import only resolves from there), the fan-out verbs, and the
changeset keying. It fails without this patch with "stat add/add: no such
file or directory".

Signed-off-by: Tom Chauveau <[email protected]>
@TomChv TomChv changed the title Drop the polyfill for the engine's findConfigDirs Drop the polyfill for the engine's findRoots Aug 26, 2026
v1.0.0-beta.10 writes lockfile format v2, so the first command run against
the engine this module now requires rewrites dagger.lock. Landing it here
keeps that churn out of the next unrelated change.

The migration is not only a format bump. v1 recorded one floating
git.head for dang-sdk; v2 records the resolved git.ref plus a digest for
every container.from the checks reach, so the deno and debian base images
are now pinned by digest rather than re-resolved per run. The dang-sdk
entry moves from 6c63cd0 to 5da2636 because the old pin floated and
5da2636 is where main sits today.

Generated by running dagger check, which reaches every lookup recorded
here; a second run reproduces the file byte for byte.

Signed-off-by: Tom Chauveau <[email protected]>
@TomChv
TomChv merged commit 3ea584c into dagger:main Aug 26, 2026
18 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.

2 participants