Repository navigation
Releases
Releases · omeryasirkucuk/context-rollover
v0.2.0 — the deterministic swap
The deterministic swap
The swap no longer contains, waits for, or depends on an LLM. v1's extraction cursor sat inside the swap's safe-point condition — a failing, quota-limited, or slow extraction model deferred swaps indefinitely (extraction_lagging), and behavior visibly differed per model. v2 replaces the whole loop with one deterministic transformation.
Highlights
- Swap = pure function. Decides and freezes from state alone; runs in milliseconds on every model. No model-dependent code path can defer or fail a swap.
- Mechanical projection (
core/projection.ts, new): verbatim user prompts (capped), first lines of assistant replies, touched files from tool parts, then the ledger sections. Ledger records are positionally scoped to the discarded region. Identical inputs render byte-identically. - Optional ledger enrichment (new
ledgerconfig key, defaulttrue;false= swap-only pipeline with zero extra LLM calls). ReplacesextractionGate. Completed records and invalidations refresh the frozen render in place; failures stay invisible. - Honest budgets:
renderTruncatedpersisted on the rollover record, newrender_truncatedmetric,gate_*metrics withdrawn, newledger_enrichedmetric. - Status card names the context counter's source (
usage/estimate);/rollover statusand/rollover showreport the frozen render the model actually receives after a swap. - Concurrency: usage tracking, touched-file notes, extraction commits, and the swap are single critical sections per session; in-lock metrics are fire-and-forget.
Verification
- 279 tests / 0 fail; live smoke against the fork-built binary: with extraction scripted to fail on every call, the swap still fired in 4 ms with a 5793 → 170 token reduction.
- Full change description in the README changelog and
docs/2026-11-19-deterministic-swap-design.md.
Install / update: opencode plugin add context-rollover (or opencode plugin update context-rollover).