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
| 1 | begin; |
| 2 | |
| 3 | -- Preserve legacy role/membership checks. Only the new sandbox model requires |
| 4 | -- versioned consent and a creator-authorized, accepted second-guardian invite. |
| 5 | create or replace function is_active_guardian(p_family uuid, p_guardian uuid, p_minor uuid) returns boolean |
| 6 | language sql stable as $$ |
| 7 | select exists( |
| 8 | select 1 from guardian_relationship g |
| 9 | join family_workspace f on f.id=g.family_id and f.archived_at is null |
| 10 | join family_membership gm on gm.family_id=g.family_id and gm.user_id=g.guardian_user_id |
| 11 | and gm.ended_at is null and gm.role='parent_guardian' |
| 12 | join family_membership mm on mm.family_id=g.family_id and mm.user_id=g.minor_user_id |
| 13 | and mm.ended_at is null and mm.role='teen_minor' |
| 14 | join app_user gu on gu.id=gm.user_id and gu.disabled_at is null |
| 15 | join app_user cu on cu.id=mm.user_id and cu.disabled_at is null |
| 16 | where g.family_id=p_family and g.guardian_user_id=p_guardian |
| 17 | and g.minor_user_id=p_minor and g.active |
| 18 | and (not cu.is_managed_child or exists( |
| 19 | select 1 from managed_child mc |
| 20 | join child_consent cc on cc.child_user_id=mc.user_id and cc.revoked_at is null |
| 21 | and cc.actor_user_id=mc.creator_user_id |
| 22 | and cc.text_version='sandbox-child-consent-v1-not-legal' |
| 23 | and cc.text_digest='5dbf640a23b538800c82791620c3a43947b7346d7eff179e6f7d5afe5a55b387' |
| 24 | join profile gp on gp.user_id=g.guardian_user_id |
| 25 | and gp.birth_date<=(current_date-interval '18 years')::date |
| 26 | join profile cp on cp.user_id=mc.user_id |
| 27 | and cp.birth_date<=current_date and cp.birth_date>(current_date-interval '18 years')::date |
| 28 | where mc.user_id=g.minor_user_id and mc.family_id=g.family_id and not mm.is_admin |
| 29 | and (g.guardian_user_id=mc.creator_user_id or exists( |
| 30 | select 1 from guardian_invitation gi where gi.family_id=mc.family_id |
| 31 | and gi.child_user_id=mc.user_id and gi.issuer_user_id=mc.creator_user_id |
| 32 | and gi.guardian_user_id=g.guardian_user_id and gi.used_at is not null and gi.revoked_at is null |
| 33 | )) |
| 34 | )) |
| 35 | ) |
| 36 | $$; |
| 37 | commit; |