Skip to content

core: version Dang modules via dang.toml, one Dang library - #14958

Merged
vito merged 13 commits into
naming/entrypoint-dang-toml-versionfrom
naming/single-dang-sdk
Nov 5, 2026
Merged

vito merged 13 commits into
naming/entrypoint-dang-toml-versionfrom
naming/single-dang-sdk

Conversation

@vito

@vito vito commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

This PR makes dang.toml authoritative for regular Dang modules and runs all supported Dang language versions through one library. It removes core/sdk/dang/v1 and the v1 dependency; older modules run on the v2 library in Dang 1.0 mode.

Source and SDK mutations re-resolve the governing configuration while preserving explicit API-chain overrides and their cache identity.

Version selection

Regular Dang SDK modules (sdk = "dang" or [runtime] source = "dang") now use the same configuration-resolution mechanism as entrypoints:

  • An explicit [imports.Dagger] dagger = "vX.Y.Z" selects the module's API view, naming rules, caching defaults and compatibility checks. On a fresh load it takes precedence over the manifest's engineVersion, with a warning if they disagree.
  • Without a Dagger version in dang.toml, regular modules retain the manifest version. dagger = true also retains it; entrypoints keep their separate pinned beta.25 default.
  • dang = "X.Y" explicitly selects the language version, independently of the Dagger API version. Without it, modules targeting an engine before v0.21.5 default to Dang 1.0. Later modules use the linked library's current version when there is no config, or its default version when a config omits the key; both are currently 2.1.
  • Runtime evaluation and the engine's own source parses—such as declared names and object directives—use the resolved language version.

Configuration and mutations

  • Discovery: use the nearest dang.toml from the source directory up to the module directory, never above it. Source context includes those config paths. Where Dang's own discovery would escape that boundary, source isolation prevents the parent config from changing the engine-selected versions.
  • Warnings: a conflicting config version produces warning: dang.toml overrides engineVersion in progress output and the engine log. It is load-time output, not repeated on cached loads.
  • Writes: generated configuration retains the manifest's original engineVersion and optional caching setting unless an explicit withEngineVersion supplies the version to write. The resolved dang.toml version is not copied back into the manifest, and the engine does not write dang.toml. Entrypoint overrides remain chain-only.
  • Mutation ordering: source/subpath changes, relevant context reloads, and SDK switches/removal re-resolve configuration before evaluating entrypoint sources. An explicit engine-version override survives the API chain, including an override equal to the previous effective value. It changes an undeclared grammar's default, not an explicit dang declaration. A fresh load reads the config again.
  • Cache identity: resolved API/language versions and the manifest/override/caching provenance participate in implementation-scope identity. Two sources with equal effective versions can behave differently after mutation, so provenance must survive cloning, persistence and warmed scope caches.
  • Errors: unsupported language versions tell the user to upgrade Dagger, which embeds the Dang runtime.

One Dang runtime

All language modes now run on the pinned vito/dang/v2 library. Dang 1.0 modules retain full type inference unless they enable self-calls.

The linked runtime includes the language-version fixes for rescue and shadowing the loop builtin. Existing integration coverage exercises a legacy module with its own loop, a rescue field and a rescue argument.

Historical differential testing against Dang v1's language suite found matching successful-program outcomes, but v2 accepted three programs from v1's error corpus because of type widening. This is not a claim that every v1 rejection is preserved.

Out of scope

  • Honoring other dang.toml imports in-engine, such as local paths and services; that still needs a separate design.
  • Changing dang-sdk's init/version-management commands to write dang.toml. This PR changes engine reading and execution, not SDK configuration generation.

Validation

Existing integration coverage in core/integration/module_dang_toml_test.go includes:

  • TestDangTomlEngineVersion: config precedence/defaults, discovery boundaries, source subdirectories, Directory sources, config writes, version rejection and mismatch warnings.
  • TestDangTomlNamingCut: module naming selected through dang.toml.
  • TestDangTomlDangVersion: language defaults/overrides, unsupported versions, parent-config isolation, inference and legacy-language constructs. The legacy loop/rescue case asserts both the function result and field value.
  • TestDangTomlVersionMutations: real public source/SDK mutation chains and module loads, including equal-valued overrides, config writes, fresh loads, declared/default grammar and receiver immutability.

