Files
buzz/crates
npub1g8493u0xfsjrvflg4n08ezd7vec99mnwzlv0qgwpr9d7gvjwhuzqx59rhwandWill Pfleger 74d78b5fe9 fix(buzz-acp): seed zero baseline for self-spawned sessions
Every session's first turn was systematically uncounted: the publisher
had no prior cumulative snapshot, so it emitted deltaReliable:false and
null turn.* fields.  For sessions that buzz-acp itself created via
session/new, prior usage is zero by definition — the zero baseline IS
the correct starting point.

Add UsageTracker::seed_zero_baseline(), called from pool.rs immediately
after create_session_and_apply_model() succeeds (both channel and
heartbeat paths).  The zero baseline seeds SessionState with
last_input/output=0 and last_cost=Some(0.0), so the first
usage_update notification computes turn.*=cumulative.* and emits
deltaReliable:true.

The re-attach path (session ID already in agent.state.sessions) is
unchanged: buzz-acp did not create that session and its prior usage is
genuinely unknown, so the existing fail-closed behavior is correct.

seed_zero_baseline() is a no-op if a baseline already exists, guarding
against accidental double-seeding across session rotation.

Regression tests added (a)-(d) per task spec:
(a) self-spawned first turn: deltaReliable=true, turn.*==cumulative.*
(b) re-attach first turn: unchanged fail-closed behavior
(c) second turn unaffected in both modes
(d) wire-frame payload field assertions for the spawned path

Gates at tip: cargo test -p buzz-acp 645/645, cargo fmt --check clean,
cargo clippy -p buzz-acp --all-targets -- -D warnings clean.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
2026-07-30 13:10:17 -04:00
..
2026-07-27 14:18:24 -04:00