سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 20:45 UTC
Close ELI-4 enterprise organization UX with evidence
davoodmehraban89 committed
Sep 30, 2026 at 09:09 UTC
f0212cb6ab40b89431929f6aa0bb76024dffb937
4 files changed
+59
-10
PROJECT_STATE.md
+12
-9
@@ -13,21 +13,23 @@ Verify live GitHub + Supabase before acting; implement/test/fix/retest/commit/ve
13
| Date | Request / decision | Status | Evidence / next action |
14
|---|---|---|---|
15
| 2026-09-30 | Continue autonomously without routine confirmation pauses. | **ACTIVE OPERATING DIRECTIVE** | Applies to reversible in-scope engineering. No claim of background execution. |
16
-| 2026-09-30 | ELI-3 secure invitations for named users, bound to email, roles and seat capacity. | **IMPLEMENTED / PRODUCTION + REAL-DOM + SECURITY VERIFIED** | Production migrations `20260930051849_enterprise_invitations` and `20260930052909_eli3_fk_index_hardening`. Transactional rollback verification PASS: hash-only token persistence, wrong-email denial, intended-user acceptance, role assignment, same-user replay idempotence, full-seat atomic rejection, revoke lifecycle, audit redaction and zero residue. Runtime/UI adds invite creation/revoke/copy-link and `?invite=` acceptance. Product head before evidence commit `71d6cd7196ef308c67f927644503f563bf4693ea`: Quality `36673537775` PASS including all accounting/Golden/ELI + Real-DOM; Security `36673537771` PASS; Pages `36673537056` PASS. Performance advisor unindexed-FK findings reduced to zero after hardening. Evidence: `docs/ELI_3_INVITATIONS_VERIFICATION.md`. External automatic email delivery remains NOT VERIFIED. |
16
+| 2026-09-30 | ELI-4 enterprise organization UX: typed hierarchy, consolidated capacity dashboard and organization-admin hardening. | **IMPLEMENTED / PRODUCTION + REAL-DOM + SECURITY VERIFIED; PERSISTENT TWO-USER PROD E2E NOT VERIFIED** | Production migration `20260930053652_enterprise_organization_ux`; unit kinds `region/branch/department/unit/subunit`, same-tenant parent/cycle guard, unit audit, owner/core-admin capacity summary, typed tree UI and company/user/module dashboard. Shell admin button now requires owner or `core/configure`, not arbitrary module configure. Transactional rollback verification PASS for ordinary-user denial, delegated core admin, cross-tenant parent rejection, cycle rejection, invalid kind rejection, capacity summary and unit audit. Product head before evidence commit `e88fab7470bb0697652d347d23ca48332a94c6e4`: Quality `36674128792` PASS including all accounting/Golden/ELI + Real-DOM; Security `36674128874` PASS; Pages `36674128102` PASS. Evidence: `docs/ELI_4_ENTERPRISE_ORGANIZATION_UX_VERIFICATION.md`. Persistent two-real-user production browser E2E remains blocked because production has no legitimate persistent non-owner member. |
17
+| 2026-09-30 | ELI-3 secure invitations for named users, bound to email, roles and seat capacity. | **IMPLEMENTED / PRODUCTION + REAL-DOM + SECURITY VERIFIED** | Production migrations `20260930051849_enterprise_invitations`, `20260930052909_eli3_fk_index_hardening`; hash-only token lifecycle, atomic seat-safe acceptance, role assignment, revoke/expire, audit redaction and UI verified. Evidence: `docs/ELI_3_INVITATIONS_VERIFICATION.md`. External automatic email delivery remains NOT VERIFIED. |
18
| 2026-09-30 | ELI-2 reusable tenant roles; direct member grants remain explicit overrides. | **IMPLEMENTED / PRODUCTION + REAL-DOM + SECURITY VERIFIED** | Production migrations `20260930050542_enterprise_reusable_roles`, `20260930050904_eli2_role_tenant_hardening`; role catalog/permissions/assignments, direct+role union, tenant integrity, commercial entitlement gate, audit and UI verified. Evidence: `docs/ELI_2_REUSABLE_ROLES_VERIFICATION.md`. |
19
| 2026-09-30 | ELI-1 named-user seats, company capacity and delegated organization admin. | **IMPLEMENTED / PRODUCTION + REAL-DOM + SECURITY VERIFIED** | Production migration `20260930045827_enterprise_license_seats_delegated_admin`; seat/company limits, delegated `core/configure`, suspend/reactivate, audit and UI verified. Evidence: `docs/ELI_1_ENTERPRISE_LICENSE_VERIFICATION.md`. |
19
-| 2026-09-30 | Slice B organization tenant/RBAC/shared office foundation. | **IMPLEMENTED / VERIFIED** | Production migrations through `20260930033010`; tenant/RBAC verification retained. |
20
+| 2026-09-30 | Slice B organization tenant/RBAC/shared office foundation. | **IMPLEMENTED / VERIFIED** | Tenant/RBAC verification retained. |
21
| 2026-09-30 | Modular organization-wide ERP + office automation/request foundation. | **SLICE A IMPLEMENTED / VERIFIED** | Product head `df82067ecb1fda9007eb11a30d0a9d7cc1b113cd` passed Quality/Security/Pages. |
22
| 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. |
23
24
## Current production state — 2026-09-30
24
-- Supabase project `hcsixhqbyuhpshfwqpjx`: `ACTIVE_HEALTHY`, PostgreSQL `17.6.1.166`, **35 migrations through `20260930052909 eli3_fk_index_hardening`**.
25
+- Supabase project `hcsixhqbyuhpshfwqpjx`: `ACTIVE_HEALTHY`, PostgreSQL `17.6.1.166`, **36 migrations through `20260930053652 enterprise_organization_ux`**.
26
- Four organization-linked licenses with server-enforced `max_companies`, `max_users`, modules and future-safe `limits`; no license is below current active seat/company usage.
27
- Persistent production membership remains four active owners and zero non-owner members. All ELI adversarial multi-user tests used existing legitimate principals inside transactions and rolled back.
28
- ELI-2 persistent seeded state: 24 system roles across four organizations, 28 starter role-permission rows, zero persistent member-role assignments.
29
- ELI-3 persistent state after tests: zero invitations, zero invitation-role links, zero non-owner members and zero role assignments.
29
-- RLS is enabled on the public tenant tables. Security advisor reports intentional authenticated SECURITY DEFINER RPC warnings (internally authorization-gated) plus leaked-password protection disabled. Negative authorization tests for ELI RPCs passed.
30
-- Performance advisor currently reports only unused-index informational notices; **no unindexed foreign-key findings remain** after `20260930052909`.
30
+- ELI-4 persistent organization-unit count remains zero after rollback verification; no test hierarchy residue exists.
31
+- RLS is enabled on public tenant tables. Security advisor reports intentional authenticated SECURITY DEFINER RPC warnings plus leaked-password protection disabled; negative authorization tests for ELI RPCs passed.
32
+- Performance advisor reports only unused-index informational notices; no unindexed foreign-key findings remain.
33
- Production invoice history remains unchanged; controlled accounting cutover is not part of ELI work.
34
35
## Implemented foundations
@@ -36,19 +38,20 @@ Verify live GitHub + Supabase before acting; implement/test/fix/retest/commit/ve
38
- ELI-1: named-user seats, company capacity, delegated customer admin and member lifecycle.
39
- ELI-2: reusable roles, role permissions, multi-role assignment, direct+role effective authorization and role audit.
40
- ELI-3: secure hash-only invitations, email binding, role-bound acceptance, atomic seat enforcement, revoke/expire lifecycle, invitation UI and URL acceptance.
41
+- ELI-4: typed organization tree, tenant/cycle integrity, capacity dashboard and strict core-admin shell gating.
42
- Existing accounting Phases 1–6 and Iran enterprise foundation remain accepted; ELI work must not rewrite posted accounting history.
43
44
## Invariants
42
-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 and seat-safe; raw invitation tokens are never persisted or audited.
45
+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 and seat-safe; raw invitation tokens are never persisted or audited; organization-unit parents cannot cross tenants or form cycles.
46
47
## Required evidence
45
-`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/superpowers/specs/2026-09-30-enterprise-licensing-organization-identity-design.md` · `docs/superpowers/plans/2026-09-30-enterprise-licensing-eli1.md` · `docs/superpowers/plans/2026-09-30-enterprise-licensing-eli2-roles.md` · `docs/superpowers/plans/2026-09-30-enterprise-licensing-eli3-invitations.md` · `docs/ELI_1_ENTERPRISE_LICENSE_VERIFICATION.md` · `docs/ELI_2_REUSABLE_ROLES_VERIFICATION.md` · `docs/ELI_3_INVITATIONS_VERIFICATION.md` · `docs/PRODUCTION_RUNBOOK.md` · `supabase/migrations/`.
48
+`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/superpowers/specs/2026-09-30-enterprise-licensing-organization-identity-design.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/PRODUCTION_RUNBOOK.md` · `supabase/migrations/`.
49
50
## NOT VERIFIED / external boundary
51
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; qualified digital signature; physical printer; live external adapters; GitHub Dependency graph; leaked-password protection; PostgreSQL 17.11 upgrade; CodeQL v4 migration.
52
53
## Exact next executable work
51
-1. Continue ELI-4 organization-tree UX/unit kinds and organization administration polish without weakening ELI-1/2/3 invariants.
54
+1. Resume mature Office Slice C on the finalized ELI-1/2/3/4 enterprise identity/RBAC model; preserve all accounting/Golden and ELI gates.
55
2. Authenticated two-real-user production browser verification remains blocked until a legitimate persistent non-owner principal is intentionally available; do not fabricate or permanently cross-add one.
56
3. External invitation email delivery remains an adapter boundary; do not claim it until a real provider is connected and tested.
54
-4. Then resume mature Office Slice C on the finalized enterprise identity/RBAC model.
57
+4. Continue compliance/accounting roadmap only with sourced legal/tax/accounting evidence and owner-approved destructive cutovers.
docs/ELI_4_ENTERPRISE_ORGANIZATION_UX_VERIFICATION.md
new
+46
@@ -0,0 +1,46 @@
1
+# ELI-4 Enterprise Organization UX Verification
2
+
3
+Date: 2026-09-30
4
+Project: `hcsixhqbyuhpshfwqpjx`
5
+
6
+## Delivered
7
+- `organization_units.unit_kind` with neutral default `unit` and vocabulary `region`, `branch`, `department`, `unit`, `subunit`.
8
+- Server-side same-tenant parent enforcement and cycle prevention for organization hierarchy.
9
+- Organization-unit mutation audit.
10
+- Authorization-gated `organization_capacity_summary` for user/company/module/license dashboard data.
11
+- Consolidated organization administration dashboard showing active named-user usage, legal-company usage, plan/status/modules and typed hierarchy.
12
+- Typed unit creation UI and nested organization-tree rendering.
13
+- Organization shell access button corrected to owner or explicit `core/configure`; arbitrary module `configure` no longer exposes tenant administration UI.
14
+
15
+## Production migration
16
+`20260930053652 enterprise_organization_ux`
17
+
18
+## TDD evidence
19
+Failing Real-DOM coverage was committed first at `ee091bd73f47c963b8299c432314fcf700fe290d`. Quality run `36673893320` failed at Real DOM because ELI-4 tree/dashboard runtime functions did not exist. Implementation then made the same coverage pass.
20
+
21
+## Transactional adversarial verification
22
+All test hierarchy/member changes were rolled back.
23
+
24
+PASS:
25
+1. Ordinary organization member cannot call commercial capacity summary.
26
+2. Owner can create typed region/branch hierarchy.
27
+3. Parent from another tenant is rejected server-side.
28
+4. Parent/descendant cycle is rejected server-side.
29
+5. Unsupported `company` unit kind is rejected; legal companies remain separate from operational units.
30
+6. Delegated `core/configure` admin can create typed units.
31
+7. Delegated `core/configure` admin can read organization capacity summary.
32
+8. Capacity summary reports named-user usage/limit correctly in the transaction.
33
+9. Unit mutations emit organization audit evidence.
34
+10. Transaction rollback leaves no persistent hierarchy or test membership residue.
35
+
36
+## GitHub evidence
37
+Verified product head before this evidence commit: `e88fab7470bb0697652d347d23ca48332a94c6e4`.
38
+- Quality `36674128792`: PASS including accounting/Golden, ELI-1/2/3/4 static gates and Real-DOM.
39
+- Security `36674128874`: PASS.
40
+- Pages `36674128102`: PASS.
41
+
42
+## Supabase advisor status
43
+Performance advisor after ELI-4 reports only unused-index informational notices and no unindexed-foreign-key findings. The new organization-unit kind index is intentionally retained pending representative production workload.
44
+
45
+## NOT VERIFIED
46
+Authenticated production browser E2E with a deliberately persistent second non-owner organization member. Production still has zero persistent non-owner members, so no principal was fabricated or permanently cross-added to satisfy this test.
scripts/enterprise-org-ux-check.mjs
+1
-1
@@ -1,6 +1,6 @@
1
import fs from 'node:fs';
2
const need=(t,r,l)=>{if(!r.test(t))throw new Error('ELI-4 invariant missing: '+l)};
3
-const m=fs.readFileSync('supabase/migrations/20260930060000_enterprise_organization_ux.sql','utf8');
3
+const m=fs.readFileSync('supabase/migrations/20260930053652_enterprise_organization_ux.sql','utf8');
4
need(m,/add column if not exists unit_kind/i,'unit kind');
5
need(m,/region[\s\S]*branch[\s\S]*department[\s\S]*unit[\s\S]*subunit/i,'unit kind vocabulary');
6
need(m,/enforce_organization_unit_tree/i,'tree integrity trigger');