Runtime core¶
The runtime layer runs coalition evaluations: archive, dedup registry, hot store, scheduler, failures and progress.
Run archive¶
RunArchive writes one
CoalitionRecord (packed mask, timing, cache-hit flag) per
coalition to archive.sqlite with the text beside it;
history_lazy() streams rows lazily. The
directory also holds manifest.json (RunManifest) and the base
generation; reanalyze rescores the stored generations.
open() refuses an existing archive unless
on_exists is "overwrite"; load() checks
the schema version.
Coalition deduplication¶
build_coalition_key() hashes snapshot id, player order,
packed mask, absence policy, model id and generation settings with SHA-256, plus the
draw index, non-default policy options and, when set, the backend’s processor_kwargs.
CoalitionDedupRegistry tracks keys already run;
dedup_enabled() resolves the dedup mode (auto follows
temperature == 0).
Hot store¶
HotResultStore, an LRU from coalition key to text, holds
a run’s outputs until scored. Capacity \(2^n\) prevents early eviction; memory grows
with coalitions evaluated. The base generation seeds the grand coalition.
Scheduling¶
InferenceScheduler checks the hot store, then the dedup
registry, then takes a max_inflight slot and calls the backend.
SchedulerMetrics counts requested, executed,
deduplicated, cache_hits and kv_cache_hits. exact on “Cancel my old phone
plan today” (mock backend) reports 64 requested, 63 executed and 1 cache hit (the grand
coalition).
Failure semantics¶
The first backend exception ends the run. The scheduler cancels pending jobs, collects simultaneous failures (none is reported as “never retrieved”) and re-raises the first. No metrics or attributions come back; the archive keeps completed outputs.
Progress callbacks¶
A CoalitionProgress passed to
InferenceScheduler or ExplainRunner
gets synchronous on_coalitions_planned and on_coalition_finished calls. The default,
NullCoalitionProgress, costs almost nothing.
See also¶
Runtime core: usage examples
How a run works: the stages of a run
Runtime: module reference
Configuration:
archive,dedupandmax_inflightsettingsHow a run works in the knowledge vault