Focused units cover version resolution, engine-side parsing, source isolation, implementation digests, source/SDK mutations, explicit override ordering, raw optional caching settings, persistence and warmed-scope provenance.

Fresh source-engine validation passed 30 cases selected by ^TestDang$/^TestDangToml(VersionMutations|DangVersion|EngineVersion|NamingCut)$, plus focused version/provenance units. Disabling version re-resolution in withSourceSubpath made three new cases fail, including a real grammar load; restoring it passed again. The duplicate legacy-language unit was removed after its remaining field assertion moved into integration coverage.

Earlier revisions passed targeted Dang, entrypoint, workspace and module-loading integrations. The original mutation/provenance fixes had bounded unit coverage; the public-API integration above now supplements it. Historical build/vet passed with pre-existing lostcancel warnings disabled and schema regeneration was clean. No broader integration or historical differential suite was rerun for this cleanup.

API changes

go -C hack/sdl-diff run . 8fbb7504a2c34632efdaf2a4b5a7a6fcc3d712e8:docs/docs-graphql/schema.graphqls aa85b3d92685835af7e516378673514e43742b7b:docs/docs-graphql/schema.graphqls

No semantic API changes.

vito added a commit that referenced this pull request Oct 29, 2026
Fill in the PR number of the dang.toml and single Dang library fragments.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito added this pull request to stack #14901 October 29, 2026 13:43
@vito
vito marked this pull request as ready for review October 29, 2026 14:25
vito added a commit that referenced this pull request Oct 29, 2026
Fill in the PR number of the dang.toml and single Dang library fragments.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito force-pushed the naming/single-dang-sdk branch from 310fe48 to 3ca1149 Compare October 29, 2026 19:11
@vito
vito requested review from a team as code owners October 29, 2026 19:11
@vito
vito force-pushed the naming/single-dang-sdk branch from 3ca1149 to 1f66cdb Compare October 29, 2026 22:07
vito added a commit that referenced this pull request Nov 2, 2026
Fill in the PR number of the dang.toml and single Dang library fragments.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito force-pushed the naming/single-dang-sdk branch from 1f66cdb to 2a576c0 Compare November 2, 2026 15:57
eunomie added a commit to dagger/go-sdk that referenced this pull request Nov 4, 2026
Released engines ignore the file, so only the dagger/dagger#14958 stack
can show that the generated declaration takes effect.

Signed-off-by: Yves Brissaud <[email protected]>
eunomie added a commit to dagger/go-sdk that referenced this pull request Nov 4, 2026
* go: default new modules to a pre-cut target

An engine with dagger/dagger#14902 serves an entrypoint module at the
release its dang.toml declares, else v1.0.0-beta.24, so bindings from a
running v1.0.0-beta.25 engine would use names that view lacks.

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Yves Brissaud <[email protected]>

* go: document versions served to pre-cut modules

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Yves Brissaud <[email protected]>

* deps: bump sdk-helpers to v1.0.8

The dang.toml writer calls loadDangConfig, which first ships in v1.0.8.

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

* feat(go): write dang.toml for generated entrypoints

dagger/dagger#14902 reads the entrypoint's Dagger import to choose the
version it serves the module at.

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

* test(go): check the engine serves the dang.toml version

Released engines ignore the file, so only the dagger/dagger#14958 stack
can show that the generated declaration takes effect.

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

* docs(go): explain the generated dang.toml

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

