سامانه صدور فاکتور و حسابداری
Record Slice B implementation and production verification
davoodmehraban89 committed
Sep 30, 2026 at 06:58 UTC
466bcbe689456dc56dac4e3e3d30f164fb44898c
1 file changed
+25
-13
PROJECT_STATE.md
+25
-13
@@ -12,17 +12,19 @@ Verify live GitHub+Supabase before acting; record material requests before imple
12
## Current change ledger
13
| Date | Request / decision | Status | Evidence / next action |
14
|---|---|---|---|
15
-| 2026-09-30 | Continue from verified Slice A into Slice B: organization tenant, multi-user memberships, module roles/capabilities, row scopes, confidentiality, shared office access/referral foundation and immutable permission/referral audit. | **AUTHORIZED / IN PROGRESS** | Live baseline rechecked before implementation: main `df0eaeaaaae883806f98cd6f29275dd367595317`; Supabase `hcsixhqbyuhpshfwqpjx` `ACTIVE_HEALTHY`, PostgreSQL `17.6.1.166`, 24 applied migrations through `20260930030314`; latest baseline CI is green. Implement Slice B without weakening posted-accounting immutability, module licensing, expired-license read-only behavior or tenant isolation. |
16
-| 2026-09-30 | Modular organization-wide ERP: office automation/scanned correspondence/secretariat, configurable requests, module managers/permissions, module-select entry, module-by-module/full-suite licensing, future transport/operations; research Barid/ParGar, Chargoon/Didgah, Faragostar. | **SLICE A IMPLEMENTED / VERIFIED** | Request `0b622439`; implementation `d3934690`; read-only expiry hardening `906d78d7`; browser integration hardening `df82067ecb1fda9007eb11a30d0a9d7cc1b113cd`. Production migrations `20260930025546`, `20260930025647`, `20260930030314` applied+archived. Final product-head Quality `36662911587` PASS including syntax, accounting/Phase2–6/Golden, new modular-office invariants and Chromium Real-DOM tests; Security `36662911572` PASS; Pages `36662911432` PASS. Production DB negative checks: non-admin module-license RPC denied and unlicensed office write denied; positive atomic-registration transaction advanced counter 7→8 then rolled back. Multi-login tenant/RBAC remains Slice B and is not claimed. |
15
+| 2026-09-30 | Continue from verified Slice A into Slice B: organization tenant, multi-user memberships, module roles/capabilities, row scopes, confidentiality, shared office access/referral foundation and immutable permission/referral audit. | **IMPLEMENTED IN PRODUCTION DB / PR #7 CI PENDING** | Production migrations `20260930031853`, `20260930031942`, `20260930032615`, `20260930032654` applied+archived. Existing accounts backfilled to isolated organizations; records are organization-keyed while creator `owner_id` remains for own-scope. RLS now intersects organization membership + commercial entitlement + capability + row scope + confidentiality. Organization-aware sync/client, member-permission UI, shared office referral and org-aware attachment paths are on `feat/slice-b-tenant-rbac`. Production transactional tests PASS for own/org scope, confidentiality, read-only capability, expired-license read-only, referral/audit immutability. Performance FK findings fixed; security advisor introduced no new exposed SECURITY DEFINER warning. Final merge requires current PR Quality/Security green, then main Pages green. Evidence: `docs/SLICE_B_TENANT_RBAC_VERIFICATION.md`. |
16
+| 2026-09-30 | Modular organization-wide ERP: office automation/scanned correspondence/secretariat, configurable requests, module managers/permissions, module-select entry, module-by-module/full-suite licensing, future transport/operations; research Barid/ParGar, Chargoon/Didgah, Faragostar. | **SLICE A IMPLEMENTED / VERIFIED** | Request `0b622439`; implementation `d3934690`; read-only expiry hardening `906d78d7`; browser integration hardening `df82067ecb1fda9007eb11a30d0a9d7cc1b113cd`. Production migrations `20260930025546`, `20260930025647`, `20260930030314` applied+archived. Final product-head Quality `36662911587` PASS including syntax, accounting/Phase2–6/Golden, modular-office invariants and Chromium Real-DOM tests; Security `36662911572` PASS; Pages `36662911432` PASS. |
17
| 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 complete lifecycle/accounting/permissions/tests exist. |
18
19
## Current production state — 2026-09-30
20
-- Verified product head: `df82067ecb1fda9007eb11a30d0a9d7cc1b113cd`. State-only continuity commits may follow it without changing product behavior.
21
-- Supabase `hcsixhqbyuhpshfwqpjx`: `ACTIVE_HEALTHY`, PostgreSQL `17.6.1.166`, 24 migrations through `20260930030314`.
22
-- Existing 4 licenses grandfathered to `full_suite`; `admin_set_license_modules` validates explicit module keys.
23
-- 4/4 records policies include module entitlement; writes and atomic sync additionally require active license. Expired/cancelled users retain read-only access to entitled historical data.
24
-- Private `office-attachments`: max 20 MB, PDF/JPEG/PNG/TIFF, owner+office-module RLS. Secretariat numbering uses server row lock + unique index.
25
-- Performance advisor after migrations: clean. Security advisor: 7 reviewed public SECURITY DEFINER RPC warnings (prior six + `admin_set_license_modules`) plus leaked-password protection disabled; new admin RPC negative-tested 42501 for non-admin.
20
+- Canonical main before Slice B merge: `cba507186ac50f1c2771f720bc651eb8d99d490e`; Slice B PR branch head advances independently until CI green.
21
+- Supabase `hcsixhqbyuhpshfwqpjx`: `ACTIVE_HEALTHY`, PostgreSQL `17.6.1.166`, 28 migrations through `20260930032654`.
22
+- 4 existing licenses remain `full_suite`; each license now belongs to a backfilled organization whose original account is owner.
23
+- `records` primary identity is `(organization_id, collection, id)`; RLS enforces membership/entitlement/capability/scope/confidentiality. Writes require active organization license; expired/cancelled organizations retain authorized historical reads.
24
+- Organization security metadata: `organizations`, `organization_units`, `organization_members`, `member_module_permissions`, immutable `organization_audit`.
25
+- Office registration is organization-aware; referral is server-validated and immutable; new Storage path is organization/uploader/correspondence/file and resolves access through correspondence authorization. Legacy attachment writes are owner-only.
26
+- Security advisor: same 7 reviewed public SECURITY DEFINER warnings from existing admin/license helpers plus leaked-password protection disabled; Slice B added no new exposed SECURITY DEFINER warning.
27
+- Performance advisor: no unindexed-FK finding after `20260930032615`; newly-created indexes currently appear only as unused-index informational notices.
28
29
## Implemented Slice A
30
- Architecture/research: `docs/FINORA_MODULAR_ERP_OFFICE_AUTOMATION_V1.md`.
@@ -31,16 +33,26 @@ Verify live GitHub+Supabase before acting; record material requests before imple
33
- Office: secretariat registries, incoming/outgoing/internal metadata, drafts, server-atomic registration number, private scan attachments, archive metadata search, OCR-ready fields.
34
- Requests: admin-defined request type/field schema + request submission foundation.
35
36
+## Implemented Slice B
37
+- Organization tenant and membership model with conservative legacy backfill.
38
+- Per-member module capabilities: `read/create/edit/delete/approve/register/refer/archive/configure`.
39
+- Row scopes: own/unit/branch/company/organization; missing scope key does not broaden access.
40
+- Confidentiality clearance independent of generic module read.
41
+- Organization-aware license selection, workspace/module visibility and sync.
42
+- Owner/member access-management surface; module configurators can assign permissions for their module. Adding a member currently requires an already-registered Finora account.
43
+- Shared office records through server RLS, capability-gated draft/register/configure/refer actions, immutable referrals and permission/referral audit.
44
+
45
## Invariants
46
Posted accounting history is immutable and balanced; tenant isolation is data-boundary enforced; commercial module entitlement and member authorization are independent; UI hiding is never security; expired licenses are read-only; office numbers are server-atomic; binary scans stay in private Storage; roadmap-only modules are not presented as operational.
47
48
## Required evidence
38
-`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/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/PRODUCTION_RUNBOOK.md` · `supabase/migrations/`.
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/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/PRODUCTION_RUNBOOK.md` · `supabase/migrations/`.
50
51
## NOT VERIFIED / external boundary
41
-Multi-login organization membership/module-manager RBAC/shared inbox/referral; real Persian OCR accuracy; authenticated production-user browser E2E; physical printer; third-party webhook/ECE/email gateways; Supabase leaked-password setting; PostgreSQL 17.11 platform upgrade.
52
+Invitation of users without an existing Finora account; authenticated two-real-user production browser E2E; real Persian OCR accuracy; qualified digital signature; physical printer; third-party webhook/ECE/email gateways; Supabase leaked-password setting; PostgreSQL 17.11 platform upgrade.
53
54
## Exact next executable work
44
-1. Slice B in progress: organization tenant + memberships + module roles/capabilities + row scopes + confidentiality + immutable permission/referral audit, with positive/negative RLS tests.
45
-2. Slice C: mature office lifecycle (templates/editor/signature/approval/referral/read receipts/SLA/reply graph/archive/OCR/full-text/integration adapters).
46
-3. Slice D/E: versioned workflow engine then transport/procurement/service/CRM/manufacturing/maintenance as complete tested vertical modules.
55
+1. Finish PR #7 release gate: current Quality/Security green → merge to `main` → verify Pages/main CI and live browser bootstrap.
56
+2. Slice C: mature office lifecycle — templates/editor, signatures/approval, referral chains/read receipts, SLA/reminders, reply/related-letter graph, archive classification, OCR/full-text and integration adapters.
57
+3. Slice D: versioned workflow engine for configurable requests — steps, conditions, parallel/sequential approval, delegation/substitution, SLA/escalation and immutable action history.
58
+4. Slice E: transport/procurement/service/CRM/manufacturing/maintenance only as complete tested vertical modules with accounting/permissions/reporting integration.