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

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

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

Synced Dec 3, 17:00 UTC

docs(phase0): record live admin-provisioning repair and open F0-07 owner gate (#95)

* docs(phase0): track fixed live admin provisioning and remaining F0-07 acceptance gates * docs(phase0): archive admin create root-cause migration and verified release with open owner gates * test(phase0): stabilize light/dark contrast gate against boot race and 200ms button transition * docs(qa): record F0-06 contrast test race and required retest without relaxing WCAG gate

davoodmehraban89 committed Oct 12, 2026 at 11:37 UTC 4595dafcb98185984894faacb97244cec2aa55e4
3 files changed +25 -3
PROJECT_STATE.md
+14
@@ -333,3 +333,17 @@ 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.
347 +
348 +
349 +- **F0-06 QA suite follow-up (no runtime change):** Documentation PR #95 initial Quality run `38220841194` failed **1/86** in the existing F0-06 light-mode contrast test at `button.contrast=1.56`; Security `38220841248` PASS and all three disposable DB jobs PASS. The isolated test toggled the body class and sampled immediately while the actual `.btn` CSS has a 200ms background-color transition; delayed `finoraApplyTheme` boot can also override the manually toggled class. Patched the fixture to hold the requested theme stable using a test-only `getMySettings` wrapper, use the actual `finoraApplyTheme()` transition, and poll for steady-state light-button contrast >=4.5 before asserting other surfaces. This does **not** waive the contrast threshold or alter live application CSS. Retest entire workflow on final PR head; do not merge on a red CI.
docs/FINORA_PHASE0_ACCEPTANCE_REGISTER_2026-10-12.md
+1 -1
@@ -25,7 +25,7 @@ Status definitions: **CONTROLLED QA PASS** = actual Chromium or isolated tests w
25 | **F0-04** · Print | Owner hardcopy/photo reproduced pale diagonal `پیش‌نویس — غیرقطعی` overlay on existing goods/services invoice; narrowly removed in PR #90; draft and pro-forma Chromium checks added, accounting state unchanged | **FIX RELEASED + CONTROLLED QA PASS; OWNER REPRINT UNVERIFIED** / P0 open | On the deployed PR #90 code, owner still checks a saved draft/ordinary sale invoice and purchase/pro-forma print: watermark absent, all rows/totals/dates visible; real printer/PDF and taxpayer-specific semantics are separate. Print QA. |
26 | **F0-05** · Large selectors | `scripts/phase0-selector-stress.spec.js`, **1,208 synthetic products + 1,206 persons** passed 2/2; keyboard/Persian/metadata covered | **CONTROLLED QA PASS for products/persons; real catalog and other high-volume selectors UNVERIFIED** / P1 open | Owner tenant/real workstation test plus assess account/project/contract selectors where applicable; measure interactive latency. UX/Perf. |
27 | **F0-06** · Modal, keyboard, RTL, themes | Targeted dark contrast PR **#92** released to protected main `745bdc847a3c2db22048d1d545da0fad0ae5cc67`; exact SHA Quality **38218505600** (**85/85 Chromium**, including two dark/light contrast tests, 3 disposable DB), Security **38218505535**, Release **38218679192**, Pages **38218725537** all SUCCESS. Remote read-only HTTP confirms updated live JS theme bundle. | **DARK/LIGHT CONTRAST RELEASED + CONTROLLED QA PASS; broader UI and owner visual acceptance UNVERIFIED** / P1 open | Owner dark/light screen review in authenticated session, keyboard/modal/RTL scroll ownership and critical save/delete/import/export negative-path tests. UI/QA. |
28 -| **F0-07** · Access and release safety | GitHub Security PASS; Supabase 21+3+1 advisor results | **VERIFIED READ-ONLY metadata; dual-user tenant/RLS proof UNVERIFIED** / P0 open | Independent role/tenant negative E2E with authorized second identity, strict no-write safe plan; formal Phase 1 security audit. Security. |
28 +| **F0-07** · Access and release safety | Security checks remain green. **Owner-reported central admin user creation HTTP 400** traced to real Auth HTTP 500 `organization license not found` (23503): live signup trigger inserted owner membership before required trial license. Controlled fix **PR #94** deployed: protected `main` `e664e8fdbc77b660dfc1fedff580b206279899f3`, Quality **38220163720** (**86/86 Chromium**, 3 disposable DB), Security **38220163569**, Release **38220396895**, Pages **38220451051** all SUCCESS. Supabase `fix_identity_bootstrap_license_before_membership` migration **20261012075507** applied successfully (total 82); independent read-only verification confirmed `profiles → organizations → licenses → membership`, original seat trigger retained, ordinary role and email/phone support preserved. Live admin JS version `20261012-provision-error-v1` reachable. | **ADMIN PROVISIONING ROOT-CAUSE FIX RELEASED + CONTROLLED QA PASS; actual owner retry and dual-user isolation E2E UNVERIFIED** / P0 still open | Owner rechecks central Users list (avoid duplicate account), refreshes and attempts authorized creation once without sharing credentials; verify created account has ordinary role and expected trial, then license assignment separately. Formal RLS/cross-tenant two-account negative E2E, Auth-advisor security audit and full F0-07 signoff remain pending. Security/QA. |
29 | **F0-08** · Stale PR reconciliation | **9** live open PRs audited against current main; all `diverged` from main | **Read-only preliminary disposition RECORDED; no PR integrated** / P1 open | Review below and safely disposition PRs with owner/context; never merge stale sensitive code automatically. Coordination. |
30
31 ### Exit decision
scripts/phase0-dark-theme-contrast.spec.js
+10 -2
@@ -20,7 +20,12 @@ async function setup(page){
20 <button type="button" class="module-link" id="f0-theme-nav">حسابداری</button>
21 </aside>`;
22 document.body.appendChild(fixture);
23 - document.body.classList.add('finora-theme-dark');
23 + // Keep the requested theme stable if the application's delayed boot runs.
24 + // This is a browser fixture only; no persisted user setting is modified.
25 + window.__f0TestTheme='dark';
26 + const originalSettings=window.getMySettings;
27 + window.getMySettings=()=>({...((typeof originalSettings==='function'&&originalSettings())||{}),ui_theme:window.__f0TestTheme});
28 + finoraApplyTheme();
29 });
30 }
31
@@ -63,7 +68,10 @@ test('F0-06 dark mode maintains readable accounting panels, controls and shell',
68
69 test('F0-06 light mode remains legible after switching out of dark mode',async({page})=>{
70 await setup(page);
66 - await page.evaluate(()=>document.body.classList.remove('finora-theme-dark'));
71 + await page.evaluate(()=>{window.__f0TestTheme='light';finoraApplyTheme()});
72 + // Buttons animate their background for 200ms; assert steady-state contrast,
73 + // not an intermediate frame during CSS transition.
74 + await expect.poll(async()=>(await sample(page)).button.contrast,{timeout:3000}).toBeGreaterThanOrEqual(4.5);
75 const s=await sample(page);
76 expect(s.rootDark).toBe(false);
77 expect(s.accordion.contrast).toBeGreaterThanOrEqual(4.5);