Skip to content

core: serve a module's local clients from its own tree - #14490

Merged
eunomie merged 4 commits into
mainfrom
eunomie/module-clients-2-own-tree
Oct 6, 2026
Merged

eunomie merged 4 commits into
mainfrom
eunomie/module-clients-2-own-tree

Conversation

@eunomie

@eunomie eunomie commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Problem

When a module's code — a Python or Go process the module's entrypoint starts — calls serveModule with a local path for one of its clients, the engine resolved the path in the caller's workspace instead of the module's own repository. So it could serve the wrong module: for a git module, the caller's module with the same name.

Change

serveModule now finds the nearest module in the calling process's parent chain and resolves the path inside that module's own tree:

  • a git module: the repository at the pinned commit,
  • a directory module: its directory,
  • a host module: the nearest git repository (else its own directory), read from the host that loaded it.

A path that leaves the tree, including through a symlink, is refused, and the target must hold a module config. A call with no module in the chain behaves as before. The module cannot forge its identity: the chain is set by the engine.

Why

It lets a module load its own local clients from generated code alone — no dagger.toml declaration and no handover from the entrypoint — in every SDK. It replaces the approach of the closed #14225 for this purpose, and does not change which Workspace a Dang entrypoint receives.

Tests

  • Unit: TestModuleTreePath and TestModuleParentAndItsHost.
  • Integration TestModuleLoading/TestServeModuleCallerTree: a git module serves its own sibling and not the caller's; a directory module; escape refused; symlink escape refused; a non-module call unchanged; a host module's child process. Plus TestServeModuleFromModule and TestServeModuleLocalAddress.

Notes for reviewers

  • It adds a server method (ModuleParentHostClientMetadata) to the core.Query interface and two test mocks.
  • A host module's tree is snapshotted from the loading host at each call (.git excluded, .gitignore not honoured), which costs time on large repositories.
  • It is meant to work together with core: key module calls on their declared clients #14489 for cache correctness, but does not depend on it.

@eunomie
eunomie added this pull request to stack #14495 October 5, 2026 16:00
@eunomie eunomie changed the title eunomie/module clients 2 own tree core: serve a module's local clients from its own tree Oct 5, 2026
@eunomie
eunomie force-pushed the eunomie/module-clients-2-own-tree branch from dc565e8 to d76cf07 Compare October 5, 2026 16:10
@eunomie
eunomie marked this pull request as ready for review October 5, 2026 16:31
@eunomie
eunomie force-pushed the eunomie/module-clients-2-own-tree branch from d76cf07 to f9ffefd Compare October 6, 2026 11:05
Base automatically changed from eunomie/module-clients-1-declared-client-key to main October 6, 2026 12:26
A module's code runs in a process its entrypoint starts, so the path
resolved in the caller's workspace, which serves the wrong module.

Signed-off-by: Yves Brissaud <[email protected]>
A path inside the tree can still reach outside it through a symlink,
and a directory with no module config is not a module to serve.

Signed-off-by: Yves Brissaud <[email protected]>
A process the module starts has no module, so the nearest non-module
client was the process itself, whose container lacks the module's files.

Signed-off-by: Yves Brissaud <[email protected]>
@eunomie
eunomie force-pushed the eunomie/module-clients-2-own-tree branch from f9ffefd to e8e61db Compare October 6, 2026 12:26
@eunomie
eunomie merged commit 5bb700b into main Oct 6, 2026
89 of 90 checks passed
@eunomie
eunomie deleted the eunomie/module-clients-2-own-tree branch October 6, 2026 13:02
eunomie added a commit to eunomie/python-sdk that referenced this pull request Oct 7, 2026
A module that calls a local client asks the engine to serve it from the tree
the module was loaded from; an engine without dagger/dagger#14490 looks in the
caller's workspace instead and answers "dir module source does not contain a
dagger config file". The check asserted its way into that wall on the floor
release and on the engine CI runs, where nothing in this SDK could have made
the call work.

The first call is now the probe: that answer, from the engine itself rather
than a version string, skips the rest and says so in the check's output, naming
the issue. Every other engine takes the assertions as they were, and the one
that fails for another reason still fails, now with its output in the message.

Signed-off-by: Yves Brissaud <[email protected]>
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