feat(processing): opt-in native result cache for warm loads (phase 1)

Merged
LO
20d ago
+6162-72

Phase 1 of the native warm-load cache from the IFC load hillclimb. Opening the same IFC file again through the Rust core no longer has to recompute: an opt-in, content-addressed on-disk cache replays the complete result. It is off by default. Only the Rust API and perf_probe use it. FFI, Python, the server and the CLI are untouched.

What is cached

One tier: the complete processing result of a full pass, ResultCache::process(content, &request). That means every mesh in order, including fields the existing perf fingerprint and serde both skip: instance, local_bounds, local_to_world, presentation, UVs, texture pixels and URLs, materials, text and properties. It also covers instances, the frame, the site and building transforms, metadata (unit refusal, georef) and every stats counter, plus the full GeometryDiagnostics. Floats are stored as raw bits. Texture pixels shared through one Arc are stored once and shared again on replay.

A hit sets stats.from_cache = true. The *_time_ms fields are the producer's, kept verbatim. The current call's work is reported separately in CacheReport.work.

RequestOutcome
CacheMode::Off (default)Calls process directly. Nothing is hashed or opened.
cancel set, injected entity_index, retain_meshes == falseBypass(..). Live pass, nothing stored.
Calling thread inside an ExecutionAccount, source stop or terminal domainBypass(AmbientResourceScope)
Streaming / callback sinksNot served. The cached entry point takes no sink, so a hit can never be missing sink events.
MissThe unchanged pipeline. In read-write mode the result is then published.

Deviation from the brief and design. The cache is a reusable session context (ResultCache) that wraps process(), not a new ProcessingRequest field, for three reasons. process() stays I/O-free, which is the design's own first requirement. The outcome report needs a return channel, and the exhaustive public ProcessingResult cannot gain one without a semver break. And "no hashing when off" becomes structural.

Key composition

SHA-256("ifc-lite-native-result-v1" ‖ SHA-256(all source bytes) ‖ len ‖ request digest ‖ engine digest), with every part length-framed.

  • Request. Explicit tags for the opening filter, skip_voids, quality, layer slicing, every batching field (including fast_first), all four feature flags and instancing. Ids are sorted, and None differs from Some(empty). ProcessingRequest is destructured in full, so a new field does not compile until it is classified.
  • Engine, build. This part covers three things:
    • The build.rs digest: core, geometry and processing sources, Cargo.lock, rustc -vV, the target, profile, flags, target features and processing's features.
    • ifc_lite_geometry::output_policy::BUILD_FEATURES: the geometry crate's own resolved features, kept equal to its Cargo.toml by a test.
    • The executable file identity: size, mtime, ctime, device and inode, with no path.
  • Engine, policy. The effective output policy, read through the accessors the pipeline calls (output_policy::effective_output_policy): rect fast and parametric paths, local frame, void union / 2D / prism paths, extra dedup, the half-space cap, the fast-cut ratio, the effective CSG caps and the alternate triangulator. Also processing's degenerate backstop and the rayon worker count.
    • No environment variable is hashed. An earlier revision hashed every IFC_LITE_* / IFCLITE_* variable except a short list. Review showed that disagrees with values cached in OnceLocks, so it was replaced by the effective policy.
    • The ratchet (tests/result_cache_policy_ratchet.rs) requires every IFC_LITE_* name read in core, geometry or processing to be either keyed through that policy or listed as non-output. The non-output list has two entries:
      • IFC_LITE_CACHE_DIR: it only chooses where entries are stored.
      • IFC_LITE_ENGINE_BUILD_DIGEST: a compile-time env! that build.rs sets to the build digest, which is itself keyed.
    • Router frame policy. No router on the cached process() path pins an explicit frame policy (RouterConfig::local_frame). All of them are built from RouterConfig::default() plus keyed request fields, and a ratchet fails if one appears.
  • Mid-pass guards. Every policy setter bumps a seqlock-style mutation generation. A pass during which it moved, even A→B→A, is not stored (SkippedPolicyChanged). A pass during which any resource::stop happened anywhere in the process is not stored either (SkippedResourceStop).

