Skip to content

fix: scope module generation to the module path#5

Open
TomChv wants to merge 1 commit into
mainfrom
fix/module-generate-scope-to-path
Open

fix: scope module generation to the module path#5
TomChv wants to merge 1 commit into
mainfrom
fix/module-generate-scope-to-path

Conversation

@TomChv

@TomChv TomChv commented Jul 23, 2026

Copy link
Copy Markdown
Member

PolyfillModuleSource.generate rooted the generated context and the fork at the caller cwd. In a module subdirectory that's fine (the cwd is the module). But at the workspace root (cwd = ".") it captured the whole workspace — including any staged dependency codegen — in the changeset's before/after snapshots.

When several modules are generated and their changesets merged (e.g. a root dagger generate running the Go and TypeScript SDK generators), the staged dependency codegen leaks across modules:

  • a dependency's codegen appears in another module's before snapshot and cancels out (goes missing from the output), or
  • the octopus merge unions those polluted befores and then conflicts on apply (.dagger/modules/b/... already exists).

Fix

Root the generated context at the module's own path and stage it on an empty fork base, so each module's changeset contains only its own files. Behavior is unchanged for a subdir cwd (there path == cwd).

This unblocks ModuleSource.generateLocalDependencies (dagger/dagger#13706) for the multi-module / workspace-root case.

PR chain

The two SDK PRs depend on both the engine PR and the polyfill PR. The engine and polyfill PRs are independent of each other.

TomChv added a commit to dagger/typescript-sdk that referenced this pull request Jul 23, 2026
Temporary: point the polyfill dependency at
fix/module-generate-scope-to-path (dagger/polyfill#5) so multi-module /
workspace-root generate works. Revert to @main once that PR merges.

Signed-off-by: Vasek - Tom C <tom@dagger.io>
TomChv added a commit to dagger/go-sdk that referenced this pull request Jul 23, 2026
Temporary: point the polyfill dependency at
fix/module-generate-scope-to-path (dagger/polyfill#5) so multi-module /
workspace-root generate works. Revert to @main once that PR merges.

Signed-off-by: Vasek - Tom C <tom@dagger.io>
PolyfillModuleSource.generate rooted the generated context and fork at the
caller cwd. At the workspace root (cwd '.') that captured the whole
workspace — including any staged dependency codegen — in the changeset's
before/after snapshots. When several modules are generated and their
changesets merged (e.g. a root 'dagger generate'), the staged dependencies
leak across modules: they cancel out (a dependency's codegen goes missing)
or conflict on apply ('already exists').

Root the generated context at the module's own path and stage it on an
empty fork base, so each module's changeset contains only its own files.
Unchanged for a subdir cwd, where path already equals the cwd.

Signed-off-by: Vasek - Tom C <tom@dagger.io>
@TomChv
TomChv force-pushed the fix/module-generate-scope-to-path branch from c2a9322 to 4357bc1 Compare July 23, 2026 14:21
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