skills/cache-expert/references/ids.md
IDs are the cache identity backbone in dagql.
An ID is an immutable representation of a call chain. Cache keying starts from that ID, so understanding ID digest behavior is the first step for any cache work.
The base cache treats call IDs as the source of truth:
CacheKey.ID.Digest() (recipe digest)CacheKey.ID.ContentDigest() (content digest), when presentThis is why subtle ID changes (args, view, module, custom digest, content digest) directly affect cache behavior.
IDs are encoded DAGs of calls (base64 protobuf), defined in dagql/call/callpbv1/call.proto and implemented in dagql/call/id.go.
Key concepts:
Append, WithDigest, WithContentDigest, WithArgument return new IDs.ID.Digest())Represents the call recipe (operation + declared inputs). This is the default cache identity.
Used for:
ID.ContentDigest())Optional digest representing actual result content.
Used for:
Important: content digest does not replace recipe digest globally; both coexist.
From dagql/call/id.go behavior:
These rules explain many "why did this key change?" cases.
In dagql/cache.go:
GetOrInitCall derives callKey from CacheKey.ID.Digest().String().CacheKey.ID.ContentDigest().String().fn, the cache indexes results under:
resultCallKey) if differentcontentDigestKey) when presentOn content-digest hit, cache reuses payload but keeps caller-facing ID equal to the requested ID (via per-call override), so external recipe identity remains stable.
GetCacheConfig hooks can rewrite CacheKey.ID before execution.
dagql/cachekey.go helpers mutate the ID digest by hashing in additional scope data:
CachePerClientCachePerSessionCachePerCallCachePerSchemaCachePerClientSchemaAfter rewrite, preselect re-decodes execution args from the final returned ID (dagql/objects.go) so execution/cache/telemetry stay aligned.
Display() is useful for debugging but can be expensive on large DAGs.dagql/call/id.godagql/call/callpbv1/call.protodagql/cachekey.godagql/cache.godagql/objects.go