Repository navigation
Conversation
2da8d00 to
1559d7b
Compare
863439a to
63dc046
Compare
Can you explain this part please? |
|
The way modules are loaded and introspected from the CLI changed. Before sequenceDiagram
autonumber
participant CLI
participant H as Engine HTTP handler<br/>(session.go)
participant L as Module loader
participant S as dagql schema
participant R as currentTypeDefs resolver
participant C as dagql result cache
Note over CLI: dagger call MODULE fn --arg ...
CLI->>H: query { currentTypeDefs { ... } }<br/>PLAIN doc, no include
Note right of CLI: multi-request session →<br/>SingleQuery peek/narrowing does NOT apply
H->>H: ensureWorkspaceLoaded() (discover)
H->>L: ensureModulesLoaded() — ALL pending
L-->>H: MODULE ok, sibling-A ok, sibling-BROKEN FAILS
Note over H,L: one broken sibling fails the whole request
H->>S: build schema = core + MODULE + sibling-A + sibling-BROKEN
H->>R: resolve currentTypeDefs
R->>C: key = CurrentSchemaInput = digest(served schema)
Note over C: served schema already contains workspace modules<br/>→ key differs per workspace for free (no client ID needed)
R-->>CLI: typedefs (everything served)
Note over CLI: build command tree → send actual call (2nd request)
After sequenceDiagram
autonumber
participant CLI
participant H as Engine HTTP handler<br/>(session.go)
participant S as dagql schema
participant R as currentTypeDefs resolver
participant C as dagql result cache
participant L as Module loader
Note over CLI: dagger call MODULE fn --arg ...<br/>extract leading positional token → "MODULE"
CLI->>H: query { currentTypeDefs(include: ["MODULE"]) { ... } }<br/>old engine rejects arg → fall back to PLAIN doc (load-all)
H->>H: ensureWorkspaceLoaded() (discover)
Note over H: ambient modules NOT loaded here (only -m extras)
H->>S: build schema = core only
Note over S: currentTypeDefs is a core field →<br/>query validates with no modules loaded
H->>R: resolve currentTypeDefs(include: ["MODULE"])
R->>C: key = CurrentSchemaInput(core only) + PerClientInput(client ID)
Note over C: schema digest is core-only → identical across workspaces<br/>PerClientInput (client ID) is what prevents an A/B collision
R->>L: EnsureWorkspaceModulesForTypeDefs(["MODULE"])
L-->>R: MODULE ok (+ entrypoint module if configured)
Note over L: sibling-A, sibling-BROKEN stay PENDING (never evaluated)
R-->>CLI: typedefs for MODULE
Note over CLI: build command tree → send actual call (2nd request)
|
Document an alternative to dagger#13406 (demand-driven workspace module loading) that keeps the same engine foundation but moves the `dagger call`/`functions` narrowing signal out of the client. Instead of a new public `currentTypeDefs(include:)` argument and the client-side document building, version gating and SDK regeneration it implies, the CLI names its typedefs introspection operation after the target module and the engine peeks the operation name. The same query works against every engine, so the CLI carries no engine-version fallback. Signed-off-by: Yves Brissaud <[email protected]>
Document an alternative to dagger#13406 (demand-driven workspace module loading) that keeps the same engine foundation but moves the `dagger call`/`functions` narrowing signal out of the client. Instead of a new public `currentTypeDefs(include:)` argument and the client-side document building, version gating and SDK regeneration it implies, the CLI names its typedefs introspection operation after the target module and the engine peeks the operation name. The same query works against every engine, so the CLI carries no engine-version fallback. Signed-off-by: Yves Brissaud <[email protected]>
Document an alternative to dagger#13406 (demand-driven workspace module loading) that keeps the same engine foundation but moves the `dagger call`/`functions` narrowing signal out of the client. Instead of a new public `currentTypeDefs(include:)` argument and the client-side document building, version gating and SDK regeneration it implies, the CLI names its typedefs introspection operation after the target module and the engine peeks the operation name. The same query works against every engine, so the CLI carries no engine-version fallback. Signed-off-by: Yves Brissaud <[email protected]>
Document an alternative to dagger#13406 (demand-driven workspace module loading) that keeps the same engine foundation but moves the `dagger call`/`functions` narrowing signal out of the client. Instead of a new public `currentTypeDefs(include:)` argument and the client-side document building, version gating and SDK regeneration it implies, the CLI names its typedefs introspection operation after the target module and the engine peeks the operation name. The same query works against every engine, so the CLI carries no engine-version fallback. Signed-off-by: Yves Brissaud <[email protected]>
Document an alternative to dagger#13406 (demand-driven workspace module loading) that keeps the same engine foundation but moves the `dagger call`/`functions` narrowing signal out of the client. Instead of a new public `currentTypeDefs(include:)` argument and the client-side document building, version gating and SDK regeneration it implies, the CLI names its typedefs introspection operation after the target module and the engine peeks the operation name. The same query works against every engine, so the CLI carries no engine-version fallback. Signed-off-by: Yves Brissaud <[email protected]>
Document the design for loading workspace modules on demand instead of all-at-once: every request loads only the modules it can possibly touch, the rest stay pending and load when a later request (or a workspace resolver) demands them. Narrowing becomes deferral rather than exclusion, which makes it safe for open multi-request sessions without any new client-server contract. 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 -- root fields naming a module load just that module (plus the existing entrypoint fallback), full-schema fields load everything -- and unselected modules stay pending, loading 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 is deferral, not exclusion, and is therefore safe for open multi-request sessions, generalizing the previous SingleQuery-only peek to every client. 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 requests that demand it, and stays pending so later demands report its load error. Entrypoint arbitration is split across batches: extras load first and outrank ambient candidates; multiple ambient entrypoint declarations load together to preserve the existing conflict detection. Served identities and names are tracked so cross-batch loads stay deduplicated and demand filters keep recognizing already-loaded modules. Two on-demand hooks (EnsureWorkspaceModules for the workspace selector resolvers, EnsureWorkspaceModulesForTypeDefs for targeted typedefs introspection) are provided here and wired up by the following patches. Cancellation and deadline errors are never recorded as module failures -- an interrupted load stays retryable by later demands in the session. Signed-off-by: Yves Brissaud <[email protected]>
The entire currentWorkspace API and currentTypeDefs return core types, so
queries like `currentWorkspace { generators(include: ["good"]) }` and the
CLI's typedefs introspection validate against the core schema with no
modules loaded -- only the resolver's result needs them. Move workspace
module loading into the resolvers via the Query.Server hooks added in the
previous patch:
- checks/generators/services call EnsureWorkspaceModules 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.
- currentTypeDefs gains an optional include argument consumed through
EnsureWorkspaceModulesForTypeDefs: patterns naming workspace modules
load just those (plus the entrypoint module, whose functions are
proxied onto the Query root), and no include loads every pending
module -- preserving bare `dagger functions`/`shell`. The argument is
gated to v1.0.0+ so it stays out of the base schema view.
Because loading now happens inside the resolver, the currentTypeDefs
result cache also mixes in the client ID: the schema digest at call time
no longer distinguishes which workspace the session is in, so without it
sessions in different workspaces would share a cache entry.
Signed-off-by: Yves Brissaud <[email protected]>
`dagger call` and `dagger functions` build their command tree from a currentTypeDefs introspection that previously loaded every workspace module. Pass the leading positional token (extracted with the same flag-skipping logic as the function-name telemetry) as the include hint: only the first token can name a workspace module (later tokens are functions or arguments within it), so targeting a module no longer loads its siblings, and an unrelated broken or stale module cannot block the call. Engines that predate the include argument reject any document naming it at validation, even with a null variable. The plain typedefs document therefore stays as-is for unscoped introspections; a derived include-scoped document is sent only when a hint exists, and an "Unknown argument" rejection falls back to the plain document, loading every workspace module exactly like older CLIs. Signed-off-by: Yves Brissaud <[email protected]>
Add a generators-broken workspace fixture -- a healthy dang module exposing a generator, a check, and a service, alongside a module with intentionally invalid source -- and lock in that `dagger generate`, `check`, `up`, `call`, and `functions` 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. A second fixture (call-narrowing) covers the demand shapes single-word module names cannot: a module declared as "goodMod" is targeted through its kebab-case CLI command name (`dagger call good-mod ...`, and `dagger generate -l good-mod` for the selector path), and with a workspace entrypoint configured, calling one of its root-proxied functions loads the entrypoint module alone. In both cases the broken sibling module stays unloaded. Signed-off-by: Yves Brissaud <[email protected]>
Regenerate the SDK client bindings and reference docs for the new currentTypeDefs include argument. Signed-off-by: Yves Brissaud <[email protected]>
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 PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
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]>
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]>
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]>
Document, in hack/designs/done, how dagger api call and api functions narrow workspace module loading to their target: the CLI forwards its leading command-line word as the workspace_module_scope client metadata hint and the engine resolves it, completing the demand-driven loading that generate/check/up already had. Covers the behavior table, the one-shot-per-session rule, nested-client plumbing, why the target rides connection metadata rather than a new API surface, and the prior attempts (dagger#13380, dagger#13406, dagger#13539, dagger#13543). Signed-off-by: Yves Brissaud <[email protected]>
Document, in hack/designs/done, how dagger api call and api functions narrow workspace module loading to their target: the CLI forwards its leading command-line word as the workspace_module_scope client metadata hint and the engine resolves it, completing the demand-driven loading that generate/check/up already had. Covers the behavior table, the one-shot-per-session rule, nested-client plumbing, why the target rides connection metadata rather than a new API surface, and the prior attempts (dagger#13380, dagger#13406, dagger#13539, dagger#13543). Signed-off-by: Yves Brissaud <[email protected]>
Document, in hack/designs/done, how dagger api call and api functions narrow workspace module loading to their target: the CLI forwards its leading command-line word as the workspace_module_scope client metadata hint and the engine resolves it, completing the demand-driven loading that generate/check/up already had. Covers the behavior table, the one-shot-per-session rule, nested-client plumbing, why the target rides connection metadata rather than a new API surface, and the prior attempts (dagger#13380, dagger#13406, dagger#13539, dagger#13543). Signed-off-by: Yves Brissaud <[email protected]>
Document, in hack/designs/done, how dagger api call and api functions narrow workspace module loading to their target: the CLI forwards its leading command-line word as the workspace_module_scope client metadata hint and the engine resolves it, completing the demand-driven loading that generate/check/up already had. Covers the behavior table, the one-shot-per-session rule, nested-client plumbing, why the target rides connection metadata rather than a new API surface, and the prior attempts (dagger#13380, dagger#13406, dagger#13539, dagger#13543). Signed-off-by: Yves Brissaud <[email protected]>
Document, in hack/designs/done, how dagger api call and api functions narrow workspace module loading to their target: the CLI forwards its leading command-line word as the workspace_module_scope client metadata hint and the engine resolves it, completing the demand-driven loading that generate/check/up already had. Covers the behavior table, the one-shot-per-session rule, nested-client plumbing, why the target rides connection metadata rather than a new API surface, and the prior attempts (dagger#13380, dagger#13406, dagger#13539, dagger#13543). Signed-off-by: Yves Brissaud <[email protected]>
|
This PR was closed because it has been stalled for 7 days with no activity. |
Problem
Workspace module loading is one-shot: the first schema-needing request loads every configured module, so
dagger generate|check|up|call|functions <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.Alternative design to #13380, which extends the request peeks and hints instead. Design doc included:
hack/designs/demand-driven-module-loading.md.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:
__schema, …) load everything; anything unrecognized conservatively loads everything.currentWorkspace { checks|generators|services(include: …) }validates against the core schema, so loading moves into the resolvers via a newQuery.Server.EnsureWorkspaceModuleshook — they receiveincludenatively, no request peeking or variable resolution. Since the CLI already sendsincludeas the command's functional argument,dagger generate|check|up <module>narrows with zero CLI change.currentTypeDefsgains an optionalincludeload hint consumed at resolver entry through the same hook; the CLI passes its leading positional token, narrowingdagger call/functions <module>. Because loading now happens inside the resolver, the result cache also mixes in the client ID (the pre-request load previously made the schema-digest key workspace-unique as a side effect).Other behavior consequences:
-m) modules keep loading eagerly with sticky errors (explicitly requested).The
currentTypeDefs(include:)phase (the API addition, the CLI hint, its tests, and the SDK/docs regeneration commit) is independent and can be dropped to keep only the engine-side phase. Two engine-only refactors close the series: per-module load state consolidated into a single lifecycle map (pending → served | failed), and the shared dedupe→arbitrate→serve tail of ambient/extra batch loading extracted into one helper.Tests
module,module:item, entrypoint/typo fallbacks, already-served patterns).TestWorkspace{Generate,Check,Up,Call}NarrowsToRequestedModuleagainst a newgenerators-brokenfixture (healthydangmodule with a generator, a check, and a service, alongside a module with invalid source): targeting the healthy module never loads the broken one —generate -yexercising the multi-request path — while full listings still surface it. The existing single-query narrowing test passes unchanged on the generalized path, as do the fullTestWorkspace/TestGeneratorssuites against a dev engine.