ENGINE 40

SFS-E40-TXF · FRANCHISE TAX · REV 2026-07-24 · PRODUCTION

PRODUCTION = runnable end-to-end, CI-backed, full test suite passing. All data fictional and seeded.

Franchise Tax Combined Apportionment

Is the tax on the combined return the tax the workpapers re-derive?

A group of affiliated development companies files one combined franchise (margin) tax return each fiscal year in the fictional State of Marran, and three things have to happen together for that return to be defensible. The affiliate roster is redrawn -- last year's members, plus the affiliates that joined, minus the ones that left -- and every affiliate not included this year has to be enumerated with a reason rather than quietly dropped. Consolidated group revenue is taken from the tax trial-balance workpaper, reduced by the group's elected deduction to a taxable margin, and apportioned to Marran by a single receipts factor, in-state receipts over everywhere receipts. And the tax is a derived figure: margin times apportionment times rate, in that order. This engine reads the seven artifacts the combined return carries -- the affiliate register and address tab, the combined-group continuity workpaper, the consolidated trial balance, the single-factor receipts workpaper, the margin worksheet, the tax summary and the return rollup -- and runs twenty-one deterministic controls over them. Is the file complete and the review date readable, are the affiliate ids unique and each affiliate addressed, registered and carrying a known status, which registrations renew inside the file's own lead-time window, does the roster rebuild from the prior year plus additions less removals, is every member registered and every removal reconciled against the excluded list, is each trial-balance line well-formed, uniquely numbered and attributed to a current member, do the receipts rows hold in-state as a subset of everywhere, do the stated totals sum the rows, does the apportionment factor recompute and stay inside [0.00%, 100.00%], does group revenue tie the trial balance, do the margin, the apportioned margin and the tax re-derive, does the summarised tax recompute end to end from the workpapers, and does the return total tie the summary and the roster. Every cent is compared with exact ==, every factor and rate is truncating integer basis-point arithmetic, and no source artifact is ever written back.

A combined franchise return is the rare tax number that is fully derivable and almost never re-derived. Nothing on its face looks wrong when it goes wrong. An affiliate falls off the roster between filings and the return still foots -- it simply taxes a smaller group than the one that earned the revenue, and no line on the return says so. A revenue line is attributed to an affiliate that is not a current member, or carries an id another line already used, and the consolidated base is quietly over- or under-stated. The receipts factor is struck against a denominator that no longer sums the rows beneath it, so the apportioned margin is a share the receipts do not support, and the error is invisible because the factor itself is a clean-looking percentage. Then the margin, the apportioned margin, the tax, the summary and the return total are each carried forward from the figure above them rather than recomputed from the base facts underneath. The engine rebuilds the roster from the prior list and this year's changes, sums revenue from the trial-balance lines, recomputes the factor from the receipts rows rather than the stated totals, and takes the whole tax through the same margin kernel the data was derived with, comparing with exact ==. It ships a planted-defect file for every registered control and states its benchmark as a command rather than a claim.

Run it Book a consultation

Architecture

functional block stack · static overview
Structural Precondition Affiliate Register Combined-Group Roster Consolidated Trial Balance Receipts Apportionment Margin and Tax Derivation Return Rollup substrate: seeded fictional data

Select a layer

Seven control families run in registry order over each combined-return file. The first proves the others had something to read, because a control that passes on absent evidence reports assurance it never performed.

Key specifications

at a glance
10,3441
Tests
the collected checks that pin this engine's behavior
212
Controls
independent rules run over every combined-return file
73
Families
groups of controls, each answering one question
234
Return files
one clean baseline plus twenty-two planted-defect files
75
Artifacts read
affiliate register, combined-group workpaper, consolidated trial balance, receipts factor, margin worksheet, tax summary, return rollup
06
Tolerance
a tax a cent off the re-derivation is a break, not a rounding band

What it does for you

plain terms

A group of affiliated development companies files one combined franchise (margin) tax return each fiscal year in the fictional State of Marran. The return is not one entity's; it is the whole group's, apportioned to Marran by a single receipts factor, and preparing it means three things happen together. The combined group is redrawn -- last year's members, plus the affiliates that joined, minus the ones that left -- and every affiliate not included this year has to be enumerated with a reason, because an affiliate that quietly falls off the roster is revenue that leaves the combined base with nobody noticing. The margin is apportioned -- consolidated group revenue from the tax trial balance, reduced by the group's elected deduction, scaled by in-state receipts over everywhere receipts -- so a factor struck against a denominator that does not sum its rows is a tax computed on numbers nobody reconciled. And the tax itself is derived: margin times apportionment times rate, in that order, each step a place a figure can be carried forward instead of recomputed. None of the failures look wrong on the return. A member with no registration, a revenue line attributed outside the group, a line id used twice, a base that does not tie the trial balance, a margin that does not re-derive from the deduction, a summary that does not recompute from the workpapers -- each foots on its own face. They are also not judgment calls. They are set equalities and integer comparisons -- a roster against prior plus additions less removals, a total against the sum of its rows, a factor against in-state over everywhere floored to a basis point, a tax against the apportioned margin at the rate with exact == -- which a deterministic control settles better than a workbook inherited by whoever prepares the return this year.

