QuantCalc QuantCalc Federal tax engine docs

Federal tax / Library

The federal tax engine as a library

The engine behind POST /api/federal-tax is also a library you run inside your own application (libfedtax 1.6.0, engine 2.3.2, tax year 2026): the same C code, the same rules, the same citations and the same output, byte for byte. No network call, no per-request latency, and no household data leaving your system. It is the sibling of the state tax engine library.

One engine, two doors

The JSON entry point (qcft_compute_json) is the API's own request parser, field table, engine call and response builder, compiled unchanged: for any request it returns the bytes the API returns, including the 400 body of a refusal. The schema and rules documents (GET /api/federal-tax/schema and /rules) are there too, byte for byte. The typed entry point (qcft_compute) takes a C struct and returns the result's figures; it runs the API's own parser and evaluator on the request, so a refused typed request carries the API's message.

What you get

ArtefactSizeFor
libfedtax-1.6.0-linux-x86_64.tar.gz687 KBC/C++ and any language with a C FFI: libfedtax.so.1, libfedtax.a, the header, a CMake package and pkg-config
quantcalc-fedtax-1.6.0.tgz249 KBnpm: WebAssembly, ESM glue and TypeScript types (Node 18 or later, browsers, workers)
quantcalc_fedtax-1.6.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl311 KBPython 3.9 or later: one wheel for every CPython version, typed
libfedtax-1.6.0-src.tar.gz406 KBthe C source drop, when the licence includes source

Thin bindings for Go, Rust, Java, .NET and Swift call the JSON entry point of the same shared library. Sizes measured on the 1.6.0 release build (engine 2.3.2) of 2026-10-11; every artefact is rebuilt byte for byte from the same commit, with SHA-256 checksums and a manifest of the pinned toolchains (the archive timestamps come from the last commit that touched the engine or the library, so sizes can move by a few bytes between commits).

Without the citations

Each full response carries the official sources of every step on the return, with their checked quotes. A build without them answers every request as the full library does, minus rules.sources and rules.unsourced (the blocks includeSources: false leaves out); every figure is the same. The sources stay published on the sources page.

ArtefactSizeFor
libfedtax-nosources-1.6.0-linux-x86_64.tar.gz399 KBthe C library without the citations
quantcalc-fedtax-nosources-1.6.0.tgz172 KBnpm @quantcalc/fedtax-nosources
quantcalc_fedtax_nosources-1.6.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl192 KBPython distribution quantcalc-fedtax-nosources (import name quantcalc_fedtax)
libfedtax-nosources-1.6.0-src.tar.gz406 KBthe source drop, built without the citations

Size budgets are enforced on every release build (bytes, measured and budget):

BinaryFullWithout citations
libfedtax.so.1, stripped1,071,104 (budget 1,276,000)538,624 (budget 642,000)
libfedtax.a1,474,312 (budget 1,754,000)687,680 (budget 819,000)
fedtax.wasm, raw659,217 (budget 784,000)379,928 (budget 452,000)
npm WebAssembly + glue + wrapper + layout, gzipped225,854 (budget 269,000)145,811 (budget 174,000)

The typed request

The typed request is generated from the API's field table, so it has one member per request field and nothing else. When the API gains a field, a regeneration and a rebuild add it at the end of the struct, and the build fails until that is done. The offsets below are the library's binary interface: they never move within a major version.

