@davoodmehraban89 / Factor-easy / commits / d62249b
Fork 0

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

docs: checkpoint verified D3a and hand off D3b

davoodmehraban89 committed Oct 1, 2026 at 22:53 UTC d62249b7a039431704e8c7d2df10eb9108229fc5
1 file changed +20 -20
PROJECT_STATE.md
+20 -20
@@ -14,46 +14,46 @@ 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. | **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. |
17 +| 2026-10-01 | Owner said «ادامه بده» after D1 closure. | **D2 + D3A VERIFIED; CONTINUE D3B** | D2 server UI/read-model cutover and D3a sequential/parallel server runtime are verified. Continue with D3b visual workflow editor/runtime timeline + safe condition DSL. |
18 +| 2026-10-01 | Slice D3a — sequential/parallel request workflow runtime. | **IMPLEMENTED / PRODUCTION + DISPOSABLE-DB + CI VERIFIED** | Migrations `20261001230000`, `20261001230500`; private step/vote runtime, schema-v2 validation, quorum semantics, capability checks, idempotent decisions and immutable event evidence. Quality run `36913565943`: all three jobs SUCCESS. Production public decision RPC is SECURITY INVOKER; anon denied; security advisor has no new request warning. Evidence: `docs/REQUEST_WORKFLOW_D3A_VERIFICATION.md`. |
19 | 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 correspondence workflow UI. Evidence: `docs/OFFICE_SLICE_C8_WORKFLOW_RUNTIME_VERIFICATION.md` and `docs/OFFICE_SLICE_C8_RUNTIME_UI_VERIFICATION.md`. |
20 +| 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 `d1-request-database` all SUCCESS. |
21 +| 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. |
22 | 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. |
23 | 2026-10-01 | Free-tier-only development/verification. | **ACTIVE OPERATING DIRECTIVE** | No paid Supabase branch or other billable development resource. |
24 | 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. |
25 | 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. |
26 | 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. |
27
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.
28 +## Live reconciliation — 2026-10-01 after D3a verification
29 +- D3a verified commit: `4f362f925de7afb4f29008b1d670aa9ad340578d`; Quality run `36913565943`: `static-quality`, `c8-policy-database`, and `d1-request-database` all SUCCESS. D3a disposable PostgreSQL assertions cover sequential activation/completion, parallel quorum, distinct approvers, idempotent retry, invalid schema and capability denial.
30 +- The first D3a behavior run failed because the authenticated test role attempted direct inspection of private runtime tables. The test was corrected to inspect private state only as the disposable DB owner; production grants were not weakened.
31 +- Production Supabase `hcsixhqbyuhpshfwqpjx`: D3a private step/vote tables exist; `authenticated` can execute `public.request_step_decide`, `anon` cannot; public wrapper is SECURITY INVOKER. The hardening migration checks tenant/module access before returning an idempotent replay result.
32 +- Production security advisor after D3a: no new request-workflow SECURITY DEFINER warning; the pre-existing 20 public warnings, C8 private RLS informational notices and leaked-password protection warning remain open.
33 +- Production performance advisor after D3a: no unindexed-foreign-key finding; only expected unused-index informational findings exist on the new/low-traffic indexes.
34 +- D2 legacy source records remain intact (2 requestTypes, 4 requests) and imported D1/D2 rows remain traceable; D3a did not mutate legacy source data.
35 - C8 correspondence workflow remains separate from Requests; request workflow state does not replace C1 registration or C5 approval evidence.
36
37 ## Implemented foundations
38 - Accounting phases 1–6: accepted high-assurance accounting foundation; posted history remains immutable and balanced.
37 -- Slice A: server-enforced commercial module entitlements, module launcher, office registries/correspondence/private scans, configurable request-type foundation.
38 -- Slice B: organizations, hierarchical units, memberships, direct/member-role capabilities, row scopes, confidentiality and shared office records.
39 -- ELI-1–4: named-user/company capacity, delegated organization admin, reusable roles, secure invitations, typed organization tree and capacity UX.
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.
39 +- Slice A/B + ELI-1–4: modular entitlements, tenant/RBAC, seats, delegated admin, reusable roles, secure invitations and organization UX.
40 +- Office C1–C8: registration/read evidence, referrals, archive/classification, numbering/templates, approvals/SLA, OCR provenance boundary and versioned correspondence workflow runtime.
41 +- Requests D1: independent versioned request definition/form/workflow foundation, pinned versions, idempotent create, expected-revision transition, immutable evidence and server authorization.
42 - 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.
43 +- Requests D3a: validated workflow schema v2, ordered sequential/parallel approval steps, quorum voting, per-step capability authorization, idempotent decisions and private runtime state.
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. D2 legacy import is non-destructive/idempotent/traceable. 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. Request type/workflow versions are immutable snapshots; request instances pin both versions; runtime mutation is server-authorized, idempotency/revision guarded and append-only evidence is retained. D2 legacy import is non-destructive/idempotent/traceable. D3a step votes require distinct actors for parallel quorum and active-step capability authorization. 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/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`.
49 +`docs/PHASE_1_REDESIGN_VERIFICATION.md` through `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` through `docs/ELI_4_ENTERPRISE_ORGANIZATION_UX_VERIFICATION.md` · `docs/OFFICE_SLICE_C1_VERIFICATION.md` through `docs/OFFICE_SLICE_C8_RUNTIME_UI_VERIFICATION.md` · `docs/REQUEST_WORKFLOW_D2_CUTOVER_VERIFICATION.md` · `docs/REQUEST_WORKFLOW_D3A_VERIFICATION.md` · `docs/PRODUCTION_RUNBOOK.md` · `supabase/migrations/` · `supabase/tests/request_d1_behavior.sql` · `supabase/tests/request_d2_legacy_behavior.sql` · `supabase/tests/request_d3a_workflow_behavior.sql`.
50
51 ## NOT VERIFIED / external boundary
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.
52 +D3b visual workflow editor/runtime timeline and condition DSL are not yet implemented. D3c SLA/escalation, delegation/substitution and cross-module outbox actions 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. 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.
55 +1. D3b: add visual workflow editor and read-only runtime timeline on top of D3a, with a bounded condition DSL that is validated server-side and never executes arbitrary SQL/JavaScript.
56 +2. Add D3b real-DOM coverage for sequential/parallel editor state, publish validation, timeline rendering and stale-revision/error recovery.
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.