Skip to content

dagql: native interfaces, unified IDs - #12041

Merged
vito merged 254 commits into
dagger:mainfrom
vito:interfaces
May 27, 2026
Merged

vito merged 254 commits into
dagger:mainfrom
vito:interfaces

Conversation

@vito

@vito vito commented Mar 23, 2026 •

Copy link
Copy Markdown
Contributor

This is one of those PRs where it feels like years of tension snaps into place.

There has long been a tension within DagQL: all objects are so close to conforming to a generic Node interface, except they all have a different return type for their id field: DirectoryID!, ContainerID!, etc. etc.

All of these different ID types served a purpose: a field taking a DirectoryID argument could generate type-safe SDK code only allowing a *Directory where a Directory is expected.

But the cost of this approach was high:

  • Instead of Global Object Identification we had dozens of loadFooFromID(id: FooID!): Foo! APIs
  • We couldn't generically pass "any object" into something like an LLM - instead we needed one API per type
  • Interfaces couldn't be native GraphQL, because Dagger's implementation allows contravariance for interface ID arguments, while GraphQL prescribes that interface arguments are invariant (same exact type)

My initial goal was to support a generic LLM.withObject(name: String!, object: ID!). Late Friday I realized we could get partway there by just having all objects implement id: ID! while keeping FooID! for all the arguments. Then they could at least all conform to interface Node { id: ID! }. But it felt silly to embark on that without making DagQL also interface-aware.

For some history, Dagger interfaces landed immediately after DagQL itself, so they weren't incorporated into DagQL's initial design. That's been a longstanding mental TODO, but it had a high cost of entry and lots of uncertainty; the roots of our old design had spread, and there were implications across all SDKs. It took both depth and breadth of knowledge.

Three years later, you can practically do it in a weekend with a lot of help from LLMs.

The Plan

There are two halves to this effort:

Unifying IDs

  1. Retire FooID types and loadFooFromID APIs, unify around ID
  2. Use GraphQL schema directives to apply type hints to ID arguments and return values
  3. Instead of SDKs doing trimSuffix("ID") to get the type name, they look at directives
  4. Add Global Object Identification APIs:
    • interface Node { id: ID! }
    • type Query { node(id: ID!): Node }
  5. Update all SDKs and client code to use node instead of loadFooFromID

Native interfaces

  1. Essentially, move Dagger's bolted-on interface system down into native GraphQL, from core/ to dagql/
    • Interfaces are now actual GraphQL interfaces! We no longer need contravariance, because at the GraphQL layer all args are just IDs.
    • No more asFoo, asBar etc. added to every object that implements an interface
  2. DagQL automatically tracks which objects implement which interfaces and reports that in its schema
    • Normally GraphQL requires an explicit implements Foo - DagQL automates it, just like Dagger always has
  3. Update all SDKs to codegen interfaces from native GraphQL interfaces
    • Languages that natively support contravariance + covariance just use their native interface system
    • Go SDK now uses interfaces, too, but has conversion helpers since it doesn't support covariance/contravariance

Breaking changes

Currently focusing on a hard cut-over. Might be OK to ship that considering most of this is internal plumbing; I expect the blast radius of e.g. loadFooFromID to be largely contained in Dagger and other projects close to its core (Dang)

TODO

Compatibility

  • ❌ API schema is a hard cut-over. Interfaces are now interfaces, loadFooFromID are gone. Maintaining compatibility here doesn't seem worth the effort to me. Unlike regular API changes that can leverage Views to present older APIs to older engines, this change is fairly integral to DagQL itself and mostly affects plumbing that the user doesn't interact with.
  • ✔️ SDK compatibility is preserved, for now. Modules written against old engines can continue to use LoadFooFromID and will continue to see interfaces as they did before. I say "for now" because we may want to remove it before too much time passes.

Bookkeeping

