@davoodmehraban89 / Factor-easy / commits / 9c66f0d
Fork 0

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

test(wp2): accept deployed posted-line guard message without relaxing denial

davoodmehraban89 committed Nov 22, 2026 at 08:00 UTC 9c66f0d872c3b14c6fb3a7e0d600477adf2755fe
3 files changed +6 -1
PROJECT_STATE.md
+3
@@ -504,3 +504,6 @@ Next action: run and inspect Quality on the latest PR212 head. If any browser te
504 - **Next proved test gap and ownership:** PR225 `scripts/wp2-source-autopost-jwt-e2e.mjs` covers authorized JWT source autopost positive, concurrency, audit and link rollback, but does not attempt **malicious authenticated PostgREST mutation of posted source commercial fields, source deletion, canonical link/status forgery or posted journal line edits**. Supabase current `supabase/migrations/20261117120000_wp1_stage3_canonical_source_link_projection.sql` replaces earlier trigger and protects commercial fields with `private.finora_stage3_guard_posted_source` when guard mode `enforce`; `public.finora_guard_posted_source_records` is separate production guard. Need real E2E with synthetic tenant, JWT, frozen source, and unmodified existing trigger functions. If a requested mutation is denied by RLS only, do not falsely attribute it to the financial trigger.
505 - **Authorized QA scope:** follow-on branch `qa/posted-source-immutable-jwt-20261122` from prior PR226 exact GREEN. Append exact negative user-JWT REST assertions to **existing** `scripts/wp2-source-autopost-jwt-e2e.mjs`, set isolated fixture mode `enforce` only after existing autopost proofs, require explicit financial guard error when possible, verify source/lines/counter/audit unchanged and owner has read access. Update only existing `PROJECT_STATE.md`, `docs/EXECUTION_STATUS.md`, `docs/ACCOUNTING_CORE_ROADMAP_V1.md`; WP2 path filters already cover this test script. Do not introduce a new equivalent financial engine, change existing migrations, owner-held `sync.js`/`organization-rbac.js`/`journal-ui.js`, touch hosted DB/production or merge/deploy.
506 - **Acceptance:** exact PR SHA real local WP2 (JWT, authenticated REST negative, readback) with Quality/WP1/Security checking that same SHA; preserve prior SHA as validated fallback. False-positive rejection due to RLS without guard proof or a real 2xx mutation is a failure to investigate, not a PASS. This does not claim draft-first linked source deletion, fully integrated ATF, cheque or Issue216 completion. Codex main final reviewer/integration owner.
507 +
508 +
509 +- **2026-11-22 actual WP2 RED on first SHA:** PR227 `21709742c51a296b0d6044dc5125374c017de3aa`, [WP2 44985153735](https://github.com/davoodmehraban89/Factor-easy/actions/runs/44985153735) failed **after** `FINORA_SOURCE_JWT_ATOMIC_PASS`. Auth JWT source commercial-field PATCH, forged source-link PATCH and source DELETE had all returned expected explicit financial guard denials. JWT posted journal-line PATCH was ALSO rejected by financial guard SQLSTATE `P0001` with exact message `posted/reversed journal lines are immutable`. Narrow test regex erroneously expected only `FINORA_POSTED_JOURNAL_CHILD_IMMUTABLE`; this is a QA assertion mismatch, not a server-accepted mutation. Widen the assertion solely to these two exact known guard messages. Subsequent linked draft-delete and readback checks had not been executed due to early assertion; rerun entire WP2/Quality/WP1/Security on new SHA. Never weaken production guard or claim fully green until exact-head success.
docs/EXECUTION_STATUS.md
+2
@@ -1,5 +1,7 @@
1 # وضعیت اجرای فینورا
2
3 +> **شکست مستند (RED) و علت:** PR227 `21709742c51a296b0d6044dc5125374c017de3aa`، WP2 `44985153735` در مقایسه متن خطای یک کنترل مالی شکست خورد؛ درخواست ویرایش سطر دفتر کل با JWT واقعی رد شده بود (SQLSTATE `P0001`، پیام `posted/reversed journal lines are immutable`)، ولی Regex فقط متن `FINORA_POSTED_JOURNAL_CHILD_IMMUTABLE` را می‌پذیرفت. با حفظ هر دو پیام معتبر و بدون تغییر guard، آزمون روی SHA بعدی تکرار می‌شود. آزمون‌های حذف voucher و readback قبلاً به‌علت این شکست اجرا نشده بودند.
4 +
5 ### ۲۰۲۶-۱۱-۲۲ — FIN-QA-POSTED-SOURCE-GUARD؛ آزمون منع تغییر سند قطعی با JWT
6 - **مبنای محفوظ:** PR226 `4f9a90c9a955800cd0ed83dc0184a5c2e8343a87`: Quality `44983973522`، WP1 `44983973555`، Security `44983973523` SUCCESS؛ WP2 روی آن SHA اجرا نشده. PR225 WP2 `44982300960` موفق بود و سند قطعی را ایجاد کرد.
7 - **کار محدود:** افزودن سناریوی منفی به `scripts/wp2-source-autopost-jwt-e2e.mjs` موجود: در tenant مصنوعیِ Supabase موقت پس از ثبت، حالت مالی `enforce` فعال و PATCH/DELETE حقیقی از سمت JWT صاحب سند برای تغییر فیلد تجاری، جعل پیوند، حذف منبع، تغییر سطر posted و حذف voucher از RPC انجام می‌شود. آزمون باید رد صریح guard مالی و عدم تغییر data/audit/counter را اثبات کند، نه تنها پاسخ RLS.
scripts/wp2-source-autopost-jwt-e2e.mjs
+1 -1
@@ -256,7 +256,7 @@ financialGuardRejected(await userRestMutation('DELETE','invoices',firstSource),
256 'posted sale direct delete',/FINORA_POSTED_SOURCE_IMMUTABLE|linked to posted\/reversed/i);
257 financialGuardRejected(await userRestMutation('PATCH','journalLines',frozenLines[0].id,{
258 ...frozenLines[0].data,debit:1
259 -}),'posted journal line edit',/FINORA_POSTED_JOURNAL_CHILD_IMMUTABLE/i);
259 +}),'posted journal line edit',/FINORA_POSTED_JOURNAL_CHILD_IMMUTABLE|posted\/reversed journal lines are immutable/i);
260 const deniedVoucherDelete=await rpc('finora_journal_delete_draft',{
261 p_organization_id:org,p_voucher_id:firstVoucher,
262 p_expected_version:frozenVoucher.version