LifeMate — Personal, Family & Learning Companion

feat/flutter-mobile-navigation
chore/phase1-repository-cleanup deploy/stable-web-apk deployment-static design/mobile-accessibility-v2 design/mobile-navigation-review docs/child-education-access-decision docs/offline-data-rescue-options docs/owner-guide-and-delivery-plan docs/phase1-policy-options docs/public-review-live-2026-10-15 feat/aparat-learning-library feat/child-device-safety feat/child-identity-schema feat/flutter-mobile-navigation feat/learning-content-operations feat/local-signing-preflight feat/online-family-stage0 feat/personal-encrypted-recovery feat/private-planner-series-api feat/public-review-page feat/standalone-weekly-planner feat/weekly-planner-android final-feature-1/iran-family-school fix/auth-abuse-expiry-safety fix/auth-expiry-after-lock fix/backend-request-safety fix/lifeguide-bootstrap-naming-ci fix/lifeguide-pages-qa-base-preflight fix/lifeguide-qa-pages-env-deployment fix/local-task-persistence fix/managed-child-session-boundary fix/personal-jalali-dates fix/personal-notification-controls fix/personal-upgrade-delivery-guard fix/sms-approval-gates fix/study-duration-display infra/cloudflare-neon-migration infra/lifeguide-cloudflare-qa infra/lifeguide-github-pages-qa infra/lifeguide-supabase-qa main phase-1/foundation-completion phase-2/product-foundation-identity phase-3/planner-school-family-core phase-4/ai-learning-wellbeing phase-5/hardening-observability-release test/android-reminder-acceptance test/personal-notification-settings test/personal-recovery-acceptance test/role-entry-apk
md 67 lines 6.72 KB
Rendered Raw
1 # LifeGuide QA: Supabase PG17 private schema + family authorization receipt
2
3 Date: **2026-10-15**
4 Scope: **LifeGuide-QA only**, org **DM Studio**; no live user records or public application deployment.
5 Supabase project ref: `iqkrwxeprxvdiubdfcrb` (`ACTIVE_HEALTHY`, Frankfurt).
6 Existing unrelated `Finora ERP – Production`: verified separately still `ACTIVE_HEALTHY`; no writes.
7
8 ## What was actually applied
9
10 **Two additive, transaction-wrapped Supabase migrations**, preserving the original application SQL source semantics within a dedicated schema:
11 - Provider migration `20261014215436_lifeguide_qa_app_schema_0001_0010` (source: `supabase/migrations/202610150001_lifeguide_qa_app_schema_0001_0010.sql`).
12 - Provider migration `20261014215539_lifeguide_qa_app_schema_0011_0020` (source: `supabase/migrations/202610150002_lifeguide_qa_app_schema_0011_0020.sql`).
13 - Existing earlier `20261014210221_lifeguide_qa_isolated_connectivity_baseline` is unchanged.
14
15 Both application batches **succeeded** using Supabase `apply_migration`. They retain a `lifeguide_qa.schema_migration` ledger of **all 20 original LifeGuide SQL migration filenames with PostgreSQL pgcrypto SHA256 of the original source bytes**, not substituted QA SQL hashes. No original migration source was modified in place.
16
17 Compatibility adjustments confined to copies:
18 - Original `create extension if not exists pgcrypto` removed from the QA copy because Supabase already installs it globally in `extensions`.
19 - Only the **five** explicitly pinned school guard `SET search_path=public,pg_catalog` statements from migration 0019 were redirected to `lifeguide_qa,pg_catalog`. All other unqualified application DDL was executed with transaction-local search path `lifeguide_qa,extensions,pg_catalog`.
20 - **No** original Compose `provision-db-roles.js`, role ownership transfer, global Supabase Auth schema or public schema modification.
21 - After each batch: revoke all usage/DML/function access for `public`, `anon`, `authenticated`, `service_role` on private schema and app objects. Enable and force RLS on every application table; no client RLS policies are granted. The table schema is **inaccessible to client roles by design** until a reviewed authenticated server adapter exists.
22 - QA generator/script and synthetic checks in `backend/scripts/build-supabase-qa-sql.js`, `backend/tests/supabase_qa_bundle.test.js`. The committed two SQL manifests are the **exact applied provider source**; generator is for a new empty QA, not to re-apply to this live QA database.
23
24 ## Actual post-migration, read-only SQL verification
25
26 | Check | Value |
27 | --- | --- |
28 | Original migration ledger | **20** |
29 | Private `lifeguide_qa` ordinary tables | **59** (includes synthetic setup/ledger) |
30 | Private functions | **19** |
31 | Public application tables | **0** |
32 | Functions with unwanted explicit `public` search path | **0** |
33 | QA `SECURITY DEFINER` functions | **0** |
34 | All QA ordinary tables RLS enabled + forced | **true** |
35 | QA schema USAGE for `anon` | **false** |
36 | QA schema USAGE for `authenticated` | **false** |
37 | QA schema USAGE for `service_role` | **false** |
38 | Direct `anon` app_user SELECT | **false** |
39 | Direct `authenticated` family SELECT | **false** |
40 | Invalid source hash entries | **0** |
41
42 Supabase security advisor reports `INFO: rls_enabled_no_policy` on 59 tables. This is an **intentional fail-closed QA state** and not an unauthorized-access permission: no RLS policies are created and all schema USAGE is explicitly revoked. These tables cannot yet serve the application over the Supabase Data API. Reference: https://supabase.com/docs/guides/database/database-linter?lint=0008_rls_enabled_no_policy
43
44 ## Live SQL fixture: mother, father, child, outsider
45
46 Executed the actual SQL in Supabase project LifeGuide-QA via `execute_sql`, in a transaction that ended with **ROLLBACK**:
47 - 4 uniquely-generated synthetic test identities (mother, father, child, unrelated outsider); no real emails, phone numbers or OTPs.
48 - 1 family, two active guardian relations and child membership.
49 - A `parent_guardian` assignment and a `private` child task.
50 - One completed `study_session` with exactly **4 recorded seconds**.
51 - Verified `is_active_guardian`, `can_view_student_academic`, `can_view_plan_item` for both authorized parents, outsider, private item, and **revocation** of the father's active guardian relationship while preserving mother's access. Every assertion succeeded, otherwise the transaction would raise and fail.
52 - Source: `backend/tests/supabase_qa_guardian_acceptance.sql`. This exercises database predicates only; it is NOT HTTP/JWT/PWA proof.
53
54 After the rollback, an independent read confirmed **0** app users, **0** family workspaces, **0** plan items and **0** study sessions. No fixture or actual child/parent record persists in the QA database.
55
56 ## Remaining blockers (do not overclaim)
57
58 - Existing LifeGuide 0.7.1 **Node/Express + native Argon2 + custom JWT/session auth** is NOT deployed to Supabase Edge. A managed PostgreSQL DB is **not** a Node app server. The Express runtime needs a compatible free host or reviewed Edge adapter with authentication equivalence; do NOT silently substitute Supabase Auth for the existing identities.
59 - The forced RLS/no grant configuration is intentionally closed. An API deployment must first establish a dedicated least-privileged server role or demonstrably secure alternative, guard all family/guardian access on the server, and separately pass HTTP negative tests. Never put Postgres/password/service_role in Flutter, PWA or client-side code.
60 - No existing endpoint `https://app.lifeguide.ir/api` or Android APK has been switched to this QA database; no live DNS, reverse proxy, PWA install or iOS Safari run was changed/tested.
61 - Kavenegar template `lifeguideotp` was created by owner and remains **under provider review** per screenshots; dedicated Node SMS delivery adapter has passing synthetic tests in CI snapshot but no real provider call, credentials or SMS delivery.
62 - Iran without VPN, real SMS, confirmed template, full family end-to-end, independent backup/restore and permanent free-host operations **NOT VERIFIED**.
63 - The project is on Supabase Free, with provider quotas, idle auto-pause and no perpetual guaranteed availability. No billing card or paid service was used.
64
65 ## Next implementation gate
66
67 Build and validate an **independently hosted, existing Express-compatible HTTPS API** for QA, linked to managed PG with credentials only in the server's private secrets; preserve current session/JWT and family permission model. Prefer smallest reversible deployment and no DNS cutover until real iPhone Safari / Android acceptance. If that is infeasible without billing, research serverless adaptation as a separate explicit architecture decision rather than presenting the database migration as the finished online app.