Skip to content

v0.8.1 — Cost & Budget Safety Audit

Choose a tag to compare

@lacrous lacrous released this 23 Aug 08:30
· 7 commits to main since this release

v0.8.1 — Cost & Budget Safety Audit

🐛 Bugs Found & Fixed

Bug Severity Fix
estimateCost() produced negative cost with negative token counts MEDIUM Added Math.max(0, ...) guard
BudgetTracker callbacks not wrapped in try/catch — throwing callback corrupted budget accounting HIGH Wrapped in try/catch (notification-only semantics)

🛡️ 74 Deep Cost Audit Tests

Area Tests
Money correctness (NaN, Infinity, negative, floating point) 10
Budget boundary enforcement (exact limits) 8
Session budget enforcement 6
Per-request budget enforcement 4
Model pricing integrity 7
Estimated vs actual cost semantics 3
Callback safety 3
Cost report integrity 5
Client lifecycle 4
Router + cost integration 3
Security 2
Adversarial inputs 7
Determinism 2
Invariant testing 7

7 Invariants Verified

  1. totalActual >= 0 for all valid inputs
  2. totalActual equals sum of recorded actual costs
  3. byProvider totals reconcile with totalActual
  4. byPhase totals reconcile with totalActual
  5. remainingBudget = sessionBudget - totalActual
  6. No NaN in any report field
  7. No Infinity in any report field

640 Tests Passing

74 new audit tests added (566 → 640 total).


Changelog: https://github.com/Hilbras/Hilbras-ai-sdk/blob/main/CHANGELOG.md