pub fn aggregate(members: &[SessionStats]) -> SessionStatsExpand description
Sum per-session views into a total (the /usage total row).
Contract:
turns,input_tokens,output_tokens,cache_read_tokens,cache_write_tokens,cache_turns,tool_errors: plain sums.tools: merged BY NAME —calls/errors/result_bytessummed per name — then re-sortedcallsdesc, name asc, so the total reads like a single session.cost:Some(Cost { micro_usd: Σ, unpriced_turns: Σ })when AT LEAST ONE member hasSome;Nonewhen none does. A member withcost: Nonecontributes nothing — its sessions are unknown, not “0 unpriced turns”.last_input_tokens: alwaysNone. A total has no “last request”; the context gauge is a per-surface fact and must never be summed.- empty slice ⇒
SessionStats::default().
Does NOT promise: deduplication. Two members that share a transcript (a peer and its mirror) are counted twice — a caller passes each session once.