سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 4, 11:45 UTC
feature/finora-phase1a-supabase-cli-20261016
Finora Phase 1A — Read-only preflight and approval stop
Date: 2026-10-16. Repository: davoodmehraban89/Factor-easy; inspected protected main SHA bccd474433b4188e43aae345773498ea6fc65209. Production ref: hcsixhqbyuhpshfwqpjx. All production queries were read-only catalog or aggregate SELECT. NO Production DDL/DML and NO phase-1 migration written.
Condition 3: mandatory schema/source parity
- Repo migration files: 81; Production recorded migrations: 82.
- Strict filename/version set comparison: 25 Production migration IDs absent from repo, 24 repo filenames absent from Production migration history. Most are timestamp-renumbered request/workflow/identity migrations, which alone do not prove divergent resulting DDL. Full manifest must be mapped by content before change.
- Confirmed material drift: Production migration
20261007165208_phone_identity_profilehas no tracked counterpart, and livepublic.profiles.phoneexists. Latest repo20261012080000_fix_identity_bootstrap_license_before_membership.sqlreferencesprofiles.phoneandauth.users.phone, so replaying the repo cannot be assumed to reproduce the live identity schema. - Further unmatched repo-only versions include
20260929222000_iran_enterprise_foundation_collections.sql,20260930222500_iran_enterprise_control_collections.sql, and20260930223000_iran_enterprise_financial_controls.sql; their resulting DDL has NOT yet been compared against every live object. - CI baseline
.github/workflows/quality.ymlruns three synthetic PostgreSQL 17 services using partial fixture/setup SQL, not a full Supabase CLI stack. Therefore no legitimate claim of whole-schema equality or RLS/security-definer behavior from existing CI; full object-by-object comparison of tables, functions, triggers, policies, grants and signatures against a Supabase CLI schema clone is NOT VERIFIED. - Live subset inspected:
recordshas organization-scoped PK(organization_id,collection,id); twofinora_sync_recordssignatures (jsonb,jsonb) and (jsonb,jsonb,uuid);records.versionandfinora_post_eventabsent (these are planned capabilities, not baseline drift);recordsRLS enabled and 4 policies; posted journal triggers run BEFORE UPDATE/DELETE only. Relevant catalog definitions reviewed read-only.
Gate: MATERIAL SCHEMA DRIFT PRESENT. STOP before writing migrations. First reconcile production-only phone schema and migration identity mapping and create a complete isolated Supabase CLI reconstruction + reproducible schema diff, without modifying Production.
Condition 4: bypass via sync / JSONB journal fields
- Client
js/sync.jsdiff/push passes entiredataJSONB objects tosb.rpc('finora_sync_records', {p_upserts, p_deletes}), with no version token, no server-only field filter;pullAll()fetchescollection,id,dataonly.js/journal-engine.jssetsjournalVouchers.status,number,postedAt,postedByon the browser. - Both live
finora_sync_recordsfunctions upsert full JSONBdata, with no rejection of status/number/postedAt fields, andSECURITY INVOKERRLS does not implement field-level restrictions. Authorized write-capable users can attempt to post adraftjournal or create one withstatus='posted'directly. Parent posted guard examinesOLD.status, so draft->posted is not rejected on balance, and INSERT is not intercepted. Parent journal children guard similarly protects UPDATE/DELETE only. This is an architecture-level bypass, not a production mutation test. - Live
recordsPK is organization-scoped, but legacy two-argument syncON CONFLICT(owner_id,collection,id)no longer matches any matching unique key in the inspectedrecordsindexes. Three-argument sync uses the current org PK. The browser sends only two named arguments, while the 3-arg overload has a default for organization; live dispatch/compatibility requires isolated end-to-end verification, not a promise of success. - Live
anontable grants may include INSERT, but RLS only allowsauthenticatedpolicies: grants alone do NOT establish anonymous insert. - Status/number security must be enforced in server context for all write routes including direct PostgREST table insert/update, both existing sync signatures, and future authorized RPC, while supporting explicit planned transition/legacy usage. Test write attempts with real local
anon/authenticated/service_role, tenant A/B, RLS, and trigger context before release. - Production journal inventory was read-only checked separately: 9 posted/reversed documents, 18 journal lines, no detected orphan lines; none of 9 inspected posted/reversed documents were unbalanced or had fewer than two lines. This is a limited snapshot, NOT runtime security proof.
Next action requiring owner approval
Accept this preflight as BLOCKED / NOT COMPLETE and explicitly authorize read-only migration-history reconciliation and isolated Supabase CLI schema reconstruction/diff before implementation of 1A. No Production DDL/DML, no credentials copied to GitHub, no Phase 1B, no migration files until these discrepancies are closed. Then resubmit the complete parity report and await owner's next gate.