KindC typeNot sent
one of the listed stringsint32_t (index)QCFT_ENUM_ABSENT
whole numberint32_tQCFT_INT_ABSENT
booleanint32_tQCFT_BOOL_ABSENT
amountdoubleQCFT_ABSENT
list of {year, taxable, nontaxable}_count + qcft_roth_conversion[16]count QCFT_LIST_ABSENT
up to 4 amounts_count + double[4]count QCFT_LIST_ABSENT
up to 4 dates_count + int32_t[4] (YYYYMMDD)count QCFT_LIST_ABSENT
a later tax year {year, inflation or cpiFactor, awiFactor, indexing}qcft_projection (year, indexing, inflation, cpi_factor, awi_factor)year QCFT_INT_ABSENT
amount_list12see include/quantcalc/fedtax.hsee include/quantcalc/fedtax.h
JSON fieldC memberKindOffset
filingStatusfiling_statusone of the listed strings: single, mfj, married_filing_jointly, mfs, married_filing_separately, hoh, head_of_household, qss, qualifying_surviving_spouse8
ageagewhole number12
spouseAgespouse_agewhole number16
mfsLivedApartmfs_lived_apartboolean20
iraDistributionsira_distributionsamount24
rothConversionroth_conversionamount32
pensionpensionamount40
otherOrdinaryIncomeother_ordinary_incomeamount48
shortTermGainsshort_term_gainsamount56
longTermGainslong_term_gainsamount64
socialSecurityGrosssocial_security_grossamount72
taxExemptInteresttax_exempt_interestamount80
includeSourcesinclude_sourcesboolean88
birthMonthbirth_monthwhole number92
blindCountblind_countwhole number96
saltIncomeOrSalesTaxsalt_income_or_sales_taxamount104
saltRealEstateTaxsalt_real_estate_taxamount112
saltPersonalPropertyTaxsalt_personal_property_taxamount120
otherTaxesother_taxesamount128
mortgageInterestmortgage_interestamount136
investmentInterestinvestment_interestamount144
charityCashcharity_cashamount152
charityCashDafcharity_cash_dafamount160
charityCapitalGainPropertycharity_capital_gain_propertyamount168
medicalExpensesmedical_expensesamount176
otherItemizedother_itemizedamount184
itemizeModeitemize_modeone of the listed strings: auto, itemize, standard192
mfsSpouseItemizesmfs_spouse_itemizesboolean196
employerPlanDistributionemployer_plan_distributionamount200
separationYearAgeseparation_year_agewhole number208
publicSafetyEmployeepublic_safety_employeeboolean212
seppDistributionsepp_distributionamount216
disableddisabledboolean224
iraBasisira_basisamount232
iraYearEndValueira_year_end_valueamount240
rothDistributionroth_distributionamount248
rothContributionsroth_contributionsamount256
rothFirstContributionYearroth_first_contribution_yearwhole number264
rothConversionsroth_conversionslist of {year, taxable, nontaxable}268
iraBalancePriorYearEndira_balance_prior_year_endamount656
spouseSoleBeneficiaryspouse_sole_beneficiaryboolean664
beneficiarySpouseAgebeneficiary_spouse_agewhole number668
rmdShortfallrmd_shortfallamount672
rmdShortfallCorrectedrmd_shortfall_correctedboolean680
priorYearTaxprior_year_taxamount688
priorYearAgiprior_year_agiamount696
priorYearFullYearReturnprior_year_full_year_returnboolean704
withholdingwithholdingamount712
estimatedPaymentsestimated_paymentsup to 4 amounts720
estimatedPaymentDatesestimated_payment_datesup to 4 dates760
taxableInteresttaxable_interestamount784
ordinaryDividendsordinary_dividendsamount792
qualifiedDividendsqualified_dividendsamount800
capitalLossRulescapital_loss_rulesboolean808
capitalLossCarryoverShortTermcapital_loss_carryover_short_termamount816
capitalLossCarryoverLongTermcapital_loss_carryover_long_termamount824
taxTabletax_tableboolean832
birthDaybirth_daywhole number836
spouseBirthMonthspouse_birth_monthwhole number840
spouseBirthDayspouse_birth_daywhole number844
governmental457bDistributiongovernmental_457b_distributionamount848
nonqualifiedAnnuitynonqualified_annuityamount856
saltSalesTaxElectedsalt_sales_tax_electedboolean864
capitalGainDistributionscapital_gain_distributionsamount872
rate28Gainrate_28_gainamount880
unrecapturedSection1250Gainunrecaptured_section_1250_gainamount888
wageswagesamount896
socialSecurityWagessocial_security_wagesamount904
medicareWagesmedicare_wagesamount912
socialSecurityWithheldsocial_security_withheldamount920
medicareTaxWithheldmedicare_tax_withheldamount928
employerCountemployer_countwhole number936
selfEmploymentIncomeself_employment_incomeamount944
selfEmploymentSstbself_employment_sstbboolean952
sepContributionsep_contributionamount960
seHealthInsurancese_health_insuranceamount968
qbiW2Wagesqbi_w2_wagesamount976
qbiUbiaqbi_ubiaamount984
spouseWagesspouse_wagesamount992
spouseSocialSecurityWagesspouse_social_security_wagesamount1000
spouseMedicareWagesspouse_medicare_wagesamount1008
spouseSocialSecurityWithheldspouse_social_security_withheldamount1016
spouseMedicareTaxWithheldspouse_medicare_tax_withheldamount1024
spouseEmployerCountspouse_employer_countwhole number1032
spouseSelfEmploymentIncomespouse_self_employment_incomeamount1040
spouseSelfEmploymentSstbspouse_self_employment_sstbboolean1048
spouseSepContributionspouse_sep_contributionamount1056
spouseSeHealthInsurancespouse_se_health_insuranceamount1064
spouseQbiW2Wagesspouse_qbi_w2_wagesamount1072
spouseQbiUbiaspouse_qbi_ubiaamount1080
qualifiedTipsqualified_tipsamount1088
qualifiedOvertimequalified_overtimeamount1096
foreignTaxPaidforeign_tax_paidamount1104
foreignSourceOrdinaryIncomeforeign_source_ordinary_incomeamount1112
foreignSourceQualifiedIncomeforeign_source_qualified_incomeamount1120
foreignTaxCarryoverforeign_tax_carryoveramount1128
ftcMethodftc_methodone of the listed strings: auto, election, form11161136
foreignIncomeOnPayeeStatementsforeign_income_on_payee_statementsboolean1140
amtFtcSimplifiedElectionamt_ftc_simplified_electionboolean1144
privateActivityBondInterestprivate_activity_bond_interestamount1152
incentiveStockOptionsincentive_stock_optionsamount1160
amtDispositionAdjustmentamt_disposition_adjustmentamount1168
amtOtherAdjustmentsamt_other_adjustmentsamount1176
taxableStateRefundtaxable_state_refundamount1184
projectionprojectiona later tax year {year, inflation or cpiFactor, awiFactor, indexing}: law, inflation1192
beneficiaryDistributionbeneficiary_distributionamount1224
rentalNetIncomerental_net_incomeamount1232
rentalPriorYearUnallowedLossrental_prior_year_unallowed_lossamount1240
rentalActiveParticipationrental_active_participationboolean1248
realEstateProfessionalreal_estate_professionalboolean1252
childTaxCreditChildrenchild_tax_credit_childrenwhole number1256
otherDependentsother_dependentswhole number1260
eitcQualifyingChildreneitc_qualifying_childrenwhole number1264
eitcSeparatedSpouseeitc_separated_spouseboolean1268
saversContributionssavers_contributionsamount1272
saversDistributionssavers_distributionsamount1280
fullTimeStudentfull_time_studentboolean1288
taxableDisabilityIncometaxable_disability_incomeamount1296
spouseSaversContributionsspouse_savers_contributionsamount1304
spouseSaversDistributionsspouse_savers_distributionsamount1312
spouseFullTimeStudentspouse_full_time_studentboolean1320
spouseTaxableDisabilityIncomespouse_taxable_disability_incomeamount1328
nontaxablePensionsnontaxable_pensionsamount1336
inheritedBalancePriorYearEndinherited_balance_prior_year_endamount1344
inheritedAccountTypeinherited_account_typeone of the listed strings: traditional, roth1352
inheritedOwnerBirthYearinherited_owner_birth_yearwhole number1356
inheritedOwnerBirthMonthinherited_owner_birth_monthwhole number1360
inheritedOwnerDeathYearinherited_owner_death_yearwhole number1364
inheritedOwnerDiedOnOrAfterRbdinherited_owner_died_on_or_after_rbdboolean1368
inheritedBeneficiaryTypeinherited_beneficiary_typeone of the listed strings: designated, spouse, minorChild, disabled, chronicallyIll, notMoreThan10YearsYounger, noDesignatedBeneficiary1372
inheritedBeneficiaryBirthYearinherited_beneficiary_birth_yearwhole number1376
inheritedElectioninherited_electionone of the listed strings: none, tenYearRule, treatAsOwn1380
inheritedDistributioninherited_distributionamount1384
inheritedShortfallCorrectedinherited_shortfall_correctedboolean1392
inheritedOwnerDistributedInDeathYearinherited_owner_distributed_in_death_yearamount1400
wagesByPeriodwages_by_periodup to 4 amounts1408
spouseWagesByPeriodspouse_wages_by_periodup to 4 amounts1448
selfEmploymentIncomeByPeriodself_employment_income_by_periodup to 4 amounts1488
spouseSelfEmploymentIncomeByPeriodspouse_self_employment_income_by_periodup to 4 amounts1528
iraDistributionsByPeriodira_distributions_by_periodup to 4 amounts1568
rothConversionByPeriodroth_conversion_by_periodup to 4 amounts1608
pensionByPeriodpension_by_periodup to 4 amounts1648
otherOrdinaryIncomeByPeriodother_ordinary_income_by_periodup to 4 amounts1688
shortTermGainsByPeriodshort_term_gains_by_periodup to 4 amounts1728
longTermGainsByPeriodlong_term_gains_by_periodup to 4 amounts1768
capitalGainDistributionsByPeriodcapital_gain_distributions_by_periodup to 4 amounts1808
taxableInterestByPeriodtaxable_interest_by_periodup to 4 amounts1848
ordinaryDividendsByPeriodordinary_dividends_by_periodup to 4 amounts1888
qualifiedDividendsByPeriodqualified_dividends_by_periodup to 4 amounts1928
socialSecurityGrossByPeriodsocial_security_gross_by_periodup to 4 amounts1968
rentalNetIncomeByPeriodrental_net_income_by_periodup to 4 amounts2008
inheritedDistributionByPeriodinherited_distribution_by_periodup to 4 amounts2048
withholdingByPeriodwithholding_by_periodup to 4 amounts2088
charityCarryoverCash1charity_carryover_cash_1amount2128
charityCarryoverCash2charity_carryover_cash_2amount2136
charityCarryoverCash3charity_carryover_cash_3amount2144
charityCarryoverCash4charity_carryover_cash_4amount2152
charityCarryoverCash5charity_carryover_cash_5amount2160
charityCarryoverProperty1charity_carryover_property_1amount2168
charityCarryoverProperty2charity_carryover_property_2amount2176
charityCarryoverProperty3charity_carryover_property_3amount2184
charityCarryoverProperty4charity_carryover_property_4amount2192
charityCarryoverProperty5charity_carryover_property_5amount2200
marketplacePremiumsmarketplace_premiumsamount_list122208
marketplaceSlcspPremiumsmarketplace_slcsp_premiumsamount_list122312
marketplaceAdvancePaymentsmarketplace_advance_paymentsamount_list122416
taxFamilySizetax_family_sizewhole number2520
povertyGuidelineStatepoverty_guideline_stateone of the listed strings: contiguous, alaska, hawaii2524
dependentsModifiedAgidependents_modified_agiamount2528
ptcEstimatedIncomeExceptionptc_estimated_income_exceptionboolean2536
ptcMfsExceptionptc_mfs_exceptionboolean2540
k1PassiveIncomek1_passive_incomeamount2544
k1PassivePriorYearUnallowedLossk1_passive_prior_year_unallowed_lossamount2552
k1NonpassiveIncomek1_nonpassive_incomeamount2560
k1NonpassiveTradingk1_nonpassive_tradingboolean2568
estateTrustIncomeestate_trust_incomeamount2576
estateTrustPassiveestate_trust_passiveboolean2584
estateTrustPriorYearUnallowedLossestate_trust_prior_year_unallowed_lossamount2592
partnershipSeEarningspartnership_se_earningsamount2600
spousePartnershipSeEarningsspouse_partnership_se_earningsamount2608
k1QualifiedBusinessIncomek1_qualified_business_incomeamount2616
k1QbiW2Wagesk1_qbi_w2_wagesamount2624
k1QbiUbiak1_qbi_ubiaamount2632
k1QbiSstbk1_qbi_sstbboolean2640
k1QbiActivek1_qbi_activeboolean2644
nonqualifiedAnnuitySeppnonqualified_annuity_seppamount2648
nonqualifiedAnnuityDeathnonqualified_annuity_deathamount2656
nonqualifiedAnnuityOtherExceptionnonqualified_annuity_other_exceptionamount2664
traditionalIraContributionstraditional_ira_contributionsamount2672
traditionalIraPriorExcesstraditional_ira_prior_excessamount2680
traditionalIraDistributionsIncludedtraditional_ira_distributions_includedamount2688
traditionalIraPriorExcessWithdrawntraditional_ira_prior_excess_withdrawnamount2696
traditionalIraCorrectiveWithdrawaltraditional_ira_corrective_withdrawalamount2704
traditionalIraValuetraditional_ira_valueamount2712
rothIraContributionsroth_ira_contributionsamount2720
rothIraPriorExcessroth_ira_prior_excessamount2728
rothIraDistributionsroth_ira_distributionsamount2736
rothIraCorrectiveWithdrawalroth_ira_corrective_withdrawalamount2744
rothIraValueroth_ira_valueamount2752
hsaContributionshsa_contributionsamount2760
hsaCoveragehsa_coverageone of the listed strings: none, self, family2768
hsaLimithsa_limitamount2776
hsaPriorExcesshsa_prior_excessamount2784
hsaTaxableDistributionshsa_taxable_distributionsamount2792
hsaCorrectiveWithdrawalhsa_corrective_withdrawalamount2800
hsaValuehsa_valueamount2808
spouseTraditionalIraContributionsspouse_traditional_ira_contributionsamount2816
spouseTraditionalIraPriorExcessspouse_traditional_ira_prior_excessamount2824
spouseTraditionalIraDistributionsIncludedspouse_traditional_ira_distributions_includedamount2832
spouseTraditionalIraPriorExcessWithdrawnspouse_traditional_ira_prior_excess_withdrawnamount2840
spouseTraditionalIraCorrectiveWithdrawalspouse_traditional_ira_corrective_withdrawalamount2848
spouseTraditionalIraValuespouse_traditional_ira_valueamount2856
spouseRothIraContributionsspouse_roth_ira_contributionsamount2864
spouseRothIraPriorExcessspouse_roth_ira_prior_excessamount2872
spouseRothIraDistributionsspouse_roth_ira_distributionsamount2880
spouseRothIraCorrectiveWithdrawalspouse_roth_ira_corrective_withdrawalamount2888
spouseRothIraValuespouse_roth_ira_valueamount2896
spouseHsaContributionsspouse_hsa_contributionsamount2904
spouseHsaCoveragespouse_hsa_coverageone of the listed strings: none, self, family2912
spouseHsaLimitspouse_hsa_limitamount2920
spouseHsaPriorExcessspouse_hsa_prior_excessamount2928
spouseHsaTaxableDistributionsspouse_hsa_taxable_distributionsamount2936
spouseHsaCorrectiveWithdrawalspouse_hsa_corrective_withdrawalamount2944
spouseHsaValuespouse_hsa_valueamount2952
coverdellContributionscoverdell_contributionsamount2960
coverdellLimitcoverdell_limitamount2968
coverdellPriorExcesscoverdell_prior_excessamount2976
coverdellDistributionscoverdell_distributionsamount2984
coverdellCorrectiveWithdrawalcoverdell_corrective_withdrawalamount2992
coverdellValuecoverdell_valueamount3000
archerMsaContributionsarcher_msa_contributionsamount3008
archerMsaLimitarcher_msa_limitamount3016
archerMsaPriorExcessarcher_msa_prior_excessamount3024
archerMsaDistributionsarcher_msa_distributionsamount3032
archerMsaCorrectiveWithdrawalarcher_msa_corrective_withdrawalamount3040
archerMsaValuearcher_msa_valueamount3048
ableContributionsable_contributionsamount3056
ableLimitable_limitamount3064
ableCorrectiveWithdrawalable_corrective_withdrawalamount3072
ableValueable_valueamount3080
trumpAccountExcesstrump_account_excessamount3088
trumpAccountExcessDistributedtrump_account_excess_distributedamount3096
trumpAccountExcessEarningstrump_account_excess_earningsamount3104
selfEmployedQualifiedTipsself_employed_qualified_tipsamount3112
spouseSelfEmployedQualifiedTipsspouse_self_employed_qualified_tipsamount3120

