Repository navigation
Description
Severity
dagger generate deletes a module's entire directory, including hand-written src/, with exit 0 and no output. A second generate re-scaffolds src/index.ts from the template, so the tree looks healthy afterwards while the user's code is gone.
The trigger — an sdk/ directory inside the module — is exactly what a module migrating off the pre-1.0 embedded layout has.
Reproduced independently twice, on main @ d97f678, engine v1.0.0-beta.16.
Repro (5 lines from a clean, committed tree)
dagger init -y && dagger install dagger.io/sdk/typescript@main
dagger module init typescript --name app -y
mkdir .dagger/modules/app/sdk && echo user > .dagger/modules/app/sdk/notes.txt
git add -A && git commit -m plant # tree clean
dagger generate -y # exit 0, "✔ 1 passed", prints nothing
git status --porcelain D .dagger/modules/app/__dagger.dispatch.ts
D .dagger/modules/app/clients/dagger/client.gen.ts
D .dagger/modules/app/clients/dagger/core.d.ts
D .dagger/modules/app/clients/dagger/core.js
D .dagger/modules/app/clients/dagger/index.ts
D .dagger/modules/app/clients/dagger/package.json
D .dagger/modules/app/clients/dagger/telemetry.ts
D .dagger/modules/app/clients/loader.gen.ts
D .dagger/modules/app/dagger-module.toml
D .dagger/modules/app/entrypoint/main.dang
D .dagger/modules/app/package.json
D .dagger/modules/app/sdk/notes.txt
D .dagger/modules/app/src/index.ts
D .dagger/modules/app/tsconfig.json
.dagger/modules/app/ no longer exists on disk. --no-apply previews this as .dagger/ -1 / 1 file changed, -1 lines — it names nothing and understates it by 13 files.
Where it comes from
moduleFiles() → prunedEmbeddedSdk() (typescript-sdk.dang), which does
ws.withoutDirectory("/" + moduleSdkPath(sourcePath)) to clean up the pre-1.0 layout.
The engine primitive is not at fault — a direct probe keeps siblings correctly:
dagger -c 'current-workspace | without-directory /a/b/target | directory /a | glob "**"'
# -> b/keepme.txt, sibling/, top.txt all retainedA second prune site has the same blast radius: a legacy .dagger/core/old.txt triggers
withoutLegacyWorkspaceCore() and the whole of .dagger/ goes, modules included. Two call sites, one symptom — this looks like a composition bug in moduleFiles/the prune helpers rather than a typo in either.
Blast radius is pinned:
| Shape | Result |
|---|---|
sdk/ at the workspace root, no module |
nothing deleted |
module installed at scope "." |
only sdk/notes.txt deleted — src/index.ts and unrelated files survive |
module at a nested scope (the normal .dagger/modules/app) |
whole module directory deleted |
a file named sdk, or lib/ sdks/ dist/ |
left alone |
The root-vs-nested split is the clue: with scope "." the path has no parent to clobber.
Related
prunedEmbeddedSdk was already flagged as a follow-up when #75 landed the ownership rule for clients/ — it is the one prune site that still removes a directory wholesale. The fix is presumably the same shape: remove only what the SDK generated, and only empty directories.
Suggested regression tests
sdk/directory inside a module → generate removessdk/and nothing else.- Legacy
.dagger/core/present → generate does not touch.dagger/modules/*. - Plant a user file in every generated directory (
sdk/,clients/,entrypoint/,src/, module root), regenerate, assert nothing disappears.
Found during a full verification sweep of @main; repros kept at verify/wild/w15f-default, w15e-1, w15e-2, w15e-3, w15g-engine in the playground worktree.
Activity
TomChv commentedon Oct 12, 2026
Third site with the same shape, found in the same sweep: flipping
legacyRuntimedeletes user files.With
legacyRuntime = trueset on an entrypoint module and a regenerate, a user'sclients/my-helper.tsandentrypoint/MY-NOTES.mdare both deleted. Exit 0, nothing printed. Removing the directories is documented intent for a layout flip; taking the user's files with them unnamed is not.So the fix wants to cover all three:
prunedEmbeddedSdk,withoutLegacyWorkspaceCore, and the flip path's directory removal — same rule as #75 gaveclients/: remove only what the SDK generated, and a directory only once it is empty. Repro:verify/wild/w16-flip.TomChv commentedon Oct 13, 2026
Correction: the whole-module deletion is an engine bug, already fixed in beta.17
I wrote this issue against engine v1.0.0-beta.16. Re-running the same repro on v1.0.0-beta.17, from a clean committed tree with an extra
src/mine.tsplanted:Only the user's file inside
sdk/is lost.src/and the module directory survive. Verified independently twice, and the agent fixing this reproduced the same on beta.17 at two different scope depths.So the catastrophic half — the whole module directory, including hand-written source — was an engine bug between beta.16 and beta.17, not the SDK, and it is already gone. The SDK bug that remains is real but confined: a wholesale
withoutDirectorytakes the user's files with the generated ones, insdk/,.dagger/core/, andentrypoint/(whereMY-NOTES.mdis still lost on alegacyRuntimeflip —clients/is already safe thanks to #75).Severity is therefore data loss, scoped to a file a user placed in a generated directory — not "a plain
generatedestroys your module". The "do not tag without this" line in my original report was wrong on beta.17; apologies for the alarm.Fix in #99, which applies #75's ownership rule to the three remaining sites.
fix: prune only the files this SDK generated, never the directory aro…
fix: prune only the files this SDK generated, never the directory aro…
refactor: generate the dispatcher inside entrypoint/, not at the modu…
refactor: generate the dispatcher inside entrypoint/, not at the modu…