Skip to content

chore: add ts sdk module max - #42

Merged
TomChv merged 15 commits into
mainfrom
feat/ts-module-max
Sep 9, 2026
Merged

TomChv merged 15 commits into
mainfrom
feat/ts-module-max

Conversation

@TomChv

@TomChv TomChv commented Sep 3, 2026

Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Vasek - Tom C <[email protected]>
The engine renamed detectScope to findClientRoot and made its result
nullable, and it validates the provider by exact match on name, argument
names and types, and return type (core/sdkmodule/provider.go validate).
A mismatch is not a load error: dagger module install simply never
records [sdks.typescript], and this repo stops being an SDK.

Null, not "", is now how a provider declines a directory.

Signed-off-by: Yves Brissaud <[email protected]>
The engine dropped ModuleManifest from its core schema; the builder now
lives in github.com/dagger/sdk-helpers, a standalone Dang implementation
that needs no engine newer than v0.21.9. Depend on it and call
sdkHelpers.moduleManifest instead of the removed builtin.

Write the manifest with Workspace.withNewFile rather than
Workspace.withFile. withFile landed after v1.0.0-beta.11, and Dang infers
the whole type on every call, so one field the running engine does not
have fails every check that touches this SDK — including checks that only
read a constant. With this the module loads and infers on the release its
own checks run against, which is what keeps them green.

runtimeSource goes with it: withLegacyTypescriptRuntime names the runtime
the constant held.

Signed-off-by: Yves Brissaud <[email protected]>
The marker predates scopes. A module is generated because dagger.toml
records it as an SDK scope, so "do not generate this tree" is now spelled
by leaving it out of the scope list, and the marker can only contradict a
decision the workspace already made. It cost one findUp per scope per
generate to say nothing.

Nothing in this repo used it for anything else: fixtures/skip was already
dead, and the two scopes registered with a marker above them —
managed-toml/app and parent-source — exist for `mod` resolution and for
reading a module's config, not for generation. Unregister those rather
than start writing generated trees into them; the scope list and
Fixtures.managedScopes now say the same thing without a footnote.

Signed-off-by: Yves Brissaud <[email protected]>
A scope whose module is still configured by dagger.json used to read as a
scope with no module at all: the starter was rendered over the source
being adopted, and a second manifest was written beside the first, leaving
the module with two config files free to disagree.

Split the two things seeding did. The starter is laid down only for a
scope with neither config, and the manifest is written for a scope without
a dagger-module.toml — from a dagger.json when there is one, which is then
removed. The manifest schema round-trips through the sdk-helpers builder,
so source, include, [[dependencies]] and the module's engine pin survive
the migration.

Refuse rather than migrate two kinds of dagger.json, because migration
deletes the original and what it cannot carry is then gone. `toolchains`
and `blueprint` have no table in dagger-module.toml — the builder validates
them on load and emits neither — so migrating either silently strips it.
And the builder copies whatever `sdk` names straight into `[runtime]`, so
a scope mistakenly recorded as TypeScript over a Go module would have its
config rewritten as a Go manifest and its source run through TypeScript
codegen. Recognizing that second case needs the older `"sdk": "typescript"`
spelling to count as TypeScript, which it did not: a module written that
way was refused by `mod --path` too.

A scope that already has a manifest keeps it untouched. Clients become a
generated package here rather than manifest dependencies, so there is
nothing to reconcile into an existing manifest, and rewriting one would
not even round-trip: the builder normalizes an absent source to ".", so
generate would report a diff on the run after every init.

Signed-off-by: Yves Brissaud <[email protected]>
The engine resolves a module's local [[dependencies]] to workspace-root-
relative paths and then reads them relative to Workspace.cwd
(ResolveDepToSource). generateScope is called with the cwd set to the
scope, so a dependency declared as "../dep" was looked for at
<scope>/<workspace-relative-path-of-dep> and the module's schema failed to
load:

  workspace module source ".../generate-deps/app/.../generate-deps/dep"
  does not contain a dagger config file

Do the work with the cwd at the workspace root — every path here is
workspace-root-relative already — and put the cwd back before returning,
because the engine rejects a generateScope that hands back a workspace
standing somewhere else.

Only the branch engine resolves dependencies this way, so nothing on
v1.0.0-beta.11 shows it. engine-e-2-e:checks-check is what caught it, on
its first run: six of the e-2-e checks, all of them the ones that touch a
module with a local dependency.

