mirror of
https://github.com/teamchong/pxpipe.git
synced 2026-07-22 02:02:51 +02:00
a197f8729d
Adds isCompressionProfitableAmortized() and a new historyAmortizationHorizon option (default 1 = current per-turn behaviour). When the host opts in to horizon ≥ 2, the history-collapse gate evaluates expected lifetime cost over N future turns instead of the cold per-turn comparison: I × (CC + CR×(N-1)) < T × CR × N where CC = 1.25 (cache_create), CR = 0.10 (cache_read) At N=5 this accepts collapses with I/T < 0.30; at N=10 with I/T < 0.47. The worst-case-for-image / best-case-for-text framing is on purpose — we only collapse when the math wins under pessimistic warm-cache assumptions, so a single-turn session can never pay a tax. This is the 'try-then-decide-with-bounded-horizon' design from the README's new 'unsolved part: multi-turn amortization' section. Picked over JIT-style session state (rejected: introduces durable state), always-collapse (rejected: dishonest per-request), and cache-bust-driven (rejected: signal arrives one turn late). - New option threaded through DEFAULTS, TransformOptions, PixelpipeOptions - Both history call sites (early-exit helper + main success path) use the amortized gate when horizon > 1, fall back to the cold gate otherwise - 4 new unit tests covering fallback, accept-on-long-history, reject-on- tiny-text, and the subset-relationship between cold and amortized gates - 298 tests pass