The seeded demo runs every control over every combined-return file7. The CLI generates twenty-three fictional combined-return files -- one clean baseline and one carrying each of the twenty-two planted defects -- then runs all twenty-one controls over each. The clean file returns PASS with no flags; every defect file returns REVIEW or FAIL and names the control it tripped along with the reason that control exists.

An affiliate leaves the group and the roster still rebuilds8. In the baseline, AFF-04 is removed from the combined group and AFF-05 joins, so the stated roster must equal the prior four members plus the addition less the removal. One defect file adds a stray prior-year member without touching the stated list, and grp_roster_continuity fails with both the stated roster and the rebuilt one; another empties the excluded list, and grp_excluded_reconciled fails because the removal is no longer enumerated with a reason.

The determination is recomputed, not read back9. A defect file moves the summarised tax by one cent and moves the return total with it, so the rollup is internally consistent and only a recomputation can see the break. rpt_summary_recomputes rebuilds the tax from the trial-balance revenue, the elected deduction, the factor recomputed from the receipts rows and the rate, and fails against the stated figure -- proving the summary is derived from the workpapers rather than trusted as filed.

Functional block diagram

engineering · each block links to its source
Functional block diagram of the Franchise Tax Combined Apportionment engine return files return files return files return files return files return files return files resolves resolves resolves resolves resolves resolves recomputed tax findings findings findings findings findings Seeded Return Files StructuralPrecondition Affiliate Register Combined-Group Roster ConsolidatedTrial Balance Receipts Apportionment Margin andTax Derivation Return Rollup Workpapers &Margin Kernel Verdict and Findings SFS-E40-TXF · FUNCTIONAL BLOCK DIAGRAM · REV 2026-07-24

Plain terms

  • Seeded Return Files. fictional combined-return files enter the control registry
  • Structural Precondition. is the combined-return file complete and the review date legible
  • Affiliate Register. is every affiliate unique, addressed, registered and in standing
  • Combined-Group Roster. does the roster rebuild and is every exclusion reconciled
  • Consolidated Trial Balance. is every revenue line well-formed, unique and attributable
  • Receipts Apportionment. does the single receipts factor recompute and stay bounded
  • Margin and Tax Derivation. does revenue tie the trial balance and the tax re-derive
  • Return Rollup. does the determination recompute from the workpapers it summarises
  • Workpapers & Margin Kernel. the artifacts and the one computation every rule resolves against
  • Verdict and Findings. every finding, with the reason it exists, ends at a person

Engineering

  • Seeded Return Files. generate_corpus writes one clean baseline plus one planted-defect file for every named control, twenty-three files in total. Only the affiliate register, the roster's prior-year members and this year's additions and removals, the consolidated trial-balance revenue lines, the receipts rows and the group's elected deduction and rate are stated as base facts; the current member list, the receipts totals and apportionment factor, group revenue, the taxable margin, the apportioned margin, the tax, the tax summary and the return totals are all re-derived through the same margin kernel the engine later recomputes with, so the relationships the engine tests are the relationships that produced the data.
  • Structural Precondition. One control. FAILs a file missing any of the seven artifact types or carrying a duplicate of one, and FAILs an unreadable as_of date, so no downstream rule holds vacuously on absent evidence.
  • Affiliate Register. Four controls: unique affiliate ids, a complete address and registration id on every row, a status inside the active / inactive vocabulary, and a FLAG on any registration renewing inside the file's own lead-time window measured to the as_of date.
  • Combined-Group Roster. Three controls: the stated member list equals the prior year plus additions less removals, every member is an affiliate on the register, and every removal is enumerated on the excluded list with a reason and is not also a current member.
  • Consolidated Trial Balance. Three controls: each line carries its id, affiliate, account and revenue figure; no line id repeats; and every line is attributed to a current combined member rather than to an affiliate outside the group.
  • Receipts Apportionment. Four controls: in-state receipts never exceed everywhere receipts on a row, the stated totals sum those rows, the factor is in-state over everywhere floored to a basis point and bounded to [0.00%, 100.00%], and the margin worksheet applied that same recomputed factor.
  • Margin and Tax Derivation. Four controls: group revenue sums the consolidated trial-balance lines, the taxable margin is revenue less the elected deduction clamped at zero, the apportioned margin is that margin at the recomputed receipts factor, and the tax is the apportioned margin at the margin-tax rate, each in truncating basis-point arithmetic compared with exact ==.
  • Return Rollup. Two controls: the summarised tax is rebuilt end to end from the base facts -- trial-balance revenue, the elected deduction, the recomputed receipts factor and the rate -- and compared to the stated figure; and the return's total tax due and combined-member count tie the summary and the roster.
  • Workpapers & Margin Kernel. The affiliate register carries each affiliate's address, registration id, status and renewal date; the combined-group workpaper carries prior-year members, additions, removals, the current member list and the excluded rows; the consolidated trial balance carries the revenue lines by affiliate; the receipts workpaper carries in-state and everywhere receipts by affiliate with the totals and the factor; the margin worksheet carries group revenue, the elected deduction, the taxable margin, the applied factor, the apportioned margin, the rate and the tax; and the tax summary and return rollup carry the determination and the filed total. Every roster, tie-out, apportionment and re-derivation control resolves against these through the shared margin kernel, so a recomputed tax cannot disagree with the arithmetic that produced the data.
  • Verdict and Findings. Findings roll up per combined-return file: any FAIL is FAIL, FLAGs without FAILs are REVIEW, clean is PASS. The CLI exit code is the verdict, so a pipeline can gate on it. Reports carry no timestamps or absolute paths, which is what makes the committed report diffable.

