ENGINE 03
SFS-E03-PTX · PARTNERSHIP TAX · REV 2026-07-20 · PRODUCTION
PRODUCTION = runnable end-to-end, CI-backed, full test suite passing. All data fictional and seeded.
Partnership Tax · Form 1065
Deterministic Form 1065 support builder with penny-exact K-1s and seven tie-out checks
From a seeded, fully fictional source bundle it builds the partnership's book-to-tax bridge, maps every figure onto Form 1065 and Schedule K, L, M-1, M-2 plus a K-1 preview, and allocates ordinary income so the partner K-1s sum to the exact penny. It runs seven deterministic tie-out checks and marks the package READY only when all pass, otherwise exit code 2. A separate mode tracks IRC §704(c) built-in gain under the traditional method, carrying two parallel capital accounts and flagging the ceiling rule rather than silently curing it.
Every figure on this page re-derives from the public repository: the 653,550.00 ordinary income, the seven tie-out checks, the 15 sourced return lines, and the §704(c) roll-forward are printed by commands you can run, not asserted.
Architecture
functional block stack · static overviewSelect a layer
Each layer is one stage of the pipeline, top of stack to substrate. Select a layer for its plain-terms and engineering detail.
Key specifications
at a glanceWhat it does for you
plain termsPreparing Form 1065 partnership-tax support is manual and error-prone: the book-to-tax bridge, the K-1 allocations that must sum to the penny, the Schedule L / M-1 / M-2 tie-outs, and multi-year IRC §704(c) built-in-gain tracking all have to reconcile before anything is filed. Typical failures are off-by-a-penny K-1 allocations, an unbalanced Schedule L, unsupported return lines, and §704(c) ceiling-rule distortions that get quietly smoothed over. This engine builds the whole package deterministically on fictional seeded data, sources every mapped line, and refuses to mark the package ready until all tie-out checks pass.
A standard 1065 support package that ties out7. The default run builds the fictional Demo 721 Development LP return: ordinary business income of 653,550.00, a 15-line Form 1065 / Schedule K/L/M-1/M-2 map, a three-partner K-1 preview, and 7/7 checks OK, so the package is marked READY and the process exits 0.
Skip the optional Excel workbook8. Passing --no-xlsx builds the identical package but omits the openpyxl support workbook, emitting only the Markdown and JSON artifacts — useful in CI or where Excel is not wanted.
An IRC §704(c) built-in gain with a binding ceiling9. The §704(c) mode models Harborview Partners LP: Atlas contributes property (FMV 1,200,000 / tax basis 300,000 = 900,000 built-in gain) and Beacon contributes 1,200,000 cash. Book depreciation (200,000/yr) exceeds tax depreciation (50,000/yr), so the ceiling rule binds in FY1-5 (flagged BINDING short 50,000 each year); the residual 150,000 layer is caught up to Atlas on the FY6 sale and the tax-basis balance sheet ties at 2,260,000.
Functional block diagram
engineering · each block links to its sourcePlain terms
- CLI dispatch. Reads the flags and picks either the standard 1065 build or the §704(c) demo.
- Source intake. Produces the fictional trial balance, balance sheet, capital, and line-map targets.
- Book-to-tax bridge. Builds book income and the M-1 adjustments to reach taxable ordinary income.
- 1065 / K / L / M-1 / M-2 line map. Maps each computed number onto its return line, with source IDs.
- K-1 partner allocation. Splits ordinary income and capital activity across partners to the penny.
- Review checks gate. Runs seven tie-out checks; only marks READY when all pass.
- Report writers. Renders the Markdown, JSON, and optional Excel outputs.
- Artifacts. The review-ready files land in the output directory.
- §704(c) built-in-gain engine. Alternate mode: tracks book vs tax capital and applies the traditional method with the ceiling rule.
- §704(c) reports. Writes the built-in-gain summary and a per-partner K-1 capital analysis.
Engineering
- CLI dispatch. argparse parser with --year (2025), --seed (1065), --out, --no-xlsx, --section704c; routes to _run_section704c or the standard build.
- Source intake. generate_source_package(year, seed) -> TaxSourcePackage, seeded by random.Random(seed).
- Book-to-tax bridge. build_tax_package computes book_income, adjustment_total, ordinary_income, tax_depreciation, and total_deductions in integer cents.
- 1065 / K / L / M-1 / M-2 line map. _form_lines emits 15 FormLine rows across Form 1065 and Schedules K/L/M-1/M-2.
- K-1 partner allocation. _partner_allocations with money.allocate_by_bps (largest remainder) so K-1 amounts sum exactly to Schedule K.
- Review checks gate. _review_checks -> seven ReviewCheck rows; TaxPackage.ready = all OK; exit 0 / 2.
- Report writers. write_outputs -> tax_workpapers.md, review_checks.md, form_1065_preview.json, optional xlsx.
- Artifacts. output/tax_workpapers.md, review_checks.md, form_1065_preview.json, 1065_supporting_package.xlsx.
- §704(c) built-in-gain engine. section704c.py tracks parallel §704(b) book and tax capital, allocates tax items under the traditional method, and flags ceiling_binding with the shortfall.
- §704(c) reports. run_demo writes section704c_summary.md and section704c_k1_<PARTNER>.md.
Instruction set
every public command| Command | Operation | Output | Exit | Artifacts |
|---|---|---|---|---|
python -m partnership_tax | Build the standard fictional Form 1065 support package | Console summary (year, partnership, ordinary income, checks OK, READY/REVIEW) + written files | 0 if READY, 2 if REVIEW | output/tax_workpapers.md, review_checks.md, form_1065_preview.json, 1065_supporting_package.xlsx |
python run.py --no-xlsx | Same build via the convenience entrypoint, skipping the Excel workbook | Console summary + written files (no xlsx) | 0 if READY, 2 if REVIEW | output/tax_workpapers.md, review_checks.md, form_1065_preview.json |
python -m partnership_tax --section704c | Run the IRC §704(c) built-in-gain demo (traditional method + ceiling rule) | Console summary (partnership, partners, contributed props, built-in gain) + written files | 0 | output/section704c_summary.md, section704c_k1_ATLAS.md, section704c_k1_BEACON.md |
python -m pytest -q | Run the engine's test suite | pytest pass/fail summary | 0 if all pass | none (test run) |
Benchmarks
measured demo results| Measure | Result |
|---|---|
| Tests collected10 | 8,605 tests the checks that pin this engine's behavior |
| Ordinary business income (seed 1065)11 | 653,550.00 USD (fictional) Demo 721 Development LP taxable ordinary income |
| Tie-out checks passing12 | 7/7 checks OK all reviewer checks pass, package READY |
| §704(c) built-in gain (Harborview demo)13 | 900,000.00 USD (fictional) FMV 1,200,000 minus tax basis 300,000 at formation |
| §704(c) tax-basis balance sheet14 | 2,260,000.00 USD (fictional), ties assets = liabilities 0 + tax capital 2,260,000; book and tax capital totals also tie |
Control characteristics
engineeringPlain terms
The code enforces the READY/REVIEW machine gate and exit code; per the README Controls, human review remains the final sign-off.
Engineering
Deterministic envelope. seeded fictional inputs, read-only operation, offline default mode.
Demo gate. machine gate: READY only when all seven tie-out checks pass, otherwise REVIEW and exit code 2
| Severity | Verdict | Action |
|---|---|---|
| All seven tie-out checks within tolerance (0) | READY | TaxPackage.ready = True; status READY in the reports; main() exits 0 |
| Any tie-out check outside tolerance | REVIEW | TaxPackage.ready = False; that check reads FAIL; main() exits 2 |
| §704(c): actual tax depreciation below the non-contributor's book-depreciation share | BINDING | non-contributor capped at the available tax item, contributor gets none, year flagged BINDING with the uncured shortfall |
| §704(c): tax item meets or exceeds the book share | not binding (—) | the book-tax disparity is cured normally; no shortfall flag |
- Integer-cent arithmetic end to end: money.py provides to_cents, fmt, and the largest-remainder allocate_by_bps, and the §704(c) module reuses the same helpers.
- Largest-remainder allocation guarantees the partner K-1 ordinary-income amounts sum exactly to the Schedule K total even when the percentages create pennies.
- Deterministic and seeded (DEFAULT_SEED = 1065): identical inputs produce byte-stable outputs.
- Read-only on inputs: all source data is generated in process on fictional seeded data, and the only writes are to the output/ artifacts directory.
- Every mapped return line carries source IDs; CHK-007 fails if any of the 15 lines is unsourced.
- The package is marked READY only when all seven tie-out checks pass; otherwise the status is REVIEW and the process exits with code 2.
- The §704(c) ceiling-rule distortion is surfaced — flagged BINDING with the uncured shortfall — not silently cured; only the traditional method is implemented.
Standard 1065 package (default). python -m partnership_tax builds the book-to-tax bridge, the 15-line Form 1065 / Schedule K/L/M-1/M-2 map, the K-1 preview, and the seven tie-out checks; exit 0 READY / 2 REVIEW. --no-xlsx skips the optional Excel workbook.
§704(c) built-in-gain demo (--section704c). python -m partnership_tax --section704c runs the traditional method plus the ceiling rule over multiple years, tracking parallel §704(b) book and tax capital, and writes section704c_summary.md and a per-partner K-1; exit 0.
Operating limits
what it refuses to do- Only the IRC §704(c) traditional method is modelled; the remedial and curative methods of Reg. §1.704-3 are explicitly not implemented.15
- It will not silently cure a ceiling-rule distortion: when tax depreciation is short, it caps the non-contributor, gives the contributor none, and flags the year BINDING with the uncured shortfall.16
- It will not mark a package READY unless all seven tie-out checks pass; a failing check forces status REVIEW and exit code 2. It operates only on fictional seeded data — no real taxpayer, partner, EIN, or client figure.17
See it run
animated overview
Integration
how to run itDistribution: public repository, MIT license.
- 1python -m pytest --collect-only -q (partnership-1065-automation/); verified 2026-07-20 and pinned in site-datasheets/counts.json
- 2partnership_tax/engine.py _review_checks (CHK-001..CHK-007); output/review_checks.md
- 3partnership_tax/engine.py _form_lines; CHK-007 counts 15/15 with source refs
- 4partnership_tax/money.py to_cents / fmt / allocate_by_bps
- 5partnership_tax/generate.py DEFAULT_SEED = 1065
- 6partnership_tax/cli.py main() (return 0 if package.ready else 2)
- 7README Run It (python -m partnership_tax); output/review_checks.md CHK-001..CHK-007; partnership_tax/cli.py main()
- 8README Run It (python run.py --no-xlsx); partnership_tax/cli.py --no-xlsx flag; partnership_tax/report.py write_outputs
- 9README §704(c) section (python -m partnership_tax --section704c); output/section704c_summary.md
- 10python -m pytest --collect-only -q (partnership-1065-automation/); verified 2026-07-20 and pinned in site-datasheets/counts.json
- 11output/review_checks.md CHK-001; output/form_1065_preview.json
- 12output/review_checks.md (Overall status: READY)
- 13output/section704c_summary.md; README §704(c) section
- 14output/section704c_summary.md
- 15partnership_tax/section704c.py module docstring ('LIMITATION (documented on purpose)'); output/section704c_summary.md method-limitation note
- 16partnership_tax/section704c.py (ceiling_binding / ceiling_shortfall); README §704(c) section
- 17partnership_tax/cli.py main() (return 0 if package.ready else 2); README Controls; partnership_tax/generate.py (ein='00-0000000', synthetic names)
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