@davoodmehraban89 / LifeMate / commits / 1c162a5
Fork 0

LifeMate — Personal, Family & Learning Companion

docs: hand over verified online Stage 0 evidence and operator steps

Codex committed Oct 8, 2026 at 17:03 UTC 1c162a50e1d9b7c0129205c46653f80d56d425ea
11 files changed +355 -28
CHANGELOG.md
+2
@@ -9,6 +9,8 @@
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 +- Preserve discarded conflict payloads in an explicit recovery journal; test reminder replay, private school/class/check-in CRUD/archive and complete Tehran-day report windows.
13 +- Add disabled-by-default HTTPS SMS webhook adapter and isolate live delivery/AI environment variables from all test processes.
14 - Set Android ID ir.lifeguide.app; require real owner release signing; remove automatic public publishing and unused fix workflow.
15 - Real-device/Safari, reachability from Iran, live provider delivery and official signed release remain UNVERIFIED. See PROJECT_STATE.md for actual execution evidence.
16
PROJECT_STATE.md
+13 -8
@@ -2,7 +2,7 @@
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.
5 +**Status: shared online Stage 0 stack verified locally with synthetic data; hardware/release gates remain open. 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. [Draft PR #10](https://github.com/davoodmehraban89/LifeMate/pull/10) is open; main is not merged.
6
7 ## Baseline and reuse
8
@@ -10,20 +10,23 @@ Updated: 2026-10-08. Backend version: **0.5.0**. Branch: **feat/online-family-st
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.
13 +- Shared Node/Express/Argon2id/PostgreSQL with migrations 0007–0012: optional email/phone identity, verification delivery recovery, rate-limited resend, opt-in HTTPS webhook SMS adapter, hashed tokens and refresh rotation. Test runner removes inherited live delivery/AI settings.
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.
17 +- Persian RTL parent views, allowed learning reports, activity timestamps, last-refresh/error state and polling. Seven/thirty-day reports include all of today in Tehran, without changing server freshness timestamps. 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. Explicit server conflict choice journals local payloads before removing their full pending chain. Storage failures are not mistaken for network outages.
19 +- Subject/class and private learning check-in CRUD/archive now use owner validation and retain linked homework/history. Profile category and editable display name remain independent of family permissions.
20 - 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.
21 - 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.
22
23 ## Execution evidence so far
24
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 +Actual output and A–H limits are recorded in [online acceptance](docs/audits/2026-10-08-online-acceptance.md) and [Stage 0 verification](docs/audits/2026-10-08-stage0-verification.md). Root reran Node22.23.3 against a fresh PostgreSQL16 database: **130/130 passed, zero failures/skips**. All twelve migrations applied, four SQL matrices passed, syntax check covered 38 files and dependency audit reported zero vulnerabilities. The independent real-entrypoint/HTTP/DB eight-step substitute passed **9/9**. Flutter aggregate **64/64**, analyzer clean; final frozen-source release web build **57.5s**. Compiled browser request test observed 14 local requests, zero external/missing/error; its HTTPS responses are explicitly intercepted and do not prove real TLS.
26
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 +Local prebuilt Compose PostgreSQL/API/nginxTLS/backup are healthy. Real trusted HTTPS smoke passed create/read/archive/logout; synthetic family task and 1500-second paused session survive API image recreation. Mother/father browser rendering and session restart evidence are recorded separately from backend substitutes. Backup cron, two concurrent distinct archives and fresh synthetic restore/privacy/session drill passed. Complete SDK Dockerfile image build failed with disk/snapshot exhaustion; **UNVERIFIED**, while the checked host/CI web artifact has a lighter Compose packaging path. Historical checksum-less ledger entries are not retrospectively certified; fresh twelve-entry ledgers have checksums.
28 +
29 +The first source CI passed backend tests/SQL but failed backup due to non-executable scripts; file mode and PostgreSQL16 client/container invocation were fixed and local restore retained **12/12** ledger/checksum entries. Final source commit **`7d9366832adaaab4cc3f24ef4d928fddd307fdc9`**, [CI run 37810558847](https://github.com/davoodmehraban89/LifeMate/actions/runs/37810558847): **all three jobs succeeded**, including 130 backend tests, 64 Flutter tests, PostgreSQL16 backup/restore, release web build and actual debug APK build/upload. [LifeGuide-web](https://github.com/davoodmehraban89/LifeMate/actions/runs/37810558847/artifacts/11563914781) and [LifeGuide-debug-apk](https://github.com/davoodmehraban89/LifeMate/actions/runs/37810558847/artifacts/11565283053) are test artifacts; debug signing is not a release. Independent downloaded APK inspection/install and release signing remain **UNVERIFIED**. Subsequent handover documentation does not change the application source tested by that run. No live host, DNS, production deploy, real-data migration, merge, signup, purchase or public release ran.
30
31 ## UNVERIFIED acceptance and remaining gates
32
@@ -33,8 +36,10 @@ Local Compose PostgreSQL/API/backup are healthy; repeat migrations and scheduled
36 - Real email/SMS delivery/provider/payment, timing-indistinguishability of registration, background push.
37 - Owner release keystore/certificate, genuinely signed LifeGuide.apk and public availability.
38 - 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.
39 +- Complete account contact/closure, active-member role/admin transfer, and legacy life-context/year/term lifecycle CRUD; richer school/check-in UI and detailed exam/grade reports. Subject/class/check-in API CRUD is now tested, but that does not complete every auxiliary entity or its UI.
40 +- Separate least-privilege PostgreSQL runtime/migration roles before real data; encrypted/off-PC backups and periodic restore. Compose currently uses its bootstrap DB role.
41 +- Fully offline cold PWA startup, browser eviction/storage quota and hardware accessibility/update behavior. Cross-tab browser cache/token coordination is not implemented/tested; use one active PWA/tab per browser profile for this candidate. Pending study events must receive acknowledgement before another event is recorded.
42
43 ## Next and operator responsibilities
44
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).
45 +Owner runs [Stage 0](docs/operations/STAGE0.md) using the checked prebuilt web artifact, synthetic accounts and A–H hardware acceptance; record real Android/Safari/Windows and VPN-free Iran results before operational use. The next engineering packet should close browser cross-tab coordination, least-privilege database roles, remaining account/membership lifecycle CRUD and detailed school UI/report gaps. 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
+10 -4
@@ -6,19 +6,20 @@
6
7 ## شروع محلی
8
9 -Windows/LAN: [راهنمای Stage 0](docs/operations/STAGE0.md). Docker Desktop/Compose و گواهی HTTPS مورد اعتماد دستگاه‌های آزمون لازم‌اند؛ حساب یا پرداخت میزبان لازم نیست.
9 +Windows/LAN: [راهنمای Stage 0](docs/operations/STAGE0.md). Docker Desktop/Compose و گواهی HTTPS مورد اعتماد دستگاه‌های آزمون لازم‌اند؛ حساب یا پرداخت میزبان لازم نیست. مسیر بررسی‌شده، بسته‌بندی وب از خروجی واقعی build است: [LifeGuide-web از CI موفق](https://github.com/davoodmehraban89/LifeMate/actions/runs/37810558847/artifacts/11563914781) را همراه فایل provenance در `apps/lifemate/build/web` استخراج کنید، یا مطابق راهنما با Flutter3.47.6 بسازید. checkout باید شامل همان کد برنامه باشد؛ checker خروجی قدیمی یا نامنطبق را رد می‌کند.
10
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
12 +node scripts/prebuilt-web-check.mjs apps/lifemate
13 +./scripts/local-deploy.ps1 -Origin https://192.168.1.10 -Certificate deployment/tls/server.pem -PrivateKey deployment/tls/server-key.pem -PrebuiltWeb
14 ```
15
16 IP نمونه را با IP رایانه عوض کنید. روی Linux، پس از تولید گواهی و انتخاب مبدأ:
17
18 ```bash
18 -bash scripts/local-deploy.sh --init https://192.168.1.10
19 +bash scripts/local-deploy.sh --prebuilt-web --init https://192.168.1.10
20 ```
21
21 -`.env`، گواهی خصوصی، backup و keystore خارج Git بمانند. API و PostgreSQL پورت عمومی ندارند؛ nginx، PWA و `/api` را از همان HTTPS ارائه می‌کند. `deployment/runtime-config.json` تنظیم عمومی وب است؛ Android از تنظیم داخل برنامه استفاده می‌کند. تغییر سرور، نشست و کش قبلی را پاک می‌کند؛ صف خصوصی به سرور دیگری ارسال نمی‌شود.
22 +`.env`، گواهی خصوصی، backup و keystore خارج Git بمانند. API و PostgreSQL پورت عمومی ندارند؛ nginx، PWA و `/api` را از همان HTTPS ارائه می‌کند. `deployment/runtime-config.json` تنظیم عمومی وب است؛ Android از تنظیم داخل برنامه استفاده می‌کند. تغییر سرور، نشست و کش قبلی را پاک می‌کند؛ صف خصوصی به سرور دیگری ارسال نمی‌شود. build کامل SDK داخل Docker در این محیط به علت کمبود دیسک موفق نشد و **UNVERIFIED** است؛ مسیر prebuilt، Compose و HTTPS واقعی آزموده شده‌اند. اجرای Windows و گوشی مالک همچنان جداگانه لازم است.
23
24 ## توسعه و آزمون
25
@@ -39,6 +40,8 @@ flutter analyze
40 flutter test
41 flutter build web --release --no-web-resources-cdn --pwa-strategy=none
42 node tool/self_host_web.mjs build/web
43 +cd ../..
44 +node scripts/prebuilt-web-check.mjs apps/lifemate --stamp-after-build
45 ```
46
47 خروجی وب CanvasKit و فونت‌ها را محلی ارائه می‌کند. انتشار خودکار قبلی حذف شده؛ استقرار و APK امضاشده فقط workflow دستیِ پیش‌فرض خاموش دارند. APK آزمایشی debug را با release رسمی اشتباه نگیرید. شناسه نهایی Android `ir.lifeguide.app` و نام فایل release رسمی `LifeGuide.apk` است؛ ساخت آن به کلید واقعی مالک نیاز دارد.
@@ -47,7 +50,10 @@ node tool/self_host_web.mjs build/web
50
51 PostgreSQL مرجع رکوردها و مجوزهاست؛ کش/صف آفلاین بر اساس کاربر و API جدا می‌شود. شناسه UUID، نسخه و تأیید سرور از تکرار و بازنویسی خاموش جلوگیری می‌کنند. والد فقط تکلیف و گزارش مجاز را می‌بیند. زمان ثبت‌شده تایمر یا گزارش شخصی، مدرک مطالعه واقعی نیست. AI/voice خارجی و قابلیت‌های حساس سلامت/چرخه در این بسته غیرفعال‌اند؛ بررسی حقوقی/رضایت و نگهداری داخلی داده حساس، گیت‌های باز انتشار هستند.
52
53 +در این نامزد آزمون، هر حساب از دستگاه یا browser profile مستقل و فقط یک تب/PWA فعال استفاده کند؛ هماهنگی token و cache بین تب‌های هم‌زمان هنوز پیاده‌سازی و آزموده نشده است.
54 +
55 - [وضعیت و شواهد](PROJECT_STATE.md)، [تغییرات](CHANGELOG.md)، [تحلیل شکاف main](docs/audits/2026-10-08-online-gap-analysis.md)
56 +- [ماتریس پذیرش A–H، خروجی‌ها و artifactها](docs/audits/2026-10-08-online-acceptance.md)، [HTTPS و مرورگر واقعی محلی](docs/audits/2026-10-08-stage0-verification.md)
57 - [تصمیم میزبانی و تحقیق](docs/decisions/0009-provider-neutral-hosting.md)، [نام و هویت انتشار](docs/decisions/0010-lifeguide-naming.md)
58 - [استقرار/بازگشت](docs/operations/SELF_HOSTED_DEPLOYMENT.md)، [تمرین مهاجرت داخلی](docs/operations/DOMESTIC_MIGRATION.md)
59
docs/audits/2026-10-08-naming.md
+21 -8
@@ -9,14 +9,21 @@ Generated with `python3 scripts/audit-naming.py` from tracked source. Product di
9 | .github/workflows/ci.yml:29 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | POSTGRES_DB: lifemate_ci |
10 | .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" |
11 | .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 |
12 -| .github/workflows/ci.yml:62 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | run: {working-directory: apps/lifemate} |
13 -| .github/workflows/ci.yml:87 | 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} |
14 -| .github/workflows/ci.yml:93 | 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} |
12 +| .github/workflows/ci.yml:58 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | docker exec -i -e DATABASE_URL=postgresql://postgres:synthetic_ci_only@127.0.0.1:5432/lifemate_ci "$PG_CONTAINER" bash -s -- /tmp/lifeguide-ci.dump < backend/scripts/backup.sh |
13 +| .github/workflows/ci.yml:61 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | test "$(docker exec "$PG_CONTAINER" psql -U postgres -d lifeguide_restore -Atc 'select count(*) from schema_migration')" = "$(docker exec "$PG_CONTAINER" psql -U postgres -d lifemate_ci -Atc 'select count(*) from schema_ |
14 +| .github/workflows/ci.yml:65 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | run: {working-directory: apps/lifemate} |
15 +| .github/workflows/ci.yml:90 | 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} |
16 +| .github/workflows/ci.yml:96 | 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} |
17 | .github/workflows/release-build.yml:16 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | run: {working-directory: apps/lifemate} |
18 | .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} |
19 | 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'. |
20 +| PROJECT_STATE.md:5 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | **Status: shared online Stage 0 stack verified locally with synthetic data; hardware/release gates remain open. Not a complete operational product or public release.** Prior COMPLETE/READY claims are retained only in [hi |
21 +| PROJECT_STATE.md:29 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | The first source CI passed backend tests/SQL but failed backup due to non-executable scripts; file mode and PostgreSQL16 client/container invocation were fixed and local restore retained **12/12** ledger/checksum entries |
22 | 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 تغییر نمی‌کنند. |
19 -| README.md:36 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | cd apps/lifemate |
23 +| README.md:9 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | Windows/LAN: [راهنمای Stage 0](docs/operations/STAGE0.md). Docker Desktop/Compose و گواهی HTTPS مورد اعتماد دستگاه‌های آزمون لازم‌اند؛ حساب یا پرداخت میزبان لازم نیست. مسیر بررسی‌شده، بسته‌بندی وب از خروجی واقعی build اس |
24 +| README.md:12 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | node scripts/prebuilt-web-check.mjs apps/lifemate |
25 +| README.md:37 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | cd apps/lifemate |
26 +| README.md:44 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | node scripts/prebuilt-web-check.mjs apps/lifemate --stamp-after-build |
27 | apps/lifemate/android/app/src/main/AndroidManifest.xml:8 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | android:icon="@drawable/lifemate_logo"> |
28 | apps/lifemate/lib/main.dart:17 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | runApp(const LifeMateApp()); |
29 | apps/lifemate/lib/main.dart:20 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | class LifeMateApp extends StatefulWidget { |
@@ -103,6 +110,10 @@ Generated with `python3 scripts/audit-naming.py` from tracked source. Product di
110 | docs/architecture/PWA_PLATFORM_CONSTRAINTS_V1.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | # LifeMate — PWA Platform Constraints v1 |
111 | 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' |
112 | 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 |
113 +| docs/audits/2026-10-08-online-acceptance.md:3 | historical — keep | snapshot/previous decision; not current deployment evidence | تاریخ: ۲۰۲۶-۱۰-۰۸ UTC. شاخه 'feat/online-family-stage0'، Backend **0.5.0**، Flutter **0.5.0+3**. PR: [#10](https://github.com/davoodmehraban89/LifeMate/pull/10). main مبنا 'abdc9d9d032bc6746c8390b902a2e52d82991530' است. |
114 +| docs/audits/2026-10-08-online-acceptance.md:22 | historical — keep | snapshot/previous decision; not current deployment evidence | **CI واقعی موفق:** [run 37810558847](https://github.com/davoodmehraban89/LifeMate/actions/runs/37810558847)، commit **'7d9366832adaaab4cc3f24ef4d928fddd307fdc9'**. هر سه job Backend/security/Flutter موفق شدند: migration |
115 +| docs/audits/2026-10-08-online-acceptance.md:24 | historical — keep | snapshot/previous decision; not current deployment evidence | - [LifeGuide-debug-apk](https://github.com/davoodmehraban89/LifeMate/actions/runs/37810558847/artifacts/11565283053): ZIP حدود۸۷MB، فایل 'LifeGuide-debug.apk'، **کلید debug و فقط آزمایشی**؛ ساخت واقعی در log '✓ Built ... |
116 +| docs/audits/2026-10-08-online-acceptance.md:25 | historical — keep | snapshot/previous decision; not current deployment evidence | - [LifeGuide-web](https://github.com/davoodmehraban89/LifeMate/actions/runs/37810558847/artifacts/11563914781): ZIP حدود۱۹MB، web کامل و provenance برای مسیر prebuilt. |
117 | 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 آنلا |
118 | 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'؛ این سند، عکس خط مبنای آغاز کار است. \| |
119 | 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 موجود است. تست‌های |
@@ -130,10 +141,12 @@ Generated with `python3 scripts/audit-naming.py` from tracked source. Product di
141 | 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' |
142 | 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' |
143 | 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 را مطابق سیاست نشس |
133 -| docs/operations/STAGE0.md:30 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | Set-Location apps/lifemate |
134 -| docs/operations/STAGE0.md:42 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | Set-Location apps/lifemate |
135 -| docs/operations/STAGE0.md:46 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | node scripts/prebuilt-web-check.mjs apps/lifemate --stamp-after-build |
136 -| docs/operations/STAGE0.md:50 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | Linux محلی، پس از همین build و بررسی: 'bash scripts/local-deploy.sh --prebuilt-web --init https://192.168.1.10'. گزینه '--prebuilt-web' باید پیش از '--init' باشد. artifact CI بررسی‌شده را نیز می‌توان در 'apps/lifemate/bu |
144 +| docs/operations/STAGE0.md:8 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | 2. ابتدا خروجی بررسی‌شده وب را طبق بخش «بسته‌بندی PWA» آماده کنید: artifact کامل [LifeGuide-web](https://github.com/davoodmehraban89/LifeMate/actions/runs/37810558847/artifacts/11563914781) را همراه provenance در 'apps/l |
145 +| docs/operations/STAGE0.md:15 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | node scripts/prebuilt-web-check.mjs apps/lifemate |
146 +| docs/operations/STAGE0.md:31 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | Set-Location apps/lifemate |
147 +| docs/operations/STAGE0.md:43 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | Set-Location apps/lifemate |
148 +| docs/operations/STAGE0.md:47 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | node scripts/prebuilt-web-check.mjs apps/lifemate --stamp-after-build |
149 +| docs/operations/STAGE0.md:51 | protocol-sensitive/internal — keep | repository/path/package/resource or JWT/service/test compatibility | Linux محلی، پس از همین build و بررسی: 'bash scripts/local-deploy.sh --prebuilt-web --init https://192.168.1.10'. گزینه '--prebuilt-web' باید پیش از '--init' باشد. artifact CI بررسی‌شده را نیز می‌توان در 'apps/lifemate/bu |
150 | 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 |
151 | 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. |
152 | 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. |
docs/audits/2026-10-08-online-acceptance.md new
+76
@@ -0,0 +1,76 @@
1 +# LifeGuide — گزارش پذیرش بسته آنلاین Stage 0
2 +
3 +تاریخ: ۲۰۲۶-۱۰-۰۸ UTC. شاخه `feat/online-family-stage0`، Backend **0.5.0**، Flutter **0.5.0+3**. PR: [#10](https://github.com/davoodmehraban89/LifeMate/pull/10). main مبنا `abdc9d9d032bc6746c8390b902a2e52d82991530` است. فقط داده ساختگی روی محیط توسعه و Docker محلی استفاده شد؛ deploy زنده، DNS، انتقال داده واقعی، merge و انتشار عمومی انجام نشدند.
4 +
5 +## اجراهای واقعی
6 +
7 +| اجرا | خروجی مشاهده‌شده | دامنه اعتبار |
8 +| --- | --- | --- |
9 +| migration روی PostgreSQL16 تازه | `applied 0001` تا `0012` | هر ۱۲ migration واقعاً اجرا شدند؛ runner، DDL و ledger را اتمی ثبت می‌کند |
10 +| Backend نهایی با Node22.23.3 | `tests 130; pass 130; fail 0; skipped 0`; ۳۸٫۴۶ ثانیه | API/DB واقعی، auth/privacy/version/overlap، سناریوی مستقل، SMS adapter و جداسازی env؛ env والد عمداً production/webhook مصنوعی بود و runner آن را حذف کرد |
11 +| چهار فایل `*schema_test.sql` | exit0، transaction/DO/ROLLBACK موفق | identity/family/planner/learning/Feature 1 ساختار و مجوزها |
12 +| `npm run check` و `npm audit --audit-level=high` | بررسی نحو موفق؛ `found 0 vulnerabilities` | زمان اجرای audit؛ گواه نبود همه آسیب‌پذیری‌ها نیست |
13 +| Flutter نهایی، analyze + full test | `No issues found!`; ۶۴/۶۴؛ در CI نیز full test موفق | HTTP/native-channel/preferences آزمون‌ها synthetic هستند؛ سخت‌افزار واقعی نیستند |
14 +| `dart format --output=none --set-exit-if-changed lib test` | `33 files (0 changed)` | licenseهای upstream عیناً حفظ و از whitespace انتهای خط مستثنا هستند |
15 +| Flutter3.47.6 / Dart3.13.5 build web | `57.5s`; `✓ Built build/web` | خروجی release وب؛ APK یا Safari نیست |
16 +| browser request check روی artifact کامپایل‌شده | ۱۴ درخواست؛ صفر external/missing/error | HTTPS origin ساختگی با response interception، service worker مسدود؛ **TLS واقعی را اثبات نمی‌کند** |
17 +| تست یادآوری با HTTP و query مستقل PG | ۱/۱ موفق | create/update/retry/reschedule/complete/archive؛ IDs و schedule بدون تکرار |
18 +| Compose، TLS، backup و restore | [شواهد مجزا](2026-10-08-stage0-verification.md) | نتایج واقعی gateway و مرورگر با اعتماد عادی از تست artifact جدا هستند |
19 +
20 +خروجی‌های خام در محیط اجرا: `lifeguide-root-final-migrate.log`، `lifeguide-root-final-backend-130.log`، `online-web-tehran-final-build.log`، `online-web-tehran-final-browser.log` و `planner-reminder-regression.log` در `/workspace/scratch/`. `lifeguide-root-final-flutter.log` بازاجرای ۶۳ آزمون قبل از افزوده گزارش روز تهران است؛ نتیجه نهایی ۶۴ آزمون از اجرا/CI جدید گرفته شد. این مسیرها secret، داده واقعی یا artifact رسمی انتشار نیستند.
21 +
22 +**CI واقعی موفق:** [run 37810558847](https://github.com/davoodmehraban89/LifeMate/actions/runs/37810558847)، commit **`7d9366832adaaab4cc3f24ef4d928fddd307fdc9`**. هر سه job Backend/security/Flutter موفق شدند: migration تکرارپذیر، چهار SQL matrix، ۱۳۰ تست، backup/restore با client16، format/analyze/۶۴ تست Flutter، web build و بررسی درخواست مرورگر. مرورگر CI، **۱۳** درخواست واقعی روی origin ساختگی و صفر external/missing/error ثبت کرد؛ اجرای host،۱۴ درخواست داشت. provenance و هر دو artifact واقعاً upload شدند.
23 +
24 +- [LifeGuide-debug-apk](https://github.com/davoodmehraban89/LifeMate/actions/runs/37810558847/artifacts/11565283053): ZIP حدود۸۷MB، فایل `LifeGuide-debug.apk`، **کلید debug و فقط آزمایشی**؛ ساخت واقعی در log `✓ Built .../app-debug.apk` ثبت شد. metadata/signature باینری مستقل و نصب دستگاه **UNVERIFIED** هستند.
25 +- [LifeGuide-web](https://github.com/davoodmehraban89/LifeMate/actions/runs/37810558847/artifacts/11563914781): ZIP حدود۱۹MB، web کامل و provenance برای مسیر prebuilt.
26 +
27 +تلاش دانلود این artifactها از اتصال رسمی، file reference تولید کرد؛ دریافت URL فایل در محیط shell با HTTP error مسدود شد. صحت digest دانلود محلی، استخراج APK و دریافت APK از gateway محلی **UNVERIFIED** است. artifactها از run بالا برای مالک در GitHub در دسترس‌اند؛ این انتشار عمومی نیست. فایل release رسمی `LifeGuide.apk` ساخته نشده است.
28 +
29 +یک اجرای ابتدایی عامل هنگام افزودن جداسازی env با cwd نادرست، پیش از اصلاح runner انجام شد و شکست خورد؛ ممکن است یک درخواست احرازنشده با credential کاملاً مصنوعی به Resend فرستاده باشد. نبود ترافیک خارجی آن اجرا **UNVERIFIED** است؛ پیام/کلید واقعی استفاده نشده و ادعای تحویل ایمیل ندارد. runner نهایی EMAIL/SMS/AI ارث‌رسیده را حذف می‌کند؛ خروجی تمیز و بازاجرای مستقل ۱۳۰/۱۳۰ مرجع این تحویل‌اند.
30 +
31 +## ماتریس A–H و سناریوی هشت‌مرحله‌ای
32 +
33 +| معیار | شاهد اجراشده | آنچه هنوز UNVERIFIED است |
34 +| --- | --- | --- |
35 +| A: ثبت تکلیف فرزند | `online_acceptance.test.js`: entrypoint واقعی، POST authenticated، بازخوانی مستقل HTTP و query مستقیم PostgreSQL | ثبت از Android واقعی |
36 +| B: مشاهده والد مجاز در PWA | مادر و پدر با ورود مستقل Chromium، API/report200 و UI واقعی تکلیف completed، ثبت۲۵دقیقه/برنامه۳۰دقیقه؛ private note در JSON/UI نیست | Safari و PWA نصب‌شده |
37 +| C: تغییر در یک دستگاه و مشاهده دیگری | سه client مستقل API؛ تکمیل کودک در گزارش مادر/پدر با polling واقعی دیده شد | سه دستگاه فیزیکی و شبکه ایران |
38 +| D: بستن و بازکردن | دو restart کامل Node؛ داده PG/refresh هر سه حساب؛ بستن/بازکردن هر دو profile مرورگر با refresh200، report200 تازه و همان داده UI | Android lifecycle/upgrade و نصب Safari؛ body JSON tab بازیابی‌شده در CDP خوانده نشد |
39 +| E: آفلاین و sync بدون تکرار | قطع واقعی HTTP، journal حفظ‌شده و replay یک UUID فقط یک رکورد DB؛ Flutter FIFO، durable enqueue، ACK خراب، conflict و cache scope آزموده شدند | airplane mode و storage واقعی روی دستگاه |
40 +| F: مجوز و داده خصوصی | خانواده دیگر، guardian لغوشده، عضویت پایان‌یافته، private task/note/session و grant انتخابی در تست‌های read/write رد شدند | penetration test مستقل و ارزیابی حقوقی |
41 +| G: تایمر | pause/resume و restart API؛ دو interval با مجموع ۱۵۰۰ ثانیه، retry بدون double-count؛ Flutter StudySync/recovery آزموده شد | exit/re-sync واقعی Android؛ زمان تایمر مدرک مطالعه نیست |
42 +| H: HTTPS/Safari/install/login/refresh | HTTPS واقعی Compose، trust عادی گواهی و آزمون منفی CA، ورود/refresh واقعی Chromium، همه درخواست‌ها همان origin | Safari/iPhone/iPad و Add to Home Screen **UNVERIFIED** |
43 +
44 +سناریوی مستقل `backend/tests/online_acceptance.test.js` واقعاً تکلیف ریاضی کودک، مشاهده مادر، شروع/وقفه/ادامه/پایان مطالعه، گزارش مجاز مدت ثبت‌شده، تکمیل تکلیف، مشاهده پدر و بازیابی سه حساب پس از restart را اجرا کرد: **۹/۹** با nested assertions. test-only proof token برای ایمیل است؛ تحویل پیام واقعی را اثبات نمی‌کند. نرخ‌های IP در این harness افزایش یافته‌اند تا assertions مجوز به‌علت بودجه آزمون متوقف نشوند؛ rate-limitهای تولید در آزمون‌های مجزا سنجیده می‌شوند. کل سناریو هنوز پذیرش سه دستگاه واقعی نیست.
45 +
46 +## تغییرات قابل تحویل
47 +
48 +- استفاده از هسته سالم main و Feature 1؛ مقایسه و reuse شاخه‌ها پیش از توسعه در [ممیزی](2026-10-08-online-gap-analysis.md).
49 +- PostgreSQL مرجع رکوردهاست: planner CRUD/archive، UUID/version/idempotency، profile category مستقل از نقش خانواده، خانواده/دعوت/guardian، اهداف و check-in آموزشی خصوصی، درس/کلاس و بایگانی امن.
50 +- study session/interval/event واقعی، جلوگیری از تداخل و تکرار، activity timestamps/source، تأیید فقط با guardian مجاز؛ گزارش‌ها فقط داده‌های مجاز را جمع می‌زنند و خوداظهاری را مدرک تلقی نمی‌کنند.
51 +- ثبت‌نام عمومی با status/body یکسان برای حساب موجود/جدید، شکست ایمیل پس از commit بدون 500، resend محدود، proof/reset رمز، token hash و refresh rotation؛ مقاومت در برابر enumeration زمانی **UNVERIFIED**، port SMS صریحاً اختیاری.
52 +- Android API settings و endpointهای جایگزین انتخابی، وب `config.json` no-store، secure refresh session، cache/queue جدا برای endpoint+user؛ conflict نیازمند انتخاب روشن است و payload محلی در journal بازیابی می‌ماند.
53 +- RTL والد، freshness/error، polling، اطلاع‌رسانی داخل برنامه با port؛ فونت‌ها/CanvasKit/iconهای LifeGuide محلی، شناسه Android `ir.lifeguide.app`، guard کلید release واقعی.
54 +- Compose یک مبدأ، PostgreSQL خصوصی، TLS، migration، cron backup، deploy محلی idempotent، smoke شبکه و restore drill؛ workflow استقرار/امضای release پیش‌فرض خاموش، بدون انتشار خودکار.
55 +
56 +## محدودیت‌ها و گیت‌های انتشار
57 +
58 +1. **این بسته نسخه کامل عملیاتی یا release رسمی نیست.** Safari/Android/Windows مالک، نصب و ارتقا، دسترسی بدون VPN ایران، TLS دستگاه و پذیرش سه‌دستگاهی اجرا نشده‌اند.
59 +2. SMTP/SMS واقعی انتخاب یا ارسال نشده‌اند؛ adapter عمومی SMS قرارداد webhook دارد و جای adapter اختصاصی carrier منتخب نیست. بدون delivery تنظیم‌شده، کاربران جدید pending هستند؛ fixtureهای verified فقط آزمون محلی‌اند.
60 +3. کلید انتشار مالک موجود نیست؛ `LifeGuide.apk` رسمی ساخته/امضاشده نیست. APK debug واقعاً در CI ساخته شد، اما جای کلید رسمی یا پذیرش دستگاه نیست.
61 +4. Dockerfile کامل SDK در این محیط با snapshot/دیسک fail شد؛ build کامل آن **UNVERIFIED** است. مسیر prebuilt همان source واقعاً buildشده را با provenance بررسی می‌کند؛ نتیجه Compose جدا ثبت است.
62 +5. API در Compose فعلاً از PostgreSQL bootstrap role استفاده می‌کند؛ تفکیک role migration/runtime با حداقل privileges، پیش از داده واقعی گیت سخت‌سازی است. backup volume محلی، خودکار رمزگذاری/off-PC نمی‌شود؛ export امن و restore دوره‌ای لازم‌اند.
63 +6. تغییر contact/بستن حساب، انتقال مدیریت خانواده و تغییر نقش عضو فعال API کامل ندارند. life-context/year/term قدیمی عمدتاً create/read هستند؛ UI کامل CRUD درس/کلاس/check-in و گزارش تفصیلی امتحان/نمره هنوز نیاز به تکمیل دارد.
64 +7. service worker فقط assetهای عمومی را cache می‌کند؛ API/config/auth cache نمی‌شوند. نصب/تازه‌سازی Safari، cold-start کاملاً آفلاین و eviction/quota دستگاه **UNVERIFIED** هستند. محافظ write در Android و mutex درون runtime وجود دارد؛ هماهنگی cache/token بین tabهای هم‌زمان وب پیاده/آزموده نشده است، پس این candidate فقط با یک tab/PWA فعال در هر browser profile آزمون شود. event مطالعه ارسال‌نشده قبل از ادامه تایمر باید ACK بگیرد.
65 +8. AI/voice خارجی خاموش‌اند؛ health/cycle/اطلاعات روانی کودک پشت feature gate خاموش‌اند. رضایت/سن/قانون/retention و نگهداری حساس داخل کشور صرفاً flag شده‌اند، پیاده یا تأیید حقوقی نشده‌اند.
66 +9. تست امنیت/نحو/dependency audit شاهد محدودی از این نسخه است؛ مقاومت کامل در برابر همه حملات، timing indistinguishability و availability عمومی ادعا نشده است.
67 +
68 +## اقدامات دقیق مالک
69 +
70 +1. ابتدا با داده ساختگی [Stage 0 روی Windows/LAN](../operations/STAGE0.md) را اجرا کنید: IP ثابت PC، Docker/Node/Flutter مشخص، mkcert، اعتماد **گواهی عمومی** روی دستگاه، فایروال محدود Private/LocalSubnet؛ سپس build/postprocess/provenance و `-PrebuiltWeb`. هیچ حساب میزبانی یا خرید لازم نیست.
71 +2. سه حساب fixture را فقط روی DB تازه آزمون بسازید و A–H/هشت مرحله را با Android فرزند و Safari هر والد اجرا کنید؛ نتیجه با زمان و وضعیت VPN ثبت شود. credential/token/کلید را در chat/log عمومی نگذارید.
72 +3. [smoke شبکه](../../scripts/reachability-smoke.mjs) را از شبکه داخل ایران با TLS معتبر اجرا کنید؛ هر `PASS` فقط همان check را ثابت می‌کند. round-trip بدون مجوز نوشتن fixture و credential برابر **UNVERIFIED** است.
73 +4. hosting عمومی را خودتان انتخاب کنید؛ پیشنهاد اصلی LAN رایگان و fallback سرور داخلی **از قبل در اختیار شما** است. VPS خارجی فقط تحقیق است؛ payment/KYC/دسترسی ایران تأیید نشده. هیچ signup/پرداخت انجام ندهید صرفاً به اتکای جدول قیمت. DNS و deploy زنده مجوز جدا می‌خواهند: [ADR](../decisions/0009-provider-neutral-hosting.md).
74 +5. کلید Android را محلی و پایدار تولید/backup کنید و تنها در secret manager/workflow environment امضا تنظیم کنید؛ فایل کلید و رمز در Git یا chat نباشد. applicationId تغییر نمی‌کند؛ debug به‌عنوان release استفاده نشود.
75 +6. SMTP یا carrier SMS را خودتان تعیین کنید؛ webhook تنها با `SMS_PROVIDER=webhook` و URL HTTPS/token در `.env` خصوصی فعال می‌شود. API carrier، هزینه، اقامت/قرارداد و ارسال به handset تا آزمون explicit **UNVERIFIED** می‌مانند.
76 +7. انتقال داخلی و DNS cutover فقط بعد از تصمیم/مجوز: [runbook](../operations/DOMESTIC_MIGRATION.md) شامل write freeze، pg_dump/restore، env/image version، صحت permissions، cutover و rollback با حفظ هر دو backup است. drill داده ساختگی جای انتقال داده واقعی نیست.
docs/audits/2026-10-08-stage0-father.png
Binary files /dev/null and b/docs/audits/2026-10-08-stage0-father.png differ
docs/audits/2026-10-08-stage0-mother.png
Binary files /dev/null and b/docs/audits/2026-10-08-stage0-mother.png differ
docs/audits/2026-10-08-stage0-verification.md
+35 -4
@@ -11,16 +11,47 @@
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** |
14 +| `bash scripts/restore-drill.sh --synthetic-only` | **PASS** نهایی16:46 با image نهایی API: حساب، policy خانواده/خصوصی، interval مطالعه و12migration؛ query مستقل count DB باقی‌مانده0 | دو DB تازه، داده ساختگی؛ انتقال واقعی **UNVERIFIED** |
15 | `DOCKER_HOST=ssh://invalid.example bash scripts/local-deploy.sh` و restore-drill | هر دو با exit1 رد شدند، پیش از تماس remote | guard واقعی محلی؛ سرور زنده تغییر نکرد |
16 +| `bash scripts/local-deploy.sh --prebuilt-web` با CA عمومی build proxy | build imageهای API/gateway/backup و تکرار deploy محلی موفق؛ هر چهار سرویس healthy، migration one-shot exit0 | PWA از build واقعی Flutter؛ مسیر کامل SDK داخل Docker **UNVERIFIED** |
17 +| checker مستقل artifact | **PASS**:44 ورودی، SHA source/artifact مطابق، CanvasKit/فونت محلی، branding و config همان origin | stamp به‌تنهایی build نیست؛ host build جدا اجرا شده |
18 +| HTTPS smoke با `ROOT_CA_FILE` عمومی و حساب ساختگی | **7/7 PASS**: TLS، health DB، PWA/manifest، config no-store، anonymous401، create/read/archive، logout/revocation | TLS verification فعال؛ نصب Safari تأیید نشده |
19 +| HTTPS بدون CA آزمون | exit1، `UNABLE_TO_VERIFY_LEAF_SIGNATURE` | آزمون منفی؛ قبول گواهی نامعتبر فعال نشد |
20 +| دو backup هم‌زمان،16:28:45 | دو archive یکتا، هر دو `pg_restore --list` معتبر، mode600، فایل ناقص0 | نسخه رمزگذاری‌شده و خارج PC **UNVERIFIED** |
21 +| فرزند: API HTTPS واقعی → sync create → independent read → pause/resume/stop → complete | task UUID پایدار، session1500ثانیه، completed؛ independent SQL پس از restart API: یک task version6 و یک session1500 | timestamps مطالعه ساختگی‌اند؛ مدرک مطالعه واقعی/تایمر روی گوشی نیست |
22 +| مادر و پدر: Chromium151 با اعتماد عادی NSS به CA آزمون | ورود200، report200، JSON مجاز و UI فارسی RTL: تکلیف completed، ثبت25دقیقه، برنامه30دقیقه؛ یادداشت خصوصی در JSON نیست | دو profile مستقل روی یک ماشین؛ سه دستگاه فیزیکی **UNVERIFIED** |
23 +| بستن و بازکردن هر دو profile والد | refresh200، report200 جدید، همان عنوان/status/25دقیقه/30دقیقه در UI؛ هر run22 درخواست همان origin، خطای شبکه/HTTP/browser و درخواست خارجی0 | body پاسخ tab بازیابی‌شده در CDP **UNVERIFIED**؛ JSON در اجرای fresh هر والد مستقل بررسی شد |
24
25 خروجی واقعی drill:
26
27 ```text
28 DO
21 -PASS synthetic PostgreSQL dump/restore: identity, family permissions, private task, paused study intervals and 10 migrations preserved.
29 +PASS synthetic PostgreSQL dump/restore: identity, family permissions, private task, paused study intervals and 12 migrations preserved.
30 ```
31
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 معتبر گزارش نشده است.
32 +خطاهای 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 هنگام توسعه هم‌زمان خطا داشت؛ در retry بعدی واقعاً `✓ Built build/web` ثبت شد ولی مرحله بعد با `no space left on device` شکست خورد. داده/volumeها حفظ شدند. SDK host به دیسک جدا منتقل و cacheهای unused با مدیریت lead پاک شدند. این خروجی، build کامل Dockerfile اصلی یا gateway معتبر نیست؛ مسیر اصلی تا build موفق کامل **UNVERIFIED** است. مسیر prebuilt دقیقاً artifact واقعی Flutter را با همان gateway و Compose بسته‌بندی می‌کند و checker، SHA source/artifact و نبود CDN را می‌سنجد؛ stamp، build نیست.
33
26 -HTTPS/PWA/API smoke نهایی بعد از ساخت نهایی gateway در همین گزارش افزوده می‌شود؛ تا قبل از آن **UNVERIFIED** است. TLS اعتماد گواهی، API round-trip و پذیرش مرورگر باید جدا گزارش شوند. اجرای حقیقی Safari/iPhone/Android، دسترسی بدون VPN از ایران، PowerShell مالک، APK release امضاشده، hosting/DNS/live deploy و migration داده واقعی **UNVERIFIED** هستند.
34 +## هویت خروجی نهایی و شواهد مرورگر
35 +
36 +PWA نهایی با Flutter3.47.6، revision `5fc346839b5d0eef006ed8404392afb4dfae428d`، Dart3.13.5 از source ثابت ساخته شد؛ خروجی build واقعی، postprocess و Chromium artifact به‌طور جدا ثبت شده‌اند. provenance نهایی16:34:24UTC:
37 +
38 +```text
39 +source SHA256 a5fa7dec9e5f3069a3a1670425ec7f608c691a4b2a60142d19c8d57c7132054e
40 +artifact SHA256 2d0f59639da289044db78b70d95a75fced7675b38d09d80c1e30c5cb60a90330
41 +API image 958bf30e68a42201ac611104dbdc0c74f0cddd8cbeb39cf0af0a4edc501d52fc
42 +gateway image db6007599859f4c373aea88597b435f5fe0ec500fcf4148504b033ba4ae9303f
43 +```
44 +
45 +PostgreSQL16، Node22.23.3، nginx1.28.3 و Chromium151.0.7922.173 در اجرا استفاده شدند. migrationهای0011–0012 checksum دارند؛ در DB طول‌عمر آزمون، checksum تاریخی0001–0010 پیش از اضافه‌شدن ledger ثبت نشده و صریحاً **UNVERIFIED** گزارش می‌شود. drill تازه هر12migration را از source اجرا کرد. schema، JWT issuer/audience و نام repo تغییر نکردند.
46 +
47 +مرورگر، gateway HTTPS واقعی را بدون intercept، mock یا ignoreTLS باز کرد. CA عمومی آزمون فقط به NSS محیط توسعه افزوده شد؛ این اجرای mkcert روی Windows یا نصب CA روی گوشی نیست. CanvasKit JS/WASM و فونت‌های فارسی/Latin/Emoji/Material/Cupertino همان origin بارگیری شدند؛ service worker واقعی فعال بود. fresh مادر22 و پدر23 درخواست داشت؛ هیچ درخواست خارجی، HTTP error، failed request یا page error مشاهده نشد.
48 +
49 +تصویرهای [مادر](2026-10-08-stage0-mother.png) و [پدر](2026-10-08-stage0-father.png) فقط خانواده ساختگی را نشان می‌دهند. گزارش آشکارا زمان را «ثبت‌شده، گزارش شخصی و نه اثبات مطالعه» معرفی می‌کند. هر دو profile در process جدا بسته و باز شدند و refresh200 و report تازه دریافت کردند؛ JSON body اجراهای reopen به‌دلیل محدودیت CDP خوانده نشد و بررسی آن **UNVERIFIED** است. assertions واقعی UI عنوان تکلیف، completed،25دقیقه ثبت و30دقیقه برنامه را بررسی کردند؛ fresh JSON همان داده را مستقل تأیید کرده بود.
50 +
51 +logs خصوصی ابزار در محیط توسعه حفظ شدند و secrets ندارند: `lifeguide-stage0-idempotent-final.log`، `lifeguide-compose-https-smoke-final.log`، `lifeguide-concurrent-backup-final.log`، `lifeguide-compose-restore-final-sms.log`، `lifeguide-real-https-{mother,father}-window-final.log` و `lifeguide-real-https-{mother,father}-window-resume-final.log`. وجود log جای اجرای دستگاه مالک نیست.
52 +
53 +## مرز پذیرش
54 +
55 +این بسته آنلاین محلی با یک API/DB مشترک است؛ این نتیجه پذیرش نهایی محصول نیست. اجرای حقیقی Safari/iPhone/Android و نصب/ارتقا، دسترسی بدون VPN از ایران، Windows/PowerShell/mkcert مالک، ایمیل/SMS واقعی، APK release امضاشده، hosting/DNS/live deploy، rollback زنده و migration داده واقعی **UNVERIFIED** هستند. provider پیامک در Compose نهایی غیرفعال بود؛ capabilities واقعی `smsAvailable:false` و `smsStatus:UNVERIFIED` داد. CA آزمون جای TLS عمومی محصول نیست.
56 +
57 +پیش از داده واقعی، نقش runtime DB باید از superuser bootstrap جدا شود و backup رمزگذاری‌شده خارج PC با drill بازیابی آماده باشد؛ این دو gate در بسته فعلی حل نشده‌اند. داده سلامت/چرخه/روانی کودکان و AI خصوصی روی میزبان خارجی آزموده یا ارسال نشدند؛ consent/legal و محل داخلی نیازمند تصمیم جدا هستند. هیچ deploy زنده، DNS، حساب جدید، پرداخت یا انتقال واقعی در این مأموریت اجرا نشد.
docs/operations/DOMESTIC_MIGRATION.md
+1 -1
@@ -12,7 +12,7 @@ bash scripts/restore-drill.sh --synthetic-only
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 و سرور داخلی مالک را تأیید نمی‌کند.
15 +آخرین اجرای محلی Linux/Docker مورخ ۲۰۲۶-۱۰-۰۸، ۱۶:۴۶ UTC با PostgreSQL16 و image نهایی API، **PASS** بود: `identity, family permissions, private task, paused study intervals and 12 migrations preserved`. query مستقل بعد از cleanup، تعداد DBهای drill باقی‌مانده را صفر نشان داد. این شاهد، انتقال واقعی، DNS و سرور داخلی مالک را تأیید نمی‌کند.
16
17 ## مراحل دستی انتقال واقعی، فقط پس از مجوز
18
docs/operations/STAGE0.md
+36 -3
@@ -5,14 +5,15 @@
5 ## آماده‌سازی Windows
6
7 1. Docker Desktop با WSL2، Git، Node >=22 و mkcert را نصب کنید. گوشی‌ها و PC به LAN مورد اعتماد متصل باشند. IP محلی PC را با `ipconfig` پیدا و DHCP آن را ثابت کنید. دریافت اولیه وابستگی‌ها ممکن است به VPN توسعه‌دهنده نیاز داشته باشد؛ اجرای کلاینت CDN خارجی ندارد.
8 -2. از ریشه مخزن، در PowerShell، IP نمونه را عوض کنید:
8 +2. ابتدا خروجی بررسی‌شده وب را طبق بخش «بسته‌بندی PWA» آماده کنید: artifact کامل [LifeGuide-web](https://github.com/davoodmehraban89/LifeMate/actions/runs/37810558847/artifacts/11563914781) را همراه provenance در `apps/lifemate/build/web` استخراج کنید، یا build واقعی محلی را انجام دهید. سپس از ریشه مخزن، در 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
15 + node scripts/prebuilt-web-check.mjs apps/lifemate
16 + ./scripts/local-deploy.ps1 -Origin https://192.168.1.10 -PrebuiltWeb
17 ```
18
19 اولین اجرا `.env` را با secretهای تصادفی می‌سازد؛ اجراهای بعدی آن را حفظ می‌کنند. فایل `.env`، کلید سرور و rootCA-key خصوصی هستند و باید خارج Git بمانند. فقط **گواهی عمومی** rootCA.pem را به گوشی آزمون منتقل کنید. CA خصوصی را هرگز منتقل نکنید.
@@ -34,6 +35,23 @@
35
36 این فرمان **UNVERIFIED روی Android واقعی** است. فقط public CA وارد context اعتماد debug می‌شود؛ هیچ callback برای قبول گواهی نامعتبر وجود ندارد. این define در profile/release رد می‌شود. APK debug جای APK رسمی امضاشده نیست و اگر نسخه با گواهی متفاوت نصب باشد ارتقای درجا ممکن نیست؛ داده واقعی را در نسخه توسعه وارد نکنید.
37
38 +## بسته‌بندی PWA از خروجی build بررسی‌شده
39 +
40 +برای جلوگیری از download و snapshotهای بزرگ SDK داخل Docker، می‌توانید PWA را با Flutter3.47.6 روی محیط توسعه/CI بسازید و فقط خروجی بررسی‌شده را با همان nginx/TLS بسته‌بندی کنید. فرمان‌ها از ریشه مخزن، **پس از checkout همان commit** هستند:
41 +
42 +```powershell
43 +Set-Location apps/lifemate
44 +flutter build web --release --no-web-resources-cdn --pwa-strategy=none
45 +node tool/self_host_web.mjs build/web
46 +Set-Location ../..
47 +node scripts/prebuilt-web-check.mjs apps/lifemate --stamp-after-build
48 +./scripts/local-deploy.ps1 -Origin https://192.168.1.10 -PrebuiltWeb
49 +```
50 +
51 +Linux محلی، پس از همین build و بررسی: `bash scripts/local-deploy.sh --prebuilt-web --init https://192.168.1.10`. گزینه `--prebuilt-web` باید پیش از `--init` باشد. artifact CI بررسی‌شده را نیز می‌توان در `apps/lifemate/build/web` استخراج کرد؛ فایل provenance باید همراهش باشد. checker source و artifact را با SHA256 تطبیق می‌دهد، برند، CanvasKit/سه فونت محلی و نبود CDN ممنوع را بررسی می‌کند و artifact قدیمی را رد می‌کند. **stamp به‌تنهایی build نیست**؛ فقط پس از اجرای واقعی و موفق build/postprocess آن را بسازید. release APK در این مسیر ساخته نمی‌شود.
52 +
53 +مسیر پیش‌فرض Dockerfile از source با SDK دقیق pinشده است. در محیط فعلی توسعه، web compile در Docker موفق شد ولی ساخت image به‌دلیل ظرفیت/snapshot دیسک fail شد؛ build کامل این مسیر **UNVERIFIED** است. مسیر prebuilt از همان source buildشده، compose API/PostgreSQL/backup و gateway واقعی استفاده می‌کند؛ نتیجه اجرای آن در [شواهد Stage 0](../audits/2026-10-08-stage0-verification.md) ثبت می‌شود. اجرای Windows و پذیرش گوشی جدا هستند.
54 +
55 ## حساب و round-trip ساختگی
56
57 اگر شبکه توسعه از proxy با CA سازمانی استفاده می‌کند، فقط گواهی **عمومی** آن را در `BUILD_CA_FILE` تنظیم کنید. script از override اختیاری `docker-compose.build-proxy.yml` و BuildKit secret استفاده می‌کند؛ گواهی یا proxy URL داخل کلاینت نهایی قرار نمی‌گیرد. TLS verification خاموش نمی‌شود. این گزینه مخصوص build است؛ CA اعتماد Stage 0 روی گوشی، گواهی جداگانه mkcert است.
@@ -48,6 +66,21 @@ $env:SMOKE_PASSWORD = $env:SYNTHETIC_PASSWORD
66 $env:SMOKE_ALLOW_SYNTHETIC_WRITE = 'yes'
67 $env:ROOT_CA_FILE = '<مسیر rootCA.pem عمومی>'
68 node scripts/reachability-smoke.mjs https://192.168.1.10
69 +```
70 +
71 +برای پذیرش چندکاربره، روی **همین DB ساختگی Stage 0** می‌توانید قبل از پاک کردن متغیر رمز، fixture خانواده را بسازید:
72 +
73 +```powershell
74 +docker compose exec -e ALLOW_SYNTHETIC_SEED=yes -e SYNTHETIC_PASSWORD api node scripts/seed-stage0-family.js
75 +```
76 +
77 +حساب‌های `stage0-child@lifeguide.test`، `stage0-mother@lifeguide.test` و `stage0-father@lifeguide.test` با همان رمز آزمایشی ساخته می‌شوند؛ عضویت و دو رابطه guardian در DB مشترک‌اند. script حساب/family غیرfixture را تغییر نمی‌دهد. تأیید ایمیل این fixture مستقیم و صریحاً آزمایشی است؛ تحویل ایمیل/SMS محصول را اثبات نمی‌کند. Android فرزند و PWA هر والد باید با حساب مستقل وارد همان origin شوند. سناریوی واقعی تکلیف/مطالعه/تازه‌سازی را از API عادی انجام دهید؛ موفقیت seed جای پذیرش سه دستگاه نیست.
78 +
79 +هر والد روی دستگاه یا browser profile مستقل، فقط **یک تب/PWA فعال LifeGuide** داشته باشد. هماهنگی token/cache بین تب‌های هم‌زمان هنوز پیاده‌سازی و آزموده نشده است؛ private-mode/پاک‌کردن storage نیز صف ارسال‌نشده را حذف می‌کند. قبل از خروج یا تغییر سرور، وضعیت صف و تأیید آخرین sync را بررسی کنید.
80 +
81 +پس از پایان آزمون، متغیرهای رمز را پاک کنید:
82 +
83 +```powershell
84 Remove-Item Env:SYNTHETIC_PASSWORD, Env:SMOKE_PASSWORD
85 ```
86
@@ -57,7 +90,7 @@ Remove-Item Env:SYNTHETIC_PASSWORD, Env:SMOKE_PASSWORD
90
91 ```bash
92 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
93 +bash scripts/local-deploy.sh --prebuilt-web --init https://192.168.1.10
94 bash scripts/restore-drill.sh --synthetic-only
95 docker compose ps
96 docker compose logs --tail=50 migrate api backup
scripts/pwa-browser-smoke.py new
+161
@@ -0,0 +1,161 @@
1 +"""Developer-only real HTTPS PWA load test; requires Playwright + Chromium.
2 +
3 +The public CA must already be trusted normally by the browser. This program
4 +never ignores TLS errors, intercepts network responses, or logs credentials.
5 +Real Safari/Android and Iran reachability are separate acceptance gates.
6 +"""
7 +import argparse
8 +import json
9 +import re
10 +import time
11 +from pathlib import Path
12 +from urllib.parse import urlparse
13 +from playwright.sync_api import sync_playwright
14 +
15 +parser = argparse.ArgumentParser()
16 +parser.add_argument("origin")
17 +parser.add_argument("--chromium", default="/usr/bin/chromium")
18 +parser.add_argument("--profile", required=True)
19 +parser.add_argument("--screenshot", required=True)
20 +parser.add_argument("--viewport-width", type=int, default=390)
21 +parser.add_argument("--synthetic-login-email", choices=["stage0-mother@lifeguide.test", "stage0-father@lifeguide.test"])
22 +parser.add_argument("--synthetic-password-file")
23 +parser.add_argument("--expected-task-title")
24 +parser.add_argument("--expected-recorded-seconds", type=int)
25 +parser.add_argument("--expected-planned-seconds", type=int)
26 +parser.add_argument("--expected-status")
27 +parser.add_argument("--resume-parent-session", action="store_true")
28 +args = parser.parse_args()
29 +origin = args.origin.rstrip("/")
30 +parsed = urlparse(origin)
31 +if parsed.scheme != "https" or parsed.username or parsed.password or parsed.path or parsed.query or parsed.fragment:
32 + raise SystemExit("Use one HTTPS origin without credentials/path/query/fragment")
33 +requests, failures, errors, http_errors, auth_responses = [], [], [], [], []
34 +login_verified, report_verified, report_body_verified, reported_task = False, False, False, None
35 +if bool(args.synthetic_login_email) != bool(args.synthetic_password_file):
36 + raise SystemExit("Synthetic login requires both the known fixture email and private local password file")
37 +if args.resume_parent_session and not args.synthetic_login_email:
38 + raise SystemExit("Resume requires a previously authenticated synthetic parent profile")
39 +with sync_playwright() as playwright:
40 + context = playwright.chromium.launch_persistent_context(
41 + user_data_dir=args.profile, executable_path=args.chromium, headless=True,
42 + viewport={"width": args.viewport_width, "height": 960}, ignore_https_errors=False,
43 + service_workers="allow", timezone_id="Asia/Tehran",
44 + )
45 + try:
46 + page = context.pages[0] if context.pages else context.new_page()
47 + def requested(request):
48 + url = urlparse(request.url)
49 + requests.append({"origin": f"{url.scheme}://{url.netloc}", "path": url.path})
50 + page.on("request", requested)
51 + page.on("requestfailed", lambda request: failures.append({"path": urlparse(request.url).path, "failure": request.failure}))
52 + page.on("pageerror", lambda error: errors.append(str(error)))
53 + def responded(response):
54 + path = urlparse(response.url).path
55 + if response.status >= 400:
56 + http_errors.append({"path": path, "status": response.status})
57 + if path in ("/api/v1/auth/login", "/api/v1/auth/refresh"):
58 + auth_responses.append({"path": path, "status": response.status})
59 + page.on("response", responded)
60 + initial_url = page.url
61 + if initial_url.rstrip("/") == origin:
62 + # Persistent Chromium may already be restoring the prior page.
63 + # Never start a second navigation while it rotates refresh tokens.
64 + response = None
65 + page.wait_for_load_state("networkidle", timeout=90000)
66 + else:
67 + response = page.goto(origin, wait_until="networkidle", timeout=90000)
68 + assert response and response.status == 200, "PWA navigation failed"
69 + page.wait_for_selector("flt-glass-pane", state="attached", timeout=90000)
70 + page.wait_for_function("() => !document.getElementById('startup-status')", timeout=90000)
71 + placeholder = page.locator("flt-semantics-placeholder")
72 + if placeholder.count():
73 + placeholder.evaluate("element => element.click()")
74 + page.wait_for_load_state("networkidle")
75 + if args.synthetic_login_email:
76 + if args.resume_parent_session:
77 + pass
78 + else:
79 + password = Path(args.synthetic_password_file).read_text().strip()
80 + assert len(password) >= 10, "Synthetic password too short"
81 + page.get_by_label("ایمیل یا شماره تلفن", exact=True).fill(args.synthetic_login_email)
82 + page.get_by_label("رمز عبور", exact=True).fill(password)
83 + password = None
84 + with page.expect_response(lambda response: urlparse(response.url).path == "/api/v1/auth/login" and response.request.method == "POST") as logged_in:
85 + page.get_by_role("button", name="ورود", exact=True).click()
86 + assert logged_in.value.status == 200, f"Synthetic parent login HTTP {logged_in.value.status}"
87 + page.get_by_role("tab", name="خانواده", exact=True).wait_for(timeout=30000)
88 + page.wait_for_load_state("networkidle")
89 + if args.resume_parent_session:
90 + assert {"path": "/api/v1/auth/refresh", "status": 200} in auth_responses, "Saved parent session did not refresh after browser restart"
91 + # Flutter's RTL semantic tab has a transformed DOM rectangle. Use
92 + # the actual visible centre tab of the five-destination navbar.
93 + page.mouse.click(args.viewport_width / 2, 920)
94 + child = page.get_by_role("button", name=re.compile("فرزند آزمایشی"))
95 + child.wait_for(timeout=30000)
96 + with page.expect_response(lambda response: urlparse(response.url).path.endswith("/learning-report")) as loaded_report:
97 + child.evaluate("element => element.click()")
98 + assert loaded_report.value.status == 200, "Permitted child report API failed"
99 + # Chromium's restored tab can expose a response without retaining
100 + # its CDP response body. Fresh-login runs independently validate
101 + # server JSON; restart runs validate refresh, new report HTTP 200
102 + # and the actual rendered values, without inventing a JSON check.
103 + server_report = None if args.resume_parent_session else loaded_report.value.json()
104 + report_body_verified = server_report is not None
105 + if server_report is not None and args.expected_planned_seconds is not None:
106 + assert server_report["metrics"]["plannedInRangeDurationSeconds"] == args.expected_planned_seconds, "Planned time for the selected report range differs"
107 + page.get_by_role("heading", name=re.compile("گزارش یادگیری")).wait_for(timeout=30000)
108 + if server_report is not None and args.expected_task_title:
109 + reported_task = next((item for item in server_report["items"] if item["title"] == args.expected_task_title), None)
110 + assert reported_task, "Expected synthetic homework missing from server report"
111 + if args.expected_recorded_seconds is not None:
112 + assert reported_task["recordedDurationSeconds"] == args.expected_recorded_seconds, "Reported task duration differs"
113 + if args.expected_status:
114 + assert reported_task["status"] == args.expected_status, "Reported task status differs"
115 + assert "SYNTHETIC-OWNER-PRIVATE-NOTE" not in json.dumps(server_report), "Private owner note leaked to parent"
116 + deadline = time.monotonic() + 30
117 + while True:
118 + rendered = page.locator("body").aria_snapshot()
119 + if "زمان ثبت‌شده" in rendered and (not args.expected_task_title or args.expected_task_title in rendered):
120 + break
121 + assert time.monotonic() < deadline, "Expected allowed report was not rendered in PWA"
122 + page.wait_for_timeout(100)
123 + if args.expected_recorded_seconds is not None:
124 + assert f"ثبت {round(args.expected_recorded_seconds / 60)} دقیقه" in rendered, "Recorded task duration not shown in PWA"
125 + if args.expected_status == "completed":
126 + assert "انجام‌شده به گزارش فرزند" in rendered, "Recorded completion status not shown in PWA"
127 + if args.expected_planned_seconds is not None:
128 + assert f"زمان برنامه‌ریزی‌شده: {round(args.expected_planned_seconds / 60)} دقیقه" in rendered, "Planned duration for report range not shown in PWA"
129 + assert "SYNTHETIC-OWNER-PRIVATE-NOTE" not in rendered, "Private owner note rendered for parent"
130 + login_verified, report_verified = True, True
131 + external = [request for request in requests if request["origin"] != origin]
132 + assert not external, f"Unexpected external request: {external}"
133 + assert not failures, f"Network failure: {failures}"
134 + assert not errors, f"Browser error: {errors}"
135 + assert not http_errors, f"HTTP failure: {http_errors}"
136 + assert any("/canvaskit/" in request["path"] and request["path"].endswith(".wasm") for request in requests), "Local CanvasKit WASM missing"
137 + assert "LifeGuide" in page.title() and "لایف‌گاید" in page.title(), "Product title differs"
138 + page.screenshot(path=args.screenshot, full_page=False)
139 + print(json.dumps({"mode": "actual local HTTPS gateway, normal browser trust, real API", "browser": context.browser.version if context.browser else "Chromium", "http": response.status if response else "Chromium restored navigation; initial HTTP status UNVERIFIED",
140 + "requestCount": len(requests), "externalRequests": external,
141 + "failedRequests": failures, "browserErrors": errors,
142 + "httpErrors": http_errors,
143 + "syntheticParentLogin": login_verified and not args.resume_parent_session,
144 + "syntheticParentAuthenticated": login_verified,
145 + "permittedChildReportRendered": report_verified,
146 + "serverReportBodyVerified": report_body_verified,
147 + "reportBodyLimit": "Restored-tab JSON body UNVERIFIED; fresh-login runs independently validate JSON" if args.resume_parent_session else None,
148 + "resumedPersistedParentSession": args.resume_parent_session,
149 + "authResponses": auth_responses,
150 + "reportedTask": None if reported_task is None else {key: reported_task.get(key) for key in ["title", "status", "recordedDurationSeconds", "plannedDurationSeconds", "activityState"]},
151 + "fonts": [request["path"] for request in requests if request["path"].endswith((".ttf", ".otf", ".woff2"))],
152 + "inputLabels": page.locator("input").evaluate_all("els => els.map(e => ({type:e.type,label:e.getAttribute('aria-label')}))"),
153 + "serviceWorkers": len(context.service_workers),
154 + "limitations": "Safari install, Android, three physical devices and Iran reachability UNVERIFIED"}, ensure_ascii=False, indent=2))
155 + finally:
156 + # Park the saved profile on a blank page before closing. Chromium may
157 + # otherwise auto-restore the prior URL before a subsequent explicit
158 + # navigation, accidentally racing two refresh rotations in this test.
159 + for open_page in context.pages:
160 + open_page.goto("about:blank")
161 + context.close()