Skip to content

A module whose SDK scope declares a git client is keyed to the session, so its calls never cache across sessions #15014

Open

Description

@yasyf

What happens. ModuleFunction adds dagql.PerSessionInput to every call of a module when the dagger.toml that governs it declares a git client for its scope (core/modfunc.go, declaredGitClientsDigest, and workspace.DeclaredGitClients). The comment there gives the reason: the result may come from credentials this session lent, which another session may lack. So every call into such a module re-executes in each new session, including pure functions over content-addressed inputs.

Reproduction. A workspace whose [sdks.dang.scopes."<module>"] sets clients = ["github.com/dagger/go/gobuild@<sha>", "github.com/dagger/go/gomod@<sha>"]. Call a function of that module twice from two dagger sessions with identical inputs: the second call shows DONE, not CACHED. Remove the clients line (keeping the module's [[dependencies]]) and the second call is CACHED. Pointing the same dependencies at local copies (clients = ["./.dagger/modules/gobuild", ...]) also caches, since local clients are keyed by content (declaredClientsDigest).

Cost. On a monorepo with about 1,160 Go test checks driven through a patched dagger.io/go module that declares gomod and gobuild as git clients, a one-line README change took 275 s against a warm engine with the clients declared and 105 s without (main 092b01e, dagger check -j 32). A smaller shard took 73 s against 41 s. The time is package discovery and setup re-running per session.

Why an opt-out is safe here. The clients are public repositories pinned to a full commit sha. No credential can change what they resolve to, so a result one session computed is the result any session would compute.

Asks, in order of preference:

  1. Key on credentials only when a git client actually resolved through the session's credentials (a private fetch), not whenever one is declared.
  2. Treat a client pinned to a full commit sha of a repository the engine can fetch anonymously as content-addressed.
  3. An explicit per-client opt-out in dagger.toml, for example clients = [{ source = "github.com/...@<sha>", public = true }].

Workaround we use: vendoring the two modules under .dagger/modules at the pinned sha and declaring them as local clients.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions