compact-budget-tracking-is-efficient-and-approximate
IN derived (depth 1)
The compact module tracks token budgets efficiently through an approximate but computationally fast strategy: O(1) per-line budget checks via a running character count, with token estimation based on chars/4 — a lightweight approximation avoiding external tokenizer dependencies while maintaining accuracy sufficient for budget enforcement.
Summary
The compaction system keeps track of how many tokens it has used by counting characters as it goes, dividing by four to estimate tokens. This avoids needing a real tokenizer while still being fast enough and accurate enough to stay within budget limits during summarization.
Justifications
SL — Grouping the two implementation choices that define compact's budget tracking strategy — deliberate trade of precision for efficiency
Antecedents (all must be IN):
- compact-char-tracking-o1 — Budget tracking uses a running `_char_count` integer, making per-line budget checks O(1) instead of O(n).
- compact-estimate-tokens-chars-div-4 — `estimate_tokens` uses `len(text) // 4` with a floor of 1, not word count or any external tokenizer.
Dependents
These beliefs depend on this one:
- budget-enforcement-is-efficient-across-pipeline — All budget-constrained operations — compact output distillation and derive belief allocation — achieve computationally efficient tracking with representation-safe minimum bounds, ensuring budget enforcement never becomes a performance bottleneck.
- compact-is-efficient-deterministic-and-bounded — The compact module simultaneously achieves computational efficiency (O(1) per-line budget tracking via running character count with chars/4 token estimation), mathematical determinism (pure function with no side effects), and guaranteed output bounds (never exceeds the budget parameter) — all three desirable output properties without trade-offs.