@davoodmehraban89 / LifeMate / commits / 48940b3
Fork 0

LifeMate — Personal, Family & Learning Companion

test(android): verify personal notification settings and OFF persistence

Quinn White committed Oct 21, 2026 at 04:57 UTC 48940b35082cdee5498562f6bda2898a27931b98
7 files changed +288 -3
PROJECT_STATE.md
+9
@@ -1,5 +1,14 @@
1 # LifeGuide / لایف‌گاید — وضعیت واقعی پروژه
2
3 +## پذیرش مستقل تنظیمات صدای Android — ۲۰۲۶-۱۰-۲۱؛ فقط ابزار آزمون
4 +
5 +در شاخهٔ `test/personal-notification-settings` بر PR41/76efe36، fixture debug با DB ساختگی جدا، تنظیمات کانال ثابت Android را از port واقعی باز می‌کند؛ میزبان UIAutomator، برگشت، SQL مستقل و باقی‌ماندن OFF/نبود اعلان را می‌سنجد. source محصول/DB پیش‌فرض/امضا و قفل تحویل PR40 تغییر نکردند. [طراحی و گزارش](docs/audits/2026-10-21-personal-native-settings-acceptance.md).
6 +
7 +**VERIFIED محلی:** baseline35، RED4شکست سپس39/39ابزار مرتبط و64/64کل ابزار؛ Flutter332/332، analyze clean، format1/0تغییر. بررسی host از مدل Android استفاده می‌کند و native نیست. [دستورها/خروجی و hash فایل‌ها](docs/audits/evidence/personal-native-settings-2026-10-21.json). بازبینی مستقل ایراد مسدودکننده‌ای پیدا نکرد.
8 +
9 +**VERIFIED خواندن CI قبلی:** عمومی PR41/39545684951 و اعلان آنلاین39545685044 موفق شدند. شخصی PR40 پس از build/SQLite/اعلان OS فقط در کنترل ناسازگاری امضا/code شکست خورد و upload APK رد شد. **UNVERIFIED:** اجرای mode جدید در Android، گوشی/صدا/باتری/راه‌اندازی مجدد و ارتقای نصب قبلی. کلید اصلی هنوز پیدا نشده/ناموجود اعلام نمی‌شود؛ درخواست نام‌های secrets با403 رد شد و کلید خوانده نشد. APK تازه، merge،deploy،DNS یا دادهٔ واقعی انجام نشده‌اند؛ نصب موجود حفظ شود.
10 +
11 +
12 ## اولویت آفلاین و حفظ دادهٔ آپدیت — ۲۰۲۶-۱۰-۲۱؛ APK جدید تحویل نشده
13
14 مالک صریحاً تکمیل همین نسخهٔ شخصی روی گوشی را پیش از ادامهٔ آنلاین خواست. [ADR0017](docs/decisions/0017-offline-first-and-update-continuity.md) این ترتیب و معیار ارتقای همان نصب را ثبت می‌کند؛ روش تازهٔ انتقال/پشتیبان داده هنوز انتخاب نشده است. دادهٔ واقعی کودک، آنلاین/AI/دسترسی والد، merge/deploy/DNS تغییر نکردند.
apps/lifemate/tool/standalone_acceptance_fixture.dart
+14 -1
@@ -330,7 +330,14 @@ Future<Map<String, Object?>> runStandaloneFixture(String route,
330 {required bool enabled, required bool debug, required bool android}) async {
331 if (!enabled || !debug || !android) throw StateError('fixture_disabled');
332 final uri = Uri.tryParse(route);
333 - const modes = {'/seed', '/inspect', '/change', '/cancel', '/off'};
333 + const modes = {
334 + '/seed',
335 + '/inspect',
336 + '/change',
337 + '/cancel',
338 + '/off',
339 + '/settings'
340 + };
341 if (uri == null ||
342 uri.hasScheme ||
343 uri.hasAuthority ||
@@ -370,6 +377,12 @@ Future<Map<String, Object?>> runStandaloneFixture(String route,
377 _require(await _reconcile(path, port) == null);
378 case '/off':
379 await port.disable(profileId: (await _profile(path)).id);
380 + case '/settings':
381 + // Existing fixture data only; no enable/reconcile/write belongs here.
382 + checks = await _audit(path);
383 + final before = await port.status(profileId: (await _profile(path)).id);
384 + _require(!before.enabled && !before.active && before.scheduledCount == 0);
385 + await port.openNotificationSettings();
386 }
387 final status = await port.status(profileId: (await _profile(path)).id);
388 return {
apps/lifemate/tool/test_standalone_android.py
+46 -1
@@ -34,7 +34,7 @@ GENERIC_BODY = "برای دیدن برنامهٔ شخصی، لایف‌گاید
34 CHANNEL = "lifeguide_personal_plan_v1"
35 CANARY = "SYNTHETIC_PRIVATE_TASK_CANARY"
36 MARKER = "LG_STANDALONE_ACCEPTANCE "
37 -MODES = {"seed", "inspect", "change", "cancel", "off"}
37 +MODES = {"seed", "inspect", "change", "cancel", "off", "settings"}
38 CHECKS = {"rawSqlAfterClose", "profilePersists", "weeklyDifferentTimes",
39 "onceAndEveryTwoDays", "independentEditAndTick", "archivePersists"}
40 PREFERENCES = "shared_prefs/lifeguide_local_reminders_v1.xml"
@@ -136,6 +136,27 @@ def active_fixture_keys(output):
136 return keys
137
138
139 +def notification_settings_visible(output):
140 + """Accept only the fixed channel title owned by Android's settings app.
141 +
142 + Read synthetic UIAutomator output in memory; never publish its raw XML.
143 + Diagnostic prefixes are allowed, malformed/oversized/DTD dumps are not.
144 + """
145 + if not isinstance(output, str) or len(output) > 65536 or '<!' in output:
146 + return False
147 + if output.count('<hierarchy') != 1 or output.count('</hierarchy>') != 1:
148 + return False
149 + start, end = output.index('<hierarchy'), output.index('</hierarchy>')
150 + try:
151 + root = ET.fromstring(output[start:end + len('</hierarchy>')])
152 + except ET.ParseError:
153 + return False
154 + return root.tag == 'hierarchy' and any(
155 + node.get('package') == 'com.android.settings' and
156 + node.get('text') == 'یادآوری برنامهٔ شخصی'
157 + for node in root.iter('node'))
158 +
159 +
160 def check_notification_record(dump, key):
161 require(active_fixture_keys(key) == [key], "invalid_fixture_notification_key")
162 records = re.split(r"(?m)(?=^[ \t]*NotificationRecord\()", dump)
@@ -412,6 +433,29 @@ class Harness:
433 return
434 self.sleep(min(1, until - self.clock()))
435
436 + def verify_notification_settings(self):
437 + settings = self.launch('settings')
438 + self.assert_status(settings, active=False, count=0)
439 + self.assert_database(settings, CHECKS)
440 + self.receipt['currentPhase'] = 'native_notification_settings'
441 + until = self.clock() + 20
442 + while True:
443 + ui = self.adb.shell('uiautomator', 'dump', '/dev/tty', allow_failure=True)
444 + if notification_settings_visible(ui):
445 + break
446 + require(self.clock() < until, 'notification_settings_screen_not_verified')
447 + self.sleep(0.5)
448 + require(self.preferences() is None and not self.active_keys(),
449 + 'settings_changed_off_native_state')
450 + self.adb.shell('input', 'keyevent', 'KEYCODE_BACK')
451 + inspected = self.launch('inspect')
452 + self.assert_status(inspected, active=False, count=0)
453 + self.assert_database(inspected, CHECKS)
454 + require(self.preferences() is None and not self.active_keys(),
455 + 'settings_return_changed_off_native_state')
456 + self.receipt['checks']['nativeNotificationSettingsWhileOff'] = 'PASS'
457 + self.receipt['checks']['sqliteAfterNotificationSettings'] = 'PASS'
458 +
459 def run(self):
460 self.install_user()
461 self.first_user_launch()
@@ -454,6 +498,7 @@ class Harness:
498 self.assert_status(off, active=False, count=0)
499 require(self.preferences() is None and not self.active_keys(), "off_did_not_clear_native_state")
500 self.receipt["checks"]["offClearsNativeState"] = "PASS"
501 + self.verify_notification_settings()
502 self.receipt["currentPhase"], self.receipt["result"] = "complete", "PASS"
503 return self.receipt
504
apps/lifemate/tool/test_standalone_android_test.py
+59 -1
@@ -245,6 +245,8 @@ class SyntheticEmulator(FakeAdb):
245 self.background_delay = 0
246 self.background_ready = 0
247 self.late_kill = False
248 + self.settings_visible = False
249 + self.settings_matches = True
250 self.identifier = "33333333-3333-4333-8333-333333333333"
251
252 def clock(self):
@@ -271,6 +273,13 @@ class SyntheticEmulator(FakeAdb):
273 if parts == ("shell", "input", "keyevent", "KEYCODE_HOME"):
274 self.background_ready = self.elapsed + self.background_delay
275 return ""
276 + if parts == ('shell', 'input', 'keyevent', 'KEYCODE_BACK'):
277 + self.settings_visible = False
278 + return ''
279 + if parts == ('shell', 'uiautomator', 'dump', '/dev/tty'):
280 + title = 'یادآوری برنامهٔ شخصی' if self.settings_matches else 'Other channel'
281 + return ('<hierarchy><node package="com.android.settings" text="' + title +
282 + '" /></hierarchy>') if self.settings_visible else ''
283 if parts == ("shell", "am", "kill", subject.PACKAGE):
284 if self.late_kill and self.state and self.state["reminders"]:
285 self.sleep(60)
@@ -314,6 +323,8 @@ class SyntheticEmulator(FakeAdb):
323 self.posted = False
324 elif mode == "off":
325 self.enabled, self.posted, self.state = False, False, None
326 + elif mode == 'settings':
327 + self.settings_visible = True
328 status = {"supported": True, "permissionGranted": True,
329 "active": self.state is not None, "enabled": self.enabled,
330 "activeScope": subject.SCOPE if self.state else None,
@@ -350,7 +361,9 @@ class LifecycleTest(unittest.TestCase):
361 with patch.object(harness, "first_user_launch", side_effect=lambda: self.first_launch(harness)):
362 receipt = harness.run()
363 self.assertEqual(receipt["result"], "PASS")
353 - self.assertEqual(adb.modes, ["seed", "inspect", "change", "cancel", "off"])
364 + self.assertEqual(adb.modes, ["seed", "inspect", "change", "cancel", "off", "settings", "inspect"])
365 + self.assertEqual(receipt["checks"]["nativeNotificationSettingsWhileOff"], "PASS")
366 + self.assertEqual(receipt["checks"]["sqliteAfterNotificationSettings"], "PASS")
367 self.assertIsNone(adb.state)
368 self.assertFalse(adb.posted)
369 self.assertGreater(adb.elapsed, 95)
@@ -402,6 +415,51 @@ class LifecycleTest(unittest.TestCase):
415 harness.run()
416 self.assertNotIn("processAbsentBeforeAlarm", harness.receipt["checks"])
417
418 + def test_wrong_native_settings_screen_cannot_claim_acceptance(self):
419 + adb = SyntheticEmulator()
420 + adb.settings_matches = False
421 + harness = self.harness(adb)
422 + with patch.object(harness, "first_user_launch", side_effect=lambda: self.first_launch(harness)):
423 + with self.assertRaisesRegex(subject.AcceptanceError, 'notification_settings_screen_not_verified'):
424 + harness.run()
425 + self.assertNotIn('nativeNotificationSettingsWhileOff', harness.receipt['checks'])
426 + self.assertEqual(harness.receipt['result'], 'FAIL')
427 +
428 +
429 +class NotificationSettingsTest(unittest.TestCase):
430 + def checker(self):
431 + function = getattr(subject, 'notification_settings_visible', None)
432 + self.assertTrue(callable(function), 'Native settings screen verification is missing')
433 + return function
434 +
435 + def xml(self, package='com.android.settings', title='یادآوری برنامهٔ شخصی'):
436 + return ('<?xml version="1.0" encoding="UTF-8"?>'
437 + '<hierarchy rotation="0"><node package="' + package +
438 + '" text="' + title + '" /></hierarchy>')
439 +
440 + def test_only_system_settings_with_our_channel_title_is_accepted(self):
441 + check = self.checker()
442 + self.assertTrue(check(self.xml()))
443 + self.assertTrue(check('UI hierchary dumped to: /dev/tty\n' + self.xml()))
444 + for wrong in (self.xml(package=subject.PACKAGE),
445 + self.xml(title='Other channel'),
446 + self.xml(package='unrelated.app')):
447 + with self.subTest(wrong=wrong):
448 + self.assertFalse(check(wrong))
449 +
450 + def test_missing_malformed_or_oversized_settings_dump_cannot_pass(self):
451 + check = self.checker()
452 + for wrong in ('', 'ERROR: could not get idle state', '<hierarchy>',
453 + '<!DOCTYPE x>' + self.xml(), self.xml() * 1000):
454 + with self.subTest(size=len(wrong)):
455 + self.assertFalse(check(wrong))
456 +
457 + def test_unrelated_node_label_cannot_supply_the_system_title(self):
458 + check = self.checker()
459 + mixed = ('<hierarchy><node package="com.android.settings" text="Other" />'
460 + '<node package="unrelated.app" text="یادآوری برنامهٔ شخصی" /></hierarchy>')
461 + self.assertFalse(check(mixed))
462 +
463
464 if __name__ == "__main__":
465 unittest.main()
docs/audits/2026-10-21-personal-native-settings-acceptance.md new
+21
@@ -0,0 +1,21 @@
1 +# پذیرش تنظیمات صدای Android — ابزار آزمون، نه APK جدید
2 +
3 +این PR بر `fix/personal-notification-controls` /76efe36 فقط ابزار آزمون و مستندات را توسعه می‌دهد. Flutter محصول، Kotlin، SQLite محصول، امضا، نسخه، مجوزها و قفل upload تغییر نکردند. هیچ سیاست اشتراک/backup یا زیرساخت انتخاب نشد.
4 +
5 +## کاری که آزمون بررسی می‌کند
6 +
7 +پس از سناریوی موجودِ SQLite واقعی، اعلان پس از نبود پردازش، لغو و OFF، fixture هرگز توزیع‌نشده متد واقعی `openNotificationSettings` را صدا می‌زند. میزبان با UIAutomator بررسی می‌کند عنوان کانال ثابت روی node متعلق به `com.android.settings` باشد؛ عنوان مشابه از app دیگر، XML نامعتبر/بزرگ یا صفحهٔ دیگر پذیرفته نمی‌شود. سپس Android Back، بستن/بازگشایی، SQL مستقل و وضعیت native بررسی می‌شوند: انتخاب OFF حفظ، اعلان جدید صفر و دادهٔ ساختگی موجود برقرار باشد.
8 +
9 +هیچ reset/uninstall، انتخاب ضمنی دستگاه، ورودی دادهٔ واقعی یا نوشتن DB محصول اضافه نشده است. گیت‌های fresh API35 emulator، serial صریح، دو APK هم‌امضا و نبود بستهٔ قبلی حفظ شدند. XML/DB خام فقط در حافظه می‌ماند؛ خروجی assertionهای محدود است. توضیح طراحی در [برنامهٔ آزمون](../superpowers/plans/2026-10-21-personal-native-settings-acceptance.md).
10 +
11 +## VERIFIED محلی
12 +
13 +[گواه دستور/خروجی](evidence/personal-native-settings-2026-10-21.json): baseline35، RED4 شکستِ نبود بررسی، GREEN39 تست مرتبط و64 تست کل ابزار، Flutter332، analyze بدون مشکل و format1/0تغییر. تست‌های host از مدل Android برای بررسی orchestration استفاده می‌کنند؛ این مدل اجرای OS نیست. بازبین مستقل ایراد مسدودکننده‌ای در حفظ گیت‌ها/DB/رضایت پیدا نکرد؛ خودش تست native اجرا نکرد.
14 +
15 +## UNVERIFIED و مانع تحویل
16 +
17 +اجرای سناریوی جدید در Android تا نتیجهٔ CI **UNVERIFIED** است. این بررسی حتی با PASS، صدای شنیدنی، انتخاب صدای واقعی، OEM fallback، گوشی/Doze/reboot یا حفظ دادهٔ **APK دقیق تحویلی قبلی → نامزد جدید در DB محصول** را اثبات نمی‌کند. متن این سند وضعیت زمان ثبت است؛ CI، receipt خودش را در artifact diagnostics نگه می‌دارد.
18 +
19 +PR40 عمومی موفق شد؛ شخصیِ آن پس از build و پذیرش OS فقط به‌علت `certificate_mismatch` و `version_code_not_incremented` در guard شکست خورد و APK upload نشد. PR41 عمومی و پذیرش اعلان کانال آنلاین نیز موفق شدند؛ این‌ها جای سناریوی جدید نیستند. [قفل تحویل](../operations/PERSONAL_UPDATE_GUARD.md) همچنان بسته است. هیچ APK تازه‌ای به‌عنوان آپدیت امن تحویل نشده است.
20 +
21 +بررسی نام‌های secrets در GitHub با403integration رد شد؛ فقط فهرست cacheها قابل خواندن بود. جست‌وجوی محلی فقط دو کپی fixture عمومی SDK با نام debug.keystore یافت؛ محتوای کلید خوانده نشد. این مشاهدات، نبود کلید اصلی نزد مالک را اثبات نمی‌کنند. وضعیت آن هنوز **UNVERIFIED** است. برای حل اختلاف امضا، برنامهٔ نصب‌شده حذف یا clear-data نشود.
docs/audits/evidence/personal-native-settings-2026-10-21.json new
+106
@@ -0,0 +1,106 @@
1 +{
2 + "date": "2026-10-21",
3 + "branch": "test/personal-notification-settings",
4 + "base": "76efe36169ce4e34deee8e218399f5a51d3e0e3f",
5 + "scope": "Developer-only isolated fixture/runner extension; product lib/Kotlin/default DB and APK delivery hold unchanged.",
6 + "sourceFiles": {
7 + "apps/lifemate/tool/standalone_acceptance_fixture.dart": "7cb4b5e433b4a90b0ee456bbf4eb50f6854fa33fdab73277c9a265d594c815a2",
8 + "apps/lifemate/tool/test_standalone_android.py": "71dae413d3d02dc9bd728de160ad38fc48da58b0789fdcade4329df28ddd3607",
9 + "apps/lifemate/tool/test_standalone_android_test.py": "999bb5a92fad0ab5e7fa8f3219a1c2ef2cd5ef67e6776424f4e809bcb0c47308"
10 + },
11 + "commands": [
12 + {
13 + "command": "python3 -B -m unittest discover -s apps/lifemate/tool -p '*standalone*test.py' -v",
14 + "phase": "baseline",
15 + "status": "VERIFIED",
16 + "output": "Ran 35 tests in 0.019s; OK"
17 + },
18 + {
19 + "command": "python3 -B -m unittest discover -s tool -p '*standalone*test.py' -v",
20 + "phase": "RED",
21 + "status": "VERIFIED_EXPECTED_FAILURE",
22 + "output": "FAILED (failures=4)",
23 + "reason": "Missing native-settings checker and missing settings/inspect orchestration."
24 + },
25 + {
26 + "command": "python3 -B -m unittest discover -s tool -p '*standalone*test.py' -v",
27 + "phase": "GREEN",
28 + "status": "VERIFIED",
29 + "output": "Ran 39 tests in 0.021s; OK"
30 + },
31 + {
32 + "command": "python3 -B -m unittest discover -s tool -p '*test.py' -v",
33 + "status": "VERIFIED",
34 + "output": "Ran 64 tests in 0.068s; OK"
35 + },
36 + {
37 + "command": "flutter test --reporter expanded",
38 + "status": "VERIFIED",
39 + "output": "01:29 +332: All tests passed!"
40 + },
41 + {
42 + "command": "flutter analyze",
43 + "status": "VERIFIED",
44 + "output": "No issues found! (ran in 2.4s)"
45 + },
46 + {
47 + "command": "dart format --output=none --set-exit-if-changed apps/lifemate/tool/standalone_acceptance_fixture.dart",
48 + "status": "VERIFIED",
49 + "output": "Formatted 1 file (0 changed) in 0.01 seconds."
50 + }
51 + ],
52 + "review": "Independent read-only review found no blocking safety/data/consent defect. Reviewer did not execute native test.",
53 + "hostTestLimitation": "XML parser rejection is real host code; orchestration uses an explicit synthetic Android model. Neither is OS execution evidence.",
54 + "newNativeScenario": "UNVERIFIED until CI receipt contains nativeNotificationSettingsWhileOff and sqliteAfterNotificationSettings PASS.",
55 + "preservedGates": [
56 + "explicit emulator serial",
57 + "fresh API35/qemu/hardware/product",
58 + "actual APK manifest and same signer",
59 + "no existing package",
60 + "no physical device/reset/uninstall",
61 + "fixture separate DB",
62 + "disabled user APK upload"
63 + ],
64 + "independentlyObservedParentCi": {
65 + "genericPR41": {
66 + "run": 39545684951,
67 + "source": "76efe36",
68 + "status": "completed",
69 + "conclusion": "success"
70 + },
71 + "onlineNotificationPR41": {
72 + "run": 39545685044,
73 + "source": "76efe36",
74 + "status": "completed",
75 + "conclusion": "success"
76 + },
77 + "personalPR41": {
78 + "run": 39545684895,
79 + "status": "in_progress",
80 + "newSettingsMode": "Not present in this parent source"
81 + }
82 + },
83 + "signingInvestigation": {
84 + "secretNamesRequest": "HTTP403 Resource not accessible by integration; no values requested",
85 + "localSigningPathSearch": "2 copies of public SDK test fixture only; contents not read",
86 + "originalPrivateKeyAvailability": "UNVERIFIED"
87 + },
88 + "unverified": [
89 + "New native settings mode execution",
90 + "Physical phone sound/vibration, DND, Doze, reboot and OEM fallback",
91 + "Exact previously delivered APK -> candidate/default product DB upgrade",
92 + "Original signing-key availability",
93 + "No new backup/export/restore implementation",
94 + "Full-history secret scan NOT_RUN",
95 + "Backend tests locally NOT_RUN: no backend change"
96 + ],
97 + "actionsNotTaken": [
98 + "merge",
99 + "deploy",
100 + "DNS/live data change",
101 + "real child data read or upload",
102 + "signing-key creation/export",
103 + "APK handoff",
104 + "uninstall or clear-data"
105 + ]
106 +}
docs/superpowers/plans/2026-10-21-personal-native-settings-acceptance.md new
+33
@@ -0,0 +1,33 @@
1 +# Personal notification settings — synthetic Android acceptance
2 +
3 +Owner priority: finish the offline planner before online work; preserve installed
4 +data and verify reminders. This PR changes only developer test tools and docs.
5 +Base: PR41 /76efe36. No new product/privacy/hosting decision is selected.
6 +
7 +The gap is specific: local widget tests mock MethodChannel and existing emulator
8 +tests never invoke the new native settings method. They cannot prove which
9 +Android settings screen opens or that the native OFF choice survives it.
10 +
11 +Acceptance:
12 +
13 +1. Keep all existing fresh API35 emulator, explicit serial, same-certificate,
14 + no-existing-package and no-real-device safety gates. Never distribute fixture.
15 +2. After the existing real SQLite/archive/notification/OFF checks, a debug-only
16 + fixture mode invokes the product port's openNotificationSettings method.
17 +3. Independent UIAutomator output must show the fixed Persian channel title
18 + owned by com.android.settings. A matching label from another app is rejected.
19 +4. Return with Android Back, then close/relaunch/read SQLite and native state:
20 + OFF remains OFF, no pending/delivered notification and all existing SQL audit
21 + checks pass. No permission/enable/record write belongs to the settings mode.
22 +5. Sanitized receipt records assertions only. No raw XML, database, task content,
23 + key, OTP or real device information enters artifacts.
24 +
25 +RED: add host parser/orchestration rejection tests first, run and observe failure.
26 +GREEN: minimally extend the existing isolated fixture/runner, retaining previous
27 +alarms/SQLite gates. Run host suite, Flutter/analyzer/format as appropriate; open
28 +a separate draft PR and let real CI execute Android. Keep failures visible.
29 +
30 +Limitations remain explicit: this complements mocked button tests; it is not a
31 +physical-phone sound/Doze/reboot test, an OEM-fallback test, or exact previously
32 +delivered APK → new APK/default-database upgrade acceptance. The existing upload
33 +hold is untouched. No keys, uninstall, clear-data, merge, deploy or DNS changes.