@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / ff5fb9a
Fork 0

سامانه صدور فاکتور و حسابداری

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 3, 22:00 UTC

Record production license gate evidence

davoodmehraban89 committed Sep 29, 2026 at 22:24 UTC ff5fb9a7041634e6f7df953b09082cdcbd842867
1 file changed +1 -1
PROJECT_STATE.md
+1 -1
@@ -32,7 +32,7 @@ Before doing any project work:
32 10. If this file conflicts with verified remote code/database evidence, correct this file immediately and record the correction in the change ledger.
33
34 ## Current change ledger
35 -| 2026-09-29 | Reconcile the D.M/Finora source contract against the implemented product and execute the post-release high-assurance hardening backlog (60-item audit), beginning with accounting-core safety and closing verified requirement gaps such as company-type starter charts, floating analytic dimensions and account-chart import. Preserve the generic normalized dimension engine; expose the owner-agreed four floating analytic slots as a compatible product contract. No destructive historical cutover or schema/RLS/auth/role mutation without the required explicit approval. | IN PROGRESS | Baseline: main `9159108a`; Supabase ACTIVE_HEALTHY with 15 migrations and RLS on all public tables. D.M source confirms GL/معین/تفصیلی + four configurable floating slots while storage remains generic. Core checkpoint `a22422bd`: safe empty-chart Excel import/validation/template helpers; compatible slots Branch=1, Counterparty=2, Project=3, Contract=4; Contract entity-backed dimension; contracting Project+Contract rules; template v2 and posting-profile seeding hook. UI checkpoint `f65fb577`: accounting UI now exposes safe Chart-of-Accounts Excel import/template download, explicit four-slot compatibility guidance, and Contract as an entity-backed analytic source. Rendering checkpoint `fdf65e49`: configured slot numbers are now visible as تفصیلی شناور ۱..۴ while generic dimensions remain unlimited. Posting checkpoint `e6067b83`: generic posting context now carries `contractId` for entity-backed Contract dimensions. Phase 4 checkpoint `39470402`: contractor statement postings now pass the active contract identity into analytic assignment. Test checkpoint `87dcf6e9`: Phase 2 gate now behavior-tests valid Excel chart normalization and invalid-parent rejection, and statically gates four-slot/Contract UI + posting integration. A1 negative-test checkpoint `f7d9b033`: behavior gate now explicitly rejects unbalanced journals, missing required analytic dimensions and non-postable analytic values, in addition to existing duplicate-source, reversal and fiscal-lock scenarios. Contract traceability test checkpoint `2d433cf3`: Phase 4 behavior gate now requires both Project and Contract analytic identities on every contractor statement posting line. Account-classification checkpoint `d7b7274b`: chart masters now persist account type/classification for templates, manual creation and Excel imports, aligned with the source Account entity. UI checkpoint `4eb0a451`: chart editor now explicitly captures asset/liability/equity/revenue/expense/memorandum/control account type. Chart table checkpoint `8a7996a2`: account type is now a first-class visible chart column. Row-render checkpoint `9008ec4f`: account classifications are rendered in the chart with legacy-safe fallback. Account-type gate `e8926876`: Phase 2 acceptance now requires classification logic, UI field/table column and import normalization. Security read-only review: production RLS policies are owner-scoped for `records` and admin/self-scoped for profiles/licenses; all 5 warned SECURITY DEFINER functions pin `search_path=public`, and the 3 admin mutation RPCs internally call `is_admin()` before mutation. Therefore advisor warnings are not by themselves proof of privilege escalation; authenticated cross-user negative E2E remains NOT VERIFIED. No RLS/auth/role change was made. Security workflow review: `Dependency review` is intentionally guarded by `if: github.event_name == 'pull_request'`; its skipped status on the prior push run is expected, not a failed security gate. CodeQL remains the push security gate. Starter-chart checkpoint `1a92a060`: added recoverable VAT (`1108 مالیات و عوارض دریافتنی`) so purchase VAT can resolve to a dedicated debit account instead of being folded into gross purchase cost. VAT account gate `40042e80` now prevents regression of the recoverable-VAT starter account. Critical restore/immutability checkpoint `4e5ad967`: `absorbRecords` now stages the entire merge and swaps datastore only after all validation succeeds (atomic in-memory restore); conflicts now protect posted/reversed vouchers, their journal lines/dimensions, posted source records, posted/reversed contract statements, posted inventory/depreciation records and audit rows. This closes a real partial-restore/posted-history overwrite risk in client restore logic. Restore regression gate `8aec35b8`: Phase 5 behavior test now proves a conflicting posted journal restore is rejected, earlier mutable changes are rolled back atomically, and a safe mutable merge still succeeds. Master-data checkpoint `42178d64` + gate `4c216040`: accounts referenced by automatic posting profiles can no longer be deleted, closing a setup-integrity hole before first journal use. Critical source-posting fix `6bb2dabd`: expense/income entry previously only wrote an operational record and ignored the selected counterparty/project; it now persists company/date/contact/project context and atomically creates the corresponding journal voucher, rolling the source back if posting fails. Source-posting gate `a10bcf64`: Phase 3 behavior now requires successful balanced posting for both expense and other-income sources. Reversal/immutability checkpoint `5b10463e` + gate `d0c61db6`: source records remain immutable after their voucher is reversed and cannot be silently reposted under the same source identity/version; corrections must use a new corrective source. This closes the UI-level post-reversal rewrite hole. Server-side source immutability beyond journal/Phase5 triggers still requires a DB migration and therefore explicit schema-change approval. Real-DOM gate checkpoint `423e38a6`: Chromium smoke now enters the accounting foundation and asserts the Chart-of-Accounts Excel import surface, four-slot contract guidance, account-type control and Contract dimension source before continuing existing ERP/report smoke. Prepared-but-NOT-APPLIED migration `20260929190000_posted_source_immutability_guard.sql` at `c5241502` to enforce source-document immutability server-side for invoices/purchases/payments/expenses/contract statements linked to posted/reversed accounting history. Applying it is intentionally blocked pending explicit schema-change approval. Phase 3 static gate `d4ed8811` now requires expense/income posting semantics, reversed-source locking, and the prepared server immutability migration to remain present. Production RLS negative read test executed safely with transaction-local `authenticated` role/JWT simulation for both record owners: owner A saw 46/46 own and 0 of owner B; owner B saw 39/39 own and 0 of owner A. This verifies cross-user SELECT isolation on live `records`; write isolation remains structurally enforced by WITH CHECK but not mutation-tested. Production privilege negative test executed: under transaction-local authenticated context a normal user resolved `is_admin=false`, while the known admin resolved `is_admin=true`; a normal-user call to `admin_cancel_license` was rejected with PostgreSQL `42501 forbidden` before mutation. This materially validates the internal authorization guard behind the SECURITY DEFINER warning; the other admin RPCs use the same `is_admin()` precondition but were not mutation-called. CI execution remains NOT VERIFIED. |
35 +| 2026-09-29 | Reconcile the D.M/Finora source contract against the implemented product and execute the post-release high-assurance hardening backlog (60-item audit), beginning with accounting-core safety and closing verified requirement gaps such as company-type starter charts, floating analytic dimensions and account-chart import. Preserve the generic normalized dimension engine; expose the owner-agreed four floating analytic slots as a compatible product contract. No destructive historical cutover or schema/RLS/auth/role mutation without the required explicit approval. | IN PROGRESS | Baseline: main `9159108a`; Supabase ACTIVE_HEALTHY with 15 migrations and RLS on all public tables. D.M source confirms GL/معین/تفصیلی + four configurable floating slots while storage remains generic. Core checkpoint `a22422bd`: safe empty-chart Excel import/validation/template helpers; compatible slots Branch=1, Counterparty=2, Project=3, Contract=4; Contract entity-backed dimension; contracting Project+Contract rules; template v2 and posting-profile seeding hook. UI checkpoint `f65fb577`: accounting UI now exposes safe Chart-of-Accounts Excel import/template download, explicit four-slot compatibility guidance, and Contract as an entity-backed analytic source. Rendering checkpoint `fdf65e49`: configured slot numbers are now visible as تفصیلی شناور ۱..۴ while generic dimensions remain unlimited. Posting checkpoint `e6067b83`: generic posting context now carries `contractId` for entity-backed Contract dimensions. Phase 4 checkpoint `39470402`: contractor statement postings now pass the active contract identity into analytic assignment. Test checkpoint `87dcf6e9`: Phase 2 gate now behavior-tests valid Excel chart normalization and invalid-parent rejection, and statically gates four-slot/Contract UI + posting integration. A1 negative-test checkpoint `f7d9b033`: behavior gate now explicitly rejects unbalanced journals, missing required analytic dimensions and non-postable analytic values, in addition to existing duplicate-source, reversal and fiscal-lock scenarios. Contract traceability test checkpoint `2d433cf3`: Phase 4 behavior gate now requires both Project and Contract analytic identities on every contractor statement posting line. Account-classification checkpoint `d7b7274b`: chart masters now persist account type/classification for templates, manual creation and Excel imports, aligned with the source Account entity. UI checkpoint `4eb0a451`: chart editor now explicitly captures asset/liability/equity/revenue/expense/memorandum/control account type. Chart table checkpoint `8a7996a2`: account type is now a first-class visible chart column. Row-render checkpoint `9008ec4f`: account classifications are rendered in the chart with legacy-safe fallback. Account-type gate `e8926876`: Phase 2 acceptance now requires classification logic, UI field/table column and import normalization. Security read-only review: production RLS policies are owner-scoped for `records` and admin/self-scoped for profiles/licenses; all 5 warned SECURITY DEFINER functions pin `search_path=public`, and the 3 admin mutation RPCs internally call `is_admin()` before mutation. Therefore advisor warnings are not by themselves proof of privilege escalation; authenticated cross-user negative E2E remains NOT VERIFIED. No RLS/auth/role change was made. Security workflow review: `Dependency review` is intentionally guarded by `if: github.event_name == 'pull_request'`; its skipped status on the prior push run is expected, not a failed security gate. CodeQL remains the push security gate. Starter-chart checkpoint `1a92a060`: added recoverable VAT (`1108 مالیات و عوارض دریافتنی`) so purchase VAT can resolve to a dedicated debit account instead of being folded into gross purchase cost. VAT account gate `40042e80` now prevents regression of the recoverable-VAT starter account. Critical restore/immutability checkpoint `4e5ad967`: `absorbRecords` now stages the entire merge and swaps datastore only after all validation succeeds (atomic in-memory restore); conflicts now protect posted/reversed vouchers, their journal lines/dimensions, posted source records, posted/reversed contract statements, posted inventory/depreciation records and audit rows. This closes a real partial-restore/posted-history overwrite risk in client restore logic. Restore regression gate `8aec35b8`: Phase 5 behavior test now proves a conflicting posted journal restore is rejected, earlier mutable changes are rolled back atomically, and a safe mutable merge still succeeds. Master-data checkpoint `42178d64` + gate `4c216040`: accounts referenced by automatic posting profiles can no longer be deleted, closing a setup-integrity hole before first journal use. Critical source-posting fix `6bb2dabd`: expense/income entry previously only wrote an operational record and ignored the selected counterparty/project; it now persists company/date/contact/project context and atomically creates the corresponding journal voucher, rolling the source back if posting fails. Source-posting gate `a10bcf64`: Phase 3 behavior now requires successful balanced posting for both expense and other-income sources. Reversal/immutability checkpoint `5b10463e` + gate `d0c61db6`: source records remain immutable after their voucher is reversed and cannot be silently reposted under the same source identity/version; corrections must use a new corrective source. This closes the UI-level post-reversal rewrite hole. Server-side source immutability beyond journal/Phase5 triggers still requires a DB migration and therefore explicit schema-change approval. Real-DOM gate checkpoint `423e38a6`: Chromium smoke now enters the accounting foundation and asserts the Chart-of-Accounts Excel import surface, four-slot contract guidance, account-type control and Contract dimension source before continuing existing ERP/report smoke. Prepared-but-NOT-APPLIED migration `20260929190000_posted_source_immutability_guard.sql` at `c5241502` to enforce source-document immutability server-side for invoices/purchases/payments/expenses/contract statements linked to posted/reversed accounting history. Applying it is intentionally blocked pending explicit schema-change approval. Phase 3 static gate `d4ed8811` now requires expense/income posting semantics, reversed-source locking, and the prepared server immutability migration to remain present. Production RLS negative read test executed safely with transaction-local `authenticated` role/JWT simulation for both record owners: owner A saw 46/46 own and 0 of owner B; owner B saw 39/39 own and 0 of owner A. This verifies cross-user SELECT isolation on live `records`; write isolation remains structurally enforced by WITH CHECK but not mutation-tested. Production privilege negative test executed: under transaction-local authenticated context a normal user resolved `is_admin=false`, while the known admin resolved `is_admin=true`; a normal-user call to `admin_cancel_license` was rejected with PostgreSQL `42501 forbidden` before mutation. This materially validates the internal authorization guard behind the SECURITY DEFINER warning; the other admin RPCs use the same `is_admin()` precondition but were not mutation-called. Production license gate test: active monthly/lifetime contexts return active, current trial returns active, and the existing cancelled account returns `has_active_license=false`; expired-date behavior is present in the function predicate but no expired production fixture exists, so expired E2E remains NOT VERIFIED. CI execution remains NOT VERIFIED. |
36 | 2026-09-29 | Execute master roadmap Phase 5 end-to-end: inventory/warehouse and costing; item/service master refinement; fixed assets; multi-currency; cost centers/advanced analytics; Excel/import center; backup/restore; company settings/permissions redesign; integration/API architecture. Preserve Phase 1–4 accounting invariants and require real-DOM, accounting/domain behavior, security and deployment gates before completion. | COMPLETED | Owner granted standing authorization for in-scope repository/Supabase changes. Delivered refined goods/services master; explicit sales/purchase warehouse routing; warehouse master, immutable stock movements, transfers, stock counts and weighted-average costing; valued inventory-adjustment journals; fixed assets and balanced depreciation journals; currency/rate masters; cost-center analytic source; company operational settings and explicit owner-RLS permission boundary; validated full restore with posted-history conflict protection; v5 backup/import preview; integration metadata/outbox without browser secrets; Phase 5 audit/navigation/sync/backup. Production migration `20260929172129_phase5_complementary_erp_collections` applied and archived under the exact production version; collection constraint, posted-record immutability trigger and five uniqueness indexes verified; records RLS remains enabled/owner-scoped; performance advisor clean. Import/restore hardening then added controlled validated merge (`16796d3d`, `ae40f5dc`, `4ede2d15`, `ce4c7dcb`); its first gate exposed a quoting syntax regression, fixed at `6abf95ca`. Final code-head verification at `6abf95ca`: Quality `36606240438` PASS including syntax, Phase 2–5 invariants/behavior and real Chromium DOM; Security/CodeQL `36606240384` PASS; Pages `36606238776` PASS. Authenticated production-user E2E, live third-party webhook delivery and physical-printer validation remain NOT VERIFIED and are not Phase 5 acceptance gates. |
37 | 2026-09-29 | Adopt owner-specified high-assurance execution protocol: verify live GitHub/Supabase before work; latest chat is the only source of new instructions; record requests before implementation; vertical slices; PROJECT_STATE in every durable commit; archive every future Supabase migration SQL; require real-DOM smoke + accounting-invariant tests before COMPLETED; explicitly list NOT VERIFIED items. | COMPLETED | Live reconciliation found head `7d054dfa` (post-login/admin-shell fix) was not recorded here; its CI is green but real-DOM smoke was not run. Phase 4 CI workflow also did not actually execute `phase4-behavior-check.mjs` because the command was folded onto the Phase 3 command, and no `supabase/migrations/` SQL archive exists. Phase 4 completion is therefore reopened pending real-DOM + accounting-invariant verification. Verification slice prepared atomically: corrected CI command separation, strengthened Phase 4 posting/reversal accounting test, added Playwright real-DOM post-login/shell smoke, and backfilled exact historical SQL files from `supabase_migrations.schema_migrations`. No database/schema/RLS/auth/role mutation was performed. Verification slice commit `55b62db0`: all 14 existing Supabase migration statements were archived exactly from migration history under `supabase/migrations/`; no database mutation occurred. Quality run `36600894426` succeeded, including Phase 3 behavior, actual Phase 4 accounting invariants and Playwright real-DOM smoke; Security/CodeQL `36600894268` succeeded; Pages `36600893196` succeeded. Live head discrepancy `7d054dfa` is now accounted for. Authenticated production-user E2E and physical-printer validation remain NOT VERIFIED. Live reconciliation before Phase 5: current head `deedea67` is documentation-only (`PROJECT_STATE.md`); Quality `36601108479` and Security `36601108485` succeeded on its parent `312fe95a`. Pages run `36601106234` on that parent failed only after a manual partial rerun created two `github-pages` artifacts; last clean Pages deployment remains `36600893196` on `55b62db0`. Head Pages run `36601145056` was cancelled. This deployment discrepancy is recorded and must be cleared by the next normal code commit/deployment before Phase 5 completion. |
38 | 2026-09-29 | Execute master roadmap Phase 4 end-to-end: projects/contracts, amendments/lifecycle, employer/contractor/subcontractor links, deductions, guarantees, contractor statements/accounting, traceability, reporting, permissions/audit/sync/backup/migration/tests/reconciliation. | COMPLETED | Re-accepted under the stricter verification rule at `55b62db0`: Playwright real-DOM smoke PASS and Phase 4 accounting invariants PASS in Quality `36600894426`; Security `36600894268` PASS; Pages `36600893196` PASS. Prior implementation evidence: domain/UI `c2100228`; persistence/navigation/backup through `172aeb59`; referential guards `44154769`; behavioral CI gate `fe29b817`; deduction-specific accounting/template migration `dd3b78ed`; verification doc `e5b814a7`. Supabase migration `20260929091743 phase4_contracting_collections` applied; RLS owner isolation verified; production had zero pre-existing Phase 4 rows requiring backfill; performance advisor clean; known pre-existing security warnings unchanged. Acceptance checkpoint `95e6de99`: Quality 36549015911 success; Security/CodeQL 36549015935 success; Pages 36549015796 success. |