Modern Apps git

← Modern-Apps.git

web: make platform backup re-key the browser database

Commit
c6d0dd530cd9719a2cea3add4439651b9af3d2ac
Author
Vayun Mathur <[email protected]>
When
2026-12-04 21:59 UTC (1 day ago)
Parents
1c33623
Device-to-device transfer copied the raw SQLCipher web-browser-db, whose passphrase is wrapped by the old device's non-exportable AndroidKeyStore key, so the restored database could not be opened and bookmarks/history were lost or crashed first launch.

Add platform/AppBackupAgent (BaseBackupAgent + SqlCipherDbCodec, following weather): the database is exported to plaintext inside the backup payload and re-encrypted under the restore device's passphrase, and web_prefs (settings plus open tabs, whose URLs duplicate the history in the database) is carried as a preference file. webDbConfigs mints a passphrase on a never-run restore target, as the Room builder does, so the codec encrypts under the passphrase Room later reads. Declare the agent in the manifest.

Rewrite data_extraction_rules identically for cloud-backup and device-transfer: exclude the raw database and its -wal/-shm/-journal sidecars, secure_prefs.xml, file/shields and file/favicons (regenerable), and the whole root/app_webview profile. Cookies decision, explicit: cookies are live session credentials and the WebView profile embeds device-bound session state, so nothing under app_webview is copied raw on either channel; the user signs in again after restore. External storage is not included.

Add WebPlatformBackupTest (Robolectric, host-strongest): manifest/agent wiring, webDbConfigs mint-then-reuse with a fake AndroidKeyStore, a byte-identical web_prefs backup/restore round trip through the real agent, a failed codec import against DB_NAME leaving the live database untouched, and parsing of both rule sections for coherence. The native sqlcipher_export/re-encrypt step itself cannot run on a host JVM; that remainder is covered on device by :library:room's codec.

Verified: ./gradlew :web:lint :web:lintVitalRelease :web:testDevUnitTest (374 tests, 0 failures) with the devvm JDK/Android env and --max-workers=128. An initial lint error (FullBackupContent on an external exclude with no include) was introduced by this change and fixed by omitting the external include; no pre-existing failures remain.

Diff