Instruction set

every public command
CommandOperationOutputExitArtifacts
python run.py
regenerate the seeded fictional corpus, run all twenty-one controls, write both reportsper-file verdicts and every actionable finding, then the overall verdict2 for the bundled corpus, which carries a planted defect for every control by designfranchise_report.json, franchise_report.md, samples/
python -m franchise_engine samples
analyze an existing folder of combined-return files without regenerating itper-file verdicts and findings0 PASS / 1 REVIEW / 2 FAIL / 3 usagenone unless --json or --md is passed
python -m franchise_engine samples --generate --quiet
regenerate the corpus and print only the overall verdicta single verdict line0 PASS / 1 REVIEW / 2 FAIL / 3 usagesamples/
python -m pytest franchise_engine/tests -q
run the full test suite for this engine10344 passed0 when every test passesnone

Benchmarks

measured demo results
MeasureResult
Engine tests1010,344 tests collected
live collection from the engine directory
Registered controls1121 controls
counted from the registry, not from documentation
Planted defects1222 defect files
every registered control has at least one file that trips it
Control coverage13100 percent of controls with a planted defect
no control ships without a file demonstrating it firing

Control characteristics

engineering

Plain terms

The engine has no write path and therefore no autonomy to gate. It produces findings; a person decides whether a figure is carried onto the combined return and whether a registration or an exclusion is chased.

Engineering

Deterministic envelope. seeded fictional inputs, read-only operation, offline default mode.

Demo gate. FAIL on the bundled corpus, by design -- it carries a planted defect for every registered control

SeverityVerdictAction
No findings above PASSPASScarry the mechanically clean combined-return file into the documented sign-off and filing review
One or more FLAG, no FAILREVIEWa human resolves each flag; an affiliate registration renewing inside the file's lead-time window lands here, current but due to be lodged
One or more FAILFAILthe figure is not carried onto the return until the failing control is cleared -- a roster that does not rebuild, an unreconciled exclusion, a member with no registration, a base that does not tie the trial balance, a factor or a tax that does not recompute

Operating limits

what it refuses to do

See it run

control architecture
Corporate obligation-matrix architecture for Franchise Tax Combined Apportionment: entity and document records pass through jurisdiction and policy controls to verified reporting evidence.
The Franchise Tax Combined Apportionment engine tile states the chain that has to hold end to end: the roster rebuilds from the prior year, group revenue ties the consolidated trial balance, the single receipts factor recomputes inside its bound, and the margin, the apportioned margin, the tax and the return total are each re-derived from the workpapers rather than carried forward.

Integration

how to run it

Distribution: public repository, MIT license.

python run.py
python -m pytest franchise_engine/tests -q
Source on GitHub Engine README All tests, by engine Run in Codespaces
Substantiation
  • 1python -m pytest --collect-only -q -o addopts= (franchise-tax-automation/)
  • 2len(franchise_engine.engine.REGISTRY)
  • 3distinct rule-id prefixes in franchise_engine.engine.REGISTRY
  • 4samples/*.json after python run.py
  • 5len(franchise_engine.model.DOC_TYPES)
  • 6franchise_engine/tests boundary tests on the cent and the basis point
  • 7python run.py (franchise-tax-automation/); franchise_engine/tests planted-defect suite
  • 8franchise_engine/generate.py DEFECTS roster_discontinuity / excluded_unreconciled
  • 9franchise_engine/generate.py DEFECTS summary_recompute_break -> rpt_summary_recomputes
  • 10python -m pytest --collect-only -q -o addopts= (franchise-tax-automation/)
  • 11len(franchise_engine.engine.REGISTRY)
  • 12len(franchise_engine.generate.DEFECTS)
  • 13franchise_engine/tests: every registered rule has a planted defect
  • 14franchise-tax-automation/README.md and franchise_engine read-only / determinism tests
  • 15franchise_engine/model.py DOC_TYPES
  • 16franchise_engine/engine.py grp_ family
  • 17franchise_engine/engine.py apt_ and mgn_ families
  • 18franchise_engine/generate.py

Show us where the hours go.

One conversation: you describe the work that consumes your team's month; we tell you plainly what this engine can take over, what it can't, and what a scoped first phase would cost. Your people keep approval authority.

Book a free consultation