QuantCalc QuantCalc Federal tax engine docs

Federal tax / Verification

How the federal tax engine is verified

What is tested, against what, and where the testing stops.

Every step has a test

Each calculation step names the tests that prove it (on the calculation order page); the documentation gate fails when a step has no test, or names a test that does not exist. The composition's tests are hand-worked returns on the 2026 parameters (the result and every Form 1040 line), every sign combination of the capital-gain netting, every branch of the senior deduction, and four Form 1040 identities on a random corpus (taxable income, line 7a, total income, total tax).

StepTestsSourcesBasis
One field table: keys, types, limits and unknown keys60convention
Value checks and the return's facts30convention
The year's parameters10convention
The projection: a later tax year20convention
The response: result, Form 1040 lines and sources30convention
The state API's computeFederal60convention
Extended fields: Schedule A, 8606, 5329, the RMD, blindness, QSS and Form 221021convention
Tax-exempt interest16official
IRA distributions and Roth conversions25official
Pensions and annuities25official
Social Security benefits15official
Taxable Social Security (the Pub 915 worksheet)46official
Net short-term gain or loss15official
Net long-term gain or loss15official
Combined net gain or loss15official
Capital-gain distributions (Schedule D line 13)37official
28% rate gain (Schedule D line 18)34official
Unrecaptured section 1250 gain (Schedule D line 19)24official
Line 7a: the net gain, or a net loss45official
Other ordinary income15official
Rental real estate: the passive activity loss limit (Form 8582)63official
Rental real estate income or loss (Schedule E line 26, Schedule 1 line 5)26official
Wages (Form 1040 line 1a)23official
Business income (Schedule 1 line 3)211official
Self-employment tax (Schedule SE, Schedule 2 line 4)38official
Deductible part of self-employment tax (Schedule 1 line 15)16official
Self-employed retirement plan deduction (Schedule 1 line 16)15official
Self-employed health insurance deduction (Schedule 1 line 17)15official
Adjustments to income (Form 1040 line 10)211official
Additional Medicare Tax (Form 8959)26official
Excess social security tax withheld (Schedule 3 line 11)15official
Employee payroll taxes (FICA), a standalone function17official
The Social Security earnings test, a standalone function14official
Total income15official
Adjusted gross income25official
Standard deduction and the §63(f) aged amount39official
Additional standard deduction for blindness16official
The senior deduction (Schedule 1-A)310official
Tips received in a trade or business (section 224(c))14official
No tax on tips (Schedule 1-A Part II)16official
No tax on overtime (Schedule 1-A Part III)16official
Qualified business income deduction (Forms 8995 / 8995-A)614official
Additional deductions on line 13b14official
Total deductions15official
Taxable income25official
Tax: the brackets and the capital-gains worksheet714official
Tax: the Tax Table below $100,000610official
Tax: the Schedule D Tax Worksheet69official
Foreign tax credit without Form 1116 (the section 904(j) election)34official
Foreign tax credit with Form 1116 (the section 904(a) limit, passive category)45official
Alternative minimum tax (Form 6251)711official
The AMT foreign tax credit (Form 6251 line 8)28official
Form 1040 lines 18 to 22: the order of the nonrefundable credits32official
Credit for the elderly or the disabled (Schedule R)23official
Saver's credit (Form 8880)25official
Child tax credit, credit for other dependents and additional child tax credit (Schedule 8812)35official
Earned income credit (Form 1040 line 27a)35official
The 10% additional tax on early distributions35official
Net investment income tax68official
Other taxes14official
Total tax34official
Medical and dental expenses15official
State and local taxes paid15official
The SALT cap and its phase-down27official
Interest you paid27official
Gifts to charity: the percentage limits and the 0.5% floor37official
Gifts to charity: the five-year carryover211official
The §68 limitation on itemized deductions32official
Total itemized deductions17official
Itemize or take the standard deduction44official
Charitable deduction for non-itemizers13official
Form 8606: the nontaxable part of a conversion15official
Form 8606: the nontaxable part of all distributions15official
Form 8606: basis carried forward15official
Roth IRA distributions: ordering and the 5-year rules25official
Form 5329: early distributions17official
Form 5329: the exceptions to the additional tax59official
Form 5329: the missed-RMD excise tax15official
The RMD divisor: Uniform Lifetime or Joint and Last Survivor24official
The required minimum distribution313official
An inherited account: the payout rule and the distribution period735official
An inherited account: the year's required distribution513official
Form 2210: the required annual payment27official
Form 2210: the underpayment by installment26official
Form 2210: the penalty27official
Form 2210 Schedule AI: the annualized income installment method419official
Taxable interest (line 2b)15official
Ordinary dividends (line 3b)15official
Qualified dividends (line 3a)18official
Short-term capital loss carryover in (Schedule D line 6)18official
Long-term capital loss carryover in (Schedule D line 14)18official
Capital loss allowed (Schedule D line 21)36official
Short-term capital loss carryover to next year25official
Long-term capital loss carryover to next year25official
Total investment income (Form 8960 line 8)25official
Net investment income: nonqualified annuities (Form 8960 line 3)16official
Net investment income: rents (Form 8960 line 4a)16official
Form 8960 line 9a: investment interest14official
Form 8960 line 9b: state income tax allocable to net investment income14official
Form 8960 line 12: net investment income16official
One amount in a later year32official
The year's brackets and deductions35official
The IRMAA income floors in a later year22official
The QCD limits in a later year23official
The premium tax credit (Form 8962) and the net credit (Schedule 3 line 9)610official
Excess advance premium tax credit repayment (Form 8962 line 29, Schedule 2 line 1a)38official
Partnerships, S corporations, estates and trusts (Schedule E Parts II-III) and Form 8582's other passive activities417official
Net investment income: the K-1 trade or business amounts (Form 8960 line 4b)13official
§72(q): the 10% on a nonqualified annuity before 59½34official
§72(q)(2): the annuity's exceptions33official
Form 5329 Part III: excess traditional IRA contributions414official
Form 5329 Part IV: excess Roth IRA contributions315official
Form 5329 Part V: excess Coverdell ESA contributions213official
Form 5329 Part VI: excess Archer MSA contributions213official
Form 5329 Part VII: excess HSA contributions313official
Form 5329 Part VIII: excess ABLE contributions213official
Form 5329 Part X: excess Trump account contributions33official
Form 5329 Part XI: 100% of a distributed Trump account excess's earnings23official

