سامانه صدور فاکتور و حسابداری
Verify ELI-1 enterprise license seats in production
davoodmehraban89 committed
Sep 30, 2026 at 08:31 UTC
6d0e1dd402cdef25ef3d2a1448c792f242fc1486
4 files changed
+77
-11
PROJECT_STATE.md
+10
-10
@@ -13,7 +13,7 @@ Verify live GitHub+Supabase before acting; record material requests before imple
13
| Date | Request / decision | Status | Evidence / next action |
14
|---|---|---|---|
15
| 2026-09-30 | Continue autonomously: do not pause for routine confirmations; keep implementation moving unless explicitly stopped or a real blocker requires owner action. | **ACTIVE OPERATING DIRECTIVE** | Applies to all in-scope reversible engineering work. No claim of background execution; each chat turn continues as far as available tools permit. |
16
-| 2026-09-30 | Implement approved enterprise licensing/organization identity model: named-user seat capacity, company capacity, module entitlements, delegated organization/system admin, regions/units/positions, later invitations and reusable roles; keep packaging evolvable. | **ELI-1 TASKS 1–3 IMPLEMENTED IN REPOSITORY — PRODUCTION APPLY/ADVERSARIAL VERIFICATION PENDING** | Approved spec: `docs/superpowers/specs/2026-09-30-enterprise-licensing-organization-identity-design.md`. Plan: `docs/superpowers/plans/2026-09-30-enterprise-licensing-eli1.md`. Live pre-change head `665c2d6e2a71026ad171e234786a4495e2211d0a`; Supabase ACTIVE_HEALTHY, 30 migrations through `20260930041735`, 4 organizations each currently one active owner. Task 1 commit `e04e7b49` introduced `max_users`, future-safe `limits`, atomic seat enforcement, organization-scoped company capacity, delegated `core/configure`, member suspend/reactivate and membership audit. Task 2–3 now add platform-admin user-capacity UI, organization seat counters, delegated-admin runtime semantics, suspend/reactivate UI and Chromium ELI-1 coverage. Production apply/transactional verification remains next; do not call ELI-1 complete until that evidence and final CI both pass. |
16
+| 2026-09-30 | Implement approved enterprise licensing/organization identity model: named-user seat capacity, company capacity, module entitlements, delegated organization/system admin, regions/units/positions, later invitations and reusable roles; keep packaging evolvable. | **ELI-1 IMPLEMENTED / PRODUCTION + REAL-DOM VERIFIED** | Approved spec: `docs/superpowers/specs/2026-09-30-enterprise-licensing-organization-identity-design.md`. Plan: `docs/superpowers/plans/2026-09-30-enterprise-licensing-eli1.md`. Live pre-change head `665c2d6e2a71026ad171e234786a4495e2211d0a`; Supabase ACTIVE_HEALTHY, 30 migrations through `20260930041735`, 4 organizations each currently one active owner. Task 1 commit `e04e7b49` introduced the server contract; Task 2–3 product head `b410145a5e821b3f39453ba10008b80d52151c37` added platform-admin capacity UI, organization seat counters, delegated `core/configure`, suspend/reactivate UI and Chromium coverage. Production migration `20260930045827_enterprise_license_seats_delegated_admin` applied successfully. Transactional adversarial verification PASS using only existing legitimate principals and ROLLBACK test data: platform admin capacity mutation succeeds; non-admin commercial mutation rejects; limit-below-usage rejects; suspension frees a seat; reactivation at capacity rejects atomically; delegated core/configure manages non-owner member/unit; ordinary member denied; module configurator cannot cross-grant another module; company capacity counts legal-company records and ignores organization units; membership audit is emitted. No test residue remained and 0/4 licenses are below active-user or company usage. Product-head Quality `36671228468` PASS including accounting/Golden/ELI invariant and all Real-DOM specs; Security `36671228442` PASS; Pages `36671227923` PASS. Evidence: `docs/ELI_1_ENTERPRISE_LICENSE_VERIFICATION.md`. |
17
| 2026-09-30 | Continue closing current-stage gap register autonomously, prioritizing production safety and real evidence. | **IN PROGRESS** | Security hardening migration `20260930041735` applied/archived; 7 intentional authenticated SECURITY DEFINER warnings remain plus leaked-password protection disabled. Controlled accounting cutover remains blocked by missing approved chart/company classification. |
18
| 2026-09-30 | Audit Gmail GitHub Run failed notifications and rank remaining gaps. | **AUDITED / GAP REGISTERED** | Final audit checkpoint `5182b786dc7488146eaaa68d87dcc2f1d2c9a725` passed Quality `36666677736`, Security `36666677677`, Pages `36666676797`. Gap register: `docs/CURRENT_STAGE_GAP_REGISTER_2026-09-30.md`. |
19
| 2026-09-30 | Slice B organization tenant/RBAC/shared office foundation. | **IMPLEMENTED / VERIFIED** | Merge `d212c6aeef5b49f33351166771a0899f307a9067`; production migrations through `20260930033010`; final verified checkpoint `99a23edcaddf542f9080bbe70bb0b450af14913f`. |
@@ -21,10 +21,10 @@ Verify live GitHub+Supabase before acting; record material requests before imple
21
| 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. |
22
23
## Current production state — 2026-09-30
24
-- Pre-ELI-1 live main head: `665c2d6e2a71026ad171e234786a4495e2211d0a`.
25
-- Supabase `hcsixhqbyuhpshfwqpjx`: `ACTIVE_HEALTHY`, PostgreSQL `17.6.1.166`, 30 migrations through `20260930041735`.
26
-- `licenses`: 4 rows, each organization-linked; before ELI-1 has `max_companies`/modules but no `max_users`.
27
-- `organization_members`: 4 rows, one active owner per organization; zero non-owner members.
24
+- Verified ELI-1 product head: `b410145a5e821b3f39453ba10008b80d52151c37`; Quality `36671228468` PASS, Security `36671228442` PASS, Pages `36671227923` PASS.
25
+- Supabase `hcsixhqbyuhpshfwqpjx`: `ACTIVE_HEALTHY`, PostgreSQL `17.6.1.166`, 31 migrations through `20260930045827 enterprise_license_seats_delegated_admin`.
26
+- `licenses`: 4 rows, organization-linked, with server-enforced `max_companies`, `max_users`, modules and future-safe `limits`; grandfather verification shows no license below current active seat/company usage.
27
+- `organization_members`: persistent production data remains 4 active owners / zero persistent non-owner members; adversarial multi-member tests were transactionally rolled back.
28
- RLS enabled on all listed public tables. Security advisor: 7 intentional authenticated SECURITY DEFINER warnings + leaked-password protection disabled. Performance advisor: 5 new unused-index informational findings.
29
- Production invoice history remains 7 records; controlled accounting cutover is unchanged and not part of ELI-1.
30
@@ -40,10 +40,10 @@ Posted accounting history is immutable and balanced; tenant isolation is enforce
40
`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/PRODUCTION_RUNBOOK.md` · `supabase/migrations/`.
41
42
## NOT VERIFIED / external boundary
43
-Authenticated two-real-user production browser E2E; ELI-2 reusable roles; ELI-3 invitations for users without an account; 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.
43
+Authenticated two-real-user production browser E2E with a persistent legitimate non-owner member; ELI-2 reusable roles; ELI-3 invitations for users without an account; 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.
44
45
## Exact next executable work
46
-1. Observe current ELI-1 repository Quality/Security/Pages; fix any regression without weakening invariants.
47
-2. Apply the exact ELI-1 migration to Production and run adversarial transactional verification with rollback test data.
48
-3. Write ELI-1 verification evidence and close only after Production seat/RLS verification + Real-DOM + accounting invariants + final Quality/Security/Pages.
49
-4. Then continue ELI-2 roles, ELI-3 invitations, ELI-4 enterprise organization UX/real-user verification before mature Office Slice C.
46
+1. Continue directly with ELI-2 reusable organization roles and effective-permission union; preserve direct grants as explicit overrides.
47
+2. Then ELI-3 secure invitation lifecycle with atomic seat-safe acceptance and audit.
48
+3. ELI-4 organization-tree UX/unit kinds and authenticated two-real-user browser verification when a legitimate persistent non-owner principal exists.
49
+4. Then resume mature Office Slice C on the finalized enterprise identity/RBAC model.
docs/ELI_1_ENTERPRISE_LICENSE_VERIFICATION.md
new
+66
@@ -0,0 +1,66 @@
1
+# ELI-1 Enterprise License Verification
2
+
3
+Date: 2026-09-30
4
+Project: `hcsixhqbyuhpshfwqpjx`
5
+Repository: `davoodmehraban89/Factor-easy`
6
+
7
+## Delivered
8
+- Named-user commercial seat capacity: `licenses.max_users`.
9
+- Future-safe quota metadata: `licenses.limits jsonb`.
10
+- Grandfathering: existing licenses never reduced below existing active membership.
11
+- Atomic active-seat enforcement on membership activation/reactivation.
12
+- Platform-admin `admin_set_user_limit` with lower-than-usage rejection.
13
+- Company-capacity enforcement corrected to organization/legal-company usage.
14
+- Explicit delegated `core/configure` domain.
15
+- Delegated member/unit administration without commercial-license mutation authority.
16
+- Member suspend/reactivate lifecycle with owner protection.
17
+- Membership/permission audit extension.
18
+- Platform-admin named-user capacity UI and organization seat counters.
19
+- Chromium coverage for named-user capacity and delegated-admin semantics.
20
+
21
+## Production migration
22
+Applied version: `20260930045827`
23
+Name: `enterprise_license_seats_delegated_admin`
24
+Repository archive: `supabase/migrations/20260930045827_enterprise_license_seats_delegated_admin.sql`
25
+
26
+Post-apply invariants:
27
+- license count: 4
28
+- licenses below active-member usage: 0
29
+- licenses below legal-company usage: 0
30
+- rollback test residue unit `ELI-TX`: 0
31
+
32
+## Transactional adversarial verification
33
+All test mutations used existing legitimate Finora principals inside a transaction and were rolled back.
34
+
35
+PASS:
36
+1. Platform admin can raise named-user capacity.
37
+2. Lowering named-user capacity below active usage is rejected.
38
+3. Adding active members consumes seats.
39
+4. Suspending a non-owner immediately frees a seat.
40
+5. Reactivating a suspended member at full capacity is rejected atomically.
41
+6. Delegated `core/configure` can create an organization unit and manage non-owner membership.
42
+7. Delegated organization admin cannot call platform commercial-capacity mutation.
43
+8. Ordinary member cannot manage another member.
44
+9. Module configurator cannot grant another module without that module's configure authority.
45
+10. Company capacity uses `records(collection='companies')` for the organization and ignores organization units/regions.
46
+11. Membership changes generate organization audit evidence.
47
+
48
+## GitHub verification
49
+Verified product head: `b410145a5e821b3f39453ba10008b80d52151c37`
50
+- Quality: run `36671228468` — PASS.
51
+- Security/CodeQL: run `36671228442` — PASS.
52
+- Pages: run `36671227923` — PASS.
53
+Quality included existing accounting/Phase 2–6/Golden gates, ELI-1 static invariant checks, and Real-DOM browser specs.
54
+
55
+## Supabase advisors after ELI-1
56
+Security advisor:
57
+- 8 authenticated-callable SECURITY DEFINER warnings; the new eighth item is `admin_set_user_limit`. It is intentionally callable by authenticated clients but internally requires `public.is_admin()`; transactional non-admin negative verification passed.
58
+- Leaked-password protection remains disabled.
59
+
60
+Performance advisor:
61
+- 4 informational unused-index notices. No ELI-1 index removal is justified without representative workload.
62
+
63
+## NOT VERIFIED
64
+- Authenticated production browser E2E using a persistent second non-owner member. Production still has no persistent active non-owner member; no user was fabricated or permanently cross-added for testing.
65
+- ELI-2 reusable roles.
66
+- ELI-3 invitations/external email delivery.
scripts/enterprise-license-check.mjs
+1
-1
@@ -1,7 +1,7 @@
1
import fs from 'node:fs';
2
3
const need=(text,rx,label)=>{if(!rx.test(text))throw new Error('ELI-1 invariant missing: '+label)};
4
-const migration=fs.readFileSync('supabase/migrations/20260930050000_enterprise_license_seats_delegated_admin.sql','utf8');
4
+const migration=fs.readFileSync('supabase/migrations/20260930045827_enterprise_license_seats_delegated_admin.sql','utf8');
5
need(migration,/add column if not exists max_users/i,'max_users');
6
need(migration,/add column if not exists limits jsonb/i,'future-safe limits metadata');
7
need(migration,/organization_active_member_count/i,'active seat count helper');