Format

A 200 B header (magic, version, total length, key, source digest and length, request and engine digests, and a SHA-256 over the header and directory), then a 4×64 B directory (kind, offset, length, count, SHA-256), then the sections META, TEXTURES, MESHES and INSTANCES back to back. There is no compression, usize, serde ordinal or memory cast. Every struct is destructured on encode.

Trust model and its limits

Entries are untrusted input:

  • Every length, offset and count is checked with overflow-safe arithmetic.
  • Every count must fit in the remaining bytes at the record's minimum size, and that bounds allocation.
  • Sections must be in a fixed order, contiguous, with no overlap, gap or trailing bytes.
  • Every checksum is verified before anything is decoded.
  • Tags, booleans and UTF-8 are validated.
  • The decoded result must pass the same invariants the encoder enforced.

Any failure gives a warning, a miss and a recompute. The store uses a 0700/0600 private directory and digest-only names. Files are opened only after lstat shows a regular file, with O_NOFOLLOW | O_NONBLOCK, and the opened handle must match, be ours and carry no group/other bits; directories are checked by path. Writers take one of 256 permanent lock stripes without waiting, then write a temp file, fsync it and atomically rename it into place. A corrupt entry is removed only if it is still the generation that was read. Eviction is LRU on publish only, against a 10 GiB directory budget, a 1 GiB entry limit and 1 GiB of free-space headroom; these are policy choices, not measured. Disk errors fail open.

Stated limit: a checksum detects damage, not authorship. A process running as the same user can write a self-consistent entry with wrong geometry, and this cache cannot tell. Stronger environments need authenticated entries or a separate trusted writer. On non-Unix targets the symlink check is a racy metadata check.

A result whose raw payload alone exceeds the entry limit is refused before it is encoded. Entries are written as parts, never concatenated. Worst-case decoded memory is about 11× the entry size, for an adversarial entry made of empty meshes: a 90 B record against an in-memory MeshData of roughly 976 B.

Review rounds

Three independent adversarial reviews; every finding was reproduced (or confirmed by reading the code) before it was fixed.

