Fix #348: bound API daily cost windows#403
Merged
anilmurty merged 1 commit intoJul 4, 2026
Merged
Conversation
Bound ApiBackend.get_daily_cost to the requested UTC calendar day instead of querying from day start through now. Update the storage backend parity guard to query the seeded historical day so the serve shim catches cumulative daily-cost regressions.
Contributor
anilmurty
approved these changes
Jul 4, 2026
anilmurty
left a comment
Contributor
There was a problem hiding this comment.
Thanks @sanmaxdev — merging. The best part of this PR is the test retarget: moving the parity spec from now.date() to a seeded historical day is what makes the missing 'until' bound actually exercisable — the old test structurally couldn't catch this. Verified the assertion fails without the fix (105.0 vs 99.0 on the seeded data). Clean, exactly scoped to #348.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ApiBackend.get_daily_costwas querying/api/v1/costfrom the requested day's midnight through now, so historical dates could return cumulative spend instead of that single day's spend. This bounds the shim query to the requested UTC day and tightens the parity guard so the regression is caught.Summary
since=<day 00:00 UTC>anduntil=<next day 00:00 UTC>.untilbound turns red.Related issue
Closes #348
Tests / Verification
PYTHONPATH=/tmp/tokenjam pytest tests/integration/test_storage_backend_parity.py::test_shim_matches_db tests/integration/test_storage_backend_parity.py::test_duckdb_and_in_memory_agree -q --tb=shortPYTHONPATH=/tmp/tokenjam pytest tests/integration/test_storage_backend_parity.py::test_every_protocol_method_is_classified tests/integration/test_storage_backend_parity.py::test_parity_methods_have_specs tests/integration/test_storage_backend_parity.py::test_parity_and_gap_methods_are_actually_implemented tests/integration/test_storage_backend_parity.py::test_unimplemented_methods_have_no_silent_shim -q --tb=shortPYTHONPATH=/tmp/tokenjam pytest tests/unit/ tests/synthetic/ tests/agents/ tests/integration/ -q --tb=short -p no:cacheprovider— 1916 passedruff check tokenjam/mypy tokenjam/ --show-error-codesChecklist
pytest tests/unit/ tests/synthetic/ tests/agents/ tests/integration/)ruff check tokenjam/)mypy tokenjam/)tests/factories.py(not rawNormalizedSpan)@anilmurtyas reviewer (or @-mentioned him above)@anilmurty ready for review.