Skip to content

Test the Working for Families rounding, NaN and period cases - #30

Merged
MaxGhenis merged 4 commits into
mainfrom
test-wff-helper-witnesses
Dec 1, 2026
Merged

MaxGhenis merged 4 commits into
mainfrom
test-wff-helper-witnesses

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Agent-written for Max, by Claude Code for Max Ghenis.

What this adds

The tests that issue #27 asks for under "Tests", plus a test that pins one of its helper items, which #24 already fixed. No formula changes. The helper fixes in #27 go in a separate PR, so this one can merge on its own.

Changes

  • test_a_rate_of_a_tenth_abates_exactly is Working for Families helpers: int64, mixed-sequence and shape edge cases, and three missed mutations #27's 0.1-rate witness: $100,000 of wages at a 10% rate over a zero threshold abates $10,000 of a $10,000.01 Family Tax Credit, which leaves one cent, stored as $0.009999999776482582. With the rate narrowed to its 32-bit value, the credit would be $0.009850988164544106.
  • test_a_neighbour_changes_no_familys_income_or_credit gains a family whose income lies a cent below halfway between two 32-bit floats: wages of $249 + $226 and −$0.01, and a child's investment income of $225 + $500. Its stored income is $562,950,020,530,176. The test runs under a $249 Family Tax Credit threshold as well as the law's. It compares every family's stored incomes, gross credits, abatement and net credits with that family's own results, in both orders, and asserts the abatement: 27.5% of the stored income's complete dollars over the threshold, which is $18,454,938 for both families near a midpoint under $2**49.
  • test_ordinary_families_side_by_side_keep_their_own_results makes the same comparison for three families whose incomes sum in 64-bit integers. Two have toddlers and different positive Best Start amounts, $4,041 and $1,731.
  • test_nan_income_gives_nan_best_start_at_a_zero_amount checks that, when a reform sets the Best Start amount to zero, NaN income gives NaN Best Start to a family with an abatable toddler, and $0 to a family with only a school-age child and to a toddler's family with $30,000 of wages, in both orders, as best_start_sums documents.
  • test_a_zero_best_start_amount_on_one_day_skips_only_that_day sets the amount to $0 on 1 April and $4,041 from 2 April, and checks that a toddler's family with $30,000 of wages gets 364 days of $4,041 ÷ 365, stored as $4,029.9287109375.
  • test_excess_dollars_of_extreme_amounts_is_infinite checks that excess_dollars gives infinity for 1.7e308 over minus infinity and for infinity over 1.7e308, under strict NumPy settings. Working for Families helpers: int64, mixed-sequence and shape edge cases, and three missed mutations #27 reported an OverflowError for both at 3d30ce8; main already returns infinity.
  • In test_working_for_families_dates.py, for a family with an eight-year-old and a two-year-old, year:2027-01-01 gives the same three credits as 2027, and 2027-05 gives a twelfth of each ($14,375, $7,670 and $4,041 a year, so $336.75 a month of Best Start). year:2026-04 and year:2027-01-02 each raise the Working for Families period error for each credit, as the README says.
  • A changelog fragment, wff-test-coverage.added.md.

Mutations

I applied each mutation below to working_for_families.py and ran the whole suite on main (c99fa58) and on this branch at its head. The table is a selection; the two reviews ran further mutations.

Mutation Main's 1,612 tests This branch's 1,625 tests
Drop the downward tie repair in stored all pass 2 fail: the cent-below-midpoint neighbour case under both thresholds (income $562,950,087,639,040)
Drop the upward tie repair in stored 2 fail: test_stored_rounds_the_exact_value_once and the five-cents-above neighbour case 3 fail: the same, with the neighbour case under both thresholds
Narrow only a 0.1 rate to 32 bits in daily_rates all pass 1 fails: test_a_rate_of_a_tenth_abates_exactly
Narrow every rate to 32 bits in daily_rates 1 fails: test_the_smallest_positive_rate_computes, as 5e-324 underflows 4 fail: that test, the 0.1-rate test, the 1,025-child neighbour case under $2**49 and the ordinary-families test
Move Best Start's NaN mask below the zero-amount guard all pass 1 fails: the zero-amount NaN test
Mark NaN Best Start for a family without an abatable child 1 fails: a direct best_start_sums case 2 fail: that case and the zero-amount NaN test
At a zero amount, give every family the first family's missing income all pass 1 fails: the zero-amount NaN test
Stop at a zero amount instead of skipping that day all pass 1 fails: test_a_zero_best_start_amount_on_one_day_skips_only_that_day
Use the first family's Best Start abatement for every family all pass 1 fails: the ordinary-families test
Send 64-bit-integer cents to the first family 23 fail 24 fail: those and the ordinary-families test
Use the largest income's excess dollars for every family 26 fail 33 fail: those, the six neighbour cases and the ordinary-families test
Halve the abatement 86 fail 93 fail: those, the 0.1-rate test and the six neighbour cases
Accept a year from 2 January 1 fails: a direct date case 2 fail: that case and the year:2027-01-02 case

Tests

The whole suite passes: 1,625 tests. Ruff reports the same findings as on main, and the format check passes. git merge-tree with main at d431c12 finds no conflicts.

