Skip to content

core: serve only listed clients from a tree a module's key leaves out - #15130

Open
sipsma wants to merge 4 commits into
mainfrom
sipsma/serve-listed-clients
Open

sipsma wants to merge 4 commits into
mainfrom
sipsma/serve-listed-clients

Conversation

@sipsma

@sipsma sipsma commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

A module's code can serve other modules from the repository it came from (#14490). That happens when its function runs, which is after the engine has looked the call up in the cache. So whatever a module can serve has to be covered by the call's cache key, or a change to a served module comes back as the old answer from the cache.

Main already covers this for git modules (the commit is in the key), for directory modules whose context is the whole directory, and, since #15080, for git workspaces with uncommitted edits. Three cases still return the old answer:

  • a module loaded from a local checkout that serves a module dagger.toml doesn't list as its client;
  • a module with entrypoint sources, or the include that replaces them (core: replace entrypoint resources with sources #14693), that another module served from a local checkout, serving its own client;
  • the same, served from a module loaded directly from git.

What changes

A module whose key doesn't cover its whole tree now serves only itself and the clients dagger.toml lists for it, and its calls are keyed on those clients and theirs in turn. That covers:

  • modules loaded from the host;
  • directory modules whose context sources or include narrowed to their own files, or that are read through a directory-backed workspace;
  • any module served from a host module's tree, at any depth. Its own key covers the tree, but the host module's key covers it only as its own files plus the clients it lists.

For a module loaded through a workspace, the list comes from the workspace's config as the session parsed it when it loaded the workspace. Reading the workspace's files is refused to a client that neither owns the workspace nor descends from its owner, and a call's key can be computed in such a client, for example an LLM's tools on a module the LLM reloaded from a workspace it edited. Any other module reads the dagger.toml nearest it in its own tree, on the host for a local module, and each client's own clients come from the config nearest that client. Either way, the list is the same however the module was reached, including from a process the module starts.

Serving an unlisted module fails with an error that says what to add, relative to the config that governs the module:

"modules/hello" is not one of its clients, so its cached results could not follow a change to it; add "./modules/hello" to clients under [sdks.<sdk>.scopes."modules/caller"] in dagger.toml

Git modules, and directory modules whose context is the whole directory, keep serving any module from their tree, because their key already covers it.

Every module that dagger/dagger's own modules serve is already listed in its dagger.toml, through the generated client bindings, which serve only listed clients.

Tests

  • TestServeModuleCallerTreeCache (TestModuleLoading) gains cases for each path:
    • a host module refuses an unlisted module;
    • a module served from a host module refuses an unlisted module;
    • a sources module and an include module refuse an unlisted module;
    • a change to a listed module reaches the caller through a host module, a git module, and a host module's served client;
    • clients listed in a nearer dagger.toml reach the caller's key;
    • the refusal names the config that governs the module.
  • Existing serve tests now list the clients they serve.
  • TestDeclaredLocalClients in core/workspace covers reading the governing config.

A module serves modules from its own tree when its function runs, after
the engine has looked the call up in the cache. A module loaded from the
host is keyed on the clients its workspace's config lists, and a module
another module loaded from its tree, whose entrypoint sources or the
include that replaces them narrowed its context to its own files, on
nothing beyond those files. Either returned results computed before a
module it served changed: one the config doesn't list, or any, served
from such a narrowed module.

Such a module now serves only itself and the clients that the config
governing it in its own tree lists, and its calls are keyed on those
clients and theirs in turn, each read from the config governing that
client. The list is read from the module's tree, so it is the same
however the module was reached, including from a process it starts.
Serving any other module fails with an error that says what to list.

A module a host module served from its tree, at any depth, serves only
listed clients too: its own key covers the tree, but the host module's
key covers it only as its own files and the clients it lists. Git
modules and directory modules whose context is their whole tree keep
serving any module from it: their key already covers it.

Signed-off-by: Erik Sipsma <[email protected]>
A local module loaded through a workspace reads its source through that
workspace, which carries its edits and its owner's route to the host.
Its dagger.toml, which lists the clients it may serve and its calls are
keyed on, was read straight from the host instead. Where the module's
host could not be reached that way, such as a module an LLM reloaded
from its edited workspace, every call failed to compute its cache key.

Read the config through the module's workspace, as its source is read,
and from the host only for a module loaded without one. An edited
dagger.toml in the workspace now counts as well.

Signed-off-by: Erik Sipsma <[email protected]>
Reading a workspace module's dagger.toml through its workspace, as the
previous commit did, is refused when the call's key is computed in a
client that neither owns the workspace nor descends from its owner: a
module an LLM reloaded from a workspace it edited is owned by the module
that edited it, while its tools are keyed in the LLM's caller. Every
call of the reloaded module then failed to compute its key.

A local module loaded through a workspace now takes its clients from the
workspace's config as the session parsed it when it loaded the
workspace, which needs no read. That list holds only the workspace's
own dagger.toml, as it was when the workspace loaded. Any other module
still reads the config governing it from its tree, and the shared tree
reader is back to reading a local module's files from its host.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma
sipsma force-pushed the sipsma/serve-listed-clients branch from 0a0a42d to b88efe5 Compare November 19, 2026 23:04
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.

2 participants