Repository navigation
Conversation
5dba7c0 to
dc25ea9
Compare
dagger generatedagger generate/check/up
Do we have a way to verify a module is broken or not then? Or we have to call it to ensure it work? I remember we had a similar discussion when I did the lazy runtime loading. |
Yes there's multiple ways. The basic one is probably just to call In this case it's slightly different, and very related to the suppression of codegen at runtime for modules. This PR will not solve the |
Add PeekWorkspaceSelectorInclude, which recognizes a GraphQL request of the
shape `{ currentWorkspace { <generators|checks|services>(include: [...]) ... } }`
and returns the literal include patterns while preserving the request body. It
is deliberately conservative: any other shape (extra root fields, a non-selector
selection, fragments, a missing or non-literal include argument) returns false.
These three currentWorkspace fields back `dagger generate`, `dagger check`, and
`dagger up` respectively. Each roots its query at currentWorkspace -- otherwise
treated as needing the full workspace schema -- so recognizing this shape lets
the engine narrow workspace module loading to only the requested items' modules.
Signed-off-by: Yves Brissaud <[email protected]>
`dagger generate <module>`, `dagger check <module>`, and `dagger up <module>`
each root their query at currentWorkspace and keep the session open rather than
declaring SingleQuery, so the existing single-query peek treats them as needing
the full workspace schema and loads every workspace module just to enumerate
generators/checks/services. One stale/broken module then blocks the operation on
any other -- including, for generate, the very module you wanted to fix.
When such a client requests specific items via an include argument, peek those
patterns (PeekWorkspaceSelectorInclude) and narrow the pending workspace modules
to the named modules ("module:item" or a bare "module" matching a known
workspace module) plus their transitive dependencies. A bare token that is not a
module name (an entrypoint item) or patterns matching no module disable the
narrowing, so loading falls back to every module.
Signed-off-by: Yves Brissaud <[email protected]>
Add TestWorkspaceGenerate/Check/UpNarrowsToRequestedModule and a generators-broken workspace fixture: a healthy dang module exposing a generator, a check, and a service, plus a module with intentionally invalid source. They lock in that `dagger generate`/`check`/`up <module>` (and their -l list forms) load only the named module -- succeeding despite the unrelated broken module -- while the full `-l` forms still load every module and surface the broken one. Signed-off-by: Yves Brissaud <[email protected]>
Add PeekWorkspaceTypeDefsInclude, which recognizes a GraphQL request of the
shape `{ currentTypeDefs(... include: [...]) ... }` and returns the include
patterns while preserving the request body. `dagger call` and `dagger functions`
build their command tree from currentTypeDefs, which otherwise needs the full
workspace schema; recognizing this shape lets the engine narrow module loading
to the targeted module.
The include argument may be a literal list or a query variable, so extend the
shared request peek to also parse the request variables and resolve a variable
reference. The existing literal-list peeks (generators/checks/services) are
unaffected.
Signed-off-by: Yves Brissaud <[email protected]>
Add an optional `include` argument to currentTypeDefs. It is a workspace module-loading hint consumed by the engine before the resolver runs (it narrows which modules are served); the typedef computation reflects whatever ended up served, so the resolver ignores it. This lets `dagger call <module>` and `dagger functions <module>` introspect only the targeted module. Regenerate the SDK clients for the new argument. Signed-off-by: Yves Brissaud <[email protected]>
`dagger call <module> <function>` and `dagger functions <module>` build their command tree from a currentTypeDefs introspection. That query roots at currentTypeDefs (treated as needing the full workspace schema) and keeps the session open rather than declaring SingleQuery, so it loads every workspace module just to introspect and one stale/broken module blocks the call. When such a client scopes the introspection via an include argument, peek those patterns (PeekWorkspaceTypeDefsInclude) and narrow the pending workspace modules to the named modules (plus their transitive dependencies), reusing the same filter as the generate/check/up narrowing. A token that does not name a workspace module disables narrowing, so loading falls back to every module. Signed-off-by: Yves Brissaud <[email protected]>
When `dagger call <module> ...` or `dagger functions <module>` has a leading positional token, pass it as the currentTypeDefs `include` hint. Only the first token can name a workspace module (later tokens are functions/arguments within it), so an unrelated broken/stale module is not loaded just to introspect the targeted one. The engine ignores the hint when it does not name a workspace module (e.g. an entrypoint-proxied function or no args), loading every module as before. Signed-off-by: Yves Brissaud <[email protected]>
Add TestWorkspaceCallNarrowsToRequestedModule, asserting `dagger call good verify` and `dagger functions good` succeed despite the unrelated broken module, while a full `dagger functions` still loads every module and surfaces it. Restructure the generators-broken healthy module so its workspace directory is a parameter of the generator rather than an object field: a `@defaultPath` field becomes a constructor argument, which collides with `dagger call`'s command-tree construction. This keeps the existing generate/check/up narrowing tests passing. Signed-off-by: Yves Brissaud <[email protected]>
Signed-off-by: Yves Brissaud <[email protected]>
dc25ea9 to
b98ddf4
Compare
dagger generate/check/updagger generate/check/up/call
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]>
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]>
Problem
dagger generate <module>,dagger check <module>,dagger up <module>, anddagger call <module> …(plusdagger functions <module>) each load every workspace module — to enumerate generators/checks/services, or to build the command tree from a typedefs introspection. A single stale or broken workspace module then blocks operating on any other module — and forgeneratethis includes the very module you were trying to fix by runningdagger generate.The single-query lazy-load mechanism (peek root fields → narrow pending workspace modules) does not help here: these commands root their query at
currentWorkspace/currentTypeDefs(treated as needing the full workspace schema) and keep the session open rather than declaringSingleQuery.Fix
Reuse and extend the existing peek/narrow mechanism rather than adding any new client→server contract:
dagql.PeekWorkspaceSelectorIncluderecognizes{ currentWorkspace { <generators|checks|services>(include: [...]) … } }— backinggenerate/check/up.dagql.PeekWorkspaceTypeDefsIncluderecognizes{ currentTypeDefs(… include: [...]) … }— backingcall/functions, which build their command tree from a typedefs introspection. The include argument may be a literal list or a query variable, so the shared request peek now also resolves variables.currentTypeDefsgains an optionalincludeargument: a workspace module-loading hint the engine consumes before the resolver runs (the resolver itself ignores it).serveQuerynarrows the pending workspace modules to the named modules (module:item, or a baremodulematching a known workspace module) plus their transitive deps, via one shared filter. A bare token that is not a module name (an entrypoint-proxied item), or patterns matching no module, fall back to loading everything.generate/check/uppass theirincludepatterns;call/functionspass their leading positional token as the typedefsincludehint.Net effect:
dagger generate/check/up/call/functions <module>loads only that module (+ its dependencies), so an unrelated broken/stale module can no longer block the operation.Tests
dagqlpeek matching forgenerators/checks/servicesandcurrentTypeDefs(literal + variable include, plus negative shapes), and theengine/serverpending-module filter.TestWorkspaceGenerate/Check/Up/CallNarrowsToRequestedModuleagainst agenerators-brokenfixture — a healthydangmodule exposing a generator, a check, and a service, alongside a module with intentionally invalid source. Each asserts that targeting only the healthy module succeeds despite the broken module, while a full listing still loads every module and surfaces the broken one.