Module cache
Expand description
Content-keyed JSON sidecar for ChangeSetReport, mirroring the
enrichment narrative cache’s shape: plain-hex key, per-repo directory
under the shared cache root, best-effort read/write, corrupt = miss.
The key covers HEAD plus the exact worktree content of every change-set path, so any edit — or a commit — moves it. Thresholds and calibration are deliberately EXCLUDED: the sidecar stores only MEASURED data, and consumers recompute verdicts on every read, so an improved gate configuration reaches warm caches without invalidation.
Functions§
- cache_
path - The on-disk sidecar path for
key:repo_cache_dir(cache_root, repo_path)/change-set/<first 16 hex>.json. - read
- Read the cached report at
key, orNonewhen absent or corrupt. A missing file is the ordinary miss and stays silent; a file that no longer deserializes is logged atwarnand treated as a miss. - report_
key - The content key for a change set: lowercase-hex SHA-256 of
head_sha | sorted "path\0content-sha256" lines | crate version |calib=<digest> | rows_limit=<n> | opts=<canonical-json digest> |[KEY_SCHEMA]. A deleted path contributes the literal"deleted"in place of its content hash. - write
- Write
reportto the sidecar forkey, creating the directory if needed. Best-effort: a cache is an optimization, so any failure is logged atwarnand swallowed — a gate run must never fail because its report could not be cached.