2f894d9e3a5a
make device revocation one verified transaction so a removed device cannot lose its revocation record
- time
- 2026-09-10 17:55 UTC · 2 months ago
- machine
- koh2
- agent
- deepseek/deepseek-v4-flash
- session
- cross-client remediation
- parent
- 6f8acb922850
↓ peach-android-2f894d9e.tar.gzatlas at this save
files changed2 files
VERSION+1 −1app/src/main/java/com/peachpasswords/sync/PairedDeviceStore.kt+22 −8app/src/main/java/com/peachpasswords/sync/PairedDeviceStore.kt+22 −8
@@ -202,12 +202,17 @@202202 revokedByDeviceId = revokedByDeviceId,203203 nowMs = nowMs,204204 )205- if (mutation.revocations !== currentRevocations) {206- persistRevocations(mutation.revocations)205+ // One verified transaction for both keys. Two independent apply() calls206+ // can land separately, and a device removed without its revocation207+ // record stops being blocked from re-admission — a silent failure of the208+ // ejection path rather than a visible error.209+ val nextPrefs = RegistryPrefsState(210+ devices = json.encodeToString(listSerializer, mutation.devices),211+ revocations = json.encodeToString(revocationSerializer, mutation.revocations),212+ )213+ check(commitWithRollback(readPrefsState(), nextPrefs, ::writePrefsState)) {214+ "paired_device_persist_failed"207215 }208- if (mutation.devices != currentDevices) {209- persist(mutation.devices)210- }211216 mutation.added212217 }213218 @@ -309,10 +314,19 @@309314 }310315 }311316 317+ /**318+ * Revocation mutations must be durable and verified. `apply()` returns319+ * before the write is on disk, and losing the terminal ledger silently320+ * un-revokes devices, so the ledger is never written that way.321+ */312322 private fun persistRevocations(records: List<DeviceRevocation>) {313- prefs.edit()314- .putString(KEY_REVOCATIONS, json.encodeToString(revocationSerializer, records))315- .apply()323+ val prior = readPrefsState()324+ val next = prior.copy(325+ revocations = json.encodeToString(revocationSerializer, records),326+ )327+ check(commitWithRollback(prior, next, ::writePrefsState)) {328+ "paired_device_persist_failed"329+ }316330 }317331 318332 private fun persist(devices: List<PairedDevice>) {