Store, validate, and inspect history_compaction.data.native_replay (ADR 0040).
Slice C persists a live /responses/compact output as standalone_window.
Slice D persists a live stream cmp_ as threshold_item and shares the same
overlay preference, late-bound after Provider/backend resolve. Overlay on
chatgpt_codex enables D only; standalone C stays local on that 404 host.
Summary
Functions
Capturing identity map used to persist and fold a native window.
Stable fallback_reason tokens (ADR 0040 Decision 2).
Fold-usable predicate for Provider replay.
Bounded inspect projection: mode, usability, item ids, fallback reason.
Accepted native_replay.mode values.
Overlay bit after Provider/backend resolve (ADR 0022 late-bound pattern).
Attach a standalone_window native replay from a compact output list.
Persist a live threshold_item capture without failing the local checkpoint.
Attach a threshold_item native replay window to local checkpoint data.
Replace a checkpoint's native_replay with the inspect projection and drop
any encrypted_content keys. Used by CLI --json and diagnostics.
Sanitize a compact/complete result so JSON never prints ciphertext.
Validate a native_replay map for either persist mode.
Functions
Capturing identity map used to persist and fold a native window.
@spec fallback_reasons() :: [String.t()]
Stable fallback_reason tokens (ADR 0040 Decision 2).
Fold-usable predicate for Provider replay.
Returns true when native_replay is present, recorded_usable, still
validates, and current Provider/backend/dialect/model match the capturing
values. Anthropic fold never consults this predicate.
Bounded inspect projection: mode, usability, item ids, fallback reason.
Never includes items or encrypted_content. Accepts either checkpoint
data or a native_replay map. Returns nil when no native replay is present.
@spec modes() :: [String.t()]
Accepted native_replay.mode values.
Overlay bit after Provider/backend resolve (ADR 0022 late-bound pattern).
preference is nil (no preference), true (request on), or false
(explicit off). identity carries string provider, backend,
dialect, and optional responses_host from the resolved request.
Overlay on is not standalone C. chatgpt_codex enables D
(compact_threshold). Official api.openai.com enables D and may POST C.
Other open_responses hosts stay local.
Attach a standalone_window native replay from a compact output list.
Persists the entire output array. Reducing that list to cmp_ alone is
standalone_window_pruned. Local text checkpoint fields remain mandatory.
Persist a live threshold_item capture without failing the local checkpoint.
Usable singleton cmp_ items are stored as today. Missing, malformed, or
forced-fallback captures still return local text plus recorded_usable false.
Attach a threshold_item native replay window to local checkpoint data.
item_or_items must be exactly the latest compaction item (type compaction,
id matching cmp_…). A full compact output list is rejected as
threshold_item_not_singleton — this helper never drops retained items to
invent a singleton.
Local text checkpoint fields remain mandatory on the same Event. This does not call the Provider and does not change live Turn ingest.
Replace a checkpoint's native_replay with the inspect projection and drop
any encrypted_content keys. Used by CLI --json and diagnostics.
Sanitize a compact/complete result so JSON never prints ciphertext.
Validate a native_replay map for either persist mode.
Returns {:ok, normalized} with recorded_usable set. Unusable windows keep
the payload and set fallback_reason. Completely unparseable input returns
{:error, structured}.
Pass compact_output: when validating standalone_window so a reduced
items list (save-only-cmp_) is standalone_window_pruned.