@davoodmehraban89 / Aram-2 Mirror · read-only
Fork 0

Mirrored from https://github.com/davoodmehraban89/Aram.git

Synced Dec 4, 14:15 UTC

source-data-cleanup
add-index-html-10623938925177053894 arena/094f314c-aram arena/2d4eda07-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 dependabot/github_actions/actions/checkout-7 dependabot/github_actions/actions/setup-node-6 dependabot/github_actions/actions/setup-python-7 dependabot/github_actions/actions/upload-artifact-7 dependabot/npm_and_yarn/frontend/eslint-plugin-react-hooks-7.1.1 dependabot/npm_and_yarn/frontend/globals-17.15.0 dependabot/npm_and_yarn/frontend/vite-8.4.0 dependabot/npm_and_yarn/frontend/vitest-5.1.2 dependabot/npm_and_yarn/frontend/vitest/coverage-v8-5.1.2 dependabot/pip/backend/mypy-gte-1.13-and-lt-3 dependabot/pip/backend/pytest-cov-gte-6.0-and-lt-8 dependabot/pip/backend/setuptools-gte-75-and-lt-85 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
md 3.92 KB

ADR-032 — R3: compare the engine's own output, and what the 1404 data actually says

  • Status: accepted
  • Date: 2026-12-04
  • Scope: booklet 2.1 task R3
  • Supersedes: the "statement_balance is pre-signed" assumption in ADR-013/018 and ADR-031 §5. Everything else in those ADRs stands.

Context

The golden comparison aggregated the source workbook separately, so it could agree with the official figures while build_statements produced something else. R3 requires comparing the engine's own persisted output. Doing that exposed three real defects and one source-data limitation.

Decision 1 — statement_balance is debit-positive, not pre-signed

Measured: applying the section display sign to statement_balance reproduces the official 1404 balance sheet 16/16; treating it as pre-signed flipped 7 notes. The sign is now applied exactly once, to whichever figure the row provides. BalanceRow.display(sign, basis) and build_statements share the rule.

Decision 2 — the statement basis belongs to the import, not the row

If a source supplies statement balances at all, that column is the statement figure and a row without one contributes nothing. The old per-row fallback to CLOSING leaked non-statement rows into the totals (BS fell to 6/16). Sources without the column keep using CLOSING, so nothing else changes.

Decision 3 — the source assigns notes per row

Account 718291 posts to both note 6 and note 9. An account-level mapping cannot express that, so LedgerBalance.source_note preserves the row's own assignment (migration 20261204_09). Precedence: an explicit mapping wins; the source note only disambiguates an account mapped to several notes. That keeps the mapping workflow authoritative while preventing double-counting.

Decision 4 — the income statement presents expenses negative

Official 1404 notes 6/7/20-3 are negative while the ledger is debit-positive, so IS Revenue and Expenses both take −1. The net result is therefore the sum of the signed IS lines, not revenue minus expenses; C-08's input was corrected.

Decision 5 — each official statement gets the parser its layout needs

official_parse.py reads BS/IS/CF as note lists and EQ as a components × movements matrix (opening / changes / closing / prior closing). The year column is located from the header row, because the title «به تاریخ 29 اسفند 1404» also contains the year and previously won the search, pointing at column 0. CF's 46268 is flagged account_code, not a note. EQ went from 0 parsed figures to 24.

Measured outcome (real 1404, 131,280 rows)

Statement Result
BS 16/16 matched — acceptance met
IS 1/6 exact (note 5); 6 and 7 within 1–2 million rial; 8/9 differ by a 1,111,554 reclassification; 20-3 absent from the source
CF 0/6 — CF is still not rendered (RENDERED_STATEMENTS = BS, IS)
EQ 24 official figures parsed; no built EQ statement yet

IS 6/6 is not met and cannot be met from this source. Note 20-3 (tax expense −4,697,329) has no corresponding row in source_1404.xlsx at all. Notes 8 and 9 together match exactly (−9,057,668); only their split differs, and the official's own adjustment column records exactly ±1,111,554. Notes 6/7 differ by 1–2 million rial because the official sums per-category rounded values.

Per booklet 2.1, this is reported as not met, not softened into a pass. No tolerance was invented and no figure was adjusted to force a match.

Consequences

  • docs/discrepancies.json is regenerated from the built output, with a cause and the exact official cell for every difference, plus account-level deltas.
  • C-13 can now be fed by official_comparisons(report); POST /years/{id}/official-comparison accepts an official workbook, parses it in memory and changes no stored figure.
  • Remaining R3 work (IS 8/9 reclassification decision, CF/EQ rendering) is carried forward explicitly rather than claimed.