Skip to content

feat: generate one module loading path, and write the entrypoint manifest through sdk-helpers - #55

Merged
TomChv merged 2 commits into
mainfrom
feat/entrypoint-one-loading-path
Sep 16, 2026
Merged

TomChv merged 2 commits into
mainfrom
feat/entrypoint-one-loading-path

Conversation

@TomChv

@TomChv TomChv commented Sep 16, 2026

Copy link
Copy Markdown
Member

A module is loaded through its [runtime] or through its [entrypoint]. Until
now it got the files for both, and the manifest for neither — dagger module init typescript test (no --entrypoint) wrote a correct [runtime] manifest
and then entrypoint/main.dang and __dagger.dispatch.ts beside it, two files
nothing reads, under names one word apart from the one that matters.

Two commits, independent enough to review separately.

1. Generate one loading path's files, not both

moduleDirectory branches on the entrypoint setting:

setting files
off sdk/, __dagger.entrypoint.ts
on sdk/, __dagger.dispatch.ts, entrypoint/main.dang

Not naming a file also skips rendering it, so a [runtime] module no longer
pays for the dang-entrypoint codegen exec at all.

Writing is only half of it — what the other setting left on disk stays there.
prunedLegacyEntrypoint becomes prunedInactiveDispatch and prunes both ways:
the legacy dispatcher under an entrypoint, the dispatcher and entrypoint/
otherwise. That is the upgrade path for every module an earlier build wrote
both halves into.

2. Write the entrypoint manifest through the sdk-helpers builder

withEntrypointManifest was the only place in the repo emitting a
dagger-module.toml by hand, and the only source of manifestVersion = 2. It
justified itself by pointing at dagger/dagger#14038's version gate: the builder
never writes that field, so a builder-written manifest would not load there.

That is the wrong way round. The builder's schema is the contract, and making
the engine read it is the engine's job — work that is under way. Targeting the
version gate instead meant one generator path diverging from the schema every
other path validates against, with TOML escaping by hand.

So: load the existing manifest when there is one, drop the legacy fields, add
the Dang entrypoint, generate. An entrypoint module's tree has no
__dagger.entrypoint.ts, so [runtime] does not stay beside [entrypoint] —
leaving it would only point an older engine at a file that is not there.

# --entrypoint                    # no flag (unchanged)
name = "test-ep"                  name = "test"
                                  engineVersion = "v1.0.0-beta.11"
[entrypoint]
  kind = "dang"                   [runtime]
  source = "./entrypoint"           source = "typescript"

Entrypoint modules therefore load nowhere until that gate comes out. That is
accepted, not a bug to route around: #14038 gates on meta.ManifestVersion != 0
and its legacy path ignores [entrypoint] entirely. Re-adding manifestVersion,
prepending it to the builder's output, or falling back to a [runtime] would
all put the generator back in the business of writing a shape the builder does
not model. design/module-entrypoint.md §7.1 records the decision (additive
won) and §7.1.1 says what not to do about it.

The setting is off by default, so nothing a user generates today changes.

Testing

dagger check against v1.0.0-beta.13:

  • new manifest:entrypoint-manifest-check — a fresh entrypoint scope
    asserts [entrypoint] and no manifestVersion; a [runtime] → entrypoint
    flip asserts the legacy fields go with it.
  • new generate:generate-prunes-entrypoint-check — plants both entrypoint
    files in a [runtime] fixture, asserts regeneration removes them.
  • init:init-check gains notAdded for both files; engine-e-2-e:dev-sdk-check
    gains test ! -e for both after a real dagger module init typescript.
  • Green alongside manifest:pins-check,
    generate:{generate-workspace-module,generate-idempotent}-check.

Also driven end to end against a real workspace with the SDK vendored from this
checkout: init with and without --entrypoint produces the two manifests above
and the matching trees, and regenerating a [runtime] module that had the
entrypoint files on disk removes them while leaving the entrypoint module alone.

Relationship to #54

Branched off main rather than onto the unified-clients stack, because none of
this has anything to do with unified clients. #54 is untouched.

They are siblings and both rewrite moduleDirectory (plus e2e/generate.dang
and e2e/manifest.dang), so whichever lands second needs a rebase. Land #54
first
— rebasing these two commits over it is cheap, the reverse is not. The
resolution for the stack's shared-client layout is already written down locally
and will come with that rebase; the only extra piece there is
Mod.isEntrypointManifest, which does not exist on main and matches an
[entrypoint] table instead of the version field.

A module is loaded through its [runtime] or through its [entrypoint], and
until now it got the files for both: __dagger.dispatch.ts and
entrypoint/main.dang were written regardless of the setting, so
`dagger module init typescript` produced a manifest-v2 entrypoint beside the
dispatcher its runtime actually execs. Two files nothing read, under names one
word apart from the one that matters.

