سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 4, 08:00 UTC
feat: read complete authorized journal graphs from one snapshot
JVK committed
Nov 4, 2026 at 22:18 UTC
61092e4810b6e0b9ab66bd7ecffbd557bea71eda
53 files changed
+1661
-19
.github/workflows/wp1-ledger.yml
+6
@@ -33,6 +33,10 @@ jobs:
33
run: node scripts/wp1-manual-guards-cycle.mjs
34
- name: Prove NULL revision rejection and rollback
35
run: node scripts/wp1-null-revision-cycle.mjs
36
+ - name: Prove complete journal graph visibility and rollback
37
+ run: node scripts/wp1-graph-read-cycle.mjs
38
+ - name: Prove graph snapshot across a concurrent commit
39
+ run: node scripts/wp1-graph-snapshot-test.mjs
40
- name: Verify full candidate conservative DOWN and UP
41
run: node scripts/wp1-prerequisite-rollback.mjs
42
- name: Upload synthetic evidence
@@ -46,4 +50,6 @@ jobs:
50
docs/wp1/evidence/reversal-dimensions/
51
docs/wp1/evidence/manual-update-guards/
52
docs/wp1/evidence/null-revision/
53
+ docs/wp1/evidence/graph-read/
54
+ docs/wp1/evidence/graph-snapshot/
55
retention-days: 14
PROJECT_STATE.md
+8
@@ -293,3 +293,11 @@ Owner requests layer-by-layer click/functional testing of all controls and compa
293
- Final15migration chain complete local proof PASS: all16SQLfiles including seeded1000events plusactualtwo-sessionconcurrency. Full15DOWN/UP restores71baselinefunctions/ACLs/triggers, retains4posted/10lines/10audit/counters byhash, andD1/D2 re-enforce afterUP. Dedicated reversal/manual/NULLcycles allPASS with exactpriorfunctions/ACLs andretainedhistory. Evidence docs/wp1/evidence/integrated-15 andprerequisite-rollback.
294
- New scoped fixes: analytical tags preserved onfull/partialreversal;17manualdate/type/scope bypasses rejected; NULL revisions rejected beforefournewjournalmutations(16negativecases), authorizedread-onlyreplayunchanged. All97manifestbodyhashes,manifestmutations,staticquality/release-safety and43clientprotocoltestsPASS. No runtimeJS changes since reviewed56818d8. SQL independently reviewed byroot only; independent specialist review remains open.
295
- Goals/current/remaining updated in docs/wp1/STATUS_FA.md, docs/ROADMAP_CURRENT.md, docs/EXECUTION_STATUS.md, SOURCE_COVERAGE andROLLOUT_HOLD. Source-backed next-step plan docs/wp1/MANUAL_RPC_NEXT.md: single-snapshot RLS graphread, pending-edit-safe merge, explicitmanualUI adapter, atomiclinkedcorrection anddimensioncontract; no graphRPC/UIadapter yet. WP1 and laterpackages notcomplete. No productionmutation/merge/deploy; G1–G5 unchanged. PublishcandidateandverifyexactnewheadCI next.
296
+
297
+### 2026-11-04 — Manual graph read prerequisite
298
+- Continue approved WP1 plan docs/wp1/MANUAL_RPC_NEXT.md while published4149d50 CI runs. Implement only the read-only, single-snapshot journal graph RPC with SECURITY INVOKER/RLS, explicit authenticated grants, deterministic complete children and derived reversal status. Missing/invisible header returns NULL. Any visible child assigned to the voucher with wrong company or a dimension without a visible matching line fails closed (FINORA_JOURNAL_GRAPH_INVALID), rather than silently dropping financial detail. No UI mutation adapter yet.
299
+- Dedicated isolated branch from4149d50; CLI additive migration + DOWN, authenticated SQL cross-tenant/revoked/anon tests, >1000 graph rows and exact rollback with unchanged data. No production operation; independent SQL review and real JWT/PostgREST still outstanding.
300
+- Read-only security design refinement before implementation: invoker RLS alone can hide a child or reversal while leaving the header visible, yielding incomplete amounts/status. Keep the public graph RPC SECURITY INVOKER; add a private STABLE boolean completeness helper with explicit auth.uid + existing can_access_record checks on the visible header and every related graph/reversal record. It returns only a permission decision, never hidden data/counts; PUBLIC/anon execute revoked. Any denied related row makes the public read fail42501 rather than returning a partial graph. This is a completeness check, not a grant or RLS policy bypass. Test confidential-child/reversal visibility explicitly.
301
+- Graph candidate verified: complete1003-record response; exact draft/posted/partial/fullstatus; immutable original header/revision; both-directiontenantisolation withcollidingIDs; read-only/suspended/anon roles; hiddenchild/reversal failclosed;4malformedlinks rejected. Initialtestfixture seat/pending-trigger failures fixed by explicit synthetic seats andconstraintflush, noapplicationguardrelaxed. InitialrepeatedRLSquery interrupted forslowness; materializedrowsreused andsameexistingstatusaggregatecomputedwithout rereadingtheview. Local probes~7.04slarge/~3.35sposted withotherdisposabletestsrunning; notperformanceacceptance.
302
+- DedicatedgraphUP/DOWN/UP andsecurity-definerauditPASS; records/audit/counters/members/permissionsunchanged. Full16migrationconservativeDOWN/UPPASS.16SQLfilesexcludingseeded1000 plusactualpostingconcurrencyPASS. Separatetwo-sessiongraphsnapshotPASS: commitafterreadsnapshotbegins yieldscompleteoldgraph, freshreadcompleteupdatedgraph; local-onlyVOLATILEmutant fails2!=1 asintended. Evidence docs/wp1/evidence/graph-read,graph-read-regressions,graph-snapshot. Rootreviewonly; independentSQLreview,realJWT/PostgREST,latencyacceptance andmanualUIadapter remainopen. No productionchange.
303
+- Published4149d50 exact-headCI nowallSUCCESS: Quality41921247467,Security41921247463,WP1proof41921247407, includingfull1000/concurrency andall15DOWN/UP plusdedicatedcycles. This is evidencefor15migrationcode, notthenewread-graphcandidate. Publishreadprerequisiteandverifyitsnewhead separately; UIadapterstillnext. Main4416794 unchanged.
docs/EXECUTION_STATUS.md
+3
-2
@@ -3,8 +3,9 @@
3
هدف جاری: تکمیل WP1 با ثبت مالی معتبر سمت سرور و حفاظت ویرایشهای ذخیرهنشده. مالک ادامه همه WPها را مجاز کرده؛ گیت هر مرحله و G1–G5 برقرار است. [نقشه راه جاری](ROADMAP_CURRENT.md) و [وضعیت دقیق WP1](wp1/STATUS_FA.md) مرجع فعلیاند.
4
5
- انجامشده: WP0 و CI آن؛ اتصال امن کلاینت در56818d8 و تمام CI آن؛ ۲۲۲ آزمون مرورگر،۴۳ آزمون Node،۸ آزمون Pages و۵۵ فرمان کنترل موفق.
6
-- اصلاحهای جدید: حفظ ابعاد برگشت سند و کنترل تاریخ/نوع سند دستی؛ زنجیرهٔ۱۴تغییر در تمام آزمونهای مالی شامل۱۰۰۰رویداد،همزمانی و DOWN/UP موفق است. نسخهٔ خالی نیز پس از بازتولید چهار نقص در عملیات سند اصلاح شد و۱۶آزمون منفی و چرخهٔ اختصاصی آن موفقاند؛ آزمون کامل محلی زنجیرهٔ۱۵تغییر شامل۱۶فایل SQL،۱۰۰۰رویداد،همزمانی و DOWN/UP موفق است؛ CI نسخهٔ جدید جداگانه بررسی میشود.
7
-- باقیمانده: خواندن یکپارچه و مسیرRPC سند دستی، اصلاح/ابطال تراکنشی خرید،قرارداد ابعاد و پوشش منابع،حل تعارض،تطبیق ساختار واقعی،shadowکامل،پذیرش واقعی،بکاپ/بازیابی و بستهG1. بازبینی مستقل SQL، ممیزی همهٔ دکمهها و ورود روی اینترنت مالک هنوز پذیرش نهایی ندارند. نصب عملیاتی انجام نشده است.
6
+- اصلاحهای جدید: حفظ ابعاد برگشت سند و کنترل تاریخ/نوع سند دستی؛ زنجیرهٔ۱۴تغییر در تمام آزمونهای مالی شامل۱۰۰۰رویداد،همزمانی و DOWN/UP موفق است. نسخهٔ خالی نیز پس از بازتولید چهار نقص در عملیات سند اصلاح شد و۱۶آزمون منفی و چرخهٔ اختصاصی آن موفقاند؛ آزمون کامل محلی زنجیرهٔ۱۵تغییر شامل۱۶فایل SQL،۱۰۰۰رویداد،همزمانی و DOWN/UP موفق است؛ CI کامیت4149d50 نیز کامل و موفق است. مسیر خواندن جدید CI جداگانه لازم دارد.
7
+- پیشنیاز جدید: خواندن یکپارچهٔ سند با کنترل کامل دسترسی،۱۰۰۳رکورد و دو اتصال آزمایش شد؛ زنجیرهٔ۱۶تغییر DOWN/UP موفق است. کارایی واقعی و CI نهایی جداگانه بررسی میشوند.
8
+- باقیمانده: ادغام پاسخ خواندن یکپارچه و مسیرRPC سند دستی، اصلاح/ابطال تراکنشی خرید،قرارداد ابعاد و پوشش منابع،حل تعارض،تطبیق ساختار واقعی،shadowکامل،پذیرش واقعی،بکاپ/بازیابی و بستهG1. بازبینی مستقل SQL، ممیزی همهٔ دکمهها و ورود روی اینترنت مالک هنوز پذیرش نهایی ندارند. نصب عملیاتی انجام نشده است.
9
10
## سوابق پیشین (وضعیتهای تاریخدار)
11
docs/ROADMAP_CURRENT.md
+2
-2
@@ -18,7 +18,7 @@
18
## کار جاری
19
20
۱. اتصال امن sync در کامیت56818d8 و تمام CI آن موفق است؛ ۲۲۲ آزمون مرورگر و ۴۳ آزمون ویژهٔ تعارض/سازمان نیز موفقاند.
21
-۲. حفظ ابعاد در برگشت و کنترل تاریخ/نوع سند دستی با آزمون کامل زنجیرهٔ۱۴تغییر موفقاند. کنترل نسخهٔ خالی نیز پس از بازتولید چهار نقص اصلاح شد؛ آزمون نهایی زنجیرهٔ۱۵تغییر شامل۱۶فایل SQL،۱۰۰۰رویداد،همزمانی و DOWN/UP کامل موفق است؛ CI نسخهٔ جدید جداگانه بررسی میشود.
22
-۳. ادامهٔ WP1: خواندن یکپارچهٔ سند با رعایت دسترسی، اتصال فرم دستی به RPC، اصلاح/ابطال تراکنشی خرید، قرارداد ابعاد و پوشش منابع. [بسته انتشار هنوز آماده نیست](wp1/ROLLOUT_HOLD.md).
21
+۲. حفظ ابعاد در برگشت و کنترل تاریخ/نوع سند دستی با آزمون کامل زنجیرهٔ۱۴تغییر موفقاند. کنترل نسخهٔ خالی نیز پس از بازتولید چهار نقص اصلاح شد؛ آزمون نهایی زنجیرهٔ۱۵تغییر شامل۱۶فایل SQL،۱۰۰۰رویداد،همزمانی و DOWN/UP کامل موفق است؛ CI کامیت4149d50 نیز کامل و موفق است. مسیر خواندن جدید CI جداگانه لازم دارد.
22
+۳. خواندن یکپارچهٔ سند نیز در شاخهٔ آزمایشی با آزمون دسترسی،۱۰۰۳رکورد،دو اتصال همزمان و DOWN/UP موفق است. ادامهٔ WP1: ادغام امن پاسخ و اتصال فرم دستی به RPC، اصلاح/ابطال تراکنشی خرید، قرارداد ابعاد و پوشش منابع. [بسته انتشار هنوز آماده نیست](wp1/ROLLOUT_HOLD.md).
23
24
تست synthetic یا SQL fixture معادل تأیید ورود روی اینترنت مالک، JWT/PostgREST واقعی،چاپگر یا داده واقعی نیست. هیچ درصد تکمیل ساختگی گزارش نمیشود. G1 نصب migration،G2 تنظیمات داشبورد،G3 راز بکاپ،G4 داده تست Production وG5 هزینه همچنان فقط پس از آمادهشدن نتیجه قابل بررسی به مالک ارجاع میشوند.
docs/wp1/JOURNAL_GRAPH_READ.md
new
+29
@@ -0,0 +1,29 @@
1
+# Journal graph read prerequisite
2
+
3
+Candidate only; no production deployment or UI activation. Public API:
4
+
5
+`finora_journal_read_graph(p_organization_id uuid, p_voucher_id text) -> jsonb | null`
6
+
7
+The response contains `organization_id`, `voucher_id`, `effective_status`, and deterministically ordered `records` with `collection`, `id`, original `data`, and separate `version`. Only the requested voucher/lines/dimensions are returned. The original posted header remains posted and its revision is unchanged; effective status is derived from related posted reversal lines with the same aggregate semantics as the existing reversal-status view. It is display metadata, not a replacement for stored financial history.
8
+
9
+The public function is STABLE SECURITY INVOKER with an empty search path, with PUBLIC/anon execution revoked. A missing or RLS-invisible header returns null, even if orphan child rows exist. One SQL statement and STABLE helpers use one snapshot. Materialized rows are reused for the derived status, avoiding repeated reads through the reversal view and records table. Aggregation returns a scalar JSON graph rather than independently paginated rows; the SQL fixture verifies1003 records in one response. Actual PostgREST/JWT and response-size/performance acceptance remain separate tests.
10
+
11
+## Complete visibility, not partial financial data
12
+
13
+Invoker RLS alone can reveal a header while hiding a confidential child or reversal. The private `finora_journal_graph_accessible` helper returns only a boolean. It requires `auth.uid()`, checks header permission, then uses the existing `private.can_access_record(...,'read')` predicate on all related voucher/line/dimension records, including reversals that contribute to status. It is STABLE SECURITY DEFINER with an empty search path, no PUBLIC/anon execution, no data/count return, and no writes. The public function still obtains every returned row through RLS.
14
+
15
+If any related record is inaccessible, the public function raises `42501 FINORA_JOURNAL_GRAPH_FORBIDDEN`. Visible mismatched-company or malformed dimension/line/voucher links raise `23514 FINORA_JOURNAL_GRAPH_INVALID`; they are never silently omitted or normalized. This completeness helper follows the existing records policy predicate; any future records-policy changes require renewed completeness review/tests. It grants no new record permission.
16
+
17
+## Verification and boundaries
18
+
19
+- Baseline RED: endpoint absent, exact `WP1_GRAPH_RPC_MISSING` marker.
20
+- Authenticated SQL tests cover draft/posted/partial/full reversal status, unchanged original header/revision, deterministic exact graph,1003-record graph, absent header/orphans, both directions of tenant isolation with colliding IDs, read-only member, suspended member, confidential child/reversal, anon denial, and four malformed graph relationships.
21
+- Fixture-only malformed/large legacy records are seeded by the local superuser with user triggers temporarily disabled and immediately restored. Prior pending constraints are explicitly checked first; no production fixture is authorized.
22
+- Initial fixture failures were a missing synthetic license seat and pending-trigger events before fixture ALTER; the fixture now provisions its explicit seats and checks constraints first. No application/license guard was weakened.
23
+- The initial query repeatedly reread RLS-protected rows and was stopped during the large fixture. The candidate reuses materialized rows and computes the existing status semantics from them. No percentage performance improvement is claimed from an interrupted run. SQL probe timings are evidence only, not a production latency target.
24
+- Dedicated UP/DOWN/UP passed: remove/recreate exactly the two functions with the same ACLs and preserve records/audit/counters/member permissions. Full16-migration conservative DOWN/UP passed and restores prior ledger APIs and financial history.
25
+- Two actual SQL sessions confirm a reader whose snapshot begins before a concurrent commit returns the complete old header/lines; a fresh read gets the complete new revision/amounts. No application function/policy is patched in the positive test. A local-only VOLATILE mutant must fail the old-revision assertion, proving the regression is sensitive to snapshot semantics. Evidence: `evidence/graph-snapshot/`.
26
+- Read-only probes leave records/audit/counters/members/permissions unchanged. One local run with other disposable tests running measured about7.04s for1003 records and3.35s for a posted graph in that same dataset. These are source-fixture SQL observations, not production benchmarks; latency/scaling acceptance remains open.
27
+- Evidence: `evidence/graph-read/result.json`, `evidence/graph-read/read-only-probe.log`, `evidence/graph-read-regressions/result.json`. The regression selection explicitly excludes seeded1000; the published15-migration chain has separate full1000 proof, and the new exact-head CI must run the full suite again.
28
+
29
+This prerequisite does not implement the manual form adapter, pending-edit-safe graph merge, atomic return-to-draft, purchase correction, dimension entity compatibility, or required/optional account rules. Independent SQL review remains open. See `MANUAL_RPC_NEXT.md` and `ROLLOUT_HOLD.md`.
docs/wp1/MANUAL_RPC_NEXT.md
+2
-2
@@ -1,6 +1,6 @@
1
# Next WP1 increment: manual journal server workflow
2
3
-Status: source-backed implementation plan, not implemented or accepted. Depends on the integrated ledger guards and versioned sync; remains in draft PR195. No production activation.
3
+Status: source-backed implementation plan. The read prerequisite now has an isolated candidate in JOURNAL_GRAPH_READ.md; client adapter/merge and remaining items are not implemented or accepted. Depends on the integrated ledger guards and versioned sync; remains in draft PR195. No production activation.
4
5
## Problem and invariant
6
@@ -10,7 +10,7 @@ Preserve the synchronous engine for existing callers; add an asynchronous adapte
10
11
## Ordered implementation
12
13
-1. **Read-only graph RPC.** Add a SQL/STABLE SECURITY INVOKER function returning the visible header plus journalLines/journalLineDimensions and separate record revisions in a single statement/snapshot. Use existing RLS; revoke PUBLIC/anon EXECUTE and grant authenticated only. Return null for an absent/invisible header, never an orphan child graph. Include organization/voucher identity and deterministic record ordering. Add `effective_status` from the existing security-invoker reversal view for posted originals, falling back to the stored status for drafts/reversal documents. Reject/omit cross-company or mismatched line links explicitly; do not normalize corrupt history. Document which behavior is selected in the test contract.
13
+1. **Read-only graph RPC.** Add a SQL/STABLE SECURITY INVOKER function returning the visible header plus journalLines/journalLineDimensions and separate record revisions in a single statement/snapshot. Use existing RLS; revoke PUBLIC/anon EXECUTE and grant authenticated only. A private boolean permission check must reject partially visible child/reversal graphs, without returning hidden records. Return null for an absent/invisible header, never an orphan child graph. Include organization/voucher identity and deterministic record ordering. Add `effective_status` from the existing security-invoker reversal view for posted originals, falling back to the stored status for drafts/reversal documents. Reject/omit cross-company or mismatched line links explicitly; do not normalize corrupt history. Document which behavior is selected in the test contract.
14
2. **Pending-edit-safe graph reconciliation.** Serialize with `syncRunning` and the normal sync queue; capture `finoraSyncContext`, hydrated tenant, company, form identity and affected records. Read/validate the complete graph before changing local arrays. Merge only affected rows and their `syncSnap`/`versionSnap` entries atomically, preserving unrelated dirty objects and timers. Check the context and affected local graph again after every await. Do not use `finoraPublishSyncSnapshot` to replace the whole datastore after a single operation.
15
3. **Manual form adapter.** Capture the expected revision when opening an edit. Whitelist company/year/date/description/reference/type for creation; date/description/reference/type for edits. Never send client numbers, posted fields, source authority or owner authority. Drafts have no server number until posting. Normalize dates and integer IRR amounts. Positive capability uses RPC; only an explicitly absent capability without positive revision evidence permits legacy behavior. No fallback after a supported endpoint fails.
16
4. **Mutation outcomes/retries.** Allow one pending form operation; retain the same intent ID and payload for uncertain create/reversal retries. Update/delete do not have identical replay semantics and need explicit reconciliation. If the server confirms a mutation but graph refresh fails or local input changed, display “server operation confirmed; display refresh pending” and retain the form/edits. A changed tenant/form must not be cleared by a stale completion. Derive totals from authoritative lines for display only; do not sync display-only fields into posted history.
docs/wp1/ROLLOUT_HOLD.md
+3
-3
@@ -2,15 +2,15 @@
2
3
Production G1 is not requested. Stacked work depends on WP0 PR194 and unmerged historical source; no production SQL has run.
4
5
-Candidate order is the eleven `2026101610*` archived Stage1–3 SQL files, followed in timestamp order by scope/authority hardening, reversal dimensions, manual update guards and NULL revision guards (`*_wp1_*.sql`, currently four corrections; fifteen files total). The initial files are preserved for provenance and must never be applied partially: early guards are strict before later mode definitions. Final production packaging must prove a single transactional UP and all DOWN paths on a complete clone/local stack before approval. Source-derived WP0 fixture excludes unrelated workflow schemas; passing that fixture is not production schema parity.
5
+Candidate order is the eleven `2026101610*` archived Stage1–3 SQL files, followed in timestamp order by scope/authority hardening, reversal dimensions, manual update guards NULL revision guards and the read-only journal graph prerequisite (`*_wp1_*.sql`, currently five additive files; sixteen files total). The initial files are preserved for provenance and must never be applied partially: early guards are strict before later mode definitions. Final production packaging must prove a single transactional UP and all DOWN paths on a complete clone/local stack before approval. Source-derived WP0 fixture excludes unrelated workflow schemas; passing that fixture is not production schema parity.
6
7
Required before G1:
8
9
-- Independent SQL review of the new additive repairs; the current root review and disposable regressions do not substitute for that review. Resolve entity-backed analytical dimensions and required/optional account rules before declaring manual source support complete.
9
+- Independent SQL review of the new additive repairs and the read-graph completeness helper; graph latency/scaling acceptance is still open. The current root review and disposable regressions do not substitute for that review. Resolve entity-backed analytical dimensions and required/optional account rules before declaring manual source support complete.
10
11
- Reconcile24/24historical migration-version drift by SQL content, and verify new columns/indexes/function contracts against the live catalog.
12
- Red/green tests for all corrective findings; actual concurrent posting;1000event trial balance; all suite and CI results at exact SHA.
13
-- Conservative DOWN/UP for all11prerequisites plus all four corrections is now locally proved (15 files):71baselinefunctiondefinitions/ACLs andbaseline triggers restored;4postedvouchers/10lines/10auditrows retained byhash; candidate APIs revoked, compatibleindexes/counters retained. Fresh exactheadCI andproductionparity remain gates. This is notpristineschema rollback.
13
+- Conservative DOWN/UP for all11prerequisites plus all five additive files is now locally proved (16 files):71baselinefunctiondefinitions/ACLs andbaseline triggers restored;4postedvouchers/10lines/10auditrows retained byhash; candidate APIs revoked, compatibleindexes/counters retained. Fresh exactheadCI andproductionparity remain gates. This is notpristineschema rollback.
14
- Capability-safe client56818d8 passed all exact-head CI; real-service integration and fresh CI for the subsequent SQL remain. Correct purchase correction/cancel transaction; no successful toast without server acknowledgement. Until proven, no enforcement cutover.
15
- Per-source shadow report including fieldscope/currency/period checks, not only aggregate balance. Existing11posted vouchers had zero anomalies in the limited aggregate audit; that is not full cutover approval.
16
- Read-only encrypted backup and disposable restore proof (G3secret viaenvironment), ordered verification queries, owner-reviewable G1 checklist.
docs/wp1/SOURCE_COVERAGE.md
+1
-1
@@ -2,7 +2,7 @@
2
3
| Source | Candidate server path | Current acceptance |
4
|---|---|---|
5
-| Manual journal | create/update/post/reverse RPC | Disposable SQL suite PASS; date/type guards and preserved reversal dimensions added; NULL revision proof and complete 15-migration local suite PASS; exact-head CI pending; manual UI RPC integration pending |
5
+| Manual journal | create/update/post/reverse RPC | Disposable SQL suite PASS; date/type guards and preserved reversal dimensions added; NULL revision proof and complete 15-migration local suite PASS; exact-head CI pending; read-graph RLS/snapshot proof PASS; manual UI RPC integration and latency acceptance pending |
6
| Sales invoice | server monetary contract + autopost | Disposable SQL suite PASS; end-to-end UI server path pending |
7
| Purchase invoice | fixed purchase contract + autopost | Disposable SQL suite PASS; client refuses unsupported ENFORCE correction; complete corrective/cancel transaction pending |
8
| Receipt/payment | existing staged RPC source allowlist | End-to-end server amount derivation and allocations NOT VERIFIED |
docs/wp1/STATUS_FA.md
+6
-3
@@ -4,9 +4,9 @@
4
5
## انجامشده با شاهد
6
7
-- زنجیره ۱۱ پیشنیاز و چهار اصلاح تکمیلی: حالت پیشفرض audit؛ تغییر حالت فقط برای مدیر سیستم؛ کنترل شرکت/سال/ارز/مبالغ؛ شمارنده تفکیکشده شرکت؛ حفاظت سند قطعی، ابعاد و انتقال هویت؛ مجوز برگشت تکراری. فایلهای اولیه برای ردیابی حفظ شدهاند؛ نصب جزئی آنها مجاز نیست.
7
+- زنجیره ۱۱ پیشنیاز و پنج تغییر افزایشی: حالت پیشفرض audit؛ تغییر حالت فقط برای مدیر سیستم؛ کنترل شرکت/سال/ارز/مبالغ؛ شمارنده تفکیکشده شرکت؛ حفاظت سند قطعی، ابعاد و انتقال هویت؛ مجوز برگشت تکراری. فایلهای اولیه برای ردیابی حفظ شدهاند؛ نصب جزئی آنها مجاز نیست.
8
- D1/D2 و ابعاد روی baseline با علت مورد انتظار شکست میخورند و روی اصلاح موفقاند. آزمونهای منفی، تراز ۱۰۰۰ رویداد و رقابت واقعی دو اتصال PostgreSQL موفقاند.
9
-- برگشت محافظهکارانه هر ۱۵ تغییر، سپس نصب مجدد موفق: تعریف و مجوز ۷۱ تابع پایه و تریگرهای قبلی بازمیگردد؛ ۴ سند قطعی، ۱۰ ردیف، ۱۰ رویداد ممیزی و شمارندهها بدون تغییر میمانند. ساختارها و ایندکسهای سازگار عمداً حفظ میشوند. [شاهد محلی](evidence/prerequisite-rollback/result.json).
9
+- برگشت محافظهکارانه هر ۱۶ تغییر، سپس نصب مجدد موفق: تعریف و مجوز ۷۱ تابع پایه و تریگرهای قبلی بازمیگردد؛ ۴ سند قطعی، ۱۰ ردیف، ۱۰ رویداد ممیزی و شمارندهها بدون تغییر میمانند. ساختارها و ایندکسهای سازگار عمداً حفظ میشوند. [شاهد محلی](evidence/prerequisite-rollback/result.json).
10
- کامیت `799cff4fcb1b9a98f763baf9e79a030c099deb58`: [Quality41626213964](https://github.com/davoodmehraban89/Factor-easy/actions/runs/41626213964)، [Security41626213753](https://github.com/davoodmehraban89/Factor-easy/actions/runs/41626213753) و [WP1 proof41626213760](https://github.com/davoodmehraban89/Factor-easy/actions/runs/41626213760) موفق؛ شامل آزمون کامل SQL و هر دو چرخه rollback. این شاهد به تغییرات بعد از این کامیت تعمیم داده نمیشود.
11
- محافظ اصلاح/ابطال خرید زیر ENFORCE، خطای ارتباط یا تعویض حساب پیش از تغییر محلی متوقف میشود. این محافظ معادل تکمیل گردش اصلاح خرید روی سرور نیست.
12
@@ -18,7 +18,10 @@
18
- مجموعهٔ این دو اصلاح با ۱۴ migration: تمام ۱۵ فایل آزمون SQL، شامل ۱۰۰۰ رویداد و همزمانی واقعی، و برگشت/نصب مجدد کامل موفقاند. [شواهد](evidence/integrated-14/green-results.json).
19
- [کنترل نسخهٔ خالی](NULL_REVISION_GUARDS_FA.md): چهار نقص ویرایش/حذف/قطعیکردن/برگشت بازتولید و اصلاح شد؛ ۱۶ حالت منفی، عملیات با نسخهٔ صحیح و تکرار امن درخواست موفقاند. چرخهٔ اختصاصی UP/DOWN/UP تعریف و مجوز چهار تابع و تاریخچه را حفظ میکند. آزمون کامل زنجیرهٔ نهایی ۱۵ تغییر نیز موفق است: هر ۱۶ فایل SQL، شامل ۱۰۰۰ رویداد و همزمانی واقعی. [شواهد نهایی محلی](evidence/integrated-15/green-results.json). CI نسخهٔ منتشرشده جداگانه بررسی میشود؛ نتیجهٔ نسخهٔ قبلی به آن تعمیم داده نمیشود.
20
21
-این اصلاحهای SQL بازبینی ریشهای و آزمون دارند؛ بازبینی مستقل متخصص SQL هنوز انجام نشده است. هدف بعدی، خواندن یکپارچهٔ سند و ردیفها با رعایت دسترسی و اتصال فرم دستی بدون از دسترفتن ویرایشهای دیگر است؛ [ترتیب اجرا و معیار پذیرش](MANUAL_RPC_NEXT.md).
21
+- کامیت `4149d50` (زنجیرهٔ۱۵تغییر) در [Quality41921247467](https://github.com/davoodmehraban89/Factor-easy/actions/runs/41921247467)، [Security41921247463](https://github.com/davoodmehraban89/Factor-easy/actions/runs/41921247463) و [WP1 proof41921247407](https://github.com/davoodmehraban89/Factor-easy/actions/runs/41921247407) موفق است؛ آزمون۱۰۰۰رویداد،همزمانی و تمام چرخهها کامل شدهاند. مسیر خواندن جدید به CI نسخهٔ خودش نیاز دارد.
22
+- [خواندن یکپارچهٔ سند](JOURNAL_GRAPH_READ.md) آمادهٔ بررسی است: آزمون۱۰۰۳رکورد، جداسازی سازمانها، عضو فقطخواندنی/تعلیقشده، ردیف و برگشت محرمانه و خطاهای اتصال ردیف موفقاند. آزمایش دو اتصال، نسخهٔ یکپارچهٔ قبل و بعد از ثبت همزمان را تأیید میکند. چرخهٔ اختصاصی و برگشت/نصب مجدد هر۱۶تغییر موفقاند. ۱۶ فایل SQL بهجز آزمون۱۰۰۰رویداد و رقابت ثبت نیز روی این زنجیره موفقاند؛ اجرای کامل CI جدید جداگانه لازم است. کارایی محیط واقعی و بازبینی مستقل هنوز تأیید نشدهاند.
23
+
24
+این اصلاحهای SQL بازبینی ریشهای و آزمون دارند؛ بازبینی مستقل متخصص SQL هنوز انجام نشده است. هدف بعدی، اتصال خواندن یکپارچه به فرم دستی و ادغام پاسخ بدون از دسترفتن ویرایشهای دیگر است؛ [ترتیب اجرا و معیار پذیرش](MANUAL_RPC_NEXT.md).
25
26
## باقیمانده برای پایان WP1
27
docs/wp1/evidence/graph-read-regressions/concurrency.log
new
+11
@@ -0,0 +1,11 @@
1
+{"name":"fixture","pass":true,"diagnostic":""}
2
+{"name":"drafts","pass":true,"diagnostic":""}
3
+{"name":"simultaneous_duplicate_create","pass":true,"diagnostic":" "}
4
+{"name":"concurrent_double_click_one_voucher_two_lines","pass":true,"diagnostic":"1,2\n"}
5
+{"name":"two_posts","pass":true,"diagnostic":" "}
6
+{"name":"gapless_numbers","pass":true,"diagnostic":"1,2\n"}
7
+{"name":"original","pass":true,"diagnostic":""}
8
+{"name":"two_reversals_one_winner","pass":true,"diagnostic":" ERROR: FINORA_REVERSAL_OVER_ALLOCATION\nCONTEXT: PL/pgSQL function public.finora_journal_reverse(uuid,text,text,text,text,bigint,jsonb) line 73 at RAISE\n"}
9
+{"name":"no_duplicate_reversals","pass":true,"diagnostic":"1\n"}
10
+{"name":"partial_status_from_view","pass":true,"diagnostic":"partially_reversed\n"}
11
+FINORA_STAGE1_TWO_CONNECTIONS_PASS
docs/wp1/evidence/graph-read-regressions/result.json
new
+139
@@ -0,0 +1,139 @@
1
+{
2
+ "scope": "All SQL except seeded1000, plus actual two-session concurrency; final full CI required",
3
+ "completed": true,
4
+ "applied": [
5
+ {
6
+ "file": "20261016100000_phase1a_server_journal_invariants.sql",
7
+ "sha256": "46c785652ebd48707fc6e8a86cffc70cbc4a2c5ef79b46acee08a8453d02a18a"
8
+ },
9
+ {
10
+ "file": "20261016100500_phase1a_optimistic_version_sync.sql",
11
+ "sha256": "9a38d8e238998c96a8f25e1b1c58c36f47a4ea00d56a90d668c70b465811abd9"
12
+ },
13
+ {
14
+ "file": "20261016101000_phase1a_guard_modes_audit.sql",
15
+ "sha256": "a94a0ee2ba6584ed3bbd4c7b550b02384f57b1f2592884e951da5945fb76919b"
16
+ },
17
+ {
18
+ "file": "20261016101500_phase1a_journal_core.sql",
19
+ "sha256": "95d64e86305dbcc40d2718a3f391e128c77b32d7a9ff86bfbf06b096682435d6"
20
+ },
21
+ {
22
+ "file": "20261016102000_phase1a_journal_rpc_surface.sql",
23
+ "sha256": "009d42fb3183277a72621ef107e1918d8e77e17ffbaa69447c10b0253145aa5b"
24
+ },
25
+ {
26
+ "file": "20261016102500_phase1a_account_role_protection.sql",
27
+ "sha256": "88f3f868d9d3eb8425eba5863d4cf637a387944423dc713ccc072a49688c1796"
28
+ },
29
+ {
30
+ "file": "20261016103000_phase1a_sale_monetary_contract.sql",
31
+ "sha256": "bc419c4a08f2a9d305e4b5387abaf2af4af3eb539f8f4143843c41f1cec3065e"
32
+ },
33
+ {
34
+ "file": "20261016103100_phase1a_autopost_server_authority.sql",
35
+ "sha256": "768a6cd5fc5f595a93240d05c43bb11f4866b5eae710af96f841cc92ec9ce61a"
36
+ },
37
+ {
38
+ "file": "20261016103500_phase1a_purchase_fixed_contract.sql",
39
+ "sha256": "a97c9d6d0bf1e98feb2081e9977f023d91fe13816532578be558bb4d4d03b5d9"
40
+ },
41
+ {
42
+ "file": "20261016104000_stage22_manual_guard_owner_mode.sql",
43
+ "sha256": "7b910723038bb6a8d1fde76fab654f7a6d42ed0f21f5013d466cf02d1be363dd"
44
+ },
45
+ {
46
+ "file": "20261016104500_stage3_posted_source_immutable.sql",
47
+ "sha256": "4ee4d3dd63dc3b47f6953227e4c3e1707e976b954b24bb8e99557bea20e4c3d4"
48
+ },
49
+ {
50
+ "file": "20261102141933_wp1_ledger_scope_authority_hardening.sql",
51
+ "sha256": "cdabffcfa64d99aa88fa900a799a953790a4918e790b644c0ae263c18aed771e"
52
+ },
53
+ {
54
+ "file": "20261104020908_wp1_reversal_dimensions.sql",
55
+ "sha256": "307eaf296a757462c2ec33d8c20c22abee0c63c0816872fc603b27f9498243e9"
56
+ },
57
+ {
58
+ "file": "20261104072719_wp1_manual_update_guards.sql",
59
+ "sha256": "be1e275fd1584cc08403423091784fc1b33eb561e5aefede0eaf4cc54afdca6d"
60
+ },
61
+ {
62
+ "file": "20261104214503_wp1_null_revision_guards.sql",
63
+ "sha256": "de8dffeab02aff67ac07c9d1d04f203ed0294285e102805cb97cf9bba1c16b98"
64
+ },
65
+ {
66
+ "file": "20261104220102_wp1_journal_graph_read.sql",
67
+ "sha256": "93f8b6e4b0462d504817b1360a9c0a09a7b35ab13bd6d9648ba1f981e3f544bb"
68
+ }
69
+ ],
70
+ "tests": [
71
+ {
72
+ "file": "wp1_direct_write_regressions.sql",
73
+ "status": 0
74
+ },
75
+ {
76
+ "file": "wp1_journal_graph_read.sql",
77
+ "status": 0
78
+ },
79
+ {
80
+ "file": "wp1_manual_update_guards.sql",
81
+ "status": 0
82
+ },
83
+ {
84
+ "file": "wp1_null_revision_guards.sql",
85
+ "status": 0
86
+ },
87
+ {
88
+ "file": "wp1_phase1a_cas_rls_behavior.sql",
89
+ "status": 0
90
+ },
91
+ {
92
+ "file": "wp1_phase1a_security_grants.sql",
93
+ "status": 0
94
+ },
95
+ {
96
+ "file": "wp1_phase1a_stage1_account_role_controls.sql",
97
+ "status": 0
98
+ },
99
+ {
100
+ "file": "wp1_phase1a_stage1_all_definer_security.sql",
101
+ "status": 0
102
+ },
103
+ {
104
+ "file": "wp1_phase1a_stage1_counter_two_fiscal.sql",
105
+ "status": 0
106
+ },
107
+ {
108
+ "file": "wp1_phase1a_stage1_sale_purchase_negatives.sql",
109
+ "status": 0
110
+ },
111
+ {
112
+ "file": "wp1_phase1a_stage1_sql_behavior.sql",
113
+ "status": 0
114
+ },
115
+ {
116
+ "file": "wp1_posted_identity_move.sql",
117
+ "status": 0
118
+ },
119
+ {
120
+ "file": "wp1_posting_negatives.sql",
121
+ "status": 0
122
+ },
123
+ {
124
+ "file": "wp1_reversal_dimensions.sql",
125
+ "status": 0
126
+ },
127
+ {
128
+ "file": "wp1_scope_move_and_null.sql",
129
+ "status": 0
130
+ },
131
+ {
132
+ "file": "wp1_shadow_and_constraint_contract.sql",
133
+ "status": 0
134
+ }
135
+ ],
136
+ "concurrency": {
137
+ "status": 0
138
+ }
139
+}
docs/wp1/evidence/graph-read-regressions/wp1_direct_write_regressions.sql.log
new
+18
@@ -0,0 +1,18 @@
1
+BEGIN
2
+INSERT 0 1
3
+ set_config
4
+--------------------------------------
5
+ f67a213d-9305-4893-9415-495a9d78b7cf
6
+(1 row)
7
+
8
+ set_config
9
+--------------------------------------
10
+ b1000000-0000-4000-8000-000000000001
11
+(1 row)
12
+
13
+INSERT 0 4
14
+DO
15
+SET
16
+DO
17
+ROLLBACK
18
+NOTICE: WP1_DIRECT_GUARDS_PASS: D1, independent RPC-balanced D2, dimension insert, spoofed GUC
docs/wp1/evidence/graph-read-regressions/wp1_journal_graph_read.sql.log
new
+154
@@ -0,0 +1,154 @@
1
+Timing is on.
2
+BEGIN
3
+Time: 0.275 ms
4
+DO
5
+Time: 1.014 ms
6
+INSERT 0 3
7
+Time: 10.020 ms
8
+ set_config
9
+--------------------------------------
10
+ 598277ff-cb58-4bce-b5dc-8e548dcafc2c
11
+(1 row)
12
+
13
+Time: 0.319 ms
14
+ set_config
15
+--------------------------------------
16
+ 8a8a2ac6-ea16-429b-a7cd-d1b26ad33906
17
+(1 row)
18
+
19
+Time: 0.210 ms
20
+ set_config
21
+--------------------------------------
22
+ ed000000-0000-4000-8000-000000000001
23
+(1 row)
24
+
25
+Time: 0.169 ms
26
+UPDATE 1
27
+Time: 0.513 ms
28
+INSERT 0 1
29
+Time: 0.766 ms
30
+INSERT 0 1
31
+Time: 2.125 ms
32
+INSERT 0 6
33
+Time: 8.799 ms
34
+SET
35
+Time: 0.227 ms
36
+ finora_journal_create_draft
37
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
38
+ {"voucher": {"id": "GR_DOC", "date": "1405/07/24", "status": "draft", "version": 1, "sourceId": "", "companyId": "GR_C", "createdAt": "2026-11-04T22:13:26.924235+00:00", "createdBy": "ed000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "", "voucherType": "manual", "fiscalYearId": "GR_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "645cd27c7b0f781da9049c5b7086562a", "reversalAllocations": null}, "replayed": false}
39
+(1 row)
40
+
41
+Time: 23.923 ms
42
+DO
43
+Time: 76.342 ms
44
+ finora_journal_post
45
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
46
+ {"voucher": {"id": "GR_DOC", "date": "1405/07/24", "number": "1", "status": "posted", "version": 2, "postedAt": "2026-11-04T22:13:27.016789+00:00", "postedBy": "ed000000-0000-4000-8000-000000000001", "sourceId": "", "companyId": "GR_C", "createdAt": "2026-11-04T22:13:26.924235+00:00", "createdBy": "ed000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "", "voucherType": "manual", "fiscalYearId": "GR_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "645cd27c7b0f781da9049c5b7086562a", "reversalAllocations": null}, "replayed": false}
47
+(1 row)
48
+
49
+Time: 8.398 ms
50
+DO
51
+Time: 31.278 ms
52
+ finora_journal_reverse
53
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
54
+ {"reason": "Graph partial reversal", "voucher": {"id": "GR_PART1", "date": "1405/07/25", "number": "2", "status": "posted", "version": 2, "postedAt": "2026-11-04T22:13:27.066009+00:00", "postedBy": "ed000000-0000-4000-8000-000000000001", "sourceId": "GR_DOC", "companyId": "GR_C", "createdAt": "2026-11-04T22:13:27.061059+00:00", "createdBy": "ed000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "reversal", "description": "برگشت سند 1", "voucherType": "reversal", "fiscalYearId": "GR_Y", "sourceVersion": "1", "reversalReason": "Graph partial reversal", "requestFingerprint": "6feffb2ba4fcf0961f6bc8693068268c", "reversalAllocations": [{"amount": 40, "lineId": "GR_LINE_A"}, {"amount": 40, "lineId": "GR_LINE_B"}]}, "replayed": false, "reversedBy": "ed000000-0000-4000-8000-000000000001", "originalVoucherId": "GR_DOC"}
55
+(1 row)
56
+
57
+Time: 12.719 ms
58
+DO
59
+Time: 108.482 ms
60
+ finora_journal_reverse
61
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
62
+ {"reason": "Graph remaining reversal", "voucher": {"id": "GR_PART2", "date": "1405/07/26", "number": "3", "status": "posted", "version": 2, "postedAt": "2026-11-04T22:13:27.18423+00:00", "postedBy": "ed000000-0000-4000-8000-000000000001", "sourceId": "GR_DOC", "companyId": "GR_C", "createdAt": "2026-11-04T22:13:27.181104+00:00", "createdBy": "ed000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "reversal", "description": "برگشت سند 1", "voucherType": "reversal", "fiscalYearId": "GR_Y", "sourceVersion": "1", "reversalReason": "Graph remaining reversal", "requestFingerprint": "e1bc3f78ac7bcb43df7f0552037cdaac", "reversalAllocations": [{"amount": 60, "lineId": "GR_LINE_A"}, {"amount": 60, "lineId": "GR_LINE_B"}]}, "replayed": false, "reversedBy": "ed000000-0000-4000-8000-000000000001", "originalVoucherId": "GR_DOC"}
63
+(1 row)
64
+
65
+Time: 9.574 ms
66
+DO
67
+Time: 174.732 ms
68
+SET CONSTRAINTS
69
+Time: 6.854 ms
70
+RESET
71
+Time: 0.222 ms
72
+ALTER TABLE
73
+Time: 0.937 ms
74
+INSERT 0 4
75
+Time: 0.854 ms
76
+INSERT 0 1002
77
+Time: 33.702 ms
78
+ALTER TABLE
79
+Time: 1.515 ms
80
+SET
81
+Time: 0.180 ms
82
+DO
83
+Time: 16631.918 ms (00:16.632)
84
+ set_config
85
+--------------------------------------
86
+ ed000000-0000-4000-8000-000000000002
87
+(1 row)
88
+
89
+Time: 0.311 ms
90
+DO
91
+Time: 17.832 ms
92
+ set_config
93
+--------------------------------------
94
+ ed000000-0000-4000-8000-000000000003
95
+(1 row)
96
+
97
+Time: 0.331 ms
98
+DO
99
+Time: 3494.915 ms (00:03.495)
100
+RESET
101
+Time: 0.305 ms
102
+ALTER TABLE
103
+Time: 0.707 ms
104
+UPDATE 1
105
+Time: 1.000 ms
106
+ALTER TABLE
107
+Time: 0.517 ms
108
+SET
109
+Time: 0.070 ms
110
+DO
111
+Time: 3366.326 ms (00:03.366)
112
+RESET
113
+Time: 0.246 ms
114
+ALTER TABLE
115
+Time: 0.821 ms
116
+UPDATE 1
117
+Time: 1.678 ms
118
+UPDATE 1
119
+Time: 0.797 ms
120
+ALTER TABLE
121
+Time: 0.931 ms
122
+SET
123
+Time: 0.117 ms
124
+DO
125
+Time: 3465.704 ms (00:03.466)
126
+RESET
127
+Time: 0.227 ms
128
+UPDATE 1
129
+Time: 0.999 ms
130
+SET
131
+Time: 0.112 ms
132
+DO
133
+Time: 0.559 ms
134
+RESET
135
+Time: 0.074 ms
136
+ set_config
137
+--------------------------------------
138
+ ed000000-0000-4000-8000-000000000001
139
+(1 row)
140
+
141
+Time: 0.106 ms
142
+DO
143
+Time: 14039.943 ms (00:14.040)
144
+SET
145
+Time: 0.244 ms
146
+DO
147
+Time: 0.287 ms
148
+RESET
149
+Time: 0.114 ms
150
+DO
151
+Time: 1.521 ms
152
+ROLLBACK
153
+Time: 0.445 ms
154
+NOTICE: WP1_GRAPH_PASS: complete deterministic graph,1003 rows,statuses,tenant/member/child/reversal/anon isolation,malformed links
docs/wp1/evidence/graph-read-regressions/wp1_manual_update_guards.sql.log
new
+57
@@ -0,0 +1,57 @@
1
+BEGIN
2
+INSERT 0 1
3
+ set_config
4
+--------------------------------------
5
+ 7763b922-ae91-420e-a684-9e8e669071c9
6
+(1 row)
7
+
8
+ set_config
9
+--------------------------------------
10
+ e9000000-0000-4000-8000-000000000001
11
+(1 row)
12
+
13
+INSERT 0 4
14
+ finora_journal_create_draft
15
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
16
+ {"voucher": {"id": "MG_manual", "date": "1405/07/24", "status": "draft", "version": 1, "sourceId": "", "companyId": "MG_C", "createdAt": "2026-11-04T22:14:08.532738+00:00", "createdBy": "e9000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "", "voucherType": "manual", "fiscalYearId": "MG_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "803b3215d3481bb4def700fe3cf7c9cd", "reversalAllocations": null}, "replayed": false}
17
+ {"voucher": {"id": "MG_opening", "date": "1405/07/24", "status": "draft", "version": 1, "sourceId": "", "companyId": "MG_C", "createdAt": "2026-11-04T22:14:08.54313+00:00", "createdBy": "e9000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "", "voucherType": "opening", "fiscalYearId": "MG_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "bd6a7a7fff1bad71f7e036cd0cff37be", "reversalAllocations": null}, "replayed": false}
18
+ {"voucher": {"id": "MG_closing", "date": "1405/07/24", "status": "draft", "version": 1, "sourceId": "", "companyId": "MG_C", "createdAt": "2026-11-04T22:14:08.549795+00:00", "createdBy": "e9000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "", "voucherType": "closing", "fiscalYearId": "MG_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "1882e7e38353bf6d3744de8e3ad5b8bf", "reversalAllocations": null}, "replayed": false}
19
+(3 rows)
20
+
21
+INSERT 0 1
22
+SET
23
+DO
24
+RESET
25
+UPDATE 1
26
+SET
27
+ finora_journal_create_draft
28
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
29
+ {"voucher": {"id": "MG_AUDIT", "date": "1405/07/24", "status": "draft", "version": 1, "sourceId": "", "companyId": "MG_C", "createdAt": "2026-11-04T22:14:09.560122+00:00", "createdBy": "e9000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "", "voucherType": "opening", "fiscalYearId": "MG_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "2a45bf8a7f945a968da7ddc92271a8de", "reversalAllocations": null}, "replayed": false}
30
+(1 row)
31
+
32
+UPDATE 1
33
+DO
34
+RESET
35
+UPDATE 1
36
+SET
37
+UPDATE 1
38
+DO
39
+ROLLBACK
40
+NOTICE: WP1_MANUAL_NEGATIVE_PASS rpc_date_range: FINORA_FISCAL_DATE_INVALID
41
+NOTICE: WP1_MANUAL_NEGATIVE_PASS rpc_date_format: FINORA_FISCAL_DATE_INVALID
42
+NOTICE: WP1_MANUAL_NEGATIVE_PASS rpc_null_date: FINORA_FISCAL_DATE_INVALID
43
+NOTICE: WP1_MANUAL_NEGATIVE_PASS rpc_null_header: FINORA_INVALID_DRAFT_UPDATE
44
+NOTICE: WP1_MANUAL_NEGATIVE_PASS rpc_year_closed: FINORA_FISCAL_YEAR_LOCKED_OR_MISSING
45
+NOTICE: WP1_MANUAL_NEGATIVE_PASS rpc_year_company: FINORA_FISCAL_YEAR_LOCKED_OR_MISSING
46
+NOTICE: WP1_MANUAL_NEGATIVE_PASS rpc_opening: FINORA_OPENING_CLOSING_NOT_APPROVED
47
+NOTICE: WP1_MANUAL_NEGATIVE_PASS rpc_closing: FINORA_OPENING_CLOSING_NOT_APPROVED
48
+NOTICE: WP1_MANUAL_NEGATIVE_PASS post_opening: FINORA_OPENING_CLOSING_NOT_APPROVED
49
+NOTICE: WP1_MANUAL_NEGATIVE_PASS post_closing: FINORA_OPENING_CLOSING_NOT_APPROVED
50
+NOTICE: WP1_MANUAL_NEGATIVE_PASS direct_date: FINORA_FISCAL_DATE_INVALID
51
+NOTICE: WP1_MANUAL_NEGATIVE_PASS direct_null_date: FINORA_FISCAL_DATE_INVALID
52
+NOTICE: WP1_MANUAL_NEGATIVE_PASS direct_opening: FINORA_OPENING_CLOSING_NOT_APPROVED
53
+NOTICE: WP1_MANUAL_NEGATIVE_PASS direct_source_relabel: FINORA_MANUAL_DRAFT_SOURCE_IMMUTABLE
54
+NOTICE: WP1_MANUAL_NEGATIVE_PASS v2_date: FINORA_FISCAL_DATE_INVALID
55
+NOTICE: WP1_MANUAL_NEGATIVE_PASS v2_closing: FINORA_OPENING_CLOSING_NOT_APPROVED
56
+NOTICE: WP1_MANUAL_NEGATIVE_PASS v2_source_relabel: FINORA_MANUAL_DRAFT_SOURCE_IMMUTABLE
57
+NOTICE: WP1_MANUAL_UPDATE_GUARDS_PASS: 17 negatives, atomic rejection, valid adjustment, boundary dates, posting replay
docs/wp1/evidence/graph-read-regressions/wp1_null_revision_guards.sql.log
new
+46
@@ -0,0 +1,46 @@
1
+BEGIN
2
+INSERT 0 1
3
+ set_config
4
+--------------------------------------
5
+ a0c3333e-0cf1-48d2-a879-b33ef850a283
6
+(1 row)
7
+
8
+ set_config
9
+--------------------------------------
10
+ ea000000-0000-4000-8000-000000000001
11
+(1 row)
12
+
13
+INSERT 0 4
14
+INSERT 0 1
15
+SET
16
+ finora_journal_create_draft
17
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
18
+ {"voucher": {"id": "RV_DRAFT", "date": "1405/07/24", "status": "draft", "version": 1, "sourceId": "", "companyId": "RV_C", "createdAt": "2026-11-04T22:14:09.717601+00:00", "createdBy": "ea000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "", "voucherType": "manual", "fiscalYearId": "RV_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "10f3b306ba9aa98fbe4e520299180481", "reversalAllocations": null}, "replayed": false}
19
+ {"voucher": {"id": "RV_ORIGINAL", "date": "1405/07/24", "status": "draft", "version": 1, "sourceId": "", "companyId": "RV_C", "createdAt": "2026-11-04T22:14:09.727889+00:00", "createdBy": "ea000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "", "voucherType": "manual", "fiscalYearId": "RV_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "10f3b306ba9aa98fbe4e520299180481", "reversalAllocations": null}, "replayed": false}
20
+ {"voucher": {"id": "RV_DELETE", "date": "1405/07/24", "status": "draft", "version": 1, "sourceId": "", "companyId": "RV_C", "createdAt": "2026-11-04T22:14:09.733544+00:00", "createdBy": "ea000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "", "voucherType": "manual", "fiscalYearId": "RV_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "10f3b306ba9aa98fbe4e520299180481", "reversalAllocations": null}, "replayed": false}
21
+(3 rows)
22
+
23
+ finora_journal_post
24
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
25
+ {"voucher": {"id": "RV_ORIGINAL", "date": "1405/07/24", "number": "1", "status": "posted", "version": 2, "postedAt": "2026-11-04T22:14:09.73834+00:00", "postedBy": "ea000000-0000-4000-8000-000000000001", "sourceId": "", "companyId": "RV_C", "createdAt": "2026-11-04T22:14:09.727889+00:00", "createdBy": "ea000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "", "voucherType": "manual", "fiscalYearId": "RV_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "10f3b306ba9aa98fbe4e520299180481", "reversalAllocations": null}, "replayed": false}
26
+(1 row)
27
+
28
+DO
29
+ROLLBACK
30
+NOTICE: WP1_REVISION_NEGATIVE_PASS update null
31
+NOTICE: WP1_REVISION_NEGATIVE_PASS update 0
32
+NOTICE: WP1_REVISION_NEGATIVE_PASS update -1
33
+NOTICE: WP1_REVISION_NEGATIVE_PASS update 999999
34
+NOTICE: WP1_REVISION_NEGATIVE_PASS delete null
35
+NOTICE: WP1_REVISION_NEGATIVE_PASS delete 0
36
+NOTICE: WP1_REVISION_NEGATIVE_PASS delete -1
37
+NOTICE: WP1_REVISION_NEGATIVE_PASS delete 999999
38
+NOTICE: WP1_REVISION_NEGATIVE_PASS post null
39
+NOTICE: WP1_REVISION_NEGATIVE_PASS post 0
40
+NOTICE: WP1_REVISION_NEGATIVE_PASS post -1
41
+NOTICE: WP1_REVISION_NEGATIVE_PASS post 999999
42
+NOTICE: WP1_REVISION_NEGATIVE_PASS reverse null
43
+NOTICE: WP1_REVISION_NEGATIVE_PASS reverse 0
44
+NOTICE: WP1_REVISION_NEGATIVE_PASS reverse -1
45
+NOTICE: WP1_REVISION_NEGATIVE_PASS reverse 999999
46
+NOTICE: WP1_NULL_REVISION_PASS: 16 rejected mutations, current versions accepted, read-only replay retained
docs/wp1/evidence/graph-read-regressions/wp1_phase1a_cas_rls_behavior.sql.log
new
+21
@@ -0,0 +1,21 @@
1
+BEGIN
2
+INSERT 0 2
3
+ set_config
4
+--------------------------------------
5
+ fc0e4518-446f-4d9b-8438-d66b89b75766
6
+(1 row)
7
+
8
+ set_config
9
+--------------------------------------
10
+ 6664ec4a-c35b-4a9d-ab86-2cef085fe749
11
+(1 row)
12
+
13
+SET
14
+ set_config
15
+--------------------------------------
16
+ 44444444-4444-4444-8444-444444444444
17
+(1 row)
18
+
19
+DO
20
+ROLLBACK
21
+NOTICE: FINORA_1A_CAS_PASS create=1 update=2 stale_rejected=true winner_preserved=true cross_tenant_denied=true
docs/wp1/evidence/graph-read-regressions/wp1_phase1a_security_grants.sql.log
new
+2
@@ -0,0 +1,2 @@
1
+DO
2
+NOTICE: FINORA_1A_SECURITY_PASS private 1A routines=27 unsafe search_path=0 anon execute=0
docs/wp1/evidence/graph-read-regressions/wp1_phase1a_stage1_account_role_controls.sql.log
new
+62
@@ -0,0 +1,62 @@
1
+BEGIN
2
+INSERT 0 3
3
+ set_config
4
+--------------------------------------
5
+ a91732d0-ff9d-4fc5-9e35-b8844b79dd5e
6
+(1 row)
7
+
8
+ set_config
9
+--------------------------------------
10
+ 995d579d-0846-4661-9cff-b3dbb2802ee1
11
+(1 row)
12
+
13
+INSERT 0 2
14
+INSERT 0 2
15
+INSERT 0 4
16
+INSERT 0 2
17
+UPDATE 1
18
+INSERT 0 1
19
+INSERT 0 1
20
+INSERT 0 1
21
+INSERT 0 1
22
+INSERT 0 1
23
+INSERT 0 1
24
+INSERT 0 1
25
+INSERT 0 1
26
+DO
27
+SET
28
+ set_config
29
+--------------------------------------
30
+ cccc3333-3333-4333-8333-333333333333
31
+(1 row)
32
+
33
+DO
34
+RESET
35
+UPDATE 1
36
+DO
37
+SET
38
+DO
39
+RESET
40
+DO
41
+UPDATE 1
42
+UPDATE 1
43
+SET
44
+ set_config
45
+--------------------------------------
46
+ aaaa1111-1111-4111-8111-111111111111
47
+(1 row)
48
+
49
+DO
50
+RESET
51
+DO
52
+DO
53
+UPDATE 1
54
+INSERT 0 1
55
+INSERT 0 1
56
+SET
57
+DO
58
+RESET
59
+DO
60
+ROLLBACK
61
+NOTICE: FINORA_ACCOUNT_ROLE_GUARDS_PASS
62
+NOTICE: FINORA_ACCOUNT_ROLE_GUARDS_AND_DRAFT_PIN_PASS
docs/wp1/evidence/graph-read-regressions/wp1_phase1a_stage1_all_definer_security.sql.log
new
+2
@@ -0,0 +1,2 @@
1
+DO
2
+NOTICE: FINORA_SECURITY_DEFINER_AUDIT_PASS zero unsafe defs and anon/public grants
docs/wp1/evidence/graph-read-regressions/wp1_phase1a_stage1_counter_two_fiscal.sql.log
new
+49
@@ -0,0 +1,49 @@
1
+BEGIN
2
+INSERT 0 1
3
+ set_config
4
+--------------------------------------
5
+ e09f363c-da6a-4364-8d52-5cb7a0a097d5
6
+(1 row)
7
+
8
+INSERT 0 1
9
+INSERT 0 2
10
+INSERT 0 2
11
+INSERT 0 2
12
+INSERT 0 1
13
+SET
14
+ set_config
15
+--------------------------------------
16
+ 12345678-aaaa-4aaa-8aaa-123456789012
17
+(1 row)
18
+
19
+ finora_journal_create_draft
20
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
21
+ {"voucher": {"id": "NEW_FIRST_41", "date": "1405/05/01", "status": "draft", "version": 1, "sourceId": "", "companyId": "COMP_COUNTER", "createdAt": "2026-11-04T22:14:11.19948+00:00", "createdBy": "12345678-aaaa-4aaa-8aaa-123456789012", "reference": "", "sourceType": "manual", "description": "", "voucherType": "manual", "fiscalYearId": "FY_FIRST", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "5d6aa2f3e0043ba4c7690d7ed8785839", "reversalAllocations": null}, "replayed": false}
22
+(1 row)
23
+
24
+ finora_journal_create_draft
25
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
26
+ {"voucher": {"id": "NEW_SECOND_12", "date": "1405/10/01", "status": "draft", "version": 1, "sourceId": "", "companyId": "COMP_COUNTER", "createdAt": "2026-11-04T22:14:11.211499+00:00", "createdBy": "12345678-aaaa-4aaa-8aaa-123456789012", "reference": "", "sourceType": "manual", "description": "", "voucherType": "manual", "fiscalYearId": "FY_SECOND", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "977a41c99e7865483e6cdc605672a586", "reversalAllocations": null}, "replayed": false}
27
+(1 row)
28
+
29
+SAVEPOINT
30
+ finora_journal_post
31
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
32
+ {"voucher": {"id": "NEW_FIRST_41", "date": "1405/05/01", "number": "41", "status": "posted", "version": 2, "postedAt": "2026-11-04T22:14:11.218005+00:00", "postedBy": "12345678-aaaa-4aaa-8aaa-123456789012", "sourceId": "", "companyId": "COMP_COUNTER", "createdAt": "2026-11-04T22:14:11.19948+00:00", "createdBy": "12345678-aaaa-4aaa-8aaa-123456789012", "reference": "", "sourceType": "manual", "description": "", "voucherType": "manual", "fiscalYearId": "FY_FIRST", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "5d6aa2f3e0043ba4c7690d7ed8785839", "reversalAllocations": null}, "replayed": false}
33
+(1 row)
34
+
35
+ROLLBACK
36
+ finora_journal_post
37
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
38
+ {"voucher": {"id": "NEW_FIRST_41", "date": "1405/05/01", "number": "41", "status": "posted", "version": 2, "postedAt": "2026-11-04T22:14:11.227678+00:00", "postedBy": "12345678-aaaa-4aaa-8aaa-123456789012", "sourceId": "", "companyId": "COMP_COUNTER", "createdAt": "2026-11-04T22:14:11.19948+00:00", "createdBy": "12345678-aaaa-4aaa-8aaa-123456789012", "reference": "", "sourceType": "manual", "description": "", "voucherType": "manual", "fiscalYearId": "FY_FIRST", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "5d6aa2f3e0043ba4c7690d7ed8785839", "reversalAllocations": null}, "replayed": false}
39
+(1 row)
40
+
41
+ finora_journal_post
42
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
43
+ {"voucher": {"id": "NEW_SECOND_12", "date": "1405/10/01", "number": "12", "status": "posted", "version": 2, "postedAt": "2026-11-04T22:14:11.231411+00:00", "postedBy": "12345678-aaaa-4aaa-8aaa-123456789012", "sourceId": "", "companyId": "COMP_COUNTER", "createdAt": "2026-11-04T22:14:11.211499+00:00", "createdBy": "12345678-aaaa-4aaa-8aaa-123456789012", "reference": "", "sourceType": "manual", "description": "", "voucherType": "manual", "fiscalYearId": "FY_SECOND", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "977a41c99e7865483e6cdc605672a586", "reversalAllocations": null}, "replayed": false}
44
+(1 row)
45
+
46
+RESET
47
+DO
48
+ROLLBACK
49
+NOTICE: FINORA_STAGE1_COUNTER_PASS years=2 first_legacy=40 next=41 second_legacy=11 next=12 rollback_consumed=0
docs/wp1/evidence/graph-read-regressions/wp1_phase1a_stage1_sale_purchase_negatives.sql.log
new
+45
@@ -0,0 +1,45 @@
1
+BEGIN
2
+INSERT 0 3
3
+ set_config
4
+--------------------------------------
5
+ 553d75c9-8704-4836-b686-8b0db397ba60
6
+(1 row)
7
+
8
+ set_config
9
+--------------------------------------
10
+ ffa3b003-c7fc-47d1-ab56-7907772c5abc
11
+(1 row)
12
+
13
+INSERT 0 2
14
+INSERT 0 2
15
+INSERT 0 4
16
+INSERT 0 2
17
+UPDATE 1
18
+INSERT 0 1
19
+INSERT 0 1
20
+INSERT 0 1
21
+INSERT 0 1
22
+INSERT 0 1
23
+INSERT 0 1
24
+INSERT 0 3
25
+INSERT 0 1
26
+DO
27
+SET
28
+ set_config
29
+--------------------------------------
30
+ aaaa1111-1111-4111-8111-111111111111
31
+(1 row)
32
+
33
+ finora_phase1a_publish_role_assignments
34
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
35
+ {"version": 1, "approved": true, "assignments": {"cash_default": "ACC_STAGE_1", "payable_control": "ACC_AP", "revenue_default": "ACC_STAGE_2", "purchase_default": "ACC_PUR", "receivable_control": "ACC_AR"}}
36
+(1 row)
37
+
38
+ set_config
39
+--------------------------------------
40
+ cccc3333-3333-4333-8333-333333333333
41
+(1 row)
42
+
43
+DO
44
+ROLLBACK
45
+NOTICE: FINORA_SALE_PURCHASE_NEGATIVES_AND_REVERSED_IDEMPOTENCY_PASS
docs/wp1/evidence/graph-read-regressions/wp1_phase1a_stage1_sql_behavior.sql.log
new
+54
@@ -0,0 +1,54 @@
1
+BEGIN
2
+INSERT 0 3
3
+ set_config
4
+--------------------------------------
5
+ d8c01336-7318-47c1-b85d-3d4b7636362e
6
+(1 row)
7
+
8
+ set_config
9
+--------------------------------------
10
+ ba867346-1bca-4273-b17e-c6c28d4f9023
11
+(1 row)
12
+
13
+INSERT 0 2
14
+INSERT 0 2
15
+INSERT 0 4
16
+INSERT 0 2
17
+UPDATE 1
18
+INSERT 0 1
19
+INSERT 0 1
20
+INSERT 0 1
21
+INSERT 0 1
22
+INSERT 0 1
23
+INSERT 0 1
24
+SET
25
+ set_config
26
+--------------------------------------
27
+ aaaa1111-1111-4111-8111-111111111111
28
+(1 row)
29
+
30
+ finora_phase1a_publish_role_assignments
31
+--------------------------------------------------------------------------------------------------------------------
32
+ {"version": 1, "approved": true, "assignments": {"cash_default": "ACC_STAGE_1", "revenue_default": "ACC_STAGE_2"}}
33
+(1 row)
34
+
35
+DO
36
+ set_config
37
+--------------------------------------
38
+ bbbb2222-2222-4222-8222-222222222222
39
+(1 row)
40
+
41
+DO
42
+ set_config
43
+--------------------------------------
44
+ cccc3333-3333-4333-8333-333333333333
45
+(1 row)
46
+
47
+DO
48
+RESET
49
+DO
50
+ROLLBACK
51
+NOTICE: FINORA_STAGE1_SMOKE_A_PASS create, doubleclick, retry-conflict, post, reverse, view, tenant A->B
52
+NOTICE: FINORA_STAGE1_SMOKE_B_PASS tenant B->A and legacy/CAS
53
+NOTICE: FINORA_STAGE1_ROLE_PASS commerce source allowed, manual create/edit/delete/post/reverse denied
54
+NOTICE: FINORA_STAGE1_BOTH_DIRECTIONS_PASS direct,2arg,3arg,v2,journal
docs/wp1/evidence/graph-read-regressions/wp1_posted_identity_move.sql.log
new
+28
@@ -0,0 +1,28 @@
1
+BEGIN
2
+INSERT 0 1
3
+ set_config
4
+--------------------------------------
5
+ 817578f3-e69e-40e4-b1e2-1a6bf2defeb6
6
+(1 row)
7
+
8
+ set_config
9
+--------------------------------------
10
+ b1000000-0000-4000-8000-000000000001
11
+(1 row)
12
+
13
+INSERT 0 4
14
+DO
15
+SET
16
+DO
17
+RESET
18
+INSERT 0 1
19
+ set_config
20
+--------------------------------------
21
+ 26d7b668-9c3b-40be-8a1b-db8b39ebb6bb
22
+(1 row)
23
+
24
+INSERT 0 1
25
+DO
26
+ROLLBACK
27
+NOTICE: WP1_DIRECT_GUARDS_PASS: D1, independent RPC-balanced D2, dimension insert, spoofed GUC
28
+NOTICE: WP1_POSTED_ORG_MOVE_PASS: old ENFORCE dominates new AUDIT, original untouched
docs/wp1/evidence/graph-read-regressions/wp1_posting_negatives.sql.log
new
+32
@@ -0,0 +1,32 @@
1
+BEGIN
2
+INSERT 0 1
3
+ set_config
4
+--------------------------------------
5
+ be4c0ec1-bcae-46d6-9a6a-8edf52a3776d
6
+(1 row)
7
+
8
+ set_config
9
+--------------------------------------
10
+ b2000000-0000-4000-8000-000000000001
11
+(1 row)
12
+
13
+INSERT 0 5
14
+INSERT 0 1
15
+SET
16
+DO
17
+ROLLBACK
18
+NOTICE: WP1_NEGATIVE_PASS missing_amount: FINORA_INVALID_RIAL_AMOUNT
19
+NOTICE: WP1_NEGATIVE_PASS null_amount: FINORA_INVALID_RIAL_AMOUNT
20
+NOTICE: WP1_NEGATIVE_PASS negative: FINORA_INVALID_RIAL_AMOUNT
21
+NOTICE: WP1_NEGATIVE_PASS fraction: FINORA_INVALID_RIAL_AMOUNT
22
+NOTICE: WP1_NEGATIVE_PASS zero: FINORA_INVALID_DEBIT_CREDIT_LINE
23
+NOTICE: WP1_NEGATIVE_PASS two_sides: FINORA_INVALID_DEBIT_CREDIT_LINE
24
+NOTICE: WP1_NEGATIVE_PASS single: FINORA_INVALID_LINE_COUNT
25
+NOTICE: WP1_NEGATIVE_PASS unbalanced: FINORA_UNBALANCED_POSTED_JOURNAL count=2 debit=1000 credit=300
26
+NOTICE: WP1_NEGATIVE_PASS closed: FINORA_FISCAL_YEAR_LOCKED_OR_MISSING
27
+NOTICE: WP1_NEGATIVE_PASS out_of_range: FINORA_FISCAL_DATE_INVALID
28
+NOTICE: WP1_NEGATIVE_PASS wrong_company: FINORA_LINE_SCOPE_MISMATCH
29
+NOTICE: WP1_NEGATIVE_PASS wrong_year: FINORA_LINE_SCOPE_MISMATCH
30
+NOTICE: WP1_NEGATIVE_PASS currency: FINORA_CURRENCY_UNSUPPORTED
31
+NOTICE: WP1_NEGATIVE_PASS inactive_account: FINORA_ACCOUNT_OUT_OF_SCOPE
32
+NOTICE: WP1_POSTING_NEGATIVES_PASS: 14 cases
docs/wp1/evidence/graph-read-regressions/wp1_reversal_dimensions.sql.log
new
+34
@@ -0,0 +1,34 @@
1
+BEGIN
2
+INSERT 0 2
3
+ set_config
4
+--------------------------------------
5
+ 291e6f8f-a35b-4d12-a8bf-fe36961f3c11
6
+(1 row)
7
+
8
+ set_config
9
+--------------------------------------
10
+ a6950f6d-e10c-4194-9f8d-4e68f4503a2e
11
+(1 row)
12
+
13
+ set_config
14
+--------------------------------------
15
+ b6000000-0000-4000-8000-000000000001
16
+(1 row)
17
+
18
+UPDATE 1
19
+INSERT 0 12
20
+INSERT 0 1
21
+INSERT 0 1
22
+CREATE FUNCTION
23
+SET
24
+DO
25
+DO
26
+RESET
27
+ALTER TABLE
28
+INSERT 0 2
29
+ALTER TABLE
30
+SET
31
+DO
32
+ROLLBACK
33
+NOTICE: WP1_REVERSAL_DIMENSIONS_PASS: full, partial, remainder, replay, changed retry, over-allocation, tenant scope, immutable originals
34
+NOTICE: WP1_LEGACY_DIMENSION_SCOPE_PASS: wrong-company and wrong-voucher fail closed with unchanged rows
docs/wp1/evidence/graph-read-regressions/wp1_scope_move_and_null.sql.log
new
+35
@@ -0,0 +1,35 @@
1
+BEGIN
2
+INSERT 0 2
3
+ set_config
4
+--------------------------------------
5
+ 7f9fd336-82cc-4d31-84a8-d34c095fceb7
6
+(1 row)
7
+
8
+ set_config
9
+--------------------------------------
10
+ 975853dc-2b19-44c2-9866-c02c2202ad6b
11
+(1 row)
12
+
13
+ set_config
14
+--------------------------------------
15
+ b4000000-0000-4000-8000-000000000001
16
+(1 row)
17
+
18
+INSERT 0 4
19
+INSERT 0 1
20
+SET
21
+DO
22
+RESET
23
+DO
24
+UPDATE 1
25
+SET
26
+DO
27
+RESET
28
+INSERT 0 1
29
+UPDATE 1
30
+SET CONSTRAINTS
31
+DO
32
+ROLLBACK
33
+NOTICE: WP1_ENFORCE_TO_AUDIT_IDENTITY_MOVE_DENIED
34
+NOTICE: WP1_MISSING_AND_NULL_AMOUNTS_REJECTED_IN_SHADOW
35
+NOTICE: WP1_AUDIT_TO_OFF_RELOCATION_ALLOWED_AND_LOGGED
docs/wp1/evidence/graph-read-regressions/wp1_shadow_and_constraint_contract.sql.log
new
+21
@@ -0,0 +1,21 @@
1
+BEGIN
2
+INSERT 0 1
3
+ set_config
4
+--------------------------------------
5
+ 9545778d-98b7-4f9d-9f10-5fe45a033ed4
6
+(1 row)
7
+
8
+ set_config
9
+--------------------------------------
10
+ b3000000-0000-4000-8000-000000000001
11
+(1 row)
12
+
13
+DO
14
+SET
15
+DO
16
+INSERT 0 1
17
+SET CONSTRAINTS
18
+RESET
19
+DO
20
+ROLLBACK
21
+NOTICE: WP1_SHADOW_PASS: default audit, persisted violation evidence, non-admin setter denied, deferred ledger-only constraints
docs/wp1/evidence/graph-read/baseline-red.log
new
+6
@@ -0,0 +1,6 @@
1
+Timing is on.
2
+BEGIN
3
+Time: 0.260 ms
4
+Time: 1.388 ms
5
+ERROR: WP1_GRAPH_RPC_MISSING
6
+CONTEXT: PL/pgSQL function inline_code_block line 2 at RAISE
docs/wp1/evidence/graph-read/definer-security.log
new
+2
@@ -0,0 +1,2 @@
1
+DO
2
+NOTICE: FINORA_SECURITY_DEFINER_AUDIT_PASS zero unsafe defs and anon/public grants
docs/wp1/evidence/graph-read/down-red.log
new
+6
@@ -0,0 +1,6 @@
1
+Timing is on.
2
+BEGIN
3
+Time: 0.248 ms
4
+Time: 1.312 ms
5
+ERROR: WP1_GRAPH_RPC_MISSING
6
+CONTEXT: PL/pgSQL function inline_code_block line 2 at RAISE
docs/wp1/evidence/graph-read/down.log
new
+2
@@ -0,0 +1,2 @@
1
+DROP FUNCTION
2
+DROP FUNCTION
docs/wp1/evidence/graph-read/green-retained.log
new
+154
@@ -0,0 +1,154 @@
1
+Timing is on.
2
+BEGIN
3
+Time: 0.096 ms
4
+DO
5
+Time: 0.908 ms
6
+INSERT 0 3
7
+Time: 8.430 ms
8
+ set_config
9
+--------------------------------------
10
+ 8c36e7d5-de52-46e0-bf35-d46b129ab5cd
11
+(1 row)
12
+
13
+Time: 0.161 ms
14
+ set_config
15
+--------------------------------------
16
+ 31ba709f-8875-4bc2-b097-954cbc54d41d
17
+(1 row)
18
+
19
+Time: 0.145 ms
20
+ set_config
21
+--------------------------------------
22
+ ed000000-0000-4000-8000-000000000001
23
+(1 row)
24
+
25
+Time: 0.164 ms
26
+UPDATE 1
27
+Time: 0.401 ms
28
+INSERT 0 1
29
+Time: 0.511 ms
30
+INSERT 0 1
31
+Time: 1.640 ms
32
+INSERT 0 6
33
+Time: 6.005 ms
34
+SET
35
+Time: 0.525 ms
36
+ finora_journal_create_draft
37
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
38
+ {"voucher": {"id": "GR_DOC", "date": "1405/07/24", "status": "draft", "version": 1, "sourceId": "", "companyId": "GR_C", "createdAt": "2026-11-04T22:13:25.609828+00:00", "createdBy": "ed000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "", "voucherType": "manual", "fiscalYearId": "GR_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "645cd27c7b0f781da9049c5b7086562a", "reversalAllocations": null}, "replayed": false}
39
+(1 row)
40
+
41
+Time: 17.769 ms
42
+DO
43
+Time: 80.856 ms
44
+ finora_journal_post
45
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
46
+ {"voucher": {"id": "GR_DOC", "date": "1405/07/24", "number": "1", "status": "posted", "version": 2, "postedAt": "2026-11-04T22:13:25.703513+00:00", "postedBy": "ed000000-0000-4000-8000-000000000001", "sourceId": "", "companyId": "GR_C", "createdAt": "2026-11-04T22:13:25.609828+00:00", "createdBy": "ed000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "", "voucherType": "manual", "fiscalYearId": "GR_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "645cd27c7b0f781da9049c5b7086562a", "reversalAllocations": null}, "replayed": false}
47
+(1 row)
48
+
49
+Time: 8.100 ms
50
+DO
51
+Time: 52.859 ms
52
+ finora_journal_reverse
53
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
54
+ {"reason": "Graph partial reversal", "voucher": {"id": "GR_PART1", "date": "1405/07/25", "number": "2", "status": "posted", "version": 2, "postedAt": "2026-11-04T22:13:25.780181+00:00", "postedBy": "ed000000-0000-4000-8000-000000000001", "sourceId": "GR_DOC", "companyId": "GR_C", "createdAt": "2026-11-04T22:13:25.775056+00:00", "createdBy": "ed000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "reversal", "description": "برگشت سند 1", "voucherType": "reversal", "fiscalYearId": "GR_Y", "sourceVersion": "1", "reversalReason": "Graph partial reversal", "requestFingerprint": "6feffb2ba4fcf0961f6bc8693068268c", "reversalAllocations": [{"amount": 40, "lineId": "GR_LINE_A"}, {"amount": 40, "lineId": "GR_LINE_B"}]}, "replayed": false, "reversedBy": "ed000000-0000-4000-8000-000000000001", "originalVoucherId": "GR_DOC"}
55
+(1 row)
56
+
57
+Time: 18.856 ms
58
+DO
59
+Time: 127.842 ms
60
+ finora_journal_reverse
61
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
62
+ {"reason": "Graph remaining reversal", "voucher": {"id": "GR_PART2", "date": "1405/07/26", "number": "3", "status": "posted", "version": 2, "postedAt": "2026-11-04T22:13:25.921946+00:00", "postedBy": "ed000000-0000-4000-8000-000000000001", "sourceId": "GR_DOC", "companyId": "GR_C", "createdAt": "2026-11-04T22:13:25.917224+00:00", "createdBy": "ed000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "reversal", "description": "برگشت سند 1", "voucherType": "reversal", "fiscalYearId": "GR_Y", "sourceVersion": "1", "reversalReason": "Graph remaining reversal", "requestFingerprint": "e1bc3f78ac7bcb43df7f0552037cdaac", "reversalAllocations": [{"amount": 60, "lineId": "GR_LINE_A"}, {"amount": 60, "lineId": "GR_LINE_B"}]}, "replayed": false, "reversedBy": "ed000000-0000-4000-8000-000000000001", "originalVoucherId": "GR_DOC"}
63
+(1 row)
64
+
65
+Time: 14.098 ms
66
+DO
67
+Time: 204.101 ms
68
+SET CONSTRAINTS
69
+Time: 7.936 ms
70
+RESET
71
+Time: 0.092 ms
72
+ALTER TABLE
73
+Time: 1.216 ms
74
+INSERT 0 4
75
+Time: 0.983 ms
76
+INSERT 0 1002
77
+Time: 58.994 ms
78
+ALTER TABLE
79
+Time: 1.225 ms
80
+SET
81
+Time: 0.072 ms
82
+DO
83
+Time: 16845.002 ms (00:16.845)
84
+ set_config
85
+--------------------------------------
86
+ ed000000-0000-4000-8000-000000000002
87
+(1 row)
88
+
89
+Time: 5.306 ms
90
+DO
91
+Time: 18.672 ms
92
+ set_config
93
+--------------------------------------
94
+ ed000000-0000-4000-8000-000000000003
95
+(1 row)
96
+
97
+Time: 0.058 ms
98
+DO
99
+Time: 3593.182 ms (00:03.593)
100
+RESET
101
+Time: 0.031 ms
102
+ALTER TABLE
103
+Time: 0.747 ms
104
+UPDATE 1
105
+Time: 3.837 ms
106
+ALTER TABLE
107
+Time: 0.603 ms
108
+SET
109
+Time: 0.023 ms
110
+DO
111
+Time: 3570.925 ms (00:03.571)
112
+RESET
113
+Time: 0.030 ms
114
+ALTER TABLE
115
+Time: 1.103 ms
116
+UPDATE 1
117
+Time: 1.369 ms
118
+UPDATE 1
119
+Time: 0.497 ms
120
+ALTER TABLE
121
+Time: 0.628 ms
122
+SET
123
+Time: 0.021 ms
124
+DO
125
+Time: 3340.428 ms (00:03.340)
126
+RESET
127
+Time: 0.186 ms
128
+UPDATE 1
129
+Time: 0.758 ms
130
+SET
131
+Time: 0.069 ms
132
+DO
133
+Time: 0.536 ms
134
+RESET
135
+Time: 0.087 ms
136
+ set_config
137
+--------------------------------------
138
+ ed000000-0000-4000-8000-000000000001
139
+(1 row)
140
+
141
+Time: 0.135 ms
142
+DO
143
+Time: 14466.461 ms (00:14.466)
144
+SET
145
+Time: 0.339 ms
146
+DO
147
+Time: 0.192 ms
148
+RESET
149
+Time: 0.129 ms
150
+DO
151
+Time: 1.575 ms
152
+COMMIT
153
+Time: 1.439 ms
154
+NOTICE: WP1_GRAPH_PASS: complete deterministic graph,1003 rows,statuses,tenant/member/child/reversal/anon isolation,malformed links
docs/wp1/evidence/graph-read/green-up2.log
new
+154
@@ -0,0 +1,154 @@
1
+Timing is on.
2
+BEGIN
3
+Time: 0.072 ms
4
+DO
5
+Time: 0.940 ms
6
+INSERT 0 3
7
+Time: 8.901 ms
8
+ set_config
9
+--------------------------------------
10
+ feb9951d-680d-4bc7-98a8-4f2fb8bb907d
11
+(1 row)
12
+
13
+Time: 0.361 ms
14
+ set_config
15
+--------------------------------------
16
+ f96bf9f0-0364-4d7d-9a3f-3ebf8f977f1e
17
+(1 row)
18
+
19
+Time: 0.242 ms
20
+ set_config
21
+--------------------------------------
22
+ ee000000-0000-4000-8000-000000000001
23
+(1 row)
24
+
25
+Time: 0.142 ms
26
+UPDATE 1
27
+Time: 0.563 ms
28
+INSERT 0 1
29
+Time: 0.609 ms
30
+INSERT 0 1
31
+Time: 1.533 ms
32
+INSERT 0 6
33
+Time: 5.790 ms
34
+SET
35
+Time: 0.263 ms
36
+ finora_journal_create_draft
37
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
38
+ {"voucher": {"id": "GR_DOC", "date": "1405/07/24", "status": "draft", "version": 1, "sourceId": "", "companyId": "GR_C", "createdAt": "2026-11-04T22:14:19.430374+00:00", "createdBy": "ee000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "", "voucherType": "manual", "fiscalYearId": "GR_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "645cd27c7b0f781da9049c5b7086562a", "reversalAllocations": null}, "replayed": false}
39
+(1 row)
40
+
41
+Time: 16.543 ms
42
+DO
43
+Time: 48.733 ms
44
+ finora_journal_post
45
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
46
+ {"voucher": {"id": "GR_DOC", "date": "1405/07/24", "number": "1", "status": "posted", "version": 2, "postedAt": "2026-11-04T22:14:19.489711+00:00", "postedBy": "ee000000-0000-4000-8000-000000000001", "sourceId": "", "companyId": "GR_C", "createdAt": "2026-11-04T22:14:19.430374+00:00", "createdBy": "ee000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "", "voucherType": "manual", "fiscalYearId": "GR_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "645cd27c7b0f781da9049c5b7086562a", "reversalAllocations": null}, "replayed": false}
47
+(1 row)
48
+
49
+Time: 7.928 ms
50
+DO
51
+Time: 34.494 ms
52
+ finora_journal_reverse
53
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
54
+ {"reason": "Graph partial reversal", "voucher": {"id": "GR_PART1", "date": "1405/07/25", "number": "2", "status": "posted", "version": 2, "postedAt": "2026-11-04T22:14:19.541935+00:00", "postedBy": "ee000000-0000-4000-8000-000000000001", "sourceId": "GR_DOC", "companyId": "GR_C", "createdAt": "2026-11-04T22:14:19.536911+00:00", "createdBy": "ee000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "reversal", "description": "برگشت سند 1", "voucherType": "reversal", "fiscalYearId": "GR_Y", "sourceVersion": "1", "reversalReason": "Graph partial reversal", "requestFingerprint": "6feffb2ba4fcf0961f6bc8693068268c", "reversalAllocations": [{"amount": 40, "lineId": "GR_LINE_A"}, {"amount": 40, "lineId": "GR_LINE_B"}]}, "replayed": false, "reversedBy": "ee000000-0000-4000-8000-000000000001", "originalVoucherId": "GR_DOC"}
55
+(1 row)
56
+
57
+Time: 12.815 ms
58
+DO
59
+Time: 101.679 ms
60
+ finora_journal_reverse
61
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
62
+ {"reason": "Graph remaining reversal", "voucher": {"id": "GR_PART2", "date": "1405/07/26", "number": "3", "status": "posted", "version": 2, "postedAt": "2026-11-04T22:14:19.653419+00:00", "postedBy": "ee000000-0000-4000-8000-000000000001", "sourceId": "GR_DOC", "companyId": "GR_C", "createdAt": "2026-11-04T22:14:19.650165+00:00", "createdBy": "ee000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "reversal", "description": "برگشت سند 1", "voucherType": "reversal", "fiscalYearId": "GR_Y", "sourceVersion": "1", "reversalReason": "Graph remaining reversal", "requestFingerprint": "e1bc3f78ac7bcb43df7f0552037cdaac", "reversalAllocations": [{"amount": 60, "lineId": "GR_LINE_A"}, {"amount": 60, "lineId": "GR_LINE_B"}]}, "replayed": false, "reversedBy": "ee000000-0000-4000-8000-000000000001", "originalVoucherId": "GR_DOC"}
63
+(1 row)
64
+
65
+Time: 9.921 ms
66
+DO
67
+Time: 163.965 ms
68
+SET CONSTRAINTS
69
+Time: 7.104 ms
70
+RESET
71
+Time: 0.086 ms
72
+ALTER TABLE
73
+Time: 1.209 ms
74
+INSERT 0 4
75
+Time: 0.894 ms
76
+INSERT 0 1002
77
+Time: 33.887 ms
78
+ALTER TABLE
79
+Time: 0.872 ms
80
+SET
81
+Time: 0.141 ms
82
+DO
83
+Time: 17888.806 ms (00:17.889)
84
+ set_config
85
+--------------------------------------
86
+ ee000000-0000-4000-8000-000000000002
87
+(1 row)
88
+
89
+Time: 0.130 ms
90
+DO
91
+Time: 18.372 ms
92
+ set_config
93
+--------------------------------------
94
+ ee000000-0000-4000-8000-000000000003
95
+(1 row)
96
+
97
+Time: 0.104 ms
98
+DO
99
+Time: 3829.324 ms (00:03.829)
100
+RESET
101
+Time: 0.126 ms
102
+ALTER TABLE
103
+Time: 0.699 ms
104
+UPDATE 1
105
+Time: 1.533 ms
106
+ALTER TABLE
107
+Time: 0.734 ms
108
+SET
109
+Time: 0.061 ms
110
+DO
111
+Time: 3171.106 ms (00:03.171)
112
+RESET
113
+Time: 0.067 ms
114
+ALTER TABLE
115
+Time: 1.038 ms
116
+UPDATE 1
117
+Time: 1.938 ms
118
+UPDATE 1
119
+Time: 0.717 ms
120
+ALTER TABLE
121
+Time: 0.712 ms
122
+SET
123
+Time: 0.105 ms
124
+DO
125
+Time: 4411.064 ms (00:04.411)
126
+RESET
127
+Time: 0.156 ms
128
+UPDATE 1
129
+Time: 0.669 ms
130
+SET
131
+Time: 0.036 ms
132
+DO
133
+Time: 0.551 ms
134
+RESET
135
+Time: 0.231 ms
136
+ set_config
137
+--------------------------------------
138
+ ee000000-0000-4000-8000-000000000001
139
+(1 row)
140
+
141
+Time: 0.101 ms
142
+DO
143
+Time: 15414.369 ms (00:15.414)
144
+SET
145
+Time: 0.152 ms
146
+DO
147
+Time: 0.704 ms
148
+RESET
149
+Time: 0.132 ms
150
+DO
151
+Time: 1.030 ms
152
+ROLLBACK
153
+Time: 0.437 ms
154
+NOTICE: WP1_GRAPH_PASS: complete deterministic graph,1003 rows,statuses,tenant/member/child/reversal/anon isolation,malformed links
docs/wp1/evidence/graph-read/read-only-probe.log
new
+21
@@ -0,0 +1,21 @@
1
+Timing is on.
2
+ set_config
3
+--------------------------------------
4
+ ed000000-0000-4000-8000-000000000001
5
+(1 row)
6
+
7
+Time: 0.696 ms
8
+SET
9
+Time: 0.175 ms
10
+ probe | rows
11
+-------------+------
12
+ large_graph | 1003
13
+(1 row)
14
+
15
+Time: 7035.875 ms (00:07.036)
16
+ probe | status
17
+--------------+----------
18
+ posted_graph | reversed
19
+(1 row)
20
+
21
+Time: 3347.085 ms (00:03.347)
docs/wp1/evidence/graph-read/result.json
new
+56
@@ -0,0 +1,56 @@
1
+{
2
+ "result": "PASS",
3
+ "scope": "source-derived SQL, not real Auth/JWT/PostgREST, schema parity or performance acceptance",
4
+ "steps": [
5
+ "snapshot",
6
+ "baseline-red",
7
+ "up1",
8
+ "snapshot",
9
+ "green-retained",
10
+ "snapshot",
11
+ "read-only-probe",
12
+ "snapshot",
13
+ "definer-security",
14
+ "down",
15
+ "snapshot",
16
+ "snapshot",
17
+ "down-red",
18
+ "snapshot",
19
+ "up2",
20
+ "snapshot",
21
+ "snapshot",
22
+ "green-up2",
23
+ "snapshot"
24
+ ],
25
+ "prior": [
26
+ "20261016100000_phase1a_server_journal_invariants.sql",
27
+ "20261016100500_phase1a_optimistic_version_sync.sql",
28
+ "20261016101000_phase1a_guard_modes_audit.sql",
29
+ "20261016101500_phase1a_journal_core.sql",
30
+ "20261016102000_phase1a_journal_rpc_surface.sql",
31
+ "20261016102500_phase1a_account_role_protection.sql",
32
+ "20261016103000_phase1a_sale_monetary_contract.sql",
33
+ "20261016103100_phase1a_autopost_server_authority.sql",
34
+ "20261016103500_phase1a_purchase_fixed_contract.sql",
35
+ "20261016104000_stage22_manual_guard_owner_mode.sql",
36
+ "20261016104500_stage3_posted_source_immutable.sql",
37
+ "20261102141933_wp1_ledger_scope_authority_hardening.sql",
38
+ "20261104020908_wp1_reversal_dimensions.sql",
39
+ "20261104072719_wp1_manual_update_guards.sql",
40
+ "20261104214503_wp1_null_revision_guards.sql"
41
+ ],
42
+ "retained": {
43
+ "posted": 3,
44
+ "lines": 1010,
45
+ "records": "f439b118d4995030b33ec6b7d7d8da15",
46
+ "audit": "3b631c02ae2c481557d2973dc1a051a3",
47
+ "counters": "6c2aeaa506c1e7e4e2ab73ca63e00255",
48
+ "members": "286ae440c3c91427eddf29f388e5ef06",
49
+ "permissions": "2e90490a86b9f281b899ebcfbd24eacd"
50
+ },
51
+ "hashes": {
52
+ "supabase/migrations/20261104220102_wp1_journal_graph_read.sql": "93f8b6e4b0462d504817b1360a9c0a09a7b35ab13bd6d9648ba1f981e3f544bb",
53
+ "supabase/rollback/20261104220102_wp1_journal_graph_read.sql": "18b19315b27615d7fab002aedf7662ac8a4f0d6836db863c25926e87dca7b3bf",
54
+ "supabase/tests/wp1_journal_graph_read.sql": "e2013bcdf579e5cb7ef4ad1bb29c368fdcaafb6f24db5cdd4b524eea5e85770d"
55
+ }
56
+}
docs/wp1/evidence/graph-read/snapshot.log
new
+2
@@ -0,0 +1,2 @@
1
+Output format is unaligned.
2
+{"posted" : 3, "lines" : 1010, "records" : "f439b118d4995030b33ec6b7d7d8da15", "audit" : "3b631c02ae2c481557d2973dc1a051a3", "counters" : "6c2aeaa506c1e7e4e2ab73ca63e00255", "members" : "286ae440c3c91427eddf29f388e5ef06", "permissions" : "2e90490a86b9f281b899ebcfbd24eacd"}
docs/wp1/evidence/graph-read/up1.log
new
+6
@@ -0,0 +1,6 @@
1
+CREATE FUNCTION
2
+REVOKE
3
+GRANT
4
+CREATE FUNCTION
5
+REVOKE
6
+GRANT
docs/wp1/evidence/graph-read/up2.log
new
+6
@@ -0,0 +1,6 @@
1
+CREATE FUNCTION
2
+REVOKE
3
+GRANT
4
+CREATE FUNCTION
5
+REVOKE
6
+GRANT
docs/wp1/evidence/graph-snapshot/fresh.log
new
+4
@@ -0,0 +1,4 @@
1
+Output format is unaligned.
2
+ed000000-0000-4000-8000-000000000001
3
+SET
4
+{"records": [{"id": "GR_TXN_A", "data": {"debit": 1500, "credit": 0, "lineNo": 1, "accountId": "GR_A", "companyId": "GR_C", "voucherId": "GR_TXN", "description": "", "currencyCode": "IRR", "fiscalYearId": "GR_Y", "reversesLineId": ""}, "version": 1, "collection": "journalLines"}, {"id": "GR_TXN_B", "data": {"debit": 0, "credit": 1500, "lineNo": 2, "accountId": "GR_B", "companyId": "GR_C", "voucherId": "GR_TXN", "description": "", "currencyCode": "IRR", "fiscalYearId": "GR_Y", "reversesLineId": ""}, "version": 1, "collection": "journalLines"}, {"id": "GR_TXN", "data": {"date": "1405/07/24", "status": "draft", "editedAt": "2026-11-04T22:16:04.198184+00:00", "editedBy": "ed000000-0000-4000-8000-000000000001", "sourceId": "", "companyId": "GR_C", "createdAt": "2026-11-04T22:16:03.887917+00:00", "createdBy": "ed000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "after", "voucherType": "manual", "fiscalYearId": "GR_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "0c57c986d1f65a712885dc323cbbb47f", "reversalAllocations": null}, "version": 2, "collection": "journalVouchers"}], "voucher_id": "GR_TXN", "organization_id": "5ff018c3-f866-4308-9281-7f80bc8d5932", "effective_status": "draft"}
docs/wp1/evidence/graph-snapshot/reader.log
new
+3
@@ -0,0 +1,3 @@
1
+ed000000-0000-4000-8000-000000000001
2
+SET
3
+{"records": [{"id": "GR_TXN_A", "data": {"debit": 1000, "credit": 0, "lineNo": 1, "accountId": "GR_A", "companyId": "GR_C", "voucherId": "GR_TXN", "description": "", "currencyCode": "IRR", "fiscalYearId": "GR_Y", "reversesLineId": ""}, "version": 1, "collection": "journalLines"}, {"id": "GR_TXN_B", "data": {"debit": 0, "credit": 1000, "lineNo": 2, "accountId": "GR_B", "companyId": "GR_C", "voucherId": "GR_TXN", "description": "", "currencyCode": "IRR", "fiscalYearId": "GR_Y", "reversesLineId": ""}, "version": 1, "collection": "journalLines"}, {"id": "GR_TXN", "data": {"date": "1405/07/24", "status": "draft", "sourceId": "", "companyId": "GR_C", "createdAt": "2026-11-04T22:16:03.887917+00:00", "createdBy": "ed000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "before", "voucherType": "manual", "fiscalYearId": "GR_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "7458c41f5b608877e19532044e421585", "reversalAllocations": null}, "version": 1, "collection": "journalVouchers"}], "voucher_id": "GR_TXN", "organization_id": "5ff018c3-f866-4308-9281-7f80bc8d5932", "effective_status": "draft"}
docs/wp1/evidence/graph-snapshot/result.json
new
+26
@@ -0,0 +1,26 @@
1
+{
2
+ "result": "PASS",
3
+ "scope": "Two real SQL sessions; commit occurs after outer read snapshot begins and before graph evaluation. Not HTTP/JWT acceptance.",
4
+ "applied": [
5
+ "20261016100000_phase1a_server_journal_invariants.sql",
6
+ "20261016100500_phase1a_optimistic_version_sync.sql",
7
+ "20261016101000_phase1a_guard_modes_audit.sql",
8
+ "20261016101500_phase1a_journal_core.sql",
9
+ "20261016102000_phase1a_journal_rpc_surface.sql",
10
+ "20261016102500_phase1a_account_role_protection.sql",
11
+ "20261016103000_phase1a_sale_monetary_contract.sql",
12
+ "20261016103100_phase1a_autopost_server_authority.sql",
13
+ "20261016103500_phase1a_purchase_fixed_contract.sql",
14
+ "20261016104000_stage22_manual_guard_owner_mode.sql",
15
+ "20261016104500_stage3_posted_source_immutable.sql",
16
+ "20261102141933_wp1_ledger_scope_authority_hardening.sql",
17
+ "20261104020908_wp1_reversal_dimensions.sql",
18
+ "20261104072719_wp1_manual_update_guards.sql",
19
+ "20261104214503_wp1_null_revision_guards.sql",
20
+ "20261104220102_wp1_journal_graph_read.sql"
21
+ ],
22
+ "oldVersion": 1,
23
+ "newVersion": 2,
24
+ "oldAmount": 1000,
25
+ "newAmount": 1500
26
+}
docs/wp1/evidence/graph-snapshot/volatile-mutant-reader.log
new
+3
@@ -0,0 +1,3 @@
1
+ed000000-0000-4000-8000-000000000001
2
+SET
3
+{"records": [{"id": "GR_TXN_A", "data": {"debit": 1500, "credit": 0, "lineNo": 1, "accountId": "GR_A", "companyId": "GR_C", "voucherId": "GR_TXN", "description": "", "currencyCode": "IRR", "fiscalYearId": "GR_Y", "reversesLineId": ""}, "version": 1, "collection": "journalLines"}, {"id": "GR_TXN_B", "data": {"debit": 0, "credit": 1500, "lineNo": 2, "accountId": "GR_B", "companyId": "GR_C", "voucherId": "GR_TXN", "description": "", "currencyCode": "IRR", "fiscalYearId": "GR_Y", "reversesLineId": ""}, "version": 1, "collection": "journalLines"}, {"id": "GR_TXN", "data": {"date": "1405/07/24", "status": "draft", "editedAt": "2026-11-04T22:17:10.131553+00:00", "editedBy": "ed000000-0000-4000-8000-000000000001", "sourceId": "", "companyId": "GR_C", "createdAt": "2026-11-04T22:17:09.830644+00:00", "createdBy": "ed000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "after", "voucherType": "manual", "fiscalYearId": "GR_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "0c57c986d1f65a712885dc323cbbb47f", "reversalAllocations": null}, "version": 2, "collection": "journalVouchers"}], "voucher_id": "GR_TXN", "organization_id": "aa484298-7dfc-40c8-bf18-9b1eeb36b41d", "effective_status": "draft"}
docs/wp1/evidence/graph-snapshot/volatile-mutant-red.log
new
+22
@@ -0,0 +1,22 @@
1
+node:internal/modules/run_main:107
2
+ triggerUncaughtException(
3
+ ^
4
+
5
+AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
6
+
7
+2 !== 1
8
+
9
+ at check (file:///workspace/wp1-graph-volatile-mutant.mjs:27:148)
10
+ at file:///workspace/wp1-graph-volatile-mutant.mjs:28:3
11
+ at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
12
+ at async withDisposableLedger (file:///workspace/Factor-easy-wp1-graph/scripts/wp0-ledger-harness.mjs:54:12)
13
+ at async file:///workspace/wp1-graph-volatile-mutant.mjs:6:1 {
14
+ generatedMessage: true,
15
+ code: 'ERR_ASSERTION',
16
+ actual: 2,
17
+ expected: 1,
18
+ operator: 'strictEqual',
19
+ diff: 'simple'
20
+}
21
+
22
+Node.js v24.19.0
docs/wp1/evidence/graph-snapshot/volatile-mutant.json
new
+8
@@ -0,0 +1,8 @@
1
+{
2
+ "result": "EXPECTED_FAIL",
3
+ "isolatedMutation": "ALTER FUNCTION public.finora_journal_read_graph(uuid,text) VOLATILE;",
4
+ "expectedReaderVersion": 1,
5
+ "observedReaderVersion": 2,
6
+ "normalTestSha256": "8340e3e3bf81fb1d0e0d8017bf9449dc9411697d87eeb8bf8a6eae3d38c83d53",
7
+ "scope": "Local disposable mutation only; no tracked migration or production function changed."
8
+}
docs/wp1/evidence/graph-snapshot/writer.log
new
+11
@@ -0,0 +1,11 @@
1
+ set_config
2
+--------------------------------------
3
+ ed000000-0000-4000-8000-000000000001
4
+(1 row)
5
+
6
+SET
7
+ finora_journal_update_draft
8
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
9
+ {"voucher": {"id": "GR_TXN", "date": "1405/07/24", "status": "draft", "version": 2, "editedAt": "2026-11-04T22:16:04.198184+00:00", "editedBy": "ed000000-0000-4000-8000-000000000001", "sourceId": "", "companyId": "GR_C", "createdAt": "2026-11-04T22:16:03.887917+00:00", "createdBy": "ed000000-0000-4000-8000-000000000001", "reference": "", "sourceType": "manual", "description": "after", "voucherType": "manual", "fiscalYearId": "GR_Y", "sourceVersion": "1", "reversalReason": "", "requestFingerprint": "0c57c986d1f65a712885dc323cbbb47f", "reversalAllocations": null}}
10
+(1 row)
11
+
docs/wp1/evidence/prerequisite-rollback/posted-reversal-seed.log
+1
-1
@@ -5,7 +5,7 @@
5
{"name":"two_posts","pass":true,"diagnostic":" "}
6
{"name":"gapless_numbers","pass":true,"diagnostic":"1,2\n"}
7
{"name":"original","pass":true,"diagnostic":""}
8
-{"name":"two_reversals_one_winner","pass":true,"diagnostic":"ERROR: FINORA_REVERSAL_OVER_ALLOCATION\nCONTEXT: PL/pgSQL function public.finora_journal_reverse(uuid,text,text,text,text,bigint,jsonb) line 73 at RAISE\n "}
8
+{"name":"two_reversals_one_winner","pass":true,"diagnostic":" ERROR: FINORA_REVERSAL_OVER_ALLOCATION\nCONTEXT: PL/pgSQL function public.finora_journal_reverse(uuid,text,text,text,text,bigint,jsonb) line 73 at RAISE\n"}
9
{"name":"no_duplicate_reversals","pass":true,"diagnostic":"1\n"}
10
{"name":"partial_status_from_view","pass":true,"diagnostic":"partially_reversed\n"}
11
FINORA_STAGE1_TWO_CONNECTIONS_PASS
docs/wp1/evidence/prerequisite-rollback/result.json
+5
-4
@@ -5,16 +5,17 @@
5
"20261102141933_wp1_ledger_scope_authority_hardening.sql",
6
"20261104020908_wp1_reversal_dimensions.sql",
7
"20261104072719_wp1_manual_update_guards.sql",
8
- "20261104214503_wp1_null_revision_guards.sql"
8
+ "20261104214503_wp1_null_revision_guards.sql",
9
+ "20261104220102_wp1_journal_graph_read.sql"
10
],
11
"baselineFunctionCount": 71,
12
"retained": {
13
"posted_count": 4,
14
"line_count": 10,
15
"audit_count": 10,
15
- "records": "b81550f6460d8d97d9bb13d3901a2b4d",
16
- "audit": "59236fd7c72dc75c96521ec8d119e908",
17
- "counters": "62e823a267de48669acb7dfedba950dc"
16
+ "records": "905b24de7ebab17a8e04d11d7602f774",
17
+ "audit": "8a7c72ecc9a88bbdf7a25cd28eba983a",
18
+ "counters": "f2680bfa05ba448deb9802c02257b83f"
19
},
20
"scope": "conservative rollback preserves inert structures/indexes; NOT pristine schema or production parity"
21
}
scripts/wp1-graph-read-cycle.mjs
new
+33
@@ -0,0 +1,33 @@
1
+// Source-derived disposable PostgreSQL only; no remote URL accepted.
2
+import {withDisposableLedger} from './wp0-ledger-harness.mjs';
3
+import {readFileSync,readdirSync,mkdirSync,writeFileSync} from 'node:fs';
4
+import {createHash} from 'node:crypto';
5
+import assert from 'node:assert/strict';
6
+const migration='20261104220102_wp1_journal_graph_read.sql';
7
+const out=process.env.WP1_EVIDENCE_DIR||'docs/wp1/evidence/graph-read';mkdirSync(out,{recursive:true});
8
+const fixture=readFileSync('supabase/tests/wp1_journal_graph_read.sql','utf8');
9
+await withDisposableLedger(async c=>{
10
+ const steps=[];
11
+ const run=(label,sql,red=false)=>{const r=c.sql(sql),log=(r.stdout||'')+(r.stderr||'');writeFileSync(out+'/'+label+'.log',log);if(red){assert.notEqual(r.status,0);assert.match(log,/WP1_GRAPH_RPC_MISSING/);}else c.requireSuccess(r,label);steps.push(label);return r;};
12
+ const query=sql=>JSON.parse(run('snapshot','\\pset format unaligned\n\\pset tuples_only on\n'+sql).stdout.split('\n').find(x=>x.startsWith('{')));
13
+ const catalog=()=>query(`select coalesce(json_object_agg(n.nspname||'.'||p.proname,json_build_object('definition',pg_get_functiondef(p.oid),'acl',p.proacl::text)),'{}') from pg_proc p join pg_namespace n on n.oid=p.pronamespace where (n.nspname='public' and p.proname='finora_journal_read_graph') or (n.nspname='private' and p.proname='finora_journal_graph_accessible');`);
14
+ const fingerprint=()=>query(`select json_build_object('posted',(select count(*) from public.records where collection='journalVouchers' and data->>'status'='posted'),'lines',(select count(*) from public.records where collection='journalLines'),'records',md5(coalesce((select string_agg(row_to_json(r)::text,'' order by organization_id,collection,id) from public.records r),'')),'audit',md5(coalesce((select string_agg(row_to_json(a)::text,'' order by id) from private.finora_phase1a_journal_audit a),'')),'counters',md5(coalesce((select string_agg(row_to_json(c)::text,'' order by organization_id,company_id,fiscal_year_id) from private.finora_wp1_company_counters c),'')),'members',md5(coalesce((select string_agg(row_to_json(m)::text,'' order by id) from public.organization_members m),'')),'permissions',md5(coalesce((select string_agg(row_to_json(m)::text,'' order by id) from public.member_module_permissions m),'')));`);
15
+ const prior=readdirSync('supabase/migrations').filter(f=>(f.startsWith('2026101610')||f.includes('_wp1_'))&&f.endsWith('.sql')&&f<migration).sort();for(const f of prior)c.apply('supabase/migrations/'+f);
16
+ assert.deepEqual(catalog(),{});run('baseline-red',fixture,true);
17
+ run('up1',readFileSync('supabase/migrations/'+migration,'utf8'));const after=catalog();assert.equal(Object.keys(after).length,2);
18
+ run('green-retained',fixture.replace(/rollback;\s*$/i,'commit;'));const retained=fingerprint();assert.equal(retained.posted,3);assert.equal(retained.lines,1010);
19
+ run('read-only-probe',String.raw`\timing on
20
+select set_config('request.jwt.claim.sub','ed000000-0000-4000-8000-000000000001',false);
21
+set role authenticated;
22
+select 'large_graph' as probe,jsonb_array_length(public.finora_journal_read_graph((select id from public.organizations where owner_user_id='ed000000-0000-4000-8000-000000000001'),'GR_LARGE')->'records') as rows;
23
+select 'posted_graph' as probe,public.finora_journal_read_graph((select id from public.organizations where owner_user_id='ed000000-0000-4000-8000-000000000001'),'GR_DOC')->>'effective_status' as status;
24
+`);assert.deepEqual(fingerprint(),retained,'Read API changed records/audit/counters/members/permissions');
25
+ run('definer-security',readFileSync('supabase/tests/wp1_phase1a_stage1_all_definer_security.sql','utf8'));
26
+ run('down',readFileSync('supabase/rollback/'+migration,'utf8'));assert.deepEqual(catalog(),{});assert.deepEqual(fingerprint(),retained);
27
+ run('down-red',fixture,true);assert.deepEqual(fingerprint(),retained);
28
+ run('up2',readFileSync('supabase/migrations/'+migration,'utf8'));assert.deepEqual(catalog(),after);assert.deepEqual(fingerprint(),retained);
29
+ run('green-up2',fixture.replaceAll('ed000000','ee000000').replaceAll('wp1-graph-','wp1-graph-up2-'));assert.deepEqual(fingerprint(),retained);
30
+ const hashes=Object.fromEntries(['supabase/migrations/'+migration,'supabase/rollback/'+migration,'supabase/tests/wp1_journal_graph_read.sql'].map(f=>[f,createHash('sha256').update(readFileSync(f)).digest('hex')]));
31
+ writeFileSync(out+'/result.json',JSON.stringify({result:'PASS',scope:'source-derived SQL, not real Auth/JWT/PostgREST, schema parity or performance acceptance',steps,prior,retained,hashes},null,2)+'\n');
32
+ console.log('PASS graph read: RLS/full-graph checks,1003-row graph,statuses,corruption,security audit,exact DOWN/UP and unchanged history/permissions.');
33
+});
scripts/wp1-graph-snapshot-test.mjs
new
+32
@@ -0,0 +1,32 @@
1
+// Real two-session graph visibility on an isolated source-derived PostgreSQL.
2
+import{withDisposableLedger}from'./wp0-ledger-harness.mjs';
3
+import{readFileSync,readdirSync,mkdirSync,writeFileSync}from'node:fs';
4
+import{spawn}from'node:child_process';import assert from'node:assert/strict';
5
+const out=process.env.WP1_EVIDENCE_DIR||'docs/wp1/evidence/graph-snapshot';mkdirSync(out,{recursive:true});
6
+await withDisposableLedger(async c=>{
7
+ const applied=readdirSync('supabase/migrations').filter(f=>(f.startsWith('2026101610')||f.includes('_wp1_'))&&f.endsWith('.sql')).sort();for(const f of applied)c.apply('supabase/migrations/'+f);
8
+ const auth="select set_config('request.jwt.claim.sub','ed000000-0000-4000-8000-000000000001',false);set role authenticated;";
9
+ const org="(select id from public.organizations where owner_user_id='ed000000-0000-4000-8000-000000000001')";
10
+ const fixture=readFileSync('supabase/tests/wp1_journal_graph_read.sql','utf8');
11
+ c.requireSuccess(c.sql(fixture.slice(0,fixture.indexOf('set local role authenticated;'))+`set local role authenticated;select public.finora_journal_create_draft(${org},'GR_TXN','{"companyId":"GR_C","fiscalYearId":"GR_Y","date":"1405/07/24","description":"before"}','[{"id":"GR_TXN_A","accountId":"GR_A","debit":1000,"credit":0},{"id":"GR_TXN_B","accountId":"GR_B","debit":0,"credit":1000}]');commit;`),'setup');
12
+ const child=spawn('docker',['exec','-i',`finora-wp0-ledger-${process.pid}`,'psql','-X','-U','postgres','-d','finora_wp0','-At','-v','ON_ERROR_STOP=1'],{env:{...process.env,DOCKER_HOST:'unix:///var/run/docker.sock',DOCKER_CONTEXT:'',DOCKER_TLS:'',DOCKER_TLS_VERIFY:'',DOCKER_CERT_PATH:''},stdio:['pipe','pipe','pipe']});
13
+ let stdout='',stderr='';child.stdout.on('data',b=>stdout+=b);child.stderr.on('data',b=>stderr+=b);
14
+ const finished=new Promise((resolve,reject)=>{child.on('error',reject);child.on('close',status=>resolve(status));});
15
+ try{
16
+ // Materialized wait keeps the outer SELECT snapshot open while a different
17
+ // session commits the edit; no application function or policy is patched.
18
+ child.stdin.end(auth+`WITH snapshot_wait AS MATERIALIZED (SELECT pg_sleep(3)) SELECT public.finora_journal_read_graph(${org},'GR_TXN') FROM snapshot_wait /* WP1_GRAPH_SNAPSHOT_READER */;`);
19
+ let waiting=false;
20
+ for(let i=0;i<40;i++){const r=c.sql("select count(*) from pg_stat_activity where pid<>pg_backend_pid() and wait_event='PgSleep' and query like '%WP1_GRAPH_SNAPSHOT_READER%';");c.requireSuccess(r,'reader barrier');if(/\n\s*1\s*\n/.test(r.stdout)){waiting=true;break;}await new Promise(r=>setTimeout(r,50));}
21
+ assert.ok(waiting,'Reader snapshot barrier not observed');
22
+ const write=c.sql(auth+`select public.finora_journal_update_draft(${org},'GR_TXN',1,'{"description":"after"}','[{"id":"GR_TXN_A","accountId":"GR_A","debit":1500,"credit":0},{"id":"GR_TXN_B","accountId":"GR_B","debit":0,"credit":1500}]');`);c.requireSuccess(write,'concurrent commit');writeFileSync(out+'/writer.log',write.stdout+write.stderr);
23
+ assert.equal(await finished,0,stderr);writeFileSync(out+'/reader.log',stdout+stderr);
24
+ const old=JSON.parse(stdout.split('\n').find(s=>s.startsWith('{')));
25
+ const fresh=c.sql('\\pset format unaligned\n\\pset tuples_only on\n'+auth+`select public.finora_journal_read_graph(${org},'GR_TXN');`);c.requireSuccess(fresh,'fresh graph');writeFileSync(out+'/fresh.log',fresh.stdout+fresh.stderr);
26
+ const latest=JSON.parse(fresh.stdout.split('\n').find(s=>s.startsWith('{')));
27
+ const check=(g,version,description,amount)=>{assert.equal(g.records.length,3);const h=g.records.find(r=>r.collection==='journalVouchers');assert.equal(h.version,version);assert.equal(h.data.description,description);const lines=g.records.filter(r=>r.collection==='journalLines');assert.equal(lines.reduce((s,r)=>s+r.data.debit,0),amount);assert.equal(lines.reduce((s,r)=>s+r.data.credit,0),amount);};
28
+ check(old,1,'before',1000);check(latest,2,'after',1500);
29
+ writeFileSync(out+'/result.json',JSON.stringify({result:'PASS',scope:'Two real SQL sessions; commit occurs after outer read snapshot begins and before graph evaluation. Not HTTP/JWT acceptance.',applied,oldVersion:1,newVersion:2,oldAmount:1000,newAmount:1500},null,2)+'\n');
30
+ console.log('PASS graph snapshot: in-flight reader gets complete old graph; fresh reader gets complete committed edit.');
31
+ }finally{if(child.exitCode===null)child.kill('SIGTERM');}
32
+});
supabase/migration-manifest.json
+6
-1
@@ -389,6 +389,10 @@
389
{
390
"file": "20261104214503_wp1_null_revision_guards.sql",
391
"sha256": "de8dffeab02aff67ac07c9d1d04f203ed0294285e102805cb97cf9bba1c16b98"
392
+ },
393
+ {
394
+ "file": "20261104220102_wp1_journal_graph_read.sql",
395
+ "sha256": "93f8b6e4b0462d504817b1360a9c0a09a7b35ab13bd6d9648ba1f981e3f544bb"
396
}
397
],
398
"unreconciled_production_only": [
@@ -456,6 +460,7 @@
460
"20261102141933",
461
"20261104020908",
462
"20261104072719",
459
- "20261104214503"
463
+ "20261104214503",
464
+ "20261104220102"
465
]
466
}
supabase/migrations/20261104220102_wp1_journal_graph_read.sql
new
+87
@@ -0,0 +1,87 @@
1
+-- CLI-generated additive read prerequisite; G1 HOLD, no production activation.
2
+-- Only a boolean completeness decision runs as definer. Every row is checked
3
+-- through the existing record policy; no hidden row or count is returned.
4
+CREATE FUNCTION private.finora_journal_graph_accessible(p_organization_id uuid,p_voucher_id text)
5
+RETURNS boolean LANGUAGE sql STABLE SECURITY DEFINER SET search_path='' AS $access$
6
+ WITH h AS MATERIALIZED (
7
+ SELECT r.id FROM public.records r WHERE r.organization_id=p_organization_id
8
+ AND r.collection='journalVouchers' AND r.id=p_voucher_id AND auth.uid() IS NOT NULL
9
+ AND private.can_access_record(r.organization_id,r.collection,r.owner_id,r.data,'read')
10
+ ), voucher_ids AS MATERIALIZED (
11
+ SELECT id FROM h UNION SELECT r.id FROM public.records r JOIN h ON r.data->>'sourceId'=h.id
12
+ WHERE r.organization_id=p_organization_id AND r.collection='journalVouchers'
13
+ AND r.data->>'sourceType'='reversal' AND r.data->>'status'='posted'
14
+ ), lines AS MATERIALIZED (
15
+ SELECT r.* FROM public.records r WHERE r.organization_id=p_organization_id
16
+ AND r.collection='journalLines' AND r.data->>'voucherId' IN (SELECT id FROM voucher_ids)
17
+ ), related AS (
18
+ SELECT r.* FROM public.records r WHERE r.organization_id=p_organization_id AND (
19
+ (r.collection='journalVouchers' AND r.id IN (SELECT id FROM voucher_ids))
20
+ OR (r.collection='journalLines' AND r.id IN (SELECT id FROM lines))
21
+ OR (r.collection='journalLineDimensions' AND (r.data->>'voucherId' IN (SELECT id FROM voucher_ids)
22
+ OR r.data->>'journalLineId' IN (SELECT id FROM lines))))
23
+ )
24
+ SELECT EXISTS(SELECT FROM h) AND NOT EXISTS(SELECT FROM related r
25
+ WHERE NOT coalesce(private.can_access_record(r.organization_id,r.collection,r.owner_id,r.data,'read'),false));
26
+$access$;
27
+REVOKE ALL ON FUNCTION private.finora_journal_graph_accessible(uuid,text) FROM PUBLIC,anon;
28
+GRANT EXECUTE ON FUNCTION private.finora_journal_graph_accessible(uuid,text) TO authenticated;
29
+
30
+CREATE FUNCTION public.finora_journal_read_graph(p_organization_id uuid,p_voucher_id text)
31
+RETURNS jsonb LANGUAGE plpgsql STABLE SECURITY INVOKER SET search_path='' AS $graph$
32
+DECLARE graph jsonb; allowed boolean; invalid boolean;
33
+BEGIN
34
+ -- One statement and STABLE helpers share one snapshot. RLS applies to every
35
+ -- returned row. Reuse materialized rows for status instead of rereading them.
36
+ WITH h AS MATERIALIZED (
37
+ SELECT r.* FROM public.records r WHERE r.organization_id=p_organization_id
38
+ AND r.collection='journalVouchers' AND r.id=p_voucher_id
39
+ ), vouchers AS MATERIALIZED (
40
+ SELECT * FROM h UNION ALL SELECT r.* FROM public.records r JOIN h ON r.data->>'sourceId'=h.id
41
+ WHERE r.organization_id=p_organization_id AND r.collection='journalVouchers'
42
+ AND r.data->>'sourceType'='reversal' AND r.data->>'status'='posted' AND r.id<>h.id
43
+ ), lines AS MATERIALIZED (
44
+ SELECT r.* FROM public.records r WHERE r.organization_id=p_organization_id
45
+ AND r.collection='journalLines' AND r.data->>'voucherId' IN (SELECT id FROM vouchers)
46
+ ), dimensions AS MATERIALIZED (
47
+ SELECT r.* FROM public.records r WHERE r.organization_id=p_organization_id
48
+ AND r.collection='journalLineDimensions' AND (r.data->>'voucherId' IN (SELECT id FROM vouchers)
49
+ OR r.data->>'journalLineId' IN (SELECT id FROM lines))
50
+ ), related AS MATERIALIZED (
51
+ SELECT * FROM vouchers UNION ALL SELECT * FROM lines UNION ALL SELECT * FROM dimensions
52
+ ), inverse AS (
53
+ SELECT l.data->>'reversesLineId' line_id,
54
+ sum(greatest((l.data->>'debit')::numeric,(l.data->>'credit')::numeric)) amount
55
+ FROM lines l JOIN vouchers v ON l.data->>'voucherId'=v.id
56
+ WHERE v.id<>p_voucher_id GROUP BY l.data->>'reversesLineId'
57
+ ), reversal_status AS (
58
+ -- Same aggregate semantics as finora_journal_reversal_status, using the
59
+ -- already selected graph. Never rewrite the original header or revision.
60
+ SELECT CASE WHEN sum(coalesce(i.amount,0))=0 THEN 'posted'
61
+ WHEN bool_and(coalesce(i.amount,0)=greatest((l.data->>'debit')::numeric,(l.data->>'credit')::numeric))
62
+ THEN 'reversed' ELSE 'partially_reversed' END status
63
+ FROM lines l LEFT JOIN inverse i ON i.line_id=l.id
64
+ WHERE l.data->>'voucherId'=p_voucher_id HAVING count(*)>0
65
+ )
66
+ SELECT jsonb_build_object('organization_id',p_organization_id,'voucher_id',h.id,
67
+ 'effective_status',CASE WHEN h.data->>'status'='posted' AND coalesce(h.data->>'sourceType','')<>'reversal'
68
+ THEN coalesce((SELECT status FROM reversal_status),h.data->>'status') ELSE h.data->>'status' END,
69
+ 'records',(SELECT jsonb_agg(jsonb_build_object('collection',r.collection,'id',r.id,'data',r.data,'version',r.version)
70
+ ORDER BY r.collection,r.id) FROM related r WHERE
71
+ (r.collection='journalVouchers' AND r.id=h.id)
72
+ OR (r.collection IN ('journalLines','journalLineDimensions') AND r.data->>'voucherId'=h.id))),
73
+ private.finora_journal_graph_accessible(p_organization_id,h.id),
74
+ nullif(h.data->>'companyId','') IS NULL OR EXISTS(SELECT FROM related r WHERE
75
+ r.data->>'companyId' IS DISTINCT FROM h.data->>'companyId'
76
+ OR (r.collection='journalLineDimensions' AND NOT EXISTS(SELECT FROM lines l
77
+ WHERE l.id=r.data->>'journalLineId' AND l.data->>'voucherId'=r.data->>'voucherId')))
78
+ INTO graph,allowed,invalid FROM h;
79
+ IF graph IS NULL THEN RETURN NULL; END IF;
80
+ IF NOT coalesce(allowed,false) THEN
81
+ RAISE EXCEPTION 'FINORA_JOURNAL_GRAPH_FORBIDDEN' USING ERRCODE='42501';
82
+ END IF;
83
+ IF invalid THEN RAISE EXCEPTION 'FINORA_JOURNAL_GRAPH_INVALID' USING ERRCODE='23514'; END IF;
84
+ RETURN graph;
85
+END $graph$;
86
+REVOKE ALL ON FUNCTION public.finora_journal_read_graph(uuid,text) FROM PUBLIC,anon;
87
+GRANT EXECUTE ON FUNCTION public.finora_journal_read_graph(uuid,text) TO authenticated;
supabase/rollback/20261104220102_wp1_journal_graph_read.sql
new
+3
@@ -0,0 +1,3 @@
1
+-- Read-only API removal; all financial records and prior APIs remain unchanged.
2
+DROP FUNCTION public.finora_journal_read_graph(uuid,text);
3
+DROP FUNCTION private.finora_journal_graph_accessible(uuid,text);
supabase/tests/wp1_journal_graph_read.sql
new
+132
@@ -0,0 +1,132 @@
1
+\set ON_ERROR_STOP on
2
+\timing on
3
+begin;
4
+do $$begin
5
+ if to_regprocedure('public.finora_journal_read_graph(uuid,text)') is null then raise exception 'WP1_GRAPH_RPC_MISSING';end if;
6
+end $$;
7
+insert into auth.users(id,email,email_confirmed_at,raw_user_meta_data) values
8
+('ed000000-0000-4000-8000-000000000001','wp1-graph-owner@example.invalid',now(),'{}'),
9
+('ed000000-0000-4000-8000-000000000002','wp1-graph-other@example.invalid',now(),'{}'),
10
+('ed000000-0000-4000-8000-000000000003','wp1-graph-reader@example.invalid',now(),'{}');
11
+select set_config('wp1.graph_org',(select id::text from public.organizations where owner_user_id='ed000000-0000-4000-8000-000000000001'),true);
12
+select set_config('wp1.graph_other',(select id::text from public.organizations where owner_user_id='ed000000-0000-4000-8000-000000000002'),true);
13
+select set_config('request.jwt.claim.sub','ed000000-0000-4000-8000-000000000001',true);
14
+update public.licenses set max_users=3 where organization_id=current_setting('wp1.graph_org')::uuid;
15
+insert into public.organization_members(organization_id,user_id,status,is_owner) values(current_setting('wp1.graph_org')::uuid,'ed000000-0000-4000-8000-000000000003','active',false);
16
+insert into public.member_module_permissions(organization_id,member_id,module_key,capabilities,scope_type,confidentiality_level)
17
+select organization_id,id,'full_suite',array['read'],'organization',0 from public.organization_members where organization_id=current_setting('wp1.graph_org')::uuid and user_id='ed000000-0000-4000-8000-000000000003';
18
+insert into public.records(owner_id,organization_id,collection,id,data) values
19
+(auth.uid(),current_setting('wp1.graph_org')::uuid,'companies','GR_C','{"name":"Graph fixture"}'),
20
+(auth.uid(),current_setting('wp1.graph_org')::uuid,'fiscalYears','GR_Y','{"companyId":"GR_C","startDate":"1405/01/01","endDate":"1405/12/29","status":"open"}'),
21
+(auth.uid(),current_setting('wp1.graph_org')::uuid,'accounts','GR_A','{"companyId":"GR_C","active":true,"postingAllowed":true}'),
22
+(auth.uid(),current_setting('wp1.graph_org')::uuid,'accounts','GR_B','{"companyId":"GR_C","active":true,"postingAllowed":true}'),
23
+(auth.uid(),current_setting('wp1.graph_org')::uuid,'dimensionTypes','GR_TYPE','{"companyId":"GR_C","active":true}'),
24
+(auth.uid(),current_setting('wp1.graph_org')::uuid,'dimensionValues','GR_VALUE','{"companyId":"GR_C","dimensionTypeId":"GR_TYPE","active":true}');
25
+set local role authenticated;
26
+select public.finora_journal_create_draft(current_setting('wp1.graph_org')::uuid,'GR_DOC',
27
+ '{"companyId":"GR_C","fiscalYearId":"GR_Y","date":"1405/07/24"}',
28
+ '[{"id":"GR_LINE_A","accountId":"GR_A","debit":100,"credit":0,"dimensions":[{"dimensionTypeId":"GR_TYPE","dimensionValueId":"GR_VALUE"}]},{"id":"GR_LINE_B","accountId":"GR_B","debit":0,"credit":100}]');
29
+do $$declare r jsonb; expected jsonb;begin
30
+ r:=public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'GR_DOC');
31
+ select jsonb_agg(jsonb_build_object('collection',collection,'id',id,'data',data,'version',version) order by collection,id) into expected from public.records where organization_id=current_setting('wp1.graph_org')::uuid and ((collection='journalVouchers' and id='GR_DOC') or (collection in ('journalLines','journalLineDimensions') and data->>'voucherId'='GR_DOC'));
32
+ if r->'records' is distinct from expected or jsonb_array_length(r->'records')<>4 or r->>'effective_status'<>'draft' or r->>'voucher_id'<>'GR_DOC' or r->>'organization_id'<>current_setting('wp1.graph_org') then raise exception 'GR_DRAFT_GRAPH_MISMATCH';end if;
33
+ if public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'MISSING') is not null or public.finora_journal_read_graph(null,'GR_DOC') is not null or public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,null) is not null then raise exception 'GR_ABSENCE_NOT_NULL';end if;
34
+end $$;
35
+select public.finora_journal_post(current_setting('wp1.graph_org')::uuid,'GR_DOC',1);
36
+do $$begin
37
+ if public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'GR_DOC')->>'effective_status'<>'posted' then raise exception 'GR_POSTED_STATUS';end if;
38
+end $$;
39
+select public.finora_journal_reverse(current_setting('wp1.graph_org')::uuid,'GR_DOC','GR_PART1','1405/07/25','Graph partial reversal',2,'[{"lineId":"GR_LINE_A","amount":40},{"lineId":"GR_LINE_B","amount":40}]');
40
+do $$declare r jsonb;begin
41
+ r:=public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'GR_DOC');
42
+ if r->>'effective_status'<>'partially_reversed' or jsonb_array_length(r->'records')<>4 then raise exception 'GR_PARTIAL_STATUS';end if;
43
+ if public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'GR_PART1')->>'effective_status'<>'posted' then raise exception 'GR_REVERSAL_STATUS';end if;
44
+end $$;
45
+select public.finora_journal_reverse(current_setting('wp1.graph_org')::uuid,'GR_DOC','GR_PART2','1405/07/26','Graph remaining reversal',2,'[{"lineId":"GR_LINE_A","amount":60},{"lineId":"GR_LINE_B","amount":60}]');
46
+do $$begin
47
+ if public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'GR_DOC')->>'effective_status'<>'reversed' then raise exception 'GR_REVERSED_STATUS';end if;
48
+ if not exists(select from jsonb_array_elements(public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'GR_DOC')->'records') e where e->>'collection'='journalVouchers' and e#>>'{data,status}'='posted' and e->>'version'='2') then raise exception 'GR_DERIVED_STATUS_CHANGED_HEADER';end if;
49
+end $$;
50
+set constraints all immediate;
51
+reset role;
52
+-- Synthetic legacy fixture only: bulk large draft and deliberately malformed
53
+-- graphs cannot be created through the guarded production mutation RPCs.
54
+alter table public.records disable trigger user;
55
+insert into public.records(owner_id,organization_id,collection,id,data) values
56
+(auth.uid(),current_setting('wp1.graph_org')::uuid,'journalVouchers','GR_LARGE','{"companyId":"GR_C","fiscalYearId":"GR_Y","date":"1405/07/24","status":"draft","sourceType":"manual"}'),
57
+('ed000000-0000-4000-8000-000000000002',current_setting('wp1.graph_other')::uuid,'journalVouchers','GR_DOC','{"companyId":"GR_C","status":"draft","description":"FOREIGN_SECRET"}'),
58
+('ed000000-0000-4000-8000-000000000002',current_setting('wp1.graph_other')::uuid,'journalLines','GR_LINE_A','{"companyId":"GR_C","voucherId":"GR_DOC","description":"FOREIGN_SECRET"}'),
59
+(auth.uid(),current_setting('wp1.graph_org')::uuid,'journalLines','GR_ORPHAN','{"companyId":"GR_C","voucherId":"NO_HEADER"}');
60
+insert into public.records(owner_id,organization_id,collection,id,data)
61
+select auth.uid(),current_setting('wp1.graph_org')::uuid,'journalLines','GR_BIG_'||lpad(n::text,4,'0'),jsonb_build_object('companyId','GR_C','voucherId','GR_LARGE','accountId',case when n%2=0 then 'GR_A' else 'GR_B' end,'debit',case when n%2=0 then 1 else 0 end,'credit',case when n%2=1 then 1 else 0 end) from generate_series(1,1002) n;
62
+alter table public.records enable trigger user;
63
+set local role authenticated;
64
+do $$declare r jsonb;begin
65
+ r:=public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'GR_LARGE');
66
+ if jsonb_array_length(r->'records')<>1003 then raise exception 'GR_LARGE_GRAPH_TRUNCATED';end if;
67
+ if r is distinct from public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'GR_LARGE') then raise exception 'GR_ORDER_UNSTABLE';end if;
68
+ if public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'NO_HEADER') is not null or public.finora_journal_read_graph(current_setting('wp1.graph_other')::uuid,'GR_DOC') is not null then raise exception 'GR_ORPHAN_OR_TENANT_LEAK';end if;
69
+ if public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'GR_DOC')::text like '%FOREIGN_SECRET%' then raise exception 'GR_FOREIGN_ID_COLLISION';end if;
70
+end $$;
71
+select set_config('request.jwt.claim.sub','ed000000-0000-4000-8000-000000000002',true);
72
+do $$begin
73
+ if public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'GR_DOC') is not null then raise exception 'GR_REVERSE_TENANT_LEAK';end if;
74
+ if public.finora_journal_read_graph(current_setting('wp1.graph_other')::uuid,'GR_DOC')::text not like '%FOREIGN_SECRET%' then raise exception 'GR_OTHER_OWN_GRAPH_MISSING';end if;
75
+end $$;
76
+select set_config('request.jwt.claim.sub','ed000000-0000-4000-8000-000000000003',true);
77
+do $$begin
78
+ if public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'GR_DOC')->>'effective_status'<>'reversed' then raise exception 'GR_READ_ONLY_ROLE_DENIED';end if;
79
+end $$;
80
+reset role;
81
+-- A hidden child/reversal must never yield a partial graph or false status.
82
+alter table public.records disable trigger user;
83
+update public.records set data=data||'{"confidentiality":"secret"}' where organization_id=current_setting('wp1.graph_org')::uuid and collection='journalLines' and id='GR_LINE_A';
84
+alter table public.records enable trigger user;
85
+set local role authenticated;
86
+do $$begin
87
+ begin perform public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'GR_DOC');raise exception 'GR_HIDDEN_CHILD_ACCEPTED';exception when insufficient_privilege then if sqlerrm<>'FINORA_JOURNAL_GRAPH_FORBIDDEN' then raise;end if;end;
88
+end $$;
89
+reset role;
90
+alter table public.records disable trigger user;
91
+update public.records set data=data-'confidentiality' where organization_id=current_setting('wp1.graph_org')::uuid and collection='journalLines' and id='GR_LINE_A';
92
+update public.records set data=data||'{"confidentiality":"secret"}' where organization_id=current_setting('wp1.graph_org')::uuid and collection='journalVouchers' and id='GR_PART1';
93
+alter table public.records enable trigger user;
94
+set local role authenticated;
95
+do $$begin
96
+ begin perform public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'GR_DOC');raise exception 'GR_HIDDEN_REVERSAL_ACCEPTED';exception when insufficient_privilege then if sqlerrm<>'FINORA_JOURNAL_GRAPH_FORBIDDEN' then raise;end if;end;
97
+end $$;
98
+reset role;
99
+update public.organization_members set status='suspended' where organization_id=current_setting('wp1.graph_org')::uuid and user_id='ed000000-0000-4000-8000-000000000003';
100
+set local role authenticated;
101
+do $$begin
102
+ if public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'GR_DOC') is not null then raise exception 'GR_REVOKED_MEMBER_VISIBLE';end if;
103
+end $$;
104
+reset role;
105
+select set_config('request.jwt.claim.sub','ed000000-0000-4000-8000-000000000001',true);
106
+-- Corruption rejection, still read-only; each fixture mutation rolled back.
107
+do $$declare kind text; dim_id text;begin
108
+ select id into dim_id from public.records where organization_id=current_setting('wp1.graph_org')::uuid and collection='journalLineDimensions' and data->>'voucherId'='GR_DOC';
109
+ foreach kind in array array['line_company','dimension_company','dimension_line','dimension_voucher'] loop
110
+ begin
111
+ alter table public.records disable trigger user;
112
+ if kind='line_company' then update public.records set data=data||'{"companyId":"WRONG"}' where organization_id=current_setting('wp1.graph_org')::uuid and collection='journalLines' and id='GR_LINE_A';
113
+ else update public.records set data=data||case kind when 'dimension_company' then '{"companyId":"WRONG"}'::jsonb when 'dimension_line' then '{"journalLineId":"MISSING"}'::jsonb else '{"voucherId":"WRONG"}'::jsonb end where organization_id=current_setting('wp1.graph_org')::uuid and collection='journalLineDimensions' and id=dim_id;end if;
114
+ alter table public.records enable trigger user;
115
+ set local role authenticated;
116
+ perform public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'GR_DOC');
117
+ raise exception 'GR_CORRUPTION_ACCEPTED_%',kind;
118
+ exception when check_violation then if sqlerrm<>'FINORA_JOURNAL_GRAPH_INVALID' then raise;end if;
119
+ end;
120
+ end loop;
121
+end $$;
122
+set local role anon;
123
+do $$begin
124
+ begin perform public.finora_journal_read_graph(current_setting('wp1.graph_org')::uuid,'GR_DOC');raise exception 'GR_ANON_ACCESS';exception when insufficient_privilege then null;end;
125
+end $$;
126
+reset role;
127
+do $$begin
128
+ if exists(select from pg_proc p where p.oid='public.finora_journal_read_graph(uuid,text)'::regprocedure and (p.prosecdef or p.provolatile<>'s')) then raise exception 'GR_INVOKER_CONTRACT';end if;
129
+ if has_function_privilege('anon','public.finora_journal_read_graph(uuid,text)','EXECUTE') or has_function_privilege('anon','private.finora_journal_graph_accessible(uuid,text)','EXECUTE') then raise exception 'GR_ANON_GRANT';end if;
130
+ raise notice 'WP1_GRAPH_PASS: complete deterministic graph,1003 rows,statuses,tenant/member/child/reversal/anon isolation,malformed links';
131
+end $$;
132
+rollback;