LifeMate — Personal, Family & Learning Companion
test: recognize owned Flutter semantics and preserve synthetic UI diagnostics
Quinn White committed
Oct 22, 2026 at 20:02 UTC
7eb413d92ec6b83c02326dd28b4e2446c1d6c321
3 files changed
+134
-18
apps/lifemate/tool/test_personal_recovery_android.py
+24
-6
@@ -290,8 +290,16 @@ class Harness:
290
require(root.tag == 'hierarchy' and len(root) > 0 and
291
all(node.tag == 'node' for node in root.iter() if node is not root),
292
'invalid_ui_hierarchy')
293
- return any(node.attrib.get('text') in (PROFILE, 'سلام ' + PROFILE)
294
- for node in root.iter('node'))
293
+ nodes = list(root.iter('node'))
294
+ owned = [node for node in nodes if node.attrib.get('package') == package]
295
+ labels = (PROFILE, 'سلام ' + PROFILE)
296
+ observation = {'package': package, 'nodeCount': len(nodes),
297
+ 'ownedPackageNodeCount': len(owned),
298
+ 'exactTextMatch': any(node.attrib.get('text') in labels for node in owned),
299
+ 'exactContentDescriptionMatch': any(
300
+ node.attrib.get('content-desc') in labels for node in owned)}
301
+ self.receipt['lastUiObservation'] = observation
302
+ return observation['exactTextMatch'] or observation['exactContentDescriptionMatch']
303
except ET.ParseError:
304
raise AcceptanceError('invalid_ui_hierarchy') from None
305
finally:
@@ -306,7 +314,12 @@ class Harness:
314
self.launched.add(package)
315
deadline = self.clock() + 30
316
while not self.profile_visible(package):
309
- require(self.clock() < deadline, 'real_profile_ui_not_visible')
317
+ if self.clock() >= deadline:
318
+ try:
319
+ self.screenshot('ui-failure-original' if package == ORIGINAL else 'ui-failure-qa')
320
+ except Exception:
321
+ self.receipt['uiFailureScreenshot'] = 'UNAVAILABLE'
322
+ raise AcceptanceError('real_profile_ui_not_visible')
323
self.sleep(0.5)
324
require(self.process_state(package) == 'PRESENT', 'ordinary_ui_process_missing')
325
@@ -340,14 +353,19 @@ class Harness:
353
require(QA not in line.split('|'), 'qa_os_notification_present')
354
self._cold(QA)
355
343
- def screenshot(self):
356
+ def screenshot(self, kind='ordinary'):
357
+ require(self.gated and bool(self.seeded & self.launched) and
358
+ kind in ('ordinary', 'ui-failure-original', 'ui-failure-qa'),
359
+ 'synthetic_screenshot_boundary_required')
360
raw = self.binary('screencap -p')
361
require(24 <= len(raw) <= MAX_PAYLOAD_BYTES and raw[:8] == b'\x89PNG\r\n\x1a\n'
362
and raw[12:16] == b'IHDR', 'fictional_screenshot_failed')
363
width, height = struct.unpack('>II', raw[16:24])
364
require(100 <= width <= 4096 and 100 <= height <= 4096, 'fictional_screenshot_failed')
349
- publish_new(self.output.with_suffix('.png'), raw)
350
- self.receipt['fictionalUiScreenshotSha256'] = digest(raw)
365
+ path = (self.output.with_suffix('.png') if kind == 'ordinary' else
366
+ self.output.with_name(self.output.stem + '-' + kind + '.png'))
367
+ publish_new(path, raw)
368
+ self.receipt.setdefault('fictionalScreenshotsSha256', {})[path.name] = digest(raw)
369
370
def run(self):
371
self.preflight()
apps/lifemate/tool/test_personal_recovery_android_test.py
+41
-12
@@ -151,26 +151,55 @@ class RecoveryBoundaryTest(unittest.TestCase):
151
with self.subTest(xml=xml), self.assertRaises(subject.AcceptanceError):
152
subject.notification_preferences_off(xml, choice=choice)
153
154
- def test_ui_requires_valid_profile_text_and_exact_owned_dump_cleanup(self):
154
+ def test_ui_requires_exact_owned_profile_semantics_and_dump_cleanup(self):
155
h = self.make()
156
h.preflight()
157
h.install(subject.ORIGINAL)
158
- xml = '<hierarchy rotation="0"><node text="Fictional آزمایشی"/></hierarchy>'
158
+ xml = ''
159
def shell(*parts, **kwargs):
160
self.adb.calls.append(parts)
161
return xml if parts[0] == 'cat' else ''
162
self.adb.shell = shell
163
- self.assertTrue(h.profile_visible(subject.ORIGINAL))
163
+ for attribute in ('text', 'content-desc'):
164
+ for value in (subject.PROFILE, 'سلام ' + subject.PROFILE):
165
+ with self.subTest(attribute=attribute, value=value):
166
+ xml = f'<hierarchy><node package="{subject.ORIGINAL}" {attribute}="{value}"/></hierarchy>'
167
+ self.assertTrue(h.profile_visible(subject.ORIGINAL))
168
+ for attrs in ('text="not fixture"',
169
+ f'text="extra {subject.PROFILE}"',
170
+ f'content-desc="سلام {subject.PROFILE} extra"',
171
+ f'content-desc="{subject.PROFILE}" package="another.app"',
172
+ f'text="{subject.PROFILE}"'):
173
+ with self.subTest(attrs=attrs):
174
+ xml = '<hierarchy><node ' + attrs + '/></hierarchy>'
175
+ self.assertFalse(h.profile_visible(subject.ORIGINAL))
176
+ for xml in ('<hierarchy><broken>', '<wrong><node/></wrong>'):
177
+ with self.assertRaises(subject.AcceptanceError):
178
+ h.profile_visible(subject.ORIGINAL)
179
dumps = [call for call in self.adb.calls if call[0] == 'uiautomator']
165
- self.assertRegex(dumps[0][2], r'^/data/local/tmp/lifeguide-recovery-[0-9a-f]+\.xml$')
166
- self.assertIn(('rm', dumps[0][2]), self.adb.calls)
167
- xml = '<hierarchy><node text="سلام Fictional آزمایشی"/></hierarchy>'
168
- self.assertTrue(h.profile_visible(subject.ORIGINAL))
169
- xml = '<hierarchy><node text="not fixture"/></hierarchy>'
170
- self.assertFalse(h.profile_visible(subject.ORIGINAL))
171
- xml = '<hierarchy><broken>'
172
- with self.assertRaises(subject.AcceptanceError):
173
- h.profile_visible(subject.ORIGINAL)
180
+ self.assertEqual(len(dumps), 11)
181
+ for call in dumps:
182
+ self.assertRegex(call[2], r'^/data/local/tmp/lifeguide-recovery-[0-9a-f]+\.xml$')
183
+ self.assertIn(('rm', call[2]), self.adb.calls)
184
+
185
+ def test_ui_timeout_keeps_failure_even_if_synthetic_diagnostic_fails(self):
186
+ for diagnostic_fails in (False, True):
187
+ with self.subTest(diagnostic_fails=diagnostic_fails):
188
+ ticks = iter((0, 31))
189
+ h = self.make(clock=lambda: next(ticks))
190
+ h.preflight()
191
+ h.install(subject.ORIGINAL)
192
+ h.seeded.add(subject.ORIGINAL)
193
+ h.profile_visible = lambda _: False
194
+ captures = []
195
+ def screenshot(kind='ordinary'):
196
+ captures.append(kind)
197
+ if diagnostic_fails:
198
+ raise subject.AcceptanceError('fictional_screenshot_failed')
199
+ h.screenshot = screenshot
200
+ with self.assertRaisesRegex(subject.AcceptanceError, '^real_profile_ui_not_visible$'):
201
+ h.launch(subject.ORIGINAL)
202
+ self.assertEqual(captures, ['ui-failure-original'])
203
204
def test_seed_checks_bytes_after_binary_exec_without_overwriting(self):
205
h = self.make()
docs/audits/evidence/personal-recovery-ui-failed-2026-10-22.json
new
+69
@@ -0,0 +1,69 @@
1
+{
2
+ "schemaVersion": 1,
3
+ "status": "FAILED_ACTUAL_ANDROID_ACCEPTANCE",
4
+ "runId": 39843072795,
5
+ "sourceCommit": "c5b548bfd534a41aadf147e0c26e3009147cdb20",
6
+ "artifactId": 12454632195,
7
+ "artifactZipSha256": "8bbd52ac7f77f2772f253ff867bc5059c507e890f5c4d75cf8482cf42e14c501",
8
+ "rootVerifiedArtifactDigest": true,
9
+ "receipt": {
10
+ "apks": {
11
+ "original": {
12
+ "package": "ir.lifeguide.app.device",
13
+ "sha256": "c24ff6e75a987945399b0d96129f5d1a72525fa0270f31b0c481f9780f84db8e",
14
+ "versionCode": 9,
15
+ "versionName": "0.7.2-personal.1"
16
+ },
17
+ "qaNeverDistribute": {
18
+ "package": "ir.lifeguide.app.personal",
19
+ "sha256": "4a8bcdcfd5c0cef91160088f437a6def7bef8a8ec885d59eae925fa3af920080",
20
+ "versionCode": 10,
21
+ "versionName": "0.7.2-recovery-qa.10"
22
+ },
23
+ "upgradeNeverDistribute": {
24
+ "package": "ir.lifeguide.app.personal",
25
+ "sha256": "a34d44c770b434a5794af4a8ea8e86deac8e870f14469c2b3b077b920c4f7d76",
26
+ "versionCode": 11,
27
+ "versionName": "0.7.2-recovery-qa.11"
28
+ }
29
+ },
30
+ "canonicalSnapshotSha256": "f64bf8f30e41dc4eddca18629f2ca950839fdb11f489c85889a40500739c06f9",
31
+ "certificatesSha256": [
32
+ "4ef990d647fc98ac41113d5dbe7ee476ba80bf95b71b5f219b7863fa95263391",
33
+ "b07d4520f095c209d76c45ef7e9393c6439add86fb007ebdaee744fc6e3a0dce",
34
+ "b07d4520f095c209d76c45ef7e9393c6439add86fb007ebdaee744fc6e3a0dce"
35
+ ],
36
+ "checks": {
37
+ "allApksAndFreshEmulatorGatedBeforeInstall": "PASS"
38
+ },
39
+ "counts": {
40
+ "local_occurrences": 4,
41
+ "local_plans": 4,
42
+ "local_profiles": 1,
43
+ "local_weekly_slots": 3
44
+ },
45
+ "currentPhase": "original_seed_and_ordinary_ui",
46
+ "errorCode": "real_profile_ui_not_visible",
47
+ "limitations": {
48
+ "Doze": "UNVERIFIED",
49
+ "USB": "UNVERIFIED",
50
+ "Windows": "UNVERIFIED",
51
+ "distributionApk": "UNVERIFIED",
52
+ "originalNotificationsEnabled": "UNVERIFIED",
53
+ "ownerData": "UNVERIFIED",
54
+ "ownerSigningKey": "UNVERIFIED",
55
+ "physicalDevice": "UNVERIFIED",
56
+ "powerLossOrFullDisk": "UNVERIFIED",
57
+ "reboot": "UNVERIFIED",
58
+ "soundOrVibration": "UNVERIFIED"
59
+ },
60
+ "result": "FAIL",
61
+ "schemaVersion": 1,
62
+ "syntheticDataOnly": true
63
+ },
64
+ "diagnosis": {
65
+ "status": "HYPOTHESIS_PENDING_ANDROID_RERUN",
66
+ "sdkSource": "Flutter engine BaseRoleConfigurator.configureLabelAndValue (local SDK source)",
67
+ "observation": "Non-text-field label is setContentDescription; previous predicate checked only text. Ordinary original greeting template independently checked against delivered source."
68
+ }
69
+}