Repository navigation
Conversation
/api/calculate's marginal_savings_rate was the donation sweep's central difference at the nearest grid point, which averages the rates on either side of a kink. A single filer giving $1,000 in 2026 sits on the 170(p) cap, so Texas showed 14.7% where the next dollar saves nothing, and Massachusetts 19.7% where it saves 5%. The rate now comes from a point run at the gift plus $100, in the same parallel batch as the $0 and gift runs: (net tax at the gift - net tax $100 above) / 100. Smaller steps turn float32 rounding into rate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
policyengine-us returns taxes as float32, whose spacing grows with the tax. Over a fixed $100 window, a $100 million earner's 35% read 32% and a $25 million earner's 37.7% read 39.0%, worse than the old sweep figure. The window is now $100, or 2,000 float32 spacings of the net tax when that is wider ($125 from $524,288 of net tax, $8,000 at $40 million). A wider window costs one more point run, alongside the sweep. The FAQ states the window from faqRules.json, which a test ties to the API. Comments in App.tsx, headlineFirst.ts and CLAUDE.md now say where the card's rate comes from. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round 1 of the review (a Codex cloud review at 83f8269) found the card promised the next $1 while showing the average over a $100 window: a Texan giving $925 saves 22% on the next $75 and 0% after the cap, so the card read 16.5%. The card now reads "Average savings per extra dollar", "Change in net taxes if you give a little more", and the FAQ says the figure is the reduction in net taxes per dollar over the next $100, how the range widens, and what a negative rate means. Also from the review: the FAQ threshold uses the magnitude of net tax (a -550,000 check), a comment notes that intermediate rounding can still move the displayed figure, and the float32 spacing example is corrected. A test pins the $925 blend. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Independent review, round 1 (Codex cloud). Result:
Round 2, a full review at bfcda89, is queued. |
MaxGhenis
added a commit
that referenced
this pull request
Dec 3, 2026
* Show the forward rate as "Saved on the next $1" /api/calculate's marginal_savings_rate was the donation sweep's central difference at the nearest grid point, which averages the rates on either side of a kink. A single filer giving $1,000 in 2026 sits on the 170(p) cap, so Texas showed 14.7% where the next dollar saves nothing, and Massachusetts 19.7% where it saves 5%. The rate now comes from a point run at the gift plus $100, in the same parallel batch as the $0 and gift runs: (net tax at the gift - net tax $100 above) / 100. Smaller steps turn float32 rounding into rate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Widen the next-dollar window for large tax bills policyengine-us returns taxes as float32, whose spacing grows with the tax. Over a fixed $100 window, a $100 million earner's 35% read 32% and a $25 million earner's 37.7% read 39.0%, worse than the old sweep figure. The window is now $100, or 2,000 float32 spacings of the net tax when that is wider ($125 from $524,288 of net tax, $8,000 at $40 million). A wider window costs one more point run, alongside the sweep. The FAQ states the window from faqRules.json, which a test ties to the API. Comments in App.tsx, headlineFirst.ts and CLAUDE.md now say where the card's rate comes from. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Label the card as an average over the next $100 Round 1 of the review (a Codex cloud review at 83f8269) found the card promised the next $1 while showing the average over a $100 window: a Texan giving $925 saves 22% on the next $75 and 0% after the cap, so the card read 16.5%. The card now reads "Average savings per extra dollar", "Change in net taxes if you give a little more", and the FAQ says the figure is the reduction in net taxes per dollar over the next $100, how the range widens, and what a negative rate means. Also from the review: the FAQ threshold uses the magnitude of net tax (a -550,000 check), a comment notes that intermediate rounding can still move the displayed figure, and the float32 spacing example is corrected. A test pins the $925 blend. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Overlap the rate run with the sweep and fix the card's sign An in-session check of #113 at bfcda89 confirmed three P2 findings: - The card's description, "Change in net taxes if you give a little more", sat under a figure that is positive when net taxes fall. It now reads "Reduction in net taxes if you give a little more", the FAQ's convention, and a test pins it. - After the site's /api/savings call the gift + $100 run is /api/calculate's only new point run, and the wizard sweep waited for it. calculate_donation now starts the three point runs, waits for $0 and the gift, starts the sweep, then waits for the rate's run. A test with fake runs on a thread pool fails at bfcda89 and passes here. point_metrics_many is now start_points plus point_results. - A step in net tax inside the window counts in full. A comment and a unit test say so, and point to PolicyEngine/policyengine-us#11282, where a gift that tips an itemization election makes such a step. Also pins the Giving Tuesday posts' joint link (TX, $150,000, $2,000: 0%) and renames the parametrized test, which covers a blend case too. Tests: test_next_dollar_rate 18 passed; test_simulation_cache, test_workers and test_faq_numbers 41 passed; test_household_payload -k agree_at_the_endpoint 5 passed; vitest 274 passed; tsc clean; lint 0 errors (1 existing warning); black and isort clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Gate forward marginal-rate card on API window and qualify rounding/step notes * Use step-agnostic fallback copy when window is omitted and clarify FAQ artifact wording --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
This branch was successfully deployed
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.
The defect
The US results card "Saved on the next $1" showed
/api/calculate'smarginal_savings_rate. On main, that figure is the donation sweep's central difference at the grid point nearest the gift. The old docstring says that "at a kink it averages the rates on either side".A gift on a kink therefore got a rate that applies on neither side. Our Giving Tuesday posts use a single 30-year-old with $75,000 in wages giving $1,000 in 2026. That gift sits exactly on the 26 U.S.C. 170(p) cap for filers who take the standard deduction ($1,000 single, $2,000 joint).
Live
/api/calculate, recorded 2026-12-01 15:20Z:Live
/api/savingsthe same day gave TX tax savings of 220.00 at $1,000, $1,001 and $1,100, and MA 270.00, 270.05 and 275.00.The change
The figure. For US households,
/api/calculatenow returns the average reduction in net taxes per dollar over a window above the gift:The point run at the gift + $100 joins the $0 and gift runs in one
point_metrics_manybatch. It shares the point cache with/api/savings.The window. It is
NEXT_DOLLARS($100), or 2,000 float32 spacings of the net tax at the gift when that is wider (next_dollar_window, which uses the magnitude, so a large negative net tax widens it too). The wider window starts at $125 at $524,288 of net tax and reaches $8,000 at $40 million. Only those households run one more simulation, alongside the sweep.Why a window. policyengine-us returns float32 taxes, whose spacing grows with the tax, so a $1 step turns rounding into rate. Measured at policyengine-us 2.156.4, by the step used to read the rate:
The window rule keeps each float32 spacing of rounding to 0.05 point. Intermediate rounding in the model, or a value near a display-rounding boundary, can still move the one-decimal figure. The CA $3M case reads 37.65% over the rule's $250 window and displays 37.6%, against 37.66% over $1,000.
The card's words. Any finite window averages across a kink inside it. A TX single filer giving $925 saves 22% on the next $75 and 0% on the $25 after the cap, so the card reads 16.5%. Main read 22.0% there, which was right for the literal next dollar. So the card no longer promises the next $1:
faqRules.jsonholdsnext_dollars, andtests/test_faq_numbers.pyties it and the threshold to the API.Fixtures. Across the 11 wizard fixtures, the new and old rates agree within 0.01 point except one: the Iowa household whose $10 gift crosses a state credit cutoff moves from 183.5% to 25.8% (22% federal plus 3.8% Iowa). Kansas stays at -5%.
Unchanged.
/api/uk/calculatekeeps the sweep's rate, and the UK results show no such card. The chart still plots the sweep's central differences, and its current-gift dot sits on the nearest sampled point.Tests
tests/test_next_dollar_rate.py, on wizard-built requests:/api/savingsover the next $100.Against main, the four cap cases and both identity cases fail (TX single read 0.1467, MA single 0.1967, TX joint 0.0400, MA joint 0.0900).
Review
tests/560 passed with-n 4, the new file 14/0, a clean merge with main, and six open PRs merging cleanly.Follow-ups (not in this PR)
🤖 Generated with Claude Code