Repository navigation
fix: make the legacyRuntime flip symmetric - #81
Merged
Merged
Conversation
Turning `legacyRuntime` off moves a module onto an entrypoint, because
withEntrypointManifest rewrites the manifest on every run. Turning it back on
did nothing of the sort: generateScope left an existing manifest alone whenever
the scope already had one, so a module that declared `[entrypoint]` and no
`[runtime]` kept that manifest while the rest of the run generated for a
runtime. Both halves of the legacy path then failed on it, and neither error
named the setting:
- withClientDependencies asked the builder to hang a dependency off a runtime
the manifest does not declare, which it refuses: "module manifest legacy
runtime is required when legacy fields are set".
- moduleSourcePath asked the engine for a sourceSubpath an entrypoint manifest
has not got, read the empty answer as ".", and generation looked for the
module's src/ at the workspace root: "stat src: no such file or directory".
The setting asks for a `[runtime]` module, so write that manifest. generateScope
now routes an entrypoint manifest through withModuleManifest, whose no-config
branch already emits exactly what is wanted — a fresh legacy manifest with the
engine release this SDK ships for — and the scope's clients come back as
`[[dependencies]]` through withClientDependencies on the same run. Nothing from
the entrypoint manifest needs carrying over: it holds only the name and the
`[entrypoint]` table.
The rest of the legacy path already cleaned up after the other layout:
prunedInactiveDispatch takes __dagger.dispatch.ts and entrypoint/, and
prunedEmbeddedClientsDir takes clients/ with the packaged clients/dagger and
clients/<name>/ packages in it. What was missing was the link into them:
package.json kept its `file:./clients/<name>` dependencies on packages the flip
had just removed, so the runtime's install failed at call time. config-updater's
package-json pass now prunes those, by the same scope-local rule shared-deps
already prunes with, leaving a client installed from anywhere else alone.
This matters more since #73 made the entrypoint layout the default: a fresh
module declares `[entrypoint]`, while the `[runtime]` layout is the one every
released engine loads, so flipping back is what a user on a released engine
does.
Signed-off-by: Tom Chauveau <[email protected]>
grouville
self-requested a review
October 9, 2026 06:50
grouville
approved these changes
Oct 9, 2026
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
(SDK Main-Engine Test Run, 2026-10-07 — issue #27, case H3.)
The setting has been renamed since that run. #73 made the
[entrypoint]layout the default and inverted the setting: what the matrix exercised asentrypoint = falseis todaylegacyRuntime = true(--legacy-runtime, scope settinglegacyRuntime = true). That makes the row more important, not less — #73's own description says the[entrypoint]layout is what a fresh module now gets, while the legacy[runtime]layout is the one every released engine loads. Flipping an entrypoint module back is therefore exactly what a user on a released engine does.Both quoted errors still reproduce verbatim on
v1.0.0-beta.17 · 55e11246— see Verification.Root cause
generateScopewrote the entrypoint manifest on every run, but left an existing manifest alone whenever the scope already had one (typescript-sdk.dang:227on main,} else if (hasToml) {). So withlegacyRuntimetrue and a manifest declaring[entrypoint]and no[runtime], the manifest was kept as it was while the rest of the run generated for a runtime. Both halves of the legacy path then failed on it, and neither error named the setting:withClientDependencies(typescript-sdk.dang:585on main) calls the builder'swithLegacyRuntimeDependencyon an entrypoint manifest.ModuleManifest.validaterefuses a dependency with no runtime to hang off:module manifest legacy runtime is required when legacy fields are set. This is the with-client half of H3.moduleSourcePath(typescript-sdk.dang:1745on main, reached from:244) asks the engine for asourceSubpaththat an entrypoint manifest has not got, gets"", reads that as".", and generation then looks for the module'ssrc/at the workspace root:workspace directory "src": … lstat <ws root>/src: no such file or directory. This is the no-client half.The forward flip works only because
withEntrypointManifestrewrites the manifest every run; nothing did the mirror image.Fix
Make the flip symmetric — the setting asks for a
[runtime]module, so write that manifest.generateScopenow routes an entrypoint manifest throughwithModuleManifest(typescript-sdk.dang:240), whose no-config branch already emits exactly what is wanted: a fresh legacy manifest pinned to the release this SDK ships for. Nothing from the entrypoint manifest needs carrying over — it holds only the name and the[entrypoint]table — and the scope's clients come back as[[dependencies]]throughwithClientDependencieson the same run. A[runtime]manifest is still generated as it stands, so no existing behaviour moves.isEntrypointManifest/tomlDeclaresTable(typescript-sdk.dang:468,:477) tell the two manifest shapes apart by reading the file, the wayisTypescriptConfigreadstsTomlPatternoff one — the builder's loaded manifest exposes neither table.withModuleManifest's docstring now says it serves three arrivals (no config, adagger.json, an entrypoint manifest moving back);withEntrypointManifest's "It is a one-way trip" is replaced by what does and does not come back; thelegacyRuntimesetting docstring and README's--legacy-runtimeparagraph say the same.The file half.
prunedInactiveDispatchalready removed__dagger.dispatch.tsandentrypoint/, andprunedEmbeddedClientsDiralready removedclients/with the packagedclients/daggerandclients/<name>/in it — both verified in the transcripts below. What was missing was the link into them:package.jsonkept itsfile:./clients/<name>dependencies on packages the flip had just deleted, so the runtime's install would fail at call time.config-updater'spackage-jsonpass now prunes those (helpers/config-updater/main.go:150), by the same scope-local ruleshared-depsalready prunes with, so a client the user installed from elsewhere (file:../…or a registry) is left alone.Verification
Engine
v1.0.0-beta.17 · 55e112468d5b08e3a8746e7e74a4dc38898cf07athroughout (DAGGER_LEAVE_OLD_ENGINE=1 dagger --x-release=55e11246… …).New checks (
.dagger/modules/e2e/generate.dang:194,:255).generateFlipsBackToRuntimeCheckgenerates a scope withlegacyRuntime: false, flips it, and asserts the whole move:[runtime] source = "typescript",engineVersion = "v<targetEngineVersion>", no[entrypoint];__dagger.entrypoint.tsandsdk/client.gen.tsgenerated;__dagger.dispatch.ts,entrypoint/andclients/gone from the resulting tree; the tsconfig alias back; nofile:./clients/left inpackage.json; and a third generation writing nothing.generateFlipsBackWithClientCheckdoes the same for a scope with a recorded client and asserts the[[dependencies]]entry,sdk/<target>.gen.ts, and the pruned link.Both new checks were confirmed to go RED without the fix, on a scratch copy with
typescript-sdk.dangand the helper reverted toorigin/mainand only the checks kept — and they fail with precisely the two errors from the report:Checks run green with the fix (scratch copy of this branch,
workspace.toml/workspace.lockswapped in; command exited 0, per-check durations 4m51s–10m2s):cd helpers/config-updater && go test ./...→ok config-updater, including a newupdatePackageJSONcase covering the pruned entrypoint links and the kept outside install. Parse gate after every.dangedit:dagger -m . functionsanddagger -m .dagger/modules/e2e functions, both load. The full 68-check suite is run by the coordinator; the baseline on unmodified main is 67/68, withpackager/library-bindings/stalered (expected on an engine newer than the committed bindings).Manual repro, both H3 variants
Workspace built the way a user does: vendor the SDK,
dagger init -y,module install,module init typescript --name hello(entrypoint layout, the default), then addlegacyRuntime = trueunder[sdks.typescript.scopes.".dagger/modules/hello".settings]anddagger -y generate. The with-client variant adds a second moduletargetand runsdagger module client add ../targetfrom insidehello.Before (pristine
origin/main) — both quoted errors, verbatim.After (this branch) — the flip happens, is idempotent, and the result runs.
In every run the entrypoint form itself calls fine on this engine before the flip (
hello container with-exec --args echo,hi stdout→hi), matching the matrix's F2/H1/I-series: both layouts load here, so this is a flip bug, not a layout bug.Not covered / follow-ups
sourceandincludeare still lost across a round trip. An entrypoint manifest has no field for them, and the way back writes a fresh manifest rather than reading the old one, so a module that declared either loses it going out and does not get it back. Documented in thelegacyRuntimedocstring, inwithEntrypointManifest's docstring and in the README rather than fixed; restoring them would mean preserving state the entrypoint manifest cannot hold.clients/isfix/clients-ownership(fix: remove only what the SDK generates from clients/ #75)'s concern. Not widened here; the flip-back path reuses the existing pruning helper, so it inherits whatever fix: remove only what the SDK generates from clients/ #75 settles.legacyRuntime = true(camelCase); alegacy-runtime = truespelling under the same[…settings]table is accepted and dropped, sodagger generatereports success and "no changes to apply" while the module stays in entrypoint form. That cost two full repro rounds here, and it is the kind of thing that reads as "the flip still doesn't work" in a future test run. Engine-side, not fixable here; worth its own report.[[dependencies]]has nowhere to live in an entrypoint manifest. Unchanged by this PR, and the reason the with-client flip is the half that failed loudest.