@davoodmehraban89 / LifeMate / commits / c5942f4
Fork 0

LifeMate — Personal, Family & Learning Companion

test: diagnose cold SQLite sidecars without reading or publishing records

Quinn White committed Oct 22, 2026 at 20:24 UTC c5942f4d06f9df87ee5874553309b75aa658d27d
3 files changed +126
apps/lifemate/tool/test_personal_recovery_android.py
+26
@@ -257,9 +257,35 @@ class Harness:
257 f'if [ -e {shm} ]; then printf EMPTY_WAL_SHM; else printf EMPTY_WAL; fi; '
258 'else printf SIDECAR; fi')
259 output = self.adb.shell('run-as', package, 'sh', '-c', query).strip()
260 + if output not in ('CLEAN', 'EMPTY_WAL', 'EMPTY_WAL_SHM'):
261 + self._diagnose_cold_files(package)
262 require(output in ('CLEAN', 'EMPTY_WAL', 'EMPTY_WAL_SHM'), 'database_sidecar_present')
263 return output
264
265 + def _diagnose_cold_files(self, package):
266 + """Metadata only, never file contents; diagnosis cannot mask the refusal."""
267 + self.receipt['lastColdFileObservation'] = 'UNAVAILABLE'
268 + try:
269 + commands = []
270 + for label, suffix in (('main', ''), ('wal', '-wal'), ('shm', '-shm'), ('journal', '-journal')):
271 + path = DATABASE + suffix
272 + commands.append(f'printf "{label} "; '
273 + f'if [ -L {path} ]; then echo SYMLINK; '
274 + f'elif [ -f {path} ]; then printf "FILE "; stat -c %s {path}; '
275 + f'elif [ -e {path} ]; then echo OTHER; else echo ABSENT; fi')
276 + raw = self.adb.shell('run-as', package, 'sh', '-c', '; '.join(commands))
277 + require(len(raw) <= 256, 'invalid_file_metadata')
278 + report = {}
279 + for line in raw.splitlines():
280 + match = re.fullmatch(r'(main|wal|shm|journal) (ABSENT|SYMLINK|OTHER|FILE ([0-9]{1,12}))', line)
281 + require(match is not None and match[1] not in report, 'invalid_file_metadata')
282 + report[match[1]] = ({'kind': 'FILE', 'bytes': int(match[3])} if match[3]
283 + else {'kind': match[2]})
284 + require(set(report) == {'main', 'wal', 'shm', 'journal'}, 'invalid_file_metadata')
285 + self.receipt['lastColdFileObservation'] = report
286 + except Exception:
287 + pass
288 +
289 def _remote(self, package, script):
290 self._owned(package)
291 return 'run-as ' + package + ' sh -c ' + shlex.quote(script)
apps/lifemate/tool/test_personal_recovery_android_test.py
+22
@@ -147,6 +147,28 @@ class RecoveryBoundaryTest(unittest.TestCase):
147 with self.assertRaisesRegex(subject.AcceptanceError, 'database_sidecar_present'):
148 h.capture(subject.ORIGINAL)
149
150 + def test_sidecar_refusal_records_only_strict_file_metadata(self):
151 + h = self.make()
152 + h.preflight()
153 + h.install(subject.ORIGINAL)
154 + previous_shell = self.adb.shell
155 + metadata = 'main FILE 45056\nwal FILE 32768\nshm FILE 32768\njournal ABSENT\n'
156 + def shell(*parts, **kwargs):
157 + if parts[0] == 'run-as' and 'stat -c' in parts[-1]:
158 + return metadata
159 + return previous_shell(*parts, **kwargs)
160 + self.adb.shell = shell
161 + self.adb.sidecars = 'SIDECAR'
162 + with self.assertRaisesRegex(subject.AcceptanceError, '^database_sidecar_present$'):
163 + h._cold(subject.ORIGINAL)
164 + self.assertEqual(h.receipt['lastColdFileObservation']['wal'],
165 + {'kind': 'FILE', 'bytes': 32768})
166 + metadata = 'untrusted diagnostic content must not be published'
167 + with self.assertRaisesRegex(subject.AcceptanceError, '^database_sidecar_present$'):
168 + h._cold(subject.ORIGINAL)
169 + self.assertEqual(h.receipt['lastColdFileObservation'], 'UNAVAILABLE')
170 + self.assertNotIn('untrusted', json.dumps(h.receipt))
171 +
172 def test_actual_exited_sqlite_reader_leaves_empty_wal_cache_only(self):
173 source = self.directory / 'real-closed-reader.sqlite'
174 fixture = subject.create_sample_database()
docs/audits/evidence/personal-recovery-empty-wal-failed-2026-10-22.json new
+78
@@ -0,0 +1,78 @@
1 +{
2 + "schemaVersion": 1,
3 + "status": "FAILED_ACTUAL_ANDROID_ACCEPTANCE",
4 + "sourceCommit": "00bb8eec1898757ad9c197eb9327135fb1e69dfd",
5 + "runId": 39847051850,
6 + "artifactId": 12455653998,
7 + "artifactZipSha256": "c1ba477e1873b7b5741af04b9a905e9c40bf779881660ba5a588c12916c0f816",
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": "70c8f8a0d0b7dccfb4df9c086a34ac0bfa0eefbc037e55b6c2b73fd0942f4943",
20 + "versionCode": 10,
21 + "versionName": "0.7.2-recovery-qa.10"
22 + },
23 + "upgradeNeverDistribute": {
24 + "package": "ir.lifeguide.app.personal",
25 + "sha256": "c9efc6ee9c452c67fb8a4293f37dd7f8ce913ab76f4fbbd04362eb10b8568022",
26 + "versionCode": 11,
27 + "versionName": "0.7.2-recovery-qa.11"
28 + }
29 + },
30 + "canonicalSnapshotSha256": "f64bf8f30e41dc4eddca18629f2ca950839fdb11f489c85889a40500739c06f9",
31 + "certificatesSha256": [
32 + "4ef990d647fc98ac41113d5dbe7ee476ba80bf95b71b5f219b7863fa95263391",
33 + "736801f88a2a64a7929a5d32c4589a28de1aeea3bac7c13daced4cf65ee6f9ab",
34 + "736801f88a2a64a7929a5d32c4589a28de1aeea3bac7c13daced4cf65ee6f9ab"
35 + ],
36 + "checks": {
37 + "allApksAndFreshEmulatorGatedBeforeInstall": "PASS"
38 + },
39 + "coldCaptureStates": {
40 + "ir.lifeguide.app.device": "CLEAN"
41 + },
42 + "counts": {
43 + "local_occurrences": 4,
44 + "local_plans": 4,
45 + "local_profiles": 1,
46 + "local_weekly_slots": 3
47 + },
48 + "currentPhase": "original_seed_and_ordinary_ui",
49 + "errorCode": "database_sidecar_present",
50 + "fictionalScreenshotsSha256": {
51 + "personal-recovery-android.png": "f28d962b8e665f82867ee227c7e2b89db5daf939efb63a8c2c824b9a7f53e5d3"
52 + },
53 + "lastUiObservation": {
54 + "exactContentDescriptionMatch": true,
55 + "exactTextMatch": false,
56 + "nodeCount": 30,
57 + "ownedPackageNodeCount": 30,
58 + "package": "ir.lifeguide.app.device"
59 + },
60 + "limitations": {
61 + "Doze": "UNVERIFIED",
62 + "USB": "UNVERIFIED",
63 + "Windows": "UNVERIFIED",
64 + "distributionApk": "UNVERIFIED",
65 + "originalNotificationsEnabled": "UNVERIFIED",
66 + "ownerData": "UNVERIFIED",
67 + "ownerSigningKey": "UNVERIFIED",
68 + "physicalDevice": "UNVERIFIED",
69 + "powerLossOrFullDisk": "UNVERIFIED",
70 + "reboot": "UNVERIFIED",
71 + "soundOrVibration": "UNVERIFIED"
72 + },
73 + "result": "FAIL",
74 + "schemaVersion": 1,
75 + "syntheticDataOnly": true
76 + },
77 + "diagnosis": "Empty-WAL relaxation did not resolve actual Android refusal; exact sidecar kinds/sizes unverified. Add bounded metadata-only diagnostic, retain fail-closed capture; do not guess or remove/checkpoint files."
78 +}