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

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

docs: checkpoint Slice D1 request workflow foundation

davoodmehraban89 committed Oct 1, 2026 at 22:17 UTC d25b6a5767ce60e8d0f72efac6310523839bcabe
1 file changed +21 -28
PROJECT_STATE.md
+21 -28
@@ -14,57 +14,50 @@ 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 C8 Task 3 verification. | **EXECUTION IN PROGRESS** | Reconciled live `main` at `398e044eb6570345bff1b34c858d0e6089ab770a`; Quality `36907314330`, Security `36907314457`, Pages `36907313039` all PASS. C8 is now closed for its bounded internal-workflow scope. Next roadmap subsystem is Slice D (requests/BPMS-lite); architectural design approval remains the next product-development gate. |
18 -| 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. Final main `398e044`; Quality/DB/DOM, CodeQL and Pages PASS. Evidence: `docs/OFFICE_SLICE_C8_WORKFLOW_RUNTIME_VERIFICATION.md` and `docs/OFFICE_SLICE_C8_RUNTIME_UI_VERIFICATION.md`. |
17 +| 2026-10-01 | Owner said «ادامه بده» after Slice D design. | **EXECUTION IN PROGRESS** | Slice D1 server foundation is now in `main` and production Supabase: versioned request definitions/forms, pinned workflow version, idempotent instance creation, optimistic revision transition, immutable event evidence and server capability checks. Continue with D2 workflow semantics/UI only after D1 CI is green. |
18 +| 2026-10-01 | Slice D1 — requests/BPMS-lite server foundation. | **IMPLEMENTED / PRODUCTION SCHEMA VERIFIED; CI RUNNING** | Repo migrations `20261001204500_request_workflow_d1_foundation.sql`, `20261001205500_request_workflow_d1_transition_evidence.sql`, `20261001210500_request_workflow_d1_rpc_security.sql`; production tables/RLS/RPC presence verified. Public request RPCs are SECURITY INVOKER wrappers; privileged implementations moved to non-exposed `private`. Supabase advisor dropped authenticated-callable public SECURITY DEFINER findings from 23 to the pre-existing 20. Static D1 gates are wired into Quality. |
19 +| 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 | 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. |
21 | 2026-10-01 | Free-tier-only development/verification. | **ACTIVE OPERATING DIRECTIVE** | No paid Supabase branch or other billable development resource. |
21 -| 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. Server-side `requestTypes` configure-only enforcement remains open; UI/nav restriction alone is not a security boundary. |
22 +| 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-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. |
24 | 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. |
25
25 -## Live reconciliation — 2026-10-01 after C8 closure
26 -- `main`: `398e044eb6570345bff1b34c858d0e6089ab770a` (`C8 workflow runtime UI integration`).
27 -- Quality run `36907314330`: PASS. Static/accounting/Golden/ELI/C1-C8 gates passed; disposable C8 PostgreSQL policy/runtime/security/concurrency job passed; real-DOM suite passed including C8 runtime UI.
28 -- Security run `36907314457`: CodeQL JavaScript PASS; dependency review was skipped because the repository dependency-graph boundary remains unresolved.
29 -- Pages run `36907313039`: PASS.
30 -- Supabase project `hcsixhqbyuhpshfwqpjx`: live migrations now include C8 `20261001173917 office_slice_c8_workflow_policy`, `20261001180610 office_slice_c8_workflow_runtime`, `20261001180949 office_c8_policy_publisher_fk_index`.
31 -- Post-C8 persistent workflow residue: zero workflow instances, zero workflow events and zero workflow policy versions in the checked production state.
32 -- Supabase performance advisor: unused-index informational notices only; no unindexed-FK finding at the C8 closure check.
33 -- Supabase security advisor: three private C8 tables have RLS enabled with no policies because direct client table access is revoked and access is mediated by checked RPCs; 20 pre-existing authenticated-callable public SECURITY DEFINER warnings remain; leaked-password protection remains disabled. These warnings are not silently treated as resolved.
26 +## Live reconciliation — 2026-10-01 after D1 production foundation
27 +- Latest D1 Quality-trigger commit at this checkpoint: `c1c05d7788068ff654900b6398abbd9c1b0a7523`; Quality/Security/Pages were still running when this continuity update was written and must be rechecked before D1 is marked CI-verified.
28 +- 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.
29 +- 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.
30 +- 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.
31 +- C8 remains closed for its bounded internal correspondence-workflow scope; D1 request workflow state is separate and does not reuse correspondence runtime tables.
32
33 ## Implemented foundations
34 - Accounting phases 1–6: accepted high-assurance accounting foundation; posted history remains immutable and balanced.
35 - Slice A: server-enforced commercial module entitlements, module launcher, office registries/correspondence/private scans, configurable request-type foundation.
36 - Slice B: organizations, hierarchical units, memberships, direct/member-role capabilities, row scopes, confidentiality and shared office records.
37 - ELI-1–4: named-user/company capacity, delegated organization admin, reusable roles, secure invitations, typed organization tree and capacity UX.
40 -- Office C1: immutable registered correspondence/read evidence.
41 -- Office C2: actionable referrals, target authorization, immutable actions and SLA work queue.
42 -- Office C3: related-letter graph and structured archive classification/search.
43 -- Office C4: tenant-safe registration repair and versioned correspondence templates.
44 -- Office C5: content-bound internal approval/attestation lifecycle.
45 -- Office C6: server-derived SLA reminder/escalation evidence.
46 -- Office C7: tenant-safe full-text archive search with append-only OCR provenance/correction evidence; no real OCR-engine claim.
47 -- Office C8: versioned workflow policies, immutable runtime transition history, idempotent/concurrency-safe server operations and safe correspondence workflow UI. C8 is internal workflow only, not external BPM/provider integration.
38 +- Office C1–C7: immutable registration/read evidence, referrals, related-letter/archive classification, numbering/template repair, approvals, SLA evidence, full-text archive/OCR provenance boundary.
39 +- Office C8: versioned workflow policies, immutable runtime transition history, idempotent/concurrency-safe server operations and safe correspondence workflow UI.
40 +- 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 and non-exposed privileged implementation functions.
41
42 ## Invariants
50 -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; only the bound target may acknowledge/complete a referral; referral/audit evidence can only be inserted by authorized server operations; OCR provenance must reference a real attachment belonging to the same organization/correspondence; C8 workflow policy is pinned per instance, workflow evidence is append-only, transitions require server-authorized capability and expected revision, and workflow stage never replaces C1 registration status or C5 approval evidence.
43 +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.
44
45 ## Required evidence
46 `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/`.
47
48 ## NOT VERIFIED / external boundary
56 -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 17.11 upgrade; CodeQL v4 migration; external BPM/provider integration.
49 +D1 real browser workflow UX and multi-user approval journey are not yet implemented; D1 disposable PostgreSQL behavioral/concurrency job is not yet added. 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 17.11 upgrade; CodeQL v4 migration; external BPM/provider integration remain outside verified scope.
50
51 ## Exact next executable work
59 -1. Close documentation drift from C8: keep the gap register and continuity evidence aligned with C8 being complete for its bounded internal scope.
60 -2. Next product subsystem is **Slice D — requests/BPMS-lite** from `docs/FINORA_MODULAR_ERP_OFFICE_AUTOMATION_V1.md`: versioned request schemas/forms, visual step definitions, conditions, sequential/parallel approvals, SLA/escalation, delegation/substitution, immutable action history and cross-module actions. This is architectural work; explore the existing request foundation first and produce the design/spec/plan before implementation.
61 -3. Do not duplicate C8 correspondence workflow inside Slice D. Reuse its proven patterns (version pinning, immutable evidence, idempotency, optimistic concurrency, capability checks) while keeping request workflow state separate from correspondence state.
62 -4. Keep qualified digital signature, external delivery/BPM adapters and real OCR provider outside verified scope until real providers are connected and tested.
63 -5. Two-real-user production browser verification remains blocked until a legitimate persistent non-owner principal exists; do not fabricate one.
52 +1. Recheck D1 Quality/Security/Pages for the latest checkpoint commit; fix any regression before advancing.
53 +2. Add disposable PostgreSQL behavioral coverage for D1 authorization, version pinning, idempotency, stale-revision rejection, immutable event evidence and concurrent transition behavior.
54 +3. 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.
55 +4. D3+: visual sequential/parallel step definitions, conditions DSL, SLA/escalation, delegation/substitution and cross-module outbox actions. Do not duplicate C8 correspondence state.
56 +5. Keep qualified digital signature, external delivery/BPM adapters and real OCR provider outside verified scope until real providers are connected and tested.
57 6. Continue compliance/accounting roadmap only with sourced legal/tax/accounting evidence and controlled cutover safeguards.
58
59 ## Live QA open items
60 - Exact Taxpayer-System print redesign: waiting for the two owner reference images; do not guess the official visual form.
68 -- `requestTypes` configure-only writes: UI/nav restriction exists, but server-side enforcement remains open and must be designed into Slice D authorization rather than treated as already secure.
61 +- Legacy `requestTypes` configure-only writes: D1 introduces the server-authorized replacement foundation; UI/data cutover is D2 and legacy record-store writes must not be represented as secured until cutover.
62 - 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.
63 - Product/service deletion must continue to fail closed whenever operational references exist.