LifeMate — Personal, Family & Learning Companion
test: retry background process exit without weakening alarm proof
Quinn White committed
Oct 19, 2026 at 03:10 UTC
837f32337aa1ee33dc6757bed515c94805824e2b
7 files changed
+165
-5
PROJECT_STATE.md
+8
@@ -1,5 +1,13 @@
1
# LifeGuide / لایفگاید — وضعیت واقعی پروژه
2
3
+## آزمون مستقل اعلان Android — ۲۰۲۶-۱۰-۱۹؛ پذیرش گوشی هنوز باز است
4
+
5
+[PR36](https://github.com/davoodmehraban89/LifeMate/pull/36) فقط fixture و ابزار آزمون شبیهساز است؛ Flutter/Android عملیاتی، Backend و APK تحویلی0.7.2+8 تغییر نکردهاند. پورت اصلی با رکورد ساختگی و برچسب صریحِ تأیید سرور شبیهسازیشده استفاده میشود. دستگاه فیزیکی/بستهٔ از قبل نصبشده رد میشود؛ fixture APK توزیع نمیشود.
6
+
7
+**VERIFIED در7fb737d:** Flutter282pass، host21pass و analyze بدون ایراد؛ CI عمومی39192545903 موفق با Backend308pass، role41 و regression96، buildوب و APKdebug. **اجرای شبیهساز39192545919 شکست خورد**: `fixture_process_did_not_exit`؛ نصب تازه و inspect موفق بودند، پذیرش رسیدن اعلان انجام نشد. [شکست حفظشده](docs/audits/evidence/android-reminder-ci-first-2026-10-19.json) و [دستورهای محلی](docs/audits/evidence/android-reminder-tooling-2026-10-19.json). اصلاح ابزار بستن عادی و اثبات بستهشدن پیش از موعد در حال بررسی است؛ نتیجهٔ اجرای بعدی باید جدا ثبت شود.
8
+
9
+**VERIFIED خواندنی:** GETباTLSمعتبر در19اکتبر روی سه مسیر عمومی `app.lifeguide.ir/config.json`،`/api/health` و`/health` هر سه404 داد؛ APIسازگار از این مسیرها تأیید نشد. [رسید](docs/audits/evidence/public-api-paths-2026-10-19.json). این آزمون دسترسی از ایران یا تمام مسیرهای دامنه نیست. هیچ deploy،merge،DNS،حساب/داده واقعی یا تغییر سیاستی انجام نشده است. نصب/اعلان/صدا/باتری روی گوشی، Safari، ورود خصوصی کودک و APIعمومی همچنان **UNVERIFIED/باز** هستند. [راهنمای آزمون](docs/operations/ANDROID_REMINDER_ACCEPTANCE.md).
10
+
11
## برنامهٔ هفته و اعلان Android — ۲۰۲۶-۱۰-۱۸؛ هنوز آمادهٔ بهرهبرداری کودک نیست
12
13
مالک اجرای بستهٔ برنامهٔ شخصی را تأیید کرد. API مستقل در [PR34](https://github.com/davoodmehraban89/LifeMate/pull/34) و Flutter/Android وابسته در [PR35](https://github.com/davoodmehraban89/LifeMate/pull/35) آماده شد؛ هیچ merge/deploy انجام نشد. نوبتهای واقعی PostgreSQL، تکرار و ساعتهای مستقل، صف پایدار، تیک/ویرایش هر روز و اعلان opt-in با دریافت تازهٔ مالک پیاده شد. Feature1، نام LifeGuide و مرز خصوصی نشست کودک حفظ شدند.
apps/lifemate/tool/test_native_reminders_android.py
+20
@@ -232,6 +232,7 @@ class Harness:
232
self.installed = False
233
self.receipt = {"schemaVersion": 1, "result": "FAIL",
234
"scope": "synthetic API 35 emulator only",
235
+ "currentPhase": "preflight",
236
"simulatedServerAcknowledgement": True,
237
"limitations": LIMITATIONS.copy(), "checks": {}}
238
@@ -280,25 +281,37 @@ class Harness:
281
282
def process_dead(self):
283
self._ready()
284
+ self.receipt.pop("processExit", None)
285
+ self.receipt["lastProcessState"] = "UNVERIFIED"
286
self.adb.shell("input", "keyevent", "KEYCODE_HOME")
287
self.adb.shell("am", "kill", PACKAGE)
288
+ attempts = 1
289
until = self.clock() + 10
290
while True:
291
state = self.adb.shell("sh", "-c", PID_QUERY).strip()
292
require(state in ("PRESENT", "ABSENT"), "fixture_process_query_failed")
293
+ self.receipt["lastProcessState"] = state
294
if state == "ABSENT":
295
+ self.receipt["processExit"] = {
296
+ "confirmedAbsent": True, "ordinaryKillAttempts": attempts}
297
return True
298
require(self.clock() < until, "fixture_process_did_not_exit")
299
self.sleep(0.25)
300
+ # HOME demotion is asynchronous. Ordinary am kill can initially be
301
+ # a no-op while Android still considers the app foreground.
302
+ self.adb.shell("am", "kill", PACKAGE)
303
+ attempts += 1
304
305
def launch(self, mode):
306
self._ready()
307
require(mode in MODES, "invalid_fixture_request")
308
+ self.receipt["currentPhase"] = "before_launch_" + mode
309
self.process_dead()
310
nonce = secrets.token_hex(8)
311
route = "/" + mode + "?nonce=" + nonce
312
if mode == "schedule":
313
route += "&delay=45"
314
+ self.receipt["currentPhase"] = "waiting_" + mode + "_marker"
315
output = self.adb.shell("am", "start", "-W", "-n", PACKAGE + "/.MainActivity",
316
"--es", "route", route)
317
require("Error" not in output and "Exception" not in output,
@@ -309,6 +322,7 @@ class Harness:
322
for line in logs.splitlines():
323
marker = fixture_marker(line, nonce, mode)
324
if marker is not None:
325
+ self.receipt["currentPhase"] = "after_" + mode + "_marker"
326
return marker
327
require(self.clock() < until, "fixture_marker_timeout")
328
self.sleep(0.5)
@@ -348,6 +362,7 @@ class Harness:
362
state["reminders"][0].get("delivered", False) is False,
363
"fixture_schedule_not_persisted")
364
require(self.active_keys() == [], "unexpected_fixture_notification_before_deadline")
365
+ self.receipt["currentPhase"] = "after_schedule_created"
366
return at, state
367
368
def wait_for_post(self, at):
@@ -382,6 +397,10 @@ class Harness:
397
398
at, scheduled = self.scheduled(exact=True)
399
self.process_dead()
400
+ require(self.device_epoch_ms() + 1000 < at,
401
+ "process_absence_missed_alarm_deadline")
402
+ require(self.preferences() == scheduled and not self.active_keys(),
403
+ "alarm_delivery_preceded_process_absence_proof")
404
checks["processAbsentBeforeAlarm"] = "PASS"
405
key = self.wait_for_post(at)
406
delivered = self.preferences()
@@ -428,6 +447,7 @@ class Harness:
447
require(self.preferences() is None and not self.active_keys(),
448
"off_did_not_clear_native_state_and_posts")
449
checks["offClearsNativeStateAndPosts"] = "PASS"
450
+ self.receipt["currentPhase"] = "complete"
451
self.receipt["result"] = "PASS"
452
return self.receipt
453
apps/lifemate/tool/test_native_reminders_android_test.py
+53
-3
@@ -49,6 +49,9 @@ class SyntheticEmulator(FakeAdb):
49
self.private_body = False
50
self.refuse_kill = False
51
self.pid_query_failure = False
52
+ self.background_delay = 0
53
+ self.background_ready_at = 0
54
+ self.pid_states = []
55
56
def clock(self):
57
return self.elapsed
@@ -84,9 +87,13 @@ class SyntheticEmulator(FakeAdb):
87
if parts[:4] == ("shell", "cmd", "appops", "set"):
88
self.exact = parts[-1] == "allow"
89
if parts == ("shell", "input", "keyevent", "KEYCODE_HOME"):
90
+ self.background_ready_at = self.elapsed + self.background_delay
91
return ""
92
if parts == ("shell", "am", "kill", subject.PACKAGE):
89
- self.alive = self.refuse_kill
93
+ if self.refuse_kill:
94
+ self.alive = True
95
+ elif self.elapsed >= self.background_ready_at:
96
+ self.alive = False
97
return ""
98
if parts == ("shell", "pidof", subject.PACKAGE):
99
if self.pid_query_failure:
@@ -95,7 +102,9 @@ class SyntheticEmulator(FakeAdb):
102
if parts[:3] == ("shell", "sh", "-c"):
103
if self.pid_query_failure:
104
return ""
98
- return "PRESENT" if self.alive else "ABSENT"
105
+ state = "PRESENT" if self.alive else "ABSENT"
106
+ self.pid_states.append(state)
107
+ return state
108
if parts == ("shell", "date", "+%s"):
109
return str(self.epoch() // 1000)
110
if parts[:3] == ("shell", "run-as", subject.PACKAGE):
@@ -368,9 +377,50 @@ class LifecycleTest(unittest.TestCase):
377
def test_process_claim_fails_when_pid_remains(self):
378
adb = SyntheticEmulator()
379
adb.refuse_kill = True
380
+ harness = self.harness(adb)
381
with self.assertRaisesRegex(subject.AcceptanceError, "fixture_process_did_not_exit"):
372
- self.harness(adb).run()
382
+ harness.run()
383
self.assertEqual(adb.modes, [])
384
+ self.assertEqual(harness.receipt["currentPhase"], "before_launch_inspect")
385
+ self.assertEqual(harness.receipt["lastProcessState"], "PRESENT")
386
+ self.assertNotIn("processExit", harness.receipt)
387
+
388
+ def test_retries_ordinary_kill_after_home_background_transition(self):
389
+ adb = SyntheticEmulator()
390
+ adb.background_delay = 1
391
+ adb.alive = True
392
+ harness = self.harness(adb)
393
+ harness.install_fixture()
394
+ self.assertTrue(harness.process_dead())
395
+ self.assertFalse(adb.alive)
396
+ self.assertEqual(adb.pid_states[0], "PRESENT")
397
+ self.assertEqual(adb.pid_states[-1], "ABSENT")
398
+ self.assertGreaterEqual(adb.elapsed, adb.background_delay)
399
+ self.assertLessEqual(adb.elapsed, 10)
400
+ kills = [parts for parts in adb.calls
401
+ if parts == ("shell", "am", "kill", subject.PACKAGE)]
402
+ self.assertGreater(len(kills), 1)
403
+ self.assertEqual(harness.receipt["processExit"], {
404
+ "confirmedAbsent": True, "ordinaryKillAttempts": len(kills)})
405
+
406
+ def test_late_process_absence_cannot_claim_death_before_alarm(self):
407
+ class SlowScheduledKill(SyntheticEmulator):
408
+ delayed = False
409
+
410
+ def command(self, *parts, allow_failure=False):
411
+ if (parts == ("shell", "am", "kill", subject.PACKAGE) and
412
+ self.state and self.state["reminders"] and not self.delayed):
413
+ self.delayed = True
414
+ self.sleep(46) # The modeled receiver posts before kill completes.
415
+ return super().command(*parts, allow_failure=allow_failure)
416
+
417
+ adb = SlowScheduledKill()
418
+ harness = self.harness(adb)
419
+ with self.assertRaisesRegex(subject.AcceptanceError, "process_absence_missed_alarm_deadline"):
420
+ harness.run()
421
+ self.assertTrue(adb.posted)
422
+ self.assertEqual(harness.receipt["currentPhase"], "after_schedule_created")
423
+ self.assertNotIn("processAbsentBeforeAlarm", harness.receipt["checks"])
424
425
def test_empty_failed_pid_query_cannot_claim_process_absence(self):
426
adb = SyntheticEmulator()
docs/audits/evidence/android-reminder-ci-first-2026-10-19.json
new
+35
@@ -0,0 +1,35 @@
1
+{
2
+ "status": "VERIFIED_FAILURE",
3
+ "runId": 39192545919,
4
+ "sourceCommit": "7fb737d044d61b61b6b3d7bba3eba47859710ba5",
5
+ "command": "gh run view 39192545919 --log-failed",
6
+ "source": "Sanitized receipt extracted from official completed job log; artifact ZIP not verified",
7
+ "artifactZipIntegrity": "UNVERIFIED",
8
+ "receipt": {
9
+ "schemaVersion": 1,
10
+ "result": "FAIL",
11
+ "scope": "synthetic API 35 emulator only",
12
+ "simulatedServerAcknowledgement": true,
13
+ "limitations": {
14
+ "physicalDevice": "UNVERIFIED",
15
+ "reboot": "UNVERIFIED",
16
+ "Doze": "UNVERIFIED",
17
+ "soundOrVibration": "UNVERIFIED",
18
+ "permissionConsentUI": "UNVERIFIED",
19
+ "realServerAcknowledgement": "UNVERIFIED",
20
+ "signedRelease": "UNVERIFIED"
21
+ },
22
+ "checks": {
23
+ "emulatorAndFreshInstallGates": "PASS",
24
+ "inspectDoesNotActivate": "PASS"
25
+ },
26
+ "apk": {
27
+ "sha256": "f7e95adb41c35a05ee96242c70bfb63c61f95c08be18c2624101349586b08d84",
28
+ "package": "ir.lifeguide.app",
29
+ "debuggable": true,
30
+ "targetSdkVersion": 36
31
+ },
32
+ "error": "fixture_process_did_not_exit"
33
+ },
34
+ "interpretation": "Fresh emulator/install and initial inspect passed. Process-death proof failed; notification acceptance not reached. HOME/background demotion race is a hypothesis pending rerun."
35
+}
docs/audits/evidence/android-reminder-tooling-2026-10-19.json
+21
-2
@@ -36,12 +36,31 @@
36
"command": "python3 -m unittest discover -s apps/lifemate/tool -p 'test_native_reminders_android_test.py' -v",
37
"output": "Ran 21 tests in 0.006s; OK",
38
"note": "Host/parser/safety/model tests only; no adb. Review reproduced transport-error false process-absence; strict PRESENT/ABSENT probe and regression added."
39
+ },
40
+ {
41
+ "status": "VERIFIED",
42
+ "command": "python3 -m unittest discover -s apps/lifemate/tool -p '*_test.py' -v",
43
+ "output": "Ran 23 tests in 0.007s; OK",
44
+ "note": "After actual CI failure, regression tests cover delayed HOME transition and refusal of process absence proven after alarm deadline. No adb locally."
45
}
46
],
41
- "androidEmulator": "UNVERIFIED — CI not executed at this checkpoint",
47
+ "androidEmulator": "First actual run39192545919 FAILED fixture_process_did_not_exit; retry/deadline fix pending new actual run; delivery UNVERIFIED",
48
"physicalAndroid": "UNVERIFIED",
49
"realServerAcknowledgement": "UNVERIFIED — fixture explicitly simulates acknowledgement",
50
"safariIranRebootDozeSoundAndUserPermissionUI": "UNVERIFIED",
51
"deliveredApk": "Unchanged 0.7.2+8 from CI39170095124, not the fixture APK",
46
- "mergeDeployLiveChanges": "Not performed"
52
+ "mergeDeployLiveChanges": "Not performed",
53
+ "genericCi": {
54
+ "runId": 39192545903,
55
+ "sourceCommit": "7fb737d044d61b61b6b3d7bba3eba47859710ba5",
56
+ "status": "VERIFIED_SUCCESS",
57
+ "counts": {
58
+ "backend": 308,
59
+ "runtime": 41,
60
+ "regressions": 96,
61
+ "flutter": 282
62
+ },
63
+ "command": "gh run view 39192545903 --json headSha,status,conclusion; inspect completed official job logs",
64
+ "output": "conclusion:success; headSha:7fb737d044d61b61b6b3d7bba3eba47859710ba5"
65
+ }
66
}
docs/audits/evidence/public-api-paths-2026-10-19.json
new
+26
@@ -0,0 +1,26 @@
1
+{
2
+ "scope": "Public read-only HTTP; no auth/data/DNS changes; not reachability from Iran",
3
+ "results": [
4
+ {
5
+ "url": "https://app.lifeguide.ir/config.json",
6
+ "method": "GET",
7
+ "tlsVerification": "enabled",
8
+ "status": "VERIFIED_HTTP_ERROR",
9
+ "httpStatus": 404
10
+ },
11
+ {
12
+ "url": "https://app.lifeguide.ir/api/health",
13
+ "method": "GET",
14
+ "tlsVerification": "enabled",
15
+ "status": "VERIFIED_HTTP_ERROR",
16
+ "httpStatus": 404
17
+ },
18
+ {
19
+ "url": "https://app.lifeguide.ir/health",
20
+ "method": "GET",
21
+ "tlsVerification": "enabled",
22
+ "status": "VERIFIED_HTTP_ERROR",
23
+ "httpStatus": 404
24
+ }
25
+ ]
26
+}
docs/operations/ANDROID_REMINDER_ACCEPTANCE.md
+2
@@ -32,3 +32,5 @@ harness به serial صریح، تأیید محیط ساختگی، manifest debug
32
فقط `PASS` در receipt و exit0 اجرای واقعی، نتیجهٔ همان شبیهساز را تأیید میکند. unit testها فقط منطق ابزار و دروازههای ایمنی را تأیید میکنند. شکست پیشنیاز یا timeout را موفقیت حساب نکنید. exact و approximate جدا گزارش میشوند؛ ثبت approximate، تضمین تحویل آن در چند ثانیه نیست.
33
34
**UNVERIFIED:** نصب/ارتقای گوشی واقعی، صدا و لرزش، صفحهٔ قفل سازنده، reboot، Doze/محدودیت باتری، اجازهٔ واقعی کاربر، iPhone/Safari/PWA، شبکهٔ ایران، تأیید سرور و ورود خصوصی مستقل کودک. نتیجهٔ اجرا و دستور/خروجی در گزارش همین PR ثبت میشود؛ قبل از اجرای CI، خود سناریوی Android نیز UNVERIFIED است.
35
+
36
+اولین اجرای واقعی39192545919 در اثبات بستهشدن پردازش شکست خورد؛ این شکست حفظ شده است. retry فرمان عادی، فقط در صورت PRESENT و با شرط ABSENT پیش از موعد اضافه شد. دلیل محتمل تأخیر رفتن Activity به پسزمینه است؛ علت runtime با اجرای اول اثبات نشده است. unit test موفق جای اجرای دوبارهٔ شبیهساز را نمیگیرد.