Skip to content

fix(memory): enforce usage store contracts - #7155

Merged
houko merged 7 commits into
mainfrom
fix/usage-store-contract
Aug 14, 2026
Merged

houko merged 7 commits into
mainfrom
fix/usage-store-contract

Conversation

@houko

@houko houko commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • allow records that exactly reach agent, global, provider cost, or provider token limits; reject only true excess
  • tolerate normal floating-point rounding at exact decimal boundaries
  • reject non-finite or negative usage costs and cost limits before persistence
  • preserve typed memory errors when atomic usage checks cannot acquire a database connection
  • bind daily-window modifiers instead of interpolating them into SQL
  • fail agent daily rollups on corrupt agent IDs instead of silently hiding spend

Verification

  • CARGO_INCREMENTAL=0 CARGO_TARGET_DIR=/Volumes/Lexar/worktrees/audit-usage-store-contract/target-7155 cargo test -p librefang-memory usage::tests:: --lib (20 passed after latest main merge)
  • cargo fmt --check
  • git diff --check
  • earlier branch verification: cargo test -p librefang-memory
  • earlier branch verification: cargo clippy -p librefang-memory --all-targets -- -D warnings
  • earlier branch verification: cargo check --workspace --lib

Out of scope

  • repairing already persisted corrupt agent IDs or invalid historical costs
  • changing UTC accounting windows
  • changing HTTP quota status mapping

@github-actions github-actions Bot added the size/M 50-249 lines changed label Aug 13, 2026
@github-actions github-actions Bot added size/L 250-999 lines changed and removed size/M 50-249 lines changed labels Aug 14, 2026
@houko
houko enabled auto-merge (squash) August 14, 2026 06:30
@houko
houko merged commit 6c2eb0c into main Aug 14, 2026
37 checks passed
@houko
houko deleted the fix/usage-store-contract branch August 14, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L 250-999 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant