Skip to content

core: serve the module to an entrypoint's call process - #14767

Merged
eunomie merged 5 commits into
dagger:mainfrom
eunomie:entrypoint-process-current-module
Oct 21, 2026
Merged

eunomie merged 5 commits into
dagger:mainfrom
eunomie:entrypoint-process-current-module

Conversation

@eunomie

@eunomie eunomie commented Oct 21, 2026

Copy link
Copy Markdown
Member

A module on a Dang entrypoint ([entrypoint] kind = "dang") runs each function in a process that the entrypoint's call starts with withExec. That process had no module, so currentModule failed with no current module in Go, Python and TypeScript modules (seen on v1.0.0-beta.19).

The entrypoint now marks its call. For a marked call, withExec gives the nesting process the module of that call. The module enters the exec's identity, so execs of two modules never share a result. A process that the process starts gets no module.

Accepted limits, unchanged since v1.0.0-beta.14:

  • The process has no currentFunctionCall or currentNode.
  • No agent-caller provenance crosses the process.
  • Workspace auto-injection treats the process as a direct client.

Tests: TestModuleProcessModule, TestNesting*, and the integration tests TestModuleEntrypointProcessServesModule (6 cases) and TestModuleFunctionProcessHasNoModule.
Not run here: golangci-lint (the local binary cannot typecheck Go 1.27), the SDK test suites, and a full dagger check.

Explanation: https://gistpreview.github.io/?54af41157818231ab75178b6c73fdde4

An SDK entrypoint runs a function in a process that it starts for the
call, so currentModule must work there as in a container runtime.

Signed-off-by: Yves Brissaud <[email protected]>
The withExec hook runs before the call is current, so it must read the
API view from the request to see the v1 default nesting.

Signed-off-by: Yves Brissaud <[email protected]>
@eunomie
eunomie marked this pull request as ready for review October 21, 2026 08:52
@eunomie
eunomie merged commit 9685f45 into dagger:main Oct 21, 2026
94 checks passed
@eunomie
eunomie deleted the entrypoint-process-current-module branch October 21, 2026 12:00
TomChv added a commit to dagger/typescript-sdk that referenced this pull request Nov 20, 2026
A call on a module whose source changed reinstalled its dependencies: 14-20s
against 3.5s for a call that changed nothing, on a node module with
remoteCoreLib on, where the install pulls five published packages. The recipe
already read the manifest and clients/ alone and said so, and it still
reinstalled for an edit of a file nothing in the install reads.

Two inputs carried the module's source digest into the install exec, and
removing one alone changes nothing.

