Skip to content

core: keep git content digests type-distinct - #13998

Merged
vito merged 1 commit into
dagger:mainfrom
vito:extract/dagql-typed-cache
Aug 29, 2026
Merged

vito merged 1 commit into
dagger:mainfrom
vito:extract/dagql-typed-cache

Conversation

@vito

@vito vito commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Cache equivalence in DagQL is keyed on content digest, and three Git-related content digests are hashed from the same url + SHA + bool inputs while returning different types:

  • dagger/core/schema/git.go

    Lines 1147 to 1149 in 106d628

    repo.URL.Value.String(),
    string(ref.Digest()),
    strconv.FormatBool(repo.DiscardGitDir),
    => returns GitRef
  • dagger/core/schema/git.go

    Lines 1488 to 1490 in 106d628

    repo.URL.Value.String(),
    ref.SHA,
    strconv.FormatBool(repo.DiscardGitDir),
    => returns GitCommit
  • dagger/core/schema/git.go

    Lines 938 to 947 in 106d628

    // A commit SHA only identifies an object inside a Git object database.
    // The remote URL is part of the checkout source.
    remoteRepo.URL.Remote(),
    // The resolved commit selects the files to check out.
    gitRef.Ref.SHA,
    // The returned Directory may include or exclude .git based on both the
    // repository keepGitDir option and tree(discardGitDir: ...).
    strconv.FormatBool(keepsGitDir),
    => returns Directory

When the inputs line up (e.g. commit digests discardGitDir=false while tree digests keepsGitDir=false), the digests collide and a lookup can hand back a Directory where a GitCommit was expected, or vice versa. The latter two collided in my case.

What this does

Mixes a per-type discriminator string (gitRef, gitCommit, gitTree) into each digest's inputs so the three can no longer collide. Existing cache entries for these calls are invalidated once by the digest change, which is the usual cost of a cache-identity fix.

Extracted from the llm-workspace-dev-env stack; independent of the other extractions.

🤖 Generated with Claude Code

Comment thread dagql/cache_egraph.go Resolved
The GitRef, GitCommit, and tree Directory content digests were all
hashed from the same url + SHA + bool inputs, so calls returning
different types could produce the same digest. Cache equivalence is
keyed on content digest, so a lookup could hand back a Directory where
a GitCommit was expected, or vice versa. Mix a per-type discriminator
into each digest so the three can no longer collide.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito force-pushed the extract/dagql-typed-cache branch from 37b8ff4 to e177422 Compare August 29, 2026 01:59
@vito vito changed the title dagql: key cache equivalence on result type core: keep git content digests type-distinct Aug 29, 2026
@vito
vito merged commit 6938a67 into dagger:main Aug 29, 2026
89 checks passed
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