Expand description
Content-addressed AI response cache (§17.8).
Each entry is a JSON-serialized provider response keyed by the
SHA-256 of the canonical JSON of the originating request. The cache
lives at .bock/ai-cache/ and is sharded git-style:
.bock/ai-cache/{hash[0..2]}/{hash}.json.
“Canonical” here means: serialize the request through
serde_json::Value before stringifying. serde_json::Value’s
object representation is backed by a BTreeMap
(when the optional preserve_order feature is off, which is the
default), so map keys are emitted in sorted order — which is what
makes the hash stable across HashMap iteration order, struct
field reordering, and language-version differences in JSON
formatting.
Cached responses are treated as pinned by callers: replaying a
cache hit is by construction deterministic, so CachingProvider reports a from_cache: true
signal that the decision-recording layer uses to set
Decision::pinned.
Structs§
- AiCache
- Content-addressed cache backed by
.bock/ai-cache/. - Cache
Stats - Summary statistics for the cache directory.
Enums§
- Cache
Error - Errors produced by the AI response cache.
Functions§
- compute_
key - Computes the SHA-256 of the canonical JSON of
request.