Skip to content

Asynchronous finite-regime memory (experimental)

from solvi.experimental.regime_memory import RegimeMemory provides an opt-in finite hidden-state filter, without running probes or models. The owner declares stable regime IDs mapped to LawSet IDs, a prior, transition matrix and probe outcome likelihood tables. Probability vector/matrix coordinates always follow lexicographically sorted regime IDs (regime_ids). Each probe table maps outcome IDs to likelihood vectors; its outcome probabilities sum to one separately under every regime.

issue(ticket_id, probe_id) returns a detached ticket at the current discrete step. Obtain the observation externally and call observe(ticket, outcome_id) later. advance() applies one declared transition. A delayed outcome is likelihood evidence at its issue step; log-forward replay propagates it through subsequent transitions. Multiple outcomes at a step are assumed conditionally independent given that step's regime. Out-of-order delivery is supported. This assumes the measurement describes the issue-time regime: if a tool measures at completion, issue at that actual measurement step instead.

weights describes the current finite-family posterior; regime_ids and lawset_ids associate it with owner-managed native LawSets by ID. No LawSet is mutated, installed or automatically reactivated. There is no synchronous probe callback, external execution, unknown-regime discovery, empirical calibration or change alarm. Epoch IDs must be globally unique for the owner's experiment; model_id declares likelihood/transition source identity. Tickets additionally bind the frozen configuration fingerprint. This is a trusted Python API, not authentication against a party forging private state.

Duplicate/unknown/foreign/expired tickets, unknown outcomes and observations impossible under the declared model refuse before changing posterior/tickets. Expiry uses discrete steps (max_delay), not wall time. max_steps bounds the entire lifetime and max_pending bounds pending tickets, with an additional total-ticket bound of their product. Stale pending entries remain burned and consume capacity. At exhaustion start a new explicitly declared epoch; no silent pruning or reset discards delayed evidence. This implementation recomputes bounded history on observation/advance; it does not claim constant-time updates.

snapshot() is detached JSON-compatible state; RegimeMemory.restore(state) strictly validates schema, bounded indices, outcomes and model probabilities, then recomputes the posterior. Save it using owner-managed durable storage. No filesystem writes or shared multiwriter service are provided. A snapshot is trusted owner data, not a signed certificate.

The historical asynchronous regime study (16/60 change alarms, seven recognitions, three false recognitions without returns; return-loss difference +0.64 with interval [-7.5,+8.3]) remains negative. The helper resolves the finite delayed noisy posterior API gap; it does not establish reduced losses, bounded detection delay, calibrated false recognition or superiority over the last-60-observation baseline. Those require a separately registered evaluation, not an automatic detector inferred from this filter.