---------

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Yves Brissaud <[email protected]>
Co-authored-by: Yves Brissaud <[email protected]>
vito added a commit that referenced this pull request Nov 4, 2026
Fill in the PR number of the dang.toml and single Dang library fragments.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito force-pushed the naming/single-dang-sdk branch from 2a576c0 to b604cb5 Compare November 4, 2026 16:29
vito added a commit that referenced this pull request Nov 4, 2026
Fill in the PR number of the dang.toml and single Dang library fragments.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito force-pushed the naming/single-dang-sdk branch from 7d8964a to a33a182 Compare November 4, 2026 19:05
vito added a commit that referenced this pull request Nov 5, 2026
Fill in the PR number of the dang.toml and single Dang library fragments.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito force-pushed the naming/single-dang-sdk branch from a8a4997 to 6aa6526 Compare November 5, 2026 00:05
@vito
vito force-pushed the naming/single-dang-sdk branch from 6aa6526 to 735890a Compare November 5, 2026 00:14
vito added a commit that referenced this pull request Nov 5, 2026
Fill in the PR number of the dang.toml and single Dang library fragments.

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit that referenced this pull request Nov 5, 2026
Fill in the PR number of the dang.toml and single Dang library fragments.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito force-pushed the naming/single-dang-sdk branch from 735890a to aa85b3d Compare November 5, 2026 03:38
vito added 11 commits November 5, 2026 11:28
A Dang SDK module's dang.toml was ignored: the runtime presets its Dagger
import, so Dang never reads the file, and its `dagger` and `dang` keys did
nothing. Its engine version came only from dagger.json, and its Dang version
only from that engine version.

The engine now reads the dang.toml governing a Dang SDK module, as #14902 does
for entrypoints, with the same resolution code (dangv2.ResolveModuleVersions
beside ResolveEntrypointVersions): the nearest one walking up from the source
directory to the module directory, never above it, as for an entrypoint.

- `[imports.Dagger] dagger` wins over dagger.json's engineVersion: view,
  naming, default caching, compat checks. The engine warns, in its log and on
  a span of its own, when the two disagree. `dagger = true` keeps the
  engineVersion, as the Dang CLI reads it.
- `dang` is the Dang version. Without one, a module before v0.21.5 is Dang 1.0
  and a later one is left to Dang, as before; the Dang major is now picked by
  that version rather than by the engine version.
