@davoodmehraban89 / Factor-easy / commits / 4a1c827
Fork 0

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

docs: close D2 and checkpoint D3 continuation

davoodmehraban89 committed Oct 1, 2026 at 22:45 UTC 4a1c8278a01246cdcd419ff40f895761d945bea6
1 file changed +19 -19
PROJECT_STATE.md
+19 -19
@@ -14,24 +14,23 @@ This is high-assurance accounting/ERP software. Posted financial history, tenant
14 ## Current change ledger
15 | Date | Request / decision | Status | Evidence / next action |
16 |---|---|---|---|
17 -| 2026-10-01 | Owner said «ادامه بده» after D1 closure. | **EXECUTION IN PROGRESS** | Execute D2 UI/read-model cutover: server-authorized D1 request definitions/runtime, version publishing, draft/published visibility, DOM/security coverage; preserve legacy data until cutover verification. |
18 -| 2026-10-01 | Owner said «ادامه بده» after Slice D design. | **EXECUTION IN PROGRESS** | Slice D1 is closed. Continue with D2 UI/read-model cutover, preserving legacy data until migration/cutover is explicitly verified. |
17 +| 2026-10-01 | Owner said «ادامه بده» after D1 closure. | **D2 VERIFIED; CONTINUE D3** | D2 server UI/read-model cutover, non-destructive legacy migration, real-DOM tests and FK-index hardening are verified. Continue with bounded D3 workflow semantics/design rather than expanding legacy record-store behavior. |
18 +| 2026-10-01 | Slice D2 — request UI/read-model + legacy cutover. | **IMPLEMENTED / PRODUCTION + DISPOSABLE-DB + REAL-DOM + CI VERIFIED** | `js/request-workflow-d2.js`; migrations `20261001223500`, `20261001224500`; Quality run `36912668369` all three jobs SUCCESS including D2 real-DOM and disposable PostgreSQL assertions. Production reconciliation preserved 2 legacy types + 4 legacy requests and imported 2 definitions + 2 versions + 4 instances + 4 immutable import events. Evidence: `docs/REQUEST_WORKFLOW_D2_CUTOVER_VERIFICATION.md`. |
19 | 2026-10-01 | Slice D1 — requests/BPMS-lite server foundation. | **IMPLEMENTED / PRODUCTION + DISPOSABLE-DB + CI VERIFIED** | Migrations `20261001204500`, `20261001205500`, `20261001210500`, `20261001211500`; production RLS/RPC/security verified. Quality run `36910187257`: `static-quality`, `c8-policy-database`, and new `d1-request-database` all SUCCESS. The D1 DB test caught an ambiguous PL/pgSQL `revision` reference; it was fixed by qualification and the production private RPC was hardened with the same migration. |
20 -| 2026-10-01 | Office Slice C8: versioned correspondence workflow policy + runtime. | **IMPLEMENTED / PRODUCTION + ADVERSARIAL + CONCURRENCY + REAL-DOM + SECURITY VERIFIED** | Production migrations `20261001173917`, `20261001180610`, `20261001180949`; immutable workflow evidence, pinned policy versions, capability-gated transitions, optimistic revision checks, idempotent request IDs, private runtime tables, SECURITY INVOKER public wrappers, two-session race test and safe runtime UI. Evidence: `docs/OFFICE_SLICE_C8_WORKFLOW_RUNTIME_VERIFICATION.md` and `docs/OFFICE_SLICE_C8_RUNTIME_UI_VERIFICATION.md`. |
20 +| 2026-10-01 | Office Slice C8: versioned correspondence workflow policy + runtime. | **IMPLEMENTED / PRODUCTION + ADVERSARIAL + CONCURRENCY + REAL-DOM + SECURITY VERIFIED** | Production migrations `20261001173917`, `20261001180610`, `20261001180949`; immutable workflow evidence, pinned policy versions, capability-gated transitions, optimistic revision checks, idempotent request IDs, private runtime tables, SECURITY INVOKER public wrappers, two-session race test and safe correspondence workflow UI. Evidence: `docs/OFFICE_SLICE_C8_WORKFLOW_RUNTIME_VERIFICATION.md` and `docs/OFFICE_SLICE_C8_RUNTIME_UI_VERIFICATION.md`. |
21 | 2026-10-01 | Owner reconfirmed autonomous GitHub + Supabase execution and five-specialist operating model. | **ACTIVE OPERATING DIRECTIVE** | No repeated routine approval requests. Preserve the safety/cost boundaries above. |
22 | 2026-10-01 | Free-tier-only development/verification. | **ACTIVE OPERATING DIRECTIVE** | No paid Supabase branch or other billable development resource. |
23 -| 2026-10-01 | Live QA: commerce/tax IDs/request builder/personnel/license/floating-detail coding. | **PARTIALLY IMPLEMENTED / FOLLOW-UPS OPEN** | Kardex/tax-ID/request-draft/profile/license/floating-code work landed before C8. Exact Taxpayer-System print layout still waits for owner reference images. Legacy record-store request builder remains until D2 cutover; do not treat its UI-only configure restriction as the final security boundary. |
23 +| 2026-10-01 | Live QA: commerce/tax IDs/request builder/personnel/license/floating-detail coding. | **PARTIALLY IMPLEMENTED / FOLLOW-UPS OPEN** | Kardex/tax-ID/request/profile/license/floating-code work landed. Exact Taxpayer-System print layout still waits for owner reference images. Request builder/runtime now uses D1/D2 server model; legacy records remain preserved only for rollback/audit. |
24 | 2026-09-30—2026-10-01 | Office C1–C7, ELI-1–ELI-4, Slice A/B and accounting phases 1–6. | **VERIFIED WITH DOCUMENTED BOUNDARIES** | See required evidence below; do not redo completed phases without verified regression evidence. |
25 | 2026-09-30 | Iran-first high-assurance ERP expansion. | **IN PROGRESS — BROADER ROADMAP** | `docs/IRAN_COMPLIANCE_MATRIX_V1.md`; do not claim statutory consolidation/full tax submission/full HR/CRM until lifecycle/accounting/permissions/tests exist. |
26
27 -## Live reconciliation — 2026-10-01 after D1 verification
28 -- Verified D1 implementation commit before this continuity-only checkpoint: `4e65a6feaa8b8c0f0be4f1afa9078d281eb7871c`.
29 -- Quality run `36910187257`: D1 static contracts, all existing static/DOM regression tests, C8 disposable DB suite and D1 disposable PostgreSQL behavioral suite succeeded.
30 -- D1 disposable DB covers immutable version snapshots, version pinning, idempotent create/retry, expected-revision stale rejection, correct pre/post transition evidence, configure denial, direct-write denial, event tamper denial and cross-tenant read isolation.
31 -- Supabase project `hcsixhqbyuhpshfwqpjx`: `request_type_definitions`, `request_type_versions`, `request_workflow_versions`, `request_instances`, `request_instance_events` exist; request-instance RLS is enabled; `anon` and `authenticated` direct INSERT privileges are absent.
32 -- Request RPCs exist in public as SECURITY INVOKER wrappers and in private as SECURITY DEFINER implementations. `anon` cannot execute either; authenticated execution is explicitly granted. Privileged implementation checks organization membership, active `requests_workflow` entitlement and capability before mutation.
33 -- D1 production security-advisor result: the three new request RPCs no longer appear in the public SECURITY DEFINER warning list; count returned from 23 to the pre-existing 20. Existing C8 private-table RLS informational notices and leaked-password protection warning remain open.
34 -- C8 remains closed for its bounded internal correspondence-workflow scope; D1 request workflow state is separate and does not reuse correspondence runtime tables.
27 +## Live reconciliation — 2026-10-01 after D2 verification
28 +- Verified D2 code/quality commit: `ef3e9c1c9e580ab273beb6372027523a9aec03ca`; Quality run `36912668369`: `static-quality`, `c8-policy-database`, and `d1-request-database` all SUCCESS. Real DOM smoke includes D2 publish/create/retry/stale-revision/configure-denial coverage.
29 +- Production Supabase project `hcsixhqbyuhpshfwqpjx`: legacy source records remain intact (2 requestTypes, 4 requests); D1/D2 contains 2 migrated definitions, 2 immutable type versions, 4 migrated instances and 4 `legacy_import` events. No destructive legacy cleanup was performed.
30 +- Production request RPCs remain public SECURITY INVOKER wrappers with private privileged implementations. D2 UI uses those RPCs for publish/create and uses D1 tables as its read model.
31 +- Production security advisor after D2: no new request-workflow security warning; pre-existing 20 public SECURITY DEFINER warnings, C8 private RLS informational notices and leaked-password protection warning remain open.
32 +- Production performance advisor initially identified 8 uncovered request-workflow foreign keys; `20261001224500_request_workflow_d2_fk_indexes.sql` was applied and a fresh advisor run eliminated the unindexed-FK findings. Newly created indexes appear only as expected unused-index informational findings on the low-traffic dataset.
33 +- C8 correspondence workflow remains separate from Requests; request workflow state does not replace C1 registration or C5 approval evidence.
34
35 ## Implemented foundations
36 - Accounting phases 1–6: accepted high-assurance accounting foundation; posted history remains immutable and balanced.
@@ -41,25 +40,26 @@ This is high-assurance accounting/ERP software. Posted financial history, tenant
40 - Office C1–C7: immutable registration/read evidence, referrals, related-letter/archive classification, numbering/template repair, approvals, SLA evidence, full-text archive/OCR provenance boundary.
41 - Office C8: versioned workflow policies, immutable runtime transition history, idempotent/concurrency-safe server operations and safe correspondence workflow UI.
42 - Requests D1: independent versioned request definition/form/workflow foundation, pinned workflow version per instance, idempotent create, expected-revision transition, immutable action evidence, tenant/module/capability checks, non-exposed privileged implementation functions and a disposable PostgreSQL behavioral gate.
43 +- Requests D2: server-backed request builder/runtime UI, immutable version publishing, retry-safe create, stale-revision recovery, capability-gated configure UI, non-destructive legacy import and traceability.
44
45 ## Invariants
46 -Posted accounting history is immutable and balanced; tenant isolation is enforced at the data boundary; commercial entitlement and member authorization are independent; UI hiding is never security; expired licenses are read-only; office numbering is server-atomic; private scans remain private; seat/company limits are server-enforced; delegated customer admins cannot mutate commercial license entitlements; invitation acceptance is authenticated/email-bound/seat-safe; raw invitation tokens are never persisted or audited; organization-unit parents cannot cross tenants or form cycles; referral targets must already be authorized to read the source correspondence; OCR provenance must reference a real attachment belonging to the same organization/correspondence; C8 workflow policy is pinned per correspondence instance and its evidence is append-only. D1 request type versions are immutable snapshots; request instances pin both request-type and workflow versions; runtime mutation is server-authorized, idempotency/revision guarded and append-only evidence is retained. Request workflow state never replaces C1 registration status or C5 correspondence approval evidence.
46 +Posted accounting history is immutable and balanced; tenant isolation is enforced at the data boundary; commercial entitlement and member authorization are independent; UI hiding is never security; expired licenses are read-only; office numbering is server-atomic; private scans remain private; seat/company limits are server-enforced; delegated customer admins cannot mutate commercial license entitlements; invitation acceptance is authenticated/email-bound/seat-safe; raw invitation tokens are never persisted or audited; organization-unit parents cannot cross tenants or form cycles; referral targets must already be authorized to read the source correspondence; OCR provenance must reference a real attachment belonging to the same organization/correspondence; C8 workflow policy is pinned per correspondence instance and its evidence is append-only. D1 request type versions are immutable snapshots; request instances pin both request-type and workflow versions; runtime mutation is server-authorized, idempotency/revision guarded and append-only evidence is retained. D2 legacy import is non-destructive/idempotent/traceable. Request workflow state never replaces C1 registration status or C5 correspondence approval evidence.
47
48 ## Required evidence
49 -`docs/PHASE_1_REDESIGN_VERIFICATION.md` · `docs/PHASE_2_REDESIGN_VERIFICATION.md` · `docs/PHASE_3_REDESIGN_VERIFICATION.md` · `docs/PHASE_4_REDESIGN_VERIFICATION.md` · `docs/PHASE_5_VERIFICATION.md` · `docs/PHASE_6_VERIFICATION.md` · `docs/PHASE_6_CUTOVER_MANIFEST.md` · `docs/PRODUCTION_ACCOUNTING_CUTOVER_READINESS_2026-09-30.md` · `docs/IRAN_COMPLIANCE_MATRIX_V1.md` · `docs/FINORA_ERP_EXPANSION_ROADMAP_V4.md` · `docs/FINORA_UX_ACCOUNTING_BENCHMARK_V3.md` · `docs/FINORA_MODULAR_ERP_OFFICE_AUTOMATION_V1.md` · `docs/SLICE_B_TENANT_RBAC_VERIFICATION.md` · `docs/SECURITY_DEFINER_HARDENING_2026-09-30.md` · `docs/CURRENT_STAGE_GAP_REGISTER_2026-09-30.md` · `docs/ELI_1_ENTERPRISE_LICENSE_VERIFICATION.md` · `docs/ELI_2_REUSABLE_ROLES_VERIFICATION.md` · `docs/ELI_3_INVITATIONS_VERIFICATION.md` · `docs/ELI_4_ENTERPRISE_ORGANIZATION_UX_VERIFICATION.md` · `docs/OFFICE_SLICE_C1_VERIFICATION.md` through `docs/OFFICE_SLICE_C7_VERIFICATION.md` · `docs/OFFICE_SLICE_C8_WORKFLOW_RUNTIME_VERIFICATION.md` · `docs/OFFICE_SLICE_C8_RUNTIME_UI_VERIFICATION.md` · `docs/PRODUCTION_RUNBOOK.md` · `supabase/migrations/` · `supabase/tests/request_d1_bootstrap.sql` · `supabase/tests/request_d1_behavior.sql`.
49 +`docs/PHASE_1_REDESIGN_VERIFICATION.md` · `docs/PHASE_2_REDESIGN_VERIFICATION.md` · `docs/PHASE_3_REDESIGN_VERIFICATION.md` · `docs/PHASE_4_REDESIGN_VERIFICATION.md` · `docs/PHASE_5_VERIFICATION.md` · `docs/PHASE_6_VERIFICATION.md` · `docs/PHASE_6_CUTOVER_MANIFEST.md` · `docs/PRODUCTION_ACCOUNTING_CUTOVER_READINESS_2026-09-30.md` · `docs/IRAN_COMPLIANCE_MATRIX_V1.md` · `docs/FINORA_ERP_EXPANSION_ROADMAP_V4.md` · `docs/FINORA_UX_ACCOUNTING_BENCHMARK_V3.md` · `docs/FINORA_MODULAR_ERP_OFFICE_AUTOMATION_V1.md` · `docs/SLICE_B_TENANT_RBAC_VERIFICATION.md` · `docs/SECURITY_DEFINER_HARDENING_2026-09-30.md` · `docs/CURRENT_STAGE_GAP_REGISTER_2026-09-30.md` · `docs/ELI_1_ENTERPRISE_LICENSE_VERIFICATION.md` · `docs/ELI_2_REUSABLE_ROLES_VERIFICATION.md` · `docs/ELI_3_INVITATIONS_VERIFICATION.md` · `docs/ELI_4_ENTERPRISE_ORGANIZATION_UX_VERIFICATION.md` · `docs/OFFICE_SLICE_C1_VERIFICATION.md` through `docs/OFFICE_SLICE_C7_VERIFICATION.md` · `docs/OFFICE_SLICE_C8_WORKFLOW_RUNTIME_VERIFICATION.md` · `docs/OFFICE_SLICE_C8_RUNTIME_UI_VERIFICATION.md` · `docs/REQUEST_WORKFLOW_D2_CUTOVER_VERIFICATION.md` · `docs/PRODUCTION_RUNBOOK.md` · `supabase/migrations/` · `supabase/tests/request_d1_bootstrap.sql` · `supabase/tests/request_d1_behavior.sql` · `supabase/tests/request_d2_legacy_seed.sql` · `supabase/tests/request_d2_legacy_behavior.sql`.
50
51 ## NOT VERIFIED / external boundary
52 -D1 real browser workflow UX and multi-user approval journey are not yet implemented. Authenticated two-real-user production browser E2E with a persistent legitimate non-owner member; automatic external invitation email delivery; owner-approved accounting cutover; real Persian OCR accuracy/provider; qualified digital signature; physical printer; live external adapters; GitHub Dependency graph/enforceable dependency review; leaked-password protection; PostgreSQL upgrade; CodeQL v4 migration; external BPM/provider integration remain outside verified scope.
52 +D3 visual/parallel workflow semantics and multi-user approval journey are not yet implemented. Authenticated two-real-user production browser E2E with a persistent legitimate non-owner member; automatic external invitation email delivery; owner-approved accounting cutover; real Persian OCR accuracy/provider; qualified digital signature; physical printer; live external adapters; GitHub Dependency graph/enforceable dependency review; leaked-password protection; PostgreSQL upgrade; CodeQL v4 migration; external BPM/provider integration remain outside verified scope.
53
54 ## Exact next executable work
55 -1. D2: migrate the request builder/runtime UI from legacy `records` requestTypes/requests to the server-authorized D1 RPC/read model; add version publishing and visible draft/published state without deleting historical legacy data.
56 -2. Add D2 real-DOM coverage for publish/create/retry/stale-revision/error surfaces and ensure users without `configure` cannot reach publishing actions.
57 -3. D3+: visual sequential/parallel step definitions, conditions DSL, SLA/escalation, delegation/substitution and cross-module outbox actions. Do not duplicate C8 correspondence state.
55 +1. D3a: define and validate versioned sequential/parallel request workflow step semantics and server-side transition authorization without duplicating C8 correspondence state.
56 +2. D3b: add visual workflow editor/read-only runtime timeline plus condition DSL with safe validation/evaluation boundaries.
57 +3. D3c: add SLA/escalation evidence, delegation/substitution and transactional cross-module outbox actions.
58 4. Keep qualified digital signature, external delivery/BPM adapters and real OCR provider outside verified scope until real providers are connected and tested.
59 5. Continue compliance/accounting roadmap only with sourced legal/tax/accounting evidence and controlled cutover safeguards.
60
61 ## Live QA open items
62 - Exact Taxpayer-System print redesign: waiting for the two owner reference images; do not guess the official visual form.
63 -- Legacy `requestTypes` configure-only writes: D1 is the server-authorized replacement foundation; UI/data cutover is D2 and legacy record-store writes must not be represented as secured until cutover.
63 +- Legacy request records are preserved for rollback/audit after D2; new request configuration/runtime must not be routed back through record-store writes.
64 - Floating-detail defaults for new records: 8-digit semantic codes currently use slot/category/sequence (Branch `11xxxxxx`, Counterparty `21xxxxxx`, Project `31xxxxxx`); historical codes are not rewritten and account-chart coding stays independent.
65 - Product/service deletion must continue to fail closed whenever operational references exist.