سامانه صدور فاکتور و حسابداری
docs(finora): close PR247 QA proof with confirmed false draft-delete guard P1 and owner handoff
davoodmehraban89 committed
Nov 23, 2026 at 23:19 UTC
898b1f89265533edf9a5e5bcfb5a89cedeaa957e
1 file changed
+8
PROJECT_STATE.md
+8
@@ -473,3 +473,11 @@ Next action: run and inspect Quality on the latest PR212 head. If any browser te
473
- **Actual tested QA HEAD `9ede2a596b2f12ad05e530e27d8dcf6587a6ca69`**, [WP1 #45250410434](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45250410434): disposable SQL reached `WP4_MANUAL_LIFECYCLE_PASS` and `WP4_TOMBSTONE_AND_NONREUSE_PASS`, then failed **`source record linked to posted/reversed accounting history is immutable`** when deleting `WP4_INV_B` linked to a just-inserted `WP4_SOURCE_V_B` draft. Error originates from `public.finora_guard_posted_source_records()` (source migration `20261117120000_wp1_stage3_canonical_source_link_projection.sql`), not the fixture's own explicit failure assertion. This is a potentially **real product integration blocker P1** in PR219, distinct from earlier missing JSON link and independent of ordinary posted-history immutability.
474
- **Code-grounded causal hypothesis**: new PR219 lifecycle BEFORE DELETE trigger (migration `20261118100000_journal_document_lifecycle.sql`, lines ~640–655) deletes linked draft voucher on source DELETE when `journalVoucherId` exists. Existing `finora_guard_posted_source_records()` queries voucher status using `SELECT ... INTO voucher_status`; no matching voucher yields NULL, and `source_locked := ... OR voucher_status IN ('posted','reversed')` becomes NULL for otherwise-unlocked source. `IF NOT source_locked THEN RETURN` does not return on NULL and raises posted-history immutability error. This could arise from ordered BEFORE DELETE triggers; **not yet separately instrumented** to prove trigger order and no preexisting posted status. The earlier unlinked source deletion had simply left an orphan voucher; when link was added the guard now blocks deletion.
475
- **Before further test edit**, add only explicit existing-PERSISTED source `accountingStatus/documentStatus=draft` and linked journal `status=draft` assertions/NOTICE to the QA SQL fixture immediately before the source DELETE. This will make the next executable log prove whether both rows were definitely draft immediately before the failing request; do not change production guards or weaken posted history protection. Retain strict delete/tombstone assertions (no xfail), verify new exact-head local WP1. If failure survives with both draft preconditions, open separate P1 blocking issue and handoff to Codex-main; do NOT turn failing product scenario into passing QA. Parent PR219 still has independent Quality/Security Syntax, WP2 Auth fixture, historic posted→draft risks. No Prod/main/merge. A90/B50/C20/D55/E53/F10 unchanged.
476
+
477
+
478
+### 2026-11-23 — FIN-QA-219-WP4-DRAFT-SOURCE-DELETE / final executable evidence and owner handoff
479
+- **Confirmed PRODUCT CANDIDATE INTEGRATION P1 in Draft PR219, not production:** [QA Draft PR247](https://github.com/davoodmehraban89/Factor-easy/pull/247) tested exact **code/test SHA `65e667b9b77aab8bcdb4a436ddad0a6e6b138b1a`**, [WP1 #45252233555](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45252233555), local `supabase-local-stack` job concluded **FAILURE**, while larger WP1 run's ledger-negative job was still in progress on latest check. This failure is from *disposable migrated PostgreSQL* with SQL-auth-claim synthetic owner, **not** a real JWT, customer ledger or live Supabase. Own QA fixture now has Auth-trigger-backed org+member+license, open company/FY/accounts, repaired DO dollar delimiters, strict posted-delete denial+voucher/registry/line unchanged assertions, both deletion directions correctly linked.
480
+- **Log hard evidence:** `WP4_MANUAL_LIFECYCLE_PASS`, `WP4_TOMBSTONE_AND_NONREUSE_PASS`, and uniquely strong `WP4_LINKED_SOURCE_AND_VOUCHER_ARE_DRAFT_PASS`: the fixture queried persisted invoice `documentStatus/accountingStatus=draft` and persisted linked voucher `status=draft` immediately before deletion, checked voucher `sourceType='sale'/sourceId` plus source `journalVoucherId`. Subsequent exact `DELETE invoices/WP4_INV_B` fails with `source record linked to posted/reversed accounting history is immutable` from `public.finora_guard_posted_source_records()`. This is a **wrongly blocked valid DRAFT source delete**, no expected-RED security PASS and no valid source↔voucher deletion completion. Earlier unlinked fixture failed the inverse expectation, proving the canonical JSON link matters.
481
+- **Likely mechanism (not separately instrumented trigger order):** PR219 `20261118100000_journal_document_lifecycle.sql` BEFORE DELETE source trigger first removes linked draft voucher; prior `20261117120000_wp1_stage3_canonical_source_link_projection.sql` public posted-source guard then `SELECT INTO voucher_status` finds no linked row (NULL), `source_locked` becomes NULL due SQL OR tri-state, and `IF NOT source_locked` does not return, thus falls through to posted-history immutable error. Confirm trigger order in separate disposable SQL instrumentation before selecting corrective design; never disable posted immutability.
482
+- **Tracking:** opened [Issue248 P1](https://github.com/davoodmehraban89/Factor-easy/issues/248) with exact evidence/acceptance. Notified Codex-main via [PR219 owner handoff](https://github.com/davoodmehraban89/Factor-easy/pull/219#issuecomment-7112139779). Required product repair: authenticated authorized draft source↔voucher deletion both directions atomic, tombstone/ATF nonreuse, correct tenant/company/fiscal scope, absolutely no posted/reversed history mutation; preserve direct/real-JWT negative cases and ensure positive draft case. Test stays **failing** to prevent misleading release gate. Financial migration, JS and tenant guards remain Codex-main exclusive.
483
+- **Current QA SHA gate separation:** for the tested `65e667b9...`, Security #45252233657 FAILED and Quality #45252233620 FAILED (parent PR219 JS SyntaxError), WP2 #45252233673 FAILED (parent Auth-fixture guard), local WP1 SQL job FAILED (real new P1; entire WP1 still in_progress last checked). These are **not** fixed by QA-only PR247. Protected `main` still `dab1a45fcfc4f12e675cfe055e477138cd3e99fa`, PR219/247 Draft. No production data/permissions/migration/merge/deploy touched. This docs append creates a new SHA **without new business or test code changes**; exact new SHA workflow results must not be claimed inherited. Stage A90/B50/C20/D55/E53/F10 unchanged.