fn append_capped_tail(buf: &mut Vec<u8>, chunk: &[u8], cap: usize)Expand description
Append chunk to a rolling tail buffer, compacting to the last
cap bytes whenever it grows past 2 * cap (amortized O(1)). The
exact final trim happens at EOF via trim_to_tail. Keeping the
tail (not a prefix) matters because the CLI’s terminal error line
is at the end of stderr.