Skip to content

give a module entrypoint a workspace built from its own module source - #14225

Closed
eunomie wants to merge 4 commits into
dagger:mainfrom
eunomie:fix-entrypoint-source-workspace
Closed

eunomie wants to merge 4 commits into
dagger:mainfrom
eunomie:fix-entrypoint-source-workspace

Conversation

@eunomie

@eunomie eunomie commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

Give a module entrypoint a workspace built from its own module source

Problem

The engine calls a module's entrypoint to load its types and dispatch its calls, and passes it a Workspace. It passed the workspace of the caller, not of the module.

So any module that does not live in the caller's workspace got a tree that does not contain it. Its entrypoint could not find its own files: types loaded, every call failed. In practice a module published to git cannot be called at all — which is what blocks module sharing for the Go and Python SDKs.

Fix

Build the entrypoint's workspace from the module's own source, whatever the source kind:

  • git — the repository at the pinned commit
  • directory — the directory the source was created from
  • local, or loaded from a workspace — the context the engine loaded: manifest, the module's files, and whatever its includes name

The caller's workspace is no longer used here. A function that declares a Workspace argument still gets the caller's, because the caller passes it.

Two consequences:

  • A local module that reads a file above its own directory must now name it in includes. Git and directory modules are unaffected.
  • An SDK entrypoint could no longer see the local clients the caller declared for the module, so the engine now adds those (and their local deps) to the workspace, with a config naming only that scope.

Notes for review

  • For git, the fix reuses ModuleSource.Git.UnfilteredContextDir rather than rebuilding a GitRef: the tree is already loaded, it keeps .git, and it is content-addressed by commit. A test asserts two sessions get the same Workspace.address.
  • For local, no API builds a host-backed workspace at an arbitrary path (NewWorkspaceSourceRootlessLocal reads as empty by design), so it reuses the include-filtered context the loader already produced. No new engine API, no extra host read.
  • Tests cover git, directory, local inside and outside the workspace, no git root, declared clients, and an entrypoint resolved by reference.

📄 Understanding this change

A module source loaded through Workspace.moduleSource carries that
workspace, and its subpath is relative to it. The entrypoint was given
the calling client's workspace instead, so a chain of local modules
could not resolve its local dependencies.

Signed-off-by: Yves Brissaud <[email protected]>
A module loaded by git ref, from a directory, or from a local path
outside the caller's workspace received the caller's workspace, so its
entrypoint could not find the module it serves.

Signed-off-by: Yves Brissaud <[email protected]>
A module inside the caller's workspace still received the caller's
workspace, so the same entrypoint saw a different kind of tree
depending on where its module was loaded from.

Signed-off-by: Yves Brissaud <[email protected]>
The workspace is now the module's own context, so an SDK entrypoint
could no longer resolve the local clients the caller declared for the
module in the workspace config.

Signed-off-by: Yves Brissaud <[email protected]>
@eunomie eunomie changed the title fix: scope an entrypoint's workspace in its module source's workspace give a module entrypoint a workspace built from its own module source Sep 21, 2026
@eunomie
eunomie force-pushed the fix-entrypoint-source-workspace branch from 25c37a0 to 099e8bb Compare September 21, 2026 15:05
@shykes

shykes commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

I don't think this is what we want. We actually want the caller's workspace IMO.

If the entrypoint wants the module's source we should make sure they can call currentModule() and it returns the module's source.

@eunomie

eunomie commented Sep 23, 2026

Copy link
Copy Markdown
Member Author

If the entrypoint wants the module's source

I'll double check but I think the issue is exactly there. The entrypoint requires its own workspace access. Without that the entrypoint cannot load its own module.
I think I don't understand why the entrypoint would be interested in the caller workspace, and I think the entrypoint itself shouldn't even have access to it. But I might be wrong.

@eunomie

eunomie commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

Closing it, will be replaced by a better design

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