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

docs: record verified test-account lifetime entitlement and suspected org-context load race

davoodmehraban89 committed Oct 14, 2026 at 23:44 UTC 41bdbe46d5ef957628a65e5914da21b19768f777
1 file changed +7
PROJECT_STATE.md
+7
@@ -697,3 +697,10 @@ Owner reports login blocked with generic 'check internet/VPN' network error on l
697 - Owner environment: Supabase organization now `Finora – Production`, project `Finora ERP – Production`, project ref `hcsixhqbyuhpshfwqpjx` (matches `js/core.js`). Supabase Free scheduled backup unavailable; Cloudflare R2 activation requires a valid card and was not completed, so this solution uses no paid subscription.
698 - **Exact next work:** owner powers on authorized Windows computer and brings Desktop Commander online; obtain Direct or Session-pooler DB endpoint without disclosing password; locally generate/secure an age identity; install matching PostgreSQL 17 client and age; run first encrypted backup with password entered privately; verify archive, copy to a second device, restore to *empty localhost disposable DB*, independently validate recovered rows/config, then plan time-based Windows Task Scheduler with OS-protected credentials and log rotation. Keep status `PRODUCTION_BACKUP_NOT_RUN / RECOVERY_NOT_VERIFIED` until each test is evidenced.
699 - Historical continuity from superseded documentation PR #142: [PR #141](https://github.com/davoodmehraban89/Factor-easy/pull/141) head `c33a6a89dccfe2558c4cc77b041ef3910a4e4f77`, Quality `38605198345` SUCCESS, Security `38605198098` SUCCESS, protected main squash `9693b342670915271e3b471cf68da44b2530d99a`. Company-form Save state respects `canWrite()`; lifetime organization license discrepancy still unverified and must not be overridden.
700 +
701 +
702 +### 2026-10-14 test-account lifetime license rendered expired — ORGANIZATION BOOTSTRAP RACE CONFIRMED IN SOURCE / FIX IN PROGRESS
703 +- **Owner-provided READ-ONLY production SQL:** both owner and test account separately have exactly one active organization ownership, with a `public.licenses` organization record `plan=lifetime, status=active, ends_at=2099-01-01`; the test account's organization is `davood_mehraban`. Do not change licenses or confuse the two identities. Screenshots are evidence of DB state; production browser account matching is still an independent acceptance gate.
704 +- **Reproduced source ordering concern:** `js/core.js` calls `initAuthSystem()` while HTML is parsing; a saved session triggers `enterApp()`, which currently starts `fetchCurrentUser()` in parallel with `window.FinoraAppAssetsReady`. The original core `fetchCurrentUser` returns placeholder `type=none,status=unavailable`; `js/organization-rbac.js` arrives later through asynchronous ordered extension loading (`js/bootstrap.js`) and **then** wraps `fetchCurrentUser` to load the real org license. If auth lookup starts earlier, the app retains an unavailable placeholder and `updateLicenseDisplay()` treats missing end date as expired. This is a plausible deterministic race; a mocked Chromium interleaving must be added to prove it.
705 +- **Authorized minimal fix:** signal when organization-context wrapper is installed; gate profile entitlement fetch on that signal while keeping the login form interactive and all existing bounded aborts; retain parallel wait for remaining app assets; distinguish genuinely expired/cancelled subscription from unavailable/unknown in the read-only badge. No Supabase schema, RLS, Auth, role, entitlement, financial data or migration changes. Synthetic Playwright race/regression tests, Quality/Security/Pages gates and real owner/test-account production acceptance are required separately. Rollback: revert scoped PR and guarded redeploy.
706 +- **Status before implementation:** branch `fix/finora-org-license-bootstrap-race-20261014` created from protected `main`; code fix/CI/merge/release all PENDING.