Repository navigation
workspace: add native polyfill replacements - #13854
Merged
Merged
Conversation
This was referenced Aug 7, 2026
grouville
marked this pull request as draft
August 7, 2026 09:47
grouville
force-pushed
the
polyfill-workspace-apis
branch
from
August 11, 2026 22:59
2a3953f to
4ae5a11
Compare
grouville
force-pushed
the
polyfill-workspace-apis
branch
2 times, most recently
from
August 12, 2026 06:22
3819203 to
03db422
Compare
eunomie
approved these changes
Aug 12, 2026
eunomie
left a comment
Member
There was a problem hiding this comment.
Looks good to me.
I haven't manually tried the new API, but the API feels nice. We also discussed the API live.
I love the fix on latest for engineVersion :-) I experienced the issue before and wanted to fix it, but happy it's done 🙏
grouville
force-pushed
the
polyfill-workspace-apis
branch
from
August 13, 2026 01:40
03db422 to
982491c
Compare
grouville
marked this pull request as draft
August 13, 2026 07:32
Projects are commonly identified by marker files such as go.mod or package.json. SDKs need one consistent rule: find marked projects below a starting directory and include the nearest enclosing project when invoked from inside it. Add that cwd-aware rule as a convenience over glob and findUp. Results are cwd-relative, and exclude patterns prune vendored trees from the downward search. Integration tests cover root and subdirectory calls, explicit starts, ancestors, exclusions, multiple markers, and invalid marker names. Signed-off-by: Guillaume de Rouville <[email protected]>
ModuleSource resolves "latest" before using a module. Config edits then wrote that resolved version back, silently turning a floating config into a pin. Keep the declared value separately for serialization while continuing to use the resolved value for compatibility checks. Tests cover unrelated edits, selecting "latest", and selecting a concrete version. Signed-off-by: Guillaume de Rouville <[email protected]>
grouville
force-pushed
the
polyfill-workspace-apis
branch
from
August 14, 2026 02:27
6b33a2d to
55f69ab
Compare
dagger.toml already records the modules managed by each installed SDK, so SDKs should not rediscover them by scanning config files. Filter CurrentModule.asSDK(workspace).modules using the supplied workspace cwd: return every managed module at or below it, plus the nearest enclosing module when needed. Unit tests cover root, module, nested, unrelated, and duplicate paths. Signed-off-by: Guillaume de Rouville <[email protected]>
grouville
force-pushed
the
polyfill-workspace-apis
branch
from
August 14, 2026 05:12
279775a to
671495b
Compare
Loading a workspace-backed module with a local dependency previously failed when requester context was lost. That engine fix already exists; add the missing end-to-end regression from issue dagger#13139 so SDK generation cannot reintroduce it. Released SDKs still call generateLocalDependencies while loading. Keep that field visible until the official SDK migrations ship, and record the removal condition beside the field. Signed-off-by: Guillaume de Rouville <[email protected]>
Refresh the checked-in clients, GraphQL schema, and reference documentation for Workspace.findRoots and cwd-scoped CurrentModuleAsSDK.modules. Signed-off-by: Guillaume de Rouville <[email protected]>
grouville
force-pushed
the
polyfill-workspace-apis
branch
from
August 14, 2026 05:21
671495b to
4ca0b92
Compare
The Workspace API additions change the generated reference input. Refresh the checked-in schema so docs:references is clean. Signed-off-by: Guillaume de Rouville <[email protected]>
grouville
marked this pull request as ready for review
August 14, 2026 07:48
The module loader accepts "latest" as an input and resolves it to the current engine version. Keep that behavior when writing configs so modules remain pinned and reproducible. Workspace module initialization had started writing the literal value. Write the current concrete version instead, and cover both initialization and later config edits. Signed-off-by: Guillaume de Rouville <[email protected]>
Member
Author
eunomie
pushed a commit
to grouville/php-sdk
that referenced
this pull request
Aug 21, 2026
The behaviors this module leaned on `dagger/polyfill` for now live in the engine: dagger/dagger#13854 added the native workspace and module-source APIs, and #13855 gave `Workspace.changes` an explicit baseline. Module discovery goes through `currentModule.asSDK(workspace: ws).modules`, which returns the modules registered to this SDK that are relevant to the client's cwd. The engine owns both membership and the cwd policy, so the SDK no longer scans for config files or rebases discovery results by hand — the `findConfigDirs` walk and its `workspacePath` helper go away with it. Changesets follow the baseline-diff shape the native APIs were designed for: stage onto the workspace value already in hand, then diff against it. No workspace fork is involved, because none is needed. `ModuleSource.generate` is what produces a module's generated context — it stages the module's local dependency closure first, applies only that module's own output, and keeps the caller's workspace as the baseline, so the resulting changeset is rooted at the client's cwd. `generateAll` folds the per-module changesets together with `changeset.withChangesets`. Staging paths anchor at "/" because the native workspace resolves a relative path from the cwd, where the polyfill's took workspace-root paths. `Workspace.withNewDirectory` is not a drop-in for the polyfill fork's `withDirectory`: on a host-backed workspace the edit lands on an empty delta base and is then diffed against the host tree, so whatever already sat at that path is reported as removed. The polyfill's merged instead. init has to layer the template onto the existing contents itself, or `dagger module init` into a directory a user already has files in deletes them. sdk-sdk's `contract:does-not-remove-existing-files` only inits into an empty path and cannot catch that, so `e-2-e:init-layering-check` covers it here. The engineVersion bump and the dependency removal land together: the version gate scopes the engine's new changeset rooting to migrated modules. Signed-off-by: Guillaume de Rouville <[email protected]> Signed-off-by: Yves Brissaud <[email protected]>
eunomie
pushed a commit
to grouville/go
that referenced
this pull request
Aug 21, 2026
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]>
eunomie
pushed a commit
to grouville/php-sdk
that referenced
this pull request
Aug 21, 2026
The behaviors this module leaned on `dagger/polyfill` for now live in the engine: dagger/dagger#13854 added the native workspace and module-source APIs, and #13855 gave `Workspace.changes` an explicit baseline. Module discovery goes through `currentModule.asSDK(workspace: ws).modules`, which returns the modules registered to this SDK that are relevant to the client's cwd. The engine owns both membership and the cwd policy, so the SDK no longer scans for config files or rebases discovery results by hand — the `findConfigDirs` walk and its `workspacePath` helper go away with it. Changesets follow the baseline-diff shape the native APIs were designed for: stage onto the workspace value already in hand, then diff against it. No workspace fork is involved, because none is needed. `generateAll` folds the per-module changesets together with `changeset.withChangesets`. Generation would read as `ModuleSource.generate(ws).changes(ws)`, which is what #13855 built the pair for. On v1.0.0-beta.10 that pair does not hold its baseline: once a module's generated files already exist, it reports the whole generated context as added rather than only what generation changed — deleting one file and regenerating returned 279 paths instead of 1, including the engine-owned dagger-module.toml. So generation stages the local dependency closure itself, takes the module's `generatedContextChangeset`, and re-roots that at the caller's cwd explicitly, which is the shape the polyfill produced. `Mod.atCwd` carries the reason and the engine version, so it can go once the engine holds the baseline. Staging paths anchor at "/" because the native workspace resolves a relative path from the cwd, where the polyfill's took workspace-root paths. `Workspace.withNewDirectory` is not a drop-in for the polyfill fork's `withDirectory`: on a host-backed workspace the edit lands on an empty delta base and is then diffed against the host tree, so whatever already sat at that path is reported as removed. The polyfill's merged instead. init has to layer the template onto the existing contents itself, or `dagger module init` into a directory a user already has files in deletes them. sdk-sdk's `contract:does-not-remove-existing-files` only inits into an empty path and cannot catch that, so `e-2-e:init-layering-check` covers it here. The engineVersion bump and the dependency removal land together: the version gate scopes the engine's new changeset rooting to migrated modules. Signed-off-by: Guillaume de Rouville <[email protected]> Signed-off-by: Yves Brissaud <[email protected]>
TomChv
added a commit
to dagger/typescript-sdk
that referenced
this pull request
Aug 21, 2026
* Drop the polyfill for native workspace APIs The TypeScript SDK depended on `dagger/polyfill` for three things: selecting the modules it manages, forking the workspace to stage edits, and re-rooting the resulting changeset into the client's cwd. All three are now native in the engine (dagger/dagger#13854, dagger/dagger#13855), so the dependency goes. Signed-off-by: Tom Chauveau <[email protected]>
TomChv
pushed a commit
to grouville/vitest
that referenced
this pull request
Aug 26, 2026
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 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: Tom Chauveau <[email protected]>
TomChv
pushed a commit
to grouville/deno
that referenced
this pull request
Aug 26, 2026
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
pushed a commit
to dagger/vitest
that referenced
this pull request
Aug 26, 2026
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 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: Tom Chauveau <[email protected]>
TomChv
added a commit
to dagger/deno
that referenced
this pull request
Aug 26, 2026
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. 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, 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". Migrate the lockfile to the v2 format Signed-off-by: Guillaume de Rouville <[email protected]> Co-authored-by: Tom Chauveau <[email protected]>
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.


dagger/polyfillcurrently provides two pieces of workspace logic that belong in the engine. This PR adds their native replacements without changing how changesets work.Workspace.findRootsfinds projects from marker files such asgo.modorpackage.json. It searches below the workspace cwd, includes the nearest enclosing project, and prunes excluded trees.globremains the lower-level API for callers that only need path matching.SDKs do not need to scan the filesystem for Dagger modules. Those modules are already registered in
dagger.toml, socurrentModule.asSDK(workspace: ws).modulesreturns the registered module objects relevant to the workspace cwd.The PR also preserves a literal
engineVersion: "latest"when editing module configuration and adds the missing regression test for loading local dependencies throughWorkspace.moduleSource.Review
The main question is the API boundary:
findRootsdiscovers ordinary projects from files, whileasSDK.modulesreads the Dagger modules already registered for that SDK.Test
#13855 builds on this with workspace generation and explicit changeset comparison.