Repository navigation
fix: raise a pre-1.0 engine pin when generating a [runtime] module - #77
Merged
Merged
Conversation
A module is served the core schema view of the release its manifest pins
(dagger core/schema/modulesource.go:4251), and `Query.serveModule` exists only
from v1.0.0 — it is registered `View(AfterVersion("v1.0.0-0"))`
(core/schema/module.go:288). `ModuleSource.introspectionSchemaJSON` is that same
view, so a manifest left on a pre-1.0 pin yields 0.21-shaped core bindings —
`sdk/client.gen.ts` without `serveModule` — beside a 1.0 bundle whose module
client calls `__dag.serveModule(...)`, a call codegen renders from its own
template whatever the schema said. The two halves disagree: the module
generates cleanly, `tsc` reports `Property 'serveModule' does not exist on type
'Client'`, and a call that reaches the serve dies with `__dag.serveModule is not
a function`.
Two places carried the old pin. Migration (`withModuleManifest`) round-tripped
the dagger.json through the builder, pin included; and `dagger setup` writes
dagger-module.toml itself with the pin copied over (core/workspace/migrate.go:524),
so a module it migrated never passes through migration here at all.
`withClientDependencies` runs for every `[runtime]` module scope before the
schema is read, which makes it the one place regeneration can repair such a
manifest.
Both now pin the release the committed bundle is built for — the same pairing a
fresh module has gotten all along. Only a major version of 0 is raised: a 1.0
pin is a deliberate choice, its view already defines everything the generated
clients call, and rewriting it would turn that choice into a diff on every
`dagger generate`.
Covered by three checks: a pre-1.0 dagger.json pair is migrated and re-pinned,
a dagger-module.toml still on v0.21.9 is raised on regeneration, and one on
v1.0.0-beta.13 is left untouched.
Signed-off-by: Tom Chauveau <[email protected]>
grouville
self-requested a review
October 9, 2026 06:49
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
Source: SDK Main-Engine Test Run, 2026-10-07 — issue #22, case G12.
Root cause
A module is served the core schema view of the release its manifest pins
(dagger
core/schema/modulesource.go:4251), andQuery.serveModuleis registeredView(AfterVersion("v1.0.0-0"))(daggercore/schema/module.go:288).ModuleSource.introspectionSchemaJSON/clientSchemaIntrospectionJSONare thatsame view, so a pre-1.0 pin produces 0.21-shaped bindings paired with this SDK's
1.0 bundle:
sdk/client.gen.tshas noserveModuleon the coreClient.await __dag.serveModule("/legacy/dep")—because codegen renders that from its own template
(
helpers/codegen/generator/typescript/templates/src/_client.ts.gtpl:90),whatever the schema said.
So the tree generates cleanly and breaks later:
tscreportsProperty 'serveModule' does not exist on type 'Client'(case G6) and a call that reachesthe serve dies with
__dag.serveModule is not a function(case G12).Two places carried the old pin into a
[runtime]manifest:typescript-sdk.dangwithModuleManifest(hasJSON branch) — migration loaded thedagger.jsonand re-emitted it as TOML through the sdk-helpers builder, whichround-trips
engineVersion(loadCanonicalConfigcopies it intolegacyEngineVersion, andwithLegacyRuntimekeeps the loaded value whenengineVersionis null). The fresh-module branch beside it already pinnedtargetEngineVersion.dagger setup/workspace migratewritesdagger-module.tomlitself with thepin copied over (dagger
core/workspace/migrate.go:524), so a module it migratednever passes through this SDK's migration at all — yet regenerating it kept
emitting 0.21-shaped bindings.
Fix
withModuleManifest, hasJSON branch: re-pin the migrated manifest with.withLegacyTypescriptRuntime(engineVersion: "v" + targetEngineVersion)— the samepairing a fresh module gets.
moduleSourceis left null, so the loadedsourceis preserved.
withClientDependencies(runs for every[runtime]module scope, before theschema is read — the one place regeneration can repair a manifest): when the
loaded manifest's pin is pre-1.0, re-pin it the same way. The existing digest
comparison is untouched, so an unchanged manifest is still not reported as
written.
hasLegacyEnginePinreads the pin off the file withFile.search, the wayisTypescriptConfigreads its pattern, because the builder keepslegacyEngineVersionto itself. Anchored^engineVersion\s*=\s*"v?0\.so itmatches the manifest's own top-level key and not a value inside some table.
Only a major version of 0 is raised. A 1.0 pin is a deliberate choice — an
earlier beta a module is known to load on — its view already defines everything the
generated clients call, and rewriting it would turn that choice into a diff on
every
dagger generate.Docstrings on both sites explain why; README's migration paragraph gained a
sentence.
Checks added
generate-migration-raises-engine-pin-checkdagger.jsonpair (fixtures/generate-legacy-pin, both pinnedv0.21.9, app depending on dep) comes out pinned attargetEngineVersion, the dep client is generated, the self client carries the__dag.serveModule(call site, andsdk/client.gen.tscarries theserveModule = async (definition — the observable proof the bindings came from a 1.0 viewgenerate-raises-legacy-engine-pin-checkdagger setup-shapeddagger-module.tomlpinnedv0.21.9(fixtures/managed-toml/legacy-pin) is re-pinned on regenerationgenerate-keeps-engine-pin-checkv1.0.0-beta.13(fixtures/managed-toml/beta-pin) is left untouched —Asserts.untouched, on the changeset layerThe new fixtures sit under the existing
fixtures/.typescript-ignore-generatemarker (found with findUp, so one file covers the tree) and are deliberately not
registered as
dagger.tomlscopes or listed inFixtures.managedTomlFixtures—their pins are the point, so
dagger generateandfixture-engine-version-checkmust leave them alone.
Verification
Engine
v1.0.0-beta.17/55e112468d5b08e3a8746e7e74a4dc38898cf07a(latest daggermain with a published build), on the
[runtime]layout throughout —Gen.scopedefaults to
legacyRuntime: true, and this change only touches that path.The new checks go red without the fix. Scratch copy with the new checks and
fixtures kept and
typescript-sdk.dangreverted to8a7c580(exit 1):(
generate-keeps-engine-pin-checkis a guard, not a discriminator: a 1.0 pin wasalready left alone.)
Green with it restored (
exit 0):The two pre-existing checks most at risk from this change —
generate-migrates-legacy-config-checkandgenerate-preserves-manifest-check—are in that run, plus
generate-dependency-check. The full suite is being run bythe coordinator against the recorded baseline (67/68 green on unmodified main; the
one red,
packager/library-bindings/stale, is expected on an engine newer than thecommitted library bindings and is unrelated to this change).
Manual repro, end to end
A user-style workspace with this SDK vendored,
fixtures/generate-legacy-deps/{dep,app}copied in as
legacy/{dep,app}, app'sdagger.jsonpinned"engineVersion": "v0.21.9",app's source calling the dependency, and both scopes recorded by hand in
dagger.toml(dep first, with the dep also recorded as a client of app — theserve-on-use shape issue #22 describes).
Before (
typescript-sdkat8a7c580):After (this branch):
The call site is identical in both; only the definition appears or not. That is the
whole bug, and the pin is what decides it.
Not covered / follow-ups
withoutLegacyFieldsdropsengineVersionwith the[runtime]it hangs off, so an[entrypoint]manifest has no pin to raise andthis change does not touch that path.
re-pinned. A dependency left on a pre-1.0 pin is still served a pre-1.0 view when
it is generated — which its own scope's generation fixes, so the workspace heals
one scope at a time rather than all at once.
dagger setup/workspace migratestill carries a pre-1.0 pininto
dagger-module.toml(daggercore/workspace/migrate.go:524). This changerepairs such a manifest on the next generation, but migration writing a current
pin would be the narrower fix, and is the other half the write-up proposed.
refusing would leave a user with a module that generated fine yesterday and
cannot generate today, with no in-SDK way out.
generate-legacy-deps/{app,dep}declare
"engineVersion": "latest", which migrates to the literal stringengineVersion = "latest"in the TOML rather than to a resolved version — it isaccepted everywhere downstream, so it is only an oddity, but it means neither
legacy fixture ever exercised a real pin (which is why this bug had no coverage).
dagger generateleaves the generated tree untracked, anda module whose
.gitignorecoverssdk/then hides its own generated files fromthe engine's module context (
module "<name>" has runtime codegen disabled but committed generated file "sdk/client.gen.ts" is missing). Pre-existing andalready noted in
.dagger/modules/runtimes/main.dang; it cost a repro round here,so it is worth a louder mention somewhere.