`src/compact/types.rs` — compaction outcome types
The data shapes that flow between manager, compactor, and driver.
Key items
CompactionOutcome { messages, tokens_after, tokens_saved, success, error }+ constructorsno_change,compacted(before, after)+ staticestimate_tokens(heuristic hint).EnsureContextResult { Compacted(outcome), NoAction(messages) }+into_messages().ContextOverflow { tokens_used, context_window, message_count, trigger, compactor_error }+overflow(),utilization()(infinity for a zero window).CompactReason { ThresholdExceeded, Emergency, Manual }.CompactionContext { tokens_before, reason, context_window, turn, counter, instructions, additional_context }— everything a custom compactor needs.CompactTelemetry+PreCompactStats/PostCompactStats— the observer payload.
Behavior notes
- A compactor’s
tokens_after/tokens_savedare self-reports — the manager re-counts and overwrites; fill them usingctx.counterso they at least match the unit. CompactReason::Emergencyreaching hooks maps toCompactTrigger::Auto;ManualstaysManual.ContextOverflowis terminal: the driver maps it toLoopError::ContextExceeded.
Deep dive: Compaction.