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

docs(finora): register real JWT generic-sync RPC authorization proof before QA implementation

davoodmehraban89 committed Nov 23, 2026 at 22:09 UTC 8622bbcb8589988558c0deb8479bab4d8fdd7612
1 file changed +6
PROJECT_STATE.md
+6
@@ -895,3 +895,9 @@ Next action: run and inspect Quality on the latest PR212 head. If any browser te
895 - **New, independently observed P0 via authenticated UPDATE:** `FINORA_PHASE5_POSTED_UPDATE_WITHOUT_APPROVE_EXPECTED_RED` confirmed A1-scoped member with `inventory:read/create/edit` and NO `inventory:approve` successfully inserted true draft stock/count rows then directly PATCHed both to POSTED; **HTTP204 for both**, with independent owner JWT readback verifying exact posted payloads. `FINORA_PHASE5_POSTED_UPDATE_JWT_EVIDENCE` logs both `posted_without_approval`. This supersedes the preceding *hypothesis* with execution. Any naive INSERT-only policy repair is incomplete: `records_update` checks edit, and existing Phase5 trigger locks only OLD posted. Existing actual posted-UPDATE/DELETE immutable guard still independently PASS.
896 - **Owner handoff**: [Issue245 implementation contract comment](https://github.com/davoodmehraban89/Factor-easy/issues/245#issuecomment-7106764847) maps `js/phase5-enterprise.js` Save→posted, `js/sync.js` generic sync, `records_insert`/`records_update` RLS and Phase5 posted guard; [Issue245 real-JWT dual path evidence](https://github.com/davoodmehraban89/Factor-easy/issues/245#issuecomment-7106797951) requires both INSERT and draft→posted UPDATE denial and positive independent authorized finalize. `finora_sync_records` SECURITY INVOKER is an additional channel to verify, not a claim it was directly tested in this slice. Codex-main retains sole financial/inventory/RLS implementation and code review. Issue229 sale/purchase unauthorized post remained expected PRODUCT RED in same WP2, not fixed.
897 - **Actual QA scope:** only existing `scripts/wp2-phase5-posted-insert-approval-jwt-e2e.mjs` modified; workflow still has one existing step/path filter. No app JS, SQL/migrations, RLS/Auth/grants, Production, posted history, protected main merge/release/deploy. This note plus `docs/EXECUTION_STATUS.md` creates new docs-inclusive SHA; exact final-head four workflows required. On tested CODE SHA Security [#45213314209](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45213314209) SUCCESS; Quality [#45213314753](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45213314753) and WP1 [#45213314488](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45213314488) still in progress at this entry. Six-stage progress unchanged A90/B50/C20/D55/E53/F10; this is evidence, not a product repair.
898 +
899 +
900 +### 2026-11-23 — FIN-QA-245-SYNC-RPC-PROOF / pre-implementation decision
901 +- User continues the scoped Finora QA/integration task. Protected main remains `dab1a45fcfc4f12e675cfe055e477138cd3e99fa`; Draft PR244 final prior exact SHA `c9696556496d4d7aad066a3049808155516513ee` had all four GitHub gates Quality/WP1/WP2/Security SUCCESS. **That green WP2 is confirmed PRODUCT P0 RED** for two direct PostgREST paths: unauthorized initial posted INSERT (HTTP201/201) and unauthorized draft→posted PATCH (HTTP204/204) for both inventory source collections. Issue245 (stock/count) and Issue229 (sale/purchase approval) remain open. No Codex-main product repair or protected-main merge verified.
902 +- **Distinct untested bypass surface**: `js/sync.js::runSync` calls public `finora_sync_records` (3-arg SQL SECURITY INVOKER). `20260930031853_organization_membership_rbac_foundation.sql` uses `INSERT ... ON CONFLICT DO UPDATE` into `records`, RLS checks `create/edit` but has no independent `inventory:approve` status gate. Static analysis implies the same risk for initial posted upsert and draft→posted upsert, but this RPC path **must not be claimed reproduced until actual JWT execution**. Prove with real Auth-issued creator-only non-owner company A1 JWT and read/create/edit non-owner A1 JWT already present in existing local WP2 QA script, using `/rest/v1/rpc/finora_sync_records` and independent owner JWT exact readback for BOTH `stockMovements`/`inventoryCounts`.
903 +- **Allowed scope**: extend ONLY existing `scripts/wp2-phase5-posted-insert-approval-jwt-e2e.mjs`; retain previous direct REST INSERT/PATCH markers and fixture fidelity, one existing WP2 workflow step, existing real license/permissions and fail-closed checks. New independent markers `FINORA_PHASE5_SYNC_RPC_POSTED_INSERT_WITHOUT_APPROVE_EXPECTED_RED`, `FINORA_PHASE5_SYNC_RPC_POSTED_UPDATE_WITHOUT_APPROVE_EXPECTED_RED`, with corresponding `*_APPROVAL_PASS` only when server denies BOTH collections without side effects; partial states or mismatched readback fail. Never use service-role to attempt unauthorized posting. On successful QA, append post-evidence to this document and `docs/EXECUTION_STATUS.md`, update PR244/Issue245 comments, verify exact final-head four gates. Codex-main exclusively owns app JS, migrations/RLS/Auth/grants and integration/merge/release; no production, historic financial records or protected main edits. No product-progress inflation: A90/B50/C20/D55/E53/F10.