Revisions

  • First version.
  • The first review found the 0.1-rate witness missing: narrowing only that rate passed every test, and the opening sentence overstated what the PR covered. It also asked the neighbour test to assert the abatement and compare every family with its own results, for an ordinary case whose incomes sum in 64-bit integers, for two families with different positive Best Start amounts, for a two-year-old in the monthly test, for a school-age-only family in the zero-amount test, and for a 2 January year to be rejected. This version adds all of them, and the changelog fragment lists them.
  • The second review closed all six. It found that the mutation table gave main's failures for the cast of every rate as this branch's, and called itself complete. It also asked the zero-amount NaN test to include a toddler's family with income, in both orders, for a test of a one-day zero amount, and for a changelog fragment that does not read as calculating credits for a year from another day. This version extends the zero-amount NaN test, adds the one-day zero-amount test, rewords the fragment and replaces the table with my own runs of the whole suite on main and on this branch.
  • The third review confirmed every row of the table on the tests it could call directly and closed the second review's findings. It found that the previous entry read as if both zero-amount tests were new, when one extends an existing test. This version fixes that wording.

axiom: no RuleSpec change (tests and changelog only)

🤖 Generated with Claude Code

MaxGhenis and others added 3 commits November 30, 2026 21:30
Add the regression tests that issue #27 lists, none of which changes a
formula:

- A family whose income lies a cent below halfway between two 32-bit
  floats, which fails if the stored-value tie repair stops rounding
  down.
- The neighbour test under a $2**49 threshold as well as the law's, with
  the families in both orders, now comparing the gross credits and the
  abatement too.
- NaN income gives NaN Best Start to a family with an abatable child
  when a reform sets the amount to zero.
- excess_dollars gives infinity for 1.7e308 over minus infinity and for
  infinity over 1.7e308.
- year:2027-01-01 gives 2027's credits, 2027-05 a twelfth of them, and
  year:2026-04 raises for each credit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Add the 0.1-rate witness: $100,000 at 10% over a zero threshold
  leaves one cent of a $10,000.01 Family Tax Credit, which fails if
  only that rate is narrowed to 32 bits.
- Check each family in the neighbour test against its own results in
  both orders, assert its abatement, and add three ordinary families
  whose incomes sum in 64-bit integers, two of them with different
  positive Best Start amounts.
- Give the zero-amount Best Start test a school-age-only family, which
  gets $0.
- Use a two-year-old in the period tests, so a month gives $336.75 of
  Best Start, and reject year:2027-01-02 as well as year:2026-04 with
  the Working for Families period error.

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

Copy link
Copy Markdown
Contributor Author

Agent-written for Max, by Claude Code for Max Ghenis.

The first independent review (at f19f35d) found one P1 and five P2s. b92358b, 5573ebd and the description answer all of them:

  • The 0.1-rate witness (P1). test_a_rate_of_a_tenth_abates_exactly pays one cent, stored as $0.009999999776482582, for $100,000 at 10% over a zero threshold against a $10,000.01 Family Tax Credit. Narrowing only that rate to 32 bits now fails it. The description separates it from the 5e-324 test, which catches a cast of every rate through underflow.
  • The abatement amount (P2). The neighbour test asserts each case's abatement from its stored income, $18,454,938 for both families near a midpoint under the $2**49 threshold. Halving the abatement now fails all six neighbour cases.
  • Every family against its own results (P2). The neighbour test compares each family, neighbours included, with its own results in both orders. A new test does the same for three ordinary families whose incomes sum in 64-bit integers, two with toddlers and Best Start of $4,041 and $1,731. Sending the 64-bit cents to the first family, using the largest excess dollars for every family, and reusing the first family's Best Start abatement each fail it.
  • Monthly Best Start (P2). The period tests use a family with an eight-year-old and a two-year-old, so a month gives $336.75 of Best Start.
  • Zero-amount Best Start (P2). The test now has a school-age-only family beside the toddler's, and asserts NaN and $0.
  • A year from 2 January (P2). year:2027-01-02 and year:2026-04 each raise the Working for Families period error for each credit.

The whole suite passes (1,624 tests), ruff matches main, and git merge-tree with main at d431c12 finds no conflicts. Round 1 raised a P1, so a full round 2 now reviews 5573ebd.

- Put a toddler's family with income beside the two NaN-income families
  in the zero-amount test, in both orders, so only the NaN-income
  toddler's family gets NaN.
- Test a $0 amount on 1 April before $4,041 from 2 April, which pays
  364 days and fails if the zero-amount guard stops the loop.
- Reword the changelog fragment so that it says a year from another
  day raises an error.

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

Copy link
Copy Markdown
Contributor Author

Agent-written for Max, by Claude Code for Max Ghenis.

The second independent review (at 5573ebd) closed all six of the first review's findings and raised one P1 and three P2s. 15369ba and the description answer them:

  • The mutation table (P1). The table now comes from my own runs of the whole suite on main and on this branch, with the failing tests named, and says it is a selection. Narrowing every rate to 32 bits fails one test on main and four here.
  • Missing income across families at a zero amount (P2). The zero-amount test adds a toddler's family with $30,000 of wages and runs in both orders. Giving every family the first family's missing income now fails it.
  • A zero amount for part of the year (P2). test_a_zero_best_start_amount_on_one_day_skips_only_that_day pays 364 days of $4,041 ÷ 365, stored as $4,029.9287109375, for $0 on 1 April and $4,041 from 2 April. Stopping at the zero amount instead of skipping it fails the test.
  • The changelog fragment (P2). It now says that a year starting on any day other than 1 January raises an error.

The whole suite passes (1,625 tests) and git merge-tree with main finds no conflicts. Round 2 raised a P1, so a scoped round 3 now reviews it and 15369ba.

@MaxGhenis
MaxGhenis marked this pull request as ready for review December 1, 2026 03:18
@MaxGhenis
MaxGhenis merged commit 9fb45cf into main Dec 1, 2026
11 checks passed
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