LifeMate — Personal, Family & Learning Companion

feat/public-review-page
chore/phase1-repository-cleanup deploy/stable-web-apk deployment-static design/mobile-accessibility-v2 design/mobile-navigation-review docs/child-education-access-decision docs/offline-data-rescue-options docs/owner-guide-and-delivery-plan docs/phase1-policy-options docs/public-review-live-2026-10-15 feat/aparat-learning-library feat/child-device-safety feat/child-identity-schema feat/flutter-mobile-navigation feat/learning-content-operations feat/local-signing-preflight feat/online-family-stage0 feat/personal-encrypted-recovery feat/private-planner-series-api feat/public-review-page feat/standalone-weekly-planner feat/weekly-planner-android final-feature-1/iran-family-school fix/auth-abuse-expiry-safety fix/auth-expiry-after-lock fix/backend-request-safety fix/lifeguide-bootstrap-naming-ci fix/lifeguide-pages-qa-base-preflight fix/lifeguide-qa-pages-env-deployment fix/local-task-persistence fix/managed-child-session-boundary fix/personal-jalali-dates fix/personal-notification-controls fix/personal-upgrade-delivery-guard fix/sms-approval-gates fix/study-duration-display infra/cloudflare-neon-migration infra/lifeguide-cloudflare-qa infra/lifeguide-github-pages-qa infra/lifeguide-supabase-qa main phase-1/foundation-completion phase-2/product-foundation-identity phase-3/planner-school-family-core phase-4/ai-learning-wellbeing phase-5/hardening-observability-release test/android-reminder-acceptance test/personal-notification-settings test/personal-recovery-acceptance test/role-entry-apk
md 39 lines 3.42 KB
Rendered Raw
1 # Phase 5 — Hardening, Observability & Release Design
2
3 Status: Approved by Phase 5 start instruction on 2026-10-05.
4
5 ## Goal
6 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.
7
8 ## Scope
9 1. Backend operational hardening: request IDs, structured logs, security headers, bounded request body, rate limiting for auth/AI/general API traffic, and explicit readiness/liveness endpoints.
10 2. Observability: privacy-safe request/error telemetry and documented alert signals. No wellbeing note, AI transcript, password, token, authorization header, or secret may be logged.
11 3. Data resilience: documented PostgreSQL backup/restore procedure and a CI-verifiable restore drill using migrations plus representative data.
12 4. Regression gates: backend integration/contract tests, dependency audit, Flutter format/analyze/tests, Android build, Web/PWA release build, accessibility/RTL smoke assertions, and release metadata checks.
13 5. Release operations: staging verification, version/changelog discipline, deployment/rollback/runbooks, environment variable inventory, and production checklist.
14
15 ## Non-goals / production gates
16 - No production deploy or public release in this phase without a separate explicit approval.
17 - No destructive production migration.
18 - No activation of an external AI provider for minor-sensitive wellbeing data until the existing legal/privacy/provider gates pass.
19 - No voice-provider activation until privacy review passes.
20
21 ## Architecture
22 Keep the current provider-neutral Node/Express API and PostgreSQL. Add a small in-process hardening layer with no new infrastructure dependency: request correlation, structured JSON logging, security headers and memory-bounded fixed-window rate limiting suitable for the current single-instance staging footprint. Document that multi-instance production must move the limiter to shared storage before horizontal scaling.
23
24 Expose `/live` for process liveness and `/ready` for database readiness; retain `/health` for compatibility. Logs are JSON lines with requestId, method, route/path, status, durationMs and error class only. Sensitive request/response bodies are never logged.
25
26 Backups use PostgreSQL-native `pg_dump`/`pg_restore`. CI performs a restore drill against an ephemeral PostgreSQL service to prove the documented commands and schema/data round-trip. Production backup scheduling remains a hosting operation and is not silently enabled.
27
28 ## Rate limits
29 Defaults are configurable by environment. General API: 120 requests/minute/IP. Auth-sensitive endpoints: 10 requests/10 minutes/IP. AI message/family-guidance endpoints: 30 requests/10 minutes/identity-or-IP. Responses use HTTP 429 with `Retry-After` and `{error:"rate_limited"}`.
30
31 ## Acceptance criteria
32 - Existing Phase 1–4 tests stay green.
33 - New hardening tests prove request IDs, security headers, readiness semantics, structured error behavior and rate-limit rejection.
34 - No sensitive values are emitted by telemetry tests.
35 - CI includes an automated PostgreSQL backup/restore drill.
36 - Flutter/Web/PWA and Android build gates remain green.
37 - Operational runbooks exist for deploy, rollback, backup/restore, incident response and production release.
38 - Staging health/readiness are verified after deployment.
39 - `PROJECT_STATE.md` records Phase 5 completion only after all automated gates and staging checks pass.