With the state engine

The state tax library (libstatetax 1.13.2) carries this engine: its JSON entry point answers computeFederal: true as POST /api/state-tax does, with the federal engine supplying the federal figures the state rules read. It is one binary, so the two engines are always the same version.

The same answer, checked on every build

A parity gate runs on every release build (make dist) and every make check. On 2026-10-11 (engine 2.3.2) it sent a generated corpus of 34,659 requests (18,704 computed, 15,955 refused: every filing status and age gate, every one of the 245 request fields at and past its limits, extended returns, every refusal the API makes, malformed bodies) through four surfaces: the C library, the WebAssembly package, the Python package and the API's own request handler. All four must produce the same bytes for every request, and the 19,987 requests the typed entry point can express must give the same document through it. make check also runs the whole test suite under address, undefined-behaviour and thread sanitizers, fuzzes both entry points, and checks that the binary exports only its own functions.

Performance

Measured 2026-10-01 (engine 2.0.0) on Intel Core i7-12800H, one core; 4,934,741 typed calls a second on 8 threads. Host load average at the start: 1.64 / 2.07 / 2.55 (1 / 5 / 15 minutes). A shared 20-thread host that other agents' test suites often keep busy: `make bench` was run when the 1-minute load average had fallen to the value recorded here. The single-thread rows are pinned to core 0 (taskset).

SurfaceCallCalls a secondMicroseconds a call
Ctyped (qcft_compute)795,3921.3
CJSON, includeSources false25,42939.3
CJSON, the full document with its sources6,485154.2
CJSON, an extended return with its sources3,243308.4
WebAssembly (Node)typed (compute)232,1514.3
WebAssembly (Node)JSON, includeSources false13,40174.6
WebAssembly (Node)JSON, the full document3,457289.3
Pythontyped (compute)64,79315.4
Pythontyped, compute_batch of 1,00072,17213.9
PythonJSON, the full document5,608178.3

Most of a JSON call is building and printing the document, and the sources are most of the document: send includeSources: false, or use the typed entry point, when a response does not need them.

Versions and updates

The library version follows semantic versioning (additions are minor versions; a break is a new major version with a new shared-library name); the engine version, reported as engineVersion, moves whenever a rule, rate or threshold moves; the tax year is the law the build encodes.

Licence

The library is licensed commercially. Ask at [email protected].