ENGINE 32
SFS-E32-COE · CLOSING CONTROLS · REV 2026-07-24 · PRODUCTION
PRODUCTION = runnable end-to-end, CI-backed, full test suite passing. All data fictional and seeded.
Home Sale Closing & Settlement Tie-Out
Did the home close, and does its closing package agree with itself?
When a residential developer's home reaches close of escrow the accounting team assembles a package -- a settlement statement, a balanced closing journal entry, a revenue-recognition line, a loan release reconciled to the lender's statement, and a cost-of-sale relief -- and this engine proves, unit by unit, that the package agrees with itself. It is a tie-out check, not an underwriting one: what a home should have sold for, whether the proforma was right, whether the loan should have been made are questions a different engine owns. The engine reads the nine artifacts a closing file carries -- the unit register, the proforma assumptions, the settlement register, the closing journal-entry register, the revenue schedule, the loan-release register, the cost-of-sale schedule, the closing summary and the closing report -- and runs twenty-five deterministic controls over them. Is the file complete; is the unit register sound and does every closed home carry its full package; does each closing entry foot with a receivable derived rather than typed; does the settlement statement recompute -- total charges, closing costs and net to seller re-summed from the components; do the rate-derived fees strike at their proforma rates, and are an off-rate broker commission and an over-allowance concession flagged for a reviewer; was revenue recognised in the close-of-escrow month and the deferred upgrade reversed in full; does each loan release roll forward and tie to the lender's loan statement, with the bank remittance covering the scheduled release price; does the cost-of-sale margin recompute and the prepaid commission relief cap at the prepaid balance; and does the rollup -- the closed count, the total net to seller and every per-unit tie-out flag -- recompute from the units underneath it. It compares every figure with exact ==, treats the release-price gate as >=, and never writes to a source artifact.
A close-of-escrow package looks like the most finished paper a developer produces: the home sold, the money moved, the entry balanced, the report footed. That is exactly why it drifts. None of the ways it goes wrong look wrong in a folder of settlement statements. An entry balances but its receivable was typed rather than plugged; a settlement total was keyed instead of summed; a rate-derived fee was struck a few hundred dollars off its proforma rate; revenue landed a month late; the internal loan release and the lender's statement disagree by a figure nobody tied; and the rollup states a closed count, a net-to-seller total and a per-unit tie-out flag that nobody recomputed from the settlements and entries beneath them. The engine rebuilds every derived figure from the base facts through the same settlement kernel that produced the data, compares with exact ==, ships a planted-defect file for every registered control, and states its benchmark as a command rather than a claim. A figure keyed instead of derived stays invisible until someone recomputes the closing the developer already booked.
Architecture
functional block stack · static overviewSelect a layer
Nine control families run in registry order over each closing file. The first proves the others had something to read: a control that passes because its artifact was absent reports assurance it never performed, so completeness is settled before anything is recomputed.
Key specifications
at a glanceWhat it does for you
plain termsWhen a residential developer's home reaches close of escrow the accounting team assembles a package: a settlement statement, a balanced journal entry, a revenue-recognition line, a loan release tied to the lender's statement, and a cost-of-sale relief. Every one of those is a spreadsheet assembled under deadline, and each goes wrong in ways nobody watches. The entry does not foot, or its Accounts Receivable plug was typed rather than derived. The settlement total settlement charges, total closing costs or net to seller was keyed instead of summed, or a rate-derived fee -- the listing sales fee, the warranty reserve -- was struck at the wrong rate. Revenue lands in the wrong month, when residential sales revenue is earned only at close of escrow. The internal loan release and the lender's loan statement disagree, or the bank remittance falls short of the scheduled release price. And the rollup states a closed count, a total net to seller or a per-unit tie-out flag that nobody recomputed from the settlements and entries underneath it. None of these are judgement calls. They are equalities, thresholds, date-gates and membership checks -- a total against its re-summed components, a receivable against the derived plug, a fee against its proforma rate, a recognition month against the close date, an ending balance against the lender statement with ==, a remittance against the release price with >= -- which a deterministic control settles better than a folder of spreadsheets inherited by whoever handles closings this quarter.
The seeded demo runs every control over every closing file7. The CLI generates twenty-seven fictional closing files -- one clean baseline and one carrying each of the twenty-six planted defects -- then runs all twenty-five 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.
The loan roll-forward and the lender tie are independent8. One defect file moves a home's stated loan ending balance and its lender-statement figure together, so the roll-forward from beginning plus activity no longer holds while the two ending figures still agree -- loan_ending_recomputes fails and loan_ties_lender_statement does not. A separate defect moves only the lender figure and trips loan_ties_lender_statement alone, proving the two controls catch different breaks.
The tie-out flag is recomputed, not read back9. A defect file flips a closed home's summary tie-out flag to false while its underlying settlement, entry, revenue line, loan release and cost-of-sale entry all still recompute. rpt_unit_tied_recomputes rebuilds the flag from that package and fails against the stated value, proving the summary is recomputed from the evidence beneath it rather than trusted as written.
Functional block diagram
engineering · each block links to its sourcePlain terms
- Seeded Closing Files. fictional close-of-escrow packages enter the control registry
- Structural Precondition. is the closing file complete
- Unit Register. is the register sound and every closed home fully packaged
- Closing Journal Entry. does each closing entry foot with a derived receivable
- Settlement Statement. does the settlement statement recompute
- Rate-Derived Fees. do the fees strike at their proforma rates
- Revenue Recognition. was revenue recognised in the close month
- Loan Release Tie. does the loan release roll forward and tie to the lender
- Cost-of-Sale Relief. does the margin relief recompute
- Rollup Tie-Out. do the count, total and tie-out flags recompute from the units
- Registers, Schedules & Proforma. the artifacts and proforma rates every rule resolves against
- Verdict and Findings. every finding, with the reason it exists, ends at a person
Engineering
- Seeded Closing Files. generate_corpus writes one clean baseline plus one planted-defect file for every registered control -- twenty-seven files in total, one carrying each of the twenty-six planted defects. Only the units, the proforma assumptions and the settlement charge components are stated as base facts; every figure the engine later checks -- each settlement total, each closing entry, the revenue lines, the loan ending balances, the cost-of-sale relief, each home's tie-out flag and the report counts -- is re-derived through the same closing_engine.settlement kernel the controls recompute 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 nine artifact types or carrying a duplicate, so no downstream rule holds vacuously on absent evidence.
- Unit Register. Four controls: unique unit ids, a known sale status, the close-of-escrow base facts on every closed home, and exactly one of each closing artifact per closed home.
- Closing Journal Entry. Three controls: every entry names a registered unit, total debits equal total credits, and the Accounts Receivable line equals the derived balancing plug rather than a typed figure.
- Settlement Statement. Three controls: total settlement charges re-summed from the components, total closing costs as charges less the broker commission, and net to seller as gross less charges, each compared with exact ==.
- Rate-Derived Fees. Four controls: the listing sales fee and warranty reserve re-derived at their proforma basis-point rates (hard), and a FLAG each for a broker commission off the proforma assumption and a concession above the assumed allowance.
- Revenue Recognition. Two controls: revenue recognised in the home's close-of-escrow month, and the deferred upgrade reversed in full to the unit's deferred balance.
- Loan Release Tie. Three controls: the ending balance re-rolled from beginning plus activity, tied to the lender's loan statement with exact ==, and the bank remittance covering the scheduled release price with exact >=.
- Cost-of-Sale Relief. Two controls: revised project profit and margin re-derived from the base facts, and the prepaid commission relief capped at the prepaid balance.
- Rollup Tie-Out. Three controls: the report's closed count ties the register, the total net to seller recomputes from the settlements, and every per-unit tie-out flag is rebuilt from its closing package.
- Registers, Schedules & Proforma. The unit register carries each home's id, status, close-of-escrow date, gross sales, deferred upgrade and prepaid balance; the settlement register, closing journal-entry register, revenue schedule, loan-release register and cost-of-sale schedule carry the per-home derived figures; the proforma assumptions carry the basis-point rates the fees are measured against; and the closing summary and closing report carry the per-home tie-out flags and the rollup. Every settlement, entry, fee, revenue, loan, cost-of-sale and rollup control resolves against these through the shared closing_engine.settlement kernel.
- Verdict and Findings. Findings roll up per closing 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| Command | Operation | Output | Exit | Artifacts |
|---|---|---|---|---|
python run.py | regenerate the seeded fictional corpus, run all twenty-five controls, write both reports | per-file verdicts and every actionable finding, then the overall verdict | 2 for the bundled corpus, which carries a planted defect for every control by design | closing_report.json, closing_report.md, samples/ |
python -m closing_engine samples | analyze an existing folder of closing files without regenerating it | per-file verdicts and findings | 0 PASS / 1 REVIEW / 2 FAIL / 3 usage | none unless --json or --md is passed |
python -m closing_engine samples --generate --quiet | regenerate the corpus and print only the overall verdict | a single verdict line | 0 PASS / 1 REVIEW / 2 FAIL / 3 usage | samples/ |
python -m pytest closing_engine/tests -q | run the full test suite for this engine | 10379 passed | 0 when every test passes | none |
Benchmarks
measured demo results| Measure | Result |
|---|---|
| Engine tests10 | 10,379 tests collected live collection from the engine directory |
| Registered controls11 | 25 controls counted from the registry, not from documentation |
| Planted defects12 | 26 defect files every registered control has at least one file that trips it |
| Control coverage13 | 100 percent of controls with a planted defect no control ships without a file demonstrating it firing |
Control characteristics
engineeringPlain terms
The engine has no write path and therefore no autonomy to gate. It produces findings; a person decides whether a home is carried into the close and whether a broken figure is corrected at its source.
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
| Severity | Verdict | Action |
|---|---|---|
| No findings above PASS | PASS | carry the mechanically clean closing file into the documented sign-off and close review |
| One or more FLAG, no FAIL | REVIEW | a human confirms each flag; a broker commission booked off the proforma rate and a concession above the assumed allowance both land here |
| One or more FAIL | FAIL | the home or figure is not carried into the close until the failing control is cleared -- an entry that does not foot, a settlement line that does not recompute, a fee off its rate, revenue in the wrong month, a loan release that does not tie, or a rollup that does not recompute |
- Read-only: closing files are parsed and never written back, so the engine cannot introduce the break it reports.
- Integer cents throughout, compared with exact ==; there is no tolerance band on a figure, and the release-price control is a genuine threshold checked with >=.
- A figure that should be integer cents but is not produces an AMOUNT_INVALID finding contained to the one row it was read on, rather than being coerced into the number the engine is meant to audit.
- One settlement kernel: the controls and the generator share the primitives in closing_engine.settlement, so a determination cannot disagree with the data that produced it.
- set_complete owns the missing-artifact finding and runs first, so a missing artifact fails completeness rather than letting the controls that read it pass unread.
- Deterministic and byte-stable: same inputs produce the same findings in the same order, with no timestamps or absolute paths in any output.
Operating limits
what it refuses to do- The engine never books an entry, files a closing, moves money, contacts a lender, or writes to a source artifact. It reads the closing file and stops.14
- It reads the nine artifacts the closing record emits. It does not connect to a general ledger, an escrow system, a lender portal or the underlying settlement documents.15
- It is a tie-out check, not an underwriting one: it proves the paper agrees with itself, not that the home should have sold for its price or that the loan should have been made. That judgement is a different engine's and a reviewer's.16
- It re-derives the fees at the proforma basis-point rates the file carries; it does not decide whether those assumed rates are the correct ones for the project.17
- It takes the closing and lender records at face value: it confirms the register, settlements and entries foot and reconcile, not that a closing actually occurred or a remittance cleared. All shipped data is fictional and the closing period is set in a fictional future.18
See it run
control architecture
Integration
how to run itDistribution: public repository, MIT license.
- 1python -m pytest --collect-only -q -o addopts= (closing-settlement-automation/)
- 2len(closing_engine.engine.REGISTRY)
- 3distinct rule-id prefixes in closing_engine.engine.REGISTRY
- 4samples/*.json after python run.py
- 5len(closing_engine.model.DOC_TYPES)
- 6closing_engine/tests boundary tests on the cent and the release-price threshold
- 7python run.py (closing-settlement-automation/); closing_engine/tests planted-defect suite
- 8closing_engine/generate.py DEFECTS loan_ending_wrong / loan_does_not_tie
- 9closing_engine/generate.py DEFECTS tied_flag_wrong -> rpt_unit_tied_recomputes
- 10python -m pytest --collect-only -q -o addopts= (closing-settlement-automation/)
- 11len(closing_engine.engine.REGISTRY)
- 12len(closing_engine.generate.DEFECTS)
- 13closing_engine/tests: every registered rule has a planted defect
- 14closing-settlement-automation/README.md and closing_engine read-only / determinism tests
- 15closing_engine/model.py DOC_TYPES
- 16closing_engine/engine.py module scope and README
- 17closing_engine/engine.py fee_ family and proforma_assumptions
- 18closing_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