parseUsageFromA2AResponse:
- Empty/malformed inputs (nil, empty, non-JSON, null result, string result)
- JSON-RPC result.usage shape (happy path)
- Top-level usage fallback
- result.usage takes precedence when both present
- Zero usage → treated as absent (ok=false)
readUsageMap:
- Happy path with both tokens
- Missing usage key
- Zero values → ok=false
- Only input_tokens set → ok=true
- Only output_tokens set → ok=true
- Malformed usage JSON → ok=false
Pure function tests using real JSON — no DB or HTTP mocking required.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Covers:
- Positive integers (including large TTLs like 3600s)
- Zero value
- Negative → collapses to 0
- Missing / absent expires_in_seconds
- No params at all
- Malformed JSON
- Empty body
- Type mismatches: null, string, float → 0
Part of ongoing pure-function test coverage for the A2A queue layer.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>