SnapshotCache

class SnapshotCache(cacheRoot: File, toolVersion: String?)

A content-addressed cache of serialized snapshots keyed by commit SHA and the running serialkompat version. Because a commit's source is immutable, a cached snapshot for a SHA can be reused without recomputing — the baseline never has to rebuild an unchanged ref twice (design §5). The tool version is part of the key (design §5: "baseline SHA + tool version") so an upgrade never reuses a baseline cached under an older serialkompat: each version reads and writes its own subdirectory, and entries of any other version — including the legacy root-level <sha>.snapshot layout — are never consulted.

Reads are validated and writes are atomic, so a corrupt or half-written cache entry (e.g. a CI job killed mid-write) is never trusted as a baseline — that would silently under-report changes (#16 "corrupt cache ⇒ refuse to run").

Constructors

Link copied to clipboard
constructor(cacheRoot: File, toolVersion: String?)

Functions

Link copied to clipboard
fun get(sha: String): String?

The cached snapshot text for sha, or null on a miss. A cached entry that does not parse as a snapshot is treated as a miss (and removed) so the caller re-extracts rather than diffing against a corrupt baseline.

Link copied to clipboard
fun put(sha: String, snapshotText: String)

Stores snapshotText for sha atomically: it is written to a temp file and renamed into place, so a crash never leaves a partially-written entry that a later run would mistake for a valid baseline.