Signed-off-by: Yves Brissaud <[email protected]>
A module's manifest can point `source` away from the directory holding it
— config in .dagger/modules/<name>/, code in ci/, the layout `dagger setup`
migration produces. The config files the runtime is detected from move with
the code, but generateScope detected before it resolved `source`, so it
looked for deno.json and bun.lock beside the manifest and found neither.

A split-layout Deno or Bun module was therefore regenerated as a Node one:
package.json and tsconfig.json laid into a Deno project, which then cannot
resolve @dagger.io/dagger at all. It generates cleanly and fails at
`dagger call`.

Resolve `source` first and detect from there. Seeding keeps detecting from
the scope, because a scope with no module has no manifest to resolve
`source` out of — and is its own source directory anyway; after seeding,
re-detection reads the config files seeding just wrote and agrees with the
runtime it was handed.

The split-deno fixture is a Deno project on the far side of a `source`
pointer, which is the shape no existing fixture had: parent-source is Node,
so it passes either way.

Signed-off-by: Yves Brissaud <[email protected]>
Idempotence is a stated contract — the engine calls generateScope on the
same scope for module init, client add, client rm, client update, module
update, workspace update and generate, and every one of them diffs the
result — but nothing asserted it. The design doc's test plan listed the
check; the check did not exist.

Generate a scope, apply the changeset, generate again, and the second one
has to be empty. isEmpty rather than the path lists, so a spurious removal
counts too. On a dependency-free scope, so it stays cheap.

It passes today. It would not have, had the manifest been regenerated on
every call: the sdk-helpers builder normalizes an absent `source` to ".",
so the manifest written at init comes back changed on the next run.

Signed-off-by: Yves Brissaud <[email protected]>
…etes

sdk-sdk drives a released CLI through the beta SDK contract — initModule,
the as-sdk marker, the @generate rollups, module deps — every piece of
which this work removes. Its 23 red checks were reporting that removal, so
they go, along with the runtimes check built on the same harness.

What they covered was the engine half of the contract, and nothing else
reached it: whether the engine accepts the provider at all, whether a
scope's settings arrive, whether a generated module runs. That is what
.dagger/modules/engine-e2e replaces it with, on the branch that has the
interface. It builds an engine from the pinned dagger/dagger#13992 commit,
runs it as a playground with this checkout mounted, and drives the real
CLI: `sdk list`, `module init` with and without settings, `call`, and the
whole check suite. Provider validation is silent when it fails — the
engine just never records [sdks.typescript] — so devSdkCheck asserts on
the recorded scope entry rather than on the command exiting zero.

The playground gets the engine commit as its `version`, or its state cache
volume is named randomly and every run starts cold. `.git` is excluded
from the mounted checkout and re-created inside: in a worktree it is a
file pointing at a directory the container does not have.

Signed-off-by: Yves Brissaud <[email protected]>
The README still described the beta contract — initModule, initClient, the
@generate rollups, `dagger api client init` with a path argument, a
`modules` function that no longer exists — so every command in it was
wrong. Rewrite it around the provider interface: what the engine asks for,
what the settings are, where a generated client package lands and why, and
what the checks cover.

design/module-max.md is edited in place rather than appended to, so it
still reads as a design rather than a changelog. What changed since it was
written: the interface rename, the manifest builder leaving the engine for
dagger/sdk-helpers, writing the manifest once instead of on every
generation, migrating a pre-1.0 dagger.json, and dropping the skip marker
— §4.10 now argues the opposite of what it argued, and says so.

Two things are worth more than the rest of the edit. §8.2 records that
settings now reach the provider, which was the one unworked-around engine
gap. §8.3 is new: one engine field the running engine does not have fails
every check that touches this SDK, because Dang infers the whole program
per call. That is what 67 red checks were, it is why the manifest is
written with withNewFile, and it is expensive to rediscover.

Signed-off-by: Yves Brissaud <[email protected]>
`dagger module client add` fails for every SDK provider whose
findClientRoot answers with a path. The engine selects the result into a
dagql.Nullable[dagql.String]; the module returns a well-formed
DynamicOptional wrapping a String; and DynamicOptional.SetField assigns
the unwrapped String into the Nullable, which nothing in dagql can do.
Valid == false returns early without assigning, so only the null answer
works — and since module init never calls findClientRoot, the declining
answer is the only one that had ever been exercised.

