سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 22:00 UTC
perf(phase1a): index reversal parent and log seeded progress
davoodmehraban89 committed
Oct 17, 2026 at 02:25 UTC
c198a1b5c71e10fb1a3558d142f49516d8a5e23f
3 files changed
+13
PROJECT_STATE.md
+3
@@ -83,3 +83,6 @@
83
### 2026-10-17 — Stage 1 SQL test coverage extension (PENDING)
84
- Owner authorizes Stage1 only. Added two-Postgres-connection concurrent same-ID create (exactly one voucher and 2 lines), same-line 600+600 competing partial reversal (1000 original; only one winner), computed partial status, manual owner UPDATE/DELETE, and commerce-only denial of manual edit/delete/reverse. No Production changes.
85
- Deferred legacy JS positive-client contract is retained, now ordered AFTER server Stage1 checks, baseline parity and artifact upload to separately report known Stage2 RED without suppressing Stage1 evidence. Exact-SHA CI still required. Stop before Stage2.
86
+
87
+### 2026-10-17 — Stage 1 seeded performance tuning (PENDING CI)
88
+- Live exact SHA run 38977189304 had 20 successful steps but seeded 1000-event DO was still running >10 minutes; preceding run 38976093909 was cancelled at seeded (not PASS/FAIL). Added tenant-scoped partial index for posted reversal source lookup and NOTICE per 100 events to diagnose without reducing event coverage. No Production changes. Exact-SHA CI required.
supabase/migrations/20261016101500_phase1a_journal_core.sql
+7
@@ -19,6 +19,13 @@ WHERE collection='journalVouchers'
19
AND coalesce(data->>'sourceId','')<>''
20
AND data->>'sourceType'<>'reversal';
21
22
+-- Supporting tenant-scoped index for multiple partial reversals of one original.
23
+-- This changes no historical posted row, source uniqueness, or revocation rules.
24
+CREATE INDEX IF NOT EXISTS idx_finora_phase1a_reversal_source
25
+ ON public.records(organization_id,(data->>'sourceId'))
26
+ WHERE collection='journalVouchers' AND data->>'status'='posted'
27
+ AND data->>'sourceType'='reversal';
28
+
29
-- Historic vouchers remain unchanged. Covers original posted identifiers too,
30
-- so posting corrected data requires a NEW business source ID.
31
CREATE UNIQUE INDEX IF NOT EXISTS ux_finora_phase1a_active_source
supabase/tests/phase1a_stage1_seeded_1000.sql
+3
@@ -79,6 +79,9 @@ BEGIN
79
complete:=complete+1;
80
END IF;
81
END IF;
82
+ IF mod(i,100)=0 THEN
83
+ RAISE NOTICE 'FINORA_SEEDED_PROGRESS seed=% events=% full=% partial=%',seed,i,complete,partial;
84
+ END IF;
85
END LOOP;
86
IF posted<>1000 OR partial<1 OR complete<1 THEN RAISE EXCEPTION 'FINORA_SEEDED_COVERAGE_FAILED';END IF;
87
IF EXISTS(