Repository navigation
Conversation
…project rows A session or project row carried only totals, so its savings_percent was the overall figure: everything saved over everything that would have been sent, which a few large requests dominate. The mean of each request's own saving, where every request weighs the same, cannot be read back from totals. Each entry now keeps the sum of its requests' saving percentages and a count of the requests that contributed to it, and the row presents their quotient as avg_request_savings_percent beside savings_percent. The count is kept apart from requests because an entry persisted before the fields existed has requests the sum never saw; such an entry reports no mean until new requests accumulate rather than one understated for good. The accumulation and the row derivation, each written out twice for projects and sessions, are shared.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins. |
PR governanceThis PR follows the template and is marked ready for human review. |
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.
Description
Session and project rows report
savings_percentas everything saved over everything that would have been sent, so a few large requests dominate it. The mean of each request's own saving, where every request weighs the same, cannot be recovered from the totals the entries keep.Each entry now also keeps the sum of its requests' saving percentages and a count of the requests that contributed, and the row presents the quotient as
avg_request_savings_percentnext tosavings_percent. The count is separate fromrequestsbecause an entry persisted before these fields existed has requests the sum never saw; it reportsnulluntil new requests accumulate instead of a mean that is understated for good. The accumulation and the row derivation were written out twice, once for projects and once for sessions, and are now shared.Type of Change
Changes Made
headroom/proxy/savings_tracker.py: per-entry accumulatorsrequest_savings_percent_sumandrequest_savings_percent_requests, normalised on load so a state file without them reads as no contributing requests._accumulate_entryand_entry_viewreplace the duplicated project and session accumulation and row derivation.docs/content/docs/proxy.mdx: the two percentages on a session row.tests/test_request_savings_percent.py: the mean against the overall figure, the project row, a reload, and a state file from before the fields.Testing
pytest)ruff check .)mypy headroom)Test Output
CI's
lint,testshards,test-extrasand the other test jobs pass on this head.Real Behavior Proof
uvdevelopment environment, Python 3.14.uv run --extra dev python -m pytest tests/test_request_savings_percent.py -qsavings_percentwhen request sizes differ, and an entry loaded from a pre-change state file reportsavg_request_savings_percentasnull.Runtime Rollout Safety
savings_percentis unchanged andavg_request_savings_percentis an added fieldReview Readiness
Checklist
CHANGELOG.md(it is generated by release-please from my Conventional Commit PR title)Additional Notes
The
Dependency audit (pip-audit)andRust advisories (cargo audit)checks fail on advisories against dependencies in the lock files (mcp,quinn-proto,rustls), which this change does not touch; they fail the same way on any branch cut frommainuntil those dependencies are bumped.