Every line and branch is executed

The coverage gate builds the engine with coverage instrumentation, runs its tests and fails below these measured floors, and when the counts below no longer match a fresh run:

FileLinesBranchesLine / branch
federal_tax.c2318 of 23182062 of 2062100% / 100%
federal_tax_api_meta.c334 of 33468 of 68100% / 100%
federal_tax_json.c1578 of 15781335 of 1335100% / 100%
state_tax_federal.c256 of 256167 of 167100% / 100%
tax_calculator.c193 of 193108 of 108100% / 100%

Outside this gate: rmd.c (the RMD tables and start ages, which the RMD steps call) and irmaa.c (the planner's Medicare tiers, not part of Form 1040). Both have their own unit tests (test_rmd_irmaa.c) but no coverage floor.

No change without a record

The engine was extracted from the planner without changing a single result: a golden corpus recorded from the planner before the extraction (every federal caller: the withdrawal cost and optimiser, every withdrawal policy, the tax-aware simulation's persona panel, full simulation and ACA-bridge responses) is compared bit for bit on every change. A change that moves a result must carry a new engine version, a record in the defects ledger and a re-recorded corpus.

The API is the planner's engine

The API's 2026 parameters are held byte-identical to the planner's 2026 year for every filing status and age pair, and the state API's computeFederal is held to the planner: for a single filer the federal tax and the state tax it returns equal the planner's in every jurisdiction. The published schema, rules and worked examples are regenerated from the code and checked on a seeded corpus of a few thousand requests: every accepted request and every response validates, and every refusal is a documented message.

Sources are re-checked weekly

Every passage on the sources page is re-fetched weekly from its official source; the job fails when a passage is no longer there, and its date on these pages moves only when the passage was found again.

Where it stops

The engine computes the parts of a return listed on the overview and nothing else; what it does not model is listed there too. The API refuses a request key it does not know, but it cannot detect income, credits or taxes that are not sent, so a figure is complete only for a household whose whole return is within its fields. Line ids follow the final 2025 forms (formYear); each line also carries its number on the 2026 drafts (lineNumberDraft2026).