Token counting, the compaction trigger and the masking schedule lived in Agent's private fields plus mask.rs, compact.rs, stats.rs and the TUI. Move them behind one module with view/record/reset/tokens, so the reset-together invariant and the mask-boundary rule have one owner. - Agent holds a ContextWindow instead of compact_at/ctx/mask_boundary - TUI shows Agent::context_tokens() (real reading + estimate), matching the compaction trigger instead of the bytes/4 guess - stats replay goes through ContextWindow::masked - ContextMeter/estimate_tokens move into the module; mask is crate-private - tests at the ContextWindow interface replace the meter unit test