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

docs(finora): pre-register Phase5 posted-insert approval JWT hypothesis

davoodmehraban89 committed Nov 23, 2026 at 18:26 UTC 052a233ee68b193c866b3af3f457de3aec93997c
1 file changed +8
PROJECT_STATE.md
+8
@@ -865,3 +865,11 @@ Next action: run and inspect Quality on the latest PR212 head. If any browser te
865 - **Independent assertion audit found one narrow coverage gap despite green CI:** the read-only member POST assertion at `df143bda...` only attempted `stockMovements`, while its broad success marker referred to both supported collections. Tightened the QA test on new code SHA `0b15eaad209e3c51be7b9823034f14bfbee9c6dc` to attempt unauthorized POST independently for **both** `stockMovements` and `inventoryCounts`, and require HTTP 401/403 plus owner readback empty. No permission, RLS, product code, test expectation or migration changed. This is a QA completeness correction, not a newly discovered product defect.
866 - **Final acceptance now pending:** all four CI workflows must rerun on the new docs-inclusive final SHA; do not inherit the `df143bda...` results. If a test fails, preserve it as a real failure and repair only the fixture/test logic where justified.
867 - No application JS, SQL/migration, RLS/Auth/grants, production data, main, history, merge or release changed. Codex-main remains integration owner/reviewer. Six stage estimates remain A90/B50/C20/D55/E53/F10; delegated-scope proof is QA evidence, not product completion.
868 +
869 +
870 +### 2026-11-23 — FIN-QA-PHASE5-POSTED-INSERT-JWT / decision BEFORE implementation
871 +- User again requested continue and linearly report progress A–F after each completed stage. Verified live main `dab1a45fcfc4f12e675cfe055e477138cd3e99fa`; [Draft PR243](https://github.com/davoodmehraban89/Factor-easy/pull/243) HEAD `b4da4aebff10994d386dfd9d57c139e1d60a3ebb`, company-scope real-JWT WP2 [45198333440](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45198333440) SUCCESS (four markers), Security [45198333439](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45198333439) SUCCESS; Quality and WP1 still in progress when checked. PR243 delegated member inventory:read read-only tests cover only a user **without** inventory:create. Two distinct Issue229 real-JWT sale/purchase approval bypass PRODUCT REDs persist on this exact WP2.
872 +- **New, distinct, high-risk hypothesis, not yet product defect proof:** `supabase/migrations/20260930031853_organization_membership_rbac_foundation.sql` `records_insert` checks inventory `create` and member/company scope, but does not visibly require `inventory:approve` for a JSON `records.data.status='posted'` insert. `supabase/migrations/20260929172129_phase5_complementary_erp_collections.sql` only protects already-posted stock/count rows on UPDATE/DELETE, not direct INSERT. This may permit a non-owner company-scoped `inventory:create` member (no `inventory:approve`) to directly POST a **ledger-effective posted stock adjustment / inventory count** without independent authorization. Must be proved or disproved by real Supabase Auth JWT & PostgREST, not asserted from static SQL alone. Separate from PR243 read-only member and PR242 Kardex browser defects.
873 +- **Scope:** new QA-only child branch `qa/finora-phase5-posted-insert-jwt-red-20261123` from exact PR243 SHA `b4da4aeb...`. Only a NEW `scripts/wp2-phase5-posted-insert-approval-jwt-e2e.mjs`, one new WP2 workflow step/path trigger, and append-only `PROJECT_STATE.md` and existing `docs/EXECUTION_STATUS.md`. NO application stock/financial JS, SQL/migrations, RLS/Auth/grants, Production, main, posted customer history, merge or release. Codex-main sole financial product implementation/review owner.
874 +- **Test design:** disposable-local only with explicit localhost API/DB guards. Real Auth-issued JWT non-owner member D in org A has **inventory:create scoped to company A1 only** and NO `inventory:approve`. A real owner A sees source readback. D attempts direct PostgREST INSERT `status:posted` for EACH `stockMovements` and `inventoryCounts`, with unique fixture IDs under company A1. Current known-broken fingerprint is HTTP201/204 **plus** one exact persisted posted data row read by A. Mark it explicitly `FINORA_PHASE5_POSTED_INSERT_WITHOUT_APPROVE_EXPECTED_RED` (source/product RED, not a permission PASS). Proper fixed behavior is HTTP401/403 with owner readback empty. Any partial, authorization bypass outside intended scope, or third state is ordinary CI FAIL with no generic xfail. Seed only fixture company/warehouse/product, no financial journal or fake approval. Use existing real DB policies and license triggers, not SQL permission overrides. Evaluate whether company-scoped create can create only A1 in separate acceptance if necessary; avoid claiming unauthenticated/foreign-org exploit.
875 +- **No status inflation:** A90/B50/C20/D55/E53/F10 unchanged (QA evidence ≠ feature completion). Record first exact workflow trace, fix only fixture assumptions if necessary, rerun same SHA gates, Draft PR and owner review; never merge/deploy.