Skip to content

core: dependencies of a served module keep its cache namespace - #14844

Closed
eunomie wants to merge 1 commit into
mainfrom
engine-dir-dependency-origin
Closed

eunomie wants to merge 1 commit into
mainfrom
engine-dir-dependency-origin

Conversation

@eunomie

@eunomie eunomie commented Oct 23, 2026

Copy link
Copy Markdown
Member

Follow-up to #14813.

Problem

#14813 gives a module served from its caller's tree the identity of that tree, so its cache volumes match the same module loaded directly. That module's own local dependencies didn't inherit it. ResolveDepToSource loads a local dependency of a Dir-kind parent with Directory.asModuleSource on the parent's context directory and no origin. The dependency then falls back to the content-digest namespace.

This shows up when a migrated module serves a legacy one. On #14840, a migrated module's client serves legacy cmd/codegen and go-client-dev, and their dependency on the go module creates its volumes in mod(goxxh3:ed7b24ab65610363):

  • That namespace is cold on every engine, and it rotates with the go module's files.
  • Main uses mod(gogithub.com/dagger/dagger/.dagger/modules/go).

Five checks are hit, about 15 minutes of extra check time per event: 2117s against 1221s on main.

Check #14840 main
release/publish-with-mock-endpoints 1010s 853s
python-client/client-library/stale 304s 71s
elixir-client/client-library/stale 303s 109s
rust-client/apiclient/stale 253s 114s
dotnet-client/test 247s 74s

Fix

A local dependency of a Dir-kind source with an origin is loaded with the parent's origin root, when the dependency lives in the same tree. Its identity is the root plus its own path (.dagger/modules/engine-dev + ../go gives <root>/.dagger/modules/go), so its namespace is that of the dependency loaded directly. Dependencies of dependencies follow from the same rule. The implementation-scoped digests include the origin, as they do since #14813.

Sources without an origin select exactly the same asModuleSource call as before, so their IDs and caches don't change. A dependency path that leaves the tree gets no origin. No public API change.

Tests

  • Unit: TestDirDependencySourceArgs covers:

    • a ../go dependency under a Git root and under a local root;
    • a dependency of a dependency;
    • the unchanged selection without an origin;
    • a path that leaves the tree.
  • Integration: TestServeModuleCallerTree/dependency_of_a_served_sibling_shares_the_caches_of_the_same_module_loaded_directly.

  • Integration: TestServeModuleCacheNamespaces, a table over these dimensions:

    • the caller: a Git module, a host module, or a served module;
    • the module it reaches: an entrypoint module, or a legacy module with manifest dependencies;
    • the depth: 1, or 2 (a dependency of a dependency, or a sibling a served sibling serves).

    Each cell writes to a cache volume through the module it reaches, then loads the module that owns the volume directly from the same path, and expects to find the write. This is the invariant behind core: serve the module to an entrypoint's call process #14767, core: same-repo modules and module entrypoints share their caches #14813 and this change, checked in one place.

  • On a dev engine built from this PR, all 12 cells and the dependency subtest pass. On v1.0.0-beta.21 the three "legacy module at depth 2" cells and the dependency subtest fail, and the other nine cells pass.

Limits

  • Cloud engines are released builds, so this is visible on Cloud only after a release.
  • Callers loaded through a Git workspace still can't serve modules from their tree: they have no unfiltered context directory. That is unchanged from core: same-repo modules and module entrypoints share their caches #14813.
  • A host module's function calls are cached on its own files, not on the siblings it serves. The new test makes each call unique for that reason. This is pre-existing and not changed here.

Related: #14813, #14840.

A module served from its caller's tree is a Dir-kind source that keeps
the identity of that tree, so its cache volumes match the module loaded
directly. Its own local dependencies were loaded with
Directory.asModuleSource on the parent's context directory without
that origin, so they fell back to the content-digest namespace. A
legacy module served by a migrated module then built its dependencies,
such as the go module, from cold caches that also rotate with every
change of their files.

Pass the parent's origin to the dependency when the dependency lives
in the same tree. Its namespace is then the one of the dependency
loaded directly, and the implementation-scoped digests include it as
they do for served modules. Sources without an origin select exactly
what they did before.

Signed-off-by: Yves Brissaud <[email protected]>
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions Bot closed this Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant