Skip to content

fix(gateway): pass consistent timestamp through budget reset#928

Merged
njbrake merged 1 commit intomainfrom
fix/budget-reset-timestamp
Mar 13, 2026
Merged

fix(gateway): pass consistent timestamp through budget reset#928
njbrake merged 1 commit intomainfrom
fix/budget-reset-timestamp

Conversation

@njbrake
Copy link
Copy Markdown
Contributor

@njbrake njbrake commented Mar 13, 2026

Description

reset_user_budget() called datetime.now(UTC) independently from validate_user_budget(), so the timestamp used for the reset log and next period calculation drifted from the time that actually triggered the reset. Now the caller's now is passed through as a parameter, ensuring all reset operations use the same point in time.

PR Type

  • 🐛 Bug Fix

Relevant issues

Fixes #917

Checklist

  • I understand the code I am submitting.
  • I have added unit tests that prove my fix/feature works
  • I have run this code locally and verified it fixes the issue.
  • New and existing tests pass locally
  • Documentation was updated where necessary
  • I have read and followed the contribution guidelines
  • AI Usage:
    • No AI was used.
    • AI was used for drafting/refactoring.
    • This is fully AI-generated.

AI Usage Information

  • AI Model used: Claude Opus 4.6

  • AI Developer Tool used: Claude Code

  • I am an AI Agent filling out this form (check box if true)

reset_user_budget() called datetime.now(UTC) independently from
validate_user_budget(), causing the reset_at log entry and
next_budget_reset_at calculation to drift from the time that
actually triggered the reset. Pass the caller's timestamp through
to ensure all reset operations use the same point in time.

Fixes #917

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@njbrake njbrake temporarily deployed to integration-tests March 13, 2026 14:17 — with GitHub Actions Inactive
@njbrake njbrake temporarily deployed to integration-tests March 13, 2026 14:17 — with GitHub Actions Inactive
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
see 39 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@njbrake njbrake merged commit 6b82fab into main Mar 13, 2026
14 checks passed
@njbrake njbrake deleted the fix/budget-reset-timestamp branch March 13, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(gateway): pass consistent timestamp through budget reset to avoid time drift

1 participant