LifeMate — Personal, Family & Learning Companion
docs: define phase 5 hardening and release design
davoodmehraban89 committed
Oct 5, 2026 at 17:07 UTC
a6e342798c662751e8abe27ebb8b4d08a2b7a4ec
1 file changed
+39
docs/superpowers/specs/2026-10-05-phase-5-hardening-release-design.md
new
+39
@@ -0,0 +1,39 @@
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.