The exec itself: the engine attaches the module to a *nesting* exec so that
currentModule works in the process an entrypoint starts for a call
(dagger/dagger#14767), and an entrypoint's execs all nest by default, so the
install carried the module as a second cache input. Read from the engine's own
cache snapshot (/debug/dagql/cache on the debug port): the install's
result_call_input_digests held two entries, one of them Module. None of these
steps calls Dagger, so every setup exec — the image's packages, the loader, the
install — now opts out of nesting, and the input is gone. The dispatcher keeps
nesting: it runs the module's own code.

The read of the manifest: `withDirectory(currentModule.source, include: [...])`
filters inside the read, so what it depends on is still the module's source
directory, whose digest moves on any file in it. Directory has no content
keying to ask for, so installContext assembles the manifest and the clients
file by file, each synced with keyByContent — dagger/go's toolSource pattern
(dagger/go@4beea52), for the same reason. A file keyed by its content is the
same result for any source holding the same bytes at the same path, so the
install follows the manifest and the clients, and two modules with the same
dependencies now share one install.

Measured against the same engine and the same module, one source edit per
round: 20.3, 15.5, 15.4, 15.5, 14.4s before, 10.3, 10.8, 10.4, 9.3, 9.4s after.
The cache snapshot shows one install exec and one apk add for the whole run of
edits, where before each edit made its own. What is left is the dispatcher,
which has to run: the module's code changed.

The resource path keeps its context read, and its shortcut comment: a read that
names no paths has nothing to content-key.

Signed-off-by: Tom Chauveau <[email protected]>
TomChv added a commit to dagger/typescript-sdk that referenced this pull request Nov 23, 2026
#145)

* entrypoint: keep the module's source out of the install's cache key

A call on a module whose source changed reinstalled its dependencies: 14-20s
against 3.5s for a call that changed nothing, on a node module with
remoteCoreLib on, where the install pulls five published packages. The recipe
already read the manifest and clients/ alone and said so, and it still
reinstalled for an edit of a file nothing in the install reads.

Two inputs carried the module's source digest into the install exec, and
removing one alone changes nothing.

The exec itself: the engine attaches the module to a *nesting* exec so that
currentModule works in the process an entrypoint starts for a call
(dagger/dagger#14767), and an entrypoint's execs all nest by default, so the
install carried the module as a second cache input. Read from the engine's own
cache snapshot (/debug/dagql/cache on the debug port): the install's
result_call_input_digests held two entries, one of them Module. None of these
steps calls Dagger, so every setup exec — the image's packages, the loader, the
install — now opts out of nesting, and the input is gone. The dispatcher keeps
nesting: it runs the module's own code.

The read of the manifest: `withDirectory(currentModule.source, include: [...])`
filters inside the read, so what it depends on is still the module's source
directory, whose digest moves on any file in it. Directory has no content
keying to ask for, so installContext assembles the manifest and the clients
file by file, each synced with keyByContent — dagger/go's toolSource pattern
(dagger/go@4beea52), for the same reason. A file keyed by its content is the
same result for any source holding the same bytes at the same path, so the
install follows the manifest and the clients, and two modules with the same
dependencies now share one install.

Measured against the same engine and the same module, one source edit per
round: 20.3, 15.5, 15.4, 15.5, 14.4s before, 10.3, 10.8, 10.4, 9.3, 9.4s after.
The cache snapshot shows one install exec and one apk add for the whole run of
edits, where before each edit made its own. What is left is the dispatcher,
which has to run: the module's code changed.

The resource path keeps its context read, and its shortcut comment: a read that
names no paths has nothing to content-key.

Signed-off-by: Tom Chauveau <[email protected]>

* entrypoint: keep the module's source out of the resource install's key too

The install for a module that imports from outside its own directory still ran
again for every source edit. It read the module context —
`currentModule.contextDirectory.filter(exclude: [sourceSubpath + "/**"])` — and
a read of the context is keyed by the context, module source and all, so the
content keying of the commit before this one could not reach it. That is what
its shortcut comment said.

Both halves of that install now read file by file: the manifest and the clients
off currentModule.source, as the path without resources already did, and the
resources off the context, each file synced with keyByContent. Nothing in the
chain depends on a directory whose digest moves with the module's source. What
is left per edit is one glob of the context; the reduce over its result is keyed
by content at every step, so it hits cache.

Resources are derived rather than declared (importedResources), so this is the
path every module importing a sibling directory takes, declaring nothing.

Verified by runtimes:include-runs, which generates the fixture, installs it and
runs its check for real, and by runtimes:include-cache-key, which pins that
rewriting an included file still invalidates the call: content keying must not
make a stale read reachable. No speed-up is measurable on that fixture — it
declares no dependencies on purpose, so its install has nothing to do, and 11s
before against 12s after is the noise. The mechanism is the one measured on the
path without resources.

shortcut: a file list carries no symlink and no empty directory, where the
context read it replaces did. Upgrade when a resource tree needs one.

Signed-off-by: Tom Chauveau <[email protected]>

* entrypoint: name the view the recipe needs, and pin what it costs

`sync(keyByContent:)` is a view-gated argument (`AfterVersion("v1.0.0-beta.26")`
in the engine's core/schema/file.go), and an entrypoint's dang.toml is what
selects the view its recipe is inferred against. So the recipe has a floor now,
and a module whose entrypoint/dang.toml pins under it — or leaves the Dagger
import unversioned, which resolves to the default view, where `File.sync` has no
arguments at all — cannot be loaded.

`e2e/version/dang-config-check` is where that lands. It writes `dagger = true`
into a settled module and regenerates, expecting the pin to be healed; but
generation loads the module through the recipe before it can rewrite the file, so
the engine's inference error arrives instead of the heal.

The heal is still asserted for every pin the recipe can be loaded under, from the
floor rather than from beta.19 or `true`. What is no longer possible is asserted
in its place, for both spellings, so the next person to raise the floor meets a
test naming the cost rather than an inference error with no owner. The `spelled`
case pins the release outright: an Engine alias spelling the release beside a
Dagger import pinned lower is refused in its own right, two Dagger versions in
one file.

The recipe's own header named v1.0.0-beta.18, the release declaring `sources`
took. It names the real floor now, and what a module under it cannot do.

Signed-off-by: Tom Chauveau <[email protected]>

---------

Signed-off-by: Tom Chauveau <[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