Repository navigation
fix: prune only the files this SDK generated, never the directory around them - #99
Merged
Merged
Conversation
…und them Three prune sites took a directory whole. A file the user had put inside one went with it, and on an engine before v1.0.0-beta.17 so did the directory around it: an `sdk/` left over from the embedded layout deleted the module it sat in — hand-written `src/` included — with exit 0 and nothing printed (issue #87). The rule #75 gave `clients/` now covers all three: remove what this SDK generated and nothing else, and take a directory only once the removals leave nothing in it. - `ownedClientFiles` becomes `ownedFiles`, and its bundle rule is read per directory — the bundle files are ours beside a `client.gen.ts`, wherever that sits, which is what makes `clients/dagger`, the embedded `sdk/` and the old `.dagger/core/typescript` the same shape. `clients/` is unaffected: it has no `client.gen.ts` of its own. - `prunedFiles` is the removal half on its own, for a directory whose owned set is known by name rather than by shape: a module's `entrypoint/`, which holds the generated Dang program. - `prunedEmbeddedSdk`, `withoutLegacyWorkspaceCore` and the `entrypoint/` removal in `prunedInactiveDispatch` go through it. Their intent is kept — an all-generated directory still goes whole, rather than lingering as a husk of the layout the module left. Signed-off-by: Tom Chauveau <[email protected]>
TomChv
force-pushed
the
fix/prune-only-generated-87
branch
from
October 13, 2026 11:50
3d361a3 to
c815b07
Compare
This was referenced Oct 13, 2026
TomChv
added a commit
that referenced
this pull request
Oct 19, 2026
…le (#110) `dagger generate` deleted a user's directory. Any direct child of a TypeScript scope that holds a file named after it — types/types.gen.ts, api/api.gen.ts, graphql/graphql.gen.ts, the layout an openapi or graphql codegen writes — was removed whole, every file of the user's in it, exit 0 and nothing printed. prunedClientPackages migrates the layout that wrote each client as a package at the scope root, and it recognized one by that marker alone and took the directory with withoutDirectory. It was the last wholesale removal over a path whose contents are not all this SDK's: #99 made every sibling prune ownership-based — prunedOwnedFiles, prunedFiles, prunedEmbeddedSdk, withoutLegacyWorkspaceCore — and this one was outside that scope. Its own docstring and the README already claimed the rule it did not follow. Route it through prunedFiles with the set ownedFiles claims, the same rule the siblings use: the generated files go, and the directory follows only once nothing is left in it. Ownership is read from a synthetic parent because ownedFiles knows a package's manifest as <name>/package.json, the depth the layout gave it — so an all-generated package still goes whole, manifest included, rather than lingering as a husk. Both call sites are covered by a check that fails without the fix: a module scope on the entrypoint path, and a client-only scope. Each asserts the resulting tree, and each asserts the other half too, so the intent survives. Signed-off-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.
Problem
An
sdk/directory inside a module madedagger generatedelete files the userowns, with exit 0 and nothing printed. On the engine the issue was filed against
(
v1.0.0-beta.16) it took the whole module directory — hand-writtensrc/, themanifest, everything — and a second generate re-scaffolded
src/index.tsfromthe template, so the tree looked healthy afterwards while the user's code was
gone. On
v1.0.0-beta.17, which this SDK pairs with, the blast radius is theremoved directory itself:
sdk/notes.txtgoes unnamed.Two more sites had the same shape: a legacy
.dagger/core/took everythingunder it (and, pre-beta.17, the
.dagger/around it, modules included), andflipping
legacyRuntimeon deleted a user's file inclients/andentrypoint/.Fixes #87
Root cause
Three sites removed a directory wholesale instead of removing what this SDK had
written into it (line numbers on
main@ d97f678,typescript-sdk.dang):prunedEmbeddedSdk:2012—ws.withoutDirectory("/" + moduleSdkPath(sourcePath)), the reported casewithoutLegacyWorkspaceCore:435—ws.withoutDirectory("/" + scopeFile(cfg, ".dagger/core"))prunedInactiveDispatch:1833—withoutDispatcher.withoutDirectory(prefix + dangEntrypointDir), thelegacyRuntimeflipThe engine primitive is not at fault:
withoutDirectoryon a nested path keepsits siblings. #75 had already solved this class for
clients/—ownedFiles(then
ownedClientFiles) decides ownership by shape andprunedOwnedFilesremoves owned-minus-rendered, taking a directory only once nothing is left in
it — and
prunedEmbeddedSdkwas the follow-up that PR named.Fix
Same rule, applied to all three:
ownedClientFiles→ownedFiles, with its bundle rule read per directory:the bundle files are ours beside a
client.gen.ts, wherever that sits. Thatis the one shape
clients/dagger, the embeddedsdk/and the old.dagger/core/typescriptshare.clients/behaviour is unchanged — it holdsno
client.gen.tsof its own, onlydagger/client.gen.ts.prunedFilesis the removal half on its own, for a directory whose owned setis known by name rather than by shape: a module's
entrypoint/, which holdsthe generated Dang program and nothing else.
directory still goes whole rather than lingering as a husk of the layout the
module left.
Verification
Engine
v1.0.0-beta.17throughout.Reproduced on unmodified
main, as the issue describes (scratch workspaceon this SDK, a module scope at
verify/app,sdk/notes.txt+sdk/client.gen.tsplanted and committed,
dagger generate -y): exit 0, nothing printed, andThe whole-module variant did not reproduce on beta.17 — that half was an engine
bug fixed between beta.16 and beta.17. The SDK-level data loss is what remains,
and is what this fixes.
Same workspace with the fix — two module scopes (
verify/app,.dagger/modules/deep) plus a planted legacy.dagger/core:verify/app/sdk/notes.txt,.dagger/modules/deep/sdk/notes.txt,.dagger/core/notes.txtand every.dagger/modules/*survive.New regression checks (
.dagger/modules/e2e/generate.dang), each redwithout the fix — proven on a scratch copy of this branch with
typescript-sdk.dangreverted toorigin/main:generate:generate-keeps-user-files-in-sdk-dir-checka user's file in a module's sdk/ must survive the move onto an entrypoint, kept [...]— nosdk/in the tree at allgenerate:generate-prunes-legacy-workspace-core-checkgeneration took .dagger/core whole, with a user's file in it, got removed [.dagger/core/]generate:generate-flips-back-keeps-user-files-checka user's file in a module's entrypoint/ must survive the flip, kept [...]Each asserts the resulting tree, not only the changeset, and each also asserts
the intent that was there: the emptied
sdk/,.dagger/core/typescript/,clients/dagger/andentrypoint/still go.Runs (all green,
check -m .dagger/modules/e2e):generate:generate-check,generate:generate-idempotent-check,generate:generate-prunes-entrypoint-check,generate:generate-keeps-user-files-in-clients-dir-check,generate:generate-flips-back-to-runtime-check,generate:generate-flips-back-with-client-check+ the three new — 9 passedclient:*— 13 passedgenerate:generate-prunes-stale-bindings-check,generate:generate-workspace-module-check,generate:generate-compat-shim-pruned-check,generate:generate-every-scope-check,generate:generate-source-edit-is-scoped-check— 5 passedNot covered
init:*,runtimes:*,manifest:*,discovery:*,sdk:*,registry:*); nothing in those paths touches pruning..dagger/core/typescript/directory on diskin the two-scope CLI run, although the changeset records the directory removal
and the in-engine tree has it gone. Cosmetic, and idempotent on the next run
(the emptied directory owns nothing, so it is a no-op); looks like an apply
artifact rather than something this change introduced.
legacyRuntimeflip is covered by the e2e check, not by a CLI run — itneeds the setting written into
dagger.tomlby hand..dagger/core/typescript's owned set is taken from the design doc thatdescribed that layout (
design/unified-clients-shared-core.md): the vendored@dagger.io/daggerpackage. A file that layout wrote under some other namewould now be left behind rather than deleted.