Repository navigation
fix(codegen): wrap an interface method's result as its own return type - #38
Merged
Merged
Conversation
An interface method returning an object or another interface was wrapped as the
interface that declared it, whatever the declared return type was:
return new __Iface_{{ $iface.Name }}(this._ctx.select(...))
So a method returning a Container handed back something with the declaring
interface's dispatch on it, and calling anything on the result failed at
runtime against a type that never had those fields.
The list branch three lines below already did this correctly — same interface,
sibling interface, module object and core object each reach a different
wrapper. Mirror it for the singular case. Core objects and module objects need
an id to rebuild from, so those select one first; an interface wraps the
selection context directly, as before.
Add a golden covering all four shapes. The existing smoke typedef has an
interface whose only method returns a string, which is why nothing caught this.
Signed-off-by: Tom Chauveau <[email protected]>
"updator" is not a word. The name shows up in the helper directory, its Go module, the binary the SDK builds onto PATH, and every withExec that calls it, so it is worth fixing before more code grows around it. Pure rename; no behaviour change. Left alone: design/archives, which are snapshots of what was proposed at the time, and read wrong if edited. This does not address the other half of the naming problem — config-updater and module-config both edit configuration, and neither name says which one owns generated pins and which owns user settings. That needs a decision about the split, not a spelling fix. Signed-off-by: Tom Chauveau <[email protected]>
TomChv
force-pushed
the
fix/iface-returns-and-helper-name
branch
from
August 28, 2026 14:30
f99cdd3 to
59b5afd
Compare
TomChv
added a commit
that referenced
this pull request
Aug 28, 2026
A TypeScript module's generated files — `sdk/`, `__dagger.entrypoint.ts`, and the config the runtime reads — were produced by the engine: `dagger generate` called into this SDK, which handed straight back to the engine's built-in TypeScript runtime, which ran `cmd/codegen` and `ts-introspector` in nested sessions. This SDK now produces them itself, the way it already produced clients: schema and module metadata in as plain data, container execs, changeset out, no round trip. Three reasons, the same ones the client move had. The SDK repo should own what the SDK emits, so a codegen fix is not an engine release. The upstream path carries three SDK-lib origins, a Go+TypeScript shared binary, module/client coexistence and per-runtime duplication, nearly all of which is dead on arrival for our narrower contract. And codegen becomes `go test` plus `dagger check` here instead of an engine integration test. Running a module stays with the engine's runtime. That split is the hardest constraint in the design: for a `dagger-module.toml` module the runtime does no codegen at call time, it mounts `sdk/` as `@dagger.io/dagger` and executes the committed entrypoint. Whatever generate writes *is* the artifact that runs, and it has to satisfy an unchanged runtime byte for byte in the parts it reads. **The library.** Generated bindings import their runtime from `./core.js`, a bundle that only existed inside the engine image. `library/` vendors dagger/dagger's `sdk/typescript` at v1.0.0-beta.11 and `.dagger/modules/packager` builds the bundle from it with the same recipe and pinned image the engine uses, committed so that generating a module needs no bun toolchain and no network. A copy has no merge base git can compute, so `library/VENDOR.md` records the one it would have had: source tag and commit, what was deliberately left behind, the exhaustive list of local deltas, and the re-import procedure. **Codegen.** `helpers/codegen` gains `module` (a module's own bindings, split per dependency), `entrypoint` (the static dispatcher, rendered from the introspector's typedef scan) and `library` (the vendored library's own bindings) alongside `client`. `helpers/config-updater` writes the module config the runtime reads. **Routing.** `Mod.generate` takes the local path for `dagger-module.toml` modules and keeps delegating for `dagger.json` ones, which regenerate at call time regardless. Both stage the local dependency closure first — a dependent's schema is only loadable once its deps' generated files exist — and both take that staging back out of the changeset, each in the way its route requires. Regeneration prunes the `*.gen.ts` it owns out of the baseline the generated tree is layered onto. Layering is what keeps the module's own source and config in the changeset, but it can only add, so a dependency dropped from the config would otherwise keep its `<dep>.gen.ts` — an API against a module that is no longer served, which a default tsc rejects. Pruned in one place, matching what different things on different workspace kinds. **Engine pairing.** Everything here is built for one release. The SDK states it once as `targetEngineVersion`; the runtime harness and every fixture read from there, and a check fails when they disagree. **Tests.** Golden tests over the renderers; e2e checks over the generated tree, the routing, dependency edges in both config formats, config preservation and binding pruning; a differential check that generates a fixture through this SDK and through the engine and diffs everything but the bundle; and one fixture per TypeScript runtime that loads a generated module and calls a function on it, which is the only thing that proves the on-disk contract end to end. Replaces the #18 → #34 stack, squashed: several of those PRs overwrote earlier ones, which made the intermediate states hard to reason about and impossible to test independently. Rebased onto #37 (beta.11) and #38 (the interface-return fix and the config-updater rename); the entrypoint golden #38 added is regenerated here, because this generator emits the source maps the engine expects and main's did not. Signed-off-by: Tom Chauveau <[email protected]>
TomChv
added a commit
that referenced
this pull request
Sep 1, 2026
A TypeScript module's generated files — `sdk/`, `__dagger.entrypoint.ts`, and the config the runtime reads — were produced by the engine: `dagger generate` called into this SDK, which handed straight back to the engine's built-in TypeScript runtime, which ran `cmd/codegen` and `ts-introspector` in nested sessions. This SDK now produces them itself, the way it already produced clients: schema and module metadata in as plain data, container execs, changeset out, no round trip. Three reasons, the same ones the client move had. The SDK repo should own what the SDK emits, so a codegen fix is not an engine release. The upstream path carries three SDK-lib origins, a Go+TypeScript shared binary, module/client coexistence and per-runtime duplication, nearly all of which is dead on arrival for our narrower contract. And codegen becomes `go test` plus `dagger check` here instead of an engine integration test. Running a module stays with the engine's runtime. That split is the hardest constraint in the design: for a `dagger-module.toml` module the runtime does no codegen at call time, it mounts `sdk/` as `@dagger.io/dagger` and executes the committed entrypoint. Whatever generate writes *is* the artifact that runs, and it has to satisfy an unchanged runtime byte for byte in the parts it reads. **The library.** Generated bindings import their runtime from `./core.js`, a bundle that only existed inside the engine image. `library/` vendors dagger/dagger's `sdk/typescript` at v1.0.0-beta.11 and `.dagger/modules/packager` builds the bundle from it with the same recipe and pinned image the engine uses, committed so that generating a module needs no bun toolchain and no network. A copy has no merge base git can compute, so `library/VENDOR.md` records the one it would have had: source tag and commit, what was deliberately left behind, the exhaustive list of local deltas, and the re-import procedure. **Codegen.** `helpers/codegen` gains `module` (a module's own bindings, split per dependency), `entrypoint` (the static dispatcher, rendered from the introspector's typedef scan) and `library` (the vendored library's own bindings) alongside `client`. `helpers/config-updater` writes the module config the runtime reads. **Routing.** `Mod.generate` takes the local path for `dagger-module.toml` modules and keeps delegating for `dagger.json` ones, which regenerate at call time regardless. Both stage the local dependency closure first — a dependent's schema is only loadable once its deps' generated files exist — and both take that staging back out of the changeset, each in the way its route requires. Regeneration prunes the `*.gen.ts` it owns out of the baseline the generated tree is layered onto. Layering is what keeps the module's own source and config in the changeset, but it can only add, so a dependency dropped from the config would otherwise keep its `<dep>.gen.ts` — an API against a module that is no longer served, which a default tsc rejects. Pruned in one place, matching what different things on different workspace kinds. **Engine pairing.** Everything here is built for one release. The SDK states it once as `targetEngineVersion`; the runtime harness and every fixture read from there, and a check fails when they disagree. **Tests.** Golden tests over the renderers; e2e checks over the generated tree, the routing, dependency edges in both config formats, config preservation and binding pruning; a differential check that generates a fixture through this SDK and through the engine and diffs everything but the bundle; and one fixture per TypeScript runtime that loads a generated module and calls a function on it, which is the only thing that proves the on-disk contract end to end. Replaces the #18 → #34 stack, squashed: several of those PRs overwrote earlier ones, which made the intermediate states hard to reason about and impossible to test independently. Rebased onto #37 (beta.11) and #38 (the interface-return fix and the config-updater rename); the entrypoint golden #38 added is regenerated here, because this generator emits the source maps the engine expects and main's did not. 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.
Two fixes to code that predates the #18→#34 stack, so they land independently of it.
An interface method wrapped every object result as the declaring interface
iface_classes.ts.gtplrendered this for any object or interface return:whatever the declared return type was. A method returning a
Containercameback wearing the declaring interface's dispatch, so calling anything on the
result failed at runtime against a type that never had those fields.
The list branch three lines below already dispatched correctly — same
interface, sibling interface, module object, core object each reach a different
wrapper. This mirrors it for the singular case. Objects need an id to rebuild
from, so those select one first; an interface wraps the selection context
directly, as before.
Covered by a new golden over all four shapes. The existing smoke typedef has an
interface whose only method returns a string, which is why nothing caught this.
config-updator→config-updater"updator" is not a word, and the name reaches the helper directory, its Go
module, the binary built onto PATH, and every
withExecthat calls it. Purerename, no behaviour change.
design/archivesis left alone — those aresnapshots of what was proposed at the time.
This does not address the other half of the naming problem:
config-updaterand
module-configboth edit configuration, and neither name says which ownsgenerated pins and which owns user settings. That needs a decision about the
split, not a spelling fix.
Note on ordering
The rename touches
typescript-sdk.dang, which the #18→#34 stack editsheavily. Whichever lands second needs a mechanical rebase — git handles the
pure rename fine, but the conflict is real.