Mirrored from https://github.com/davoodmehraban89/Aram.git
Synced Dec 3, 19:30 UTC
codex/aram-mapping-source-parser-20261101
add-index-html-10623938925177053894
arena/094f314c-aram
chatgpt-phase1b2-autopilot
codex/adr-future-connectors-pi-v1
codex/aram-account-note-source-trace-20261031
codex/aram-actions-node24-maintenance-20261031
codex/aram-analyst-review-workbook-20261031
codex/aram-bs-candidate-statement-20261031
codex/aram-cash-flow-direct-candidate-20261031
codex/aram-clean-reference-year-integrity-20261030
codex/aram-cross-statement-controls-20261031
codex/aram-equity-changes-candidate-20261031
codex/aram-five-statement-cli-20261031
codex/aram-five-statement-integration-20261031
codex/aram-five-statement-orchestrator-20261031
codex/aram-gate3-coverage-target-guard-20261030
codex/aram-gate3-hidden-xlsx-guard-20261030
codex/aram-gate3-integration-validation-20261030
codex/aram-gate3-mapping-change-preview-20261030
codex/aram-gate3-stale-note-guard-20261030
codex/aram-income-statement-candidate-20261031
codex/aram-manifest-referential-integrity-20261031
codex/aram-mapping-source-parser-20261101
codex/aram-multidimensional-mapping-20261101
codex/aram-multistatement-mapping-20261031
codex/aram-pipeline-manifest-schema-20261031
codex/aram-readonly-mapping-coverage-20261031
codex/aram-reconciliation-review-gate-20261031
codex/aram-same-flush-fiscal-lock-20261030
codex/aram-synthetic-windows-demo-20261031
codex/aram-trial-balance-diagnostic-20261031
codex/aram-windows-background-detail-search-20261031
codex/aram-windows-detail-review-20261031
codex/aram-windows-five-statement-pilot-20261031
codex/aram-windows-statement-figures-20261031
codex/gate-2a-pilot-workbook
codex/gate-2a-pilot-workbook-6864754244772568979
codex/gate3-authenticated-principal-boundary-20261030
codex/gate3-authored-draft-staging-20261030
codex/gate3-carry-forward-preview-20261023
codex/gate3-draft-staging-audit-20261030
codex/gate3-mapping-batch-freshness-20261030
codex/gate3-mapping-batch-review-20261030
codex/gate3-mapping-core
codex/gate3-mapping-coverage-20261023
codex/gate3-mapping-excel-20261023
codex/gate3-note-mapping-review-20261023
codex/gate3-signed-year-scope-20261030
codex/gate3-unapproved-proposal-storage-20261030
codex/payvast-mapping-discovery-20261023
codex/phase-2a-backend-foundation
codex/phase-2b-post-merge-record
codex/phase-2b-source-registration
codex/phase-2b-source-registration-12955190277775369594
codex/post-gate2a-control-reconciliation
codex/post-pr18-acceptance-record
codex/project-control-foundation
codex/t1-repo-hygiene-20261023
codex/t2-ci-hardening-20261023
codex/t3-explicit-migrations-20261023
codex/t6a-readonly-diagnostics-20261023
codex/v1-01-safety-gate-hardening
codex/v1-year-isolation-followup-20261023
codex/windows-native-pilot-shell-20261030
docs/aram-master-control-plan-20261111
docs/aram-roadmap-dashboard-20261030
docs/financial-statement-reconciliation-1402-1404-20261110
feat/gate3-governed-mapping-20261101
feat/gate3-package9-1-security-20261103
feat/gate3-package9-isolated-20261103
fix/password-unicode-validation-20261111
governance/aram-5-1-3-controls-20261030
governance/role-based-operating-model
jules-1168663913887856558-73b8a885
jules-gate-2b-mapping-workflow-foundation-4137724387867065330
phase-1b1-audit-report-7365389436990903239
phase-2a-backend-foundation-10237597358138521261
phase1b2-postmerge-metadata-fix
refactor/drg-parent-year-id-15088443704684163304
source-data-cleanup
| 1 | # ARAM — cross-statement reconciliation gate (NOT APPROVAL) |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | The five independent previews now need a single arithmetic gate before any combined analyst review packet can be considered: |
| 6 | |
| 7 | - Trial balance diagnostic |
| 8 | - Balance sheet candidate |
| 9 | - Income statement candidate |
| 10 | - Statement of changes in equity candidate |
| 11 | - Direct-method cash flow candidate |
| 12 | |
| 13 | `reconcile_cross_statements(...)` consumes the typed candidate objects produced by those modules. It does not rebuild or trust a report just because an individual module returned a positive eligibility flag. |
| 14 | |
| 15 | ## Exact controls |
| 16 | |
| 17 | 1. **Common provenance:** company, fiscal year and source XLSX SHA-256 must match across all five candidates. BS, IS and EQ must also share one exact note-reference snapshot. Candidate eligibility must be a real boolean; nonempty findings or forged completeness/approval flags cannot be smuggled through. |
| 18 | 2. **Balance sheet detail:** re-aggregates every BS presentation line by category from its source closing exposure and explicit sign multiplier. Recomputes assets − liabilities − equity = 0; duplicate note keys, negative presentation lines and summary/detail mismatches block. |
| 19 | 3. **Income statement detail:** re-aggregates revenue, cost, operating expense, other income/expense and tax from individual presentation lines. Recomputes gross profit, operating profit, profit before tax and net result; the summary cannot pass if the underlying line amounts or sign policies differ. |
| 20 | 4. **Equity detail:** re-aggregates account movements into note movements, component totals and movement categories. Recomputes opening + movement = closing at account, note, component and statement levels. Each EQ account's opening, debit, credit, closing, account name and source-row identity must match its exact trial-balance account. |
| 21 | 5. **Trial balance:** recomputes each account's own opening + debit − credit = closing before aggregating totals. It also recomputes opening, debit, credit, closing and net movement totals from the full account trace; offsetting row errors cannot cancel to a green global total. |
| 22 | 6. **Five-statement bridges:** BS equity must equal EQ closing; IS net result must equal the EQ movement explicitly classified as `NET_PROFIT_LOSS`. All comparisons use exact Decimal arithmetic and zero tolerance. |
| 23 | 7. **Cash note policy:** caller must explicitly select the BS asset note/subnote keys that represent cash and cash equivalents, with separate evidence references. Their presentation total must equal direct cash-flow closing cash. Selection evidence is traceability, not authenticated approval. |
| 24 | 8. **Cash-flow detail:** re-aggregates operating/investing/financing inflows and outflows from individual classified lines, recomputes internal transfers, and verifies opening + net change = closing. |
| 25 | 9. **Cash account trace:** each registered cash account must exist in the TB trace. Transaction debit/credit turnovers are recomputed from cash-flow lines, including both sides of internal transfers, then tied to source turnover, opening/closing balances and source-row identity in TB. |
| 26 | |
| 27 | All comparisons use exact Decimal values and zero tolerance. A missing note selection, duplicate BS note line, mismatched source hash, wrong scope, blocked upstream candidate or arithmetic mismatch makes the result ineligible. |
| 28 | |
| 29 | ## Example invocation |
| 30 | |
| 31 | After the application has created all five typed candidates from the **same immutable workbook bytes**: |
| 32 | |
| 33 | ```python |
| 34 | from aram_backend.cross_statement_reconciliation import ( |
| 35 | CashBalanceNoteSelection, |
| 36 | reconcile_cross_statements, |
| 37 | ) |
| 38 | |
| 39 | result = reconcile_cross_statements( |
| 40 | balance_sheet=bs_candidate, |
| 41 | income_statement=is_candidate, |
| 42 | equity_changes=equity_candidate, |
| 43 | cash_flow=cash_candidate, |
| 44 | trial_balance=trial_balance_diagnostic, |
| 45 | cash_balance_notes=[ |
| 46 | CashBalanceNoteSelection( |
| 47 | statement_section="Current assets", |
| 48 | note_number="C01", |
| 49 | subnote_code="", |
| 50 | evidence_ref="FINANCE-OWNER-CASH-NOTE-POLICY", |
| 51 | ), |
| 52 | ], |
| 53 | ) |
| 54 | if not result.eligible_for_analyst_review: |
| 55 | # Resolve every finding; never override or silently ignore it. |
| 56 | print(result.findings) |
| 57 | ``` |
| 58 | |
| 59 | The cash-note selection is an untrusted input. Its evidence reference is traceability, not authenticated approval. The caller must ensure that the selected BS notes include **all and only** cash and cash equivalents, including approved treatment of restricted cash and overdrafts. |
| 60 | |
| 61 | ## End-to-end integration test |
| 62 | |
| 63 | `tests/test_five_statement_pipeline_integration.py` builds one synthetic Pilot XLSX and invokes the actual BS, IS, EQ, direct-CF and TB builders against the exact same workbook bytes. The synthetic ledger demonstrates: |
| 64 | |
| 65 | - BS: assets 100 = liabilities 10 + equity 90 |
| 66 | - IS: net result 20 = EQ net-profit movement 20 |
| 67 | - EQ: opening 70 + movement 20 = closing 90 |
| 68 | - CF: opening cash 40 + net change 10 = closing cash 50 |
| 69 | - TB: opening and closing debit-net totals zero; debit and credit turnover both 60 |
| 70 | |
| 71 | A second test omits a cash transaction and verifies that the combined gate blocks. These are synthetic software tests, not evidence that a real ledger or bank transaction population is complete. |
| 72 | |
| 73 | ## Interpretation and limits |
| 74 | |
| 75 | `eligible_for_analyst_review=true` means the provided candidates, references and arithmetic tie out under their explicit user-supplied policies. It does **not** prove that the ledger, bank transactions, cash-account registry, mapping or note selection is complete or authentic. |
| 76 | |
| 77 | The result permanently marks `source_ledger_completeness_verified=false`, `accounting_policy_authorized=false`, `independently_reviewed=false`, `trusted_approvals=false`, `official_financial_statement=false`, `export_authorized=false`, `releasable=false`. |
| 78 | |
| 79 | No real accounting approval, statutory compliance, tax treatment, authenticated C1/C2/C3 review, database write, report export, GUI or installer is implemented by this gate. It is an engineering control only. |
| 80 | |
| 81 | Run `cd backend && pytest -q tests/test_cross_statement_reconciliation.py tests/test_five_statement_pipeline_integration.py` and full Backend CI. Synthetic candidate objects are used in tests; never place real financial files or approvals in public GitHub. |