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

docs(finance): record WP1 green gate and UI integration blocker

davoodmehraban89 committed Nov 16, 2026 at 07:01 UTC b16381138faeb17051c7453df98698314450401d
2 files changed +30 -2
PROJECT_STATE.md
+8 -1
@@ -344,4 +344,11 @@ Owner requests layer-by-layer click/functional testing of all controls and compa
344
345 ### 2026-11-15 — Source tenant audit attribution fix
346 - Latest WP1 run on `7b0d058e4eb8f3a791a68c2a82e043a0067ff4a8` passed reversal dimensions, then failed in `wp1_scope_move_and_null.sql` at the final audit-to-off move. This is a real function issue, not a fixture issue: `guard_server_journal_fields` passed NEW organization to `log_guard`, while the actor is authorized in OLD/source organization.
347 -- Added candidate migration `20261115150000_wp1_scope_move_audit_source_tenant.sql` to attribute identity-move guard audit to OLD organization; added conservative DOWN. No production deployment. Exact-head WP1 UP/DOWN/UP and full security/quality CI pending.
\ No newline at end of file
347 +- Added candidate migration `20261115150000_wp1_scope_move_audit_source_tenant.sql` to attribute identity-move guard audit to OLD organization; added conservative DOWN. No production deployment. Exact-head WP1 UP/DOWN/UP and full security/quality CI pending.
348 +
349 +### 2026-11-16 — WP1 exact-head CI green; integration remains blocked
350 +- Exact PR206 head `42a044f7b53a53fa7b8a3a82fa3c5d87e0004da0` passed all three GitHub checks: WP1 disposable ledger proof, Security checks, Quality checks.
351 +- WP1 job completed all stages: expected RED baseline; isolated financial contract; correction UP/DOWN/UP and retained history; reversal dimensions; manual update guards; NULL revision; complete graph read; concurrent graph snapshot; full candidate conservative DOWN/UP; synthetic evidence upload.
352 +- The full candidate DOWN/UP step reports 11 prerequisite and 8 correction migrations, baseline functions/ACLs/triggers restored, retained rows unchanged, and D1/D2 enforced again in the disposable DB. This is not a Production rollback rehearsal.
353 +- Post-CI review found the live UI is not yet using the dedicated journal RPC surface: `journal-engine.js` mutates local datastore and calls `saveDatastore`; `journal-ui.js` invokes synchronous legacy methods; `sync.js` sends generic diffs via `finora_sync_records`. Browser workflow tests mock this generic sync path and do not establish dedicated RPC integration.
354 +- PR206 remains Draft/unmerged. Next package: async journal repository adapter for create/update/post/delete/reverse/read-graph, server response reconciliation, version/idempotency/permission/network tests, then source workflow adapters. Independent SQL/ACL/RLS and live Auth/JWT/PostgREST/schema parity remain mandatory gates.
\ No newline at end of file
docs/audits/WP1_DB_ONLY_INTEGRATION_CANDIDATE_2026-11-15_FA.md
+22 -1
@@ -78,4 +78,25 @@ The event is evidence of an attempted mutation of the source tenant’s posted j
78
79 ## Source-tenant audit attribution correction — 2026-11-15
80
81 -The exact-head WP1 rerun confirmed `wp1_reversal_dimensions.sql` passes and exposed a real guard-function issue in `wp1_scope_move_and_null.sql`: when a posted voucher is moved between organizations while the source is audit and destination is off, `finora_phase1a_guard_server_journal_fields` derives the logger organization from NEW row scope. It then tries to write the guard event into the destination tenant, where the source actor is not a member; the tenant-scoped logger correctly rejects this. Added migration `20261115150000_wp1_scope_move_audit_source_tenant.sql` to attribute identity-move guard events to OLD/source organization, plus a conservative DOWN restoring the prior function. Existing fixture expects source tenant, source actor and voucher ID. Exact-head CI must validate UP/DOWN and all regressions before any merge.
\ No newline at end of file
81 +The exact-head WP1 rerun confirmed `wp1_reversal_dimensions.sql` passes and exposed a real guard-function issue in `wp1_scope_move_and_null.sql`: when a posted voucher is moved between organizations while the source is audit and destination is off, `finora_phase1a_guard_server_journal_fields` derives the logger organization from NEW row scope. It then tries to write the guard event into the destination tenant, where the source actor is not a member; the tenant-scoped logger correctly rejects this. Added migration `20261115150000_wp1_scope_move_audit_source_tenant.sql` to attribute identity-move guard events to OLD/source organization, plus a conservative DOWN restoring the prior function. Existing fixture expects source tenant, source actor and voucher ID. Exact-head CI must validate UP/DOWN and all regressions before any merge.
82 +
83 +## Final exact-head CI result — commit `42a044f7b53a53fa7b8a3a82fa3c5d87e0004da0`
84 +
85 +All three dedicated checks completed successfully on the exact PR head:
86 +- `WP1 disposable ledger proof`: success. Baseline RED detected the expected missing guards; all green fixtures passed, including the 1,000-event/two-organization randomized property suite, reversal dimension preservation, scope-move/null behavior, and two-session concurrency. The candidate correction cycle verified UP/DOWN/UP with retained history. The full candidate conservative DOWN/UP verified 11 prerequisites and 8 correction migrations, restoration of baseline functions/ACLs/triggers, unchanged retained rows, and re-enforcement of D1/D2 in the disposable environment.
87 +- `Security checks`: success (CodeQL and release/QA safety invariants; dependency review skipped by workflow conditions).
88 +- `Quality checks`: success (static quality and three database quality jobs).
89 +
90 +## Post-CI integration review — manual journal UI remains a hard blocker
91 +
92 +Review of the exact same commit's application sources found that the database RPC surface is not yet the application's journal mutation path:
93 +- `js/journal-engine.js` still implements `jeCreateDraft`, `jePost`, `jeReverse`, `jeUpdateDraft`, `jeDeleteDraft` by mutating local `datastore` and calling `saveDatastore()`.
94 +- `js/journal-ui.js` calls those synchronous legacy functions directly from `jeSaveManual`, `jePostUi`, and `jeReverseUi`.
95 +- `js/sync.js` persists generic collection diffs through `sb.rpc('finora_sync_records', ...)`; it does not invoke the dedicated `finora_journal_create_draft`, `finora_journal_update_draft`, `finora_journal_post`, `finora_journal_reverse`, or `finora_journal_read_graph` RPCs.
96 +- Existing browser workflow tests exercise the generic sync mock; they do not prove that the live journal form uses the new dedicated journal RPC surface.
97 +
98 +Therefore a green database-only proof is not end-to-end accounting acceptance. The next work package must create an asynchronous journal repository/adapter, route manual draft create/update/post/delete/reverse and journal read graph through the dedicated RPCs, reconcile authoritative server responses into the UI state, and test retries, version conflicts, permission failures, and partial network failure. Source-driven sales/purchase/treasury posting must be migrated separately and not silently left on generic sync.
99 +
100 +## Gate decision
101 +
102 +PR206 remains Draft and is not merged. No Production database, migration, data, Auth/RLS, role/grant, deployment, or live service has been changed. Remaining pre-merge gates include independent SQL/ACL/RLS review, live schema and Auth/JWT/PostgREST parity, the manual UI RPC adapter, source workflow adapters, account-specific required/optional dimension rules, performance evidence, and backup/restore rehearsal.
\ No newline at end of file