Skip to main content

Module compilation_cache

Module compilation_cache 

Source
Expand description

v2.76.0 — the EMS compilation cache: content-addressed, with GHC-style early cutoff. Nix model: a compile is a pure function of its inputs, so matching inputs ⇒ the recorded outcome is the outcome.

§What is actually cached (stated precisely, so the claim can be true)

The unit of persisted skip is a module’s validation (the type-check — by far the expensive pass; the 680k-line checker dwarfs parse + IR generation). Parsing and IR generation always re-run: IR nodes are Serialize-only by design (consumers re-derive from source), so the honest cache skips what it can prove skippable and recomputes the cheap, total passes.

  • Module validation hit — a module whose content_hash AND dependency interface_hash set match a recorded CLEAN validation skips its per-module type-check.
  • Early cutoff — a dependency edited without changing its public surface (comment, body-only edit) keeps its interface_hash, so every dependent’s key still matches: the dependents skip re-validation. This is real, observable via CacheStats, and sound because per-module validation consumes only interface facts (v2.76.0) — nothing body-derived is cached per-dependent.
  • The merged revalidation re-runs whenever any module changed. Cross-module semantics are global; v1 does not scope it. When NO module changed, the project-level entry marks the whole compile clean and the driver skips validation entirely.

§Laws

  1. Source hash changed → module miss.
  2. Any dependency interface hash changed → module miss.
  3. Both match a recorded clean validation → hit.
  4. Dependency source changed, interface stable → dependents still hit (early cutoff).
  5. Writes are atomic (.tmp + rename). A corrupt or unreadable cache is NOT an error: it self-heals by re-deriving from source (the boot-hydrate doctrine — a cache is never the source of truth).
  6. The manifest pins schema_version + axi_format + the compiler version; any mismatch busts the cache wholesale.

Only CLEAN validations are recorded: a failing module re-validates every run so diagnostics re-emit from source, never from a replay.

Structs§

CacheStats
Observable cache behavior — the tests’ witness that the laws run.
CachedDiagnostic
One persisted diagnostic (merged-gate warnings only — errors are NEVER cached; a failing compile re-derives from source every run).
CompilationCache
The EMS compilation cache. All operations are infallible by contract: any I/O or shape problem degrades to “no cache” (law 5).

Constants§

CACHE_DIR_NAME
Cache directory name, created beside the entry file.
CACHE_SCHEMA_VERSION
On-disk manifest schema version.