Commit 0124f68
fix(agent): extend checked/unknown treatment to input/output token accumulation
input and output token accumulators used saturating_add throughout,
while the PR's own total and cache counters already used checked_add
with Unknown/Poisoned poison semantics (flagged by Wes's agent review).
Introduce TurnIOState (Unseen | Exact(n) | Poisoned) in types.rs:
- fold_round(n): overflow -> Poisoned, absence handled by caller
- merge_session(turn): Poisoned poisons permanently; Exact checked-add
- exact_value(): Some(n) only for Exact
Wire changes:
- accumulatedInputTokens / accumulatedOutputTokens: emitted only when
Exact; omitted (never null, never u64::MAX) when Poisoned
- used: saturating fallback to 0 for display-only proxy (ACP dead code)
ACP changes:
- UsageUpdatePayload.accumulated_{input,output}_tokens: Option<u64>
with #[serde(default)] for backward compat; None = publisher-poisoned
- absent field -> delta_reliable: false, null turn fields, null cumulative
- SessionState.last_{input,output}: Option<u64> to match provenance
- TurnUsage.cumulative_{input,output}_tokens: Option<u64>
- pool.rs: pass through directly (TokenCounts fields already Option<u64>)
- Box<UsageUpdatePayload> in GooseSessionUpdateVariant to satisfy
clippy::large_enum_variant after struct grew with new doc+Option fields
Tests added (426+686 pass):
- TurnIOState unit tests: fold overflow, merge_session overflow, exact_value
- wire: omit input/output when poisoned; emit when exact
- ACP: absent input/output -> unreliable; goose payload unchanged;
round-trip: poison mid-session -> subsequent turns stay unknown
Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>1 parent ec9115d commit 0124f68
8 files changed
Lines changed: 836 additions & 147 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1860 | 1860 | | |
1861 | 1861 | | |
1862 | 1862 | | |
1863 | | - | |
1864 | | - | |
| 1863 | + | |
| 1864 | + | |
1865 | 1865 | | |
1866 | 1866 | | |
1867 | 1867 | | |
| |||
4353 | 4353 | | |
4354 | 4354 | | |
4355 | 4355 | | |
4356 | | - | |
4357 | | - | |
| 4356 | + | |
| 4357 | + | |
4358 | 4358 | | |
4359 | 4359 | | |
4360 | 4360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3698 | 3698 | | |
3699 | 3699 | | |
3700 | 3700 | | |
3701 | | - | |
3702 | | - | |
| 3701 | + | |
| 3702 | + | |
3703 | 3703 | | |
3704 | 3704 | | |
3705 | 3705 | | |
| |||
6168 | 6168 | | |
6169 | 6169 | | |
6170 | 6170 | | |
6171 | | - | |
6172 | | - | |
| 6171 | + | |
| 6172 | + | |
6173 | 6173 | | |
6174 | 6174 | | |
6175 | 6175 | | |
| |||
6207 | 6207 | | |
6208 | 6208 | | |
6209 | 6209 | | |
6210 | | - | |
6211 | | - | |
| 6210 | + | |
| 6211 | + | |
6212 | 6212 | | |
6213 | 6213 | | |
6214 | 6214 | | |
| |||
6247 | 6247 | | |
6248 | 6248 | | |
6249 | 6249 | | |
6250 | | - | |
6251 | | - | |
| 6250 | + | |
| 6251 | + | |
6252 | 6252 | | |
6253 | 6253 | | |
6254 | 6254 | | |
| |||
6287 | 6287 | | |
6288 | 6288 | | |
6289 | 6289 | | |
6290 | | - | |
6291 | | - | |
| 6290 | + | |
| 6291 | + | |
6292 | 6292 | | |
6293 | 6293 | | |
6294 | 6294 | | |
| |||
6324 | 6324 | | |
6325 | 6325 | | |
6326 | 6326 | | |
6327 | | - | |
6328 | | - | |
| 6327 | + | |
| 6328 | + | |
6329 | 6329 | | |
6330 | 6330 | | |
6331 | 6331 | | |
| |||
6376 | 6376 | | |
6377 | 6377 | | |
6378 | 6378 | | |
6379 | | - | |
6380 | | - | |
| 6379 | + | |
| 6380 | + | |
6381 | 6381 | | |
6382 | 6382 | | |
6383 | 6383 | | |
| |||
0 commit comments