Skip to content

Bump to v1.0.0-beta.11 and write directories with the native workspace API - #37

Merged
TomChv merged 2 commits into
dagger:mainfrom
eunomie:typescript-sdk-beta-11-withdirectory-lead-ad383283
Aug 28, 2026
Merged

TomChv merged 2 commits into
dagger:mainfrom
eunomie:typescript-sdk-beta-11-withdirectory-lead-ad383283

Conversation

@eunomie

@eunomie eunomie commented Aug 27, 2026

Copy link
Copy Markdown
Member

This moves the TypeScript SDK to engine v1.0.0-beta.11 and writes init and client directories through the native workspace API.

  • dagger.json and README.md: engineVersion v1.0.0-beta.10 → v1.0.0-beta.11.
  • dagger.lock is migrated — forced, not cosmetic: beta.11's parser rejects the old git.ref object value outright (lockfile line 6: invalid value), breaking every command including dagger update itself. Regenerated by a beta.11 engine: git.ref → git-latest + git-sha, container.from → oci-sha. sdk-sdk stays at 3344489, so no dependency moved.
  • initModule: the read-back-and-merge workaround (existingDir(ws, modPath).withDirectory(...) fed into withNewDirectory) collapses to ws.withDirectory("/" + modPath, templateSource), now that dagger/dagger#13956 ships a merging Workspace.withDirectory.
  • generateClient / generateAllClient: keep withNewDirectory. Clients must prune stale *.gen.ts, which a merge cannot do. The double prune (baseline + workspace-level withoutFile) collapses to one, and the withoutClientBindings helper is deleted.

Notes

  • Pre-existing and unchanged: generateAllClient rebuilds each client from the untouched workspace, so a nested client path (a client inside another client's directory) would have the outer discard the inner. This predates this branch on local-directory workspaces and is not addressed here.
  • The client baseline deliberately reads from the untouched workspace to work around a still-open engine bug — withoutFile followed by a read-back loses the directory on a local-directory workspace. That read is load-bearing and must not be "simplified" away.

Test

dagger check

59/59 against a v1.0.0-beta.11 engine, lockfile stable across runs. Live dagger module init typescript … --path … was driven end to end — onto an empty target, and onto a non-empty one holding foo.txt, existing.ts, nested/deep.txt and a package.json with its own scripts: all survive, package.json merged, template lands beside them.

beta.11 lands Workspace.withDirectory, which the next patch needs, and changes
the lockfile schema: git.ref carried an object value that beta.11's parser
rejects outright, so every command — dagger check, and dagger update itself —
fails with "lockfile line 6: invalid value" until the file is migrated.

Regenerated by letting a beta.11 engine resolve the entries: git.ref splits into
git-latest + git-sha and container.from becomes oci-sha. The legacy
container.from lines are dropped rather than left in place; beta.11 no longer
writes them, and engineVersion now rules out the beta.10 that read them.

No dependency moves: sdk-sdk stays pinned at 3344489, the sha the old git.ref
entry held.

Signed-off-by: Yves Brissaud <[email protected]>
Both call sites carried scaffolding for a Workspace.withNewDirectory that meant
two different things: it replaced the directory it wrote on a local-directory
workspace and merged into it on a synthetic one, the shape a git-loaded
workspace has. beta.11 makes it always replace and adds Workspace.withDirectory,
which always merges. Confirmed against a beta.11 engine on both workspace kinds:

  withNewDirectory  [added.txt]
  withDirectory     [added.txt, existing.txt, keep.txt]

init wants the merge, so it says so: the read-back of existingDir(ws, modPath)
that hand-merged the starter onto the destination is now withDirectory.

Clients want the opposite. Regeneration owns the *.gen.ts set and has to drop
the bindings of a module that has left the closure, which a merge cannot do —
so they keep withNewDirectory and rebuild the directory they replace it with.
What goes away there is the second prune: the bindings came off the workspace
with withoutFile as well as out of the baseline, purely to cover the merging
half of the old split. One prune, in the baseline, now covers both kinds.

The baseline still reads from the untouched workspace. Pruning the workspace and
reading it back loses the directory outright on a local-directory workspace —
still open as dagger/dagger#13955, still reproducible on beta.11:

  ws.withoutFile("/fixture/keep.txt").directory("/fixture").entries
  => stat fixture: no such file or directory

Building the client on withDirectory instead fails for that reason, and fails
loudly: generate-client-respects-existing-check reports main.ts removed.

Verified with dagger check (59/59) and, on an engine-driven
`dagger module init typescript busy --path ./busy-target`, over a directory
holding foo.txt, existing.ts, nested/deep.txt and a package.json with its own
scripts: all four survive, package.json keeps name and scripts, and the template
lands beside them.

Known and unchanged: generateAllClient rebuilds each client from the untouched
workspace, so nested client paths (a client inside another client's directory)
would have the outer one discard the inner. That predates this patch on a
local-directory workspace, where withNewDirectory already replaced.

Signed-off-by: Yves Brissaud <[email protected]>
@eunomie
eunomie marked this pull request as ready for review August 27, 2026 13:01
@eunomie
eunomie requested a review from TomChv August 27, 2026 13:01
@TomChv
TomChv merged commit 305807a into dagger:main Aug 28, 2026
60 checks passed
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-updator` 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
#37 established for client generation once `withNewDirectory` stopped meaning
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.

Signed-off-by: Tom Chauveau <[email protected]>
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants