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

Record verified ELI-2 reusable role evidence

davoodmehraban89 committed Sep 30, 2026 at 08:42 UTC 58784f0e7b070853405b4aab6bcd333a2a7fa3d4
4 files changed +43 -6
PROJECT_STATE.md
+5 -5
@@ -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 | Continue into ELI-2 reusable tenant roles without pausing after ELI-1; preserve direct member grants as overrides and keep commercial entitlement independent. | **ELI-2 SERVER APPLIED / TRANSACTIONALLY VERIFIED — RUNTIME/UI IMPLEMENTED, FINAL CI PENDING** | Plan: `docs/superpowers/plans/2026-09-30-enterprise-licensing-eli2-roles.md`. Production migration `20260930050542_enterprise_reusable_roles` applied. Transactional adversarial verification PASS with rollback: delegated core admin creates role/permission/assignment; role-only accounting read becomes effective; ordinary assignee cannot administer roles; cross-tenant assignment rejects; unlicensed role permission rejects after transactionally narrowing modules; system role deletion rejects; role audit emits. Follow-up hardening now closes direct-table bypasses with tenant-integrity triggers + entitlement-aware RLS. Runtime/UI loads role grants, unions them with direct grants, exposes reusable role creation/assignment/permission editing only to owner/core-configure, and retains direct grants as advanced overrides. Final hardening migration + CI verification pending. |
16 +| 2026-09-30 | Continue into ELI-2 reusable tenant roles without pausing after ELI-1; preserve direct member grants as overrides and keep commercial entitlement independent. | **ELI-2 IMPLEMENTED / PRODUCTION + REAL-DOM VERIFIED — FINAL SECURITY RUN OBSERVATION PENDING** | Plan: `docs/superpowers/plans/2026-09-30-enterprise-licensing-eli2-roles.md`. Production migration `20260930050542_enterprise_reusable_roles` applied. Transactional adversarial verification PASS with rollback: delegated core admin creates role/permission/assignment; role-only accounting read becomes effective; ordinary assignee cannot administer roles; cross-tenant assignment rejects; unlicensed role permission rejects after transactionally narrowing modules; system role deletion rejects; role audit emits. Follow-up production migration `20260930050904_eli2_role_tenant_hardening` closes direct-table bypasses with tenant-integrity triggers + entitlement-aware RLS. Direct-table adversarial rollback tests PASS. Runtime/UI loads role grants, unions them with direct grants, exposes reusable role creation/assignment/permission editing only to owner/core-configure, and retains direct grants as advanced overrides. Product head `c2ecd2a0451b8b7db6a246af0e5c49cf617ef8e5`: Quality `36672058163` PASS including Real-DOM and accounting/Golden gates; Pages `36672058038` PASS; Security `36672058144` still running at this state-writing moment and is NOT yet claimed. Production has 24 seeded system roles across 4 organizations, 28 starter permission rows, 0 persistent assignments and 0 test-role residue. Evidence: `docs/ELI_2_REUSABLE_ROLES_VERIFICATION.md`. |
17 | 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`. |
18 | 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. |
19 | 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`. |
@@ -23,7 +23,7 @@ Verify live GitHub+Supabase before acting; record material requests before imple
23
24 ## Current production state — 2026-09-30
25 - Verified ELI-1 product head: `b410145a5e821b3f39453ba10008b80d52151c37`; Quality `36671228468` PASS, Security `36671228442` PASS, Pages `36671227923` PASS.
26 -- Supabase `hcsixhqbyuhpshfwqpjx`: `ACTIVE_HEALTHY`, PostgreSQL `17.6.1.166`, 31 migrations through `20260930045827 enterprise_license_seats_delegated_admin`.
26 +- Supabase `hcsixhqbyuhpshfwqpjx`: `ACTIVE_HEALTHY`, PostgreSQL `17.6.1.166`, 33 migrations through `20260930050904 eli2_role_tenant_hardening`.
27 - `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.
28 - `organization_members`: persistent production data remains 4 active owners / zero persistent non-owner members; adversarial multi-member tests were transactionally rolled back.
29 - 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.
@@ -41,10 +41,10 @@ Posted accounting history is immutable and balanced; tenant isolation is enforce
41 `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/`.
42
43 ## NOT VERIFIED / external boundary
44 -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 +Authenticated two-real-user production browser E2E with a persistent legitimate non-owner member; 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.
45
46 ## Exact next executable work
47 -1. Finish ELI-2 by applying the direct-table tenant/entitlement hardening migration, run rollback adversarial tests against direct writes, then require final Quality/Security/Pages + Real-DOM.
48 -2. Then ELI-3 secure invitation lifecycle with atomic seat-safe acceptance and audit.
47 +1. Observe final ELI-2 Security run `36672058144`; if it fails, fix before full closure.
48 +2. Start ELI-3 secure invitation lifecycle with atomic seat-safe acceptance and audit; external email delivery remains NOT VERIFIED until provider integration is tested.
49 3. ELI-4 organization-tree UX/unit kinds and authenticated two-real-user browser verification when a legitimate persistent non-owner principal exists.
50 4. Then resume mature Office Slice C on the finalized enterprise identity/RBAC model.
docs/ELI_2_REUSABLE_ROLES_VERIFICATION.md new
+37
@@ -0,0 +1,37 @@
1 +# ELI-2 Reusable Organization Roles Verification
2 +
3 +Date: 2026-09-30
4 +Project: `hcsixhqbyuhpshfwqpjx`
5 +
6 +## Delivered
7 +Tenant-scoped reusable roles, role permissions, multiple role assignments per non-owner member, direct+role effective authorization union, starter roles, system-role protection, audit, runtime role loading, role administration UI, and direct per-user grants retained as advanced overrides.
8 +
9 +## Production migrations
10 +- `20260930050542 enterprise_reusable_roles`
11 +- `20260930050904 eli2_role_tenant_hardening`
12 +
13 +The hardening migration closes direct-table tenant and commercial-entitlement bypasses.
14 +
15 +## Adversarial verification
16 +All mutations used existing principals inside transactions and were rolled back.
17 +- delegated `core/configure` created role/permission/assignment;
18 +- role-only accounting read became effective without configure over-grant;
19 +- ordinary member could not administer roles;
20 +- cross-tenant assignment rejected;
21 +- unlicensed role permission rejected;
22 +- system role deletion rejected;
23 +- role audit emitted;
24 +- direct-table cross-tenant assignment rejected by tenant-integrity trigger;
25 +- direct-table unlicensed permission rejected;
26 +- persistent test-role residue = 0.
27 +
28 +Persistent seeded state: 24 system roles across 4 organizations, 28 starter role-permission rows, 0 member-role assignments.
29 +
30 +## GitHub evidence
31 +Product head `c2ecd2a0451b8b7db6a246af0e5c49cf617ef8e5`
32 +- Quality `36672058163`: PASS, including accounting/Golden, ELI-1/ELI-2 checks and Real-DOM role spec.
33 +- Pages `36672058038`: PASS.
34 +- Security `36672058144`: still running when this evidence snapshot was written; NOT VERIFIED until observed complete.
35 +
36 +## NOT VERIFIED
37 +Persistent second-user production browser E2E; ELI-3 invitation delivery.
scripts/enterprise-role-check.mjs
+1 -1
@@ -16,7 +16,7 @@ need(q,/Reusable organization roles invariants[\s\S]*enterprise-role-check\.mjs/
16 console.log('ELI-2 reusable role database contract: PASS');
17
18 const ui=fs.readFileSync('js/organization-rbac.js','utf8');
19 -const h=fs.readFileSync('supabase/migrations/20260930051000_eli2_role_tenant_hardening.sql','utf8');
19 +const h=fs.readFileSync('supabase/migrations/20260930050904_eli2_role_tenant_hardening.sql','utf8');
20 need(ui,/organization_role_permissions/i,'runtime role permissions load');
21 need(ui,/organization_member_roles/i,'runtime member role load');
22 need(ui,/directPermissions\.concat\(rolePermissions\)/i,'client effective direct plus role union');
supabase/migrations/20260930050904_eli2_role_tenant_hardening.sql renamed