d0e95f23b0
The `message_threshold` field on `CompactionConfig` was a 128K-era heuristic that fired compaction on long sessions of small messages — exactly the case where rewriting V4's prefix cache is most wasteful. Token budget is the only signal that maps to actual model context pressure; counting messages adds nothing. Changes: * Remove `CompactionConfig::message_threshold` field. * Remove the message-count branch in `should_compact` — token threshold + 500K floor is now the sole compaction trigger. * Remove `compaction_message_threshold_for_model`, `DEFAULT_COMPACTION_MESSAGE_THRESHOLD`, `COMPACTION_MESSAGE_DIVISOR`, `MAX_COMPACTION_MESSAGE_THRESHOLD` from `models.rs`. * Drop the `forced_config.message_threshold` tweak in the engine's capacity-guardrail forced-compaction path; that path now also bypasses the floor (`auto_floor_tokens = 0`) because we're at a hard ceiling and have to free budget regardless of cache cost. * Update production constructors (`main.rs`, `runtime_threads.rs`, `app.rs::compaction_config`) to drop the field. * Update tests: keep the floor + token-threshold assertions, delete the two tests that specifically validated message-count triggering, replace `should_compact_respects_message_threshold` with `message_count_no_longer_triggers_compaction` pinning the new contract. Verified locally: * `cargo fmt --all -- --check` clean. * `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` clean. * `cargo test --workspace --all-features --locked` — 2036 passed in TUI bin (2 ignored), all other crates green. * parity gates: snapshot, parity_protocol, parity_state — all pass. * `git diff --exit-code -- Cargo.lock` — clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>