Repository navigation
Conversation
taxable_income adds the gross nz_superannuation, and jobseeker_support with the new jobseeker_support_tax (Income Tax Act 2007, sections CF 1(1)(c) and (e)). jobseeker_support_tax is the income tax that the model assumes MSD pays on Jobseeker Support under section 350 of the Social Security Act 2018. It grosses the year's payment up on the personal tax schedule, apart from other income, and section 351(b)(iv) makes it the person's income. For a period that starts before 1 April 2022, taxable income keeps the old sources and raises an error for a person marked as a recipient of either benefit or given a nonzero amount of one. Part of #18. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- taxable_income reads a benefit amount stored for the period on the simulation's own branch, else on the branch it was made from, else on disk, and compares whole periods. Core's lookup read the default branch's amount in a named branch, and failed for a period-2022 calculation when either benefit had an input for a year that starts in April. - grossed_up_tax rejects a schedule with a NaN or infinite threshold, a NaN rate, or thresholds and rates of different shapes. - The income_tax documentation, the README and the docs describe income_tax as the year's liability before credits and jobseeker_support_tax as a separate estimate, whose difference can be negative. The README and the docs say income tax starts in 2021-22 and the benefits enter it in 2022-23. - New tests cover a linked couple's two Jobseeker shares, a partnered NZ Super recipient beside a working partner, a loss beside Jobseeker Support, branch, anchored-year and disk reads, and invalid schedules. - The Jobseeker Support rate description says the rates come before the income test, and the README's clause 1(d) example leaves out 2013 transferees. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Agent-written for Max, by Claude Code for Max Ghenis. Answer to the first review, which requested changes at 3606387. I fixed each P1, P2 and P3 in 63e9c99. I reproduced every RAN witness at 3606387 first, and each result below comes from a run at 63e9c99 on this Mac. P1, the branch read. P1, a year that starts in April. The same Core defect reaches further than the guard, and P1, the tax MSD pays and the year's liability. The P1, NaN in the schedule. P1, a linked couple. P2, the partnered NZ Super case. The YAML case now gives the retiree a partner who earns $30,000. The retiree owes $3,386.47 and the partner $4,158; taxing the couple's $55,591.28 together would give $8,897.88. Summing taxable income over the household fails it. P2, the documentation. The README and the docs now say income tax starts in 2021-22 and that the two benefits enter it in 2022-23. The Jobseeker Support rate description says the rates come before the applicable income test, and the README's clause 1(d) example now leaves out people transferred to Jobseeker Support on 15 July 2013. P2, the test module. Its header now names the years: the inverse from 2021-22 to 2027-28, and simulations from 2022-23. P3, wording. The Your suggestion to tax supplied period-2022 amounts on the 2021-22 schedule is a design change beyond the findings, so this PR keeps the error. Checks. The two test files hold 67 cases, and the suite passes, 1,692 tests. The mutation table covers 43 changes, including your three survivors, and each fails at least one test. Ruff 0.16.7 flags only The second review of 63e9c99 is under way, alongside CI. |
- taxable_income decides whether a period that starts before 1 April 2022 has a benefit recipient from the receiving_nz_super and receiving_jobseeker_support flags alone. The supplied-amount check, which read Core's storage directly, is gone, and an amount given without a flag is left out, as on main. - grossed_up_tax sums each bracket's tax and its amount left after tax, finds the bracket by that amount, and raises when the tax on a finite amount overflows a float. A tiny rate keeps its tax, a rate just below one keeps a finite tax, and a large bracket keeps its small after-tax width. - jobseeker_support_tax raises a TypeError when a reform makes the income tax schedule anything other than a marginal-rate scale. - The documentation, README and changelog say the model assumes MSD pays the tax, and name the clause each couple rate comes from. - New tests cover a NaN rate set through a reform, an average-rate schedule, two grants on the clause 1(g)(i) rate, and the float limits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Agent-written for Max, by Claude Code for Max Ghenis. Answer to the second review, which requested changes at 63e9c99. 128f88b answers each finding, and #34 tracks the Core upgrade. Each result below comes from a run at 128f88b on this Mac, beside main at ba0a233 where it matters. P1s on the inherited, disk, ancestor, colon and neutralized reads. P1, a year that starts in April. This stays a Core 3.20.0 defect, and #33 still reaches it in more places than main. With either benefit set only for P1, a branch made after a calculation. This is Core-wide. On main as at 128f88b, calculating P1, the gross-up's arithmetic. P1, an average-rate schedule. P1, the two-grant clause. You are right, and my first reply was wrong to say both couples take the clause 1(j)(i) rate. A couple with one grant takes clause 1(j)(i), split half to each partner, and a couple with two takes clause 1(g)(i) for each. The comment and the description now say so. P1, the pooling mutations. You are right that P2, Core's private attributes and version range. The model no longer reads any private Core attribute. #34 asks for a lower bound in P2, the schedule contract. The P2, the README, tolerances and population wording. The README gives the thresholds to 2023-24 and from 2025-26, names 2024-25's composite schedule, and its clause 1(d) example now leaves out only the people clause 1(c) covers. The description gives each tolerance on its own: a cent for the YAML cases, $0.000001 for the inverse and 3 cents for simulations. The changelog and the documentation say a recipient stops the whole calculation. P3, voice and attribution. The changelog, README, labels and documentation now say the model assumes MSD pays the tax, use active subjects and sentence case, and drop the explanatory colons and semicolons you named. Checks. The two test files hold 70 cases, and the suite passes, 1,695 tests. The mutation table makes 43 changes, and each fails at least one test except one: searching for the bracket from the left gives the same tax at a boundary, since the lower bracket's whole excess times its rate over one minus its rate is that bracket's tax. Ruff 0.16.7 flags only A scoped third review of the nine P1s comes next, alongside CI. Edited after posting: the anchored-year paragraph now names the routes I tested, and it no longer lists the disk-only case as a limit, since Core 3.20.0 reaches it for a receipt flag only through private attributes. |
|
Agent-written for Max, by Claude Code for Max Ghenis. Answer to the third review, which requested changes at 128f88b. a733144 merges main, which now requires Core 3.38.0 (#35), and bb0d13d answers each finding. The suite passes on Core 3.38.0, 1,926 tests, with the one expected failure that main records, and each result below comes from a run on this Mac. P1 4, years from April and flags on disk. Main now locks Core 3.38.0. Its 3.30.3 release parses a key such as P1 6, the gross-up at rounded boundaries. P1, the overflow in the accumulation. The sums now run in exact arithmetic. Thresholds [0, 3 × 2⁹⁷⁰, largest float] with zero rates give 0 on 0, 1 and the largest float under P1, the claim about b04. The claim was wrong. At 128f88b, searching from the left gave $0 on the [0, 100, 125] reform where the code gave $25, so that mutant came closer to the exact tax than the code did. The new code takes the exact bracket, and b04b and b04c now fail. The renamed b04, which counts only boundaries whose exact value lies strictly below their float, now fails too, since a payment of 0 sits exactly on the first boundary and takes the last bracket under it. The description now makes no claim that any change is equivalent. P2, my reply's coverage wording. My second reply overstated two tests. P2, b05. A payment at or below zero now becomes 0 before the bracket search, and 0 takes the first bracket with no excess, so the output mask for those payments changed nothing. bb0d13d removes it and keeps the mask for NaN. The mutation check now removes the input clamp (b05c) and the NaN mask (b05) separately, and each fails a test. The mutation check makes 50 changes, and each fails at least one test. Round 4 covers the four open P1s. |
|
Agent-written for Max, by Claude Code for Max Ghenis. Answer to the scoped round-4 review (
Checks at
Per |
Agent-written for Max, by Claude Code for Max Ghenis.
Part of #18. This PR carries out steps 2 and 3 of its plan. It meets step 4 in the documentation only, since no variable gives income after tax yet, and step 5 for Jobseeker Support, whose rate metadata now says the rates come before the income test and that the model assumes MSD pays the tax on them. The Jobseeker Support variable already called its amount net cash and now names that assumption, and the NZ Super rates were already labelled gross. Main already reads a bare year as the tax year ending 31 March, which settles step 1. Step 6, the Working for Families income measure, follows in a separate PR.
What this fixes
taxable_incomeadded employment, self-employment and investment income and nothing else, so a person on NZ Superannuation or Jobseeker Support paid no income tax on it. The Income Tax Act 2007 makes both income: a main benefit under section CF 1(1)(c) and NZ Superannuation under section CF 1(1)(e).Changes
taxable_incomeaddsnz_superannuation, which the rates already give gross, from the 2022-23 tax year (period 2023).jobseeker_support_taxis the income tax that the model assumes MSD pays on Jobseeker Support. Section 350(2) of the Social Security Act 2018 lets MSD pay that tax to Inland Revenue instead of deducting it, section 350(3) computes it on the payment grossed up so that what remains after tax equals the payment, and section 351(b)(iv) makes it the person's income.taxable_incomeaddsjobseeker_supportand this tax.grossed_up_taxinverts the tax schedule in closed form. It adds up, bracket by bracket and in exact rational arithmetic, the tax on each full bracket and the amount that bracket leaves after tax. It compares the payment with those exact amounts to find its bracket, and adds the tax at the bracket's threshold to the payment's excess over the bracket's lowest amount after tax, times the bracket's rate over one minus that rate. For a finite payment, the result lies within four units in the last place of the exact tax on the converted thresholds and rates, or within 1e-300 of it where a subnormal float loses precision. A payment at or below zero gives no tax, and a NaN gives NaN. It raises aValueErrorfor a schedule it cannot invert (thresholds and rates that are not one-dimensional or differ in shape, no brackets, a NaN or infinite threshold, a first threshold other than 0, thresholds that do not rise, or a rate that is NaN or outside [0, 1)) and for a tax more than four units in the last place above the largest 64-bit float, and it may raise one for a tax within four such units of that float. It raises noFloatingPointErrorunder any NumPy error setting. It reads the thresholds and rates as NumPy converts them to 64-bit floats and checks the converted arrays, which for the model's schedule are the brackets Core builds for the period.jobseeker_support_taxraises aTypeErrorwhen a reform makes the income tax schedule anything other than a marginal-rate scale, such as a linear average-rate scale, which the gross-up cannot invert.nz_superannuationandjobseeker_supportraise an error for everyone unless an amount is given, so taxable income keeps the three old sources and leaves out both benefits, as before. It raises aValueErrorfor the whole calculation whenreceiving_nz_superorreceiving_jobseeker_supportmarks anyone as a recipient. Core reads the two flags as it reads any input. An amount of either benefit given for such a period without a flag stays out of taxable income, as on main. Period 2022 still taxes other income as before.income_tax,jobseeker_support, the Jobseeker Support rates and the README now says that the model assumes MSD pays the tax on Jobseeker Support. It describesincome_taxas the year's liability before credits andjobseeker_support_taxas a separate estimate of what MSD pays. The README and the docs say that income tax starts in 2021-22 and that the two benefits enter it in 2022-23. The README now gives the schedule for each tax year, and its clause 1(d) example now leaves out the people clause 1(c) covers. The changelog fragment for the NZ Super rates no longer says that no variable readsnz_superannuation.Assumptions and limits
jobseeker_supporton the personal tax schedule for the tax year, apart from the person's other income. Section 350(3) uses the rate that the Commissioner determines for each payment, in consultation with MSD's chief executive, under section RD 11(3), so the tax on each payment can differ from this annual figure. For 2024-25, the annual gross-up uses the year's composite schedule.income_taxfrom benefits.income_tax - jobseeker_support_taxis the balance after MSD's payment, and it is negative when a loss brings the liability below that payment: $19,372.60 of Jobseeker Support beside a $40,000 self-employment loss gives $2,785.70 ofjobseeker_support_taxand noincome_tax.family_incomestill leaves out both benefits, so Working for Families is unchanged.Tests
test_benefit_income_tax.yamlholds #18's cases 1 to 6 for 2026-27, to the cent, with each derivation from Table 1 in a comment:taxable_incomeincome_taxIt also covers a Jobseeker grant at the clause 1(d) rate, which gives case 4's figures; a $40,000 self-employment loss beside NZ Super, which gives 0; the same loss beside case 4's Jobseeker Support, which leaves $2,785.70 of
jobseeker_support_taxand noincome_tax; and NZ Super in 2022-23, which gives $3,917.98 of tax.The YAML cases compare to a cent.
test_benefit_income_tax.pychecks:grossed_up_taxgives, to $0.000001;taxable_incomelessjobseeker_support_taxis the payment andincome_taxlessjobseeker_support_taxis 0 for a person with no other income, to 3 cents, since a simulation stores 32-bit floats;jobseeker_support_taxunchanged, and that each person's payment is grossed up on its own;jobseeker_support_tax, with one grant (clause 1(j)(i), half to each) and with two (clause 1(g)(i) to each), and that a reform raising only the clause 1(g)(i) rate to $401 a week moves the couple with two grants to $20,852 and $3,099.52 each and leaves the couple with one grant where it was;ValueErrorfor a tax too large for a 64-bit float;ValueErrorfor each kind of schedule that cannot be inverted, including NaN and infinite values, shapes that differ, the 2024-25 schedule with a NaN rate, and the same NaN rate set by a reform through Core'sParameter.update, and theTypeErrorfor a reform that gives the schedule average rates;[0.0, 5e-324],[0.75, Q]) returning0.0at zero;np.errstate(all="raise"), a first bracket one subnormal float wide, ten taxes near the largest float that each come within four units in the last place or raise, thresholds whose differences overflow and signalling NaN thresholds and rates, which raise the schedule'sValueErrorundernp.errstate(all="raise"), a signalling NaN payment, which gives NaN, and widernp.longdoubleinputs undernp.errstate(all="raise")(skipped wherelongdoubleis 64-bit) matching quiet-mode outputs or raisingValueError;year:2021-07raises for that year;year:2025-04leaves periods 2022, 2023 and 2027 at the wage-only tax; inputs foryear:2025-04andyear:2021-04count in those years; an input kept on disk under a memory limit is read, so a false flag gives the wage-only tax and a true one raises; and a branch made after its parent calculated taxes its own benefit while the parent keeps its result. Each of these 16 tests fails on Core 3.20.0.The two new test files hold 109 cases, 99 in Python (with the wider-
longdoublecase skipped wherelongdoubleis 64-bit) and 10 in YAML, and the full suite passes on Core 3.38.0 atef3a5ea0: 1,928 passed, 1 expected failure recorded on main (test_core_version.py:338). A 52-mutation check kills all 52 changes acrosstaxable_income,jobseeker_support_tax,jobseeker_supportand the 2024-25 rates (the 50 prior changes plus keeping onlyinvalid="ignore"in the float64 cast guard and taking the tie sign from the rounded remaindernp.sign(rest)). A sweep against exact rational arithmetic, over 63,532 payments on 1,027 schedules at each boundary, the floats either side and random amounts, finds 0 failures within the documented bound.ruff format --checkpasses on the two changed Python files; CI checks ruff 0.15.5.Revisions
taxable_incomereads a stored benefit amount on the simulation's own branch first and compares whole periods;grossed_up_taxrejects NaN, infinite and mismatched schedules; the documentation describesincome_taxandjobseeker_support_taxas separate amounts whose difference can be negative; and new tests cover a linked couple, a working partner, a loss beside Jobseeker Support, branches, anchored years and disk storage.taxable_incomechecks only the receipt flags for a period before April 2022 and leaves a supplied amount out, as main does, in place of 63e9c99's private read of Core's storage.grossed_up_taxadds up each bracket's amount after tax and computes the tax directly, so a near-1 rate, a tiny rate or a large amount no longer loses or invents tax, andjobseeker_support_taxrejects a schedule that is not a marginal-rate scale. The description states Core 3.20.0's limits with the Core versions that fix them, the linked-couple test names the clause each grant takes and adds a reform that tells them apart, and the README gives the schedule for each tax year.grossed_up_taxadds up each bracket's tax and amount after tax in exact rational arithmetic, finds the bracket by comparing the payment with those exact amounts, and keeps the part of each boundary that rounding to a float drops, so a payment at or beside a rounded boundary owes the exact tax. It converts and checks the schedule without a NumPy floating-point error, and sets zero, NaN and overflowing results without one. New tests cover rounded boundaries, widths whose sum passes the largest float, a first bracket one subnormal float wide, taxes near the largest float, strict NumPy error settings and, on Core 3.38.0, years from April, disk storage and branches made after a calculation. A payment at or below zero becomes 0 before the bracket search, so the output mask keeps only NaN. The description drops Core 3.20.0's limits, which Core 3.38.0 removes, and the mutation note no longer claims a change equivalent.grossed_up_taxsuppressesoverandunderalongsideinvalidinnp.errstateduring float64 casting so wide floating-point inputs raise noFloatingPointErrorbefore schedule validation or nonpositive payment clamping; new tests cover widernp.longdoubleinputs undernp.errstate(all="raise")(skipped wherelongdoubleis 64-bit) and the subnormal tied boundary at zero ([0.0, 5e-324],[0.75, Q]).axiom: no RuleSpec change (model formulas, tests and documentation)
🤖 Generated with Claude Code