سامانه صدور فاکتور و حسابداری
docs(finora): record actual JWT inventory isolation, fixture failure and remaining P0
davoodmehraban89 committed
Nov 23, 2026 at 13:16 UTC
aa34c5386d75c1b2740c4fc9db6115fba3411037
1 file changed
+9
PROJECT_STATE.md
+9
@@ -829,3 +829,12 @@ Next action: run and inspect Quality on the latest PR212 head. If any browser te
829
- **Test scope:** create two real Supabase Auth JWT identities in two disposable organizations, plus two companies controlled by organization A. Fixture-seed posted stock movement and inventory count per organization (psql/service role fixture only), validate scoped read via real JWT PostgREST; same-organization multi-company rows are expected visible to their authorized owner and must **NOT** be mislabeled SQL cross-tenant RLS breach. Prove other organization cannot read/insert/update/delete A stock/count; prove posted stock/count data immutable against *same-tenant JWT* direct PATCH/DELETE. Verify readback after mutation attempts; all tests fail closed and never catch/skip an unexpected product state. Localhost endpoint guard and nonproduction Supabase stack required.
830
- **Scope limitations:** this validates cross-*organization*/owner RLS and posted immutability only. It cannot establish active-company UI scoping, warehouse accounting correctness, physical stock reception/post authorization, inventory count draft-first, rollback/concurrency or approval boundary. These remain open and require separate Codex-main acceptance. No Phase A–F percentage change (A90/B50/C20/D55/E53/F10).
831
- **Gate:** exact-head WP2 test log must contain precise positive marker; verify Quality/WP1/WP2/Security statuses on tested and final SHAs without copying previous results. If new test reveals a true RLS or immutability bypass, report FAIL (no generic xfail) and preserve raw evidence while seeking Codex-main repair.
832
+
833
+
834
+### 2026-11-23 — FIN-QA-223-JWT-INVENTORY / actual real JWT verification and fixture correction
835
+- First [WP2 #45149212154](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45149212154) at `52c4fb9cc0b1c2e7232fc6b59f5278139c022ad7` **FAILED** in *SQL fixture setup* with `company license limit exceeded` while trying to seed a second company under one user's default `max_companies=1`. New JWT stock test did not execute. Confirmed enforcement via existing `supabase/migrations/20260929220543_license_company_capacity.sql` and ELI organization-wide later migration. This was an actual protective license rule, not a stock/RLS/security failure.
836
+- Minimal **disposable fixture-only correction** on SHA `b309e240be66137ccf042aa728935eaf31130662`: raise A's own local QA license to `max_companies=2` before seeding A1 and A2, preserving real DB triggers and all authorization test assertions. No live-license modification, license policy/grant/SQL migration/product JS/production operations.
837
+- **Actual performed JWT/DB proof:** [WP2 #45149626342](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45149626342) **COMPLETED SUCCESS** on corrected code SHA. Genuine Supabase Auth A/B JWT + PostgREST tests printed `WP2_PHASE5_STOCK_JWT_ISOLATION_PASS`: both `stockMovements` and `inventoryCounts` own-org visibility, forbidden foreign-org read/INSERT/PATCH/DELETE, unchanged posted source after attempts; `WP2_PHASE5_POSTED_IMMUTABILITY_PASS`: posted record cannot have `data` PATCHed or be DELETEd even by authentic same-org owner; record intact. In addition, `WP2_PHASE5_ACTIVE_COMPANY_NOT_RLS_SCOPE` explicitly documents *legitimate same-owner A1/A2 cross-company rows visibility* by design of organization RLS. Thus **organization-level RLS and posted immutability PASS only**, no active-company Kardex/product stock fix claim. Existing journal tenant `WP3_FINANCIAL_TENANT_ISOLATION_PASS` preserved.
838
+- **Still actual P0 at exact WP2 SHA:** restricted commerce:create non-owner can still POST sale and purchase with no accounting:approve; log includes `FINORA_ISSUE229_APPROVAL_EXPECTED_RED` and `FINORA_ISSUE229_PURCHASE_APPROVAL_EXPECTED_RED`. Issue223 PR242 four browser known-product-REDs likewise remain. None was converted to product PASS; no production or per-company RLS claim.
839
+- On tested code SHA `b309e240...` Security [#45149625790](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45149625790) SUCCESS. Quality [#45149625327](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45149625327) and WP1 [#45149625302](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45149625302) were IN PROGRESS at this record; verify independently. **After this append, final branch SHA necessarily changes**; prior per-SHA CI is not a substitute for new final SHA CI. Real browser/owner-ISP and actual production tenant isolation remain NOT VERIFIED. PR243 Draft, code owner Codex-main review pending, A90/B50/C20/D55/E53/F10 unchanged.
840
+- Next owner: combine PR242 active-company/warehouse/draft/sign/transfer read-model correction with PR240 stock lifecycle under ONE inventory policy, and separately close Issue229 independent approval bypass via real JWT restricted permission gate; rerun browser expected REDs to ordinary PASS, real JWT rollback/concurrency/fiscal lock, and protected review before integration. No financial core rewrite in this QA child.