- Both key SourceImplementationDigest for every Dang module (the resolved Dang
  version can follow the engine's Dang, whatever the source), and the
  engine's own parses of the source (declared type names, object directives)
  parse it as its version.
- A `dang` version newer than the engine's Dang says to upgrade Dagger, not
  Dang.

ModuleSource.EntrypointDangVersion becomes DangVersion.

Signed-off-by: Alex Suraci <[email protected]>
A dang.toml's Dagger version replaced ModuleSource.EngineVersion, which every
config write (develop, install, generate) copied into dagger.json, silently
rewriting the manifest's engineVersion and hiding the mismatch warning from then
on. The caching default it decides leaked the same way: a dang.toml before
v0.19.4 added `disableDefaultFunctionCaching: true`, which later loads read as
explicit.

ModuleSource.ConfigEngineVersion and ConfigDisableDefaultFunctionCaching keep
the manifest's own for config writes. withEngineVersion sets the former too,
and recomputes the default Dang version of a Dang module whose dang.toml
declares none, as loading does (ModuleSource.DangVersionDeclared). Also
restores version.go doc comments that the previous commit reverted to older
wording.

Signed-off-by: Alex Suraci <[email protected]>
Dang walks up from a module's source to a .git for the dang.toml that decides
its version, past the module directory the engine stops at, so a dang.toml
above it in the module context (a directory source's parent) could still
decide the syntax. Such a source now runs from an isolated copy of its .dang
files, so the versions the engine resolved decide. A source without a Dang
version (one given the Dang SDK by withSDK) gets the default for its engine
version.

Tests cover config writes keeping engineVersion and the caching default, a
`dang` version above a directory source's module, and a Dang 1.0 module with
fields typed by their values.

Signed-off-by: Alex Suraci <[email protected]>
The Dang module skill said engineVersion alone picks the Dang major. A
dang.toml now declares both versions and wins over dagger.json.

Signed-off-by: Alex Suraci <[email protected]>
The engine linked two Dang libraries, the v1 line for Dang 1.0 modules (by
default, an engineVersion before v0.21.5) and the v2 line for the rest, with
core/sdk/dang/v1 a frozen copy of the SDK glue. The split was a stopgap for
versioning, which `dang = "1.0"` now covers.

Dang v2 parses every Dang language version since 1.0 into the same AST, gating
changed syntax, so a Dang 1.0 module now runs on the v2 line in Dang 1.0 mode:
ModuleSource.DangVersion is already "1.0" for it. As the SDK of the v1 line
did, a Dang 1.0 module builds its types with full inference (dang.RunDir)
unless it enables self calls itself; declaring alone would leave a `pub` field
with no annotation and a computed value untyped.

Against the Dang v1.0.1 language suite (233 programs, with its GraphQL test
server), v2.2.0 in 1.0 mode gives the same outcome and output for each. Two
known gaps remain, documented in the README and changelog, with a fix in
progress in vito/dang: `rescue` is reserved in every version, and the `loop`
builtin takes precedence over a module's own `loop` binding.

Drops core/sdk/dang/v1 and github.com/vito/dang v1.

Signed-off-by: Alex Suraci <[email protected]>
Fill in the PR number of the dang.toml and single Dang library fragments.

Signed-off-by: Alex Suraci <[email protected]>
Dang v2.3.0 (vito/dang#212) reserves `rescue` only from Dang 2.1 and lets a
module's own declarations shadow builtins in every version, so a Dang 1.0
module that names something `rescue` or defines its own `loop` runs as it did
on the Dang v1 line. That closes the two known gaps of Dang 1.0 mode; the
README and changelog no longer list them.

Its language versions are unchanged (CurrentVersion and DefaultVersion stay
2.1), and no engine call site changed. Unit and integration tests cover a Dang
1.0 module using both names.

Signed-off-by: Alex Suraci <[email protected]>
Use main's context-aware parser for versioned source reads so prepared
compilation and the shared syntax cache remain intact. Adapt the existing
version assertions to pass the grammar version through context.

Signed-off-by: Alex Suraci <[email protected]>
Keep manifest fallbacks, optional caching configuration, and explicit
withEngineVersion provenance separate from resolved values. Source and SDK
changes recompute versions from raw context before evaluating entrypoint
sources; API-chain overrides survive, but fresh loads read dang.toml again.

Cover construction order, declared/default grammar, SDK removal, config
writes, entrypoint reload ordering, cloning and persistence with finite
regressions.

Signed-off-by: Alex Suraci <[email protected]>
Equal effective versions can still behave differently after source/SDK
mutations. Include manifest fallback, explicit override and optional caching
provenance in the implementation digest used by source and module scopes,
so warming one variant cannot erase another's override.

Signed-off-by: Alex Suraci <[email protected]>
Exercise source and SDK changes with real module loads, including equal-valued
engine overrides, declared versus default grammar, and config-write reloads.
Clarify the explicit override exception in the existing SDK documentation.

Query both legacy rescue and loop behavior through the engine and remove the
now-redundant interpreter-only test. Keep the distinct provenance, persistence,
and caching invariant units.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito force-pushed the naming/single-dang-sdk branch from aa85b3d to 34ef8d7 Compare November 5, 2026 16:28
vito added a commit that referenced this pull request Nov 5, 2026
Fill in the PR number of the dang.toml and single Dang library fragments.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito force-pushed the naming/single-dang-sdk branch from 34ef8d7 to 9fa6864 Compare November 5, 2026 17:36
@vito
vito force-pushed the naming/single-dang-sdk branch from 9fa6864 to 635d012 Compare November 5, 2026 20:06
The sparse workspace config reader only needs the populated module source.
Ignore the parsed config now returned by initFromModConfig and retain the
existing error handling so the caller matches the updated signature.

Signed-off-by: Alex Suraci <[email protected]>
Address golangci-lint findings: initFromModConfig no longer returns the
parsed config no caller used (unparam), the test's path if/else chain is
a tagged switch (QF1003), and the unused entrypointDangVersion helper is
removed.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito merged commit 7e9eaac into main Nov 5, 2026
95 checks passed
@vito
vito deleted the naming/single-dang-sdk branch November 5, 2026 21:43
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