FindingFixRegression testFails without the fix?
R1-1 policy setters and OnceLock-vs-environment not keyed282113aceffective_policy_overrides_are_keyed, a_late_environment_change_cannot_poison_a_fresh_process, env-knob ratchetYes: revert mutant fails both
R1-2 geometry features not in build identity282113acbuild_features_list_every_cargo_feature; cross-build (csg_manifold_gate / csg_topology_gate rebuilds miss)Cross-build at the old head still queued
R1-3 eviction unlinked lock files → two exclusive owners39c8a6f5 (256 permanent stripes)eviction_never_replaces_a_lock_a_writer_may_holdYes
R1-4 FIFO at an entry path hangs the load39c8a6f5 (lstat + O_NONBLOCK + handle check)non_regular_files_at_entry_and_lock_paths_never_blockYes (10 s deadline)
R1-5 fingerprint collapsed diagnostic NaNs (JSON)eb8b8214 (raw-bit walk)fingerprint_distinguishes_diagnostic_float_bitsYes
R1-6 0644 entries accepted39c8a6f5 (0o077)private-modes testYes
R1-7 silent read-only miss undocumented82fd43f6 (docs)——
R2-1 A→B→A policy change mid-pass storedc2ed6881 (mutation generation)a_policy_change_undone_mid_pass_is_never_stored (real fixture, hook between products)Yes: Published instead of SkippedPolicyChanged
R2-2 ambient account / cancel / terminal statec2ed6881 (bypass + stop-event guard)ambient_resource_scopes_bypass_the_cache_both_ways, a_stop_during_the_pass_is_never_storedYes, each
R2-3 in-place edit keeps exe metadatac2ed6881 (ctime, no path)an_in_place_edit_with_restored_mtime_changes_the_identityYes
R2-4 env ratchet lexical holes09e71d04 (access-site count per file)every_environment_access_site_is_reviewed—
R2 allocation before size check09ae9bef (preflight, parts)a_certainly_oversized_result_is_refused_before_encodingYes
Found by the mutants: entry open racing a rename gave a spurious miss005d521b (bounded retry)readers_during_replacement_see_whole_generations (failed on Pop)Yes
Thread: description named IFC_LITE_REQUIRE_FIXTURES as excepted32d3c1a3 (description, docs and ratchet list agree; each entry justified)ratchet—
Thread: an explicit per-router local_frame bypasses the keyed fallback32d3c1a3 (not reachable from ResultCache::process; ratchet added)the_cached_pass_never_pins_a_router_frame_policyPinned-frame mutant: fails the ratchet
R3-1 retained wasm clippy: unused re-export0dd543b0 (cfg-gated like the cache)native-adapter RETAINED_CLIPPYFailed at 32d3c1a3; success at 0dd543b0
R3-2 overlapping setters can show an even generation mid-store76f236ab (writer lock across both bumps, unwind-safe)overlapping_writers_never_expose_an_even_generation_mid_store, a_panicking_store_still_closes_the_generationYes: the unserialised-writer mutant fails with "generation went even while a writer was mid-store"
R3-3 worker in a pre-latched terminal stop refuses products without a new stop399df4b9 (per-pass foreign-scope observation)a_worker_with_a_pre_latched_terminal_stop_never_stores_its_degraded_passYes: the reviewer's recipe at the unfixed head stored a 958 B degraded entry; the mutant fails the same way
R3-4 a hit drops scan-refusal reports (core report sink)399df4b9 (never store a pass that reported)passes_that_report_scan_refusals_are_never_replayed_silentlyYes: the unfixed head and the mutant return Hit
CodeRabbit: perf_probe cache flags with a missing value, or orphaned, were silently ignoredc88b0f4bcache_flags_refuse_missing_values_and_orphans (probe unit test)—
CodeRabbit: the Windows LRU refresh had no attribute-write accessc88b0f4b (second handle with FILE_WRITE_ATTRIBUTES)server-binaries dispatch compiles it for x86_64-pc-windows-msvc; no Windows runtime test—
Found by stress runs: a forked child holds copies of the process's flock()ed lock descriptors until its exec, so concurrent spawns caused spurious skipped publishes or removals (5/40 on Pop; never a wrong result)53458284 (bounded ~10 ms lock retry), d67bcee0 (test FIFOs via libc::mkfifo, so the lib test binary never forks)a_lock_held_for_a_moment_does_not_skip_publicationYes: the no-retry mutant gives SkippedConcurrentWriter. Stress after the fix: 0 panics in 100 lib-cache-test runs and 10 integration runs
R4-1 a hit drops binary_textures_refused() (texture refusals)a2c234e0 (SkippedRefusalReported)passes_that_refuse_a_texture_binary_are_never_replayed_silentlyYes: the reviewer's recipe returns Hit at the unfixed head (d67bcee0 + test); the mutant returns Hit too
R4-2 Windows refresh reopened an unchecked path13c769f6 (refresh through the validated read handle; reparse points opened as themselves)the_lru_refresh_never_follows_a_swapped_path (Unix contract)Windows only. The Windows server-binaries build compiled it (run 42899485359); no Windows runtime test
R4-3 inventory omissionsd4cbe090 (config rows, counter sweep, assumptions table)——

Notes on the round-2 questions:

  • Thread count stays in the key. No mesh output is known to depend on it. Keying it only costs hits between differently sized pools. Point-cache counters do vary with scheduling and are documented as producer statistics, like timings.
  • Crash consistency. The file is fsynced before the rename (no torn entries). The directory fsync is best effort; a lost entry is a later miss.
  • Engine identity for future phases. The executable metadata identifies the binary that statically links the engine. FFI and Python consumers need an identity embedded in the engine library, and that is a stated prerequisite for those phases. A content hash of the executable was rejected for phase 1: it would add SHA over 30–60 MB to every fresh-process hit.

Inputs and channels: complete inventory