Nothing here can work around it: the interface fixes the return type, and
the engine never inspects the value beyond unwrapping it. Written down
with the reasoning rather than the symptom, because the message names
three dagql types and none of this repo's code.

Reproduced at the pinned 8fd9b22b with two plain TypeScript modules.

Signed-off-by: Yves Brissaud <[email protected]>
Picks up "Omit the default module source from dagger-module.toml": a
module source of "." means the manifest directory, which is what a reader
assumes when the field is absent, so the builder no longer writes it.

That removes a wart from what this SDK produces. Migrating a dagger.json
with no `source` used to emit `source = "."`, because the builder fills
the field in when the legacy config names an SDK — so every migrated
manifest carried a line stating the default. generateMigratesLegacyConfigCheck
now asserts it stays unwritten; the assertion fails on the previous pin and
passes on this one, which is what says the bump took effect.

It also retires half an argument. Writing the manifest only when a scope
has none was justified partly by that normalization: a manifest this SDK
wrote came back changed on the next generation, so regenerating could not
be a fixed point. That is no longer true, and the note in
withModuleManifest and design/module-max.md §4.6 said so as if it were
load-bearing. The reason that survives is the one that was doing the work
all along — clients are a generated package here, not manifest
dependencies, so there is nothing to reconcile into a manifest that
already exists.

Bumped in dagger.lock only. `dagger module deps update` writes a pin into
dagger.json instead and leaves the lock contradicting it, which is not the
shape this repo or python-sdk uses.

Signed-off-by: Yves Brissaud <[email protected]>
@TomChv
TomChv marked this pull request as ready for review September 8, 2026 15:08
`dagger module client add` inside a module generated a package the module
itself could not reach. The standalone package under `clients/` carries the
bootstrap that serves its targets, which is what code outside the module
needs; the module's own source imports @dagger.io/dagger, which resolves to
the generated sdk/ directory, and the target was not bound there.

Fold each target into the module's own bindings too, so `sdk/<target>.gen.ts`
sits beside the module's types and its manifest dependencies, re-exported
through client.gen.ts.

The fold is filtered rather than merged. A target's schema is core plus one
module, and its core half is the client-facing one, which hides nothing --
merging it whole would hand a module bindings for core types its own schema
withholds. Schema.Include keeps the target's own types and, on the extendable
types, only the fields it contributed.

Mod.generate cannot reconstruct a scope's targets, since they live in
dagger.toml and only the engine reads it. Rather than prune the bindings it
cannot regenerate, it now refuses when the module has a clients/ directory.

Also name and version the generated package so it can be installed. The name
came from the directory the package sits in, which is `clients` in every
scope, so every generated package in a workspace had the same name and two of
them could not be installed side by side; it now comes from the scope. npm and
yarn both refuse a package with no version, so the file: dependency a user
adds to reach it could not resolve at all.

The engine does not yet install a scope's client targets into the module's own
session, so `dag.<target>()` type-checks and then fails at run time unless the
target is also a manifest dependency. That half is the engine's; recorded in
design/module-max.md section 8.5 rather than worked around.

Signed-off-by: Tom Chauveau <[email protected]>
A client generated into a module type-checked and then failed at run time
with `Cannot query field "<target>" on type "Query"`. A module's session
serves what its manifest lists in [[dependencies]]; a scope's clients live in
dagger.toml, which only the engine reads, so nothing ever installed them.

Write them into the manifest, the way the Go SDK does. A git target is
recorded by its canonical ref and pin, a local one by its path relative to the
module that declares it -- the form a manifest uses for any local dependency.

This has to run before the module's schema is read, since the schema is what
the bindings are generated from and a target that is not a dependency yet is
not in it. So it runs for every module scope, not only the ones being created,
which is why it is separate from writing the manifest itself.

Dependencies are upserted, never pruned: a manifest may carry entries written
by hand or migrated from a pre-1.0 dagger.json, and they are indistinguishable
from ours, so removing what is missing from the client set would take those
with it. Dropping a client therefore leaves its dependency behind.

Signed-off-by: Tom Chauveau <[email protected]>
Section 8.5 recorded the run-time failure as the engine's to fix and said
nothing here could close it. Both were wrong: the Go SDK already wrote its
scope's clients into the module manifest, which is what gets them served, and
this SDK now does the same.

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