Skip to content

core: version entrypoint modules via dang.toml - #14812

Closed
vito wants to merge 9 commits into
dagger:naming/view-prerelease-gatefrom
vito:entrypoint-dang-toml-version
Closed

vito wants to merge 9 commits into
dagger:naming/view-prerelease-gatefrom
vito:entrypoint-dang-toml-version

Conversation

@vito

@vito vito commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Why

A manifest v2 module (a dagger-module.toml with an [entrypoint] table) declares no engine version. Until now the engine served it at its own version (engine.Version), parsed its Dang at the latest Dang, and skipped the minimum/maximum version checks. Every core API view change, every Dang language change and the upcoming naming cut would reach existing entrypoints silently, on engine upgrade.

Dang can now declare both versions in dang.toml (vito/dang#185, #206, #208), and generated entrypoints will ship one:

dang = "2.1"

[imports.Dagger]
dagger = "v1.0.0-beta.21"

This PR makes the engine read it.

What

  • Which dang.toml. The one governing the entrypoint by Dang's rules, restricted to the module: for a local entrypoint, the nearest dang.toml from the entrypoint directory up to the module directory; for a module reference or address, the named directory's own. A dang.toml above the module directory never counts: a local or Git module context doesn't hold it while a directory source may, so honoring it would make the version depend on how the module was loaded. It's decoded into Dang's own ProjectConfig, so keys parse and validate exactly as Dang reads them.
  • [imports.Dagger] dagger becomes ModuleSource.EngineVersion: API view (through engine.ModuleAPIViewVersion, exactly like a dagger.json engineVersion), naming, default function caching, dependency/core schema view. The min/max checks are re-enabled for entrypoints with the same rules as engineVersion ("module requires dagger vX, but you have vY"). The sources member, which runs before the module exists, is now served at that view too (it was type-checked at it but ran at the engine's own view).
  • dang picks the Dang language version via dang.ContextWithVersion (also when scanning for a sources member).
  • Caching. Both versions key SourceImplementationDigest, so the persisted _moduleTypesDefinition (and anything else keyed on the implementation digest) built under one version never answers for another, even when the dang.toml is outside the module context (remote entrypoints).
  • Spec. future/module-manifest-v2/spec.md gains a Versions section; hack/designs/identifier-casing.md records the outcome for entrypoint naming.

Defaults

Declared Dagger version Dang version
No dang.toml v1.0.0-beta.20 2.1
No Dagger import, or dagger = true v1.0.0-beta.20 as declared
No dang key as declared 2.1 (Dang's DefaultVersion)

v1.0.0-beta.20 is the last release before the naming cut at v1.0.0-beta.21. Versionless entrypoints in the wild were written against beta.16–beta.20 engines: the v1 API, Dang 2.1, the pre-cut naming. With #14810's prerelease-granular views it lands exactly on the shared pre-cut view. The default is pinned: following the running engine is what this PR removes.

The Dang default is DefaultVersion (2.1) even without a dang.toml, rather than Dang's CurrentVersion, for the same reason.

Dependencies and merge order

Behavior changes

  • Move the repository's Go modules to the go-sdk Dang entrypoint #14714 (repo Go modules → go-sdk entrypoints) says "No engineVersion means the v1 view". That stays true: beta.20 is a v1 view, so execs still nest and the DAGGER_SESSION_* handling there is unaffected. What changes is that those modules now get the pre-cut v1 view instead of whatever the running engine serves, so they won't pick up beta.21+ API (renames included) until their generated dang.toml declares a version.
  • A remote entrypoint (module reference or address) is now resolved when the module source loads, not only when its types load, so metadata-only queries such as ModuleSource.engineVersion fetch it and fail if it's unreachable.
  • Existing entrypoint modules get a new implementation digest (one-time cache miss for their type definitions).

Tests

  • Unit: core/sdk/dang/v2/version_test.go (resolution and defaults, prerelease kept, dagger = true/false, conflicting imports, too new/too old, Dang version honored by the parser and the sources scan, default view is pre-cut), core/schema/module_implementation_scoped_test.go (versions key the digest only for entrypoints), core/schema/modulesource_test.go (re-enabled checks).
  • Integration (core/integration/module_entrypoint_version_test.go): default with no dang.toml; declared in/above the entrypoint dir; prerelease; ignored above the module dir for workspace and directory sources; module-reference entrypoint; declared older view rejects Workspace.resolve; sources runs at the declared view; too-new version refused; Dang 2.0 syntax honored only when declared; versionless entrypoint with pre-cut FunctionCachePolicy values.
  • go build ./..., go vet, go test ./core/ ./core/schema/... ./core/sdk/... ./core/modules/..., golangci-lint and markdown-lint pass; the entrypoint integration tests (TestModule/(TestBuiltinDangModuleEntrypoint|TestDangModuleEntrypoint|TestModuleEntrypoint|TestModuleAtLocalRepoRoot)) pass against a dev engine.

Open questions

  1. Where the walk stops. It stops at the module directory rather than at Dang's .git boundary, so a repo-level dang.toml that Dang tooling (LSP, dang CLI) would apply to the entrypoint is ignored by the engine. Generated entrypoints keep theirs in the entrypoint directory, so this only matters for hand-written layouts.
  2. Eager remote resolution (above): acceptable, or should remote entrypoints resolve their versions lazily?
  3. Later betas. Like a dagger.json engineVersion, the max check compares base versions, so a beta.21 engine accepts dagger = "v1.0.0-beta.22" and serves its own latest API under that view. Refusing later prereleases would be a change for both, not just entrypoints.
  4. A floor for entrypoints. Nothing stops dagger = "v0.19.0", older than entrypoints themselves; such an entrypoint gets the v0.19 view, where some of the ModuleEntrypoint contract's API may not exist. Should there be a minimum entrypoint version?
  5. withEngineVersion still overrides an entrypoint module's version (as for any module), and dang = "..." has no API equivalent.
  6. Best-effort parses (ensureModuleSelfTypes) still use the current Dang grammar; an entrypoint declaring an older Dang only loses self-type pre-registration for files that don't parse at 2.1.
  7. Naming gate. core.IdentifierNamingVersion is still v1.0.0-0, so the identifier API (Query.formatIdentifiers) is visible at the beta.20 view. Undeclared entrypoints get legacy naming only once the naming work gates on engine.IdentifierCasingVersion (core: name modules with engine/naming from v1.0.0-beta.21 #14669 / core: rename non-canonical core names from beta.21 #14681).

vito added 9 commits October 22, 2026 13:59
APIViewVersion now keeps a declared prerelease from PrereleaseViewsVersion
(v1.0.0-beta.21) on, so a view gate can separate v1.0.0 betas. Dev builds still
drop their prerelease and share the release's view. Every earlier v1.0.0
prerelease, from v1.0.0-0 to v1.0.0-beta.20, shares the v1.0.0-beta.20 view:
it sorts above every gate set while views were base-granular, so those callers
keep exactly the API they had.

Add IdentifierCasingVersion, the cut for the identifier casing changes, and
APIVersionAtLeast, the same gate for a declared version outside a call.

Refs dagger#13668

Signed-off-by: Alex Suraci <[email protected]>
Prove that a field gated at engine.IdentifierCasingVersion is visible to
beta.21+, dev builds and v1.0.0, and hidden from beta.20 and earlier, including
v1.0.0-0, while gates set before views kept prereleases keep applying to every
v1.0.0 prerelease. Pin that view-scoped calls are cached per view and unscoped
ones are not, and that every pre-cut v1.0.0 prerelease gets one core schema.

Update the version-gating doc and the comments that said views drop
prereleases.

Signed-off-by: Alex Suraci <[email protected]>
While the engine is a v1.0.0 prerelease or dev build, a module declaring exactly
v1.0.0 gets the shared pre-cut view (v1.0.0-beta.20) instead of the release's.
Every sdk-helpers tag and go-sdk declare v1.0.0 and are locked by SDKs and
users; on a beta.21 engine they would otherwise see the renamed API and break
with no way to re-pin a locked tag. The clamp moves that break to v1.0.0 GA.

ModuleAPIViewVersion maps module engineVersions to views (module client
sessions, default schema builders) and backs APIVersionAtLeast. Client versions
keep APIViewVersion.

Proposal pending maintainer sign-off; this commit drops cleanly.

Signed-off-by: Alex Suraci <[email protected]>
Say which mapping applies to modules (ModuleAPIViewVersion) and clients
(APIViewVersion), that fixtures testing API past the cut must declare a
prerelease from the cut on, and that a client's view follows the CLI that
starts its session, not the SDK release it was generated with.

Signed-off-by: Alex Suraci <[email protected]>
Stores written before prerelease-granular views recorded "v1.0.0" as the view
of every v1.0.0 prerelease caller. That view is now the release's, past every
prerelease gate, so a GA or dev-build caller would hit pre-cut results, and
IDs naming fields gated before the cut would stop loading once such gates
exist. Bump the persistence schema so they are wiped on import.

Signed-off-by: Alex Suraci <[email protected]>
Pins github.com/vito/dang/v2 to the head of vito/dang#208, stacked on #206 and
#185. Together they add the `dang` and `[imports.Dagger] dagger` keys of
dang.toml, dang.ContextWithVersion and DaggerSource.VersionString, which keeps
a declared prerelease (v1.0.0-beta.19 stays as is rather than becoming v1.0.0,
past the naming cut). BurntSushi/toml becomes a direct dependency: the engine
decodes an entrypoint's dang.toml into Dang's own ProjectConfig.

This is a pseudo-version of an unmerged branch; re-bump it to a Dang release
before merging.

Signed-off-by: Alex Suraci <[email protected]>
A manifest v2 module had no engine version: it was served at the running
engine's own version and always parsed as the latest Dang, with the minimum and
maximum version checks skipped. Core API view changes, Dang language changes and
the naming cut would all reach existing entrypoints silently.

The engine now reads the dang.toml governing the entrypoint, with Dang's own
types: the nearest one walking up from the entrypoint directory to the module
directory (never above it, so the result does not depend on how the module was
loaded), or the named directory's own for a module reference or address.

- `[imports.Dagger] dagger = "vX.Y.Z"` is the module's engine version: its API
  view (through engine.ModuleAPIViewVersion, like a dagger.json engineVersion),
  naming rules, default caching and dependency schema. It gets the same minimum
  and maximum checks as an engineVersion, at load and in
  loadModuleSourceConfig. The sources member, which runs before the module
  exists, is served at that view too, as types and call are.
- `dang = "X.Y"` is the Dang version the entrypoint is parsed as, set with
  dang.ContextWithVersion (and when scanning for a sources member).

With no Dagger version declared, the engine version is v1.0.0-beta.20, the last
release before the naming cut and the shared pre-cut view, which existing
entrypoints were written against; with no Dang version, Dang's DefaultVersion
(2.1). Both are pinned so an entrypoint that declares nothing keeps its meaning
across engine releases.

Both versions key SourceImplementationDigest, so results such as the persisted
_moduleTypesDefinition built under one version never answer for another, even
when the dang.toml lies outside the module context.

Signed-off-by: Alex Suraci <[email protected]>
Covers the default (v1.0.0-beta.20 with no dang.toml, no Dagger import or
`dagger = true`), a version or prerelease declared in or above the entrypoint
directory and in a module reference, a dang.toml above the module directory
ignored however the module is loaded, the declared API view gating
Workspace.resolve and serving sources, a too-new version refused with "module
requires dagger ...", the declared Dang version, and a versionless entrypoint
that spells the pre-cut FunctionCachePolicy values.

Signed-off-by: Alex Suraci <[email protected]>
The manifest v2 spec gains a Versions section: the dang.toml keys, which
dang.toml the engine reads, the defaults and why they are pinned. The identifier
casing design records that entrypoints pin their naming through it.

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit to dagger/typescript-sdk that referenced this pull request Oct 22, 2026
dagger/dagger#14812 serves an entrypoint module at the Dagger version its
dang.toml declares ([imports.Dagger] dagger), and at v1.0.0-beta.20 when it
declares none. Write entrypoint/dang.toml beside main.dang with dang = "2.1"
and that version: the running engine's (minus build metadata) for a module
being initialized, v1.0.0-beta.20 for one that already had an entrypoint, so
regenerating never moves it onto the beta.21 naming. An existing dang.toml is
kept as it is.

It is written with the manifest, before the module's schema is read, so the
bindings and the entrypoint are generated for the version the engine will
serve. Engines before beta.21 get no file. The Dang entrypoint's
FunctionCachePolicy spellings stay Default/PerSession/Never, valid on every
view per dagger/dagger#14681.

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit to dagger/python-sdk that referenced this pull request Oct 22, 2026
The engine reads `[imports.Dagger] dagger` from a dang.toml beside an
entrypoint (dagger/dagger#14812) and serves it at v1.0.0-beta.20 without
one. The entrypoint generated into a module now ships one, and the scope is
generated in that version's view, so bindings and calls agree.

A new module declares the engine it is created on, without build metadata,
and so gets the engine's naming from beta.21. A module that already had an
entrypoint but no dang.toml gets beta.20, what the engine already serves it,
so regenerating never moves it silently. An existing dang.toml is kept.

FunctionCachePolicy keeps its old spellings: they stay valid in every view.

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit to dagger/go-sdk that referenced this pull request Oct 22, 2026
Generated Dang entrypoints now come with a dang.toml beside them, declaring
dang = "2.1" and [imports.Dagger] dagger = "<version>". Engines with
dagger/dagger#14812 serve an entrypoint module the API, and name it by the
rules, of that version; without one they serve v1.0.0-beta.20, the last
version before the naming cut. Older engines copy only the .dang files and
ignore it.

The version follows the module, like a runtime module's engineVersion:
- a dang.toml that declares one is kept, and the bindings are generated for
  it (one without a version is refused rather than rewritten);
- an existing entrypoint without dang.toml gets v1.0.0-beta.20, what engines
  serve it today, so generating again never renames its API;
- a new module, or one migrating from the Go runtime, gets the running
  engine's version (sdk-helpers' normalizeEngineVersion).

The file is not generated code: it is the module's declaration to change.

FunctionCachePolicy keeps its Default/PerSession/Never spelling: those
stay valid at every view (dagger/dagger#14681), so the entrypoint needs no
version-dependent spelling.

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit to dagger/go-sdk that referenced this pull request Oct 22, 2026
Look for the module's dang.toml from the entrypoint directory up to the
module directory, as the engine does (dagger/dagger#14812), both to pick the
version to generate for and before writing one. A dang.toml without a Dagger
version, or with dagger = true, is what engines serve at v1.0.0-beta.20, so
it generates for that instead of being refused.

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit to dagger/java-sdk that referenced this pull request Oct 22, 2026
dagger/dagger#14812 serves an entrypoint module at the Dagger and
Dang versions of the dang.toml next to its entrypoint, and at
v1.0.0-beta.20 without one. Generation now writes one: dang = "2.1"
and [imports.Dagger] dagger = the running engine's version for a new
module. An existing module is never moved: an entrypoint without a
dang.toml gets v1.0.0-beta.20, a module migrated from the runtime its
engineVersion (at least v1.0.0-beta.20), and a dang.toml the module
has is kept as it is.

The staged manifest the module's schema is read through declares the
same version, so the Java code is generated against the API, and the
naming rules, the engine serves the entrypoint at.

The generated main.dang keeps FunctionCachePolicy.Never/PerSession/
Default, which every view accepts.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito force-pushed the naming/view-prerelease-gate branch from 2873e64 to 94fdbda Compare October 27, 2026 20:05
@vito
vito force-pushed the naming/view-prerelease-gate branch from e65f47e to b4aa8d8 Compare October 28, 2026 16:11
@vito vito closed this Oct 28, 2026
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