moduleDirectory now branches on the setting. Not naming a file also skips
rendering it, so a [runtime] module no longer pays for the dang-entrypoint
codegen exec at all.

Writing is only half of it: what the other setting left on disk stays there.
prunedLegacyEntrypoint becomes prunedInactiveDispatch and prunes in both
directions — the legacy dispatcher under an entrypoint, the dispatcher and
entrypoint/ otherwise. That is the upgrade path for every module an earlier
build wrote both halves into.

Signed-off-by: Tom Chauveau <[email protected]>
withEntrypointManifest was the only place in the repo that emitted a
dagger-module.toml by hand, and the only source of `manifestVersion = 2`. It
justified itself by pointing at dagger/dagger#14038's version gate: the builder
never writes that field, so a builder-written manifest would not load there.

That is the wrong way round. The builder's schema is the contract and making
the engine read it is the engine's job — work that is under way. Targeting the
version gate instead meant one generator path diverging from the schema every
other path validates against, with TOML escaping done by hand.

So: load the existing manifest when there is one, drop the legacy fields, add
the Dang entrypoint, and generate. An entrypoint module's tree has no
__dagger.entrypoint.ts, so `[runtime]` does not stay beside `[entrypoint]` —
leaving it would only point an older engine at a file that is not there.

Entrypoint modules therefore load nowhere until the gate comes out. That is
accepted; design/module-entrypoint.md §7.1 records the decision and §7.1.1 says
what not to do about it. The setting is off by default, so nothing a user
generates changes.

Signed-off-by: Tom Chauveau <[email protected]>
@TomChv

TomChv commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

Tested manually with multiple cases:

  • module init typescript -n test 🆗
  • module init typescript -n test-with-entrypoint --entrypoint 🆗
  • module init typescript -n test-migrate-to-entrypoint (we set the settings to entrypoint after) 🆗
  • install a dependency in all these modules, for modules using the runtime it successfully update the dagger-module.toml [[dependencies]] field, for the other modules that supports entrypoint it update the dispatcher to load the module.

All these tests are using dagger/dagger#14038 engine

@TomChv
TomChv merged commit 21c1056 into main Sep 16, 2026
5 checks passed
TomChv added a commit that referenced this pull request Sep 16, 2026
Brings in #55, which split module generation onto one loading path at a time
and moved the entrypoint manifest onto the sdk-helpers builder.

The conflict is moduleDirectory, which both sides restructured. Resolution
keeps #55's shape — one branch per loading path, never both — and puts this
branch's clients/ in the part common to them: the per-module bindings are what
the module's own source imports, which is independent of how the module is
loaded. The dispatcher keeps this branch's signature without targets, since
serve moved onto each client here and the dispatcher no longer stages client
meta.

Signed-off-by: Tom Chauveau <[email protected]>
TomChv added a commit that referenced this pull request Sep 16, 2026
#55 made a module get one loading path's files and not the other's, so a
`[runtime]` module no longer carries a __dagger.dispatch.ts. generateSelfCallCheck
still read one — it was written when both halves were generated — and failed on a
missing file rather than on anything it was checking.

The claim is worth keeping: serving moved onto the clients, so no dispatch file
stages modules of its own. But it can only be asserted where a dispatcher exists,
which is the entrypoint path. Gen.scope gains the `entrypoint` setting, and the
assertion moves to a check of its own covering both paths — the entrypoint's
dispatcher, which this branch took the serving out of, and the legacy entrypoint,
which never had any. generateSelfCallCheck keeps what it is named for.

Also drops the superseded dispatcher-serves-self bullet from the design note; the
per-client serve below it replaced that mechanism.

Signed-off-by: Tom Chauveau <[email protected]>
TomChv added a commit that referenced this pull request Sep 16, 2026
#55 made a module get one loading path's files and not the other's, so a
`[runtime]` module no longer carries a __dagger.dispatch.ts. generateSelfCallCheck
still read one — it was written when both halves were generated — and failed on a
missing file rather than on anything it was checking.

The claim is worth keeping: serving moved onto the clients, so no dispatch file
stages modules of its own. But it can only be asserted where a dispatcher exists,
which is the entrypoint path. Gen.scope gains the `entrypoint` setting, and the
assertion moves to a check of its own covering both paths — the entrypoint's
dispatcher, which this branch took the serving out of, and the legacy entrypoint,
which never had any. generateSelfCallCheck keeps what it is named for.

Also drops the superseded dispatcher-serves-self bullet from the design note; the
per-client serve below it replaced that mechanism.

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.

1 participant