web/AGENTS.md
diff --git a/web/AGENTS.md b/web/AGENTS.mdindex 9feffa124b..b301e01480 100644--- a/web/AGENTS.md+++ b/web/AGENTS.md@@ -21,6 +21,7 @@ _Install: ./install web (dev by default)._ **Architecture / data-flow:** `ui/` chrome (omnibox, menu, tab switcher, panels) → `platform/WebViewModel` (+ split `Permissions`/`SiteData` helpers, `BrowserState`) → `data/WebRepository` over Room (bookmarks/history/tabs/favicons) + `platform/shields/ShieldsEngine` on the network path; `platform/ContentFilters` + `ThumbnailCapture` + `WindowLauncher` support. **Entry points + reading order:** `Route` → `MainActivity.kt` → `Navigation.kt` → `ui/BrowserPage.kt` → `platform/WebViewModel.kt` → `platform/shields/ShieldsEngine.kt` → `domain/shields/UrlCleaner.kt`. **Gotchas:**+- Backup/restore goes through `platform/AppBackupAgent` + `SqlCipherDbCodec`, never a raw copy of `web-browser-db` or `secure_prefs.xml`: the SQLCipher passphrase is wrapped by a non-exportable AndroidKeyStore key, so a raw restored database cannot be opened. `app_webview/` is excluded on both backup channels — its cookies are live session credentials and must not be transplanted; users sign in again after a restore - `SYSTEM` trust bundle is intentional here (arbitrary user hosts) — do NOT "fix" it to a narrower bundle - Shields filtering runs on the request path — regressions break all browsing; test with Shields on AND off - PWA windows run outside the browser chrome (`PwaActivity` + `PwaHelper`); window-launch bugs live there, not in `BrowserPage`@@ -33,7 +34,7 @@ _Install: ./install web (dev by default)._ - com/vayunmathur/web/Navigation.kt - com/vayunmathur/web/Route.kt ### data/ — Room (bookmarks/history/tabs/permissions)-- com/vayunmathur/web/data/WebDatabase.kt+- com/vayunmathur/web/data/WebDatabase.kt — `DB_NAME` + `webDbConfigs()` (backup passphrase config; mints the passphrase on a fresh restore target) - com/vayunmathur/web/data/WebRepository.kt - com/vayunmathur/web/data/Bookmark.kt - com/vayunmathur/web/data/HistoryEntry.kt@@ -51,6 +52,7 @@ _Install: ./install web (dev by default)._ ### platform/ + platform/shields/ — ViewModel, PWA, permissions, engine - com/vayunmathur/web/platform/WebViewModel.kt - com/vayunmathur/web/platform/WebViewModelFactory.kt+- com/vayunmathur/web/platform/AppBackupAgent.kt — stock-OS backup agent (`BaseBackupAgent` + `SqlCipherDbCodec`): carries the re-keyed database and `web_prefs`; `app_webview/` (cookies/cache/session state), `secure_prefs.xml`, the raw database files, `shields/` and `favicons/` are excluded in `res/xml/data_extraction_rules.xml` on both channels - com/vayunmathur/web/platform/WebViewModelPermissions.kt - com/vayunmathur/web/platform/WebViewModelSiteData.kt - com/vayunmathur/web/platform/BrowserState.kt
web/src/main/AndroidManifest.xml
diff --git a/web/src/main/AndroidManifest.xml b/web/src/main/AndroidManifest.xmlindex fd94d6f746..e4e3f8aaf7 100644--- a/web/src/main/AndroidManifest.xml+++ b/web/src/main/AndroidManifest.xml@@ -28,6 +28,7 @@      <application         android:allowBackup="true"+        android:backupAgent=".platform.AppBackupAgent"         android:dataExtractionRules="@xml/data_extraction_rules"         android:icon="@mipmap/ic_launcher"         android:label="@string/app_name"
web/src/main/java/com/vayunmathur/web/data/WebDatabase.kt
diff --git a/web/src/main/java/com/vayunmathur/web/data/WebDatabase.kt b/web/src/main/java/com/vayunmathur/web/data/WebDatabase.ktindex 8f2a74a24a..76ed49d14e 100644--- a/web/src/main/java/com/vayunmathur/web/data/WebDatabase.kt+++ b/web/src/main/java/com/vayunmathur/web/data/WebDatabase.kt@@ -9,12 +9,36 @@ import androidx.room3.Upsert import androidx.room3.migration.Migration import androidx.sqlite.SQLiteConnection import androidx.sqlite.execSQL+import android.content.Context+import com.vayunmathur.library.util.DatabaseHelper import com.vayunmathur.library.util.DatabaseMigrations import kotlinx.coroutines.flow.Flow  // Bumped to new file name to avoid old migration crash — fresh install uses this DB. const val DB_NAME = "web-browser-db" +/**+ * Backup config shared by [com.vayunmathur.web.platform.AppBackupAgent].+ *+ * The passphrase must exist before [com.vayunmathur.library.room.SqlCipherDbCodec]+ * can re-encrypt the restored database, but on a restore target the app has+ * never run, so no AndroidKeyStore key or wrapped passphrase exists yet.+ * Minting one here (the same first-open logic the Room builder uses) means+ * the codec encrypts under exactly the passphrase Room will later decrypt+ * from `secure_prefs`. On the backup device the database already exists, so+ * this simply decrypts its existing passphrase.+ */+fun webDbConfigs(context: Context): List<Pair<String, String>> {+    val helper = DatabaseHelper(context)+    val password = if (!helper.isKeyGenerated()) {+        helper.generateKey()+        helper.createAndStorePassphrase(helper.getCipherForEncryption())+    } else {+        helper.getPassphrase()+    }+    return listOf(DB_NAME to password)+}+ /** Contract for history dao. */ @Dao interface HistoryDao {
web/src/main/java/com/vayunmathur/web/platform/AppBackupAgent.kt
diff --git a/web/src/main/java/com/vayunmathur/web/platform/AppBackupAgent.kt b/web/src/main/java/com/vayunmathur/web/platform/AppBackupAgent.ktnew file mode 100644index 0000000000..f97f196552--- /dev/null+++ b/web/src/main/java/com/vayunmathur/web/platform/AppBackupAgent.kt@@ -0,0 +1,43 @@+package com.vayunmathur.web.platform++import com.vayunmathur.library.room.SqlCipherDbCodec+import com.vayunmathur.library.util.BaseBackupAgent+import com.vayunmathur.web.data.webDbConfigs++/**+ * Stock-OS backup agent for the browser.+ *+ * Cloud backup uses key/value backup through this agent (declared in the+ * manifest without `fullBackupOnly`), and device-to-device transfer produces+ * the same payload through the platform's backup infrastructure, so both+ * channels carry exactly this content:+ *+ *  - [com.vayunmathur.web.data.DB_NAME], exported by [SqlCipherDbCodec] to a+ *    plaintext SQLite file inside the payload and re-encrypted under the+ *    restore device's own passphrase. The raw SQLCipher file is never copied:+ *    its passphrase is wrapped by the old device's non-exportable+ *    AndroidKeyStore key, so a raw copy could not be opened after restore.+ *    The database holds the user data worth preserving — bookmarks, folders,+ *    history, site permissions, downloads metadata, installed sites and+ *    per-site shield settings.+ *  - `web_prefs`: browser settings plus the serialized open-tab list. The+ *    tab URLs duplicate history already carried by the database, so this+ *    file adds no new category of data; excluding it would lose settings+ *    (search engine, shields defaults, cache/JS/desktop modes) instead.+ *+ * WebView's own profile (`app_webview/`: cookies, local storage, IndexedDB,+ * service workers, cache) is deliberately not carried by this agent or by+ * the data-extraction rules. Cookies are live session credentials and the+ * profile embeds device-bound session state, so transplanting it would+ * move signed-in sessions to a new device and could not be trusted to open+ * there. Sites are signed into again after a restore; the rest of that+ * profile is cache that rebuilds.+ */+class AppBackupAgent : BaseBackupAgent() {+    override val dbCodec = SqlCipherDbCodec++    override val prefNames: List<String> = listOf("web_prefs")++    override val dbConfigs: List<Pair<String, String>>+        get() = webDbConfigs(this)+}
web/src/main/res/xml/data_extraction_rules.xml
diff --git a/web/src/main/res/xml/data_extraction_rules.xml b/web/src/main/res/xml/data_extraction_rules.xmlindex 6931869224..31480896af 100644--- a/web/src/main/res/xml/data_extraction_rules.xml+++ b/web/src/main/res/xml/data_extraction_rules.xml@@ -1,33 +1,76 @@ <?xml version="1.0" encoding="utf-8"?>-<!-- Browser. Overrides the permissive default in the shared :library module.+<!-- Browser.       Storage audit:        database  web-browser-db  Room: HistoryEntry, Bookmark, BookmarkFolder, SitePermission,                                  StorageInfo, DownloadEntry, InstalledSite (PWAs), ShieldSetting.-       sharedpref web_prefs.xml  Browser + Brave Shields defaults AND the serialized open-tab+                                 Bookmarks and history are user data worth preserving.+       sharedpref web_prefs.xml  Browser + Shields settings AND the serialized open-tab                                  list (full URLs) for every window.+       sharedpref secure_prefs.xml  SQLCipher passphrase, wrapped by a non-exportable+                                 AndroidKeyStore key that never leaves the device.        root       app_webview/   WebView profile: cookies, localStorage, IndexedDB, service-                                 workers. Session credentials.+                                 workers and cache. Cookies are live session credentials+                                 and the profile embeds device-bound session state.        file       shields/       ~8 MB serialized adblock engine snapshot, rebuilt from the                                  bundled assets whenever it is missing or stale.+       file       favicons/      Site icons, refetched on demand.+       cache      tab-thumbs/    Tab thumbnails (cacheDir, never backed up).        Downloads go to the public Downloads dir via DownloadManager, not app storage. -     Cloud backup is denied outright, and not reflexively: bookmarks and shield settings are-     worth restoring, but they are not separable from the data that must not leave the device.-     Bookmarks/ShieldSetting share one Room file with browsing history, and the shield/browser-     defaults share one SharedPreferences file with the open-tab URLs. Splitting bookmarks and-     settings into their own stores is the prerequisite for a partial cloud allowlist here. -->+     The raw database must never be copied by a rule on either channel: it is+     SQLCipher-encrypted under a passphrase wrapped by the old device's+     non-exportable AndroidKeyStore key, so a restored copy cannot be opened —+     the restore device mints a fresh key and passphrase, the already-encrypted+     file is skipped by the encryption check, and Room fails to open it.++     Data is preserved instead by .platform.AppBackupAgent (manifest+     android:backupAgent, no fullBackupOnly): cloud backup is key/value+     through that agent, and it uses SqlCipherDbCodec to export the database+     to plaintext inside the backup payload and re-encrypt it under the new+     device's passphrase on restore, plus web_prefs (settings and open tabs;+     the tab URLs duplicate the history already in the database).++     SCOPE: because the backupAgent is declared, the <cloud-backup> section+     below is NOT consulted for cloud backup; it is the correct control if+     the agent is ever removed. <device-transfer> is governed here. Both+     sections are kept identical so the two channels stay coherent: the same+     raw files are withheld either way, and the agent payload is the one+     path that carries the database and preferences.++     WebView profile decision, explicit for both channels: app_webview/ is+     excluded entirely. Its cache is regenerable, and its cookies are live+     session credentials — transplanting them would move signed-in sessions+     to a new device, and the surrounding localStorage/IndexedDB/service-worker+     state is device-bound session state of the same kind. Nothing under+     app_webview/ is copied raw; the user signs in again after a restore. --> <data-extraction-rules>     <cloud-backup>-        <exclude domain="root" path="." />-        <exclude domain="file" path="." />-        <exclude domain="database" path="." />-        <exclude domain="sharedpref" path="." />-        <exclude domain="external" path="." />+        <include domain="root" path="." />+        <exclude domain="root" path="app_webview" />+        <include domain="file" path="." />+        <exclude domain="file" path="shields" />+        <exclude domain="file" path="favicons" />+        <include domain="database" path="." />+        <exclude domain="database" path="web-browser-db" />+        <exclude domain="database" path="web-browser-db-wal" />+        <exclude domain="database" path="web-browser-db-shm" />+        <exclude domain="database" path="web-browser-db-journal" />+        <include domain="sharedpref" path="." />+        <exclude domain="sharedpref" path="secure_prefs.xml" />     </cloud-backup>     <device-transfer>-        <!-- Exclude-only: everything not listed here transfers, which is correct for a-             direct device-to-device migration that never reaches Google's servers. -->+        <include domain="root" path="." />+        <exclude domain="root" path="app_webview" />+        <include domain="file" path="." />         <exclude domain="file" path="shields" />+        <exclude domain="file" path="favicons" />+        <include domain="database" path="." />+        <exclude domain="database" path="web-browser-db" />+        <exclude domain="database" path="web-browser-db-wal" />+        <exclude domain="database" path="web-browser-db-shm" />+        <exclude domain="database" path="web-browser-db-journal" />+        <include domain="sharedpref" path="." />+        <exclude domain="sharedpref" path="secure_prefs.xml" />     </device-transfer> </data-extraction-rules>
web/src/test/java/com/vayunmathur/web/platform/WebPlatformBackupTest.kt
diff --git a/web/src/test/java/com/vayunmathur/web/platform/WebPlatformBackupTest.kt b/web/src/test/java/com/vayunmathur/web/platform/WebPlatformBackupTest.ktnew file mode 100644index 0000000000..92c9f0b2a9--- /dev/null+++ b/web/src/test/java/com/vayunmathur/web/platform/WebPlatformBackupTest.kt@@ -0,0 +1,217 @@+package com.vayunmathur.web.platform++import android.content.Context+import android.content.pm.ApplicationInfo+import android.content.res.XmlResourceParser+import android.os.ParcelFileDescriptor+import androidx.test.core.app.ApplicationProvider+import com.vayunmathur.library.room.SqlCipherDbCodec+import com.vayunmathur.library.util.DatabaseHelper+import com.vayunmathur.testsupport.FakeAndroidKeyStore+import com.vayunmathur.web.data.DB_NAME+import com.vayunmathur.web.data.webDbConfigs+import java.io.File+import kotlin.test.Test+import kotlin.test.assertEquals+import kotlin.test.assertNotNull+import kotlin.test.assertTrue+import org.junit.runner.RunWith+import org.robolectric.RobolectricTestRunner+import org.robolectric.Shadows+import org.robolectric.shadows.BackupDataInputBuilder++/**+ * Stock-OS platform backup for Web's real [AppBackupAgent].+ *+ * Host-strongest evidence available: the SQLCipher codec's native library+ * cannot load on a host JVM, so a true encrypted-database round trip cannot+ * run here (the library's own codec tests prove its pre-native contract and+ * that a failed import leaves the live database untouched; that import+ * safety is re-proven below against Web's actual database name). What this+ * test does prove end to end on the host:+ *+ *  - the manifest selects [AppBackupAgent] (key/value cloud backup, coherent+ *    with the device-transfer rules parsed below);+ *  - the agent's wiring: codec, the one database config and `web_prefs`;+ *  - a backup -> restore round trip of the declared preferences through+ *    Robolectric's backup-data streams, byte-identical at the file level;+ *  - [webDbConfigs] mints a passphrase on a fresh (never-run) device and+ *    then reuses it, which is what lets the codec re-encrypt on restore;+ *  - both data-extraction sections exclude the raw SQLCipher database, the+ *    wrapped passphrase and the whole WebView profile on both channels.+ *+ * The remaining device-only step is the codec's sqlcipher_export /+ * re-encrypt itself, exercised on device by :library:room's codec.+ */+@RunWith(RobolectricTestRunner::class)+class WebPlatformBackupTest {++    companion object {+        @org.junit.BeforeClass+        @JvmStatic+        fun installKeyStore() = FakeAndroidKeyStore.install()+    }++    private val ctx: Context get() = ApplicationProvider.getApplicationContext()++    private fun attachedAgent(): AppBackupAgent {+        val agent = AppBackupAgent()+        val attach = android.content.ContextWrapper::class.java+            .getDeclaredMethod("attachBaseContext", Context::class.java)+        attach.isAccessible = true+        attach.invoke(agent, ctx)+        return agent+    }++    private fun pfd(file: File): ParcelFileDescriptor {+        if (!file.exists()) file.writeBytes(ByteArray(0))+        return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_WRITE)+    }++    @Test+    fun manifestSelectsBackupAgentWithBackupAllowed() {+        val info = ctx.packageManager.getApplicationInfo(ctx.packageName, 0)+        assertTrue(info.flags and ApplicationInfo.FLAG_ALLOW_BACKUP != 0, "allowBackup must stay on")+        assertEquals(+            "com.vayunmathur.web.platform.AppBackupAgent",+            info.backupAgentName,+            "manifest must declare the codec backup agent",+        )+    }++    @Test+    fun agentWiringCarriesDatabaseAndPrefsOnly() {+        val agent = AppBackupAgent()+        assertTrue(agent.dbCodec === SqlCipherDbCodec, "database must go through the re-keying codec")+        assertEquals(listOf("web_prefs"), agent.prefNames)+        assertTrue(agent.datastoreNames.isEmpty(), "web has no DataStore")+        assertTrue(agent.extraFiles.isEmpty(), "no raw files (favicons/shields/app_webview) are carried")+    }++    @Test+    fun webDbConfigsMintsThenReusesPassphrase() {+        DatabaseHelper(ctx).deleteKey()+        try {+            val first = webDbConfigs(ctx)+            assertEquals(listOf(DB_NAME), first.map { it.first })+            assertTrue(first.single().second.isNotBlank(), "a passphrase is minted on a fresh device")+            assertEquals(first, webDbConfigs(ctx), "the minted passphrase is the one Room will reuse")+        } finally {+            DatabaseHelper(ctx).deleteKey()+        }+    }++    @Test+    fun backupThenRestoreRoundTripsWebPrefs() {+        val agent = attachedAgent()+        ctx.getSharedPreferences("web_prefs", Context.MODE_PRIVATE).edit()+            .putString("web_search_engine", "BING")+            .putBoolean("web_js_enabled", false)+            .putString("web_saved_tabs", "[{\"id\":\"t1\"}]")+            .commit()+        val prefsFile = File(ctx.dataDir, "shared_prefs/web_prefs.xml")+        assertTrue(prefsFile.exists(), "seeded prefs file exists")+        val seededBytes = prefsFile.readBytes()++        val stateFile = File(ctx.cacheDir, "web-backup-state.bin").apply { delete() }+        val output = org.robolectric.shadows.BackupDataOutputFactory.newInstance()+        agent.onBackup(null, output, pfd(stateFile))+        val entities = Shadows.shadowOf(output).entities+        assertEquals(1, entities.size)+        assertEquals("full_backup", entities.single().key())++        ctx.getSharedPreferences("web_prefs", Context.MODE_PRIVATE).edit().clear().commit()+        prefsFile.delete()+        assertTrue(!prefsFile.exists())++        val restoreState = File(ctx.cacheDir, "web-restore-state.bin").apply { delete() }+        val input = BackupDataInputBuilder.newBuilder().addEntity(entities.single()).build()+        agent.onRestore(input, 1, pfd(restoreState))++        assertTrue(prefsFile.exists(), "prefs XML restored")+        assertEquals(seededBytes.toList(), prefsFile.readBytes().toList(), "prefs restore byte-identically")+        assertEquals(8, restoreState.length())+    }++    @Test+    fun failedCodecImportLeavesLiveDatabaseUntouched() {+        val dbFile = ctx.getDatabasePath(DB_NAME)+        dbFile.parentFile?.mkdirs()+        val liveBytes = ByteArray(64) { 7 }+        dbFile.writeBytes(liveBytes)+        val wal = File("${dbFile.path}-wal").apply { writeBytes(byteArrayOf(2)) }+        val shm = File("${dbFile.path}-shm").apply { writeBytes(byteArrayOf(3)) }+        val input = File(ctx.cacheDir, "web-corrupt-plaintext.db")+        input.writeBytes(ByteArray(64) { 0x55 })+        try {+            // Host cannot load SQLCipher (and this input is not SQLite at+            // all): either way the import must fail before any swap.+            runCatching {+                SqlCipherDbCodec.importDatabase(ctx, DB_NAME, "pw", input)+            }+            assertTrue(dbFile.exists())+            assertEquals(liveBytes.toList(), dbFile.readBytes().toList())+            assertEquals(listOf<Byte>(2), wal.readBytes().toList())+            assertEquals(listOf<Byte>(3), shm.readBytes().toList())+            val leftovers = dbFile.parentFile?.listFiles()+                ?.filter { it.name.contains(".import-") || it.name.contains(".bak-") }+                .orEmpty()+            assertTrue(leftovers.isEmpty(), "leftover swap files: $leftovers")+        } finally {+            dbFile.delete(); wal.delete(); shm.delete(); input.delete()+        }+    }++    @Test+    fun extractionRulesExcludeRawDatabasePassphraseAndWebViewOnBothChannels() {+        val resId = ctx.resources.getIdentifier("data_extraction_rules", "xml", ctx.packageName)+        assertTrue(resId != 0, "manifest dataExtractionRules resource resolves")+        val parser: XmlResourceParser = ctx.resources.getXml(resId)+        val sections = mutableMapOf<String, MutableList<Triple<String, String, String>>>()+        var section: String? = null+        var event = parser.eventType+        while (event != XmlResourceParser.END_DOCUMENT) {+            if (event == XmlResourceParser.START_TAG) {+                when (parser.name) {+                    "cloud-backup", "device-transfer" -> {+                        section = parser.name+                        sections[section] = mutableListOf()+                    }+                    "include", "exclude" -> section?.let {+                        sections.getValue(it).add(+                            Triple(+                                parser.name,+                                parser.getAttributeValue(null, "domain") ?: "",+                                parser.getAttributeValue(null, "path") ?: "",+                            ),+                        )+                    }+                }+            }+            if (event == XmlResourceParser.END_TAG && parser.name in sections) section = null+            event = parser.next()+        }+        assertEquals(+            sections["cloud-backup"]?.toSet(), sections["device-transfer"]?.toSet(),+            "cloud and device-transfer rules must be coherent",+        )+        for (channel in listOf("cloud-backup", "device-transfer")) {+            val rules = sections[channel].orEmpty()+            fun has(action: String, domain: String, path: String) =+                Triple(action, domain, path) in rules+            assertTrue(has("include", "database", "."), "$channel includes databases generally")+            assertTrue(has("exclude", "database", "web-browser-db"), "$channel must not copy the raw DB")+            assertTrue(has("exclude", "database", "web-browser-db-wal"), "$channel excludes the WAL")+            assertTrue(has("exclude", "database", "web-browser-db-shm"), "$channel excludes the SHM")+            assertTrue(has("exclude", "database", "web-browser-db-journal"), "$channel excludes the journal")+            assertTrue(has("exclude", "sharedpref", "secure_prefs.xml"), "$channel excludes the wrapped passphrase")+            assertTrue(has("exclude", "root", "app_webview"), "$channel excludes cookies/cache/WebView profile")+            assertTrue(has("exclude", "file", "shields"), "$channel excludes the regenerable shields snapshot")+            assertTrue(+                rules.none { it.first == "include" && it.second == "external" },+                "$channel must not include external storage",+            )+        }+        assertNotNull(sections["cloud-backup"])+    }+}