This table lists everything that can change what ResultCache::process returns, or what a caller observes, and how each item is handled. A hit must be indistinguishable from the live run on every channel listed as replayed or keyed. Tests are in rust/processing/tests/ unless marked (unit).

Inputs

InputKindHandlingPinned by
Source bytes (all of them) + lengthrequestKeyed (SHA-256, never sampled)every_output_affecting_input_misses (mid-file digit, appended byte)
opening_filter, skip_voids, quality, layer_slicing, batching.{initial,throughput,fast_first}, features.{properties,presentation_layers,quick_metadata_bootstrap,finishes}, instancingrequestKeyed (explicit tags)every_output_affecting_input_misses (15 variants)
entity_ids (None / Some(empty) / Some(set))requestKeyed (sorted; None ≠ empty)same test (None vs Some(empty), copied-entry identity mismatch)
retain_meshes == false, entity_index, cancelrequestIneligible (Bypass)off_and_bypassed_requests_do_no_cache_work_and_match_the_pipeline
A new ProcessingRequest fieldrequestCompile error until classified (exhaustive destructure)compiler
13 IFC_LITE_* / IFCLITE_* output knobs (rect fast and param, local frame, void union / 2D / prism, dedup extra, half-space cap, fast-cut ratio, CSG op and element budgets, alt triangulator, degenerate backstop)env, read onceKeyed through the effective policy accessors, never by re-reading envan_output_affecting_environment_knob_misses_in_a_fresh_process, a_late_environment_change_cannot_poison_a_fresh_process, every_environment_knob_is_classified_for_the_result_cache
A new environment read anywhere in core, geometry or processingenvRatchet (access sites counted per file)every_environment_access_site_is_reviewed
IFC_LITE_CACHE_DIRenvOutput-neutral (location only)ratchet NOT_OUTPUT
HOME, XDG_CACHE_HOME, LOCALAPPDATAenvOutput-neutral: they only choose the default directory (default_directory), never read by the pipelineby inspection (the pipeline's env sites are ratchet-listed)
Config mode, directory, max_bytes, max_entry_bytes, min_free_bytescache configChange only the cache outcome and work (hit, miss, bypass, skip, eviction), never the returned resultoff_and_bypassed_requests_do_no_cache_work_and_match_the_pipeline, damaged_entries_on_disk_miss_warn_and_are_repaired (oversized), a_certainly_oversized_result_is_refused_before_encoding, eviction_removes_least_recently_used_first (unit)
Config engine_salt (doc-hidden test hook)cache configKeyedevery_output_affecting_input_misses (salt)
Config pass_hook (doc-hidden test hook)cache configLive passes only: called after each live batch, never on a hit. Not a supported API; the one exception to "takes no sink"a_policy_change_undone_mid_pass_is_never_stored
IFC_LITE_ENGINE_BUILD_DIGESTcompile-time env!Keyed (it is the build digest)ratchet NOT_OUTPUT
Setters local_frame_set_enabled_override, rect_fast::param_set_enabled_override, set_build_dedup_extra_override, budget::set_cap, set_element_cap, set_alt_triangulatorprocess globalKeyed (effective policy)effective_policy_overrides_are_keyed
A setter while a pass runs or a hit is read (incl. A→B→A, overlapping writers)process globalIneligible (serialised seqlock generation)a_policy_change_undone_mid_pass_is_never_stored, overlapping_writers_never_expose_an_even_generation_mid_store (unit), a_panicking_store_still_closes_the_generation (unit)
Explicit router local_framerouter configNot reachable from the cached path (every router is RouterConfig::default() + keyed fields)the_cached_pass_never_pins_a_router_frame_policy
Rayon worker countexecutionKeyed (conservative; no mesh dependence known)— (phase 2 drops it after a pool-size matrix)
Caller-thread ExecutionAccount / source stop / terminal / owned observerthread-localIneligible (Bypass(AmbientResourceScope)), both waysambient_resource_scopes_bypass_the_cache_both_ways
A job of the pass on a worker carrying foreign resource state (stolen job, pre-latched terminal stop)thread-local, workerIneligible (decided per pass)a_worker_with_a_pre_latched_terminal_stop_never_stores_its_degraded_pass
Any resource::stop anywhere during the passprocess globalIneligible (second net)a_stop_during_the_pass_is_never_stored
analytic::with_source_capturethread-localOutput-neutral for ProcessingResultsource_capture_and_the_progress_hook_are_output_neutral
Kernel, core and processing source; Cargo.lock; rustc; target, profile, flags, target features; processing featuresbuildKeyed (build.rs digest, all three src trees watched)cross-build qualification (gated rebuilds miss); revert mutants
Geometry resolved featuresbuildKeyed (output_policy::BUILD_FEATURES)build_features_list_every_cargo_feature (unit), cross-build
Running executable file (size, mtime, ctime, device, inode; no path)buildKeyedan_in_place_edit_with_restored_mtime_changes_the_identity (unit)
Entry format versionbuildKeyed; other versions → Miss(Unsupported)identity_and_version_mismatches_are_named (unit)

Output channels

ChannelHandlingPinned by
Every ProcessingResult field: meshes incl. serde-skipped fields, textures and sharing, instances, frame, transforms, metadata, stats, diagnosticsReplayed bit for bit. from_cache is set to true; *_time_ms and point-cache counters are the producer's valuesround_trip_preserves_every_field_bits_and_texture_sharing, fingerprint_sees_every_field, fingerprint_distinguishes_diagnostic_float_bits (unit); corpus and heavy fresh-process equality
ProcessingSink eventsNot offered: the cached entry point takes no sinkby construction
Core scan report sink (set_report_sink: refused ids, malformed file)Ineligible: a pass that emits one is never stored (SkippedRefusalReported), so every call keeps delivering itpasses_that_report_scan_refusals_are_never_replayed_silently
ifc_lite_geometry::binary_textures_refused(): embedded texture binaries refused because they do not decode exactly (D18, #7778)Ineligible: a pass that refuses one is never stored (SkippedRefusalReported), so every call counts itpasses_that_refuse_a_texture_binary_are_never_replayed_silently
progress::set_hook heartbeatOutput-neutral liveness signal; a hit does no work and makes no tickssource_capture_and_the_progress_hook_are_output_neutral
tracing events (e.g. the CSG failure summary)Not replayed: diagnostics, not API. Their content is in the replayed stats and diagnostics; a hit logs the cache's own eventsdocumented
Work measurements of the call that did the work: take_cdt_recovery_fallbacks, take_plane_weld_stats, take_prism_stats / take_prism_defers, take_bool2d_stats, rect-param fires, kernel::budget::peak / element_peak / reset_peak, take_csg_census, csg_capture, opening traces, phase-markersNot replayed: they count work this call performed, and a hit performs none, so zero is the truthful reading. Its result is the producer's output whichever path the producer took (CDT or ear-clip and so on). These are diagnostics read by tools (perf_probe --census, calibration), not refusal reportsdocumented; sweep below
Process-wide observations output_policy::policy_generation, resource::stop_events, ifc_lite_core::scan_report_eventsGuards: the cache reads them around a pass. A hit advances none of them, because it performs no setter, stop or scanthe guard tests above
Router- and decoder-owned refusal accessors (take_csg_failures, refused_records, take_classification_stats, ...)Replayed through the result: the pass drains them into ProcessingStats and GeometryDiagnostics (for example refused_input_elements, refused_prepass_records, failure breakdowns). A host never holds the pass's router or decoderfingerprint_sees_every_field (unit); corpus equality
CacheReport (outcome, work, warnings)New channel, current call onlyintegration tests

Sweep for host-readable refusal and diagnostic accessors (pub fn names matching refus / skip / drop / degrad / fail / reject / fallback / census / capped / stats / peak / recover across core, geometry and processing):

  • Process-global ones a host can read after a load: binary_textures_refused is a refusal (row above). All the others are in the work-measurement row.
  • Object-scoped ones (decoder, router, processors): drained into the result by the pass.
  • Mesh-editing helpers (drop_degenerate_triangles, ...): not accessors.
  • take_pending_mapped_bool_failures: has no producer today; a router drains it into the result.

Assumptions (stated, not enforced)

AssumptionStatus
Floating-point environment: default rounding, no FTZ/DAZ, default MXCSR/FPCR on the calling thread and on every rayon workerAssumed, not enforced. Compiler flags and target features are keyed; a thread's mutable FP control register is not. Core, geometry and processing never read or set it. Phase 1 requires the default Rust FP environment. Before FFI, the host contract must normalise and restore it, or test it.
Runtime CPU dispatchNone in core, geometry or processing (no is_x86_feature_detected / std::arch); compile-time target features are keyed. sha2 detects SHA-NI at runtime only to hash, with identical output.
Allocator choice, allocation failureThe allocator (system or mimalloc) does not change output. Allocation failure aborts, as for the uncached pipeline; it is not a cache miss.
Hash seeds, scheduling, address orderResults use ordered, indexed collections. The cache guarantees replay equals its producer, byte for byte, not that two independent cold runs are identical. Point-cache counters and timings are scheduling- and clock-dependent producer values.
Wall clockOnly in *_time_ms, which are replayed as producer metadata.
Filesystem errors, permissions, locks, free spaceChange the cache outcome only: fail open to the live result, with a warning. Covered by the store tests (modes, symlinks, FIFO, oversized, eviction, lock races).
Immutable schema and type tables (OnceLock)Source-derived constants, covered by the build digest.
Owner, document, load and block id countersIdentify execution scopes, not output.
Memo, scratch and budget thread-locals (weld, orient, placement and point caches, per-op and per-element budgets, incidence work)Reset per operation or element, or pure memoisation of deterministic values.
External referencesImage textures are returned as URLs and never read. No locale, schema or other file is read by the pass besides the source bytes. Host-side texture resolution is outside this cache.
Analytic source capture, progress hookProven output-neutral on one fixture (row above). The hook contract is a pure liveness heartbeat. A hook that changes policy is caught by the generation guard; one that panics prevents storage.

Test matrix

AcceptanceEvidence
1 Exact equality, fresh processesIn-repo corpus (13 processing fixtures, 7 mapped_instances_* with instancing, hello-wall, the annex_e texture set) and the four heavy fixtures × {full, instancing}. Warm equals cold bit for bit, timings included, with the raw-bit fingerprint (Pop, 608dc405).
2 InvalidationMid-file digit, appended byte, 15 request variants, None vs Some(empty), engine salt, 6 policy setters, the late-environment case, IFC_LITE_RECT_FAST in a fresh process, an entry copied under another key, gated rebuilds
3 Hostile entriesTruncation at every byte, every byte flipped three ways, overflowing counts after re-sealing, overlap / gap / reorder, dangling references, 4,000 re-sealed mutations, oversized entries, on-disk damage repaired, FIFO / directory / socket / device / symlink
4 ConcurrencyTwo writer processes, 8 racing writer threads, readers during 60 replacements, crash temp swept, generation-checked removal, the paused-writer lock schedule, mid-pass policy and stop guards
5 Off / missOff hashes nothing and creates no directory; output equals process(); bypasses hash nothing
6 BuildWorkspace clippy, cargo test -p ifc-lite-processing, wasm32 and --no-default-features checks: At 399df4b9 (fleet): workspace clippy, wasm32 clippy for ifc-lite-wasm and --no-default-features --all-targets clippy all pass with -D warnings; cargo test -p ifc-lite-processing exits 0 (157 test binaries ok) and the heavy-fixture equality gate passes. native-adapter is green at 0dd543b0 (RETAINED_CLIPPY=success)

Exact-head validation (receipts)

On pull requests, CI's Rust tests job runs clippy only: the test and doctest steps are skipped (lane != fast), and tests run in the merge queue. An earlier revision of this description cited that job as test evidence; that was wrong. The evidence below is fleet receipts on the final merged head 95e74a20 (main 6aefb783 merged in; #9635 / #9636 included):

CheckResultReceipt
cargo clippy --workspace --all-targets -D warnings; wasm32 clippy for ifc-lite-wasm and processing --lib; --no-default-features --all-targets clippyall exit 0Pop job d46396e9
cargo test -p ifc-lite-core / -p ifc-lite-geometry / -p ifc-lite-processing23 / 182 / 158 test binaries ok, 0 failedPop job d46396e9
Heavy-fixture equality gate (release, fresh processes: FZK, advanced_model, schependomlaan, ISSUE_129 × full / instancing)passPop job d46396e9
Stress: lib result_cache × 50, the six cache integration binaries × 100 failuresPop job d46396e9
native-adapter (all 17 lanes incl. RETAINED_CLIPPY)successrun 42906303935
Required checks (Build + WASM + Rust + Node, Issue queue, PR review signal, parity, CLA)passGitHub

Cache-off cost (instruction counts, not timing)

scripts/perf/instructions.sh (callgrind, single thread, perf_probe with no --result-cache) on Pop, main 6aefb783 vs merged head 95e74a20. Meshes and triangles are identical.

FixtureTotal IrGeometry IrProcess Ir
AC20-FZK-Haus−0.0007%+0.0025%+0.0275%
advanced_model+0.0298%+0.0325%+0.0177%

The same comparison before the merge (PR base 004934fa vs d4cbe090) read +0.097% total and +0.111% process on advanced_model. Against the current base it is about a third of that, consistent with code-layout variance rather than per-job work.

Untimed warm-hit work breakdown (perf_probe)

perf_probe <f> --cold --iters 1 --result-cache DIR --expect-cache hit --result-fingerprint --json, run in a fresh process after a cold run (Pop, 608dc405). The byte counts are exact; this is not benchmark evidence and no wall times are claimed.

FixtureSource bytes hashedEntry bytes read and checksummedSection bytes decodedEntry / source
AC20-FZK-Haus2,526,5111,304,1171,303,6610.52
advanced_model35,309,93789,396,56689,396,1102.53
schependomlaan49,286,96716,733,02116,732,5650.34
ISSUE_12912,030,6847,421,9907,421,5340.62

On every fixture the cold and warm complete-result fingerprints are equal. advanced_model's entry is 2.5× its source; that is the case for optional per-section compression in a later phase, which the scoreboard should time.

Perf verdict

The cache-off path is the existing pipeline: process() is unchanged and off mode never reaches the cache, so cold numbers do not move. A hit replaces the pass with O(source) SHA-256 + O(entry) read and checksum + O(output) decode. Timed A/B against cold is left to the hillclimb scoreboard (exclusive Pop benchmark admission).

What is not verified

  • Timed warm-vs-cold numbers.
  • arm64 and macOS runs (Windows compiles with weaker symlink handling; not run). NFS and overlay filesystems, power-cut injection, a foreign-uid entry and multi-GB results.
  • A fresh-process thread-count matrix.
  • Uncached passes: a concurrent policy setter can still mix policies inside a live pass. The cache only refuses to store or replay such a pass.
  • Shared-library consumers need an embedded engine identity before phase 2.
  • The ci:native-adapter lane.
  • The viewer and TS gates skipped by pre-handoff (no TS changes).

Ledger entry

The scripts/perf/README.md ledger entry for this PR is in the consolidated ledger PR #9673 (commit 62350633). This PR no longer touches that file, so it cannot conflict there in the queue.

Remaining phases

  1. The prepared-source tier: index and discovery, for faster misses.
  2. FFI and Python: versioned config entry points; Python hashes with the GIL released.
  3. Server layering under the existing HTTP cache, with the engine identity propagated into its keys.
  4. CLI flags where a native backend runs.
  5. Replayable sink events for streaming consumers.
  6. Relaxing the engine key to explicit revisions once cross-architecture determinism evidence exists.

Size

About 5.5k lines, roughly 2.3k of them tests. That is above the ~1.5k stacking guideline. Kept as one PR because the codec, store and acceptance tests only make sense together; I can split it into codec / store / API + probe if review prefers.

🤖 Generated with Claude Code