@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / 6173674
Fork 0

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

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 3, 20:45 UTC

docs(phase0): archive admin create root-cause migration and verified release with open owner gates

davoodmehraban89 committed Oct 12, 2026 at 11:28 UTC 6173674ae643a3464943d2ea62ca2c8a73130df2
1 file changed +11
PROJECT_STATE.md
+11
@@ -333,3 +333,14 @@ Owner reports login blocked with generic 'check internet/VPN' network error on l
333 - **Bounded intended correction:** add reviewed, idempotent one-function migration to reorder fresh-user bootstrap as `profiles → organizations → licenses → owner membership`, preserving all current live email/phone signup support, default `role='user'`, trial entitlements, security-definer fixed search_path and seat enforcement. Reproduce 23503 in disposable PostgreSQL fixture, then verify successful bootstrap and existing seat-limit rejection. Add safe UI parsing of Edge structured error codes and regression test so admin form no longer displays opaque non-2xx errors. Run static/Chromium, disposable DB, Security; gate on exact SHA. Production migration only after independent tests and confirmed source/version equivalence; no changes to existing user/license rows, RLS, Auth JWT verification, or financial data. Rollback: approved previous function definition (do not mutate accounts/data). No live account creation without separately approved isolated identity.
334 - **Dependent continuation:** PR #92 dark-mode work already merged into latest main; verify its exact protected-main gates before further F0-06 work. Phase 0 remains OPEN; do not claim owner E2E pass from synthetic tests or read-only diagnostics.
335 - **Current status:** ROOT_CAUSE_VERIFIED / REPRODUCE_AND_FIX_IN_PROGRESS.
336 +
337 +
338 +### 2026-10-12 F0-07 admin new-user provisioning — ROOT CAUSE FIXED IN PRODUCTION / PHASE 0 OPEN
339 +- **Verified incident:** Owner's central administrator create-user request at 2026-10-12 07:13:44 UTC reached live Edge `admin-user-management` v3 (JWT verification enabled) and returned HTTP 400. Supabase Auth logs show underlying admin-user POST HTTP 500 `unexpected_failure` caused by PostgreSQL `organization license not found` (SQLSTATE 23503). No evidence this was bad internet or an invalid user-input password. Avoid reproducing the owner's personal details in logs.
340 +- **Root cause independently confirmed:** Live `public.handle_new_user()` inserted owner into `organization_members` before creating trial `licenses`; existing BEFORE INSERT `private.enforce_organization_member_seat()` correctly rejected membership lacking a license. No existing account or license required repair. The guard remains enabled and unchanged.
341 +- **Fix implemented in PR [#94](https://github.com/davoodmehraban89/Factor-easy/pull/94), merged to protected main SHA `e664e8fdbc77b660dfc1fedff580b206279899f3`:** new `supabase/migrations/20261012080000_fix_identity_bootstrap_license_before_membership.sql` preserves actual email/phone support and ordinary role, reorders new-user bootstrap to `profiles → organizations → trial license → owner membership`. No existing rows/permissions/role/RLS/Auth JWT behavior changed. `js/admin.js` safely renders localized structured server error rather than opaque `Edge Function returned a non-2xx status code`; cache-busted `admin.js?v=20261012-provision-error-v1`, password cleared after submit. No sensitive request/response bodies leaked.
342 +- **Independent disposable verification:** identity PostgreSQL job `114713267003` first **reproduced original 23503**, then applied proposed fix and confirmed owner trial + ordinary role, **second active user blocked** by unmodified seat-limit trigger, phone-only identity support preserved; three disposable DB jobs PASS. PR Quality `38219871219` **86/86 Chromium PASS** (includes real browser Persian failure display) and Golden accounting/security invariants; PR Security `38219871204` PASS.
343 +- **Same-main-SHA verification:** Quality `38220163720` SUCCESS, Security `38220163569` SUCCESS, Release `38220396895` SUCCESS, gated Pages `38220451051` SUCCESS; duplicate release canceled/skipped not counted. Migration applied through Supabase as **`20261012075507 fix_identity_bootstrap_license_before_membership`**; 82 migrations. Read-only function catalog verifies new 4-step order, original seat trigger count 1, ordinary `'user'` profile, phone support, function ACL `postgres,service_role` execute only. Deployed domain HTML references new versioned admin JS and served bundle contains safe error mapper (remote PC read-only HTTP). No test or real user was created in production; no existing financial postings or Auth account credentials were touched.
344 +- **Parallel Phase 0 continuity:** previously delivered F0-06 dark/light contrast #92, exact-main Quality `38218505600` 85/85, Security `38218505535`, Release `38218679192`, Pages `38218725537` SUCCESS; actual deployed `20261012-phase0-dark-contrast-v1` version confirmed on real domain. F0-06 **targeted controlled QA/release PASS** but owner full visual acceptance OPEN. Also F0-04 watermark print #90 released but owner reprint unverified.
345 +- **Current acceptance:** admin provision blocking defect **FIX_RELEASED / SOURCE+CI+MIGRATION VERIFIED**, actual authenticated admin create/retry **NOT OWNER-VERIFIED**. Owner should first check central users list to avoid duplicate, refresh and retry once with authorized personal identity, then verify ordinary role and trial; NEVER send passwords/tokens in chat. F0-01 affected ISP login, F0-02 tenant catalog, F0-03 safe real server invoice, F0-04 owner physical print, F0-05 real 1200+ catalog, F0-06 all visual controls, F0-07 dual-account RLS, F0-08 final stale PR disposition remain pending. **PHASE 0 IS STILL OPEN.**
346 +- **Rollback:** restore reviewed prior `handle_new_user()` definition in a new controlled migration (but this reintroduces recorded incident; do not undo automatically). Frontend rollback via PR #94 revert/gated Pages. No data rollback necessary. Next independent safe slice: F0-08 stale PR read-only evidence or F0-06 additional visual QA; actual owner E2E tests require an authorized session and controlled scope.