LifeMate — Personal, Family & Learning Companion

fix/backend-request-safety
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 151 lines 6.87 KB
Rendered Raw
1 # Personalized Profile Foundation Implementation Plan
2
3 > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
4
5 **Goal:** Correct the test APK profile entry and persistence model, establish explicit girl-minor/boy-minor/adult profile context, and add privacy-safe foundations for relevant health and guidance personalization.
6
7 **Architecture:** Keep family authorization roles independent from profile category. The test-only role-entry app uses local persistent profile state and routes both minor categories to the student shell and adults to the adult shell. Production PostgreSQL gains an explicit profile category plus dedicated private health-cycle storage; guidance consumes minimized profile context rather than gender stereotypes.
8
9 **Tech Stack:** Flutter/Dart, shared_preferences, Node.js/Express, PostgreSQL, node:test.
10
11 **Spec:** `docs/superpowers/specs/2026-10-07-personalized-profile-guidance-design.md`
12
13 ## Global Constraints
14 - First-run choices are exactly «فرزند دختر»، «فرزند پسر»، «بزرگسال».
15 - Display name is independent from profile category and must persist.
16 - `member_role` remains the authorization model and is not repurposed for girl/boy.
17 - Menstrual-cycle functionality is explicit opt-in and private by default.
18 - Guidance must not infer temperament/interests/ability from sex/profile category.
19 - Existing child wellbeing privacy boundaries remain intact.
20 - Security-bypassed entrypoint remains test-only.
21
22 ## Review Focus
23 - Empty/whitespace display names must not replace a valid persisted name.
24 - Restarting the test app must restore category/name rather than returning to generic «فرزند».
25 - Changing category must not silently delete existing profile/health data.
26 - Adult/minor shell routing must not depend on whether a family has already been created.
27 - Sensitive cycle records must not leak through guardian/family summary endpoints.
28
29 ---
30
31 ### Task 1: Persistent test profile and corrected first-run choices
32
33 **Files:**
34 - Modify: `apps/lifemate/pubspec.yaml`
35 - Create: `apps/lifemate/lib/local_test_profile.dart`
36 - Modify: `apps/lifemate/lib/role_entry_main.dart`
37 - Modify: `apps/lifemate/test/role_entry_test.dart`
38
39 **Interfaces:**
40 - Produces: `LocalTestProfileStore.load/save`, profile category values `girl_minor|boy_minor|adult`, mutable display name.
41 - Consumes: existing `HomeShell` and `IdentityApi`.
42
43 - [ ] Write widget/unit tests proving the three exact choices, name entry/edit, persistence after recreation, and empty-name rejection.
44 - [ ] Run `flutter test test/role_entry_test.dart` and verify RED for missing persistence/new choices.
45 - [ ] Add `shared_preferences` and implement local test profile persistence.
46 - [ ] Refactor `LocalRoleTestApi` so `getProfile()` reflects persisted edits and category-specific theme defaults.
47 - [ ] Run the focused Flutter test and verify GREEN.
48 - [ ] Commit.
49
50 ### Task 2: Shell routing independent of family creation
51
52 **Files:**
53 - Modify: `apps/lifemate/lib/main.dart`
54 - Modify: `apps/lifemate/lib/role_entry_main.dart`
55 - Test: `apps/lifemate/test/role_entry_test.dart`
56
57 **Interfaces:**
58 - Consumes: profile category from Task 1.
59 - Produces: explicit shell-mode/profile-category signal used by `HomeShell`.
60
61 - [ ] Add tests proving both minor categories receive student navigation and adult receives adult navigation before any family exists.
62 - [ ] Run focused test and verify RED.
63 - [ ] Add explicit shell context to `HomeShell`; retain family membership only for authorization/family features.
64 - [ ] Run focused test and verify GREEN.
65 - [ ] Commit.
66
67 ### Task 3: Editable profile UI
68
69 **Files:**
70 - Modify: `apps/lifemate/lib/main.dart`
71 - Test: `apps/lifemate/test/role_entry_test.dart`
72
73 **Interfaces:**
74 - Consumes: `IdentityApi.getProfile/updateProfile`.
75 - Produces: profile page that edits display name and refreshes visible profile state.
76
77 - [ ] Add widget test setting display name to «آرام», navigating away/back, and confirming «آرام» remains.
78 - [ ] Run focused test and verify RED.
79 - [ ] Implement profile editor in the shell/profile area with validation and refresh.
80 - [ ] Run focused test and verify GREEN.
81 - [ ] Commit.
82
83 ### Task 4: Production profile-category schema and API
84
85 **Files:**
86 - Create: `backend/migrations/0007_profile_personalization.sql`
87 - Modify: `backend/src/server.js`
88 - Modify: `backend/tests/api.test.js`
89 - Modify: `backend/tests/schema_test.sql`
90
91 **Interfaces:**
92 - Produces: `profile.profile_category` constrained to `girl_minor|boy_minor|adult`; GET/PATCH profile support.
93 - Consumes: existing profile API and family roles unchanged.
94
95 - [ ] Add schema/API tests for category values, updates, and independence from family role.
96 - [ ] Run backend tests/schema test and verify RED.
97 - [ ] Add migration and API handling without deriving authorization from category.
98 - [ ] Run backend tests/schema test and verify GREEN.
99 - [ ] Commit.
100
101 ### Task 5: Private opt-in cycle data foundation
102
103 **Files:**
104 - Modify: `backend/migrations/0007_profile_personalization.sql`
105 - Create: `backend/src/health.js`
106 - Modify: `backend/src/server.js`
107 - Create: `backend/tests/health.test.js`
108 - Modify: `backend/tests/schema_test.sql`
109
110 **Interfaces:**
111 - Produces: owner-authenticated cycle settings/records API; private-by-default storage.
112 - Consumes: authenticated user identity and profile category.
113
114 - [ ] Add tests for explicit opt-in, owner access, disabled-state gating, and guardian/family non-access.
115 - [ ] Run health/schema tests and verify RED.
116 - [ ] Implement minimal owner-only health-cycle endpoints and tables.
117 - [ ] Run health/schema tests and verify GREEN.
118 - [ ] Commit.
119
120 ### Task 6: Guidance context minimization
121
122 **Files:**
123 - Modify: `backend/src/phase4.js`
124 - Modify: `backend/tests/phase4.test.js`
125
126 **Interfaces:**
127 - Consumes: profile category/age and explicit health opt-in only when relevant.
128 - Produces: minimized guidance context with no stereotype-based rules.
129
130 - [ ] Add tests proving profile category does not hard-code personality/advice and private health context is omitted unless explicitly relevant/enabled.
131 - [ ] Run phase-4 tests and verify RED.
132 - [ ] Implement context builder with allowlisted fields.
133 - [ ] Run phase-4 tests and verify GREEN.
134 - [ ] Commit.
135
136 ### Task 7: Full review, regression verification, and APK build
137
138 **Files:**
139 - Modify only if RED→GREEN fixes are required.
140 - Update: `PROJECT_STATE.md` if present.
141
142 **Interfaces:**
143 - Consumes: Tasks 1–6.
144 - Produces: verified test APK and review findings.
145
146 - [ ] Run full Flutter tests.
147 - [ ] Run full backend tests and schema checks.
148 - [ ] Build release APK with `flutter build apk --release --target=lib/role_entry_main.dart`.
149 - [ ] Review role entry, name persistence, routing, privacy boundaries, RTL/copy, mock/incomplete paths.
150 - [ ] Fix Critical/Important findings using RED→GREEN tests.
151 - [ ] Record verified state and commit.