سامانه صدور فاکتور و حسابداری
docs: record ADR216 destructive-history migration CI guard scope before work
davoodmehraban89 committed
Nov 22, 2026 at 12:39 UTC
2f5bb674494139b874d87504aabcb84deeb7764a
1 file changed
+6
PROJECT_STATE.md
+6
@@ -537,3 +537,9 @@ Next action: run and inspect Quality on the latest PR212 head. If any browser te
537
- **2026-11-22 pre-implementation integration refinement:** The first SELECT+isolated test candidate `717b0ebbf71fd76813e3bfb1724c567f3dcc950c` passed the real GitHub Quality step `Draft conversion inventory on isolated PostgreSQL` (Quality run 44992593097; full suite still running at this checkpoint). The existing operator CLI `scripts/draft-conversion-preflight.mjs` currently prints only journal aggregates and its scope text falsely says no source-only coverage. Complete this SAME narrow preflight task by adding a strictly allowlisted aggregate-only sourceIdentityAudit projection to that existing CLI, fail closed with exit=2 for absent/unsafe/problematic source-audit metrics (never mark cutover executable), and test those exits in the existing inventory test. Historical private snapshot compatibility: missing new source counts must be flagged as requiring a refreshed snapshot, not silently called ready. Do not introduce alternate auditor, product SQL migration, production connection, financial code or source data.
538
539
- **2026-11-22 safety review before acceptance:** A legitimately reversed sale/purchase source can have `documentStatus=accountingStatus='reversed'` even when its original historical journal voucher stays `status='posted'` (compensating reversal preserves the original). The new posted-source projection audit must accept this matched reversed pair rather than produce a false orphan/status incident. Revise only the aggregate `postedProjectionMismatches` predicate and add a synthetic reversed-source regression before accepting the final QA SHA; source/tombstone/posted history unchanged.
540
+
541
+### 2026-11-22 — FIN-ADR216-STOP-DESTRUCTIVE-MIGRATION (decision BEFORE implementation)
542
+- **Exact protected status:** `main` = `dab1a45fcfc4f12e675cfe055e477138cd3e99fa`; PR230 prior GREEN SHA `a7b74af8af063eb5ce496e1210ec1915db96e59c` Quality 44993182949, WP1 44993182887, Security 44993182850 all SUCCESS. PR230 and PR218 still Draft/unmerged; Issue216/229 OPEN. No Codex-main product patch since last verified checkpoint.
543
+- **Proven issue:** Existing Draft PR217 and PR219 new SQL migrations use `UPDATE public.records ... status='draft'/jsonb_build_object('status','draft')` on existing posted/reversed journal and transactional records without source-status exclusion, deleting posting metadata. Both PRs have RED CI and violate ADR0216. Preserve the immutable posted history regardless of QA green status.
544
+- **Next narrowly bounded implementation:** strengthen EXISTING Security workflow with a diff-scoped SQL history-downgrade tripwire for ADDED/MODIFIED `supabase/migrations/*.sql` files on PR base→head. Scan UPDATEs of persisted `public.records` that assign accounting lifecycle status/documentStatus/accountingStatus to `draft`; fail closed with filename/line and explanatory non-release instruction. Use shallow-insensitive checkout fetch-depth 0 and explicit PR base SHA; on push use previous SHA, and for manual dispatch fall back to HEAD parent. Test synthetic exact-shaped PR217/PR219 destructive UPDATEs and safe INSERT-only / unrelated UPDATE examples. This is an automated **heuristic guard** against one dangerous class, NOT proof every migration is non-destructive; manual code review and isolated historical parity tests remain required.
545
+- **Strict scope:** only existing `PROJECT_STATE.md`, Security workflow, a minimal reusable guard and focused tests (wire to existing Quality). Do not touch product JS, SQL migrations, RLS/Auth/role grants, posted history, hosted/prod data, owner-held modules, main, merge or deployment. Keep prior QA GREEN SHA recoverable and PR230 Draft. Verify exact new SHA Quality/WP1/Security; WP2 not claimed unless triggered.