Skip to content

Fold the methodology card into the questions, with tested figures - #93

Closed
MaxGhenis wants to merge 2 commits into
mainfrom
claude/reconcile-methodology-explainer
Closed

MaxGhenis wants to merge 2 commits into
mainfrom
claude/reconcile-methodology-explainer

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Removes the collapsible "How GiveCalc calculates" / "How Gift Aid works" card under the results. It repeated the Questions section directly below it (#92) in hand-written copy that no test checked. The two true points the questions lacked move into them, backed by production API runs and model checks. Follows up the reconciliation flagged in #92.

Each claim on the old card, and where it went

Each claim was checked against policyengine-us 2.49.2 and policyengine-uk 2.134.6, the versions modal_app.py pins and production serves (read from a live Modal container on 2026-10-24).

Old claim Finding Now
"Many donation calculators simply multiply…" A claim about other tools that nothing here can check Cut
US 1: gifts lower federal tax once itemized deductions pass the standard deduction True, but it left out states that itemize on their own return (ca_deductions) Already in "Why did my gift save little or nothing?"
US 2: "A $50,000 donation might save at 32% for the first portion and 24% for the rest" Illustrative, with no run behind it, and misleading. Under the standard deduction the first part of a gift often saves nothing: in the Florida case below, $1,000 and $10,000 both save $320. Replaced by the Florida example from API runs
US 3: "State income taxes and the SALT cap interact with federal taxes" Mostly not modelled. The federal SALT deduction takes state income tax from state_withheld_income_tax, an estimate from AGI that a cash gift doesn't move. Only the local taxes in local_income_tax, such as New York City's, feed back. Cut. The Arizona and Mississippi credits are already in "What does GiveCalc leave out?"
US 4: 2026 rules ($1,000/$2,000, the 0.5% floor, "at most 35 cents") True; "35 cents" simplifies the 2/37 limit Already in "What changed for 2026?", with parameter-checked rules
US 5: cash gifts capped at 60% of AGI True (gov.irs.deductions.itemized.charity.ceiling.all = 0.6). Unlike the card's "may not be fully deductible in the current year", the law carries the excess forward five years (26 U.S.C. 170(b)(1)(G)(ii)), and policyengine-us does not model that. Moved, see below
UK 1: the charity claims 25p per £1, "automatic" 25p is right. "Automatic" leaves out the donor's Gift Aid declaration. Already in "How does Gift Aid work in GiveCalc?"
UK 2: a 40% taxpayer reclaims £250 on £1,000 Matches the API (£70,000 earner). "40% or 45%" leaves out Scotland and the band limits. Already there, from the same API run
UK 3: Scotland "19%-48%" Right for 2026/27 (19, 20, 21, 42, 45, 48%), but relief starts at the 21% intermediate band (first_extended_scottish_threshold) Already there, with the 21% start
UK 4: personal allowance taper above £100,000, £1 per £2 "earned" The taper is on adjusted net income, not earnings (maximum_ANI £100,000, reduction_rate 0.5) Already there
UK 5: High Income Child Benefit Charge over £60,000 "earns" £60,000 is right (CB_HITC.phase_out_start, ending at £80,000); the test is adjusted net income Already there
Footer: PolicyEngine's open-source model True Already in "Where does the model come from?"

What the questions gain

"Why did my gift save little or nothing?" now says three things:

  • a larger gift can save less on each extra dollar once it brings taxable income into a lower bracket;
  • the federal deduction for cash gifts stops at 60% of AGI;
  • the results show the rate as "Saved on the next $1".

A single 30-year-old earning $250,000 in Florida in 2026 shows each step, from six new /api/savings runs against production (2026-10-24):

  • $30,000 → $40,000 saves $3,200 more, 32 cents a dollar;
  • $60,000 → $70,000 saves $2,400 more, 24 cents a dollar;
  • $150,000 → $160,000 saves nothing more.

An "Open the Florida example" link opens the $70,000 case. In the browser it shows a $54,418 cost, $15,582 of savings and "Saved on the next $1: 24.0%". The marginal chart shows the 32% plateau, the drop to 24% and the fall to zero at $150,000.

"What does GiveCalc leave out?" gains a bullet: deducting, in later years, cash gifts above 60% of AGI, which federal law lets you carry forward for up to five years.

The FAQ keeps nine questions. faqNumbers.json adds only the six Florida cases and a new date; every earlier answer is unchanged to the byte.

The space the build dropped

The 375 px check found "60%of your" on the built page, though Vitest's text matched. The cause is in Next 16.2.6's SWC: it drops the leading spaces of a JSX text that spans lines and contains an HTML entity. to {x} of your, then a line break and “q”, compiles to ["to ", x, "of your “q”"].

This was reproduced with next/dist/build/swc across the variants:

  • named and numeric entities, and tabs, all lose the space;
  • trailing spaces survive;
  • one-line texts, entity-free texts and literal “ ” keep it.

PR #92's {us.year}{" "}deduction works around the same thing.

The fix puts the space in an expression. frontend/src/test/jsxWhitespace.test.ts parses every component with TypeScript and fails on any JSX text of that shape. Before the fix it flagged exactly this line, and nothing else in the frontend.

Invariants (tested)

  • Differential. The API code at the uv.lock pins gives each recorded production answer, to the cent, including the six new cases (test_api_gives_the_recorded_answer).
  • The Florida answer holds in the model (test_florida_answer_holds_in_the_model). For all six cases, simulated the way the API simulates them:
    • state and local income tax are 0;
    • AGI equals wages;
    • the donor itemizes;
    • each $10,000 step's extra saving equals the federal rate of the bracket that taxable income stays in at both ends: 0.32 at $219,682 and $209,682, and 0.24 at $189,682 and $179,682;
    • the second rate is lower;
    • the charitable deduction at $150,000 and $160,000 is (0.6 − 0.005) × AGI = $148,750;
    • the $160,000 run saves exactly what the $150,000 run does.
  • Rules. cash_gift_limit_share_of_agi (0.6) equals charity.ceiling.all for 2026.
  • Relations (faqNumbers.test.ts):
    • each step is $10,000;
    • the first step saves more than the second, and both save more than 0;
    • the limit gift is 60% of wages;
    • past it, the extra saving is 0.
  • Rendering.
    • The FAQ quotes the API's numbers word for word.
    • The example links have distinct names.
    • Results renders no button and no explainer heading, in US or UK mode.
    • No JSX text in src/ has the shape the build strips.

Checks

  • Vitest: 150 passed. ESLint: 0 errors; the one warning is the existing <img> in Header.tsx.
  • next build passes. The prerendered page reads 60%<!-- --> <!-- -->of your.
  • pytest: test_faq_numbers.py 19 passed (full suite: see below). black and isort: clean.
  • Browser (local frontend against the production API):
    • 1440 px: the Florida link calculates the case above; Questions follows the breakdown directly; the UK result has no card; there is no horizontal scroll.
    • 375 px: no horizontal scroll (scrollWidth 375); the new paragraphs and bullet wrap cleanly; the UK £1,000 gift at £70,000 reclaims £250.
    • Screenshots are in ~/reviews/givecalc-2026-10-16/screenshots/methodology-pr93/.
  • Review: pending.

axiom: n/a: UI copy and tests only

🤖 Generated with Claude Code

The collapsible "How GiveCalc calculates" / "How Gift Aid works" card under
the results repeated the Questions section below it in hand-written copy
that no test checked. Remove it, and move the two true points the questions
lacked into them, each backed by production API runs and model checks:

- Why did my gift save little or nothing? now explains that a larger gift
  can save less on each extra dollar, once it brings taxable income into a
  lower bracket, and that the federal deduction for cash gifts stops at 60%
  of adjusted gross income. A Florida household earning $250,000 in 2026
  shows both: $10,000 more saves $3,200, then $2,400, then nothing past
  $150,000.
- What does GiveCalc leave out? now lists the five-year carryforward of cash
  gifts above that limit, which policyengine-us does not model.

tests/test_faq_numbers.py traces the Florida answer through the model: no
state or local income tax, AGI equal to wages, each step's saving equal to
the rate of the bracket its taxable income stays in, and a deduction that
stops at the 60% limit (charity.ceiling.all) less the 0.5% floor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
givecalc Ready Ready Preview Oct 24, 2026 11:56am UTC

Request Review

The built page read "60%of your adjusted gross income". Next 16.2's SWC
drops the leading spaces of a JSX text that spans lines and holds an HTML
entity, so `to {cashLimit} of your` with `&ldquo;` later in the same text
compiled to ["to ", cashLimit, "of your …"]. Vitest compiles JSX another way
and kept the space, so the FAQ tests passed.

Put the space in an expression, as the FAQ already does for
`{us.year}{" "}deduction`, and add src/test/jsxWhitespace.test.ts. It
parses every component with TypeScript and fails on any JSX text of that
shape: leading spaces, a line break and an entity. It reports only this
line before the fix, and nothing in the rest of the frontend.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis added a commit that referenced this pull request Nov 30, 2026
Replaces the results page's methodology card with the Questions section,
adds Florida examples, the federal cash-gift limit, carryforwards, the
marginal-savings estimate and the Gift Aid conditions. Supersedes #93.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Superseded by #104, which builds on this branch and merged as f0884e5. It is live on givecalc.org. The branch stays.

@MaxGhenis MaxGhenis closed this Nov 30, 2026

This branch was successfully deployed

1 active deployment
Preview – givecalc — 6955cefc Deployed Oct 24, 2026 by vercel[bot]
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.

1 participant