GeezerVison is showing github.com — fix(dang): correct namespaced type-name mangling; cross-dependency interface dispatch by vito · Pull Request #13377 · dagger/dagger
Conversation
vito
commented
Jun 9, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Fixes a Dang SDK namespacing bug and adds cross-dependency interface support.
strcase.ToCamel (gqlObjectName) is not idempotent: re-applying it to an already-final, module-namespaced type name lowercases word boundaries, so a namespaced interface that should be ModuleAOverlay came back as ModuleAoverlay. The corruption stayed hidden because the mangled names were ToCamel fixed-points, so the round-trips that rebuild a typedef from its name were accidentally idempotent — until a name that isn't a fixed point (a module whose camelCased name ends in a lone capital abutting a PascalCase subtype, e.g. moduleA + Overlay) flows through.
This keeps the existing collapsed naming convention (ModuleAOverlay) and fixes it at the layer where it breaks: every path that rebuilds a typedef from an already-final type name now preserves that name verbatim instead of running it back through ToCamel.
(An earlier revision of this branch standardized on an underscore separator — ModuleA_Overlay — for namespace hygiene, but that required fixing a long tail of ToCamel-on-namespaced-name sites across the engine, CLI, and interpreter, so it was dropped from this PR's scope. Some comments still use ModuleA_Overlay as an illustrative example.)
closes #13364
What's here
Preserve already-final type names (the core fix):
- The internal
__withName setters (object/interface/enum typedefs) store names verbatim; raw SDK names are still normalized once at creation (NewObjectTypeDef etc.).
InterfaceType.Install uses the name as-is, matching how objects install (ModuleObject.TypeDefinition).
- Typedef-reconstruction paths go through a new
SelectReferenceTypeDef helper: {Interface,ModuleObject,ModuleEnum}Type.TypeDef, the ModTypeFor lookups in interface.go, and — the best-hidden site — introspectionRefToTypeDef/resolveIDScalar in coremod.go, which rebuild the Query typedef from live schema introspection (a module's main-object functions promoted onto the Query root) and were re-collapsing enum/object/interface/scalar references. That surfaced as arguments resolving to empty-member stubs (e.g. a Dang module's enum flag showing no valid values).
Dang cross-dependency interface dispatch (self-calls run path):
- The interpreted runtime resolves its own types by name against the runtime schema, so it needs self-calls to invoke a method on an interface value received across a dependency boundary. A single
ModuleSource.SelfCallsEnabled() predicate covers both the SELF_CALLS flag and an always-on SDK capability that the Dang SDK opts into (persisted so cached module sources stay enabled). Routing both paths through one predicate keeps them consistent — an inconsistency would let a module's own types be both installed and rejected as duplicates.
- The eager
asModule in runCodegen stays gated on the explicit flag, since it type-checks the source purely to feed code generation and must not run for SDKs (like Dang) whose codegen is a no-op — otherwise dagger init/install fails on uninitialized or not-yet-installed-dependency source.
- At runtime the interpreter maps module-local type names to their namespaced schema names when building
node(id) queries, falling back to the local name for types already present (e.g. dependency types).
Tests
The full TestDang integration suite passes on the dev engine — enums, mismatch, core-type shadowing, and a new cross-dependency structural-interface run-path test (consume structural interface value across dependencies, asserting only that the run succeeds). Go SDK self-calls and the SDK-capability persistence are covered, and go test ./core ./core/schema is green.
🤖 Generated with Claude Code
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
vito
changed the title
fix: namespace Dang module types with underscore separator
fix(dang): correct namespaced type-name mangling; cross-dependency interface dispatch
Jun 9, 2026
The internal __withName setters and the typedef reconstruction paths
re-ran strcase.ToCamel on names that were already final and module-
namespaced. ToCamel is not idempotent: when a module name ends in a lone
capital (moduleA -> ModuleA) abutting a PascalCase subtype, a second
pass lowercased the boundary, turning "ModuleAOverlay" into
"ModuleAoverlay". The corruption stayed hidden because the mangled names
were ToCamel fixed-points, so the round-trips that rebuild a typedef
from a type's name were accidentally idempotent.
Store __withName names verbatim (raw SDK names are still normalized at
creation via withObject/withInterface), stop the interface install path
from re-normalizing, and route the reconstruction sites
(ModType.TypeDef and the ModTypeFor lookups in interface.go) through a
helper that keeps the already-final name.
Signed-off-by: Alex Suraci <[email protected]>
currentTypeDefs rebuilds the Query typedef from live schema
introspection, reconstructing each enum/object/interface/scalar reference
with a bare withEnum/withObject/withInterface/withScalar selector. Those
constructors run the name through strcase.ToCamel, which is not
idempotent: an already-final, module-namespaced name like
"TestEnum_Status" collapses to "TestEnumStatus". The collapsed reference
then diverges from the served definition, so consumers that resolve it by
name -- the CLI building arg flags, cross-module dispatch -- find an empty
stub instead of the real type. This is what broke Dang modules' enum,
object, and interface references once the namespace separator was kept.
Route these reconstructions through SelectReferenceTypeDef, which
preserves the final name verbatim, matching the fix already applied to the
other typedef-reconstruction sites. resolveIDScalar gets the same
treatment for the @expectedType directive's object/interface names. A new
SelectReferenceTypeDefWithServer variant lets these run against the
module's dependency schema rather than the current call's server.
Signed-off-by: Alex Suraci <[email protected]>
Self-calls could only be turned on via the SELF_CALLS experimental flag,
but the interpreted Dang SDK always needs them: it resolves its own types
by name against the runtime schema, so a module's own types must be
present in the schema it queries (e.g. to call a method on an interface
value received across a dependency).
Add a single ModuleSource.SelfCallsEnabled predicate that is true when the
flag is set or the SDK reports the new AlwaysEnablesSelfCalls capability,
and route every call site through it; the Dang SDK opts in. Routing both
paths through one predicate keeps them consistent -- an inconsistency
would let a module's own types be both installed and rejected as
duplicates. The eager asModule in runCodegen stays gated on the explicit
flag, since it type-checks the source purely to feed code generation and
must not run for SDKs (like Dang) whose codegen is a no-op.
Signed-off-by: Alex Suraci <[email protected]>
A Dang module's own types are local in its source (e.g. an interface
"Overlay") but module-namespaced in the schema it queries against
("ModuleA_Overlay"). When marshaling a received interface value into a
runtime node query, the interpreter referenced the local name, so the
query and its inline fragment named a type that does not exist in the
schema and the cross-dependency call failed.
Thread the executing module's name through the eval context and resolve
local type names to their namespaced schema names when building node
queries, falling back to the local name for types already present (e.g.
dependency types). NamespaceObject is exported from core so the runtime
can reuse the engine's namespacing rule rather than duplicating it.
Signed-off-by: Alex Suraci <[email protected]>
Add a subtest that calls a Dang module which receives a structural
interface value across a dependency boundary and invokes a method on it,
asserting only that the run succeeds. The test-interface module now
implements Dep_Greeter, the namespaced name of the dependency's Greeter
interface under the underscore convention.
Signed-off-by: Alex Suraci <[email protected]>
Record whether an SDK always enables self calls in ModuleSource persistence and
replay that capability through the lazy SDK wrapper. This keeps Dang module
sources self-call enabled after they are reloaded from cache.
Signed-off-by: Alex Suraci <[email protected]>
Keep the Dang integration test independent of shared module test helpers by
using local Dang-specific module init helpers. This avoids compile failures in
runs that do not include the generic helper definitions.
Signed-off-by: Alex Suraci <[email protected]>
withFinalTypeName preserved already-final names for object, interface,
and enum typedefs but fell through to a silent no-op for scalars, even
though SelectReferenceTypeDef is used with withScalar (e.g. in
coremod.go's Query rebuild). A reconstructed scalar reference therefore
kept the strcase.ToCamel'd name, diverging from the served scalar when
the namespaced name is not a ToCamel fixed-point — a module whose
camelCased name ends in a lone capital, e.g. module-a's "ModuleAToken"
collapsing to "ModuleAtoken".
Add a verbatim ScalarTypeDef.WithName plus its __withName field and a
scalar case in withFinalTypeName. The divergence was harmless in
practice — custom scalars are opaque, so unlike enums and objects they
carry no members or fields to resolve by name — but the helper was
dishonest and a footgun for future callers. A Dang integration test
covers a namespaced custom scalar argument.
Signed-off-by: Alex Suraci <[email protected]>
An earlier revision of this branch standardized type namespacing on an
underscore separator (ModuleA_Overlay), but that was dropped; the
collapsed form (ModuleAOverlay) is what the engine serves. Update the
lingering underscore examples in the runtime type-name mapping comments
to match.
Signed-off-by: Alex Suraci <[email protected]>
withFinalTypeName's scalar case (added so SelectReferenceTypeDef stays
correct for every kind, including coremod.go's withScalar reconstruction)
cannot be exercised yet: Dagger modules don't expose custom scalars as
distinct module-namespaced types. A Dang `scalar Foo` resolves to String,
and the only scalars in a schema are core ones whose names are already
strcase.ToCamel fixed-points, so there is no manglable namespaced scalar
to preserve.
Drop the integration test and fixture that appeared to cover this but in
fact passed regardless of the fix, and document the branch as speculative
so the plumbing is kept for when module-defined custom scalars land.
Signed-off-by: Alex Suraci <[email protected]>
The runtime needs the executing module's name to map the module's own local
type names to the namespaced names its schema exposes, but that name was being
smuggled through context.Context, which read as a smell. Move the
value-marshaling helpers onto a dangConverter that carries the resolution scope
and the module identity, so the name is passed explicitly and context.Context
is back to carrying only cancellation and telemetry.
The conversion helpers were a cohesive cluster that all threaded the same
(ctx, env) pair, so making them methods also sheds the repeated env argument.
Behavior is unchanged and the change is confined to Dang v2; v1 stays frozen.
Signed-off-by: Alex Suraci <[email protected]>
The converter only ever marshals values for a live function call, whose
moduleContext is a populated ObjectResult, so Self() is never nil and the
module always has a name. The nil check in eval and the known() fallback in
schemaTypeName could therefore never fire; remove them so the module identity
is built and namespaced unconditionally. Confined to Dang v2.
Signed-off-by: Alex Suraci <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
marcosnils
pushed a commit
that referenced
this pull request
Jun 10, 2026
…terface dispatch (#13377)
* fix(core): preserve final type names when rebuilding typedefs
The internal __withName setters and the typedef reconstruction paths
re-ran strcase.ToCamel on names that were already final and module-
namespaced. ToCamel is not idempotent: when a module name ends in a lone
capital (moduleA -> ModuleA) abutting a PascalCase subtype, a second
pass lowercased the boundary, turning "ModuleAOverlay" into
"ModuleAoverlay". The corruption stayed hidden because the mangled names
were ToCamel fixed-points, so the round-trips that rebuild a typedef
from a type's name were accidentally idempotent.
Store __withName names verbatim (raw SDK names are still normalized at
creation via withObject/withInterface), stop the interface install path
from re-normalizing, and route the reconstruction sites
(ModType.TypeDef and the ModTypeFor lookups in interface.go) through a
helper that keeps the already-final name.
Signed-off-by: Alex Suraci <[email protected]>
* fix(core): keep final type names in Query rebuild
currentTypeDefs rebuilds the Query typedef from live schema
introspection, reconstructing each enum/object/interface/scalar reference
with a bare withEnum/withObject/withInterface/withScalar selector. Those
constructors run the name through strcase.ToCamel, which is not
idempotent: an already-final, module-namespaced name like
"TestEnum_Status" collapses to "TestEnumStatus". The collapsed reference
then diverges from the served definition, so consumers that resolve it by
name -- the CLI building arg flags, cross-module dispatch -- find an empty
stub instead of the real type. This is what broke Dang modules' enum,
object, and interface references once the namespace separator was kept.
Route these reconstructions through SelectReferenceTypeDef, which
preserves the final name verbatim, matching the fix already applied to the
other typedef-reconstruction sites. resolveIDScalar gets the same
treatment for the @expectedType directive's object/interface names. A new
SelectReferenceTypeDefWithServer variant lets these run against the
module's dependency schema rather than the current call's server.
Signed-off-by: Alex Suraci <[email protected]>
* feat(core): unify self-calls enablement check
Self-calls could only be turned on via the SELF_CALLS experimental flag,
but the interpreted Dang SDK always needs them: it resolves its own types
by name against the runtime schema, so a module's own types must be
present in the schema it queries (e.g. to call a method on an interface
value received across a dependency).
Add a single ModuleSource.SelfCallsEnabled predicate that is true when the
flag is set or the SDK reports the new AlwaysEnablesSelfCalls capability,
and route every call site through it; the Dang SDK opts in. Routing both
paths through one predicate keeps them consistent -- an inconsistency
would let a module's own types be both installed and rejected as
duplicates. The eager asModule in runCodegen stays gated on the explicit
flag, since it type-checks the source purely to feed code generation and
must not run for SDKs (like Dang) whose codegen is a no-op.
Signed-off-by: Alex Suraci <[email protected]>
* fix(dang): map local type names to schema names
A Dang module's own types are local in its source (e.g. an interface
"Overlay") but module-namespaced in the schema it queries against
("ModuleA_Overlay"). When marshaling a received interface value into a
runtime node query, the interpreter referenced the local name, so the
query and its inline fragment named a type that does not exist in the
schema and the cross-dependency call failed.
Thread the executing module's name through the eval context and resolve
local type names to their namespaced schema names when building node
queries, falling back to the local name for types already present (e.g.
dependency types). NamespaceObject is exported from core so the runtime
can reuse the engine's namespacing rule rather than duplicating it.
Signed-off-by: Alex Suraci <[email protected]>
* test(dang): cover cross-dep interface dispatch
Add a subtest that calls a Dang module which receives a structural
interface value across a dependency boundary and invokes a method on it,
asserting only that the run succeeds. The test-interface module now
implements Dep_Greeter, the namespaced name of the dependency's Greeter
interface under the underscore convention.
Signed-off-by: Alex Suraci <[email protected]>
* fix(core): persist SDK self-call capability
Record whether an SDK always enables self calls in ModuleSource persistence and
replay that capability through the lazy SDK wrapper. This keeps Dang module
sources self-call enabled after they are reloaded from cache.
Signed-off-by: Alex Suraci <[email protected]>
* test(dang): use local init helpers
Keep the Dang integration test independent of shared module test helpers by
using local Dang-specific module init helpers. This avoids compile failures in
runs that do not include the generic helper definitions.
Signed-off-by: Alex Suraci <[email protected]>
* ununderscore
Signed-off-by: Alex Suraci <[email protected]>
* test(dang): switch to fixture for cross-dep test
Signed-off-by: Alex Suraci <[email protected]>
* fix(core): preserve final type names for scalars too
withFinalTypeName preserved already-final names for object, interface,
and enum typedefs but fell through to a silent no-op for scalars, even
though SelectReferenceTypeDef is used with withScalar (e.g. in
coremod.go's Query rebuild). A reconstructed scalar reference therefore
kept the strcase.ToCamel'd name, diverging from the served scalar when
the namespaced name is not a ToCamel fixed-point — a module whose
camelCased name ends in a lone capital, e.g. module-a's "ModuleAToken"
collapsing to "ModuleAtoken".
Add a verbatim ScalarTypeDef.WithName plus its __withName field and a
scalar case in withFinalTypeName. The divergence was harmless in
practice — custom scalars are opaque, so unlike enums and objects they
carry no members or fields to resolve by name — but the helper was
dishonest and a footgun for future callers. A Dang integration test
covers a namespaced custom scalar argument.
Signed-off-by: Alex Suraci <[email protected]>
* docs(dang): fix namespaced-name examples in comments
An earlier revision of this branch standardized type namespacing on an
underscore separator (ModuleA_Overlay), but that was dropped; the
collapsed form (ModuleAOverlay) is what the engine serves. Update the
lingering underscore examples in the runtime type-name mapping comments
to match.
Signed-off-by: Alex Suraci <[email protected]>
* core: mark scalar typedef rename as speculative
withFinalTypeName's scalar case (added so SelectReferenceTypeDef stays
correct for every kind, including coremod.go's withScalar reconstruction)
cannot be exercised yet: Dagger modules don't expose custom scalars as
distinct module-namespaced types. A Dang `scalar Foo` resolves to String,
and the only scalars in a schema are core ones whose names are already
strcase.ToCamel fixed-points, so there is no manglable namespaced scalar
to preserve.
Drop the integration test and fixture that appeared to cover this but in
fact passed regardless of the fix, and document the branch as speculative
so the plumbing is kept for when module-defined custom scalars land.
Signed-off-by: Alex Suraci <[email protected]>
* dang: marshal call values via a converter struct
The runtime needs the executing module's name to map the module's own local
type names to the namespaced names its schema exposes, but that name was being
smuggled through context.Context, which read as a smell. Move the
value-marshaling helpers onto a dangConverter that carries the resolution scope
and the module identity, so the name is passed explicitly and context.Context
is back to carrying only cancellation and telemetry.
The conversion helpers were a cohesive cluster that all threaded the same
(ctx, env) pair, so making them methods also sheds the repeated env argument.
Behavior is unchanged and the change is confined to Dang v2; v1 stays frozen.
Signed-off-by: Alex Suraci <[email protected]>
* dang: drop unreachable module-identity guard
The converter only ever marshals values for a live function call, whose
moduleContext is a populated ObjectResult, so Self() is never nil and the
module always has a name. The nil check in eval and the known() fallback in
schemaTypeName could therefore never fire; remove them so the module identity
is built and namespaced unconditionally. Confined to Dang v2.
Signed-off-by: Alex Suraci <[email protected]>
---------
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|