Durable History compaction.
Pixir keeps the full Log as source of truth, but the Provider does not need every
old Event on every Turn. Compaction records a canonical history_compaction Event
that summarizes an older prefix and leaves a recent tail uncompressed. Provider
replay then sends the latest checkpoint plus the tail, so context stays bounded
while resume/fork/debug still read the original Log.
Summary
Functions
Append a durable history_compaction checkpoint when there is compactable History.
Default tail size used for recovery/preflight compactions.
Developer instruction for a future model-assisted compaction pass.
Plan compaction without appending anything to the Log.
The to_seq of the latest compaction checkpoint in history, or nil when the
Session has never been compacted. Keys context-pressure warning hysteresis
(ADR 0020): a new checkpoint re-arms the warning gate.
Build the instruction, schema, and delimited user payload for model-assisted compaction. This does not call the network and does not mutate the Log.
JSON schema for a model-assisted compaction checkpoint.
Build the deterministic compaction plan for a Session.
Return the Provider-visible History: latest compaction checkpoint plus uncompressed events after its range. Sessions without compaction pass through unchanged.
Render compaction data as a Provider input item.
Functions
Append a durable history_compaction checkpoint when there is compactable History.
@spec default_tail_events() :: {:ok, pos_integer()}
Default tail size used for recovery/preflight compactions.
@spec developer_instruction() :: String.t()
Developer instruction for a future model-assisted compaction pass.
Keep this short and contract-like. Detailed shape belongs in output_schema/0, and
actual Session facts belong in the per-call input payload.
Plan compaction without appending anything to the Log.
@spec latest_checkpoint_to_seq([Pixir.Event.t()]) :: non_neg_integer() | nil
The to_seq of the latest compaction checkpoint in history, or nil when the
Session has never been compacted. Keys context-pressure warning hysteresis
(ADR 0020): a new checkpoint re-arms the warning gate.
@spec model_contract(String.t(), [Pixir.Event.t()], keyword()) :: {:ok, map()} | {:error, map()}
Build the instruction, schema, and delimited user payload for model-assisted compaction. This does not call the network and does not mutate the Log.
@spec output_schema() :: map()
JSON schema for a model-assisted compaction checkpoint.
This intentionally lives in code instead of prompt prose so the Provider path can enforce the shape with structured outputs when model-assisted compaction is enabled.
Build the deterministic compaction plan for a Session.
@spec provider_history([Pixir.Event.t()]) :: [Pixir.Event.t()]
Return the Provider-visible History: latest compaction checkpoint plus uncompressed events after its range. Sessions without compaction pass through unchanged.
Render compaction data as a Provider input item.