LifeMate — Personal, Family & Learning Companion
fix/study-duration-display
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 | #!/usr/bin/env bash |
| 2 | # Fresh synthetic databases only; never targets the application DB for restore. |
| 3 | set -euo pipefail |
| 4 | cd "$(dirname "${BASH_SOURCE[0]}")/.." |
| 5 | [[ "${1:-}" == '--synthetic-only' ]] || { echo 'Use --synthetic-only explicitly' >&2; exit 1; } |
| 6 | if [[ -n "${DOCKER_CONTEXT:-}" ]]; then |
| 7 | endpoint="$(docker context inspect "$DOCKER_CONTEXT" --format '{{.Endpoints.docker.Host}}')" |
| 8 | else |
| 9 | endpoint="${DOCKER_HOST:-$(docker context inspect --format '{{.Endpoints.docker.Host}}')}" |
| 10 | fi |
| 11 | case "$endpoint" in unix://*|npipe://*) ;; *) echo 'Refusing remote Docker' >&2; exit 1;; esac |
| 12 | docker compose config --quiet |
| 13 | state_dir="$(mktemp -d "${TMPDIR:-/tmp}/lifeguide-role-test.XXXXXX")" |
| 14 | chmod 700 "$state_dir" |
| 15 | tool_args=(compose run --rm --no-deps --user "$(id -u):$(id -g)" -v "$state_dir:/role-test-state" -e ROLE_TEST_STATE_FILE=/role-test-state/state.json db-role-test) |
| 16 | dump_file='' |
| 17 | cleanup() { |
| 18 | cleanup_ok=yes |
| 19 | if [[ -f "$state_dir/state.json" ]]; then |
| 20 | if ! docker "${tool_args[@]}" node scripts/test-db-roles.js --cleanup; then |
| 21 | cleanup_ok=no |
| 22 | echo "UNVERIFIED: test database cleanup needs operator review; state preserved in $state_dir" >&2 |
| 23 | fi |
| 24 | fi |
| 25 | if [[ -n "$dump_file" ]]; then |
| 26 | docker compose run --rm --no-deps --entrypoint rm backup -f "$dump_file" >/dev/null 2>&1 || true |
| 27 | fi |
| 28 | if [[ "$cleanup_ok" == yes ]]; then rm -rf "$state_dir"; fi |
| 29 | } |
| 30 | trap cleanup EXIT |
| 31 | docker "${tool_args[@]}" |
| 32 | source_db="$(node -p 'JSON.parse(require("fs").readFileSync(process.argv[1],"utf8")).source_db' "$state_dir/state.json")" |
| 33 | target_db="$(node -p 'JSON.parse(require("fs").readFileSync(process.argv[1],"utf8")).target_db' "$state_dir/state.json")" |
| 34 | [[ "$source_db" =~ ^lifeguide_roles_source_[a-f0-9]{16}$ && "$target_db" =~ ^lifeguide_roles_target_[a-f0-9]{16}$ ]] || { echo 'Invalid synthetic database names' >&2; exit 1; } |
| 35 | dump_file="/backups/LifeGuide-role-test-${source_db#lifeguide_roles_source_}.dump" |
| 36 | docker compose run --rm --no-deps --entrypoint /opt/lifeguide/backup.sh \ |
| 37 | -e "DATABASE_URL=postgresql://lifeguide_backup@postgres:5432/$source_db" backup "$dump_file" |
| 38 | docker compose run --rm --no-deps --entrypoint pg_restore backup --list "$dump_file" >/dev/null |
| 39 | docker compose run --rm --no-deps -e "DATABASE_URL=postgresql://lifeguide_migrator@postgres:5432/$target_db" restore "$dump_file" |
| 40 | docker "${tool_args[@]}" node scripts/test-db-roles.js --verify-restored |
| 41 | echo 'PASS local least-privilege SQL + runtime family/learning HTTP scenarios + read-only dump/migrator restore; checksum ledger matches migration files' |