Mirrored from https://github.com/davoodmehraban89/Aram.git
Synced Dec 4, 15:30 UTC
dependabot/pip/backend/setuptools-gte-75-and-lt-85
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
| 1 | # Aram Project Status |
| 2 | |
| 3 | > Canonical status entry point. Update this file in every meaningful pull request. Always fetch the live accepted-branch head before acting; a committed snapshot is not a substitute for GitHub remote evidence. |
| 4 | |
| 5 | ## Repository baseline |
| 6 | |
| 7 | - Repository: [davoodmehraban89/Aram](https://github.com/davoodmehraban89/Aram) |
| 8 | - Accepted branch: `source-data-cleanup` |
| 9 | - **Live accepted head: `f2e6da5e7ade3c851584008d590c588894d4c9c3`** — squash merge of [PR #97](https://github.com/davoodmehraban89/Aram/pull/97), merged 2026-12-04T07:25:29Z under a one-time owner waiver (preconditions verified: OPEN, head `1e247083`, `mergeable_state=clean`). Previous head `46253c9` (PR #96) is preserved by tag `v1.0.0`. |
| 10 | - **Release tag `v1.0.0`** points to `46253c94405abd065dfc5e8cf080b295cb83cde4` (owner-authorized, created pre-mission). The implementation author does not tag (§19); no further tagging without owner directive. |
| 11 | - Post-merge CI on the accepted head: [Backend CI #47137691800](https://github.com/davoodmehraban89/Aram/actions/runs/47137691800) ✅ and [Frontend CI #47137691857](https://github.com/davoodmehraban89/Aram/actions/runs/47137691857) ✅. |
| 12 | - Product objective: a controlled, auditable accounting and financial-statement workflow that preserves canonical source data. |
| 13 | - Authoritative work orders: booklet 1 v1.0 ([`docs/booklet/BOOKLET_v1.0.md`](docs/booklet/BOOKLET_v1.0.md), ADR-025) and **booklet 2 v2.0** ([`docs/booklet/BOOKLET_v2.0.md`](docs/booklet/BOOKLET_v2.0.md), ADR-027 — course correction + general-platform architecture; supersedes conflicting parts of booklet 1). Integrity anchored by SHA-256 in [`docs/booklet/MANIFEST.json`](docs/booklet/MANIFEST.json). **Governing now: booklet 2.1** (owner message 2026-12-04; no markdown copy is committed because the agent holds no byte-exact original — the owner's text is authoritative, see `MANIFEST.json`). It closes only the remaining gaps and takes precedence over booklets 2 and 1, whose other sections stay valid. Work is split into **R1…R6**, one PR each, ≤1,500 lines excluding tests/data; security/control defects may not be deferred. |
| 14 | |
| 15 | - **Agent operations — five-role orchestration (ADR-033, 2026-12-04):** M0 manager + A1 Analyst / B1 Backend / F1 Frontend / D1 DevOps / T1 Independent Tester; auto-discovered through the `AGENTS.md` pointer; entry point `docs/agent-orchestration/MASTER_ORCHESTRATION_PROMPT.md`, per-role prompts `docs/agent-orchestration/AGENT_PROMPTS.md`. Orchestration adds operating procedure only — it never overrides `AGENTS.md`, `docs/ACCEPTANCE_POLICY.md`, or the booklets; a T1 verdict is verification evidence, not acceptance. |
| 16 | |
| 17 | ## Status vocabulary |
| 18 | |
| 19 | | State | Meaning | |
| 20 | |---|---| |
| 21 | | VERIFIED_AND_MERGED | Present on the accepted branch with Git evidence. | |
| 22 | | IN_PROGRESS | Work is in an open PR and is not accepted. | |
| 23 | | NOT_IMPLEMENTED | Required capability is absent. | |
| 24 | | BLOCKED | Work cannot proceed until the recorded blocker is resolved. | |
| 25 | |
| 26 | ## Accepted state — booklet Phases 0–9 (all MERGED via PR #96) |
| 27 | |
| 28 | All Phase 0–9 work below is **VERIFIED_AND_MERGED** on `source-data-cleanup` at head `46253c9` (squash of PR #96). Evidence is the merged head plus post-merge CI; per-commit references are the pre-squash implementation history on `arena/094f314c-aram`. |
| 29 | |
| 30 | | Phase / capability | State | Evidence | |
| 31 | |---|---|---| |
| 32 | | Phase 0 debts D-01..D-07, D-10..D-12 (LedgerBalance, controls C-01..04, rial money, code/header normalization, source store, immutability+audit+reopen, hierarchy, inspection guards, CI gates) | VERIFIED_AND_MERGED | head `46253c9`; ADR-012/013/014/016/017 | |
| 33 | | Phase 1 statements + drill-down | VERIFIED_AND_MERGED | head `46253c9`; ADR-018 | |
| 34 | | Phase 2 mapping import/export | VERIFIED_AND_MERGED | head `46253c9`; ADR-019 | |
| 35 | | Phase 3 note formula engine (AST, no eval) | VERIFIED_AND_MERGED | head `46253c9`; ADR-020 | |
| 36 | | Phase 4 golden comparison (1403+1404) | VERIFIED_AND_MERGED | head `46253c9`; ADR-021 | |
| 37 | | Phase 5 RTL React workbench + Playwright | VERIFIED_AND_MERGED | head `46253c9`; Frontend CI #47137691857 | |
| 38 | | Phase 6 reviewable outputs (XLSX+JSON, exact rial + lineage) | VERIFIED_AND_MERGED | head `46253c9`; ADR-022 | |
| 39 | | Phase 7 users/audit/reopen/backup (roles, PBKDF2, migration 07) | VERIFIED_AND_MERGED | head `46253c9`; ADR-023 | |
| 40 | | Phase 8 offline desktop packaging (loopback entrypoint + PyInstaller recipe) | VERIFIED_AND_MERGED | head `46253c9`; ADR-024; no binary committed (§19) | |
| 41 | | Phase 9 UAT + release prep (`scripts/uat_real_data.py`) | VERIFIED_AND_MERGED | head `46253c9`; UAT evidence below | |
| 42 | | Review fixes: approve role gate, note/mapping edit/delete endpoints, NotesManager UI, python-multipart ADR | VERIFIED_AND_MERGED | head `46253c9`; `docs/reviews/BOOKLET_COMPLIANCE_REVIEW.md` | |
| 43 | | D-08 status/log refresh | VERIFIED_AND_MERGED (this B0 PR) | this entry | |
| 44 | | D-09 git-history rewrite | BLOCKED | owner-only; requires explicit owner directive (§19); tracked in B12 | |
| 45 | |
| 46 | **Test/quality evidence at the accepted head:** backend **319 tests passed** (full local suite); Backend CI #47137691800 green (SQLite + PostgreSQL migration round-trips, ruff, mypy domain-strict + services, coverage, pip-audit); Frontend CI #47137691857 green (eslint, tsc, vitest, build, Playwright). No canonical `data/` or `samples/` file changed. |
| 47 | |
| 48 | ### Historical control events (reference) |
| 49 | |
| 50 | Earlier accepted control events remain part of history: PR #1/#4/#6/#8/#10/#12/#13/#15/#18/#19/#20/#21 (see `docs/PROJECT_LOG.md`). Closed-unmerged candidates PR #7/#9/#16/#17 were never accepted and are reference only. The stale "V1-01 IN_PROGRESS" and "VERIFIED_BUT_UNMERGED" phase rows from prior snapshots are superseded: that work is now merged in PR #96. |
| 51 | |
| 52 | ## Active mission — booklet 2 course correction + C0…C10 roadmap |
| 53 | |
| 54 | Booklet 2 v2.0 («اصلاح مسیر و معماری نهایی Aram», [`docs/booklet/BOOKLET_v2.0.md`](docs/booklet/BOOKLET_v2.0.md), ADR-027; appendix revised by owner 2026-12-03 — positioning + Host Integration API + accepted elements, ADR-029) **supersedes** the conflicting parts of booklet 1 and the earlier B0…B12 framing; it defines the governing roadmap **C0…C10 + optional C11** below. Positioning: Aram is an independent, pluggable financial-statement preparation/control/audit engine with a Host Integration API (REST + permissions) for future embedding; government systems (مودیان/IMED/trade), bank-invoice processing, form builder/cartable are rejected scope; messenger bots for financial data prohibited (ADR-029). One focused PR per phase task, ≤ ~1,500 changed lines excluding tests/generated data (الف5); PR body must match `git diff --stat` + real head (الف4). Executor only; independent reviewer separate; no "done" without evidence (§19). Ambiguities closed via booklet 2 §14 (default + proof + ADR, OD-01..OD-14), never by querying the owner. `data/` + `samples/` read-only with before/after tree-hash evidence per PR. No merge, no tag, no runtime network, no company-specific code (§16). |
| 55 | |
| 56 | | Phase | Scope (summary) | State | |
| 57 | |---|---|---| |
| 58 | | C0 | Course correction (بخش الف): browser-edition removal (الف1, ADR-028); persistent core is main path (الف2); phase 0/1 + golden 1404 verified (الف3); PR honesty/size rules (الف4/5); `docs/PR_TRIAGE.md` (الف6); exit criteria (الف7); booklet 1+2 references | IN_PROGRESS (this PR) | |
| 59 | | C1 | Real vertical slice: 1404 ledger → LedgerBalance → C-01/C-02 → mapping → BS/IS → official reconciliation; golden green or diffs documented | NOT_IMPLEMENTED (core largely merged; re-verify on new model) | |
| 60 | | C2 | Mapping + notes (booklet 1 phases 2–3) | NOT_IMPLEMENTED | |
| 61 | | C3 | Four statements BS/IS/EQ/CF + all controls C-01..C-15 + two-year comparison + 1403 | NOT_IMPLEMENTED | |
| 62 | | C4 | Connector framework + FileConnector: plugin model, manifest, Conformance Suite, Adapter, snapshot + reconciliation | NOT_IMPLEMENTED | |
| 63 | | C5 | DB Connector: SQLite/PostgreSQL then SQL Server (**OD-09 revised: pyodbc-first**, python-tds fallback — ADR-029), test DB in CI, read-only source user | NOT_IMPLEMENTED | |
| 64 | | C6 | Data packs + generalization: template/mapping packs; "second synthetic company" CI proof (ب1/ب8); document level only after C6 (OD-12) | NOT_IMPLEMENTED | |
| 65 | | C7 | Full UI + outputs (booklet 1 phases 5–6 on new model): exact-rial Persian UI, PDF/XLSX; work center; print templates w/ letterhead + statutory ledgers (روزنامه/کل); Ctrl+K search; group dashboard; Host Integration API surface (ADR-029) | NOT_IMPLEMENTED | |
| 66 | | C8 | Security + audit (booklet 1 phase 7 + ب10): pilot API auth, Argon2id, DPAPI vault, encrypted backup, plugin allowlist; multi-layer access (module←company←year←row/field); source-drift detection → «نیازمند بازبینی»; dry-run; nightly document audit C-16+ (optional, post-C6) | NOT_IMPLEMENTED | |
| 67 | | C9 | Packaging + deployment (booklet 1 phase 8 + SBOM/signing): offline Windows, CI gates, large-file manifest; signed updates w/ auto-rollback + in-app backup/restore; Windows drift service | NOT_IMPLEMENTED | |
| 68 | | C10 | Acceptance: Shadow Run on a real period of two companies + owner signature | NOT_IMPLEMENTED | |
| 69 | | C11 | AI assistant (optional, OFF by default): understands questions only, **never generates numbers** — figures only from engine + approved CalculationRun with lineage; read-only, local/anonymized, audited (ADR-029) | NOT_IMPLEMENTED (optional) | |
| 70 | |
| 71 | ### C0 progress (بخش الف) |
| 72 | |
| 73 | - **الف1 (browser removal):** DONE — `webapp/`, `docs/{app.js,index.html,bridge.py,styles.css,py,vendor}`, `scripts/build_webapp.py`, `.github/workflows/pilot-pages.yml` removed (ADR-028). Recoverable from history at `46253c9`; the named `experiment/browser-edition` branch is an owner action (Arena single-branch constraint). |
| 74 | - **الف2 (persistent core main):** VERIFIED — `domain/{controls,money,hierarchy,formula,normalization}` + `statement_api`/`admin_api` on stored `LedgerBalance` is the product path; legacy in-memory pilot (`pilot_engine/store/api/editing`, `static/pilot`) retained as logic reference, secured in C8 then retired; exception-queue persistence tracked in C4. |
| 75 | - **الف3 (phase 0/1 + golden 1404):** VERIFIED merged at `46253c9` — D-01..D-12, `test_golden.py`/`test_domain_controls.py`/`test_approval_gate.py`; real-1404 UAT evidence below. |
| 76 | - **الف4/الف5 (PR honesty/size):** rules added to `AGENTS.md`; this PR body matches the diff. |
| 77 | - **الف6 (PR triage):** DONE — `docs/PR_TRIAGE.md` (ADOPT #81/#89/#92; CLOSE NO-GO #82/#88; SUPERSEDED #90/#91 + #22–#80 backlog). |
| 78 | - **الف7 (exit criteria):** MET — CI green at accepted head; `PROJECT_STATUS.md` consistent with head; golden 1404 freshly re-run (`golden.compare_year`): **28 comparisons, 9 matched, 19 differences** (BS 9/16, IS 0/6, EQ 0/0, CF 0/6), **all 19 recorded one-by-one in [`docs/discrepancies.json`](docs/discrepancies.json) with cause + reproducible evidence** (16 caused: 8 presentation-sign flips with exact magnitude, note-number reuse, absent/undderived CF notes; 3 under investigation = IS notes 6/8/9, treated as bugs until proven, D1). EQ official sheet yields 0 extractable note rows (C3 parsing gap, recorded). Real-1404 approval remains blocked by C-01/C-03/C-04 (fail-loud, correct). |
| 79 | - **Appendix revision (owner, 2026-12-03 second message):** Databan catalog studied by owner (marketing, unverified; agent has no site access); positioning + Host Integration API recorded (ADR-029); **OD-09 revised to pyodbc-first** (python-tds fallback); accepted elements mapped to C4–C9/C11; C11 added (optional AI assistant, OFF by default, never generates numbers); rejected scope binding; booklet 2 markdown re-anchored (revision history in `MANIFEST.json`). |
| 80 | |
| 81 | ## Phase 9 UAT evidence (real source_1404.xlsx, read-only) |
| 82 | |
| 83 | `python scripts/uat_real_data.py --year 1404` on a fresh local DB: |
| 84 | - Import: **131,280 raw rows** preserved (4 anomalous rows skipped + reported). |
| 85 | - Auto-mapping from embedded note numbers: 22 notes, 244 mappings. |
| 86 | - Build: BS/IS/CF/EQ persisted; 1 unmapped ordinary account surfaced. |
| 87 | - Golden reconciliation: core balance-sheet notes match official **rial-for-rial** (÷10⁶ half-up): 10→673,740,637 · 11→242,194 · 12-1→13,386,398 · 12-2→8,310,168 · 13→6,839,535 · 14→11,273,650 · 15→19,951,136 (plus zero notes 17-1/17-2). Remaining BS/IS differences are surfaced as discrepancies (OD-08), never silently corrected; B8 records them one-by-one in `docs/discrepancies.json`. |
| 88 | - Approval gate: correctly **blocks** on real-data control failures (C-01/C-03/C-04) — fail-loud, no bypass. |
| 89 | - Export: XLSX (6.27 MB) + JSON with **158,050 lineage rows** (file/SHA-256/sheet/row). |
| 90 | - Backup: created + verified (hashes + audit chain); audit chain valid. |
| 91 | |
| 92 | ## Booklet 2.1 — R-task progress |
| 93 | |
| 94 | | Task | Scope | Status | |
| 95 | | --- | --- | --- | |
| 96 | | R1 | Real authentication (backend + frontend), backup confinement, desktop launch token, legacy surfaces | **MET** — PR #98 squash-merged 2026-12-04T09:38:06Z → `07a8ae0e` | |
| 97 | | R2 | Controls C-05..C-15 wired into `run_controls` + approval | **MET** — PR #100 squash-merged 2026-12-04T10:40:42Z → `a8ba20c1` | |
| 98 | | R3 | `build_statements` vs official; (statement, note) aggregation; IS 6/8/9 root cause; EQ/CF parsing | **PARTIAL** (this PR) — BS 16/16 met; IS 6/6 **not met**, blocked by source data (evidence below) | |
| 99 | | R4 | Remove `create_all` from the production path; backup → `alembic upgrade head` → trigger check | NOT_STARTED | |
| 100 | | R5 | `docs/c01_exceptions.json` — the six C-01 source rows, unapprovable until resolved | NOT_STARTED | |
| 101 | | R6 | Propose marking the `v1.0.0` Release as pre-release; `experiment/browser-edition` = owner action | NOT_STARTED | |
| 102 | |
| 103 | ### R1 acceptance ← evidence |
| 104 | |
| 105 | All R1 criteria are met; the full «معیار پذیرش ← شاهد» table is in the R1 PR report. |
| 106 | Witnesses: the 33 tests in `backend/tests/test_auth_r1.py`, the frontend vitest suite, |
| 107 | and `frontend/e2e/session.spec.ts` (CI starts uvicorn on a migrated throwaway DB with |
| 108 | `ARAM_E2E_BACKEND=1`). Migration `20261204_08` verified on a populated copy: 131,280 |
| 109 | ledger rows, 2 users, 28 triggers unchanged. |
| 110 | |
| 111 | Backend **354 passed** (was 319); frontend **15 vitest tests / 5 files**; ruff, mypy, tsc, eslint all clean. |
| 112 | |
| 113 | ### R2 acceptance ← evidence |
| 114 | |
| 115 | | معیار پذیرش | شاهد | |
| 116 | | --- | --- | |
| 117 | | C-05..C-15 implemented as pure functions with Persian messages and booklet 1 §7 severities | `backend/src/aram_backend/domain/controls.py` (`check_c05`…`check_c15`); `tests/test_controls_r2.py` positive + negative case per control | |
| 118 | | `run_controls` always returns the full set | `TestFullSet::test_fifteen_controls_always_present`; `test_domain_controls.py::test_stable_order`; `test_preflight.py::test_all_fifteen_controls_present` | |
| 119 | | Approval runs every ERROR control | `services/approval.py` → `build_control_context`; `TestCompleteYearThroughApi::test_all_fifteen_run_and_approval_succeeds` | |
| 120 | | Missing input ⇒ «اجرا نشد: دلیل» **and** approval blocked | `TestApprovalRejectsIncompleteControls`, `TestPreflightApi::test_approval_is_rejected_when_error_controls_did_not_run`; live 1404 preflight shows 8 unrun controls and `can_approve: false` | |
| 121 | | **15 controls visible in preflight** | `GET /api/v1/years/1/preflight` on the live 131,280-row DB → `controls: 15` (7.2 s); `TestPreflightApi::test_preflight_returns_fifteen_controls_with_ran_flags` | |
| 122 | | WARN never blocks; C-13 ERROR in CI / INFO in UI | `TestC13Official`, `TestC14SuddenChange::test_large_change_warns_not_blocks`, `TestFullSet::test_failing_warn_is_not_a_blocking_severity` | |
| 123 | |
| 124 | Backend **404 passed / exit 0** (was 354); frontend **17 vitest tests / 6 files**; ruff check + format, mypy (23 files), tsc, eslint, build all clean. |
| 125 | Decisions in **ADR-031**: unrun ≠ pass; explicit note roles (never inferred); refused approvals are audited; `POST /companies/{id}/years` so a prior year can actually be loaded. |
| 126 | Authored lines excl. tests/data: **968 / 1500**. |
| 127 | |
| 128 | ### R3 acceptance ← evidence |
| 129 | |
| 130 | | معیار پذیرش | شاهد | وضعیت | |
| 131 | | --- | --- | --- | |
| 132 | | Compare **`build_statements` output** (not a separate source aggregation) | `services/statement_compare.py` reads persisted `StatementLine` rows; `TestBuiltComparison` | MET | |
| 133 | | Aggregate by **(statement, note)** | `TestBuiltComparison::test_note_keys_are_scoped_by_statement` | MET | |
| 134 | | Display-sign policy per section/note; stored values untouched | ADR-032 §1/§4; `test_statement_build.py::test_bs_is_totals_and_signs`; no stored figure is modified by the comparison | MET | |
| 135 | | **BS 16/16** | live run on real 1404 (131,280 rows): all 16 notes Δ=0 | **MET** | |
| 136 | | **IS 6/6** | live run: 1/6 exact. 6 → Δ−2, 7 → Δ+1 (official per-category rounding), 8/9 → ±1,111,554 reclassification, 20-3 → no source rows at all | **NOT MET** | |
| 137 | | Root-cause IS 6/8/9 with account-by-account deltas | `docs/discrepancies.json` v2 (cause + official cell + accounts per entry); ADR-032 | MET | |
| 138 | | Finish EQ parsing + CF classification (46268 = account code) | `TestOfficialParsing`: EQ 0 → 24 figures; `test_cf_account_code_is_not_treated_as_a_note` | MET (parsing); CF/EQ still not rendered | |
| 139 | | Regenerate `discrepancies.json` | `docs/discrepancies.json` regenerated from built output, 11 caused entries | MET | |
| 140 | |
| 141 | **Why IS 6/6 cannot be met from this source:** official note 20-3 (tax −4,697,329) has no |
| 142 | corresponding row in `source_1404.xlsx`. Notes 8+9 combined match exactly (−9,057,668); only |
| 143 | their split differs, and the official's own adjustment column records exactly ±1,111,554. |
| 144 | No tolerance was invented and no figure was adjusted to force a match (booklet 2.1: MET only |
| 145 | when acceptance fully holds). |
| 146 | |
| 147 | Three real engine defects were found and fixed by measuring against the official workbook: |
| 148 | `statement_balance` is debit-positive (not pre-signed), the CLOSING fallback leaked |
| 149 | non-statement rows (BS 6/16 → 16/16), and per-row note assignment was lost (migration |
| 150 | `20261204_09`). Decisions in **ADR-032**. |
| 151 | |
| 152 | ## Known gaps feeding the C-phases (honest residual risks) |
| 153 | |
| 154 | - **Authorization forgeability — CLOSED in R1 (2026-12-04, ADR-030).** Was: roles derived from a client-supplied `actor` body string; `"actor":"admin"` granted admin to anyone; most endpoints unguarded; approval open when no users existed; `pilot_api.py` exposed 17 unauthenticated routes. Now: `actor` removed from every request model; identity comes only from `current_user` resolving a 256-bit bearer token whose SHA-256 is stored server-side (8-hour absolute TTL, logout, 5-attempt lockout for 15 minutes, PBKDF2 600,000); every route except `/health`, `/auth/login`, `/auth/launch` and the one-time first-admin bootstrap requires a session, reads included; approval without users is impossible; the pilot router and the legacy `/` UI are out of the app; backup `dest` is confined to the data folder; the desktop launcher gates the local API with a one-time token. Evidence: `backend/tests/test_auth_r1.py` (33 tests). Remaining C8 scope: DPAPI vault, encrypted backup, plugin allowlist, row/field-level access layers. |
| 155 | - `frontend/src/lib/format.ts` uses `Number(value)` (float risk) (C7). |
| 156 | - ~~Only 4 of 15 controls implemented~~ — **closed by R2**: all C-01..C-15 run, an unrun ERROR blocks approval and reports «اجرا نشد: دلیل» (ADR-031). |
| 157 | - C-13 now has a feed (`official_comparisons` + `POST /years/{id}/official-comparison`, R3); it still reports «اجرا نشد» until an official workbook is supplied for the year. |
| 158 | - **Account natures are not populated** by any import path (`account_versions` is empty on real data), so C-15 reports «اجرا نشد» (WARN, non-blocking). A chart-of-accounts import is still missing. |
| 159 | - **CF/EQ are still not rendered** (`RENDERED_STATEMENTS=("BS","IS")`). Their official layouts are parsed (R3) but no built statement exists, so CF is 0/6 and C-07 compares their note totals against nothing → carried forward. |
| 160 | - **IS 8/9 need an explicit reclassification decision** (1,111,554 million rial) and **IS 20-3 has no source rows**; both are recorded with cause in `docs/discrepancies.json`. |
| 161 | - **Desktop install bypasses Alembic** (`desktop.py` `Base.metadata.create_all`); existing user DBs will not migrate on update → **R4** (booklet 2.1; was C9). R1 added migration `20261204_08` and verified it on a copy of a populated database (131,280 ledger rows, 2 users, 28 triggers unchanged), but the startup path still uses `create_all`. |
| 162 | - ImportRun/CalculationRun/LineageEdge/Adjustment/UnknownAccountQueue/carried_from_year_id/calculation_run_id refs absent; pilot exception queue not persisted in `domain/` (C1/C4). |
| 163 | - `note_engine.acct()` is closing-only; statement_balance-only rows evaluate 0 in notes (C1/C3). |
| 164 | - No connector framework / Source Adapter / snapshot reconciliation / packs yet; generality grep test pending (C4/C5/C6). |
| 165 | - CI: prod-dependency `npm audit --omit=dev --audit-level=moderate` gate + initial frontend coverage gate (thresholds lines/statements 30, branches 70, functions 40 vs measured 33.97/72.97/42.85) + repo-wide pre-commit/secret-gate/Dependabot added by the 2026-12-04 tooling PR (frontend coverage + audit in Frontend CI; `Repo Hygiene` workflow runs pre-commit + detect-secrets baseline gate on every PR). Dev-only advisories in the vitest/vite chain (tinypool ×2 critical, vite high, esbuild/@vitest/mocker/vite-node moderate — none shipped; prod audit clean) await a dedicated vitest+vite major-upgrade task. **The 80/90 frontend coverage target and services-mypy strictness remain open (C9).** |
| 166 | - Backup unencrypted; no DPAPI vault / plugin allowlist / SBOM yet (C8/C9). |
| 167 | - Browser edition removed (C0); single reference UI = React workbench. Backend `static/pilot` files remain in the tree but are no longer served or mounted (R1); the pilot router keeps the `current_user` dependency and is exercised only by a test-only app. |
| 168 | - Windows EXE not built; clean-machine install log + Shadow Run two-company + owner signature pending (C9/C10). |
| 169 | - `docs/discrepancies.json` now records all 19 golden-1404 differences with cause+evidence (الف7 met); 3 IS magnitude mismatches remain under investigation (bugs until proven, D1) and build-vs-official comparison is added in C3. |
| 170 | - **PR-discipline violation recorded (independent review):** merged PR #96 bundled all 10 phases in one PR (154 files, +24,327 lines ≈ 16× the الف5 cap), its body cited a stale head (`969f608` vs merged `babe829`), and it merged without independent review under a one-time owner waiver. Historical; cannot be un-merged. Booklet 2 الف4/الف5 now enforced in `AGENTS.md` for all future PRs. |
| 171 | - Booklet 1 markdown is a token-reversal PDF extraction (ADR-025): RTL/English-code artifacts possible; the original PDF SHA-256 is the authoritative anchor. A faithful re-extraction awaits a docx original or a better bidi method (owner option). |
| 172 | |
| 173 | ## Release procedure (owner) |
| 174 | |
| 175 | The implementation author does **not** merge or tag (§19 / booklet 2 §16). Tag `v1.0.0` already exists on `46253c9` (owner-authorized pre-mission). After C0…C9 acceptance, prepare the release checklist here (owner tags, retained artifact, clean-machine offline install log, SBOM/signing); final acceptance is **C10**: Shadow Run on a real period of two companies + owner signature (booklet 2 §15). Do not tag. Git-history rewrite / large-file external migration stays BLOCKED absent an explicit owner directive (C9). |
| 176 | |
| 177 | ## Control documents |
| 178 | |
| 179 | - [Project log](docs/PROJECT_LOG.md) |
| 180 | - [Decision log](docs/DECISION_LOG.md) |
| 181 | - [Acceptance policy](docs/ACCEPTANCE_POLICY.md) |
| 182 | - [Booklet v1.0 (reference)](docs/booklet/BOOKLET_v1.0.md) · [Booklet v2.0 (course correction)](docs/booklet/BOOKLET_v2.0.md) · [manifest](docs/booklet/MANIFEST.json) |
| 183 | - [PR triage (الف6)](docs/PR_TRIAGE.md) |
| 184 | - [Discrepancy registry (skeleton)](docs/discrepancies.json) |
| 185 | - [Archived analytical documents](docs/archive/README.md) |
| 186 | - [Master recovery prompt](docs/handoff/MASTER_RECOVERY_PROMPT.md) |
| 187 | - [Latest handoff snapshot](docs/handoff/LATEST_HANDOFF.md) |
| 188 | - [Saveable ChatGPT bootstrap prompt](docs/handoff/CHATGPT_BOOTSTRAP_PROMPT.txt) |