Repository navigation
Targeted module loading for dagger api call / api functions - #13574
Merged
Merged
Conversation
eunomie
force-pushed
the
api-call-module-scope-design
branch
from
July 2, 2026 12:07
e5164e1 to
7697688
Compare
eunomie
force-pushed
the
api-call-module-scope-design
branch
2 times, most recently
from
July 16, 2026 08:18
8d3d02d to
f9e3023
Compare
dagger api call / api functionsdagger api call / api functions
eunomie
force-pushed
the
api-call-module-scope-design
branch
2 times, most recently
from
July 16, 2026 10:01
0a97a16 to
b1331a0
Compare
eunomie
force-pushed
the
api-call-module-scope-design
branch
from
July 16, 2026 13:02
b1331a0 to
ad8452e
Compare
eunomie
marked this pull request as ready for review
July 16, 2026 13:49
eunomie
force-pushed
the
api-call-module-scope-design
branch
2 times, most recently
from
July 16, 2026 14:18
192c252 to
c57b53f
Compare
tiborvass
force-pushed
the
api-call-module-scope-design
branch
2 times, most recently
from
July 20, 2026 16:00
99b7d4e to
76c577f
Compare
tiborvass
approved these changes
Jul 20, 2026
tiborvass
force-pushed
the
api-call-module-scope-design
branch
2 times, most recently
from
July 21, 2026 08:29
69b9d75 to
af16986
Compare
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]>
Add a WorkspaceModuleScope hint to ClientMetadata: the leading CLI command token, forwarded unresolved (it may name a workspace module, an entrypoint-proxied function, or a typo). The engine may use it to defer loading unrelated workspace modules for the first request whose only full-schema demand is currentTypeDefs; consumption and resolution are engine-side and follow in the next patch. The client only forwards the scope when it also asks for workspace module loading, mirroring the LoadWorkspaceModules guard: with -m or core mode there are no pending workspace modules to narrow. Nested request metadata treats the scope like the other load-shaping fields: never inherited from the parent's struct copy, re-read from the nested request's own headers -- a dagger CLI running inside a container is a nested client and its scoped call must narrow like on the host. Since the nested client is created by a headerless session-attachables pre-request before the CLI's metadata arrives, the scope also joins getOrInitClient's late-arriving fill-in set, beside LoadWorkspaceModules and SingleQuery. Old engines json.Unmarshal client metadata and ignore the unknown key, degrading to loading everything; old CLIs simply do not send it. Signed-off-by: Yves Brissaud <[email protected]>
Consume the workspace_module_scope hint in ensureRequestModulesLoaded: when a request's only full-schema demand is currentTypeDefs, the scope replaces its load-everything contribution with the resolved module set -- the named module plus the pending entrypoint module(s), whose functions are proxied onto the Query root and belong in the command tree either way. A token naming nothing known demands the entrypoint alone when one is pending (it is probably one of its proxied functions), else everything loads. Matching kebab-normalizes both sides like the selector and root-field filters, and served modules are recognized without reloading. Any other full-schema root field (env, __schema, ...) keeps loading everything, scope untouched. The scope is consumed exactly when it is applied. One-shot consumption is load-bearing: dagger api call handing off to the interactive prompt-mode shell reuses the session, and the shell's own typedefs introspections must see every remaining module, not the narrowed view. Consuming early is monotonically safe -- loading stays additive, so a consumed scope only ever means more loads later, never less served. Scoped loads stay strict (no best-effort): a call whose demanded module fails to load must fail with that module's error. Signed-off-by: Yves Brissaud <[email protected]> Signed-off-by: Tibor Vass <[email protected]>
dagger api call and api functions forward their leading positional token -- extracted with the existing functionName flag-skipping logic -- as the workspace_module_scope client metadata hint, so the engine narrows the currentTypeDefs introspection to the targeted module instead of loading every workspace module. The queries the CLI sends are unchanged, there is no engine-version branch (old engines ignore the unknown metadata key and load everything, as before), and all resolution stays engine-side. The scope is set at the two command sites, deliberately not in initModuleParams: dagger shell shares that helper and must keep the full workspace view for its command table. Signed-off-by: Yves Brissaud <[email protected]>
Lock in that dagger api call/functions targeting one module never load an unrelated broken sibling: the CLI's workspace_module_scope hint narrows the currentTypeDefs introspection to the targeted module, so building the command tree (including --help) no longer pays for -- or fails on -- every workspace module. Full listings still load everything and surface the broken module. The call-narrowing fixture covers the demand shapes single-word module names cannot: a module declared goodMod targeted through its kebab-case command name, and a workspace entrypoint whose root-proxied function is the first argument, loading the entrypoint module alone. The fixture also extends kebab-case coverage to the generate/check/up selector path, which the merged generators-broken fixture only exercises with single-word names. Signed-off-by: Yves Brissaud <[email protected]>
tiborvass
force-pushed
the
api-call-module-scope-design
branch
from
July 21, 2026 16:12
8e586e2 to
a9d4c30
Compare
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.
dagger api call <module>/api functions <module>build their command tree from acurrentTypeDefsintrospection that names no module — so they load every workspace module, and one broken sibling blocks calling any module. This completes #13548, which narrowedgenerate/check/upand leftcall/functionsout of scope.Fix
The CLI forwards its leading argv token (already extracted by
functionName) as a newworkspace_module_scopeClientMetadatahint. The engine resolves it inensureRequestModulesLoaded(kebab-normalized; a known module → that module's target + entrypoint; unknown → entrypoint, else all) and consumes it one-shot after the first successful load whose only full-schema demand iscurrentTypeDefs. Pre-request loading leavescurrentTypeDefsand its cache key untouched.getOrInitClient's late-arriving fill-in, since the nested client is created by a headerless session-attachables pre-request).sequenceDiagram autonumber participant CLI as dagger CLI participant H as serveQuery participant L as module loader participant R as currentTypeDefs resolver Note over CLI: dagger api call good fn<br/>(workspace = {good, bad-broken, entry*}) Note over CLI: connect: workspace_module_scope: "good" CLI->>H: query { currentTypeDefs(...) } — unchanged document H->>H: peek root fields → [currentTypeDefs]<br/>scope set → resolve + consume (one-shot) H->>L: demand = {good, entry} — bad stays pending L-->>H: good + entry served H->>R: resolve currentTypeDefs (unchanged resolver) R-->>CLI: typedefs (Query + good + entry closure) CLI->>H: query { goodMod { fn } } H-->>CLI: result — bad never loaded, cannot blockDesign doc
hack/designs/targeted-module-loading-api-call-functions.md(in-tree) — includes a post-mortem of #13380 / #13406 / #13539 / #13543 and the alternatives considered.Tests
Unit (demand-filter matrix, one-shot consumption, metadata plumbing incl. nested inherit/forward, CLI sites incl. shell guard) + integration
TestWorkspaceCall*— targeting a module (exact + kebab), entrypoint-proxied function, scoped--help, one-shot within a session, bare listings still load all — all passing against a dev engine (27 passed), plus the merged generate/check/up narrowing tests as regression.