Files
tobayahandClaude Opus 4.7 142400947a feat(db): add compass schema + RLS day 1 migration
Sprint 4 first production migration. New `compass` schema isolates the
multi-tenant data layer from the legacy Lovable `public.*` demo tables
so both can coexist until the demo is retired.

Tables (all with tenant_id + RLS enabled in the same file):
- compass.tenants / compass.users
- compass.contracts / compass.clauses (denormalized tenant_id for RLS perf)
- compass.audit_log + compass.task_events (append-only: SELECT+INSERT
  policies only, REVOKE UPDATE/DELETE as defense-in-depth)
- compass.jurisdictions (global reference, no RLS, GRANT SELECT)

Fail-closed posture: when middleware does not SET LOCAL app.tenant_id,
current_setting(..., true) returns NULL and policy filter evaluates
false, leaving rows invisible rather than open.

Audit report in docs/audits/2026-05-18_rls_day_one.md walks
compass-rls-auditor checklist + CLAUDE.md security invariants 9-pkt +
compass-architecture self-check 12-pkt. Verdict PASS with 5 non-blocking
follow-up notes (storage bucket policy, soft-delete filter,
jurisdictions Python sync, service_role runtime discipline, audit_log
writer Sprint 5).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 17:39:46 +02:00
..