@vito vito changed the title dagql: native interfaces dagql: native interfaces, unified IDs Mar 23, 2026
@vito
vito force-pushed the interfaces branch 6 times, most recently from 4a1431a to 744522a Compare April 4, 2026 00:08
vito added 22 commits April 4, 2026 18:55
Implements the dagql infrastructure for GraphQL interfaces as described
in dagql/INTERFACES.md Phase 1:

- New Interface type with field specs, structural satisfaction checking,
  and AST definition generation (dagql/interfaces.go)
- Server.InstallInterface/InterfaceType for registering interfaces
- Class.Implements for declaring interface conformance with structural
  verification (panics on mismatch)
- Schema generation emits ast.Interface definitions, populates
  def.Interfaces on objects, and registers PossibleTypes
- Auto-implements Object interface for all idable classes when the
  Object interface is installed before the class
- Inline fragment support in parseASTSelections
- Fragment spread type condition checking against both concrete types
  and interface implementors
- Updates golden introspection test data (pre-existing staleness)

Signed-off-by: Alex Suraci <[email protected]>
LoadContainerFromID and LoadGitRefFromID expect typed IDs
(ContainerID, GitRefID) not generic dagger.ID.

Signed-off-by: Alex Suraci <[email protected]>
Remove sdk/go/object.go which defined an Object interface that
conflicted with generated interface type structs. Update Go and
TypeScript codegen to handle the bare ID scalar gracefully by
skipping the empty-prefix case in CutSuffix/Cut.

Signed-off-by: Alex Suraci <[email protected]>
Change InterfaceType.Install to create a dagql.Interface instead of
a Class[*InterfaceAnnotatedValue]. This makes module interfaces
appear as ast.Interface in the schema rather than ast.Object,
enabling proper GraphQL introspection (kind=INTERFACE, possibleTypes,
implements declarations on objects).

Key changes:

