Repository navigation
Load workspace modules on demand for generate/check/up - #13548
Merged
Merged
Conversation
shykes
approved these changes
Jun 26, 2026
Contributor
|
Did not read the code, but we discussed the design with @eunomie and we're in sync :) |
Design for loading workspace modules on demand -- additively, so narrowing is deferral rather than exclusion -- for dagger generate/check/up and raw execution queries. dagger call/functions are out of scope and keep loading everything, unchanged. Signed-off-by: Yves Brissaud <[email protected]>
Replace the one-shot ensureModulesLoaded with per-request, per-module loading. Each request loads only the pending workspace modules it demands and unselected modules stay pending, loading when a later request demands them. The dagql schema is rebuilt from the served set per request, so the session schema grows monotonically: narrowing is deferral, not exclusion, and is therefore safe for open multi-request sessions, generalizing the previous SingleQuery-only peek to every client. The demand is read from the request's root fields: a field naming a pending module loads just that module (the existing entrypoint fallback is preserved), while full-schema fields (__schema, currentTypeDefs, env, ...) and anything unrecognized load everything. The currentWorkspace selector resolvers load on demand from their own include argument instead (the EnsureWorkspaceModules hook), so currentWorkspace itself demands nothing here. Extra (-m) modules are explicitly requested, so they keep loading eagerly on the first request with sticky errors. Ambient module failures become per-module: a broken module only fails the requests that demand it, and stays pending so later demands report its load error. Served identities and names are tracked so cross-batch loads stay deduplicated and demand filters keep recognizing already-loaded modules. Cancellation and deadline errors are never recorded as module failures, so an interrupted load stays retryable by later demands in the session. Signed-off-by: Yves Brissaud <[email protected]>
The entire currentWorkspace selector API returns core types, so
currentWorkspace { generators|checks|services(include: [...]) } validates
against the core schema with no modules loaded -- only the resolver's
result needs them. Add a Query.Server.EnsureWorkspaceModules hook
(implemented by the engine, precedent: CurrentWorkspace) and call it at
the top of the checks/generators/services resolvers with their native
include argument.
So `dagger generate|check|up <module>` loads only the named module with
no CLI or API change -- the include is already the command's functional
argument -- and an unrelated broken or stale module can no longer block
the operation.
Signed-off-by: Yves Brissaud <[email protected]>
Add a generators-broken workspace fixture -- a healthy module exposing a generator, a check, and a service, alongside a module with intentionally invalid source -- and lock in that `dagger generate`, `check`, and `up` targeting the healthy module never load the broken one, while full listings still load every module and surface it. The generate test runs with -y, exercising the multi-request path where later requests must keep recognizing the already-loaded module. Signed-off-by: Yves Brissaud <[email protected]>
eunomie
force-pushed
the
demand-load-generate-check-up
branch
from
June 29, 2026 07:50
943107b to
ac73461
Compare
eunomie
added a commit
to eunomie/dagger
that referenced
this pull request
Jul 2, 2026
Design for extending the demand-driven workspace module loading (merged for generate/check/up in dagger#13548) to dagger api call and api functions. The introspection these commands build their command tree from (currentTypeDefs) names no module, so the target must cross the wire: the chosen design carries the CLI's leading command token in a new ClientMetadata workspace_module_scope hint, resolved engine-side with the same kebab/entrypoint rules as the merged demand filters and consumed one-shot by the first request whose only full-schema demand is currentTypeDefs. No GraphQL API change, no SDK regeneration, no version gating; old engines ignore the unknown metadata key and old CLIs simply do not send it. Includes the investigation behind the choice: the merged foundation, why call/functions are the hard case, a post-mortem of the prior attempts (dagger#13380, dagger#13406, dagger#13539, dagger#13543), and the alternatives ranked. Signed-off-by: Yves Brissaud <[email protected]>
eunomie
added a commit
to eunomie/dagger
that referenced
this pull request
Jul 16, 2026
Design for extending the demand-driven workspace module loading (merged for generate/check/up in dagger#13548) to dagger api call and api functions. The introspection these commands build their command tree from (currentTypeDefs) names no module, so the target must cross the wire: the chosen design carries the CLI's leading command token in a new ClientMetadata workspace_module_scope hint, resolved engine-side with the same kebab/entrypoint rules as the merged demand filters and consumed one-shot by the first request whose only full-schema demand is currentTypeDefs. No GraphQL API change, no SDK regeneration, no version gating; old engines ignore the unknown metadata key and old CLIs simply do not send it. Includes the investigation behind the choice: the merged foundation, why call/functions are the hard case, a post-mortem of the prior attempts (dagger#13380, dagger#13406, dagger#13539, dagger#13543), and the alternatives ranked. Signed-off-by: Yves Brissaud <[email protected]>
eunomie
added a commit
to eunomie/dagger
that referenced
this pull request
Jul 16, 2026
Design for extending the demand-driven workspace module loading (merged for generate/check/up in dagger#13548) to dagger api call and api functions. The introspection these commands build their command tree from (currentTypeDefs) names no module, so the target must cross the wire: the chosen design carries the CLI's leading command token in a new ClientMetadata workspace_module_scope hint, resolved engine-side with the same kebab/entrypoint rules as the merged demand filters and consumed one-shot by the first request whose only full-schema demand is currentTypeDefs. No GraphQL API change, no SDK regeneration, no version gating; old engines ignore the unknown metadata key and old CLIs simply do not send it. Includes the investigation behind the choice: the merged foundation, why call/functions are the hard case, a post-mortem of the prior attempts (dagger#13380, dagger#13406, dagger#13539, dagger#13543), and the alternatives ranked. Signed-off-by: Yves Brissaud <[email protected]>
eunomie
added a commit
to eunomie/dagger
that referenced
this pull request
Jul 16, 2026
Design for extending the demand-driven workspace module loading (merged for generate/check/up in dagger#13548) to dagger api call and api functions. The introspection these commands build their command tree from (currentTypeDefs) names no module, so the target must cross the wire: the chosen design carries the CLI's leading command token in a new ClientMetadata workspace_module_scope hint, resolved engine-side with the same kebab/entrypoint rules as the merged demand filters and consumed one-shot by the first request whose only full-schema demand is currentTypeDefs. No GraphQL API change, no SDK regeneration, no version gating; old engines ignore the unknown metadata key and old CLIs simply do not send it. Includes the investigation behind the choice: the merged foundation, why call/functions are the hard case, a post-mortem of the prior attempts (dagger#13380, dagger#13406, dagger#13539, dagger#13543), and the alternatives ranked. Signed-off-by: Yves Brissaud <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Workspace module loading is one-shot: the first schema-needing request loads every configured module, so
dagger generate|check|up <module>pays for all its siblings, and a single broken or stale module blocks operating on any other module — forgenerate, including the very module you were trying to fix. The existing narrowing (peek root fields → drop pending modules) is restricted toSingleQueryclients, because dropped modules can't come back in a later request, andgenerate/check/upare structurally multi-request.Fix
Make loading additive and demand-driven: each request loads only the modules it can possibly touch; the rest stay pending and load when a later request demands them. The dagql schema is already rebuilt from the served set per request, so the session schema grows monotonically — narrowing becomes deferral rather than exclusion, safe for open multi-request sessions, and the root-field demand generalizes from
SingleQueryto every client.The demand source is the natural one for each query shape:
currentWorkspace { checks|generators|services(include: …) }validates against the core schema (all those fields return core types), so loading moves into the resolvers via a newQuery.Server.EnsureWorkspaceModuleshook — they receiveincludenatively, no request peeking. Since the CLI already sendsincludeas the command's functional argument,dagger generate|check|up <module>narrows with zero CLI and zero API change.dagger query, shell) load just that module (existing entrypoint fallback preserved); full-schema fields (__schema,currentTypeDefs,env, …) and anything unrecognized conservatively load everything.sequenceDiagram autonumber participant CLI as dagger CLI participant H as serveQuery participant L as ensureModulesLoaded participant R as generators resolver Note over CLI: dagger generate good<br/>(workspace = {good, bad-broken}) CLI->>H: query { currentWorkspace { generators(include:["good"]) { … } } } H->>H: ensureWorkspaceLoaded (pending = {good, bad}) H->>L: peek root fields → currentWorkspace is core → demand = ∅ H->>R: resolve generators(include:["good"]) R->>L: EnsureWorkspaceModules(["good"]) Note over L: include names "good" → load {good}<br/>bad stays pending, never loaded R-->>CLI: good's generators (bad cannot block this)Other behavior:
-m) modules keep loading eagerly with sticky errors (explicitly requested).dagger generate -l, baredagger functions) still load everything and surface it.Design doc:
hack/designs/demand-driven-module-loading.md.Scope —
dagger call/functionsare intentionally outThis is the fourth PR on this topic. It deliberately covers only
generate/check/up(and raw execution queries), which the engine narrows for free from theincludethey already send.dagger call|functions <module>are not addressed here. They build their command tree from acurrentTypeDefs(returnAllTypes: true)introspection that carries no module signal; narrowing it requires getting the target into the request (a new typedefs path/argument plus a CLI change) — a larger, separately reviewable change with its own trade-offs. This PR does not regress them:currentTypeDefsstays on the full-schema list, socall/functionsload everything exactly as onmain. The additive engine here is the foundation a latercall-narrowing change builds on.Relationship to the prior PRs (all same author):
generate/check/up+ acurrentTypeDefs(include:)argument forcall/functions+ SDK regen.callnarrowing via a peeked operation name. Superseded.callnarrowing via aWorkspaceModule.typeDefsfield. Open.This PR extracts the engine-only foundation + selector narrowing common to all three, with no SDK regen, no
schema.graphqlschange, and nocmd/daggerchange.Tests
TestGenerators/TestWorkspace{Generate,Check,Up}NarrowsToRequestedModule: a broken sibling no longer blocks a scopedgenerate/check/upof a healthy module, while full listings still load every module and surface the broken one. Verified against a from-source dev engine.