Module result_cache

Module result_cache 

Source
Expand description

Native warm-load cache of complete results; off unless a caller opts in. Native warm-load cache of complete processing results (phase 1).

A [ResultCache] wraps process: on a full pass whose source bytes, output-affecting request fields and engine identity match a stored entry, it replays that entry’s exact ProcessingResult (every mesh, instance, frame, transform, metadata field, diagnostic and refusal count, in order, float bits intact) instead of processing. Otherwise it runs the unchanged pipeline and, in [CacheMode::ReadWrite], stores the result. process itself stays pure: callers that never build a cache never reach this module, and [CacheMode::Off] calls straight through without hashing anything.

What it does not do (phase 1): replay sink events (the cached entry point takes no sink, so streaming and callback consumers keep calling process), cache a cancellable pass, trust an injected entity index, or cache the prepared-source tier (index/discovery). A request it cannot replay reports [CacheOutcome::Bypass] and runs live; it never returns a hit with missing outputs.

Trust model: entries live in a per-user private directory (0700/0600, owner-checked, O_NOFOLLOW, digest-only names, see store.rs). Every entry is treated as untrusted input: bounded reads, checked arithmetic, per-section SHA-256 verified before anything is decoded, and any failure is a warning plus a miss and a recompute, never a panic or a partial result. The checksums detect damage, not authorship: a process running as the same user can write a self-consistent entry with wrong geometry, and this cache cannot tell. Environments that need that guarantee need authenticated entries or a separate trusted writer, which phase 1 does not provide.

Keys, layout and store policy: key.rs, envelope.rs, store.rs.

Structs§

CacheReport
CacheWork
The current call’s work. Durations are wall time on this machine; byte counts are exact.
CachedProcessing
A result and what the cache did to produce it.
ResultCache
A reusable cache context. Cheap to build; holds no open files.
ResultCacheConfig
Where and how much. Defaults: off, the platform cache directory, 10 GiB per directory, 1 GiB per entry. The limits are policy choices, not measured optima.

Enums§

BypassReason
CacheMode
What a ResultCache may do. Off unless a caller opts in.
CacheOutcome
How the result was obtained.
MissReason
PublishOutcome
What happened to the live result afterwards.

Functions§

default_directory
The per-user default root: IFC_LITE_CACHE_DIR if set, else $XDG_CACHE_HOME/ifc-lite/native or ~/.cache/ifc-lite/native (Linux and other Unix), ~/Library/Caches/ifc-lite/native (macOS), %LOCALAPPDATA%\ifc-lite\native (Windows).