@davoodmehraban89 / LifeMate / commits / d5e7965
Fork 0

LifeMate — Personal, Family & Learning Companion

docs: define LifeGuide hosting, naming and verified Stage 0 gates

Codex committed Oct 8, 2026 at 15:39 UTC d5e79655816d365c868a20996765f44c26790034
44 files changed +928 -277
.github/workflows/ci.yml
+54 -83
@@ -1,114 +1,85 @@
1 -name: LifeMate CI
2 -
1 +name: LifeGuide CI
2 on:
3 push:
5 - branches: [main]
4 + branches: [main, 'feat/online-family-stage0']
5 pull_request:
7 -
6 + workflow_dispatch:
7 permissions:
8 contents: read
10 -
9 +concurrency:
10 + group: lifeguide-ci-${{ github.ref }}
11 + cancel-in-progress: true
12 jobs:
13 security:
14 runs-on: ubuntu-latest
15 steps:
16 - uses: actions/checkout@v4
16 - - name: Reject committed environment files
17 + - name: Reject tracked credentials and private artifacts
18 run: |
18 - bad_files=$(find . -type f \( -name '.env' -o -name '.env.*' \) ! -name '.env.example' ! -path './.git/*')
19 - if [ -n "$bad_files" ]; then echo "Committed environment files detected:"; echo "$bad_files"; exit 1; fi
20 - - name: Scan high-confidence secret patterns
21 - run: |
22 - if git grep -I -n -E '(-----BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY-----|AKIA[0-9A-Z]{16}|gh[pousr]_[A-Za-z0-9_]{30,}|sk_live_[A-Za-z0-9]{20,})' -- .; then echo "Potential committed secret detected."; exit 1; fi
23 -
24 - flutter:
25 - runs-on: ubuntu-latest
26 - defaults:
27 - run:
28 - working-directory: apps/lifemate
29 - steps:
30 - - uses: actions/checkout@v4
31 - - uses: subosito/flutter-action@v2
32 - with:
33 - channel: stable
34 - cache: true
35 - - run: flutter pub get
36 - - run: dart format lib test
37 - - run: flutter analyze
38 - - run: flutter test
39 - - name: Verify PWA release metadata
40 - run: |
41 - grep -q 'manifest.json' web/index.html
42 - grep -q 'theme-color' web/index.html
43 - grep -q 'apple-touch-icon' web/index.html
44 - grep -q 'dir="rtl"' web/index.html
45 - test -f web/manifest.json
46 - - run: flutter build web --release
47 - - run: flutter build apk --release
48 - - name: Upload Web release
49 - uses: actions/upload-artifact@v4
50 - with:
51 - name: lifemate-web-release
52 - path: apps/lifemate/build/web
53 - if-no-files-found: error
54 - - name: Upload Android APK
55 - uses: actions/upload-artifact@v4
56 - with:
57 - name: lifemate-android-apk
58 - path: apps/lifemate/build/app/outputs/flutter-apk/app-release.apk
59 - if-no-files-found: error
60 -
19 + python3 scripts/check-tracked-secrets.py
20 + - name: Audit product naming
21 + run: python3 scripts/audit-naming.py --check
22 backend:
23 runs-on: ubuntu-latest
24 services:
25 postgres:
26 image: postgres:16
27 env:
67 - POSTGRES_PASSWORD: lifemate_ci
28 + POSTGRES_PASSWORD: synthetic_ci_only
29 POSTGRES_DB: lifemate_ci
30 ports: ['5432:5432']
31 options: >-
71 - --health-cmd "pg_isready -U postgres -d lifemate_ci"
32 + --health-cmd 'pg_isready -U postgres -d lifemate_ci'
33 --health-interval 5s --health-timeout 5s --health-retries 10
34 env:
74 - PGPASSWORD: lifemate_ci
75 - DATABASE_URL: postgresql://postgres:lifemate_ci@localhost:5432/lifemate_ci
76 - JWT_SECRET: ci-only-secret-ci-only-secret-ci-only-secret
35 + PGPASSWORD: synthetic_ci_only
36 + DATABASE_URL: postgresql://postgres:synthetic_ci_only@localhost:5432/lifemate_ci
37 + JWT_SECRET: synthetic-ci-only-not-a-live-secret-2026
38 NODE_ENV: test
39 steps:
40 - uses: actions/checkout@v4
41 - uses: actions/setup-node@v4
81 - with:
82 - node-version: 22
83 - - name: Apply migrations
84 - run: |
85 - for migration in backend/migrations/*.sql; do echo "Applying $migration"; psql -h localhost -U postgres -d lifemate_ci -v ON_ERROR_STOP=1 -f "$migration"; done
86 - - name: Database authorization tests
87 - run: |
88 - psql -h localhost -U postgres -d lifemate_ci -v ON_ERROR_STOP=1 -f backend/tests/schema_test.sql
89 - psql -h localhost -U postgres -d lifemate_ci -v ON_ERROR_STOP=1 -f backend/tests/phase3_schema_test.sql
90 - if [ -f backend/tests/phase4_schema_test.sql ]; then psql -h localhost -U postgres -d lifemate_ci -v ON_ERROR_STOP=1 -f backend/tests/phase4_schema_test.sql; fi
91 - if [ -f backend/tests/phase6_schema_test.sql ]; then psql -h localhost -U postgres -d lifemate_ci -v ON_ERROR_STOP=1 -f backend/tests/phase6_schema_test.sql; fi
92 - - name: Install backend
42 + with: {node-version: 22, cache: npm, cache-dependency-path: backend/package-lock.json}
43 + - run: npm ci
44 working-directory: backend
94 - run: npm install
95 - - name: Backend dependency audit
45 + - name: Apply migrations and verify repeat run
46 working-directory: backend
97 - run: npm audit --audit-level=high
98 - - name: Backend tests
99 - working-directory: backend
100 - run: npm test
101 - - name: Backend syntax checks
47 + run: npm run migrate && npm run migrate
48 + - name: SQL authorization matrix
49 + run: |
50 + for test in backend/tests/*schema_test.sql; do psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -f "$test"; done
51 + - run: npm test && npm run check && npm audit --audit-level=high
52 working-directory: backend
103 - run: npm run check
104 - - name: Verify schema objects
53 + - name: Backup and restore synthetic database
54 run: |
106 - test "$(psql -h localhost -U postgres -d lifemate_ci -Atc "select count(*) from information_schema.tables where table_schema='public' and table_name in ('app_user','profile','family_workspace','family_membership','guardian_relationship','family_invitation','access_audit','auth_credential','auth_token','auth_session','life_context','academic_year','academic_term','subject','class_session','plan_item','sharing_grant','reminder','notification_preference','notification_outbox','sync_mutation','learning_goal','learning_checkin','wellbeing_checkin','ai_guide_session','ai_guide_message','ai_plan_proposal','wellbeing_safety_event','education_profile','curriculum_subject','textbook_catalog','iran_calendar_event','menstrual_cycle_entry');")" = "33"
107 - - name: Backup and restore drill
55 + backend/scripts/backup.sh /tmp/lifeguide-ci.dump
56 + createdb -h localhost -U postgres lifeguide_restore
57 + DATABASE_URL=postgresql://postgres:synthetic_ci_only@localhost:5432/lifeguide_restore backend/scripts/restore.sh /tmp/lifeguide-ci.dump
58 + test "$(psql -h localhost -U postgres -d lifeguide_restore -Atc 'select count(*) from schema_migration')" = "$(psql "$DATABASE_URL" -Atc 'select count(*) from schema_migration')"
59 + flutter:
60 + runs-on: ubuntu-latest
61 + defaults:
62 + run: {working-directory: apps/lifemate}
63 + steps:
64 + - uses: actions/checkout@v4
65 + - uses: actions/setup-node@v4
66 + with: {node-version: 22}
67 + - uses: subosito/flutter-action@v2
68 + with: {flutter-version: '3.47.6', channel: stable, cache: true}
69 + - run: flutter pub get
70 + - run: dart format --output=none --set-exit-if-changed lib test
71 + - run: flutter analyze
72 + - run: flutter test
73 + - run: node tool/test_web_bootstrap.mjs
74 + - run: flutter build web --release --no-web-resources-cdn --pwa-strategy=none
75 + - run: node tool/test_web_bootstrap.mjs
76 + - name: Bundle local resources and reject external runtime services
77 + run: node tool/self_host_web.mjs build/web
78 + - name: Build test APK (debug certificate; not a release)
79 run: |
109 - psql -h localhost -U postgres -d lifemate_ci -v ON_ERROR_STOP=1 -f backend/scripts/restore-smoke.sql
110 - chmod +x backend/scripts/backup.sh backend/scripts/restore.sh
111 - backend/scripts/backup.sh /tmp/lifemate-ci.dump
112 - createdb -h localhost -U postgres lifemate_restore
113 - DATABASE_URL=postgresql://postgres:lifemate_ci@localhost:5432/lifemate_restore backend/scripts/restore.sh /tmp/lifemate-ci.dump
114 - test "$(psql -h localhost -U postgres -d lifemate_restore -Atc "select count(*) from profile where display_name='Restore Smoke';")" = "1"
80 + flutter build apk --debug
81 + cp build/app/outputs/flutter-apk/app-debug.apk build/LifeGuide-debug.apk
82 + - uses: actions/upload-artifact@v4
83 + with: {name: LifeGuide-web, path: apps/lifemate/build/web, if-no-files-found: error}
84 + - uses: actions/upload-artifact@v4
85 + with: {name: LifeGuide-debug-apk, path: apps/lifemate/build/LifeGuide-debug.apk, if-no-files-found: error}
.github/workflows/deploy.yml new
+40
@@ -0,0 +1,40 @@
1 +name: LifeGuide operator deploy (DISABLED by default)
2 +on:
3 + workflow_dispatch:
4 + inputs:
5 + confirm:
6 + description: 'Explicit owner approval for this live change: type APPROVE_LIVE_DEPLOY'
7 + required: true
8 + type: string
9 +permissions: {contents: read}
10 +concurrency: {group: lifeguide-operator-deploy, cancel-in-progress: false}
11 +jobs:
12 + deploy:
13 + if: vars.LIFEGUIDE_DEPLOY_ENABLED == 'true' && inputs.confirm == 'APPROVE_LIVE_DEPLOY'
14 + environment: owner-approved-server
15 + runs-on: ubuntu-latest
16 + steps:
17 + - uses: actions/checkout@v4
18 + - name: Deploy reviewed commit to operator-configured server
19 + env:
20 + DEPLOY_HOST: ${{ secrets.LIFEGUIDE_DEPLOY_HOST }}
21 + DEPLOY_USER: ${{ secrets.LIFEGUIDE_DEPLOY_USER }}
22 + DEPLOY_KEY: ${{ secrets.LIFEGUIDE_DEPLOY_KEY }}
23 + KNOWN_HOSTS: ${{ secrets.LIFEGUIDE_DEPLOY_KNOWN_HOSTS }}
24 + run: |
25 + set -euo pipefail
26 + [[ "$DEPLOY_HOST" =~ ^[a-zA-Z0-9.-]+$ ]]
27 + [[ "$DEPLOY_USER" =~ ^[a-zA-Z0-9_-]+$ ]]
28 + umask 077
29 + mkdir -p "$RUNNER_TEMP/lifeguide-ssh"
30 + printf '%s\n' "$DEPLOY_KEY" > "$RUNNER_TEMP/lifeguide-ssh/key"
31 + printf '%s\n' "$KNOWN_HOSTS" > "$RUNNER_TEMP/lifeguide-ssh/known_hosts"
32 + ssh_args=(-i "$RUNNER_TEMP/lifeguide-ssh/key" -o BatchMode=yes -o StrictHostKeyChecking=yes -o "UserKnownHostsFile=$RUNNER_TEMP/lifeguide-ssh/known_hosts")
33 + target="$DEPLOY_USER@$DEPLOY_HOST"
34 + release="/opt/lifeguide/releases/$GITHUB_SHA"
35 + ssh "${ssh_args[@]}" "$target" "test -f /opt/lifeguide/shared/.env && mkdir -p '$release'"
36 + git archive HEAD | ssh "${ssh_args[@]}" "$target" "tar -x -C '$release'"
37 + ssh "${ssh_args[@]}" "$target" "cd '$release' && ln -sfn /opt/lifeguide/shared/.env .env && ln -sfn /opt/lifeguide/shared/runtime-config.json deployment/runtime-config.json && rm -rf deployment/downloads && ln -s /opt/lifeguide/shared/downloads deployment/downloads && bash scripts/local-deploy.sh && ln -sfn '$release' /opt/lifeguide/current"
38 + - name: Remove deployment credentials
39 + if: always()
40 + run: rm -rf "$RUNNER_TEMP/lifeguide-ssh"
.github/workflows/fix-unused.yml deleted
-19
@@ -1,19 +0,0 @@
1 -name: Fix Final Unused
2 -on:
3 - push:
4 - branches: ['final-feature-1/iran-family-school']
5 -permissions:
6 - contents: write
7 -jobs:
8 - fix:
9 - runs-on: ubuntu-latest
10 - steps:
11 - - uses: actions/checkout@v4
12 - with: {ref: final-feature-1/iran-family-school}
13 - - run: |
14 - python - <<'PY'
15 - from pathlib import Path
16 - p=Path('apps/lifemate/lib/iran_hub.dart');s=p.read_text().replace("final profile=s.data![0],prefs=s.data![3];","final prefs=s.data![3];");p.write_text(s)
17 - PY
18 - if git diff --quiet; then exit 0; fi
19 - git config user.name 'github-actions[bot]'; git config user.email '41898282+github-actions[bot]@users.noreply.github.com'; git add apps/lifemate/lib/iran_hub.dart; git commit -m 'fix: remove unused profile local'; git push origin HEAD:final-feature-1/iran-family-school
.github/workflows/publish-static.yml deleted
-68
@@ -1,68 +0,0 @@
1 -name: Publish static PWA and APK
2 -
3 -on:
4 - push:
5 - branches: [main]
6 - workflow_dispatch:
7 -
8 -permissions:
9 - contents: write
10 -
11 -jobs:
12 - publish:
13 - runs-on: ubuntu-latest
14 - defaults:
15 - run:
16 - working-directory: apps/lifemate
17 - steps:
18 - - uses: actions/checkout@v4
19 -
20 - - uses: subosito/flutter-action@v2
21 - with:
22 - channel: stable
23 - cache: true
24 -
25 - - run: flutter pub get
26 -
27 - - name: Build PWA against staging API
28 - run: >
29 - flutter build web --release
30 - --dart-define=LIFEMATE_API_URL=https://lifemate-api-fn-staging.up.railway.app
31 -
32 - - name: Build Android APK against staging API
33 - run: >
34 - flutter build apk --release
35 - --dart-define=LIFEMATE_API_URL=https://lifemate-api-fn-staging.up.railway.app
36 -
37 - - name: Publish stable APK release
38 - env:
39 - GH_TOKEN: ${{ github.token }}
40 - run: |
41 - TAG=feature1-test
42 - git tag -f "$TAG" "$GITHUB_SHA"
43 - git push origin "refs/tags/$TAG" --force
44 - gh release view "$TAG" >/dev/null 2>&1 || \
45 - gh release create "$TAG" \
46 - --title "LifeMate Feature 1 Test" \
47 - --notes "Latest installable Android test build connected to the LifeMate staging API." \
48 - --prerelease \
49 - --target "$GITHUB_SHA"
50 - gh release upload "$TAG" \
51 - build/app/outputs/flutter-apk/app-release.apk#LifeMate.apk \
52 - --clobber
53 -
54 - - name: Prepare static release directory
55 - run: |
56 - rm -rf ../../public-release
57 - mkdir -p ../../public-release
58 - cp -R build/web/. ../../public-release/
59 - touch ../../public-release/.nojekyll
60 -
61 - - name: Publish immutable static branch
62 - uses: peaceiris/actions-gh-pages@v4
63 - with:
64 - github_token: ${{ secrets.GITHUB_TOKEN }}
65 - publish_branch: deployment-static
66 - publish_dir: ./public-release
67 - force_orphan: true
68 - commit_message: "publish: LifeMate PWA and APK ${{ github.sha }}"
.github/workflows/release-build.yml new
+43
@@ -0,0 +1,43 @@
1 +name: LifeGuide signed APK (manual; disabled by default)
2 +on:
3 + workflow_dispatch:
4 + inputs:
5 + confirm:
6 + description: 'Owner approval: type BUILD_SIGNED_TEST_ARTIFACT'
7 + required: true
8 + type: string
9 +permissions: {contents: read}
10 +jobs:
11 + signed-apk:
12 + if: vars.LIFEGUIDE_RELEASE_SIGNING_CONFIGURED == 'true' && inputs.confirm == 'BUILD_SIGNED_TEST_ARTIFACT'
13 + environment: release-signing
14 + runs-on: ubuntu-latest
15 + defaults:
16 + run: {working-directory: apps/lifemate}
17 + steps:
18 + - uses: actions/checkout@v4
19 + - uses: subosito/flutter-action@v2
20 + with: {flutter-version: '3.47.6', channel: stable, cache: true}
21 + - name: Prepare owner key outside repository
22 + env:
23 + KEYSTORE_BASE64: ${{ secrets.LIFEGUIDE_KEYSTORE_BASE64 }}
24 + run: |
25 + umask 077
26 + test -n "$KEYSTORE_BASE64"
27 + printf '%s' "$KEYSTORE_BASE64" | base64 --decode > "$RUNNER_TEMP/lifeguide-release.jks"
28 + - name: Build genuinely signed release artifact
29 + env:
30 + LIFEGUIDE_KEYSTORE_PATH: ${{ runner.temp }}/lifeguide-release.jks
31 + LIFEGUIDE_KEYSTORE_PASSWORD: ${{ secrets.LIFEGUIDE_KEYSTORE_PASSWORD }}
32 + LIFEGUIDE_KEY_ALIAS: ${{ secrets.LIFEGUIDE_KEY_ALIAS }}
33 + LIFEGUIDE_KEY_PASSWORD: ${{ secrets.LIFEGUIDE_KEY_PASSWORD }}
34 + run: |
35 + flutter pub get
36 + flutter test
37 + flutter build apk --release
38 + cp build/app/outputs/flutter-apk/app-release.apk build/LifeGuide.apk
39 + - uses: actions/upload-artifact@v4
40 + with: {name: LifeGuide-signed-apk, path: apps/lifemate/build/LifeGuide.apk, if-no-files-found: error}
41 + - name: Remove private key
42 + if: always()
43 + run: rm -f "$RUNNER_TEMP/lifeguide-release.jks"
AGENTS.md
+2 -2
@@ -1,7 +1,7 @@
1 -# LifeMate — Operating Rules
1 +# LifeGuide — Operating Rules
2
3 ## Mission
4 -Build LifeMate as a maintainable, secure, attractive personal/family/learning companion. The product starts with a teen-and-family use case but must not be hard-coded to one family, one age, or one school year.
4 +Build LifeGuide as a maintainable, secure, attractive personal/family/learning companion. The product starts with a teen-and-family use case but must not be hard-coded to one family, one age, or one school year.
5
6 ## Coordination model
7 The coordinating project lead owns prioritization, dependencies, integration, conflict resolution, and final delivery. Five specialist ownership areas are active:
CHANGELOG.md
+21 -12
@@ -1,12 +1,21 @@
1 -# Changelog
2 -
3 -## 0.3.0 — Phase 5 candidate
4 -- Added production-entrypoint request correlation, privacy-safe structured HTTP telemetry and security headers.
5 -- Added configurable general/auth/AI rate limiting with `Retry-After` responses.
6 -- Added separate liveness and database-readiness probes.
7 -- Added PostgreSQL backup/restore scripts and automated CI restore drill.
8 -- Strengthened PWA RTL/iOS install metadata and release checks.
9 -- Added deployment, rollback, backup/restore, incident-response and production-readiness runbooks.
10 -
11 -## 0.2.0 — Phase 4
12 -- Added learning goals/check-ins, wellbeing check-ins, advisory AI guides, explicit plan proposals, guardian summaries and privacy-preserving family guidance.
1 +# LifeGuide Changelog
2 +
3 +## 0.5.0 — 2026-10-08 — online Stage 0 candidate
4 +
5 +- Rebrand product as LifeGuide / لایف‌گاید; preserve repository, schema and JWT protocol identifiers.
6 +- Reuse main identity/family/planner/Feature 1 instead of replacing it with the login-free local test API.
7 +- Add provider-neutral Docker Compose PostgreSQL/API/TLS/PWA package, backup cron, local deployment, reachability and synthetic restore/migration runbooks.
8 +- Add email delivery failure recovery, generic registration response, rate-limited verification resend, optional email/phone OTP provider boundary and ownership/password proof.
9 +- Harden active memberships, guardian privacy, invitation reuse and disabled external AI/voice/sensitive data gates.
10 +- Add real study sessions with pause/resume, versioned/idempotent events, overlap protection and authorized reports; recorded time is not evidence of study.
11 +- Add runtime endpoint configuration, scoped session/cache/queue, server acknowledgements, optimistic versions and visible conflicts.
12 +- Set Android ID ir.lifeguide.app; require real owner release signing; remove automatic public publishing and unused fix workflow.
13 +- Real-device/Safari, reachability from Iran, live provider delivery and official signed release remain UNVERIFIED. See PROJECT_STATE.md for actual execution evidence.
14 +
15 +## 0.3.0 — historical Phase 5 candidate
16 +
17 +Added operational headers/rate limits/probes, PostgreSQL backup/restore scripts, CI and release runbooks. Historical CI/hosting results do not prove current online acceptance.
18 +
19 +## 0.2.0 — historical Phase 4
20 +
21 +Added goals/check-ins, advisory guides, proposals and guardian summaries. Sensitive features in the current candidate are disabled pending consent/legal/in-country gates.
PROJECT_STATE.md
+40 -63
@@ -1,63 +1,40 @@
1 -# LifeMate — Project State
2 -
3 -**Last updated:** 2026-10-05
4 -**Phase:** Phase 5 — Hardening, Observability & Release — COMPLETE
5 -**Repository:** `davoodmehraban89/LifeMate`
6 -**Working product name:** LifeMate — approved
7 -
8 -## Transfer checkpoint
9 -Phases 1–5 engineering core are complete. LifeMate now has the foundation/identity, planner-school-family core, advisory learning/wellbeing guides, and the operational hardening/release-readiness layer required for a controlled beta. Public production release and minor-sensitive external AI/voice exposure remain intentionally gated and require separate explicit approval.
10 -
11 -## Five-phase roadmap
12 -1. **Foundation, Product Contract & UX Direction** — COMPLETE
13 -2. **Product Foundation & Identity** — COMPLETE
14 -3. **Planner, School & Family Core** — COMPLETE
15 -4. **AI Guides, Learning & Wellbeing** — COMPLETE
16 -5. **Hardening, Observability & Release** — COMPLETE
17 -
18 -## Accepted architecture baseline
19 -- Flutter Android + responsive Web/PWA; future packaged/native iOS path preserved.
20 -- Provider-neutral Node API + PostgreSQL; Railway remains staging host.
21 -- LifeMate-owned identity/session adapter; server-side relationship-aware authorization.
22 -- Offline client support does not replace server authority.
23 -- AI guides are advisory and plan proposals require explicit acceptance.
24 -- Wellbeing/AI transcripts remain owner-private; family membership does not grant transcript access.
25 -
26 -## Phase 4 completed vertical slice
27 -Learning goal → learning check-in → wellbeing check-in → AI guide session → safety classification → advisory response → explicit plan proposal → accept/reject decision. No guide response silently mutates planner state.
28 -
29 -### Verified Phase 4 gates
30 -- Migration `0004_ai_learning_wellbeing.sql` defines seven Phase 4 tables, including the separate `wellbeing_safety_event` ledger, and owner-oriented indexes.
31 -- Phase 4 API implements learning goals/check-ins, private/guardian-summary wellbeing check-ins, AI sessions/messages, explicit proposal decisions, guardian wellbeing summaries and privacy-preserving family guidance.
32 -- High-risk self-harm language follows a fixed urgent-support path and writes a separate safety signal; ordinary family membership never grants raw wellbeing notes or AI transcripts.
33 -- Study/planner/wellbeing guidance is advisory, non-diagnostic and never silently mutates planner data.
34 -- Flutter includes interactive guide chat, learning goals/check-ins, wellbeing check-ins, guardian summary and parent family-guidance flows.
35 -- ADR `docs/decisions/0004-ai-learning-wellbeing-safety.md` records privacy, provider, voice and production safety gates.
36 -
37 -## Phase 5 completed scope
38 -- Production-entrypoint request correlation, security headers, privacy-safe structured request/error telemetry and bounded request bodies.
39 -- Configurable general/auth/AI fixed-window rate limits with HTTP 429 and `Retry-After`.
40 -- Separate `/live` and database-backed `/ready` operational probes while retaining `/health` compatibility.
41 -- PostgreSQL-native backup/restore scripts plus an automated CI data round-trip restore drill.
42 -- Release regression gates for backend tests/syntax/audit/schema, secret scanning, Flutter format/analyze/tests, Web release build, Android build and PWA install/RTL metadata.
43 -- Deployment, rollback, backup/restore, incident-response and production-readiness runbooks plus changelog/version discipline.
44 -- Railway staging API function hardened with request IDs, security headers, rate limiting, `/live`, `/ready` and privacy-safe error handling; staging tracing and auto-instrumentation enabled.
45 -
46 -### Verified Phase 5 gates
47 -- Red-first operations contract was observed failing before the hardening implementation; subsequent backend contract/integration tests passed.
48 -- GitHub Actions run 165 at branch commit `125c44f55827dc5ed26d81fe821969348db4598e` completed successfully: security, backend and Flutter jobs all green.
49 -- Backend run 165 passed migrations, authorization tests, dependency audit, 11 Node tests, syntax checks, 28-table schema verification and the backup/restore data round-trip drill.
50 -- Flutter run 165 passed formatting, analysis, widget/tests, PWA release metadata checks, Web release build and Android debug build.
51 -- Railway staging deployment `0cd21bed-5cba-494b-afef-7f45312f2fdf` is SUCCESS/online with no reported warnings or critical issues after Phase 5 hardening.
52 -- Railway staging source inspection confirms the operational middleware and `/live` + `/ready` routes are deployed; external AI/voice remain unenabled and Phase 4 AI continues in local-fallback mode.
53 -
54 -## Production-gate items intentionally deferred
55 -Jurisdiction-specific legal/guardian consent review; final safety severity taxonomy; emergency resource localization; external AI provider privacy/retention review; wellbeing retention/export/deletion policy; voice-provider privacy review; production push-provider configuration; final device beta acceptance. These are release gates, not missing Phase 5 engineering-core work.
56 -
57 -## Release status
58 -Engineering phases 1–5: COMPLETE.
59 -Controlled family beta: READY FOR OWNER-APPROVED DEVICE TESTING.
60 -Public production deployment/release: NOT PERFORMED.
61 -
62 -## Guardrail
63 -AI/wellbeing production exposure stays disabled until dedicated safety/legal/provider gates pass. Production deploys, destructive migrations, public release and sensitive access changes require explicit action-specific approval.
1 +# LifeGuide / لایف‌گاید — وضعیت واقعی پروژه
2 +
3 +Updated: 2026-10-08. Backend version: **0.5.0**. Branch: **feat/online-family-stage0**, based on main `abdc9d9d032bc6746c8390b902a2e52d82991530`. Repository remains `davoodmehraban89/LifeMate`.
4 +
5 +**Status: online Stage 0 candidate, integration in progress. Not a complete operational product or public release.** Prior COMPLETE/READY claims are retained only in [historical checkpoint](docs/history/2026-10-05-project-state.md); they do not prove this candidate's acceptance.
6 +
7 +## Baseline and reuse
8 +
9 +[Main gap analysis](docs/audits/2026-10-08-online-gap-analysis.md) was written before new implementation. GitHub refs verified: local persistence `62e82ba`, backend safety `e5e3e41`, Cloudflare/Neon `7a83ca8`; only isolated backend safety commit reused. Login-free LocalOnlyApi and managed-host adapters were not merged into the online product. Main already contains family/guardian identity, planner/offline queue, authorization tests and **Feature 1** Iranian education/catalog/calendar/preferences; these are preserved. Feature 1 household persona is a preference, not a server grant of parental access. Health/cycle UI and external AI/voice remain disabled.
10 +
11 +## Current implementation
12 +
13 +- Shared Node/Express/Argon2id/PostgreSQL with migrations 0007 onward: optional email/phone identity, verification delivery recovery, rate-limited resend, provider port, hashed tokens and refresh rotation.
14 +- Current family/membership/guardian checks, private notes stripped from shared task views, report metrics scoped per visible task. Family archival and revoked membership/guardian relationships close access. Selected grants do not resurrect after rejoining.
15 +- Canonical plan creation version1, stable UUID offline mutations, request-hash idempotency, row/owner locks, expected-version conflicts, canonical server acknowledgement; edit and safe archive use real storage.
16 +- Study sessions/intervals/events survive backend restart; start/pause/resume/stop, corrections/archive, overlap/duplicate protection. Timer/self-reported durations are explicitly not proof of study. Guardian confirmation requires authorized evidence.
17 +- Persian RTL parent views, allowed learning reports, activity timestamps, last-refresh/error state and polling. Android endpoint settings/fallback selection and web no-store config.json use one chosen HTTPS API; endpoint/account switch clears old credentials/cache.
18 +- Client queue/cache scoped to endpoint+authenticated user, durable enqueue-before-send, FIFO chains, malformed-ack rejection, conflicts retained, logout generation invalidation. Storage failures are not mistaken for network outages.
19 +- Self-hosted Compose API/Postgres/nginxTLS + backup cron/healthchecks; tested synthetic backup/restore uses existing scripts. Runtime web fonts/CanvasKit are bundled locally. Notification polling uses a replaceable delivery port; background push is not enabled.
20 +- Product rebrand **LifeGuide**, Android **ir.lifeguide.app**, release key required from secrets; automatic public publishing and unused fix workflow removed. Deployment and signed-APK workflows are manual and disabled by default.
21 +
22 +## Execution evidence so far
23 +
24 +Actual output is recorded in [Stage 0 verification](docs/audits/2026-10-08-stage0-verification.md). Before final integration, the team executed fresh real PostgreSQL migrations and backend tests (95 passed), an independent HTTP/DB eight-step scenario (9 assertions passed), focused runtime/session/endpoint tests, and focused offline tests. Root executed proxy HTTP tests (3 passed), offline FIFO/ack/scope tests (8 passed), local bootstrap regression and diff checks. These counts are intermediate; final aggregate results belong in the handover report.
25 +
26 +Local Compose PostgreSQL/API/backup are healthy; repeat migrations and scheduled backup plus synthetic restore/privacy/session drill ran successfully. First gateway builds failed (SDK/proxy/source issues), were not counted as success, and are being rebuilt. No live host, DNS, production deploy, real-data migration, merge or public release ran.
27 +
28 +## UNVERIFIED acceptance and remaining gates
29 +
30 +- Real Android three-device lifecycle/install/upgrade; iPhone/iPad Safari login, Add to Home Screen and safe PWA update.
31 +- Windows PowerShell/WSL2/mkcert owner-PC installation and trusted mobile TLS.
32 +- VPN-free API/PWA/APK reachability inside Iran; foreign VPS/payment/KYC eligibility. No suitable long-term free/no-card VPS was verified; Stage 0 LAN is the primary recommendation.
33 +- Real email/SMS delivery/provider/payment, timing-indistinguishability of registration, background push.
34 +- Owner release keystore/certificate, genuinely signed LifeGuide.apk and public availability.
35 +- Legal/consent/retention gates for minor wellbeing and cycle data; in-country sensitive storage policy. These gates are flagged, not implemented or certified.
36 +- Complete lifecycle CRUD for legacy auxiliary school/context/check-in entities and richer report UX must be audited against scope. Existing implementations must not be called complete merely because tests pass.
37 +
38 +## Next and operator responsibilities
39 +
40 +Finish the local HTTPS/PWA integration and actual aggregate regression; open/update the feature PR with exact evidence and unverified gaps. Owner then runs [Stage 0](docs/operations/STAGE0.md) with synthetic accounts and A–H hardware acceptance. Owner chooses hosting, DNS, SMS/email provider and signing key outside chat; any live change needs its explicit approval. [Hosting ADR](docs/decisions/0009-provider-neutral-hosting.md), [naming ADR](docs/decisions/0010-lifeguide-naming.md), [migration/rollback](docs/operations/DOMESTIC_MIGRATION.md).
README.md
+43 -20
@@ -1,31 +1,54 @@
1 -# LifeMate
1 +# LifeGuide / لایف‌گاید
2
3 -**Personal, Family & Learning Companion**
3 +همراه فارسی و راست‌به‌چپ خانواده و آموزش؛ Android و PWA والدین از یک API مبتنی بر Node/Express و PostgreSQL مشترک استفاده می‌کنند. نام مخزن `davoodmehraban89/LifeMate` و قراردادهای قدیمی پایگاه داده و JWT تغییر نمی‌کنند.
4
5 -LifeMate is a cross-platform personal and family companion designed to grow with its users across life stages. The first product focus is a teen-and-family experience combining planning, school organization, learning support, family coordination, and safe AI-assisted wellbeing guidance.
5 +این شاخه یک **نامزد آزمون آنلاین با داده ساختگی** است. نسخه کامل عملیاتی یا منتشرشده نیست. پذیرش Android/iPhone/Safari واقعی و دسترسی بدون VPN داخل ایران **UNVERIFIED** است. Backend موجود و Feature 1 ایران حفظ شده‌اند؛ حالت بدون ورودِ محلی جای سیستم چندکاربره نیست.
6
7 -## Product principles
7 +## شروع محلی
8
9 -- One identity, multiple life contexts: student, personal, family, and later work/university.
10 -- One Family Workspace with independent member accounts and role-based access.
11 -- Parents can access authorized planning, academic reports, and meaningful support signals without turning the product into continuous surveillance.
12 -- AI assists with planning, learning, reflection, and parent guidance; it does not impersonate a clinician or replace human professional care.
13 -- Android installable app + high-quality iPhone/iPad PWA + responsive web, sharing one backend and data model.
14 -- Persian/RTL quality and an attractive, age-appropriate visual experience are first-class requirements.
15 -- Security, privacy, safety, and auditability are architectural requirements, not post-release additions.
9 +Windows/LAN: [راهنمای Stage 0](docs/operations/STAGE0.md). Docker Desktop/Compose و گواهی HTTPS مورد اعتماد دستگاه‌های آزمون لازم‌اند؛ حساب یا پرداخت میزبان لازم نیست.
10
17 -## Current phase
11 +```powershell
12 +./scripts/local-deploy.ps1 -Origin https://192.168.1.10 -Certificate deployment/tls/server.pem -PrivateKey deployment/tls/server-key.pem -Project lifeguide-stage0
13 +```
14
19 -**Discovery / Foundation**
15 +IP نمونه را با IP رایانه عوض کنید. روی Linux، پس از تولید گواهی و انتخاب مبدأ:
16
21 -The repository is intentionally starting with product rules, architecture decisions, and project state before application scaffolding is locked in.
17 +```bash
18 +bash scripts/local-deploy.sh --init https://192.168.1.10
19 +```
20
23 -## Repository operating documents
21 +`.env`، گواهی خصوصی، backup و keystore خارج Git بمانند. API و PostgreSQL پورت عمومی ندارند؛ nginx، PWA و `/api` را از همان HTTPS ارائه می‌کند. `deployment/runtime-config.json` تنظیم عمومی وب است؛ Android از تنظیم داخل برنامه استفاده می‌کند. تغییر سرور، نشست و کش قبلی را پاک می‌کند؛ صف خصوصی به سرور دیگری ارسال نمی‌شود.
22
25 -- [`AGENTS.md`](AGENTS.md) — operating rules and ownership model.
26 -- [`PROJECT_STATE.md`](PROJECT_STATE.md) — current checkpoint and change ledger.
27 -- [`docs/decisions/`](docs/decisions/) — architecture and product decision records.
23 +## توسعه و آزمون
24
29 -## Working name
25 +```bash
26 +cd backend
27 +npm ci
28 +npm run migrate
29 +npm test
30 +npm run check
31 +```
32
31 -**LifeMate** is approved as the current product name. It may be revisited only through an explicit product decision.
33 +دیتابیس آزمون باید PostgreSQL16 محلی با **داده ساختگی** باشد؛ `DATABASE_URL` و `JWT_SECRET` را از محیط خصوصی تنظیم کنید. پیش از آزمون، migrationها را اجرا کنید. Flutter3.47.6:
34 +
35 +```bash
36 +cd apps/lifemate
37 +flutter pub get
38 +flutter analyze
39 +flutter test
40 +flutter build web --release --no-web-resources-cdn --pwa-strategy=none
41 +node tool/self_host_web.mjs build/web
42 +```
43 +
44 +خروجی وب CanvasKit و فونت‌ها را محلی ارائه می‌کند. انتشار خودکار قبلی حذف شده؛ استقرار و APK امضاشده فقط workflow دستیِ پیش‌فرض خاموش دارند. APK آزمایشی debug را با release رسمی اشتباه نگیرید. شناسه نهایی Android `ir.lifeguide.app` و نام فایل release رسمی `LifeGuide.apk` است؛ ساخت آن به کلید واقعی مالک نیاز دارد.
45 +
46 +## داده و حریم خصوصی
47 +
48 +PostgreSQL مرجع رکوردها و مجوزهاست؛ کش/صف آفلاین بر اساس کاربر و API جدا می‌شود. شناسه UUID، نسخه و تأیید سرور از تکرار و بازنویسی خاموش جلوگیری می‌کنند. والد فقط تکلیف و گزارش مجاز را می‌بیند. زمان ثبت‌شده تایمر یا گزارش شخصی، مدرک مطالعه واقعی نیست. AI/voice خارجی و قابلیت‌های حساس سلامت/چرخه در این بسته غیرفعال‌اند؛ بررسی حقوقی/رضایت و نگهداری داخلی داده حساس، گیت‌های باز انتشار هستند.
49 +
50 +- [وضعیت و شواهد](PROJECT_STATE.md)، [تغییرات](CHANGELOG.md)، [تحلیل شکاف main](docs/audits/2026-10-08-online-gap-analysis.md)
51 +- [تصمیم میزبانی و تحقیق](docs/decisions/0009-provider-neutral-hosting.md)، [نام و هویت انتشار](docs/decisions/0010-lifeguide-naming.md)
52 +- [استقرار/بازگشت](docs/operations/SELF_HOSTED_DEPLOYMENT.md)، [تمرین مهاجرت داخلی](docs/operations/DOMESTIC_MIGRATION.md)
53 +
54 +میزبانی عمومی، DNS، انتقال داده واقعی، merge و انتشار هنوز انجام نشده‌اند و به مجوز مالک نیاز دارند. گزینه پیشنهادی فعلی Stage 0 رایگان روی LAN است؛ VPS رایگانِ مناسب بدون کارت در تحقیق تأیید نشد.
backend/README.md
+6 -2
@@ -1,4 +1,6 @@
1 -# LifeMate backend contract
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 +# LifeGuide backend contract
4
5 Phase 2 keeps infrastructure provider-neutral.
6
@@ -7,7 +9,7 @@ Required operations: register(email,password), verifyEmail(token), signIn(email,
9
10 Security requirements: normalized email; non-enumerating recovery response; single-use/time-limited verification and reset tokens stored as digests; modern password hashing in the identity adapter; session rotation/revocation; rate limiting; audit sensitive changes.
11
10 -## LifeMate API authorization
12 +## LifeGuide API authorization
13 Every request resolves an authenticated `app_user`. Family operations evaluate active membership and explicit guardian relationships server-side. `owner_admin` is administrative authority and never grants blanket access to private teen content. Safety-controlled access is a separate audited policy path.
14
15 ## Invitation
@@ -18,3 +20,5 @@ Invitation token is random, time-limited and stored only as a digest. Acceptance
20
21 ## Staging
22 CI exercises migrations/tests against an isolated PostgreSQL service. Persistent managed staging is attached separately and must use its own credentials/data before Phase 2 is declared complete.
23 +
24 +Current hosting is the root Docker Compose Stage 0 package; see docs/operations/STAGE0.md. Backend version0.5.0 requires current migrations before startup. External AI/voice and sensitive features are disabled; actual evidence and UNVERIFIED release/device gates are in PROJECT_STATE.md.
docs/ROADMAP.md
+2
@@ -1,3 +1,5 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 # LifeMate — Five-Phase Roadmap
4
5 **Status:** Active
docs/architecture/DOMAIN_MODEL_V1.md
+2
@@ -1,3 +1,5 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 # LifeMate — Conceptual Domain Model v1
4
5 ## Identity
docs/architecture/PHASE_2_BLUEPRINT.md
+2
@@ -1,3 +1,5 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 # LifeMate — Phase 2 Implementation Blueprint
4
5 ## Repository structure
docs/architecture/PWA_PLATFORM_CONSTRAINTS_V1.md
+2
@@ -1,3 +1,5 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 # LifeMate — PWA Platform Constraints v1
4
5 ## iPhone/iPad install model
docs/audits/2026-10-08-hosting-research.md new
+45
@@ -0,0 +1,45 @@
1 +# LifeGuide — شواهد تحقیق میزبانی، 2026-10-08
2 +
3 +مسئول این زیرکار: Product & Research. دامنه: تحقیق فقط خواندنی و ADR؛ کد استقرار و نتیجه اجرای Compose در بسته جدا ثبت می‌شود. [ADR 0009](../decisions/0009-provider-neutral-hosting.md) تصمیم عملی را توضیح می‌دهد.
4 +
5 +## چه چیزی واقعاً انجام شد
6 +
7 +- `AGENTS.md` و `PROJECT_STATE.md` روی شاخه `feat/online-family-stage0` پیش از کار خوانده شدند. سند وضعیت موجود همچنان نام و ادعاهای تاریخی میزبانی را دارد؛ دستور جدید مالک درباره نام LifeGuide، کنارگذاشتن Railway و ممنوعیت تغییر زنده مقدم است.
8 +- با ابزار وب واقعی جست‌وجو و سپس صفحات رسمی زیر باز شد؛ اطلاعات از حافظه یا پیشنهاد قدیمی پلن‌ها برداشت نشده است. تاریخ مشاهده 2026-10-08 است.
9 +- اسکریپت‌های موجود `backend/scripts/backup.sh` و `restore.sh` خوانده شدند: `pg_dump` custom، حذف owner/privilege و `pg_restore --clean --if-exists --exit-on-error`. این مطالعه، اجرای backup/restore نیست.
10 +- هیچ account، VM، خرید، ticket، ارسال پیام به فروشنده، تغییر DNS، تغییر سرور یا انتقال داده واقعی انجام نشد.
11 +
12 +## دفتر شواهد رسمی
13 +
14 +| منبع بازشده | مشاهده قابل استناد | چه چیزی را اثبات نمی‌کند |
15 +|---|---|---|
16 +| [Docker Windows installation](https://docs.docker.com/desktop/setup/install/windows-install/) | راه نصب Windows/WSL و رایگان بودن Docker Desktop برای personal use در مستند رسمی | دانلود بدون VPN در ایران، نصب روی PC مالک یا اجرای پروژه |
17 +| [mkcert repository](https://github.com/FiloSottile/mkcert) | تولید CA/certificate محلی؛ موبایل نیازمند نصب CA؛ کلید CA نباید توزیع شود؛ ابزار برای development است | TLS Flutter Android یا Safari روی دستگاه واقعی این پروژه |
18 +| [Apple certificate trust](https://support.apple.com/en-us/102390) | نصب دستی profile به‌تنهایی SSL trust نمی‌دهد؛ full trust باید در Certificate Trust Settings فعال شود | نصب PWA، نشست، refresh یا صحت داده روی Safari مالک |
19 +| [Android network security configuration](https://developer.android.com/privacy-and-security/security-config) | debug-overrides می‌تواند CAهای توسعه را به app debuggable اضافه کند | اینکه `dart:io HttpClient` همین تنظیم native را به‌کار می‌برد؛ transport باید جدا آزموده شود |
20 +| [TurkVPS.cloud plans](https://turkvps.cloud/) | صفحه رسمی Istanbul KVM/root/IPv4 همراه پلن و قیمت 1 GB=$3.44، 2 GB=$4.50، 4 GB=$7.50 ماهانه را نشان می‌دهد | عملکرد/ظرفیت واقعی، اعتبار حقوقی/عملیاتی شرکت، قیمت نهایی پس از ثبت، مناسب بودن پلن برای بار پروژه |
21 +| [TurkVPS crypto page](https://turkvps.cloud/buy-turkey-vps-crypto) | فروشنده می‌گوید مسیر USDT/TRX بدون کارت و با ایمیل است | پذیرش اقامت ایران، توان یا مجوز پرداخت مالک، پذیرش واقعی سفارش، ثبات این سیاست |
22 +| [TurkVPS terms](https://turkvps.cloud/terms) — last updated 2026-10-02 | موجودی ناکافی در تمدید می‌تواند حذف فوری و برگشت‌ناپذیر داده بدهد؛ ضمانت بازگشت 24 ساعته برای کارت است و رمزارز بازپرداخت به مبدأ ندارد؛ backup مسئولیت مشتری است | امنیت backup، کیفیت پشتیبانی یا جبران خسارت واقعی |
23 +| [TurkVPS looking glass](https://turkvps.cloud/looking-glass) | فروشنده test IPv4 `37.221.79.1` و فایل تست ارائه می‌کند؛ ~20 ms تهران ادعای خودش است | probe از ایران اجرا نشده؛ دسترسی IP تحویلی، دامنه نهایی/API/TLS/APK/PWA، پایداری هنگام اختلال یا اعتبار IP |
24 +| [Oracle Free Tier FAQ](https://www.oracle.com/cloud/free/faq/) | Always Free واقعی وجود دارد اما مسیر عمومی ثبت کارت credit/debit می‌خواهد؛ اطلاعات تماس/صورتحساب باید معتبر باشد | مسیر رایگان **بدون کارت** برای این مالک، پذیرش ایران یا ظرفیت VM |
25 +| [THE.Hosting test VPS](https://the.hosting/en/test-vps) | فقط trial سه‌روزه با signup، ticket و KYC؛ فروشنده اختیار رد دارد | VPS رایگان بلندمدت، بی‌نیاز از KYC یا قابل استفاده برای مالک. پیوند signup باز/اجرا نشد |
26 +| [Melbicom USDT guidance](https://www.melbicom.net/solutions/buy-server-with-usdt/) | اولین پرداخت برای mandatory KYC باید با روش دیگری باشد؛ سپس crypto از invoice BitPay ممکن است | مسیر پرداخت عملی مالک ایران؛ صرف لوگوی رمزارز کافی نیست |
27 +| [BitPay jurisdictions](https://support.bitpay.com/hc/en-us/articles/360000123366-What-countries-or-jurisdictions-does-BitPay-support) — updated 2026-10-03 | ایران صریحاً در blocked jurisdictions است | دسترسی مستقیم API خودمیزبان در ایران؛ این محدودیت متعلق به پرداخت BitPay است |
28 +| [Hetzner payment overview](https://docs.hetzner.com/general/billing-and-account-management/billing-at-hetzner/payment-overview/) — last changed 2026-07-28 | کارت، SEPA، transfer یا PayPal؛ روش‌ها در همه کشورها یکسان نیستند؛ crypto پذیرفته نمی‌شود | روش عملی پرداخت مالک یا پذیرش ثبت‌نام ایران |
29 +| [PQ.Hosting About](https://www.pq.hosting/en/about) — last updated 2026-02-01 | سایت خودش را comparison platform معرفی می‌کند و سفارش/پرداخت را به provider منتخب واگذار می‌کند | اطلاعات قدیمی که PQ.Hosting را یک provider واحد با شرایط ثابت فرض کند |
30 +
31 +این جدول مطالب منابع را خلاصه می‌کند؛ گواهی مستقل برای کیفیت فروشنده نیست. TurkVPS «نامزد تحقیق» است، نه توصیه خرید. نبود گزینه رایگان تأییدشده نتیجه همین بررسی است؛ ادعای نبود تمام گزینه‌های ممکن جهان نیست.
32 +
33 +## محدودیت‌ها و پذیرش موردنیاز
34 +
35 +**UNVERIFIED:** دسترسی endpoint نهایی از داخل ایران بدون VPN، مسیر پرداخت مالک، ثبت‌نام/KYC ایران، IP reputation، uptime، داده‌گردانی/backup فروشندگان، اجرای Docker روی Windows مالک، Android واقعی، iPhone/iPad Safari، Add to Home Screen و API round-trip از شبکه مالک.
36 +
37 +برای مقایسه دسترسی، tester داخل ایران باید تاریخ/ساعت، اپراتور، Wi-Fi یا mobile، خاموش بودن VPN و نتیجه TLS/health/PWA/APK/API را ثبت کند. شناسه دستگاه شخصی، IP عمومی tester و token ورود لازم نیست در گزارش عمومی یا چت قرار گیرد. بررسی ICMP/looking glass فقط سرنخ شبکه است؛ جای HTTPS و سناریوی کاربردی را نمی‌گیرد.
38 +
39 +در LAN، PC و گوشی باید origin یکسان داشته باشند. روی iPhone، `localhost` به خود گوشی اشاره می‌کند. HTTPS با CA توسعه باید بدون suppress/skip verification آزموده شود. توسعه‌دهنده می‌تواند registry/tooling را با VPN یا انتقال آفلاین آماده کند؛ این امر معیار «کاربر نهایی بدون VPN» را برآورده نمی‌کند.
40 +
41 +اطلاعات خصوصی خانواده، notes، chat، health/cycle و wellbeing واقعی در این تحقیق یا میزبان خارجی به‌کار نرفته است. موضوع رضایت کودکان و محل نگهداری سلامت داخل کشور نیازمند تصمیم جداست؛ سرویس خارجی AI/voice انتخاب یا فعال نشده است.
42 +
43 +## بازبینی لازم پیش از تصمیم هزینه‌دار
44 +
45 +مالک باید قیمت همان روز، IPv4 واقعی، هزینه تمدید، شرایط حذف داده، روش پرداخت اولیه/تمدید و صلاحیت اقامت ایران را شخصاً تأیید کند. بدون این تأیید، Stage 0 مسیر قابل بررسی است. تغییر به سرور داخلی با همان Compose و backup PostgreSQL طراحی می‌شود؛ جابه‌جایی داده واقعی و DNS به تأیید جدا نیاز دارد و در این کار انجام نشده است.
docs/audits/2026-10-08-naming.md new
+123
@@ -0,0 +1,123 @@
1 +# LifeGuide — remaining legacy-name inventory
2 +
3 +Generated with `python3 scripts/audit-naming.py` from tracked source. Product displays are LifeGuide; repository/schema/JWT/internal compatibility and historical evidence retain their original names. Rows classify every remaining case-insensitive legacy-name line; repeated occurrences on that line share its classification. Binary fonts/icons are not text. This inventory excludes itself.
4 +
5 +| Location | Classification | Reason | Source excerpt |
6 +| --- | --- | --- | --- |
7 +| .github/workflows/ci.yml:29 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | POSTGRES_DB: lifemate_ci |
8 +| .github/workflows/ci.yml:32 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | --health-cmd 'pg_isready -U postgres -d lifemate_ci' |
9 +| .github/workflows/ci.yml:36 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | DATABASE_URL: postgresql://postgres:synthetic_ci_only@localhost:5432/lifemate_ci |
10 +| .github/workflows/ci.yml:62 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | run: {working-directory: apps/lifemate} |
11 +| .github/workflows/ci.yml:83 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | with: {name: LifeGuide-web, path: apps/lifemate/build/web, if-no-files-found: error} |
12 +| .github/workflows/ci.yml:85 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | with: {name: LifeGuide-debug-apk, path: apps/lifemate/build/LifeGuide-debug.apk, if-no-files-found: error} |
13 +| .github/workflows/release-build.yml:16 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | run: {working-directory: apps/lifemate} |
14 +| .github/workflows/release-build.yml:40 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | with: {name: LifeGuide-signed-apk, path: apps/lifemate/build/LifeGuide.apk, if-no-files-found: error} |
15 +| PROJECT_STATE.md:3 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | Updated: 2026-10-08. Backend version: **0.5.0**. Branch: **feat/online-family-stage0**, based on main 'abdc9d9d032bc6746c8390b902a2e52d82991530'. Repository remains 'davoodmehraban89/LifeMate'. |
16 +| README.md:3 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | همراه فارسی و راست‌به‌چپ خانواده و آموزش؛ Android و PWA والدین از یک API مبتنی بر Node/Express و PostgreSQL مشترک استفاده می‌کنند. نام مخزن 'davoodmehraban89/LifeMate' و قراردادهای قدیمی پایگاه داده و JWT تغییر نمی‌کنند. |
17 +| README.md:36 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | cd apps/lifemate |
18 +| apps/lifemate/android/app/src/main/AndroidManifest.xml:7 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | android:icon="@drawable/lifemate_logo"> |
19 +| apps/lifemate/lib/main.dart:16 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | runApp(const LifeMateApp()); |
20 +| apps/lifemate/lib/main.dart:19 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | class LifeMateApp extends StatefulWidget { |
21 +| apps/lifemate/lib/main.dart:20 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | const LifeMateApp({super.key, this.api, this.runtime}); |
22 +| apps/lifemate/lib/main.dart:25 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | State<LifeMateApp> createState() => _LifeMateAppState(); |
23 +| apps/lifemate/lib/main.dart:28 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | class _LifeMateAppState extends State<LifeMateApp> { |
24 +| apps/lifemate/pubspec.yaml:1 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | name: lifemate |
25 +| apps/lifemate/test/app_test.dart:5 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | import 'package:lifemate/api.dart'; |
26 +| apps/lifemate/test/app_test.dart:6 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | import 'package:lifemate/main.dart'; |
27 +| apps/lifemate/test/app_test.dart:211 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | await tester.pumpWidget(LifeMateApp(api: FakeApi())); |
28 +| apps/lifemate/test/app_test.dart:219 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | await tester.pumpWidget(LifeMateApp(api: FakeApi())); |
29 +| apps/lifemate/test/iran_hub_test.dart:2 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | import 'package:lifemate/iran_hub.dart'; |
30 +| apps/lifemate/test/phase4_ui_test.dart:3 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | import 'package:lifemate/api.dart'; |
31 +| apps/lifemate/test/phase4_ui_test.dart:4 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | import 'package:lifemate/phase4_ui.dart'; |
32 +| backend/package.json:2 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | "name": "lifemate-backend", |
33 +| backend/scripts/backup.sh:4 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | output="${1:-lifemate-$(date -u +%Y%m%dT%H%M%SZ).dump}" |
34 +| backend/scripts/restore-smoke.sql:3 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | values('00000000-0000-4000-8000-000000000005','restore-smoke','restore-smoke@lifemate.test',now()) |
35 +| backend/src/entrypoint.js:22 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | res.json({ status: 'ok', service: 'lifemate-api' }); |
36 +| backend/src/entrypoint.js:37 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | outer.listen(publicPort, () => console.log(JSON.stringify({ type: 'startup', service: 'lifemate-api', port: publicPort }))); |
37 +| backend/src/session_auth.js:9 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | audience: 'lifemate-api', |
38 +| backend/src/session_auth.js:10 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | issuer: 'lifemate', |
39 +| backend/tests/request_safety.test.js:98 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | const token = jwt.sign({ sub: id, sid: sessionId, aud: 'lifemate-api' }, process.env.JWT_SECRET, { expiresIn: '15m', issuer: 'lifemate' }); |
40 +| docs/ROADMAP.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | # LifeMate — Five-Phase Roadmap |
41 +| docs/architecture/DOMAIN_MODEL_V1.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | # LifeMate — Conceptual Domain Model v1 |
42 +| docs/architecture/PHASE_2_BLUEPRINT.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | # LifeMate — Phase 2 Implementation Blueprint |
43 +| docs/architecture/PHASE_2_BLUEPRINT.md:7 | historical — keep | snapshot/previous decision; not current deployment evidence | apps/lifemate/ Flutter application (Android + Web/PWA) |
44 +| docs/architecture/PHASE_2_BLUEPRINT.md:40 | historical — keep | snapshot/previous decision; not current deployment evidence | MyStudyLife is the primary information-architecture benchmark for the student surface. Direct destinations remain visible for Today, Schedule, Calendar, Tasks, Exams/Grades, Focus and AI; LifeMate Family/Wellbeing extens |
45 +| docs/architecture/PWA_PLATFORM_CONSTRAINTS_V1.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | # LifeMate — PWA Platform Constraints v1 |
46 +| docs/architecture/PWA_PLATFORM_CONSTRAINTS_V1.md:6 | historical — keep | snapshot/previous decision; not current deployment evidence | LifeMate must include a Web App Manifest and standalone display behavior plus explicit icons. On iOS/iPadOS, a Home Screen web app can open as its own app-like surface rather than a normal browser tab. 'apple-touch-icon' |
47 +| docs/architecture/PWA_PLATFORM_CONSTRAINTS_V1.md:12 | historical — keep | snapshot/previous decision; not current deployment evidence | Current Flutter web does not provide a managed caching service worker by default. LifeMate must own its caching strategy. Phase 2 begins with conservative app-shell/static caching; offline data editing is added only per |
48 +| docs/audits/2026-10-08-online-gap-analysis.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | تاریخ: ۲۰۲۶-۱۰-۰۸. این گزارش **پیش از پیاده‌سازی آنلاین جدید**، با خواندن source در 'main' تهیه شده است. هدف جدید، Android و PWA والدین متصل به یک Node/PostgreSQL مشترک است. بسته محلی بدون Login، شاهد اشتراک یا Sync آنلا |
49 +| docs/audits/2026-10-08-online-gap-analysis.md:12 | historical — keep | snapshot/previous decision; not current deployment evidence | \| 'feat/online-family-stage0'، هنگام ایجاد \| 'abdc9d9d032bc6746c8390b902a2e52d82991530' \| worktree جدید '/workspace/LifeMate-online' از 'main'؛ این سند، عکس خط مبنای آغاز کار است. \| |
50 +| docs/audits/2026-10-08-online-gap-analysis.md:16 | historical — keep | snapshot/previous decision; not current deployment evidence | \| 'final-feature-1/iran-family-school' \| '71ee193e4b5a6ef39a5a4b5e5a2abbed8756023d' \| diff فایل‌های 'backend' و 'apps/lifemate/lib' نسبت به main خالی است؛ پیاده‌سازی runtime Feature 1 از قبل در main موجود است. تست‌های |
51 +| docs/audits/2026-10-08-online-gap-analysis.md:22 | historical — keep | snapshot/previous decision; not current deployment evidence | \| Stage 0 مشترک روی Windows/LAN \| 'backend/package.json' با Node >=22 و 'npm start → src/entrypoint.js'؛ migration runner و 'backend/scripts/backup.sh'/'restore.sh'. 'apps/lifemate/Dockerfile' فقط web/APK را می‌سازد و |
52 +| docs/audits/2026-10-08-online-gap-analysis.md:23 | historical — keep | snapshot/previous decision; not current deployment evidence | \| endpoint قابل تغییر در runtime \| 'HttpIdentityApi(baseUrl:)' قابلیت تزریق URL دارد؛ مقدار پیش‌فرض از 'LIFEMATE_API_URL' در زمان build و سپس 'http://localhost:8080' است ('apps/lifemate/lib/api.dart'). \| رابط انتخاب/ذ |
53 +| docs/audits/2026-10-08-online-gap-analysis.md:24 | historical — keep | snapshot/previous decision; not current deployment evidence | \| Android رسمی \| 'applicationId = com.example.lifemate'، label قدیمی و 'release' با debug signing در 'android/app/build.gradle.kts'. manifest اصلی main اجازه INTERNET ندارد؛ فقط debug/profile آن را دارند. \| شناسه 'ir. |
54 +| docs/audits/2026-10-08-online-gap-analysis.md:40 | historical — keep | snapshot/previous decision; not current deployment evidence | - 'apps/lifemate/lib/offline_store.dart' cache/queue را با user/server namespace تفکیک نمی‌کند؛ fallback UI همه exceptionها، از جمله خطای auth، را آفلاین تلقی می‌کند. این مرز باید پیش از استفاده چندحسابی/اشتراک دستگاه اص |
55 +| docs/decisions/0006-provider-neutral-postgresql-backend.md:9 | historical — keep | snapshot/previous decision; not current deployment evidence | Phase 2 originally treated Supabase as the likely combined database/auth/backend provider. Creation of an isolated LifeMate staging project was blocked by account-level project limits. More importantly, tying identity, a |
56 +| docs/decisions/0006-provider-neutral-postgresql-backend.md:12 | historical — keep | snapshot/previous decision; not current deployment evidence | LifeMate will use PostgreSQL as its durable relational source of truth while exposing infrastructure through explicit application ports/adapters. |
57 +| docs/decisions/0006-provider-neutral-postgresql-backend.md:18 | historical — keep | snapshot/previous decision; not current deployment evidence | - 'LifeMateApi': authenticated application boundary; clients do not receive privileged database credentials. |
58 +| docs/decisions/0006-provider-neutral-postgresql-backend.md:31 | historical — keep | snapshot/previous decision; not current deployment evidence | - LifeMate is no longer blocked by Supabase project quotas. |
59 +| docs/decisions/0009-provider-neutral-hosting.md:7 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | نام محصول: **LifeGuide / لایف‌گاید**؛ نام مخزن 'davoodmehraban89/LifeMate' و شناسه‌های پروتکل تغییر نمی‌کنند. |
60 +| docs/decisions/0010-lifeguide-naming.md:8 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | برند در label، PWA، صفحات، ایمیل‌ها و مستندات جاری LifeGuide است. نام مخزن 'davoodmehraban89/LifeMate'، مسیر 'apps/lifemate'، package داخلی Dart/Node، منابع داخلی drawable و قرارداد JWT issuer='lifemate'/audience='lifema |
61 +| docs/decisions/0010-lifeguide-naming.md:12 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | شناسه جدید جایگزین 'com.example.lifemate' است؛ نصب قبلی با شناسه قدیمی به‌صورت خودکار upgrade نمی‌شود. پاک‌کردن نصب قدیمی یا انتقال داده آن بدون تصمیم مستقل مجاز نیست. کلید امضای واقعی مالک بیرون Git و chat می‌ماند. ساخت |
62 +| docs/final/DELIVERY.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | # LifeMate Feature 1 — Final Delivery |
63 +| docs/final/DELIVERY.md:7 | historical — keep | snapshot/previous decision; not current deployment evidence | - 'lifemate-android-apk' — release APK for owner-side Android installation/testing. |
64 +| docs/final/DELIVERY.md:8 | historical — keep | snapshot/previous decision; not current deployment evidence | - 'lifemate-web-release' — production Web/PWA bundle for controlled hosting/testing. |
65 +| docs/final/DELIVERY.md:11 | historical — keep | snapshot/previous decision; not current deployment evidence | The Flutter iOS project is present in 'apps/lifemate/ios'. A signed '.ipa' requires macOS/Xcode plus the owner's Apple Developer signing identity/provisioning profile. Verification command on an authorized macOS runner: |
66 +| docs/final/THREE_PHASE_AUDIT.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | # LifeMate — Final Three-Phase Audit |
67 +| docs/history/2026-10-05-project-state.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | # LifeMate — Project State |
68 +| docs/history/2026-10-05-project-state.md:7 | historical — keep | snapshot/previous decision; not current deployment evidence | **Repository:** 'davoodmehraban89/LifeMate' |
69 +| docs/history/2026-10-05-project-state.md:8 | historical — keep | snapshot/previous decision; not current deployment evidence | **Working product name:** LifeMate — approved |
70 +| docs/history/2026-10-05-project-state.md:11 | historical — keep | snapshot/previous decision; not current deployment evidence | Phases 1–5 engineering core are complete. LifeMate now has the foundation/identity, planner-school-family core, advisory learning/wellbeing guides, and the operational hardening/release-readiness layer required for a con |
71 +| docs/history/2026-10-05-project-state.md:23 | historical — keep | snapshot/previous decision; not current deployment evidence | - LifeMate-owned identity/session adapter; server-side relationship-aware authorization. |
72 +| docs/operations/BACKUP_RESTORE.md:8 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | 'backend/scripts/backup.sh /secure/location/lifemate-YYYYMMDD.dump' |
73 +| docs/operations/BACKUP_RESTORE.md:15 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | 'backend/scripts/restore.sh /secure/location/lifemate-YYYYMMDD.dump' |
74 +| docs/operations/SELF_HOSTED_DEPLOYMENT.md:13 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | 3. '.env.example' را به '.env' کپی و secretها را در محیط/secret management میزبان تولید کنید. نام schemaها، JWT issuer='lifemate' و audience='lifemate-api' تغییر نمی‌کند. روی انتقال دیتابیس، secret JWT را مطابق سیاست نشس |
75 +| docs/operations/STAGE0.md:30 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | Set-Location apps/lifemate |
76 +| docs/plans/PHASE_2_IMPLEMENTATION_PLAN.md:11 | historical — keep | snapshot/previous decision; not current deployment evidence | Supabase is no longer a required platform dependency. LifeMate uses provider-neutral backend ports with PostgreSQL as the durable relational core. Neon is the preferred managed PostgreSQL target when its connector is ope |
77 +| docs/plans/PHASE_2_IMPLEMENTATION_PLAN.md:34 | historical — keep | snapshot/previous decision; not current deployment evidence | - Student IA uses MyStudyLife as benchmark: direct access to Today, Schedule, Calendar, Tasks, Exams/Grades, Focus and AI; LifeMate family/wellbeing extensions remain additive. |
78 +| docs/plans/PHASE_3_IMPLEMENTATION_PLAN.md:23 | historical — keep | snapshot/previous decision; not current deployment evidence | - MyStudyLife remains the benchmark for student IA, but LifeMate adds family sharing and guardian support. |
79 +| docs/product/FEATURE_PRIORITIES_V1.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | # LifeMate — Feature Priorities v1 |
80 +| docs/product/FEATURE_PRIORITIES_V1.md:36 | historical — keep | snapshot/previous decision; not current deployment evidence | LifeMate V1 is not a surveillance product, clinical diagnosis/treatment system, location tracker, social network, school ERP, or autonomous decision-maker. |
81 +| docs/product/PERMISSION_MATRIX_V0.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | # LifeMate — Permission & Visibility Matrix v0 |
82 +| docs/product/PRODUCT_SPEC_V1.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | # LifeMate — Product Specification v1 |
83 +| docs/product/PRODUCT_SPEC_V1.md:9 | historical — keep | snapshot/previous decision; not current deployment evidence | LifeMate is a personal, family and learning companion. It begins with a teen-and-family scenario but must grow with a person across school years and later life. It is not a surveillance app, not only a student planner, a |
84 +| docs/quality/ANALYTICS_POLICY_V1.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | # LifeMate — Analytics Policy v1 |
85 +| docs/quality/PHASE_2_QUALITY_GATES.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | # LifeMate — Phase 2 Quality Gates |
86 +| docs/quality/PHASE_2_QUALITY_GATES.md:16 | historical — keep | snapshot/previous decision; not current deployment evidence | For each protected resource, test allowed and denied access for: owner profile, related guardian, unrelated family member, removed member, unauthenticated user and privileged server path where applicable. LifeMate's prim |
87 +| docs/safety/SAFETY_PRIVACY_RISK_V1.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | # LifeMate — Safety, Privacy & Risk Baseline v1 |
88 +| docs/safety/SAFETY_PRIVACY_RISK_V1.md:6 | historical — keep | snapshot/previous decision; not current deployment evidence | LifeMate may provide general wellbeing reflection, coping ideas, communication prompts and educational support. It must not claim diagnosis, treatment, professional licensure or certainty about a user's mental state. The |
89 +| docs/superpowers/plans/2026-10-05-iran-family-learning-hub.md:48 | historical — keep | snapshot/previous decision; not current deployment evidence | **Files:** create 'apps/lifemate/lib/iran_hub.dart'; modify 'api.dart', 'phase3_ui.dart', navigation as required. |
90 +| docs/superpowers/plans/2026-10-05-phase-5-hardening-release.md:5 | historical — keep | snapshot/previous decision; not current deployment evidence | **Goal:** Harden LifeMate operationally and make the existing Android/Web/PWA/API stack release-ready without performing a production release. |
91 +| docs/superpowers/plans/2026-10-06-lifeguide-rebrand-domain-migration.md:5 | historical — keep | snapshot/previous decision; not current deployment evidence | **Goal:** Rebrand the existing LifeMate release candidate to LifeGuide, move public identity to lifeguide.ir, isolate transactional email, and preserve the working shared backend/database. |
92 +| docs/superpowers/plans/2026-10-06-lifeguide-rebrand-domain-migration.md:27 | historical — keep | snapshot/previous decision; not current deployment evidence | - Old 'LifeMate' strings remain in active user-facing flows: repository audit must distinguish harmless historical/internal identifiers from visible brand copy. |
93 +| docs/superpowers/plans/2026-10-06-lifeguide-rebrand-domain-migration.md:38 | historical — keep | snapshot/previous decision; not current deployment evidence | - Inspect: 'apps/lifemate/**' |
94 +| docs/superpowers/plans/2026-10-06-lifeguide-rebrand-domain-migration.md:47 | historical — keep | snapshot/previous decision; not current deployment evidence | - [ ] Search active source/configuration for 'LifeMate', 'lifemate', 'com.example.lifemate', current public URLs, and email sender configuration. |
95 +| docs/superpowers/plans/2026-10-06-lifeguide-rebrand-domain-migration.md:54 | historical — keep | snapshot/previous decision; not current deployment evidence | - Modify: 'apps/lifemate/lib/main.dart' |
96 +| docs/superpowers/plans/2026-10-06-lifeguide-rebrand-domain-migration.md:55 | historical — keep | snapshot/previous decision; not current deployment evidence | - Test: 'apps/lifemate/test/app_test.dart' |
97 +| docs/superpowers/plans/2026-10-06-lifeguide-rebrand-domain-migration.md:62 | historical — keep | snapshot/previous decision; not current deployment evidence | - [ ] Replace active user-facing LifeMate branding with LifeGuide and implement local password validation. |
98 +| docs/superpowers/plans/2026-10-06-lifeguide-rebrand-domain-migration.md:69 | historical — keep | snapshot/previous decision; not current deployment evidence | - Modify: 'apps/lifemate/web/index.html' |
99 +| docs/superpowers/plans/2026-10-06-lifeguide-rebrand-domain-migration.md:70 | historical — keep | snapshot/previous decision; not current deployment evidence | - Modify: 'apps/lifemate/web/manifest.json' |
100 +| docs/superpowers/plans/2026-10-06-lifeguide-rebrand-domain-migration.md:80 | historical — keep | snapshot/previous decision; not current deployment evidence | - [ ] Replace 'com.example.lifemate' with the approved stable identifier 'ir.lifeguide.app' if audit confirms no conflicting package structure requirement. |
101 +| docs/superpowers/plans/2026-10-06-lifeguide-rebrand-domain-migration.md:125 | historical — keep | snapshot/previous decision; not current deployment evidence | - Produces: current documentation that names LifeGuide and records remaining historical/internal LifeMate identifiers intentionally retained. |
102 +| docs/superpowers/plans/2026-10-06-lifeguide-rebrand-domain-migration.md:149 | historical — keep | snapshot/previous decision; not current deployment evidence | - [ ] Re-audit active runtime/source for Factoreasy references and unresolved user-facing LifeMate branding. |
103 +| docs/superpowers/specs/2026-10-05-iran-family-learning-hub-design.md:4 | historical — keep | snapshot/previous decision; not current deployment evidence | Complete LifeMate's owner-testable family/school/planner experience for an Iranian household. A household can explicitly identify mother, father and children; a child can carry age/sex and Iranian education stage/grade; |
104 +| docs/superpowers/specs/2026-10-05-iran-family-learning-hub-design.md:23 | historical — keep | snapshot/previous decision; not current deployment evidence | LifeMate may show catalog metadata and links to official Ministry textbook distribution sources (for example 'chap.sch.ir') and may support user-initiated lawful download/import later. The repository will not embed textb |
105 +| docs/superpowers/specs/2026-10-05-phase-5-hardening-release-design.md:6 | historical — keep | snapshot/previous decision; not current deployment evidence | Make the existing LifeMate Android + Web/PWA + Node/PostgreSQL system operationally safe and release-ready without expanding the product scope or enabling public production exposure of minor-sensitive wellbeing AI. |
106 +| docs/superpowers/specs/2026-10-06-lifeguide-rebrand-domain-migration-design.md:5 | historical — keep | snapshot/previous decision; not current deployment evidence | Repository: davoodmehraban89/LifeMate |
107 +| docs/superpowers/specs/2026-10-06-lifeguide-rebrand-domain-migration-design.md:6 | historical — keep | snapshot/previous decision; not current deployment evidence | Current runtime project: LifeMate-Staging |
108 +| docs/superpowers/specs/2026-10-06-lifeguide-rebrand-domain-migration-design.md:12 | historical — keep | snapshot/previous decision; not current deployment evidence | Rebrand the existing LifeMate product to LifeGuide without rebuilding the project, while preserving working functionality and keeping the current staging release path intact. |
109 +| docs/superpowers/specs/2026-10-06-lifeguide-rebrand-domain-migration-design.md:20 | historical — keep | snapshot/previous decision; not current deployment evidence | - Replace user-facing product branding from LifeMate to LifeGuide. |
110 +| docs/superpowers/specs/2026-10-06-lifeguide-rebrand-domain-migration-design.md:29 | historical — keep | snapshot/previous decision; not current deployment evidence | - Update backend transactional email subjects/body text from LifeMate to LifeGuide. |
111 +| docs/superpowers/specs/2026-10-06-lifeguide-rebrand-domain-migration-design.md:89 | historical — keep | snapshot/previous decision; not current deployment evidence | Replacement must be targeted. Generic identifiers containing 'lifemate' are not blindly renamed if doing so risks compatibility. |
112 +| docs/superpowers/specs/2026-10-06-lifeguide-rebrand-domain-migration-design.md:245 | historical — keep | snapshot/previous decision; not current deployment evidence | - No user-facing LifeMate branding remains in active flows. |
113 +| docs/ux/BRAND_BRIEF_V1.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | # LifeMate — Brand & Visual Brief v1 |
114 +| docs/ux/BRAND_BRIEF_V1.md:6 | historical — keep | snapshot/previous decision; not current deployment evidence | **LifeMate = همراه رشد، نه ناظر.** The visual language combines calm, momentum, independence and connection. |
115 +| docs/ux/BRAND_BRIEF_V1.md:12 | historical — keep | snapshot/previous decision; not current deployment evidence | LifeMate uses a white/light neutral foundation and applies a profile-aware accent as a **default, not an irreversible identity lock**: |
116 +| docs/ux/BRAND_BRIEF_V1.md:28 | historical — keep | snapshot/previous decision; not current deployment evidence | The mark should express **path + companion + growth** using a simple abstract form readable at favicon/app-icon size. Avoid book/pencil/graduation-cap as the primary symbol because LifeMate is broader than school. The ic |
117 +| docs/ux/BRAND_BRIEF_V1.md:37 | historical — keep | snapshot/previous decision; not current deployment evidence | Phase 1 design file: 'LifeMate — Product UX & Brand v1'. Initial editable board is directional, not a final UI kit. |
118 +| docs/ux/BRAND_BRIEF_V1.md:43 | historical — keep | snapshot/previous decision; not current deployment evidence | Reject screens that feel like a generic school ERP, a surveillance dashboard, or a small-child game. LifeMate should feel like a polished personal companion that understands school and family. |
119 +| docs/ux/IA_AND_JOURNEYS_V1.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | # LifeMate — Information Architecture & Primary Journeys v1 |
120 +| docs/ux/IA_AND_JOURNEYS_V1.md:30 | historical — keep | snapshot/previous decision; not current deployment evidence | Create academic year/term → add subjects → add repeating class schedule → add assignments/exams → LifeMate surfaces Today/Week workload → teen schedules study sessions → reminders follow schedule changes. |
121 +| scripts/audit-naming.py:20 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | if not re.search('lifemate', line, re.I): continue |
122 +| scripts/audit-naming.py:22 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | internal = re.search(r'LifeMateApp\|_LifeMateAppState\|davoodmehraban89/LifeMate\|/LifeMate\|apps/lifemate\|package:lifemate\|lifemate[-_]\|\blifemate\b\|LIFEMATE', line) |
123 +| scripts/audit-naming.py:31 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | if name.startswith(('apps/lifemate/lib/', 'apps/lifemate/web/', '.github/workflows/')) and re.search(r"['\"][^'\"]*\bLifeMate\b[^'\"]*['\"]", line) and not re.search(r'LifeMateApp\|package:', line): |
docs/audits/2026-10-08-stage0-verification.md new
+26
@@ -0,0 +1,26 @@
1 +# LifeGuide — شواهد Stage 0
2 +
3 +تاریخ: ۲۰۲۶-۱۰-۰۸ UTC. scope اجرا، Docker محلی Linux در محیط توسعه با **داده ساختگی** است. `.env` خصوصی، پروژه `lifeguide-stage0-audit`، HTTPS loopback `127.0.0.1:8443` و گواهی آزمون OpenSSL خارج Git استفاده شدند؛ mkcert/Windows مالک یا شبکه داخل ایران اجرا نشده‌اند. شاخه `feat/online-family-stage0`؛ SHA نهایی در گزارش تحویل ثبت می‌شود.
4 +
5 +| اجرا | نتیجه مشاهده‌شده | حد اعتبار |
6 +| --- | --- | --- |
7 +| `docker version` / `docker compose version` | Engine 28.4.0، Compose 2.40.3 | فقط محیط Linux فعلی |
8 +| `docker compose config --quiet` | exit0 | secrets چاپ نشد؛ startup نیست |
9 +| `bash -n scripts/local-deploy.sh scripts/restore-drill.sh deployment/backup/*.sh` و Node `--check` smoke/seed | exit0 | syntax؛ اجرای Windows PS **UNVERIFIED** |
10 +| build API/backup با npm lock و Node22 | موفق | اجرای اول npm شبکه fail شد؛ trusted build proxy/CA اضافه و TLS verification حفظ شد |
11 +| migration نخست DB تازه، سپس تکرار و upgrade 0010 | 0001–0009 applied؛ تکرار بدون applied؛ 0010 بعداً applied | فقط DB ساختگی محلی؛ ledger idempotency مشاهده شد |
12 +| `docker compose up -d --wait ... api backup` | PostgreSQL/API/backup healthy | این نتیجه UI/CRUD/Safari را تأیید نمی‌کند |
13 +| startup backup + cron آزمایشی یک‌دقیقه‌ای | dump ساعت10:37:20 و dump scheduled10:38:00؛ archive list قابل خواندن | schedule خصوصی آزمون به default روزانه برگشت؛ restore جدا اجرا شد |
14 +| `bash scripts/restore-drill.sh --synthetic-only` | **PASS** در15:23: حساب، policy خانواده/خصوصی، interval مطالعه و10migration | دو DB تازه، داده ساختگی؛ انتقال واقعی **UNVERIFIED** |
15 +| `DOCKER_HOST=ssh://invalid.example bash scripts/local-deploy.sh` و restore-drill | هر دو با exit1 رد شدند، پیش از تماس remote | guard واقعی محلی؛ سرور زنده تغییر نکرد |
16 +
17 +خروجی واقعی drill:
18 +
19 +```text
20 +DO
21 +PASS synthetic PostgreSQL dump/restore: identity, family permissions, private task, paused study intervals and 10 migrations preserved.
22 +```
23 +
24 +خطاهای build اولیه پنهان نشده‌اند: image Flutter3.47.6 در registry Cirrus وجود نداشت؛ Dockerfile به commit رسمی Flutter pin شد. SHA-only checkout، SDK را `0.0.0-unknown` گزارش کرد؛ tag رسمی3.47.6 با همان SHA از GitHub fetch/verify شد. COPY فایل‌های checkout با permission600 به runtime غیرroot، خطای EACCES داد؛ COPY --chown=node:node اصلاح شد. اولین web compile هنگام توسعه هم‌زمان خطا داشت؛ از آن build هیچ gateway/APK معتبر گزارش نشده است.
25 +
26 +HTTPS/PWA/API smoke نهایی بعد از ساخت نهایی gateway در همین گزارش افزوده می‌شود؛ تا قبل از آن **UNVERIFIED** است. TLS اعتماد گواهی، API round-trip و پذیرش مرورگر باید جدا گزارش شوند. اجرای حقیقی Safari/iPhone/Android، دسترسی بدون VPN از ایران، PowerShell مالک، APK release امضاشده، hosting/DNS/live deploy و migration داده واقعی **UNVERIFIED** هستند.
docs/decisions/0001-product-scope-and-lifecycle.md
+2 -2
@@ -4,10 +4,10 @@
4 - **Date:** 2026-10-05
5
6 ## Context
7 -LifeMate begins from a teen/student use case but is intended to remain useful across school years and later life. A student-only root model would make later expansion into university, work, personal projects and adult family life structurally expensive.
7 +LifeGuide begins from a teen/student use case but is intended to remain useful across school years and later life. A student-only root model would make later expansion into university, work, personal projects and adult family life structurally expensive.
8
9 ## Decision
10 -LifeMate is a **Personal, Family & Learning Companion**. The core identity is `Person/Profile`; `Student` is a contextual role/life context. School capabilities are a major initial domain but do not define the root user model.
10 +LifeGuide is a **Personal, Family & Learning Companion**. The core identity is `Person/Profile`; `Student` is a contextual role/life context. School capabilities are a major initial domain but do not define the root user model.
11
12 The product will maintain a deliberately small initial executable scope while keeping domain boundaries extensible.
13
docs/decisions/0002-family-privacy-and-parental-visibility.md
+1 -1
@@ -4,7 +4,7 @@
4 - **Date:** 2026-10-05
5
6 ## Context
7 -LifeMate must support meaningful parent involvement for minors while preserving enough personal space for a teen to trust and use the product. Treating all teen data as either fully private or fully parent-visible is unsuitable.
7 +LifeGuide must support meaningful parent involvement for minors while preserving enough personal space for a teen to trust and use the product. Treating all teen data as either fully private or fully parent-visible is unsuitable.
8
9 ## Decision
10 Use independent accounts within a dynamic `Family Workspace` and a layered visibility model.
docs/decisions/0006-provider-neutral-postgresql-backend.md
+3 -2
@@ -1,6 +1,7 @@
1 # ADR-0006 — Provider-neutral PostgreSQL Backend
2
3 -- **Status:** Accepted
3 +- **Status:** Superseded hosting recommendation; PostgreSQL/adapter invariants retained
4 +- **Superseded by:** [ADR-0009](0009-provider-neutral-hosting.md) for hosting
5 - **Date:** 2026-10-05
6 - **Supersedes:** any Phase 2 assumption that Supabase is a mandatory backend platform
7
@@ -10,7 +11,7 @@ Phase 2 originally treated Supabase as the likely combined database/auth/backend
11 ## Decision
12 LifeMate will use PostgreSQL as its durable relational source of truth while exposing infrastructure through explicit application ports/adapters.
13
13 -The managed PostgreSQL host is replaceable. Neon is the preferred current target when available, but no domain entity, authorization rule, migration or client contract may require Neon-specific semantics.
14 +The managed PostgreSQL host is replaceable. The former Neon preference is historical. The active target is self-hosted PostgreSQL in the same provider-neutral Compose package as the API and PWA; managed database services are excluded by ADR-0009.
15
16 Required ports:
17 - `IdentityProvider`: registration, email verification, login/session, password recovery/change.
docs/decisions/0007-frontend-flutter.md renamed
+2 -2
@@ -1,4 +1,4 @@
1 -# ADR-0004 — Frontend Baseline: Flutter
1 +# ADR-0007 — Frontend Baseline: Flutter
2
3 - **Status:** Accepted for Phase 2 baseline
4 - **Date:** 2026-10-05
@@ -7,7 +7,7 @@
7 Use **Flutter** as the initial client framework for Android and the app-centric responsive Web/PWA surface, with platform-specific web integration where standards-based PWA behavior requires it.
8
9 ## Why
10 -LifeMate is an app-centric experience rather than a document/SEO site. A shared Dart/Flutter product surface reduces divergence between Android and PWA while preserving high visual fidelity and RTL control. Official Flutter guidance identifies PWAs, SPAs and existing mobile-style applications as suitable Flutter web scenarios.
10 +LifeGuide is an app-centric experience rather than a document/SEO site. A shared Dart/Flutter product surface reduces divergence between Android and PWA while preserving high visual fidelity and RTL control. Official Flutter guidance identifies PWAs, SPAs and existing mobile-style applications as suitable Flutter web scenarios.
11
12 ## Important constraint
13 Flutter no longer generates/manages an application caching service worker by default. Offline/PWA caching must therefore be an explicit web concern using a custom standards-based service worker/Workbox or equivalent, not an assumed framework feature.
docs/decisions/0009-provider-neutral-hosting.md new
+99
@@ -0,0 +1,99 @@
1 +# ADR 0009 — میزبانی مستقل LifeGuide و آزمون Stage 0
2 +
3 +تاریخ: 2026-10-08
4 +
5 +وضعیت: پذیرفته‌شده برای بسته توسعه و آزمون محلی؛ انتخاب و راه‌اندازی میزبان عمومی **نیازمند تصمیم و مجوز مالک** است.
6 +
7 +نام محصول: **LifeGuide / لایف‌گاید**؛ نام مخزن `davoodmehraban89/LifeMate` و شناسه‌های پروتکل تغییر نمی‌کنند.
8 +
9 +## مسئله و تصمیم
10 +
11 +کاربران داخل ایران باید API، PWA و APK را از یک مبدأ، بدون VPN و بدون وابستگی زمان اجرا به CDN یا دیتابیس مدیریت‌شده خارجی دریافت کنند. برنامه موجود Express، Argon2 بومی و PostgreSQL را حفظ می‌کنیم. Railway از گزینه‌های فعال کنار گذاشته شده؛ Firebase، Supabase، Neon، Cloudflare Workers/D1 و سایر PaaS/BaaS مدیریت‌شده در این تصمیم گزینه انتشار نیستند. سوابق آن‌ها فقط تاریخچه‌اند.
12 +
13 +**گزینه اصلی فعلی Stage 0 است:** همان پشته آنلاین چندکاربره روی رایانه Windows مالک، Docker Compose و LAN خانگی، با HTTPS مورد اعتماد دستگاه‌های آزمون. این گزینه حساب میزبانی یا پرداخت نمی‌خواهد؛ برق، سخت‌افزار موجود و اتصال شبکه لازم‌اند. «آنلاین» در این مرحله یعنی چند دستگاه به **یک API و یک PostgreSQL واقعی** وصل می‌شوند؛ دسترسی اینترنت عمومی، آزمون داخل شبکه اپراتورها و انتشار محصول با آن اثبات نمی‌شود.
14 +
15 +**مسیر جایگزین:** اجرای همین Compose روی یک سرور Linux موجود و در اختیار مالک داخل کشور، اگر مالک آن را انتخاب و مجاز کند. این توصیه خرید از ارائه‌دهنده ایرانی نیست. اگر چنین سروری وجود ندارد، Stage 0 ادامه می‌یابد؛ انتخاب خارجی تا رفع مانع پرداخت، احراز هویت و اثبات دسترسی داخل ایران باز می‌ماند.
16 +
17 +## مقایسه گزینه‌ها
18 +
19 +قیمت‌ها حاصل مشاهده صفحات رسمی در 2026-10-08 هستند، پیشنهاد خرید نیستند. **هیچ آزمون از داخل ایران اجرا نشده است.** ادعای فروشنده درباره ایران، دسترسی واقعی یا اعتبار IP را تأیید نمی‌کند.
20 +
21 +| گزینه | هزینه و مسیر پرداخت | ثبت‌نام / KYC | دسترسی ایران و اعتبار IP | HTTPS / PWA و محدودیت | نتیجه |
22 +|---|---|---|---|---|---|
23 +| Stage 0: رایانه Windows موجود + LAN | هزینه میزبانی صفر؛ بدون کارت یا حساب؛ ابزار Docker Desktop برای استفاده شخصی رایگان است [S1] | حساب میزبان ندارد؛ دانلود اولیه ابزار/ایمیج ممکن است برای توسعه‌دهنده نیازمند VPN یا انتقال آفلاین باشد | مسیر LAN وابسته به مسیریابی خارجی نیست؛ کارکرد روی LAN مالک **UNVERIFIED** تا اجرای دستگاهی؛ اعتبار IP عمومی مطرح نیست | mkcert و نصب CA فقط روی دستگاه‌های آزمون [S2,S3]؛ iPhone باید با IP واقعی LAN وارد شود؛ `localhost` روی گوشی به PC اشاره نمی‌کند | **گزینه اصلی توسعه و پذیرش خانوادگی محلی**؛ برق/خواب Windows و guest Wi-Fi می‌توانند ارتباط را قطع کنند |
24 +| سرور Linux موجود تحت کنترل مالک داخل کشور | خرید پیشنهاد نشده؛ هزینه واقعی زیرساخت موجود و IP **UNVERIFIED** | وابسته به مالک زیرساخت؛ دسترسی SSH و مجوز اجرای Docker لازم است | دسترسی اینترنتی اپراتورها و مسدود نبودن IP **UNVERIFIED**؛ داخلی بودن به‌تنهایی اثبات دسترسی نیست | همان Compose؛ گواهی معتبر برای دامنه مالک یا گواهی ارائه‌شده توسط مالک؛ دیتابیس فقط شبکه داخلی Docker | **جایگزین پس از تصمیم مالک**؛ نیازمند آزمون مستقل اپراتورها، پشتیبان و مالکیت عملیات |
25 +| TurkVPS.cloud، Istanbul / ترکیه | صفحه رسمی: 1 GB از $3.44، 2 GB از $4.50، 4 GB از $7.50 در ماه، IPv4 همراه پلن [S4]؛ پرداخت کارت یا USDT/TRX ادعا شده [S5]؛ قابلیت پرداخت مالک **UNVERIFIED** | سایت مدعی ثبت با ایمیل و بدون مدرک در مسیر رمزارز است؛ پذیرش اقامت ایران و اجرای واقعی این مسیر **UNVERIFIED** | عدد ~20 ms تهران صرفاً ادعای فروشنده است؛ نه probe داخل ایران. IP تحویلی/اعتبار/فیلتر نبودن **UNVERIFIED** [S7] | KVM/root امکان اجرای Linux/Docker و TLS را می‌دهد؛ این سازگاری استنتاج فنی است و این پشته روی سرویس اجرا نشده | فقط **نامزد تحقیق**. شروط فعلی: نبود مهلت پس از اتمام موجودی و حذف فوری داده؛ پرداخت رمزارزی بازپرداخت به مبدأ ندارد [S6]. بدون تأیید مالک انتخاب نمی‌شود |
26 +| VPS رایگان بلندمدت و بدون کارت | **گزینه قابل استفاده تأیید نشد**. Oracle Always Free وجود دارد اما مسیر عمومی کارت اعتباری/دبیت می‌خواهد [S8]؛ trial رایگان THE.Hosting فقط 3 روز است [S9] | Oracle اطلاعات معتبر می‌خواهد؛ trial مورد دوم KYC و اختیار رد درخواست دارد | پذیرش کاربر ایران، ظرفیت و دسترسی کاربر نهایی **UNVERIFIED** | حتی ماشین رایگان باید Docker، دیسک پایدار و TLS قابل دسترسی فراهم کند؛ حساب/ماشین ایجاد نشده | مبنای معماری یا وعده میزبانی رایگان قرار نمی‌گیرد |
27 +
28 +بسته روی یک Linux VM معمولی قابل اجرا طراحی می‌شود؛ حداقل عملی حافظه/دیسک و بار Argon2 باید با آزمون همین بسته تعیین شود. ارزان‌ترین پلن 1 GB از صرف مشاهده قیمت، مناسب کل پشته فرض نمی‌شود.
29 +
30 +**دام پرداخت:** Melbicom در UAE گزینه نزدیک دیگری است، اما طبق صفحه رسمی، اولین پرداخت برای KYC باید از روش دیگری انجام شود و رمزارز بعد از آن در دسترس است [S10]. BitPay ایران را در فهرست مناطق مسدود دارد [S11]. بنابراین عبارت «پذیرش رمزارز» مسیر پرداخت قابل استفاده برای مالک را اثبات نمی‌کند. Hetzner نیز رمزارز قبول نمی‌کند و روش‌های پرداختش لزوماً در همه کشورها ارائه نمی‌شوند [S12]. هیچ حسابی ساخته، ارائه‌دهنده‌ای تماس گرفته یا پرداختی انجام نشده است.
31 +
32 +## قرارداد بسته استقرار
33 +
34 +- فایل ریشه `docker-compose.yml` شامل API موجود، PostgreSQL و Nginx TLS است. فقط درگاه HTTPS لبه به LAN/میزبان منتشر می‌شود؛ PostgreSQL و API داخل شبکه Docker می‌مانند.
35 +- همان مبدأ `/` برای PWA، `/api/` برای API، `/health` برای probe و `/downloads/LifeGuide.apk` برای APK انتخاب‌شده مالک استفاده می‌شود. APK عمومی منتشر نمی‌شود؛ فایل تحویل باید با کلید واقعی مالک امضا شده باشد.
36 +- `config.json` حاوی تنظیمات عمومی زمان اجرا، بدون secret و بدون URL میزبانی کنارگذاشته‌شده است. CanvasKit و فونت‌ها باید همراه خروجی وب و از همان مبدأ سرو شوند.
37 +- `.env.example` فقط نام متغیرها/placeholder است. `.env`، کلید TLS، کلید امضا و backup در Git قرار نمی‌گیرند. کلمات عبور دیتابیس و کلید JWT در محیط محلی تولید و نگهداری می‌شوند؛ issuer/audience فعلی حفظ می‌شوند.
38 +- اسکریپت‌های `scripts/local-deploy.sh` و `scripts/local-deploy.ps1` مخصوص اجرای محلی‌اند. workflow استقرار به‌صورت پیش‌فرض خاموش است؛ وجود آن مجوز اجرای زنده نیست.
39 +- پشتیبان PostgreSQL از اسکریپت‌های موجود `backend/scripts/backup.sh` و `restore.sh` استفاده می‌کند. restore مخرب روی پایگاه مقصد باید فقط در مقصد آزمایشی یا با مجوز صریح عملیات انجام شود.
40 +- runbookها: [Stage 0](../operations/STAGE0.md)، [استقرار خودمیزبان](../operations/SELF_HOSTED_DEPLOYMENT.md)، [مهاجرت داخلی](../operations/DOMESTIC_MIGRATION.md). این ADR به‌تنهایی اثبات اجرای بسته، backup یا مهاجرت نیست؛ شواهد اجرا در گزارش تحویل ثبت می‌شود.
41 +
42 +## کارهای دستی مالک برای Stage 0
43 +
44 +1. Windows، WSL2 و Docker Desktop/Compose را طبق [مستند رسمی Docker][S1] آماده کنید. نیازی به ثبت حساب میزبان نیست. اگر دریافت اولیه وابستگی‌ها مسدود است، توسعه‌دهنده می‌تواند ایمیج‌ها و ابزارهای بررسی‌شده را آفلاین منتقل کند؛ کلاینت در زمان اجرا به registry وصل نمی‌شود.
45 +2. PC و Android/iPhone را به یک LAN مورد اعتماد متصل کنید؛ guest network یا client isolation را برای همین شبکه آزمون بررسی کنید. با `ipconfig` آدرس IPv4 کارت شبکه PC را پیدا کنید و در router برای آن DHCP reservation بگذارید. مثال `192.168.1.10` صرفاً نمونه است.
46 +3. mkcert را از [منبع رسمی][S2] نصب کنید و از ریشه مخزن در PowerShell اجرا کنید. مقدار مثال را با IP واقعی PC عوض کنید:
47 +
48 + ```powershell
49 + New-Item -ItemType Directory -Force deployment/tls | Out-Null
50 + mkcert -install
51 + mkcert -cert-file deployment/tls/server.pem -key-file deployment/tls/server-key.pem 192.168.1.10 localhost 127.0.0.1
52 + mkcert -CAROOT
53 + ```
54 +
55 + فقط `rootCA.pem` را از مسیر آخر روی دستگاه‌های شخصی آزمون منتقل کنید. `rootCA-key.pem` و `server-key.pem` را در چت، Git، APK یا دستگاه‌های دیگر قرار ندهید. CA محلی برای انتشار کاربران عمومی نیست.
56 +4. iPhone/iPad: گواهی را روی دستگاه باز و profile را در Settings نصب کنید؛ سپس Settings → General → About → Certificate Trust Settings، full trust همان CA را فعال کنید [S3]. Safari باید URL HTTPS بدون هشدار گواهی باز کند. Android: CA را از تنظیمات امنیت دستگاه به‌عنوان CA certificate نصب کنید؛ فقط نسخه توسعه مجاز است این CA را برای اتصال اپ قبول کند. نصب CA به‌تنهایی برای transport مبتنی بر Dart اثبات اعتماد نیست؛ آزمون app/TLS واقعی باید انجام شود. در release، اعتماد عمومی سیستم حفظ می‌شود و دورزدن اعتبارسنجی TLS مجاز نیست [S13].
57 +5. اسکریپت Stage 0 در اولین اجرا `.env` را از نمونه، با secretهای تصادفی محلی و origin انتخاب‌شده می‌سازد؛ `.env` قبلی را خودکار بازنویسی نمی‌کند. origin/API runtime را روی `https://<LAN-IP>` بگذارید. دستور مورد انتظار بسته از ریشه مخزن:
58 +
59 + ```powershell
60 + ./scripts/local-deploy.ps1 -Origin https://192.168.1.10 -Certificate deployment/tls/server.pem -PrivateKey deployment/tls/server-key.pem -Project lifeguide-stage0
61 + ```
62 +
63 + IP مثال باید عوض شود. جزئیات build، migration و ایجاد `config.json` در [STAGE0.md](../operations/STAGE0.md) است. این دستور روی Windows مالک **UNVERIFIED** است؛ گزارش اجرای Linux/Compose جای آن را نمی‌گیرد. `docker compose config` خروجی secretدار می‌تواند داشته باشد؛ آن را عمومی یا در چت ارسال نکنید.
64 +6. اگر Windows Firewall مانع ارتباط است، فقط TCP 443 را روی Private profile و `LocalSubnet` برای LAN مورد اعتماد باز کنید. port-forward روی router، تونل عمومی، DNS عمومی یا دسترسی WAN در این مرحله انجام ندهید. دستور نمونه با PowerShell مدیر برای همین PC:
65 +
66 + ```powershell
67 + New-NetFirewallRule -DisplayName 'LifeGuide Stage 0 HTTPS' -Direction Inbound -Action Allow -Protocol TCP -LocalPort 443 -Profile Private -RemoteAddress LocalSubnet
68 + ```
69 +
70 +7. Safari را به `https://<LAN-IP>/` ببرید، با حساب والد **آزمایشی** وارد شوید و Share → Add to Home Screen را اجرا کنید. Android را روی همین مبدأ تنظیم کنید. سناریوی چندکاربره باید API/DB مشترک را بررسی کند؛ ذخیره محلی یا صفحه بازشده بدون داده کافی نیست.
71 +8. تست شبکه `scripts/reachability-smoke.mjs` را طبق runbook اجرا کنید. برای CA محلی می‌توان Node را با `NODE_EXTRA_CA_CERTS` حاوی مسیر **گواهی عمومی** rootCA اجرا کرد؛ از `NODE_TLS_REJECT_UNAUTHORIZED=0` یا گزینه skip TLS استفاده نکنید. نتیجه باید TLS، `/health`، PWA و round-trip داده آزمایشی را جدا نشان دهد. پاسخ 200 health به‌تنهایی CRUD/مجوز/همگام‌سازی را تأیید نمی‌کند.
72 +9. پس از آزمون، وضعیت خواب PC، روشن بودن Docker، آخرین sync و backups را بررسی کنید. هنگام پایان استفاده از CA آزمایشی، profile/trust آن را از دستگاه‌ها حذف کنید؛ rule فایروال را می‌توان با `Remove-NetFirewallRule -DisplayName 'LifeGuide Stage 0 HTTPS'` حذف کرد.
73 +
74 +## تصمیم بعدی میزبانی عمومی، فقط توسط مالک
75 +
76 +1. ابتدا Stage 0 و آزمون‌های API/مجوز/backup/restore با داده ساختگی را تمام کنید. انتخاب یک VPS بدون این شواهد، نقص برنامه را حل نمی‌کند.
77 +2. برای نامزد خارجی، مالک باید قبل از ثبت/پرداخت از مسیر مجاز خود، پذیرش اقامت ایران، KYC، روش پرداخت اولیه/تمدید، شرایط حذف داده، مالکیت IP و سیاست بازپرداخت را تأیید کند. تیم در این نوبت پیام یا درخواست به فروشنده نمی‌فرستد. هیچ ادعای vendor درباره رمزارز به‌عنوان مسیر عملی پرداخت مالک پذیرفته نشده است.
78 +3. پس از انتخاب و مجوز مالک، فقط داده ساختگی روی میزبان خارجی قرار می‌گیرد. دسترسی دامنه/IP واقعی باید از چند اپراتور داخل ایران، بدون VPN، با زمان، TLS و نتیجه PWA/API/APK ثبت شود. تست از محیط توسعه خارجی و looking glass جای این پذیرش را نمی‌گیرد.
79 +4. مالک دامنه/IP و گواهی را انتخاب و تغییر DNS یا انتشار را جداگانه مجاز می‌کند. endpointها به یک origin می‌روند؛ دیتابیس مدیریت‌شده یا CDN خارجی زمان اجرا اضافه نمی‌شود. IP reputation، دسترسی IPv4، چرخه تمدید TLS و دسترسی هنگام اختلال اینترنت باید بررسی شوند؛ اعلام fallback URL مجوز ارسال داده به میزبان دیگری نیست.
80 +5. برای استفاده واقعی خانوادگی، private notes، چت AI، سلامت/چرخه و داده حساس روانی روی میزبان خارجی منتقل نمی‌شود. درگاه‌های حقوقی/رضایت برای کودکان و نگهداری داده سلامت در کشور باید جدا تعیین شوند؛ این ADR آن‌ها را پیاده‌سازی یا تأیید حقوقی نمی‌کند. AI/voice خارجی خاموش می‌ماند.
81 +6. مهاجرت به سرور داخلی باید با [runbook مهاجرت](../operations/DOMESTIC_MIGRATION.md)، backup/restore آزمایشی، صحت نسخه/env، برنامه توقف نوشتن و rollback انجام شود. `pg_dump/restore` محلی با داده ساختگی می‌تواند اجرا و ثبت شود؛ انتقال داده واقعی، DNS cutover و خاموشی میزبان قبلی در این کار **انجام نشده و UNVERIFIED** هستند.
82 +
83 +## شواهد و حدود اعتبار
84 +
85 +تحقیق صفحات رسمی و مطالعه کد مخزن انجام شد؛ هیچ account، VM، DNS، deploy زنده، پرداخت یا migration داده واقعی انجام نشد. دسترسی داخل ایران، نصب روی Windows مالک، TLS Android واقعی، Safari Add to Home Screen و عملکرد میزبان خارجی **UNVERIFIED** تا اجرای پذیرش مربوط‌اند. ریز مشاهده‌ها در [یادداشت تحقیق](../audits/2026-10-08-hosting-research.md) ثبت است.
86 +
87 +[S1]: https://docs.docker.com/desktop/setup/install/windows-install/
88 +[S2]: https://github.com/FiloSottile/mkcert
89 +[S3]: https://support.apple.com/en-us/102390
90 +[S4]: https://turkvps.cloud/
91 +[S5]: https://turkvps.cloud/buy-turkey-vps-crypto
92 +[S6]: https://turkvps.cloud/terms
93 +[S7]: https://turkvps.cloud/looking-glass
94 +[S8]: https://www.oracle.com/cloud/free/faq/
95 +[S9]: https://the.hosting/en/test-vps
96 +[S10]: https://www.melbicom.net/solutions/buy-server-with-usdt/
97 +[S11]: https://support.bitpay.com/hc/en-us/articles/360000123366-What-countries-or-jurisdictions-does-BitPay-support
98 +[S12]: https://docs.hetzner.com/general/billing-and-account-management/billing-at-hetzner/payment-overview/
99 +[S13]: https://developer.android.com/privacy-and-security/security-config
docs/decisions/0010-lifeguide-naming.md new
+14
@@ -0,0 +1,14 @@
1 +# ADR-0010 — نام LifeGuide و هویت پایدار انتشار
2 +
3 +- Status: Accepted — دستور صریح مالک، 2026-10-08
4 +- Product: **LifeGuide / لایف‌گاید**
5 +- Android application ID: **ir.lifeguide.app**؛ پس از انتشار تغییر نمی‌کند.
6 +- Signed release filename: **LifeGuide.apk**؛ debug: **LifeGuide-debug.apk**.
7 +
8 +برند در label، PWA، صفحات، ایمیل‌ها و مستندات جاری LifeGuide است. نام مخزن `davoodmehraban89/LifeMate`، مسیر `apps/lifemate`، package داخلی Dart/Node، منابع داخلی drawable و قرارداد JWT issuer=`lifemate`/audience=`lifemate-api` حفظ می‌شوند. تغییر این قراردادها به‌عنوان تغییر نام ظاهری مجاز نیست. کلاس داخلی `LifeMateApp` برای سازگاری آزمون‌های موجود باقی می‌ماند و نام نمایشی نیست.
9 +
10 +نام‌های تاریخی در اسناد تصمیم/آزمون قدیمی با وضعیت تاریخی حفظ می‌شوند. [ممیزی نام‌ها](../audits/2026-10-08-naming.md) هر occurrence باقی‌مانده در فایل‌های متنی Git را طبقه‌بندی می‌کند؛ `python3 scripts/audit-naming.py --check` باقی‌ماندن نام نمایشی قبلی در کلاینت و workflow جاری را رد می‌کند.
11 +
12 +شناسه جدید جایگزین `com.example.lifemate` است؛ نصب قبلی با شناسه قدیمی به‌صورت خودکار upgrade نمی‌شود. پاک‌کردن نصب قدیمی یا انتقال داده آن بدون تصمیم مستقل مجاز نیست. کلید امضای واقعی مالک بیرون Git و chat می‌ماند. ساخت release بدون secretها یا با گواهی Android Debug رد می‌شود؛ این کنترل source جای اثبات نصب/ارتقای واقعی را نمی‌گیرد. release امضاشده، ارتقا و کلید مالک **UNVERIFIED** تا اجرای مربوط‌اند.
13 +
14 +شماره تکراری ADR-0004 رفع شد: Flutter به ADR-0007 منتقل شد؛ ADR-0004 مخصوص AI/privacy باقی ماند. ADR-0005 Supabase Superseded است؛ ترجیح میزبانی قدیمی ADR-0006 با ADR-0009 جایگزین شد.
docs/final/DELIVERY.md
+2
@@ -1,3 +1,5 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 # LifeMate Feature 1 — Final Delivery
4
5 ## Installable outputs
docs/final/THREE_PHASE_AUDIT.md
+2
@@ -1,3 +1,5 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 # LifeMate — Final Three-Phase Audit
4
5 Date: 2026-10-05
docs/history/2026-10-05-project-state.md new
+65
@@ -0,0 +1,65 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 +# LifeMate — Project State
4 +
5 +**Last updated:** 2026-10-05
6 +**Phase:** Phase 5 — Hardening, Observability & Release — COMPLETE
7 +**Repository:** `davoodmehraban89/LifeMate`
8 +**Working product name:** LifeMate — approved
9 +
10 +## Transfer checkpoint
11 +Phases 1–5 engineering core are complete. LifeMate now has the foundation/identity, planner-school-family core, advisory learning/wellbeing guides, and the operational hardening/release-readiness layer required for a controlled beta. Public production release and minor-sensitive external AI/voice exposure remain intentionally gated and require separate explicit approval.
12 +
13 +## Five-phase roadmap
14 +1. **Foundation, Product Contract & UX Direction** — COMPLETE
15 +2. **Product Foundation & Identity** — COMPLETE
16 +3. **Planner, School & Family Core** — COMPLETE
17 +4. **AI Guides, Learning & Wellbeing** — COMPLETE
18 +5. **Hardening, Observability & Release** — COMPLETE
19 +
20 +## Accepted architecture baseline
21 +- Flutter Android + responsive Web/PWA; future packaged/native iOS path preserved.
22 +- Provider-neutral Node API + PostgreSQL; Railway remains staging host.
23 +- LifeMate-owned identity/session adapter; server-side relationship-aware authorization.
24 +- Offline client support does not replace server authority.
25 +- AI guides are advisory and plan proposals require explicit acceptance.
26 +- Wellbeing/AI transcripts remain owner-private; family membership does not grant transcript access.
27 +
28 +## Phase 4 completed vertical slice
29 +Learning goal → learning check-in → wellbeing check-in → AI guide session → safety classification → advisory response → explicit plan proposal → accept/reject decision. No guide response silently mutates planner state.
30 +
31 +### Verified Phase 4 gates
32 +- Migration `0004_ai_learning_wellbeing.sql` defines seven Phase 4 tables, including the separate `wellbeing_safety_event` ledger, and owner-oriented indexes.
33 +- Phase 4 API implements learning goals/check-ins, private/guardian-summary wellbeing check-ins, AI sessions/messages, explicit proposal decisions, guardian wellbeing summaries and privacy-preserving family guidance.
34 +- High-risk self-harm language follows a fixed urgent-support path and writes a separate safety signal; ordinary family membership never grants raw wellbeing notes or AI transcripts.
35 +- Study/planner/wellbeing guidance is advisory, non-diagnostic and never silently mutates planner data.
36 +- Flutter includes interactive guide chat, learning goals/check-ins, wellbeing check-ins, guardian summary and parent family-guidance flows.
37 +- ADR `docs/decisions/0004-ai-learning-wellbeing-safety.md` records privacy, provider, voice and production safety gates.
38 +
39 +## Phase 5 completed scope
40 +- Production-entrypoint request correlation, security headers, privacy-safe structured request/error telemetry and bounded request bodies.
41 +- Configurable general/auth/AI fixed-window rate limits with HTTP 429 and `Retry-After`.
42 +- Separate `/live` and database-backed `/ready` operational probes while retaining `/health` compatibility.
43 +- PostgreSQL-native backup/restore scripts plus an automated CI data round-trip restore drill.
44 +- Release regression gates for backend tests/syntax/audit/schema, secret scanning, Flutter format/analyze/tests, Web release build, Android build and PWA install/RTL metadata.
45 +- Deployment, rollback, backup/restore, incident-response and production-readiness runbooks plus changelog/version discipline.
46 +- Railway staging API function hardened with request IDs, security headers, rate limiting, `/live`, `/ready` and privacy-safe error handling; staging tracing and auto-instrumentation enabled.
47 +
48 +### Verified Phase 5 gates
49 +- Red-first operations contract was observed failing before the hardening implementation; subsequent backend contract/integration tests passed.
50 +- GitHub Actions run 165 at branch commit `125c44f55827dc5ed26d81fe821969348db4598e` completed successfully: security, backend and Flutter jobs all green.
51 +- Backend run 165 passed migrations, authorization tests, dependency audit, 11 Node tests, syntax checks, 28-table schema verification and the backup/restore data round-trip drill.
52 +- Flutter run 165 passed formatting, analysis, widget/tests, PWA release metadata checks, Web release build and Android debug build.
53 +- Railway staging deployment `0cd21bed-5cba-494b-afef-7f45312f2fdf` is SUCCESS/online with no reported warnings or critical issues after Phase 5 hardening.
54 +- Railway staging source inspection confirms the operational middleware and `/live` + `/ready` routes are deployed; external AI/voice remain unenabled and Phase 4 AI continues in local-fallback mode.
55 +
56 +## Production-gate items intentionally deferred
57 +Jurisdiction-specific legal/guardian consent review; final safety severity taxonomy; emergency resource localization; external AI provider privacy/retention review; wellbeing retention/export/deletion policy; voice-provider privacy review; production push-provider configuration; final device beta acceptance. These are release gates, not missing Phase 5 engineering-core work.
58 +
59 +## Release status
60 +Engineering phases 1–5: COMPLETE.
61 +Controlled family beta: READY FOR OWNER-APPROVED DEVICE TESTING.
62 +Public production deployment/release: NOT PERFORMED.
63 +
64 +## Guardrail
65 +AI/wellbeing production exposure stays disabled until dedicated safety/legal/provider gates pass. Production deploys, destructive migrations, public release and sensitive access changes require explicit action-specific approval.
docs/operations/DEPLOYMENT.md
+1 -1
@@ -1,6 +1,6 @@
1 # Deployment Runbook
2
3 -LifeMate uses staging before production. Normal engineering changes deploy to staging first and are verified there before any production decision.
3 +LifeGuide uses staging before production. Local staging uses the Stage 0 Compose package. No live staging/server change is authorized by routine development. See SELF_HOSTED_DEPLOYMENT.md and STAGE0.md; any live change needs explicit approval.
4
5 ## Staging
6 1. Confirm branch CI is green: security, backend, backup/restore and Flutter jobs.
docs/operations/DOMESTIC_MIGRATION.md new
+51
@@ -0,0 +1,51 @@
1 +# LifeGuide — انتقال به سرور داخلی و بازگشت
2 +
3 +این runbook همان Compose و PostgreSQL مستقل را منتقل می‌کند. **انتقال واقعی خانواده، DNS cutover، deploy سرور داخلی و rollback زنده در این کار اجرا نشده‌اند و UNVERIFIED هستند.** تنها drill با داده ساختگی محلی، پس از ثبت خروجی، می‌تواند VERIFIED شود. private notes، AI chat، wellbeing/چرخه و داده روانی کودکان نباید روی میزبان خارجی قرار بگیرند؛ درگاه حقوقی/رضایت و محل نگهداری داخلی جدا لازم‌اند.
4 +
5 +## drill قابل اجرا بدون داده واقعی
6 +
7 +بعد از بالا آمدن Stage 0:
8 +
9 +```bash
10 +bash scripts/restore-drill.sh --synthetic-only
11 +```
12 +
13 +script از Docker محلی استفاده می‌کند، دو نام DB تازه با prefix `lifeguide_drill_` می‌سازد، migrations موجود را اجرا، fixture موجود `backend/scripts/restore-smoke.sql` و fixture خانواده ساختگی `deployment/restore-fixture.sql` را درج و scripts موجود `backup.sh`/`restore.sh` را اجرا می‌کند. در مقصد، حساب/profile، شمار کامل migrationها، دسترسی guardian مجاز، عدم دسترسی او به تکلیف خصوصی، عدم دسترسی والد نامرتبط و مجموع ۶۰۰ ثانیه interval مطالعه با وقفه را بررسی و فقط همین دو DB تازه را پاک می‌کند. دیتابیس برنامه و volume آن دست‌نخورده‌اند. خروجی `PASS ... preserved` شاهد drill است؛ موفقیت syntax/build به‌تنهایی شاهد restore نیست.
14 +
15 +اجرای محلی Linux/Docker مورخ ۲۰۲۶-۱۰-۰۸، ۱۵:۲۳ UTC با PostgreSQL16، **PASS** بود: `identity, family permissions, private task, paused study intervals and 10 migrations preserved`. این شاهد، انتقال واقعی، DNS و سرور داخلی مالک را تأیید نمی‌کند.
16 +
17 +## مراحل دستی انتقال واقعی، فقط پس از مجوز
18 +
19 +1. origin/DNS و سرور داخلی را مالک تعیین کند. imageهای دقیق و versioned، PostgreSQL16 و ظرفیت دیسک مقصد را بررسی کنید. مقصد باید database تازه و خالی داشته باشد. پیش از اتصال کاربران، همان Compose روی مقصد با داده **ساختگی** آزمون شود.
20 +2. schema/version، migration ledger، roleهای DB و envهای لازم را فهرست کنید. secretها فقط کانال امن/secret management؛ در issue/chat/docs قرار نگیرند. نام جدول/SQL function و قراردادهای JWT تغییر نمی‌کنند. زمان UTC، CORS و PUBLIC_APP_URL مطابق origin مقصد شوند. API/PWA/APK همه همان origin هستند.
21 +3. بازه توقف نوشتن را تعیین و مشتری‌ها را از maintenance آگاه کنید. API/gateway قدیمی را متوقف یا route نوشتن را در لایه مالک مسدود کنید؛ فقط نمایش stale/offline معتبر مجاز است. queueهای دستگاه تا پایان انتقال server acknowledgement جدید نمی‌گیرند.
22 +4. از دیتابیس منبع `pg_dump --format=custom --no-owner --no-privileges` با `backend/scripts/backup.sh` بگیرید. checksum SHA256 و snapshot/backup قبل از انتقال را ثبت کنید. dump را رمزگذاری و از مسیر امن به **داخل کشور** انتقال دهید؛ به مقصد خارجی یا CDN منتقل نشود.
23 +5. روی DB تازه مقصد و فقط با مجوز restore، `backend/scripts/restore.sh` را با DATABASE_URL و PGPASSWORD امن اجرا کنید. script از `--clean --if-exists` استفاده می‌کند؛ **نباید به DB دارای داده جدید اشاره کند**. نسخه source/backups را حفظ کنید. سپس migration ledger و `docker compose run --rm migrate` را با نسخه تاییدشده بررسی کنید.
24 +6. تعداد رکوردهای کلیدی، مالکیت، خانواده/guardian، تاریخ‌ها، revoked sessions و policyهای خصوصی را با query و API مستقل بررسی کنید؛ private data در log نیاید. سناریوی ۸ مرحله‌ای با fixture جدید و تست restore نشست/Sync را اجرا کنید. مقصد هنوز public نیست.
25 +7. مالک پس از پذیرش، DNS/endpoint را cutover کند. TTL قبلی و مدت caching را در نظر بگیرید؛ endpoint runtime با `config.json` no-store و تنظیم Android قابل تغییر است. همه originهای fallback باید متعلق به همان سامانه تأییدشده باشند؛ fallback به DB مستقل جدید، Sync امن نیست. TLS hostname و Safari نصب‌شده را دوباره آزمون کنید.
26 +8. منبع قدیمی را تا پایان بازه rollback حفظ و در حالت **بدون نوشتن** نگه دارید. دو DB هم‌زمان قابل نوشتن باعث divergence می‌شوند. پس از پایان بازه و مجوز مالک، خاموشی/حذف منبع انجام شود.
27 +
28 +دستورهای زیر فقط الگوی اجرای دستی اپراتور **بعد از مجوز** هستند؛ به سرور source/target وصل نمی‌شوند و باید در terminal همان میزبان، با `.env` درست اجرا شوند. source و target باید تشخیص داده شوند؛ قبل از restore، مقصد تازه و خالی را بررسی کنید.
29 +
30 +```bash
31 +# SOURCE، پس از توقف نوشتن مجازشده
32 +docker compose stop api gateway
33 +docker compose exec -T backup /opt/lifeguide/backup.sh /backups/LifeGuide-transfer.dump
34 +docker compose cp backup:/backups/LifeGuide-transfer.dump ./LifeGuide-transfer.dump
35 +sha256sum LifeGuide-transfer.dump
36 +# انتقال امن/رمزگذاری‌شده dump، imageها و env توسط اپراتور؛ هیچ upload خودکار ندارد.
37 +
38 +# TARGET تازه، با TLS/env آماده، پیش از public کردن
39 +docker compose up -d --wait postgres backup
40 +docker compose cp ./LifeGuide-transfer.dump backup:/backups/LifeGuide-transfer.dump
41 +docker compose exec -T backup /opt/lifeguide/restore.sh /backups/LifeGuide-transfer.dump
42 +docker compose run --rm migrate
43 +docker compose up -d --wait api gateway
44 +node scripts/reachability-smoke.mjs https://OWNER_APPROVED_ORIGIN
45 +```
46 +
47 +در صورت snapshot فایل قدیمی با همان نام، قبل از backup نام یکتا انتخاب کنید؛ نسخه بازیابی معتبر قبلی را overwrite نکنید. این الگوی **restore واقعی UNVERIFIED** است. اجرای drill محلی، حفظ ledger و representative rows را می‌سنجد؛ جای مقایسه کامل policy/data و پذیرش cutover واقعی نیست.
48 +
49 +## بازگشت
50 +
51 +اگر مقصد هنوز نوشتن جدید ندارد، مالک می‌تواند DNS/endpoint را به منبع read-only حفظ‌شده برگرداند و بعد از بررسی مجوزها نوشتن را فعال کند. اگر مقصد داده جدید دارد، ابتدا backup کامل آن بگیرید؛ برگشت مستقیم به dump قدیمی آن نوشته‌ها را از بین می‌برد. reconciliation/restore معکوس باید با plan، حفظ هر دو نسخه و مجوز جدا انجام شود. rollback بدون بررسی Login/CRUD/Sync و داده تازه کامل نیست.
docs/operations/SELF_HOSTED_DEPLOYMENT.md new
+29
@@ -0,0 +1,29 @@
1 +# LifeGuide — بسته مستقل از میزبان
2 +
3 +Compose مشترک از `docker-compose.yml` استفاده می‌کند: API با Node22 و Argon2 native، PostgreSQL16 داخلی، migration با ledger موجود، nginx TLS برای PWA/API/APK و cron backup با scripts موجود. `/api` از همان origin به API می‌رود. `deployment/runtime-config.json` در runtime mount می‌شود و `Cache-Control: no-store` دارد؛ API URL داخل Dockerfile نیست. فونت/CanvasKit باید از artifact محلی PWA ارائه شوند؛ check ساخت کلاینت این شرط را بررسی می‌کند.
4 +
5 +Stage 0 محلی در [STAGE0.md](STAGE0.md) است. انتقال این بسته به سرور داخلی انتخاب‌شده، ثبت حساب، هزینه، DNS، deploy زنده و تغییر سرور **فقط پس از تصمیم و مجوز صریح مالک** است. در این کار اجرا نشده‌اند و **UNVERIFIED** هستند. Railway و معماری managed خارجی مسیر فعال این بسته نیستند.
6 +
7 +## آماده‌سازی سرور، دستور دستی پس از مجوز
8 +
9 +شبکه داخلی `proxy` فقط API و gateway را وصل می‌کند. alias `api-proxy` فقط در همین شبکه است و gateway IP ثابت `GATEWAY_PROXY_IP` دارد. API فقط همین IP با `/32` را برای forwarded address قابل اعتماد می‌داند؛ nginx `X-Forwarded-For` ورودی را با peer واقعی جایگزین می‌کند. PostgreSQL روی شبکه دیگری است و هیچ host port برای API/DB منتشر نمی‌شود. برای جلوگیری از تداخل با LAN/VPN/Docker دیگر، `PROXY_SUBNET` و `GATEWAY_PROXY_IP` را **با هم** در `.env` انتخاب کنید؛ IP gateway باید داخل همان subnet باشد. CIDR وسیع عمومی یا trust-all مجاز نیست. تنظیم proxy خارج Compose به‌صورت پیش‌فرض اعتماد ندارد.
10 +
11 +1. مالک سرور، origin/IP، پرداخت قابل انجام، دسترسی بدون VPN از ایران و مسیر تمدید TLS را تأیید کند. قبل از استقرار، از حداقل دو اپراتور داخل ایران تست شبکه انجام شود.
12 +2. Docker/Compose را نصب و snapshot/backup قابل بازیابی تهیه کنید. همان کد و imageهای versioned بررسی‌شده را به میزبان منتقل کنید؛ build در سرور الزام نیست. imageها را می‌توان با `docker save/load` آفلاین انتقال داد.
13 +3. `.env.example` را به `.env` کپی و secretها را در محیط/secret management میزبان تولید کنید. نام schemaها، JWT issuer=`lifemate` و audience=`lifemate-api` تغییر نمی‌کند. روی انتقال دیتابیس، secret JWT را مطابق سیاست نشست حفظ یا با اطلاع کاربر rotate کنید؛ عوض کردن آن کاربران را خارج می‌کند.
14 +4. گواهی معتبر برای همان origin را **مالک/اپراتور** تهیه و مسیرهای `TLS_CERT_PATH`/`TLS_KEY_PATH` را تنظیم کند. Compose به‌صورت خودکار Let's Encrypt، DNS یا سرویس خارجی را تغییر نمی‌دهد. برای عمومی کردن سرویس، mkcert مناسب کاربران عمومی نیست. تمدید گواهی باید توسط اپراتور زمان‌بندی و بعد از آن `docker compose exec gateway nginx -s reload` اجرا شود.
15 +5. فقط پورت HTTPS لازم را در فایروال مجاز کنید. PostgreSQL/API port مستقیم منتشر نشود. `PUBLIC_APP_URL`/`CORS_ORIGINS` و runtime config باید به همان مبدأ اشاره کنند؛ redirect/CDN خارجی اضافه نشود.
16 +6. بعد از backup و مجوز migrations، Compose را build/load کنید، DB را بالا بیاورید، `docker compose run --rm migrate` و سپس API/gateway/backup را با `--wait` اجرا کنید. این دستورات برای اپراتور هستند؛ تیم این نوبت آن‌ها را روی میزبان زنده اجرا نکرده است.
17 +7. smoke test با TLS معتبر و credential ساختگی و پذیرش Android/Safari/مجوزها را ثبت کنید. provider ایمیل/SMS تا انتخاب و پیکربندی مالک غیرفعال است؛ ثبت حساب pending، تحویل واقعی پیام نیست.
18 +
19 +## rollback
20 +
21 +imageها را پیش از rollout با tag یکتا و SHA ثبت کنید، مثل `API_IMAGE=lifeguide-api:<commit>` و `WEB_IMAGE=lifeguide-web:<commit>`. کپی خصوصی `.env`، نسخه config، fingerprint گواهی و آخرین backup معتبر را نگه دارید.
22 +
23 +اگر schema با نسخه قبل سازگار است: نوشتن را متوقف، image tagهای قبلی را در `.env` برگردانید و **بدون build و بدون اجرای migration جدید** `docker compose up -d --no-build --no-deps api gateway` را اجرا کنید. سپس health، ورود و CRUD ساختگی را بررسی کنید. داده volume حفظ می‌شود. downgrade schema و restore داده واقعی نیاز به مجوز جدا دارند؛ روی schema ناسازگار فقط عوض کردن image معتبر نیست. قبل از restore، از وضع فعلی backup بگیرید. مراحل انتقال/بازگشت در [DOMESTIC_MIGRATION.md](DOMESTIC_MIGRATION.md) است.
24 +
25 +## backup و health
26 +
27 +`/live` حیات API، `/ready` ارتباط DB و `/health` probe سازگار قبلی است. gateway health داخلی روی 8081 است و publish نمی‌شود. cron backup از `backend/scripts/backup.sh` استفاده می‌کند؛ custom-format/no-owner/no-privileges. `pg_restore --list` فقط خوانایی archive را می‌سنجد، جای restore drill نیست. اجرای `bash scripts/restore-drill.sh --synthetic-only` دو DB تازه ایجاد می‌کند و هیچ DB موجود را restore/drop نمی‌کند. dumpها و TLS keys خارج Git و chat می‌مانند.
28 +
29 +backup cron داخل container با UTC اجرا می‌شود، retention پیش‌فرض ۱۴ روز است. export/رمزگذاری/off-PC backup و restore زمان‌بندی‌شده بر عهده اپراتور است. container cron خاموش، PC خوابیده یا دیسک پر، backup جدید نمی‌سازد؛ status آن باید پایش شود. تغییر password در `.env` خودکار password role داخل PostgreSQL volume قدیمی را عوض نمی‌کند؛ برای rotation، runbook و مجوز عملیات DB لازم است.
docs/operations/STAGE0.md new
+74
@@ -0,0 +1,74 @@
1 +# LifeGuide / لایف‌گاید — Stage 0 روی LAN
2 +
3 +این بسته Node/Express، PostgreSQL و PWA را روی **یک PC محلی** با یک مبدأ HTTPS اجرا می‌کند. حساب، پرداخت، DNS عمومی، تونل و port-forward ندارد. این راهنما دستور اجرای مالک است؛ اجرای Windows، Android واقعی و Safari واقعی تا ثبت شواهد **UNVERIFIED** هستند. توصیه میزبانی در [ADR 0009](../decisions/0009-provider-neutral-hosting.md) است.
4 +
5 +## آماده‌سازی Windows
6 +
7 +1. Docker Desktop با WSL2، Git، Node >=22 و mkcert را نصب کنید. گوشی‌ها و PC به LAN مورد اعتماد متصل باشند. IP محلی PC را با `ipconfig` پیدا و DHCP آن را ثابت کنید. دریافت اولیه وابستگی‌ها ممکن است به VPN توسعه‌دهنده نیاز داشته باشد؛ اجرای کلاینت CDN خارجی ندارد.
8 +2. از ریشه مخزن، در PowerShell، IP نمونه را عوض کنید:
9 +
10 + ```powershell
11 + New-Item -ItemType Directory -Force deployment/tls | Out-Null
12 + mkcert -install
13 + mkcert -cert-file deployment/tls/server.pem -key-file deployment/tls/server-key.pem 192.168.1.10 localhost 127.0.0.1
14 + mkcert -CAROOT
15 + ./scripts/local-deploy.ps1 -Origin https://192.168.1.10
16 + ```
17 +
18 + اولین اجرا `.env` را با secretهای تصادفی می‌سازد؛ اجراهای بعدی آن را حفظ می‌کنند. فایل `.env`، کلید سرور و rootCA-key خصوصی هستند و باید خارج Git بمانند. فقط **گواهی عمومی** rootCA.pem را به گوشی آزمون منتقل کنید. CA خصوصی را هرگز منتقل نکنید.
19 +3. فقط در صورت نیاز، PowerShell مدیر، rule فایروال محدود به LAN بسازید:
20 +
21 + ```powershell
22 + New-NetFirewallRule -DisplayName 'LifeGuide Stage 0 HTTPS' -Direction Inbound -Action Allow -Protocol TCP -LocalPort 443 -Profile Private -RemoteAddress LocalSubnet
23 + ```
24 +
25 +4. iOS: profile گواهی عمومی را نصب و Settings → General → About → Certificate Trust Settings، full trust همان CA را فعال کنید. Safari باید `https://192.168.1.10/` را بدون هشدار TLS باز کند؛ سپس Share → Add to Home Screen. روی Android، اعتماد اپ Dart به CA نصب‌شده باید مستقلاً آزموده شود؛ نصب CA به‌تنهایی شاهد نیست. نسخه release نباید TLS را دور بزند. برای APK debug توسعه، گواهی عمومی mkcert را صریحاً به build بدهید:
26 +
27 + ```powershell
28 + $caRoot = mkcert -CAROOT
29 + $publicCa = [Convert]::ToBase64String([IO.File]::ReadAllBytes((Join-Path $caRoot 'rootCA.pem')))
30 + Set-Location apps/lifemate
31 + flutter build apk --debug --dart-define="LIFEGUIDE_DEBUG_CA_BASE64=$publicCa"
32 + Set-Location ../..
33 + ```
34 +
35 + این فرمان **UNVERIFIED روی Android واقعی** است. فقط public CA وارد context اعتماد debug می‌شود؛ هیچ callback برای قبول گواهی نامعتبر وجود ندارد. این define در profile/release رد می‌شود. APK debug جای APK رسمی امضاشده نیست و اگر نسخه با گواهی متفاوت نصب باشد ارتقای درجا ممکن نیست؛ داده واقعی را در نسخه توسعه وارد نکنید.
36 +
37 +## حساب و round-trip ساختگی
38 +
39 +اگر شبکه توسعه از proxy با CA سازمانی استفاده می‌کند، فقط گواهی **عمومی** آن را در `BUILD_CA_FILE` تنظیم کنید. script از override اختیاری `docker-compose.build-proxy.yml` و BuildKit secret استفاده می‌کند؛ گواهی یا proxy URL داخل کلاینت نهایی قرار نمی‌گیرد. TLS verification خاموش نمی‌شود. این گزینه مخصوص build است؛ CA اعتماد Stage 0 روی گوشی، گواهی جداگانه mkcert است.
40 +
41 +این fixture، فقط برای دیتابیس تازه Stage 0 است؛ تحویل واقعی ایمیل/SMS را اثبات نمی‌کند. رمز را خودتان تولید و فقط در محیط محلی نگه دارید. ثبت/ورود کاربران محصول باید از API عادی بگذرد.
42 +
43 +```powershell
44 +$env:SYNTHETIC_PASSWORD = '<یک رمز آزمایشی تصادفی حداقل ۱۰ کاراکتر>'
45 +docker compose exec -e ALLOW_SYNTHETIC_SEED=yes -e SYNTHETIC_PASSWORD api node scripts/seed-compose-smoke.js
46 +$env:SMOKE_EMAIL = 'compose-smoke@lifeguide.test'
47 +$env:SMOKE_PASSWORD = $env:SYNTHETIC_PASSWORD
48 +$env:SMOKE_ALLOW_SYNTHETIC_WRITE = 'yes'
49 +$env:ROOT_CA_FILE = '<مسیر rootCA.pem عمومی>'
50 +node scripts/reachability-smoke.mjs https://192.168.1.10
51 +Remove-Item Env:SYNTHETIC_PASSWORD, Env:SMOKE_PASSWORD
52 +```
53 +
54 +خروجی JSON هر check را جدا نشان می‌دهد. `TLS=PASS` یعنی زنجیره و hostname معتبرند؛ health فقط آماده بودن DB را نشان می‌دهد. `PWA=PASS` بارگیری HTML/manifest است، **نصب Safari را اثبات نمی‌کند**. `API round-trip=PASS` ایجاد تکلیف خصوصی ساختگی، خواندن مستقل و بایگانی روی API مشترک است. بدون اجازه explicit نوشتن و credential ساختگی، round-trip برابر **UNVERIFIED** است. نتیجه داخل ایران باید با تاریخ، اپراتور شبکه و وضعیت VPN خاموش ثبت شود؛ credential و token به گزارش اضافه نشوند.
55 +
56 +## Linux محلی و نگهداری
57 +
58 +```bash
59 +mkcert -cert-file deployment/tls/server.pem -key-file deployment/tls/server-key.pem 192.168.1.10 localhost 127.0.0.1
60 +bash scripts/local-deploy.sh --init https://192.168.1.10
61 +bash scripts/restore-drill.sh --synthetic-only
62 +docker compose ps
63 +docker compose logs --tail=50 migrate api backup
64 +docker compose stop
65 +docker compose start
66 +```
67 +
68 +`stop/start` و `down` بدون `-v` volume داده را حفظ می‌کنند. **`down -v` داده و backupها را حذف می‌کند؛ برای استفاده معمول اجرا نکنید.** script اجرای محلی endpoint Docker از نوع SSH/TCP را رد می‌کند. PostgreSQL هیچ host port ندارد. `.env` را `source` نکنید؛ `docker compose config` بدون `--quiet` می‌تواند secretها را چاپ کند.
69 +
70 +backup در volume جدا، هنگام startup و طبق cron UTC ساخته می‌شود؛ `/backups/last-success` وضعیت آخرین موفقیت است. این نسخه، backup را خودکار رمزگذاری یا از PC خارج نمی‌کند. مالک باید نسخه رمزگذاری‌شده روی فضای محلی جدا نگه دارد و بازیابی را آزمون کند. خاموشی/خواب PC و توقف Docker باعث قطع سرویس LAN می‌شود. برای خروج، CA آزمون و rule فایروال را از دستگاه‌های آزمون حذف کنید.
71 +
72 +## APK
73 +
74 +Dockerfile فقط PWA می‌سازد؛ APK را با کلید debug به‌عنوان release تولید نمی‌کند. فقط APK **امضاشده رسمی با کلید انتشار مالک** را پس از بررسی در `deployment/downloads/LifeGuide.apk` بگذارید؛ از همان مبدأ `/downloads/LifeGuide.apk` دریافت می‌شود. APK توسعه، اگر نیاز بود، باید جدا با نام صریح `LifeGuide-debug.apk` و برچسب آزمایشی نگه داشته شود؛ جای فایل رسمی نیست. فایل‌ها در Git نیستند. تا آماده شدن کلید و آزمون امضا، artifact رسمی **UNVERIFIED/ساخته‌نشده** است. نام و وجود فایل، معتبر بودن امضا یا پذیرش دستگاه را اثبات نمی‌کنند.
docs/plans/PHASE_2_IMPLEMENTATION_PLAN.md
+2
@@ -1,3 +1,5 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 # Phase 2 — Product Foundation & Identity Implementation Plan
4
5 Status: IN PROGRESS
docs/plans/PHASE_3_IMPLEMENTATION_PLAN.md
+2
@@ -1,3 +1,5 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 # Phase 3 — Planner, School & Family Core Implementation Plan
4
5 Status: IN PROGRESS
docs/product/FEATURE_PRIORITIES_V1.md
+2
@@ -1,3 +1,5 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 # LifeMate — Feature Priorities v1
4
5 ## MUST — first useful product
docs/product/PERMISSION_MATRIX_V0.md
+2
@@ -1,3 +1,5 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 # LifeMate — Permission & Visibility Matrix v0
4
5 **Status:** Phase 1 working contract
docs/product/PRODUCT_SPEC_V1.md
+2
@@ -1,3 +1,5 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 # LifeMate — Product Specification v1
4
5 **Status:** Phase 1 baseline
docs/quality/ANALYTICS_POLICY_V1.md
+2
@@ -1,3 +1,5 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 # LifeMate — Analytics Policy v1
4
5 ## Principle
docs/quality/PHASE_2_QUALITY_GATES.md
+2
@@ -1,3 +1,5 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 # LifeMate — Phase 2 Quality Gates
4
5 ## Pull request gates
docs/safety/SAFETY_PRIVACY_RISK_V1.md
+2
@@ -1,3 +1,5 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 # LifeMate — Safety, Privacy & Risk Baseline v1
4
5 ## Product safety boundary
docs/superpowers/plans/2026-10-08-online-family-stage0.md new
+14
@@ -0,0 +1,14 @@
1 +# LifeGuide — authorized implementation plan
2 +
3 +Implementation follows the owner's order; independent work proceeds in parallel under one owner per file group. No final merge, live deployment, DNS, payment or real-data migration is included.
4 +
5 +1. **Gap analysis — lead/reviewer:** main and three remote branches verified; preserve existing healthy core. Committed `da0b0f4`.
6 +2. **Hosting — research owner:** official current sources, no assumed Iran reachability; ADR0009 and Stage 0 primary. **Deployment owner:** Compose, TLS, health, backup, disabled deploy workflow contract and tested synthetic migration drill.
7 +3. **Auth — backend owner:** generic registration/retry, provider failure, email optional, phone OTP port, contact-bound family invitations; migration0007 and real HTTP/DB regressions.
8 +4. **Permissions — privacy owner:** current memberships/roles/grants, revocation and sensitive-feature defaults; migration0009 and real read/write tests. **Lead:** planner/calendar/school private-field projection and report visibility.
9 +5. **Study — study owner:** migration0008, sessions/intervals/ledger, activity states and allowed reports; duplicate/overlap/restart tests and eight-step synthetic scenario.
10 +6. **Runtime/release — Flutter owner:** config.json/endpoint settings, session restoration, local assets/PWA update, stable Android identity and fail-closed signing. **UI owner:** auth/parent dashboard, timer and lifecycle polling. **Lead:** existing offline store/queue, stable mutations and server conflict policy (migration0010).
11 +7. **Integration — lead:** mount new router, ensure revision/activity consistency, run synthetic complete Compose stack, independent API/DB and browser tests. Each specialist supplies RED/GREEN evidence; lead repeats integration checks.
12 +8. **Handover — lead:** naming inventory, README/CHANGELOG/PROJECT_STATE, duplicate ADR correction, private PR, evidence matrix A–H and exact operator steps. UNVERIFIED means unrun, including hardware/Safari/Iran/provider/live release where absent.
13 +
14 +The scope remains online API/PostgreSQL authority. Local-only APK tests are reusable engineering evidence, never online acceptance.
docs/superpowers/specs/2026-10-08-online-family-stage0-design.md new
+39
@@ -0,0 +1,39 @@
1 +# LifeGuide — online family system, Stage 0 design
2 +
3 +The owner's 2026-10-08 execution brief authorizes local implementation, synthetic tests, documentation and a private PR. Hosting selection, production deployment, DNS, real-data migration, final merge and public release remain owner actions. This design builds on main, not a replacement of its domain model. See the committed [gap analysis](../../audits/2026-10-08-online-gap-analysis.md).
4 +
5 +## Deployment and data authority
6 +
7 +Stage 0 runs PostgreSQL, the existing Express API and a TLS reverse proxy on one Windows LAN host through Docker Compose. PWA, `/api`, `/config.json` and optional `/downloads/LifeGuide.apk` share one HTTPS origin. The same package moves to an owner-controlled Linux server without a managed database. Docker volumes hold PostgreSQL; tested pg_dump/restore and an operator-managed backup target precede migration. No automated live cutover is authorized. mkcert trust is installed by the operator on test devices; no certificate-validation bypass is permitted.
8 +
9 +No suitable long-term free/no-card VPS or Iran reachability is assumed. The hosting ADR records actual official sources and UNVERIFIED eligibility/reachability. No accounts, purchases or foreign-host real personal data are part of implementation.
10 +
11 +## Existing code to preserve
12 +
13 +Retain identity/family/guardian tables, Argon2id, hashed tokens, refresh rotation, planner/school APIs, sharing model, reminders/outbox, Feature 1 Iran curriculum/calendar and existing authorization tests. Reuse request/session repair commit `148c260` selectively. Do not import its Railway endpoint or the local-only entrypoint. Keep repository paths, database identifiers and JWT issuer/audience as compatible protocol identifiers.
14 +
15 +## Identity and privacy
16 +
17 +Registration uses one verified contact channel, email or phone; failure to deliver never becomes a false post-commit 500 or a dead-end duplicate account. Production register/resend responses are generic. Resend/OTP have bounded expiry, attempts, cooldown and rate limits. SMS is an explicit provider port, disabled without operator configuration; no real provider send is executed by tests. Phone-only members can accept contact-bound invitations through an authorized share link.
18 +
19 +Every authenticated route checks a current session and active account. Guardian reads require current membership, current roles and current guardian relation. Shared-record reads require current record visibility and current grants; revocation cannot resurrect old grants. Parent reports and calendars redact private notes and exclude private items even from aggregates. Sensitive wellbeing/cycle APIs are closed by default; legal/consent/in-country-storage decisions are flags for later work. External AI/voice execution is disabled.
20 +
21 +## Study and activity model
22 +
23 +Reuse `plan_item`; add study sessions, non-overlapping intervals, activity-state events and an idempotency ledger. A session stores child/activity IDs, source, start/end, pause/resume intervals, status, recorded duration, version and last acknowledgement. Start/pause/resume/stop are explicit user actions. Duration is computed from accepted intervals; duplicate mutations and overlapping sessions do not count twice. Timer and self-reported records are clearly labelled as recorded information, never evidence of actual study.
24 +
25 +Activity states planned/started/paused/completed/verified retain timestamp and source. Verification requires an authorized guardian's explicit confirmation after completion. Ending a study session does not silently complete the homework. Ordinary planner updates reconcile activity history; both planner and activity versions remain coherent.
26 +
27 +## Client and synchronization
28 +
29 +Web loads same-origin config.json without caching. Android stores validated HTTPS primary/alternate URLs in settings; switching server clears the old authentication scope and prevents replay to the new origin. Release identity is permanently `ir.lifeguide.app`; official release signing requires operator secrets and never falls back to debug signing. Release without those secrets is UNVERIFIED, not a release APK.
30 +
31 +Session restoration uses persisted opaque refresh credentials, fresh server verification and refresh rotation. Offline cache and pending changes are scoped to server plus user. Authentication/permission/server/storage errors remain visible; only explicitly classified transport failures permit an offline cache view. Cache views show age and pending state.
32 +
33 +The existing offline queue becomes serialized, durable and UUID-based. Mutation ID and entity ID are stable, persisted before send, and removed only after accepted/already-applied server acknowledgement. Retries reuse the exact payload; the server stores a canonical request hash and rejects changed-payload reuse. Updates use an expected record version. Conflicts keep the pending change visible for review; no silent last-writer-wins. Study events use the same durable storage with their separate server ledger. Polling refreshes shared data while the foreground app is active; no correctness depends on realtime or FCM.
34 +
35 +PWA assets, CanvasKit and fonts are served locally. A network-first versioned app shell excludes API/auth/config responses from service-worker caches. Runtime request checks supplement built-output checks for external gstatic/googleapis dependencies. Real Safari installation and device trust are UNVERIFIED until tested on those devices.
36 +
37 +## Acceptance evidence
38 +
39 +Run synthetic HTTP/PostgreSQL tests for the eight-step child/mother/father scenario, independent DB checks, permission revocation, duplicate/concurrent mutations, pause/resume/restart and token/rate/delivery failures. Run Flutter unit/widget tests and browser substitutes over local HTTPS with independent child/parent sessions. Run Compose health, TLS, PWA, round-trip and synthetic backup/restore. Record exact commands, exit codes, artifacts and substitutions. A–H real Android/iPhone/Safari and inside-Iran reachability remain UNVERIFIED where hardware/location is unavailable. Green CI alone is not completion.
docs/ux/BRAND_BRIEF_V1.md
+2
@@ -1,3 +1,5 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 # LifeMate — Brand & Visual Brief v1
4
5 ## Brand idea
docs/ux/IA_AND_JOURNEYS_V1.md
+2
@@ -1,3 +1,5 @@
1 +**Historical snapshot — retained as decision/evidence history. Current product: LifeGuide; current execution status: PROJECT_STATE.md.**
2 +
3 # LifeMate — Information Architecture & Primary Journeys v1
4
5 ## Navigation model
scripts/audit-naming.py new
+41
@@ -0,0 +1,41 @@
1 +#!/usr/bin/env python3
2 +"""Inventory every remaining legacy-name text occurrence in tracked source."""
3 +import argparse
4 +import re
5 +import subprocess
6 +from pathlib import Path
7 +
8 +parser = argparse.ArgumentParser()
9 +parser.add_argument('--check', action='store_true')
10 +args = parser.parse_args()
11 +files = subprocess.check_output(['git', 'ls-files', '-z']).decode().split('\0')
12 +rows, errors = [], []
13 +active_docs = {'README.md', 'AGENTS.md', 'PROJECT_STATE.md', 'CHANGELOG.md'}
14 +for name in filter(None, files):
15 + p = Path(name)
16 + if not p.is_file() or name == 'docs/audits/2026-10-08-naming.md': continue
17 + raw = p.read_bytes()
18 + if b'\0' in raw: continue
19 + for line_no, line in enumerate(raw.decode('utf-8', errors='replace').splitlines(), 1):
20 + if not re.search('lifemate', line, re.I): continue
21 + historical = name.startswith(('docs/history/', 'docs/final/', 'docs/plans/', 'docs/ux/', 'docs/product/', 'docs/quality/', 'docs/safety/', 'docs/architecture/', 'docs/superpowers/')) or name == 'docs/ROADMAP.md' or name.startswith('docs/audits/') or name in {'docs/decisions/0005-backend-supabase.md', 'docs/decisions/0006-provider-neutral-postgresql-backend.md'}
22 + internal = re.search(r'LifeMateApp|_LifeMateAppState|davoodmehraban89/LifeMate|/LifeMate|apps/lifemate|package:lifemate|lifemate[-_]|\blifemate\b|LIFEMATE', line)
23 + if historical:
24 + category, reason = 'historical — keep', 'snapshot/previous decision; not current deployment evidence'
25 + elif internal:
26 + category, reason = 'protocol-sensitive/internal — keep', 'repository/path/package/resource or JWT/service/test compatibility'
27 + else:
28 + category, reason = 'user-facing — change', 'legacy display name requires review'
29 + errors.append(f'{name}:{line_no}')
30 + # Display declarations must never hide behind adjacent internal paths.
31 + if name.startswith(('apps/lifemate/lib/', 'apps/lifemate/web/', '.github/workflows/')) and re.search(r"['\"][^'\"]*\bLifeMate\b[^'\"]*['\"]", line) and not re.search(r'LifeMateApp|package:', line):
32 + category, reason = 'user-facing — change', 'legacy label/literal in active client or workflow'
33 + errors.append(f'{name}:{line_no}')
34 + snippet = line.strip().replace('|', '\\|').replace('`', "'")[:220]
35 + rows.append(f'| {name}:{line_no} | {category} | {reason} | {snippet} |')
36 +if args.check:
37 + if errors: raise SystemExit('Unchanged user-facing legacy name:\n' + '\n'.join(sorted(set(errors))))
38 + print(f'Naming audit passed: {len(rows)} retained text occurrences classified; binary fonts/icons excluded.')
39 +else:
40 + Path('docs/audits/2026-10-08-naming.md').write_text('# LifeGuide — remaining legacy-name inventory\n\nGenerated with `python3 scripts/audit-naming.py` from tracked source. Product displays are LifeGuide; repository/schema/JWT/internal compatibility and historical evidence retain their original names. Rows classify every remaining case-insensitive legacy-name line; repeated occurrences on that line share its classification. Binary fonts/icons are not text. This inventory excludes itself.\n\n| Location | Classification | Reason | Source excerpt |\n| --- | --- | --- | --- |\n' + '\n'.join(rows) + '\n')
41 + print(f'Wrote {len(rows)} classified rows; {len(set(errors))} display-name review items.')
scripts/check-tracked-secrets.py new
+18
@@ -0,0 +1,18 @@
1 +#!/usr/bin/env python3
2 +"""Check tracked files only; synthetic fixture literals are not live secrets."""
3 +import re
4 +import subprocess
5 +from pathlib import Path
6 +
7 +files = subprocess.check_output(['git', 'ls-files', '-z']).decode().split('\0')
8 +patterns = re.compile(rb'-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|AKIA[0-9A-Z]{16}|gh[pousr]_[A-Za-z0-9_]{30,}|sk_live_[A-Za-z0-9]{20,}')
9 +errors = []
10 +for name in filter(None, files):
11 + p = Path(name)
12 + if not p.is_file(): continue
13 + if (p.name.startswith('.env') and p.name != '.env.example') or p.suffix.lower() in {'.jks', '.keystore', '.dump', '.p12', '.pfx'}:
14 + errors.append(f'{name}: private artifact must not be tracked')
15 + if p.stat().st_size > 10_000_000: continue
16 + if patterns.search(p.read_bytes()): errors.append(f'{name}: high-confidence secret pattern (content withheld)')
17 +if errors: raise SystemExit('\n'.join(errors))
18 +print('Tracked-file credential/artifact scan passed; this is not a complete secret audit.')