Skip to content

core: key module calls on their declared clients - #14489

Merged
eunomie merged 4 commits into
mainfrom
eunomie/module-clients-1-declared-client-key
Oct 6, 2026
Merged

eunomie merged 4 commits into
mainfrom
eunomie/module-clients-1-declared-client-key

Conversation

@eunomie

@eunomie eunomie commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Problem

A caller can serve a local client's module and cache a function result computed from it. Today, if only the client's target module changes, the caller's cached result can stay stale: the served module never enters the caller's cache key, so the cache lookup hits even though the inputs really changed.

Fix

Before a module function's cache lookup, the call gains one implicit input: a digest of the local clients the caller's dagger.toml declares for that module's scope, plus those clients' own declared clients, recursively.

  • A module with no declared clients gets no extra input, so its cache key is unaffected.
  • The digest is an implicit input, not a visible argument, so it never appears in dagger call output or in Dagger Cloud's trace.
  • A declared client that cannot be resolved no longer disables caching for the whole module; it keys on a stable sentinel.
  • The declared-client list is persisted with the workspace.

Test

core/integration/module_serve_test.go adds TestServeModuleDeclaredClientCache with four subtests:

  • an unchanged target hits the cache,
  • a changed target misses and then hits,
  • an unresolvable target fails and then succeeds correctly,
  • the new implicit input stays hidden from dagger call display.

Trade-offs (reviewed and accepted)

Known side effect

Replaying a recorded call by ID now recomputes this digest from the caller's current clients rather than reusing the recorded value. This matches how other engine-computed implicit inputs already behave.

A hook can then add engine-computed identity that call displays omit.

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

TomChv commented Oct 5, 2026

Copy link
Copy Markdown
Member

This lint failure failure is weird since you don't update these codes, and it passes on main.

core/schema/modulesource.go:1122:43 nolintlint directive //nolint:staticcheck // deprecated; read for legacy JSON config compat is unused for linter "staticcheck"
core/schema/modulesource.go:1123:43 nolintlint directive //nolint:staticcheck // deprecated; read for legacy JSON config compat is unused for linter "staticcheck"
core/schema/modulesource.go:1124:43 nolintlint directive //nolint:staticcheck // deprecated; read for legacy JSON config compat is unused for linter "staticcheck"
core/workspace/migrate.go:377:81 nolintlint directive //nolint:staticcheck // SA1019: migration must inspect deprecated JSON fields. is unused for linter "staticcheck"

@eunomie
eunomie marked this pull request as ready for review October 5, 2026 16:31
@grouville
grouville self-requested a review October 6, 2026 07:43
A module serves its clients at run time, after the cache lookup, so a
changed target left the caller's cached result stale. A target that
cannot resolve must not stop the module's other calls caching, and a
workspace restored from the cache must keep its clients.

Signed-off-by: Yves Brissaud <[email protected]>
@eunomie
eunomie force-pushed the eunomie/module-clients-1-declared-client-key branch from 39f0b93 to 8b0cae5 Compare October 6, 2026 11:05

@TomChv TomChv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge when CI is green

@eunomie
eunomie merged commit fe2107c into main Oct 6, 2026
90 checks passed
@eunomie
eunomie deleted the eunomie/module-clients-1-declared-client-key branch October 6, 2026 12:26
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