dagql/objects.go: Add ImplementInterfaceUnchecked for cases where
a higher-level type system (core's IsSubtypeOf) has already validated
conformance with richer covariance/contravariance semantics.

core/interface.go: Rewrite Install to create a dagql.Interface with
field specs derived from the InterfaceTypeDef's functions, including
an implicit id field for SDK codegen compatibility. Install DynamicID
scalar and loadFooFromID separately since there's no longer a Class.

core/moddeps.go: Register interface implementations via dagql's
Satisfies check (strict type matching for GraphQL compatibility).
Deprecate asFoo fields with a reason string. Use NewResultForCurrentID
instead of NewObjectResultForCurrentID since there's no Class.

core/schema/coremod.go: Handle TypeKindInterface in
introspectionRefToTypeDef so the core can convert introspected
interface return types.

SDK codegen updates across Go, TypeScript, and Python to handle
INTERFACE type kind alongside OBJECT in code generation, type
formatting, and introspection.

Signed-off-by: Alex Suraci <[email protected]>
…ching

Add INTERFACE to the codegen visitor so Go/TS/Python SDKs generate
type definitions for interface types. Update parseASTSelections to
resolve fields on interface types via a new Interface.ParseField
method. Extend isObjectType to recognize interface type names so
the Select chain treats interface-typed returns as sub-selectable.

Fix the asFoo deprecated field to return the concrete object
directly (standard GraphQL interface semantics) instead of wrapping
in InterfaceAnnotatedValue which required cross-module type lookup.

Add ObjectResult.WithPostCall and WithSafeToPersistCache so that
post-processing in ModuleFunction.Call preserves the ObjectResult
wrapper needed by the cache to reconstruct selectable results.

Add ensureSelectable in ModuleFunction.Call to upgrade Result values
(and list elements) to ObjectResult using the merged schema server,
so the cache preserves ObjectType info for cross-module types.

Signed-off-by: Alex Suraci <[email protected]>
Handle the GraphQL __typename introspection field in dagql's own
execution engine. Previously untested because all queries knew their
concrete types, but required for proper interface support where
clients need to discriminate the concrete type behind an interface.

Signed-off-by: Alex Suraci <[email protected]>
The introspection query already requests possibleTypes but the
codegen struct wasn't capturing it. SDK codegens need this to
know which concrete objects implement a given interface.

Signed-off-by: Alex Suraci <[email protected]>
Covers removal of asFoo schema fields, InterfaceAnnotatedValue,
DynamicID cleanup, and SDK codegen changes. Go generates actual Go
interfaces with AsFoo() adapters for covariance. TS/Python remove
asFoo references since they have structural typing.

Signed-off-by: Alex Suraci <[email protected]>
Add AsFoo() (*Foo, bool) narrowing methods on the Go interface
itself, one per possibleType. This is necessary because Go's lack
of covariant returns means concrete types can never directly satisfy
the interface — so standard Go type assertions won't work. The
narrowing methods provide type-safe downcasting.

Signed-off-by: Alex Suraci <[email protected]>
Instead of AsMallard()/AsRubberDuck() on the interface (which can't
work for lazy query builders), add a single Concrete(ctx) method
that resolves __typename + ID and returns DaggerObject. The caller
type-switches on the result. Works for all three cases: adapter
wrappers (immediate), lazy query builders (queries __typename), and
all three SDK languages.

Signed-off-by: Alex Suraci <[email protected]>
…erface codegen

Remove deprecated asFoo schema fields from ModDeps.lazilyLoadSchema.
Remove InterfaceAnnotatedValue, wrapIface, and dagql.InterfaceValue
along with all dead code paths that referenced them. Replace with a
thin interfaceTypedMarker for loadFooFromID return types.

Update Go SDK codegen to generate proper Go interface types for
GraphQL INTERFACE kinds instead of treating them as structs. Each
interface gets a Go interface type plus an unexported query-builder
struct. Objects implementing interfaces get client-side AsFoo()
adapter methods (no schema field needed).

Fix Satisfies to support covariant return types via an
ImplementsChecker callback, enabling objects with covariant returns
(e.g. SelfIface() returning the concrete type) to properly declare
interface implementation in the schema.

Add PossibleTypes to dagqlToCodegenType so SDK codegen has access
to the implementing types for each interface.

Update Go iface test expectations for the new interface types
(Go interfaces instead of pointer-to-struct).

Signed-off-by: Alex Suraci <[email protected]>
Add duck-typed interface-to-interface implementation detection.
When interface A structurally satisfies interface B, automatically
declare A implements B in the schema.

Fix introspection Interfaces() to return implemented interfaces for
ast.Interface types (not just ast.Object).

This is needed for covariant return types: when an object's field
returns ImplLocalOtherIface but the interface declares
TestOtherIface, the schema validator needs to know that
ImplLocalOtherIface implements TestOtherIface.

Note: argument type mismatches (e.g. ImplOtherImplID vs
TestOtherIfaceID) still prevent full implements declaration.
Next step: unify all FooID scalars to a single ID type with
@expectedType directives.

Signed-off-by: Alex Suraci <[email protected]>
Replace all per-type FooID scalars with the single built-in ID
scalar. Type knowledge is conveyed via @expectedType(name: "Foo")
directives on arguments instead of separate scalar types.

Changes:
- ID[T].TypeName() returns "ID" instead of "FooID"
- ID[T].Type() returns ID! instead of FooID!
- InstallObject no longer registers FooID scalars
- loadFooFromID args use ID! + @expectedType directive
- Remove DynamicID (replaced by AnyID everywhere)
- Add ExpectedTypeDirective helper and @expectedType directive def
- Update Go/TS codegen FormatKindScalarID and formatArgType
- Add ExpectedType() to introspection Directives

Note: CLI and existing SDKs still send queries with FooID types.
Those need to be regenerated to use ID! instead. WIP.

Signed-off-by: Alex Suraci <[email protected]>
Fix formatArgType to handle list types with @expectedType.
Fix FormatReturnType and ConvertID for sync-like methods.
Fix findExpectedTypeName to handle ArrayInput and Optional wrappers.
Add @expectedType on field definitions for ID return types.
Update all CLI/TUI/module references from FooID to ID.
Regenerate sdk/go/dagger.gen.go with unified ID types.

Signed-off-by: Alex Suraci <[email protected]>
Manually convert all FooID type definitions to type aliases (= ID)
so the codebase compiles with unified IDs. This enables building
the dev engine which can then properly regenerate dagger.gen.go.

Signed-off-by: Alex Suraci <[email protected]>
XXX_GraphQLIDType returns "ID" instead of "FooID".
UnmarshalJSON uses ID() cast instead of FooID().

Signed-off-by: Alex Suraci <[email protected]>
- idTypeName() returns "dagger.ID" instead of "FooID"
- Remove idDefCode() (no per-type ID scalar definitions needed)
- graphqlIDTypeMethodCode returns "ID"
- loadFromIDMethodCode takes dagger.ID parameter
- concreteStructDefCode uses dagger.ID for id field
- unmarshalJSONMethodCode uses dagger.ID
- Slice return type uses dagger.ID for id struct field

Signed-off-by: Alex Suraci <[email protected]>
vito and others added 10 commits May 20, 2026 22:07
The interfaces branch unified per-type ID scalars (DiffStatID, CheckID,
…) into a single `ID` scalar and replaced per-type `loadXFromID` Query
fields with a generic `node(id: ID!): Node`. The codegen's
list-of-objects branch still emitted `Vec<DiffStatId>` and called the
removed `root.load_*_from_id(id)` helpers, so the regenerated SDK no
longer compiled.

Emit `Vec<Id>` and construct each element directly via
`node(id:).inline_fragment(TypeName)`, mirroring the single-object
ConvertID path. Regenerate gen.rs to pick up the change.

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Scale-out has to rebuild the module in the scaled-out query before it can run the selected function or check remotely. For a normal CLI checkout, a command such as dagger --scale-out check usually starts from moduleSource(refString: "."), which is a local or git module source. This bug is in the other user-facing shape: the module was created from a Directory object first, for example through host.directory(...).asModule or Directory.asModuleSource(...), and then the module was used by the scale-out path.

In that Directory-source case, ModuleSourceKindDir stores the original Directory object ID in DirSrc.OriginalContextDir and stores the source root path separately. The old scale-out query tried to rebuild the module source like this:

    {
      node(id: "...") {
        asModuleSource(sourceRootPath: "src") {
          asModule {
            id
          }
        }
      }
    }

That query is invalid GraphQL. node(id:) returns the Node interface, and Node only exposes id. asModuleSource is a Directory field, so GraphQL validation rejects asModuleSource when it is selected directly from node(id:).

The valid query first narrows the Node result to Directory:

    {
      node(id: "...") {
        ... on Directory {
          asModuleSource(sourceRootPath: "src") {
            asModule {
              id
            }
          }
        }
      }
    }

Fix buildScaleOutModuleQuery by adding the Directory inline fragment before selecting asModuleSource when the stored module source came from a Directory.

The regression test builds the scale-out query for a module whose source was created from a Directory, then validates the generated GraphQL against a tiny schema containing only node, Directory.asModuleSource, ModuleSource.asModule, and Module.id. Without the fix, validation fails because asModuleSource is selected from Node. With the fix, the query validates through the Directory fragment.

Focused repro:

    dagger call engine-dev test --pkg ./core --run '^TestModTreeNode/TestBuildScaleOutModuleQueryForModuleLoadedFromDirectory$' --test-verbose

Signed-off-by: Guillaume de Rouville <[email protected]>
DagQL checks whether a field can implement an interface field before publishing that relationship in the GraphQL schema. The old check verified that every argument declared by the interface existed on the implementation with a compatible type. It did not check for required arguments that exist only on the implementation.

A module author can hit this with an interface method that takes no argument and an object method that requires one:

    type Runnable interface {
      DaggerObject
      Run(ctx context.Context) (string, error)
    }

    type Job struct{}

    func (j *Job) Run(ctx context.Context, target string) (string, error) {
      return target, nil
    }

If Job is accepted as Runnable, callers that only know they have a Runnable can call Run, but they cannot pass target because target is not part of the interface method. In GraphQL terms, the invalid contract is:

    interface Runnable {
      run: String!
    }

    type Job {
      run(target: String!): String!
    }

That required target argument is implementation-only. A query through Runnable cannot provide it, so the implementation can fail when the Job resolver is called without a required value.

Extra implementation arguments are still valid when callers are not forced to provide them:

    type Job {
      run(optionalTarget: String): String!
      runWithDefault(target: String! = "default"): String!
    }

Fix argsCompatible by scanning implementation arguments after the interface arguments have been matched. Extra arguments are allowed when they are nullable or have a default value. An extra non-null argument without a default now makes the implementation incompatible.

The tests cover both object and interface cases. Query.run(target:) no longer satisfies an interface field shaped as run(). TransformC, which adds required z, no longer satisfies TransformA. TransformCDefault documents the allowed case where the extra z argument has a default.

Focused repro:

    dagger call engine-dev test --pkg ./dagql --run '^TestInterfaces$' --test-verbose

Signed-off-by: Guillaume de Rouville <[email protected]>
DagQL compares field types before allowing one field to implement an interface field. For list return types, the old comparison checked the element type before checking whether the list value itself could be null. That accepted a field returning a nullable list for an interface field that promised a list would always be present.

This invalid return shape was accepted:

    interface NonNullList {
      names: [String!]!
    }

    type Query {
      names: [String!]
    }

Both fields agree that every element is a non-null String. They disagree about the list itself. Callers through NonNullList rely on names never returning null, but the implementation can return null for the whole list.

List arguments need the same outer-list check in the opposite direction. It is valid for an implementation to accept null when the interface always passes a list:

    interface NonNullListArg {
      acceptsNames(names: [String!]!): String!
    }

    type Query {
      acceptsNames(names: [String!]): String!
    }

The reverse is invalid because a caller using the interface may omit the list or pass null, while the implementation requires the list:

    interface NullableListArg {
      acceptsNames(names: [String!]): String!
    }

    type Query {
      acceptsNames(names: [String!]!): String!
    }

Fix typeCompatible by checking the list value's NonNull flag before recursing into the element type. Fix argTypeCompatible with the matching argument rule, where the implementation must accept every value the interface allows callers to pass.

The tests keep the cases separate. namesOrNull cannot satisfy an interface that promises names is always a list. acceptsNames cannot satisfy an interface that allows names to be null. The valid directions are tested too: a non-null list result can satisfy a nullable-list interface field, and a method accepting names or null can satisfy an interface that always passes names.

Focused repro:

    dagger call engine-dev test --pkg ./dagql --run '^TestInterfaces$' --test-verbose

Signed-off-by: Guillaume de Rouville <[email protected]>
Some GraphQL arguments are encoded as the ID scalar but are still object or interface inputs. The schema marks those cases with @expectedType so SDK generators can expose the generated client type instead of asking users to pass a raw ID.

For example, this schema field should accept a File client object in TypeScript:

    type Query {
      file(id: ID @expectedType(name: "File")): File!
    }

The TypeScript generator also has a special case for arguments literally named id. That branch ran before @expectedType handling, so an id-named object input was generated as a plain ID:

    file = (id: ID): File

That makes generated TypeScript clients reject the natural call shape where the user passes a File object. The same schema worked when the argument had any name other than id, because those arguments reached the @expectedType path.

Fix formatInputType by handling @expectedType before the id-name special case. Modern TypeScript generation now emits the generated object or interface type first:

    file = (id: File): File

Legacy SDK compatibility is preserved for old FooID aliases on id arguments when appropriate. Plain ID arguments without @expectedType still generate as ID.

The regression test is dedicated to this edge case: Query.file(id: ID @expectedType(name: "File")) must generate file = (id: File): File and must not generate file = (id: ID): File.

Focused repro:

    dagger call engine-dev test --pkg ./cmd/codegen/generator/typescript/templates/src --run '^TestModernTypeScriptFileInputNamedIDUsesFileType$' --test-verbose

Signed-off-by: Guillaume de Rouville <[email protected]>
TypeScript method generation maps GraphQL object IDs into generated client instances. For a concrete object list, that is correct:

    containers: [Container!]!

    results.map((r) => new Container(ctx.copy().selectNode(r.id, "Container")))

After TypeRef.IsObject started treating GraphQL interfaces as object-like, list fields returning interfaces also entered that concrete-object branch. For a schema like this:

    interface Syncer {
      id: ID!
    }

    type Query {
      syncers: [Syncer!]!
    }

the generated TypeScript tried to compile this:

    results.map((r) => new Syncer(ctx.copy().selectNode(r.id, "Syncer")))

That is invalid because Syncer is emitted as a TypeScript interface, not a runtime class. The constructible client wrapper is _SyncerClient, which is already what single interface-returning methods use.

Add an IsListOfInterface template helper that unwraps NonNull and List wrappers and detects an interface element type. Use it inside the existing list-of-object branch to construct _<Interface>Client for interface lists while preserving the existing class construction for concrete object lists:

    results.map((r) => new _SyncerClient(ctx.copy().selectNode(r.id, "Syncer")))

The regression test renders a schema with Query.syncers returning [Syncer!]! and asserts that the generated method returns Promise<Syncer[]> while mapping results through new _SyncerClient(...). It also asserts that new Syncer(...) is not emitted.

Focused repro for this commit:

    dagger call engine-dev test --pkg ./cmd/codegen/generator/typescript/templates/src --run '^TestInterfaceListReturnUsesClientWrapper$' --test-verbose

Focused repro for both TypeScript generator regressions in this stack:

    dagger call engine-dev test --pkg ./cmd/codegen/generator/typescript/templates/src --run '^(TestModernTypeScriptFileInputNamedIDUsesFileType|TestInterfaceListReturnUsesClientWrapper)$' --test-verbose

Signed-off-by: Guillaume de Rouville <[email protected]>
Comment thread core/modfunc.go Outdated
Comment on lines +898 to +904
// Ensure the return value is selectable (ObjectResult) when possible.
// ConvertFromSDKResult may return a plain Result[*ModuleObject] which
// the cache would normalize to Result[Typed], losing the ObjectType
// needed for toSelectable to work across module boundaries.
if returnValue != nil && opts.Server != nil {
returnValue = ensureSelectable(opts.Server, returnValue)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking, but this feels sorta off. This seems like something that we should fix in ConvertFromSDKResult rather than patch/kludge on top here? Obviously if it works, it works, but want to avoid piling on kludge when possible since it obviously tends to build up over time. I could easily be missing something though too and maybe this is the best or only way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done - moved to ConvertFromSDKResult

Comment thread dagql/cache.go
// resolverForSharedResultObject returns a resolver that can instantiate the
// cached object's concrete type. Dynamic schemas may need to rebuild the server
// from the result call before dependency-module object types are visible.
func resolverForSharedResultObject(ctx context.Context, resolver TypeResolver, res *sharedResult, typeName string) (TypeResolver, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't really tell why this would be needed now but wasn't needed previously. The decoding part was already taken care of by making the decoding lazy.

Maybe something new came up in the interface and/or generic ID loader work here that necessitates something new here? But I can't really tell what it is, if anything. I also am concerned with the perf overhead of resultServerForCall being called here (could be premature but seems sus), so if it's not needed that would be preferable.

Comment thread dagql/cache_persistence_import.go Resolved
Comment thread core/schema_build.go Resolved
Comment thread dagql/server.go Resolved
vito added 2 commits May 26, 2026 20:40
Drop the ensureSelectable shim that wrapped ModuleFunction.Call results
after the fact. The same upgrade-to-ObjectResult now happens at the
source in ModuleObjectType.ConvertFromSDKResult, so list elements come
out selectable without the post-hoc DynamicResultArrayOutput rebuild.

Best-effort: falls through to the plain Result when the current server
can't see the type, matching prior behavior.

Signed-off-by: Alex Suraci <[email protected]>
... freeing the cache hot path

Pre-PR (main), interface values flowed as a *InterfaceAnnotatedValue
wrapper that carried its concrete type's ModType (with module pointer)
alongside the data. Interface field calls dispatched via that pointer,
so cross-module type resolution never reached the cache layer — the
cache only ever saw the universal wrapper class and could look it up
in any server that used the interface.

This branch retires InterfaceAnnotatedValue in favor of native GraphQL
interfaces. Interface values now flow as concrete ObjectResult[*ModuleObject]
typed in their producing module's class, and any cache hit on the
consuming side needs to resolve "Impl" by name on a schema that may not
have impl installed. The previous fix (resolverForSharedResultObject
calling back into core via resultServerForCall) was on the hot path,
which is the perf concern sipsma flagged.

This change carries dispatch info on the cached result instead of
re-resolving it by name on each hit — the same mechanism the old
InterfaceAnnotatedValue used, generalized:

- sharedResult gains an objClass ObjectType field, set the first time
  the result is wrapped as AnyObjectResult.
- wrapSharedResultWithResolver and Server.toSelectable resolve in
  three tiers: (1) current resolver, (2) cached objClass, (3) the
  resultServerForCall bootstrap (which now caches its result back onto
  the shared, so it fires at most once per shared).

Where responsibilities shifted between core and dagql on this branch:

  Before this PR (main)
  =====================
  ┌────────────── core/interface.go ─────────────────────────┐
  │                                                          │
  │  Interface values: *InterfaceAnnotatedValue {            │
  │    UnderlyingType: ModType  ◄─── module pointer          │
  │    Fields:         map[string]any                        │
  │  }                                                       │
  │                                                          │
  │  Field dispatch:                                         │
  │    callable := runtimeVal.UnderlyingType.GetCallable(.)  │
  │    pointer-based, no name lookup                         │
  │                                                          │
  │  Cross-module bootstrap lives in ONE place — loadImpl(): │
  │    deps := query.ModDepsForCall(ctx, call)               │
  │    dag  := deps.Schema(ctx)                              │
  │    val  := dag.Load(ctx, id)                             │
  │  Called only from InterfaceType.ConvertFromSDKResult.    │
  └──────────────────────────────────────────────────────────┘
              │
              │  values reaching dagql are *InterfaceAnnotatedValue,
              │  whose class is installed on every server that uses
              │  the interface — name lookup never fails
              ▼
  ┌────────────── dagql/cache.go ─────────────────────────────┐
  │  resolver.ObjectType(typeName)  always succeeds locally.  │
  │  Cross-module resolution: not dagql's problem.            │
  └───────────────────────────────────────────────────────────┘

  After this PR (this branch)
  ===========================
  ┌────────────── core/interface.go ─────────────────────────┐
  │  Interface values flow as concrete ObjectResult[*ModObj] │
  │  typed in their PRODUCING module's class.                │
  │  loadImpl() still does the same ModDepsForCall dance,    │
  │  but is no longer the only place that needs it.          │
  └──────────────────────────────────────────────────────────┘
              │
              │  values reaching dagql are typed in their
              │  producing module's class, which may not be
              │  installed in the consuming server's schema
              ▼
  ┌────────────── dagql/cache.go ─────────────────────────────┐
  │  Three-tier resolution for "Impl" → class:                │
  │                                                           │
  │    1. resolver.ObjectType("Impl")     — fast path         │
  │    2. shared.objClass                  — cached fast path │
  │    3. resultServerForCall hook         — bootstrap,       │
  │       └─ ModDepsForCall + deps.Schema                     │
  │       └─ result stored on shared.objClass, so tier 3      │
  │          self-extinguishes after the first hit            │
  └───────────────────────────────────────────────────────────┘
              ▲
              │  hook closure provided by core via
              │  Server.SetResultServerForCall, registered from
              │  core/schema_build.go:InstallCoreSchemaLoaders
              │
        (back across the package boundary)

The objClass field on sharedResult is the moral equivalent of the old
InterfaceAnnotatedValue.UnderlyingType: dispatch info stored on the
value itself so reads don't need name-based lookup. The hook is the
generalized equivalent of loadImpl's dep-schema build. Both existed
before; what changed is that the cache layer now needs them, and the
class is no longer carried by a universal wrapper.

Class capture sites that populate objClass eagerly:
  - Class[T].New (objects.go) — covers every standard ObjectResult
    construction path
  - NewObjectResultForCall (server.go) — explicit ObjectResult builds
  - getOrInitCall completion (cache.go) — via the now-class-returning
    resultIsObject classifier
  - do-not-cache detached path (cache.go) — same classifier
  - WithContentDigest clones (cache.go) — preserves across forks
  - persistence decode (cache_persistence_import.go) — captures from
    the decoded AnyObjectResult

In effect, the cache hit hot path goes through tiers 1 or 2; tier 3
only fires for cross-module shareds on first access (typically values
materialized in core/object.go's ConvertFromSDKResult against a server
that doesn't have the producing module installed).

Signed-off-by: Alex Suraci <[email protected]>
vito and others added 4 commits May 27, 2026 11:21
chore: fix reviewed interface and TypeScript codegen regressions
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
@vito
vito merged commit 84bbeea into dagger:main May 27, 2026
78 checks passed
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
dagger 0.21.1

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## v0.21.1 - 2026-05-29

### Added
- Add native GraphQL interfaces and unified object IDs in DagQL by @vito in dagger/dagger#12041 \
  Dagger now exposes objects through the standard `Node` interface and `ID` scalar, enabling APIs to accept generic Dagger objects while preserving SDK compatibility through legacy `FooID` and `loadFooFromID` views for older clients.

### Fixed
- Python SDK: fix unhandled module registration cases and bugs by removing the AST-based module analyzer and returning to runtime introspection by @eunomie in dagger/dagger#13251
- Fix Go module generation to avoid unnecessary dependency churn in generated `go.mod` and `go.sum` files by @sipsma in dagger/dagger#13244
- Fix registry authentication so `withRegistryAuth` credentials are not incorrectly skipped and authenticated publishes keep working after anonymous pulls to the same registry by @marcosnils + @sipsma in dagger/dagger#13255 dagger/dagger#13256
- Fix published image layer structure so `withDirectory` and `withFile` operations preserve expected layer boundaries instead of being squashed into a few large layers by @sipsma in dagger/dagger#13242
- Fix Dockerfile `RUN --mount=type=bind` conversion when the bind source selector points to a regular file, improving compatibility with file and directory bind mounts by @sipsma in dagger/dagger#13273
- Fix module source cache dependency retention, including ephemeral `missing shared result` errors after cache persistence or engine restarts by @sipsma in dagger/dagger#13243
- Fix a bug where some cache entries did not have their size calculated during background and shutdown pruning by @sipsma in dagger/dagger#13225
- Fix repeated `op://` 1Password secret reads by caching resolved 1Password secret values during a run, avoiding provider rate limits when the same secret is mounted or read multiple times by @matipan in dagger/dagger#13249
- Fix Windows Changeset exports so `RemovePaths` entries cannot remove files outside the selected export root through backslash or absolute-path interpretation by @marcosnils in dagger/dagger#13222
- Fix `dagger --x-release` for tagged releases so semver refs download release artifacts instead of looking in the main-build artifact namespace, and prevent local runner override environment from leaking into the re-executed CLI by @grouville in dagger/dagger#13259

### What to do next?
- Read the [documentation](https://docs.dagger.io)
- Join our [Discord server](https://discord.gg/dagger-io)
- Follow us on [Twitter](https://twitter.com/dagger_io)

</pre>
  <p>View the full release notes at <a href="https://github.com/dagger/dagger/releases/tag/v0.21.1">https://github.com/dagger/dagger/releases/tag/v0.21.1</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!9585
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.

4 participants