Skip to main content

Module cache

Module cache 

Source
Expand description

Disposable, closure-keyed derived observation cache (Phase 11.8).

A seed node’s output is a pure function of its canonical bytes, hence of its NodeId. A cache keyed by NodeId is therefore automatically closure-keyed: a changed dependency yields a different dependency id, hence a different node id, hence a miss; an unchanged closure yields a hit. This is the exact analogue of rustc’s red-green validation, and it needs no invalidation pass (ADR-0025, ADR-0027).

The cache is disposable and never normative. It is off the exactness path and can never influence materialize. Because DerivedCache::get only has the output bytes (it cannot re-derive the node), every entry carries a sidecar integrity digest: a mismatch fails closed with crate::ErrorClass::IntegrityMismatch rather than returning wrong bytes. The DAG layer treats any cache error as a miss, so a corrupt or missing entry simply falls back to recomputation.

§On-disk layout

<root>/<64-hex>        output bytes, verbatim
<root>/<64-hex>.b3     BLAKE3-256 sidecar digest of those bytes

Writes are atomic (tmp -> fsync -> rename); a torn write cannot publish a half-entry. Cache bytes are a fourth accounting universe and are never folded into the descriptor or store universes (ADR-0027).

Structs§

DerivedCache
A disposable, closure-keyed derived observation cache rooted under a field store’s cache/ directory.