[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6C587HJC1SVAPYEZHJBV1C7":3,"skill-same:01M6C587HJC1SVAPYEZHJBV1C7":117},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":14,"repositoryHtmlUrl":47,"repositoryHomepageUrl":48,"ownerHtmlUrl":49,"ownerBlogUrl":50,"ownerDescription":51,"updatedAt":52,"install":53,"resources":66},"01M6C587HJC1SVAPYEZHJBV1C7","storage-lifecycle",null,"Ditto SDK data removal and local storage management covering DELETE vs soft delete vs EVICT, tombstones and their TTL, husk documents, eviction with complementary subscriptions, retention cleanup, and storage monitoring. Use when writing Ditto DELETE or EVICT statements, soft-delete flags or retention cleanup for Ditto documents, or TOMBSTONE_TTL_HOURS, or when deleted Ditto data came back or evicted documents sync back.","ditto-examples\u002Fditto-cookbook","ditto-examples","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F192611150?v=4","01M6C57F0Y1W6S5D9RD8GHE3YB","Ditto Examples","01M6C57F52Z11DDMBC0ZJ7FJPG",0,"MIT","https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fstorage-lifecycle\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"storage","lifecycle","storage lifecycle","ditto","ttl","when","subscriptions","with","local","retention","evict","back","monitoring","documents","use","writing","cleanup","sync","sdk","delete","2026-11-10 10:12:30",false,"---\nname: storage-lifecycle\ndescription: \"Ditto SDK data removal and local storage management covering DELETE vs soft delete vs EVICT, tombstones and their TTL, husk documents, eviction with complementary subscriptions, retention cleanup, and storage monitoring. Use when writing Ditto DELETE or EVICT statements, soft-delete flags or retention cleanup for Ditto documents, or TOMBSTONE_TTL_HOURS, or when deleted Ditto data came back or evicted documents sync back.\"\n---\n\n# Ditto Storage Lifecycle\n\nChoosing how to remove data (`DELETE`, soft delete, `EVICT`), tombstone settings, and keeping local storage bounded. Targets Ditto SDK 5.2.0; the rules are the same in every SDK.\n\n## Before You Apply\n\n- Identify the project's SDK and version: Flutter (`ditto_live` in `pubspec.yaml` \u002F `pubspec.lock`), JavaScript (`@dittolive\u002Fditto` in `package.json`), Kotlin (`com.ditto:ditto-kotlin` in Gradle files), or Swift (`DittoSwift` in `Package.swift`, `Package.resolved`, or the Xcode project). These rules target SDK 5.2.0; for devices that still run 5.1.0, also apply `§ Known Issues in SDK 5.1.0`. **Note (SDK 5.1.0 and 5.2.0)** and **Note (SDK 5.1.0)** mark easy-to-miss behavior seen on those releases, with the safe pattern; **(SDK 5.1+)** \u002F **(SDK 5.2+)** mark features introduced in that release.\n- For API calls, Grep the outline of that SDK's page, `${CLAUDE_SKILL_DIR}\u002F..\u002Fguide\u002Freference\u002Fbest-practices\u002Fplatforms\u002F\u003Csdk>.md` (`flutter`, `javascript`, `kotlin`, `swift`), with `^#{1,3} ` and read only the section you need, not the whole page; sections are named `\u003CTopic> in \u003CSDK>`. DQL examples: `examples\u002F*.sql` (every SDK); API examples: `examples\u002F\u003Csdk>\u002F`, with the same base names in every SDK.\n- `§ \u003CHeading>` cites the full guide: Grep the heading as a fixed string in `best-practices\u002F` and `knowledge\u002F` under `${CLAUDE_SKILL_DIR}\u002F..\u002Fguide\u002Freference\u002F`, then read that section.\n- Report each finding at the severity of its item in `§ Anti-Pattern Checklist` (the checklist decides; Grep a phrase of the item there). The labels below rank the rules, not each item in them.\n\n## Prevents\n\n- Deleted data resurrected by devices offline longer than the tombstone TTL; a Small Peer TTL above the Ditto Server TTL\n- `DELETE`\u002F`EVICT` with `USE IDS` and no `WHERE` predicate silently removing nothing (SDK 5.1.0)\n- Soft-delete filters (`isDeleted != true`) that hide documents where the flag is missing or `null`\n- Soft-deleted documents excluded from subscriptions, so relays cannot pass the flag on\n- Husk documents from `DELETE` racing a concurrent `UPDATE`; evicted documents syncing straight back\n- Evicting too often and overloading connected peers with resyncs\n\n## Choosing a Removal Strategy\n\n| Requirement | `DELETE` | Soft delete | `EVICT` |\n|---|---|---|---|\n| Remove data for every peer | ✅ (tombstone) | ✅ (flag, then cleanup) | ❌ (local only) |\n| Safe when devices stay offline longer than the tombstone TTL (7 days by default) | ❌ (data can be resurrected) | ✅ | ✅ (other peers are unaffected) |\n| Safe with concurrent updates on other devices | ❌ (husk documents) | ✅ | ✅ |\n| Can be undone | ❌ | ✅ | ✅ (data syncs back if a subscription matches it again) |\n| Frees local storage | ✅ (values immediately; tombstones after reaping) | ❌ (until cleanup) | ✅ (immediately) |\n| Extra query complexity | None | Every query filters the flag | Subscription and eviction scopes must be complementary |\n\n- **Data owned by one user and rarely edited concurrently**, in a deployment where devices sync regularly: `DELETE`.\n- **Shared business records** (orders, tasks, inventory) or long offline periods: soft delete, cleaned up by a synced `DELETE` (Variant A) or device-side `EVICT` (Variant B); see rule 5.\n- **Storage management on edge devices**: `EVICT` with complementary subscriptions.\n\nWith a Ditto Server (formerly Big Peer), use `DELETE` for permanent removal (typically on the Ditto Server) and `EVICT` to manage storage on edge devices. If you plan to use `DELETE` in a deployment with Small Peers only, contact Ditto support to review the design.\n\n`§ Deletion and Storage Management`, `§ Choosing DELETE, Soft Delete, or EVICT`\n\n## Workflow\n\n```text\n- [ ] Pick DELETE, soft delete, or EVICT with the table above\n- [ ] DELETE: target with WHERE _id IN :ids; every device connects within the tombstone TTL\n- [ ] Soft delete: set isDeleted + deletedAt; filter with coalesce(isDeleted, false) = false\n- [ ] Soft delete: keep flagged documents in the subscriptions of relaying devices; choose Variant A or B cleanup\n- [ ] EVICT: cancel\u002Fnarrow subscriptions, evict the exact complement, re-subscribe with the same cutoff\n- [ ] Schedule eviction at most about once per day; batch large runs with LIMIT\n- [ ] Verify with system:system_info (on demand) and deletion tests\n```\n\n## Rules\n\n### 1. Target DELETE and EVICT with WHERE (CRITICAL)\n\n`WHERE _id IN :ids` is planned as an ID scan and works on every release. On SDK 5.1.0, `DELETE` and `EVICT` with `USE IDS` and no `WHERE` predicate (no `WHERE` clause, or `WHERE true`) complete without an error but remove nothing (`§ Known Issues in SDK 5.1.0`).\n\n**✅ DO**:\n- Target documents with `WHERE _id = :id` or `WHERE _id IN :ids`.\n- Add `RETURNING` (SDK 5.1+) when you need the removed content (undo banner, audit record); the tombstone keeps no values. Read it from the result's `items` (each document as it was before deletion), not from its mutated document IDs.\n\n**❌ DON'T**:\n- Write `DELETE FROM orders USE IDS LIST :ids` or `EVICT FROM orders USE IDS 'a'` while any device runs SDK 5.1.0.\n- Use `DELETE` to free space on one device; it removes the data for every peer.\n\n```sql\n-- ✅ GOOD: Delete by ID and capture what was removed (SDK 5.1+).\n-- Arguments: {\"ids\": [\"order-1\", \"order-2\"]}\nDELETE FROM orders WHERE _id IN :ids RETURNING _id, status, total\n```\n\n`RETURNING` also accepts aggregates: `DELETE FROM orders WHERE status = 'cancelled' AND createdAt \u003C :cutoff RETURNING COUNT(*) AS removed`.\n\n`§ DELETE and Tombstones`, `§ Capturing deleted content with RETURNING (SDK 5.1+)`, `§ RETURNING (SDK 5.1+)` · Example: [examples\u002Fevict-subscription-management-bad.sql](examples\u002Fevict-subscription-management-bad.sql) (anti-pattern 5, EVICT form)\n\n### 2. Respect the Tombstone TTL (CRITICAL)\n\n`DELETE` leaves a tombstone (document ID, metadata such as the deletion time, and the field names; no values). Each device reaps expired tombstones periodically. A device that stays offline longer than the TTL can reconnect after every other peer has reaped the tombstone and share its old copy again (\"zombie data\").\n\n| System parameter | Default | Meaning |\n|---|---|---|\n| `TOMBSTONE_TTL_ENABLED` | `true` | Expired tombstones are removed automatically |\n| `TOMBSTONE_TTL_HOURS` | `168` (7 days) | Age after which a tombstone expires on this device |\n| `DAYS_BETWEEN_REAPING` | `1` | Days between reaping runs |\n| `TOMBSTONE_REAP_BATCH_SIZE` (SDK 5.1+) | `10000` | Expired tombstones are removed in bounded batches |\n\nInspect with `SHOW ALL LIKE '%tombstone%'`.\n\n**✅ DO**:\n- Make sure every device connects within the tombstone TTL, or use a soft delete for that data.\n- If devices can legitimately stay offline longer than 7 days, raise `TOMBSTONE_TTL_HOURS` on the device, staying at or below the Ditto Server TTL (for 14 days: `{\"TOMBSTONE_TTL_HOURS\": 336}` in the system parameters of `DittoConfig`).\n- Pass system parameters in the system parameters of `DittoConfig` (SDK 5.2+) on every open; they are not persisted. On SDK 5.1, run `ALTER SYSTEM` after every open, before sync starts.\n\n**❌ DON'T**:\n- Configure the Edge TTL (`TOMBSTONE_TTL_HOURS` on Small Peers) above the Ditto Server TTL. The Ditto Server always syncs documents, so tombstones that outlive its copy are sent back to it repeatedly. The Ditto Server tombstone TTL defaults to 30 days; changes to the server side go through Ditto support. \u003C!-- lint-ignore -->\n- Choose a very short TTL; the tombstone can expire before it reaches the other peers.\n- Look for a tombstone-lifetime method on the SDK: the TTL is a system parameter.\n\nClock skew, off-hours reaping, and what else `DELETE` leaves behind (re-insert, `INITIAL DOCUMENTS`): [reference\u002Fdeletion-patterns.md](reference\u002Fdeletion-patterns.md#what-delete-leaves-behind).\n\n`§ Tombstone TTL and reaping`, `§ System Parameters Reference`, `§ Applying System Parameters` · Example: [examples\u002Fttl-eviction-small-peer.sql](examples\u002Fttl-eviction-small-peer.sql)\n\n### 3. Filter Soft-Deleted Documents with coalesce (CRITICAL)\n\nIn DQL, a comparison with a missing or `null` field never passes a `WHERE` clause, so `isDeleted != true` and `NOT isDeleted` silently drop every document that has no `isDeleted` field.\n\n| Filter (`isDeleted` is `true`, `false`, `null`, or missing) | Matches |\n|---|---|\n| `isDeleted != true` | `false` only |\n| `NOT isDeleted` | `false` only |\n| `isDeleted = false` | `false` only |\n| `coalesce(isDeleted, false) = false` | `false`, `null`, missing |\n\n**✅ DO**:\n- Soft delete with `UPDATE orders SET isDeleted = true, deletedAt = :deletedAt WHERE _id = :id`, both fields in one statement; `deletedAt` is UTC ISO-8601 with a zone designator, from the same fixed-precision helper as `createdAt`. Cleanup cutoffs never match a flag without `deletedAt`.\n- Write `isDeleted: false` when you create documents.\n- Filter with `coalesce(isDeleted, false) = false` in every query, observer, aggregate, lookup by `_id`, and joined collection that reads the documents.\n- Restore with `UPDATE orders SET isDeleted = false UNSET deletedAt WHERE _id = :id`.\n\n**❌ DON'T**: Filter with `isDeleted != true` or `NOT isDeleted`.\n\n**Indexes**: `coalesce(isDeleted, false) = false` alone cannot use an index on `isDeleted` (collection scan). Lead with an indexed field (`status = :status AND coalesce(...)`) or use the equivalent `isDeleted IS MISSING OR isDeleted IS NULL OR isDeleted = false`; options in [reference\u002Fdeletion-patterns.md](reference\u002Fdeletion-patterns.md#indexing-soft-delete-filters).\n\n`§ Soft Delete`, `§ Indexing soft-delete filters`, `§ MISSING and NULL`, `§ Timestamps` · Example: [examples\u002Fsoft-delete-relay.sql](examples\u002Fsoft-delete-relay.sql) (create, soft delete, restore, query helpers)\n\n### 4. Avoid Husk Documents (CRITICAL)\n\nWhen one device deletes a document while another concurrently updates it, the add-wins merge produces a *husk document*, and the document is **not** deleted, even when the `DELETE` is the later write. In SDK 5.1.0 and 5.2.0, the updated fields keep their new values (or become `null` if the deletion was later), and all other fields are **MISSING**, not `null` as Ditto's docs say.\n\n**✅ DO**:\n- Use a soft delete for data that may be edited concurrently.\n- Manage edge storage with `EVICT` and perform permanent deletion on the Ditto Server.\n- Coordinate workflows so the same document is not deleted and updated at the same time.\n- Make the UI tolerate documents whose fields are `null` or missing if husks are possible, and keep husks out of lists with `WHERE make IS NOT MISSING AND make IS NOT NULL` on a field every live document has (`IS NOT NULL` alone is true for a missing field). \u003C!-- lint-ignore -->\n- Run the `DELETE` again after the merge to remove a husk on every device.\n\n**❌ DON'T**: Use `DELETE` for shared records that other devices edit.\n\nMerge outcomes and a null-tolerant list: [reference\u002Fdeletion-patterns.md](reference\u002Fdeletion-patterns.md#husk-documents).\n\n`§ Husk documents`\n\n### 5. Keep Soft-Deleted Documents in Subscriptions (HIGH)\n\nA subscription that excludes soft-deleted documents (for example `WHERE coalesce(isDeleted, false) = false`) still delivers the flag and a later restore for documents the device holds (SDK 5.1.0 and 5.2.0), but the device cannot relay the flag for documents it did not already hold, and a `DELETE` of a flagged document never reaches it. A subscription filter does not hide documents in local results (rule 3).\n\n**✅ DO**:\n- Keep soft-deleted documents in the subscriptions of devices that relay data to others, at least for as long as a device may stay offline.\n- Hide them in every local query and observer (rule 3); register and release those observers as the SDK page shows (*Store Observers in \u003CSDK>*).\n- Choose one subscription design and clean up accordingly:\n  - **Variant A (whole collection or partition)**: subscribe with `SELECT * FROM orders WHERE storeId = :storeId` (includes flagged documents), owned by a long-lived service. Clean up after the retention period, once flagged documents are no longer edited, with a `DELETE` that syncs to every device, run on the Ditto Server (for example through its HTTP API) or by another authorized peer: `DELETE FROM orders WHERE isDeleted = true AND deletedAt \u003C :cutoff LIMIT 30000`.\n  - **Variant B (retention window)**: subscribe with `coalesce(isDeleted, false) = false OR deletedAt >= :cutoff` and evict exactly the complement (`isDeleted = true AND deletedAt \u003C :cutoff`), cancelling the old subscription first and re-registering it with the moved cutoff. Choose a window longer than the longest expected offline period, so that other devices can still relay the flag, and move the cutoff only when you run cleanup, not on every screen change.\n\n**❌ DON'T**:\n- Subscribe with `WHERE coalesce(isDeleted, false) = false` (or any filter on the flag) alone, unless every device syncs directly with the Ditto Server and evicts flagged documents itself.\n- Evict old soft-deleted documents on a device while a subscription still matches them (Variant A); they sync back.\n\nTrade-offs and the full comparison: [reference\u002Fdeletion-patterns.md](reference\u002Fdeletion-patterns.md#cleaning-up-soft-deleted-documents).\n\n`§ Soft delete, subscriptions, and cleanup`, `§ Multi-hop relay` · Examples: [examples\u002Fsoft-delete-relay.sql](examples\u002Fsoft-delete-relay.sql) (Variant A and B, observer filtering), `retention-service` in `examples\u002F\u003Csdk>\u002F`\n\n### 6. Evict Only Outside Every Active Subscription (HIGH)\n\n`EVICT` removes documents from the local store only; no tombstone is created and other peers keep them. If an active subscription on this device still matches an evicted document, connected peers notice it is missing and sync it back, which can become a loop of evicting and re-syncing.\n\n**✅ DO**:\n- Cancel or narrow the affected subscriptions **before** evicting.\n- Make the eviction query the exact complement of the remaining subscription (same cutoff value, `>=` in the subscription and `\u003C` in the eviction).\n- Keep subscription references in an app-level or feature-level service so you can cancel them.\n- For a large boundary change (for example a store switch), data that was already being transferred can still arrive after cancelling; if the device must not keep it, run the same `EVICT` again later (for example, on the next app start or in a periodic cleanup).\n\n**❌ DON'T**:\n- Evict and then register a subscription that matches the evicted documents again (for example `SELECT * FROM orders`).\n- Evict documents that an active subscription still covers.\n\n```sql\n-- ✅ GOOD: Keep the last 7 days of orders. 1. Cancel the subscription.\n-- 2. Evict exactly the complement of the new subscription:\n-- Arguments: {\"cutoff\": \"2026-10-01T10:30:00.123Z\"}\nEVICT FROM orders WHERE createdAt \u003C :cutoff\n\n-- 3. Subscribe again with the moved boundary, even if the eviction failed:\n-- Arguments: {\"cutoff\": \"2026-10-01T10:30:00.123Z\"}\nSELECT * FROM orders WHERE createdAt >= :cutoff\n```\n\n**Flag-based eviction**: when a central component (typically the Ditto Server, which can make sure documents have synced first) sets `evictionFlag = true`, devices subscribe with `coalesce(evictionFlag, false) = false` and evict `evictionFlag = true`. The subscription never matches flagged documents, so it need not be cancelled before each eviction. Not on relays whose peers can miss the flag: they send the unflagged version back.\n\n`§ EVICT`, `§ Time-based eviction`, `§ Flag-based eviction`, `§ Cancelling subscriptions and local data` · Examples: `retention-service` in `examples\u002F\u003Csdk>\u002F` (the service), [ttl-eviction-small-peer.sql](examples\u002Fttl-eviction-small-peer.sql), [evict-subscription-management-good.sql](examples\u002Fevict-subscription-management-good.sql), [-bad.sql](examples\u002Fevict-subscription-management-bad.sql), [flag-based-eviction.sql](examples\u002Fflag-based-eviction.sql), [ttl-eviction-ditto-server.sql](examples\u002Fttl-eviction-ditto-server.sql)\n\n### 7. Evict on a Schedule, in Batches (HIGH)\n\nEach eviction triggers a resync with every connected peer, which costs network traffic and processing on those peers. (SDK 5.1+) Ditto writes a warning-level log entry when post-eviction session cleanup runs too frequently.\n\n**✅ DO**:\n- Evict on a regular schedule, no more than about once per day, at a quiet time.\n- Split a large cleanup with `LIMIT` and stop when `RETURNING COUNT(*)` reports zero (first cancel or narrow every matching subscription, rule 6).\n- Treat the eviction-frequency warning as a sign to evict less often.\n\n**❌ DON'T**:\n- Evict on every screen change or app resume.\n- Change `DISABLE_REPLICATION_GC_ON_EVICT` (default `false`) unless profiling shows eviction-time write latency.\n\n```sql\n-- ✅ GOOD: Evict in batches of 1,000; repeat until evicted is 0.\n-- Arguments: {\"cutoff\": \"2026-10-01T10:30:00.123Z\"}\nEVICT FROM orders WHERE createdAt \u003C :cutoff LIMIT 1000\nRETURNING COUNT(*) AS evicted\n```\n\nBatching keeps write transactions short. It does not reduce the sync cost of eviction: run the whole batched cleanup on the usual schedule, not as many separate cleanups.\n\n`§ Batching evictions`, `§ Eviction frequency` · Examples: [examples\u002Fttl-eviction-small-peer.sql](examples\u002Fttl-eviction-small-peer.sql), `retention-service` in `examples\u002F\u003Csdk>\u002F`\n\n## Checklist\n\nDELETE:\n- [ ] Targets documents with `WHERE _id = :id` \u002F `WHERE _id IN :ids`, never `USE IDS` without a `WHERE` predicate\n- [ ] Not used to free storage on one device (use `EVICT`)\n- [ ] Uses `RETURNING` (SDK 5.1+) when the removed content is needed\n- [ ] Not used for shared records edited concurrently (husk documents)\n- [ ] Every device connects within the tombstone TTL (7 days by default), or the data uses soft delete\n- [ ] `TOMBSTONE_TTL_HOURS` on devices never exceeds the Ditto Server TTL; set on every open\n- [ ] Large deletions on the Ditto Server run in batches of 30,000 documents or fewer\n\nSoft delete:\n- [ ] Sets `isDeleted` and `deletedAt` (UTC, with zone); new documents get `isDeleted: false`\n- [ ] Every query, observer, aggregate, and joined collection filters with `coalesce(isDeleted, false) = false` (or the index-friendly `IS MISSING OR IS NULL OR = false` form)\n- [ ] Subscriptions of relaying devices keep flagged documents (Variant A: whole collection or partition; Variant B: retention window)\n- [ ] Old flagged documents are cleaned up (Variant A: synced `DELETE`; Variant B: device-side `EVICT` of the complement)\n\nEVICT:\n- [ ] Affected subscriptions are cancelled or narrowed before evicting\n- [ ] Eviction query is the exact complement of the remaining subscriptions\n- [ ] No re-subscription that matches the evicted documents\n- [ ] Runs on a schedule, at most about once per day; large runs use `LIMIT`\n- [ ] Subscription references are kept in a long-lived service\n\nMonitoring:\n- [ ] Storage read from `system:system_info` with `execute` on demand, not with a long-lived observer\n\n## More\n\n- Reference: [reference\u002Fdeletion-patterns.md](reference\u002Fdeletion-patterns.md) - what `DELETE` leaves behind, husks, Ditto Server deletion, soft-delete indexing and cleanup, store switch, eviction, storage monitoring\n- Examples: [examples\u002F](examples\u002F) - one DQL file per pattern, linked from each rule; `examples\u002F\u003Csdk>\u002Fretention-service` for the services that run them\n- Guide sections: `§ Subscription Lifecycle`, `§ Monitoring Storage`, `§ Testing Deletion and Soft Delete`\n- Related skills: `query-sync` (subscriptions, `RETURNING`), `data-modeling` (flag fields, timestamps), `performance-observability` (indexes, observers)\n","# Ditto Storage Lifecycle\n\nChoosing how to remove data (`DELETE`, soft delete, `EVICT`), tombstone settings, and keeping local storage bounded. Targets Ditto SDK 5.2.0; the rules are the same in every SDK.\n\n## Before You Apply\n\n- Identify the project's SDK and version: Flutter (`ditto_live` in `pubspec.yaml` \u002F `pubspec.lock`), JavaScript (`@dittolive\u002Fditto` in `package.json`), Kotlin (`com.ditto:ditto-kotlin` in Gradle files), or Swift (`DittoSwift` in `Package.swift`, `Package.resolved`, or the Xcode project). These rules target SDK 5.2.0; for devices that still run 5.1.0, also apply `§ Known Issues in SDK 5.1.0`. **Note (SDK 5.1.0 and 5.2.0)** and **Note (SDK 5.1.0)** mark easy-to-miss behavior seen on those releases, with the safe pattern; **(SDK 5.1+)** \u002F **(SDK 5.2+)** mark features introduced in that release.\n- For API calls, Grep the outline of that SDK's page, `${CLAUDE_SKILL_DIR}\u002F..\u002Fguide\u002Freference\u002Fbest-practices\u002Fplatforms\u002F\u003Csdk>.md` (`flutter`, `javascript`, `kotlin`, `swift`), with `^#{1,3} ` and read only the section you need, not the whole page; sections are named `\u003CTopic> in \u003CSDK>`. DQL examples: `examples\u002F*.sql` (every SDK); API examples: `examples\u002F\u003Csdk>\u002F`, with the same base names in every SDK.\n- `§ \u003CHeading>` cites the full guide: Grep the heading as a fixed string in `best-practices\u002F` and `knowledge\u002F` under `${CLAUDE_SKILL_DIR}\u002F..\u002Fguide\u002Freference\u002F`, then read that section.\n- Report each finding at the severity of its item in `§ Anti-Pattern Checklist` (the checklist decides; Grep a phrase of the item there). The labels below rank the rules, not each item in them.\n\n## Prevents\n\n- Deleted data resurrected by devices offline longer than the tombstone TTL; a Small Peer TTL above the Ditto Server TTL\n- `DELETE`\u002F`EVICT` with `USE IDS` and no `WHERE` predicate silently removing nothing (SDK 5.1.0)\n- Soft-delete filters (`isDeleted != true`) that hide documents where the flag is missing or `null`\n- Soft-deleted documents excluded from subscriptions, so relays cannot pass the flag on\n- Husk documents from `DELETE` racing a concurrent `UPDATE`; evicted documents syncing straight back\n- Evicting too often and overloading connected peers with resyncs\n\n## Choosing a Removal Strategy\n\n| Requirement | `DELETE` | Soft delete | `EVICT` |\n|---|---|---|---|\n| Remove data for every peer | ✅ (tombstone) | ✅ (flag, then cleanup) | ❌ (local only) |\n| Safe when devices stay offline longer than the tombstone TTL (7 days by default) | ❌ (data can be resurrected) | ✅ | ✅ (other peers are unaffected) |\n| Safe with concurrent updates on other devices | ❌ (husk documents) | ✅ | ✅ |\n| Can be undone | ❌ | ✅ | ✅ (data syncs back if a subscription matches it again) |\n| Frees local storage | ✅ (values immediately; tombstones after reaping) | ❌ (until cleanup) | ✅ (immediately) |\n| Extra query complexity | None | Every query filters the flag | Subscription and eviction scopes must be complementary |\n\n- **Data owned by one user and rarely edited concurrently**, in a deployment where devices sync regularly: `DELETE`.\n- **Shared business records** (orders, tasks, inventory) or long offline periods: soft delete, cleaned up by a synced `DELETE` (Variant A) or device-side `EVICT` (Variant B); see rule 5.\n- **Storage management on edge devices**: `EVICT` with complementary subscriptions.\n\nWith a Ditto Server (formerly Big Peer), use `DELETE` for permanent removal (typically on the Ditto Server) and `EVICT` to manage storage on edge devices. If you plan to use `DELETE` in a deployment with Small Peers only, contact Ditto support to review the design.\n\n`§ Deletion and Storage Management`, `§ Choosing DELETE, Soft Delete, or EVICT`\n\n## Workflow\n\n```text\n- [ ] Pick DELETE, soft delete, or EVICT with the table above\n- [ ] DELETE: target with WHERE _id IN :ids; every device connects within the tombstone TTL\n- [ ] Soft delete: set isDeleted + deletedAt; filter with coalesce(isDeleted, false) = false\n- [ ] Soft delete: keep flagged documents in the subscriptions of relaying devices; choose Variant A or B cleanup\n- [ ] EVICT: cancel\u002Fnarrow subscriptions, evict the exact complement, re-subscribe with the same cutoff\n- [ ] Schedule eviction at most about once per day; batch large runs with LIMIT\n- [ ] Verify with system:system_info (on demand) and deletion tests\n```\n\n## Rules\n\n### 1. Target DELETE and EVICT with WHERE (CRITICAL)\n\n`WHERE _id IN :ids` is planned as an ID scan and works on every release. On SDK 5.1.0, `DELETE` and `EVICT` with `USE IDS` and no `WHERE` predicate (no `WHERE` clause, or `WHERE true`) complete without an error but remove nothing (`§ Known Issues in SDK 5.1.0`).\n\n**✅ DO**:\n- Target documents with `WHERE _id = :id` or `WHERE _id IN :ids`.\n- Add `RETURNING` (SDK 5.1+) when you need the removed content (undo banner, audit record); the tombstone keeps no values. Read it from the result's `items` (each document as it was before deletion), not from its mutated document IDs.\n\n**❌ DON'T**:\n- Write `DELETE FROM orders USE IDS LIST :ids` or `EVICT FROM orders USE IDS 'a'` while any device runs SDK 5.1.0.\n- Use `DELETE` to free space on one device; it removes the data for every peer.\n\n```sql\n-- ✅ GOOD: Delete by ID and capture what was removed (SDK 5.1+).\n-- Arguments: {\"ids\": [\"order-1\", \"order-2\"]}\nDELETE FROM orders WHERE _id IN :ids RETURNING _id, status, total\n```\n\n`RETURNING` also accepts aggregates: `DELETE FROM orders WHERE status = 'cancelled' AND createdAt \u003C :cutoff RETURNING COUNT(*) AS removed`.\n\n`§ DELETE and Tombstones`, `§ Capturing deleted content with RETURNING (SDK 5.1+)`, `§ RETURNING (SDK 5.1+)` · Example: [examples\u002Fevict-subscription-management-bad.sql](examples\u002Fevict-subscription-management-bad.sql) (anti-pattern 5, EVICT form)\n\n### 2. Respect the Tombstone TTL (CRITICAL)\n\n`DELETE` leaves a tombstone (document ID, metadata such as the deletion time, and the field names; no values). Each device reaps expired tombstones periodically. A device that stays offline longer than the TTL can reconnect after every other peer has reaped the tombstone and share its old copy again (\"zombie data\").\n\n| System parameter | Default | Meaning |\n|---|---|---|\n| `TOMBSTONE_TTL_ENABLED` | `true` | Expired tombstones are removed automatically |\n| `TOMBSTONE_TTL_HOURS` | `168` (7 days) | Age after which a tombstone expires on this device |\n| `DAYS_BETWEEN_REAPING` | `1` | Days between reaping runs |\n| `TOMBSTONE_REAP_BATCH_SIZE` (SDK 5.1+) | `10000` | Expired tombstones are removed in bounded batches |\n\nInspect with `SHOW ALL LIKE '%tombstone%'`.\n\n**✅ DO**:\n- Make sure every device connects within the tombstone TTL, or use a soft delete for that data.\n- If devices can legitimately stay offline longer than 7 days, raise `TOMBSTONE_TTL_HOURS` on the device, staying at or below the Ditto Server TTL (for 14 days: `{\"TOMBSTONE_TTL_HOURS\": 336}` in the system parameters of `DittoConfig`).\n- Pass system parameters in the system parameters of `DittoConfig` (SDK 5.2+) on every open; they are not persisted. On SDK 5.1, run `ALTER SYSTEM` after every open, before sync starts.\n\n**❌ DON'T**:\n- Configure the Edge TTL (`TOMBSTONE_TTL_HOURS` on Small Peers) above the Ditto Server TTL. The Ditto Server always syncs documents, so tombstones that outlive its copy are sent back to it repeatedly. The Ditto Server tombstone TTL defaults to 30 days; changes to the server side go through Ditto support. \u003C!-- lint-ignore -->\n- Choose a very short TTL; the tombstone can expire before it reaches the other peers.\n- Look for a tombstone-lifetime method on the SDK: the TTL is a system parameter.\n\nClock skew, off-hours reaping, and what else `DELETE` leaves behind (re-insert, `INITIAL DOCUMENTS`): [reference\u002Fdeletion-patterns.md](reference\u002Fdeletion-patterns.md#what-delete-leaves-behind).\n\n`§ Tombstone TTL and reaping`, `§ System Parameters Reference`, `§ Applying System Parameters` · Example: [examples\u002Fttl-eviction-small-peer.sql](examples\u002Fttl-eviction-small-peer.sql)\n\n### 3. Filter Soft-Deleted Documents with coalesce (CRITICAL)\n\nIn DQL, a comparison with a missing or `null` field never passes a `WHERE` clause, so `isDeleted != true` and `NOT isDeleted` silently drop every document that has no `isDeleted` field.\n\n| Filter (`isDeleted` is `true`, `false`, `null`, or missing) | Matches |\n|---|---|\n| `isDeleted != true` | `false` only |\n| `NOT isDeleted` | `false` only |\n| `isDeleted = false` | `false` only |\n| `coalesce(isDeleted, false) = false` | `false`, `null`, missing |\n\n**✅ DO**:\n- Soft delete with `UPDATE orders SET isDeleted = true, deletedAt = :deletedAt WHERE _id = :id`, both fields in one statement; `deletedAt` is UTC ISO-8601 with a zone designator, from the same fixed-precision helper as `createdAt`. Cleanup cutoffs never match a flag without `deletedAt`.\n- Write `isDeleted: false` when you create documents.\n- Filter with `coalesce(isDeleted, false) = false` in every query, observer, aggregate, lookup by `_id`, and joined collection that reads the documents.\n- Restore with `UPDATE orders SET isDeleted = false UNSET deletedAt WHERE _id = :id`.\n\n**❌ DON'T**: Filter with `isDeleted != true` or `NOT isDeleted`.\n\n**Indexes**: `coalesce(isDeleted, false) = false` alone cannot use an index on `isDeleted` (collection scan). Lead with an indexed field (`status = :status AND coalesce(...)`) or use the equivalent `isDeleted IS MISSING OR isDeleted IS NULL OR isDeleted = false`; options in [reference\u002Fdeletion-patterns.md](reference\u002Fdeletion-patterns.md#indexing-soft-delete-filters).\n\n`§ Soft Delete`, `§ Indexing soft-delete filters`, `§ MISSING and NULL`, `§ Timestamps` · Example: [examples\u002Fsoft-delete-relay.sql](examples\u002Fsoft-delete-relay.sql) (create, soft delete, restore, query helpers)\n\n### 4. Avoid Husk Documents (CRITICAL)\n\nWhen one device deletes a document while another concurrently updates it, the add-wins merge produces a *husk document*, and the document is **not** deleted, even when the `DELETE` is the later write. In SDK 5.1.0 and 5.2.0, the updated fields keep their new values (or become `null` if the deletion was later), and all other fields are **MISSING**, not `null` as Ditto's docs say.\n\n**✅ DO**:\n- Use a soft delete for data that may be edited concurrently.\n- Manage edge storage with `EVICT` and perform permanent deletion on the Ditto Server.\n- Coordinate workflows so the same document is not deleted and updated at the same time.\n- Make the UI tolerate documents whose fields are `null` or missing if husks are possible, and keep husks out of lists with `WHERE make IS NOT MISSING AND make IS NOT NULL` on a field every live document has (`IS NOT NULL` alone is true for a missing field). \u003C!-- lint-ignore -->\n- Run the `DELETE` again after the merge to remove a husk on every device.\n\n**❌ DON'T**: Use `DELETE` for shared records that other devices edit.\n\nMerge outcomes and a null-tolerant list: [reference\u002Fdeletion-patterns.md](reference\u002Fdeletion-patterns.md#husk-documents).\n\n`§ Husk documents`\n\n### 5. Keep Soft-Deleted Documents in Subscriptions (HIGH)\n\nA subscription that excludes soft-deleted documents (for example `WHERE coalesce(isDeleted, false) = false`) still delivers the flag and a later restore for documents the device holds (SDK 5.1.0 and 5.2.0), but the device cannot relay the flag for documents it did not already hold, and a `DELETE` of a flagged document never reaches it. A subscription filter does not hide documents in local results (rule 3).\n\n**✅ DO**:\n- Keep soft-deleted documents in the subscriptions of devices that relay data to others, at least for as long as a device may stay offline.\n- Hide them in every local query and observer (rule 3); register and release those observers as the SDK page shows (*Store Observers in \u003CSDK>*).\n- Choose one subscription design and clean up accordingly:\n  - **Variant A (whole collection or partition)**: subscribe with `SELECT * FROM orders WHERE storeId = :storeId` (includes flagged documents), owned by a long-lived service. Clean up after the retention period, once flagged documents are no longer edited, with a `DELETE` that syncs to every device, run on the Ditto Server (for example through its HTTP API) or by another authorized peer: `DELETE FROM orders WHERE isDeleted = true AND deletedAt \u003C :cutoff LIMIT 30000`.\n  - **Variant B (retention window)**: subscribe with `coalesce(isDeleted, false) = false OR deletedAt >= :cutoff` and evict exactly the complement (`isDeleted = true AND deletedAt \u003C :cutoff`), cancelling the old subscription first and re-registering it with the moved cutoff. Choose a window longer than the longest expected offline period, so that other devices can still relay the flag, and move the cutoff only when you run cleanup, not on every screen change.\n\n**❌ DON'T**:\n- Subscribe with `WHERE coalesce(isDeleted, false) = false` (or any filter on the flag) alone, unless every device syncs directly with the Ditto Server and evicts flagged documents itself.\n- Evict old soft-deleted documents on a device while a subscription still matches them (Variant A); they sync back.\n\nTrade-offs and the full comparison: [reference\u002Fdeletion-patterns.md](reference\u002Fdeletion-patterns.md#cleaning-up-soft-deleted-documents).\n\n`§ Soft delete, subscriptions, and cleanup`, `§ Multi-hop relay` · Examples: [examples\u002Fsoft-delete-relay.sql](examples\u002Fsoft-delete-relay.sql) (Variant A and B, observer filtering), `retention-service` in `examples\u002F\u003Csdk>\u002F`\n\n### 6. Evict Only Outside Every Active Subscription (HIGH)\n\n`EVICT` removes documents from the local store only; no tombstone is created and other peers keep them. If an active subscription on this device still matches an evicted document, connected peers notice it is missing and sync it back, which can become a loop of evicting and re-syncing.\n\n**✅ DO**:\n- Cancel or narrow the affected subscriptions **before** evicting.\n- Make the eviction query the exact complement of the remaining subscription (same cutoff value, `>=` in the subscription and `\u003C` in the eviction).\n- Keep subscription references in an app-level or feature-level service so you can cancel them.\n- For a large boundary change (for example a store switch), data that was already being transferred can still arrive after cancelling; if the device must not keep it, run the same `EVICT` again later (for example, on the next app start or in a periodic cleanup).\n\n**❌ DON'T**:\n- Evict and then register a subscription that matches the evicted documents again (for example `SELECT * FROM orders`).\n- Evict documents that an active subscription still covers.\n\n```sql\n-- ✅ GOOD: Keep the last 7 days of orders. 1. Cancel the subscription.\n-- 2. Evict exactly the complement of the new subscription:\n-- Arguments: {\"cutoff\": \"2026-10-01T10:30:00.123Z\"}\nEVICT FROM orders WHERE createdAt \u003C :cutoff\n\n-- 3. Subscribe again with the moved boundary, even if the eviction failed:\n-- Arguments: {\"cutoff\": \"2026-10-01T10:30:00.123Z\"}\nSELECT * FROM orders WHERE createdAt >= :cutoff\n```\n\n**Flag-based eviction**: when a central component (typically the Ditto Server, which can make sure documents have synced first) sets `evictionFlag = true`, devices subscribe with `coalesce(evictionFlag, false) = false` and evict `evictionFlag = true`. The subscription never matches flagged documents, so it need not be cancelled before each eviction. Not on relays whose peers can miss the flag: they send the unflagged version back.\n\n`§ EVICT`, `§ Time-based eviction`, `§ Flag-based eviction`, `§ Cancelling subscriptions and local data` · Examples: `retention-service` in `examples\u002F\u003Csdk>\u002F` (the service), [ttl-eviction-small-peer.sql](examples\u002Fttl-eviction-small-peer.sql), [evict-subscription-management-good.sql](examples\u002Fevict-subscription-management-good.sql), [-bad.sql](examples\u002Fevict-subscription-management-bad.sql), [flag-based-eviction.sql](examples\u002Fflag-based-eviction.sql), [ttl-eviction-ditto-server.sql](examples\u002Fttl-eviction-ditto-server.sql)\n\n### 7. Evict on a Schedule, in Batches (HIGH)\n\nEach eviction triggers a resync with every connected peer, which costs network traffic and processing on those peers. (SDK 5.1+) Ditto writes a warning-level log entry when post-eviction session cleanup runs too frequently.\n\n**✅ DO**:\n- Evict on a regular schedule, no more than about once per day, at a quiet time.\n- Split a large cleanup with `LIMIT` and stop when `RETURNING COUNT(*)` reports zero (first cancel or narrow every matching subscription, rule 6).\n- Treat the eviction-frequency warning as a sign to evict less often.\n\n**❌ DON'T**:\n- Evict on every screen change or app resume.\n- Change `DISABLE_REPLICATION_GC_ON_EVICT` (default `false`) unless profiling shows eviction-time write latency.\n\n```sql\n-- ✅ GOOD: Evict in batches of 1,000; repeat until evicted is 0.\n-- Arguments: {\"cutoff\": \"2026-10-01T10:30:00.123Z\"}\nEVICT FROM orders WHERE createdAt \u003C :cutoff LIMIT 1000\nRETURNING COUNT(*) AS evicted\n```\n\nBatching keeps write transactions short. It does not reduce the sync cost of eviction: run the whole batched cleanup on the usual schedule, not as many separate cleanups.\n\n`§ Batching evictions`, `§ Eviction frequency` · Examples: [examples\u002Fttl-eviction-small-peer.sql](examples\u002Fttl-eviction-small-peer.sql), `retention-service` in `examples\u002F\u003Csdk>\u002F`\n\n## Checklist\n\nDELETE:\n- [ ] Targets documents with `WHERE _id = :id` \u002F `WHERE _id IN :ids`, never `USE IDS` without a `WHERE` predicate\n- [ ] Not used to free storage on one device (use `EVICT`)\n- [ ] Uses `RETURNING` (SDK 5.1+) when the removed content is needed\n- [ ] Not used for shared records edited concurrently (husk documents)\n- [ ] Every device connects within the tombstone TTL (7 days by default), or the data uses soft delete\n- [ ] `TOMBSTONE_TTL_HOURS` on devices never exceeds the Ditto Server TTL; set on every open\n- [ ] Large deletions on the Ditto Server run in batches of 30,000 documents or fewer\n\nSoft delete:\n- [ ] Sets `isDeleted` and `deletedAt` (UTC, with zone); new documents get `isDeleted: false`\n- [ ] Every query, observer, aggregate, and joined collection filters with `coalesce(isDeleted, false) = false` (or the index-friendly `IS MISSING OR IS NULL OR = false` form)\n- [ ] Subscriptions of relaying devices keep flagged documents (Variant A: whole collection or partition; Variant B: retention window)\n- [ ] Old flagged documents are cleaned up (Variant A: synced `DELETE`; Variant B: device-side `EVICT` of the complement)\n\nEVICT:\n- [ ] Affected subscriptions are cancelled or narrowed before evicting\n- [ ] Eviction query is the exact complement of the remaining subscriptions\n- [ ] No re-subscription that matches the evicted documents\n- [ ] Runs on a schedule, at most about once per day; large runs use `LIMIT`\n- [ ] Subscription references are kept in a long-lived service\n\nMonitoring:\n- [ ] Storage read from `system:system_info` with `execute` on demand, not with a long-lived observer\n\n## More\n\n- Reference: [reference\u002Fdeletion-patterns.md](reference\u002Fdeletion-patterns.md) - what `DELETE` leaves behind, husks, Ditto Server deletion, soft-delete indexing and cleanup, store switch, eviction, storage monitoring\n- Examples: [examples\u002F](examples\u002F) - one DQL file per pattern, linked from each rule; `examples\u002F\u003Csdk>\u002Fretention-service` for the services that run them\n- Guide sections: `§ Subscription Lifecycle`, `§ Monitoring Storage`, `§ Testing Deletion and Soft Delete`\n- Related skills: `query-sync` (subscriptions, `RETURNING`), `data-modeling` (flag fields, timestamps), `performance-observability` (indexes, observers)\n",{"name":5,"description":7},"main","b67d1a0bc891c9b2a952f8beb0a6dce7d449717c","plugins\u002Fditto\u002Fskills\u002Fstorage-lifecycle","https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook","https:\u002F\u002Fdocs.ditto.live\u002Fhome\u002Fintroduction","https:\u002F\u002Fgithub.com\u002Fditto-examples","https:\u002F\u002Fdocs.ditto.live","Example Apps and Information for Ditto","2026-11-13 17:08:48",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add ditto-examples\u002Fditto-cookbook --skill storage-lifecycle",{"tool":59,"command":60},"bunx","bunx skills add ditto-examples\u002Fditto-cookbook --skill storage-lifecycle",{"tool":62,"command":63},"pnpm","pnpm dlx skills add ditto-examples\u002Fditto-cookbook --skill storage-lifecycle","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fstorage-lifecycle\u002FSKILL.md",true,[67,73,77,81,85,91,95,99,103,107,111],{"path":68,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":72},"examples\u002Fevict-subscription-management-bad.sql","OTHER","其他",5020,"https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fstorage-lifecycle\u002Fexamples\u002Fevict-subscription-management-bad.sql",{"path":74,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":75,"sourceHtmlUrl":76},"examples\u002Fevict-subscription-management-good.sql",3913,"https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fstorage-lifecycle\u002Fexamples\u002Fevict-subscription-management-good.sql",{"path":78,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":79,"sourceHtmlUrl":80},"examples\u002Fflag-based-eviction.sql",2002,"https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fstorage-lifecycle\u002Fexamples\u002Fflag-based-eviction.sql",{"path":82,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":83,"sourceHtmlUrl":84},"examples\u002Fflutter\u002Fretention-service.dart",8116,"https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fstorage-lifecycle\u002Fexamples\u002Fflutter\u002Fretention-service.dart",{"path":86,"resourceType":87,"resourceTypeDesc":88,"sizeBytes":89,"sourceHtmlUrl":90},"examples\u002Fjavascript\u002Fretention-service.js","SCRIPT","脚本",7003,"https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fstorage-lifecycle\u002Fexamples\u002Fjavascript\u002Fretention-service.js",{"path":92,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":93,"sourceHtmlUrl":94},"examples\u002Fkotlin\u002Fretention-service.kt",5938,"https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fstorage-lifecycle\u002Fexamples\u002Fkotlin\u002Fretention-service.kt",{"path":96,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":97,"sourceHtmlUrl":98},"examples\u002Fsoft-delete-relay.sql",5164,"https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fstorage-lifecycle\u002Fexamples\u002Fsoft-delete-relay.sql",{"path":100,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":101,"sourceHtmlUrl":102},"examples\u002Fswift\u002Fretention-service.swift",7640,"https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fstorage-lifecycle\u002Fexamples\u002Fswift\u002Fretention-service.swift",{"path":104,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":105,"sourceHtmlUrl":106},"examples\u002Fttl-eviction-ditto-server.sql",3725,"https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fstorage-lifecycle\u002Fexamples\u002Fttl-eviction-ditto-server.sql",{"path":108,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":109,"sourceHtmlUrl":110},"examples\u002Fttl-eviction-small-peer.sql",3331,"https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fstorage-lifecycle\u002Fexamples\u002Fttl-eviction-small-peer.sql",{"path":112,"resourceType":113,"resourceTypeDesc":114,"sizeBytes":115,"sourceHtmlUrl":116},"reference\u002Fdeletion-patterns.md","REFERENCE","参考文档",18435,"https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fstorage-lifecycle\u002Freference\u002Fdeletion-patterns.md",[118,128,153,162,171,181],{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":39},"01M6C58EAD92WQKNE74549PXEW","transactions-attachments","Ditto SDK transactions and attachments (Flutter, JavaScript, Kotlin, Swift): ditto.store.transaction with tx.execute only, no nesting, short scopes, rollback, close(); newAttachment, ATTACHMENT declarations, lazy fetchAttachment with a stall timeout, immutability, thumbnails, and blob availability. Use when writing or reviewing ditto.store.transaction, newAttachment, or fetchAttachment code, or when displaying photos or files stored in Ditto.","https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Ftransactions-attachments\u002FSKILL.md",[],[125,126,127],"transactions attachments","attachments","transactions",{"skillNo":129,"name":130,"nameZh":6,"description":131,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":132,"categories":133,"keywords":139,"publishedAt":39},"01M6C58B0PQHV5WXMQRP9DEPX1","testing","Ditto SDK testing strategies in Flutter, JavaScript, Kotlin, or Swift: local-store test helper, tests for DQL statements, MISSING\u002FNULL filters, merge-sensitive writes, soft delete, observer lifecycle, subscription rules, and multi-peer sync tests in one process. Use when writing or reviewing tests for code that uses Ditto, setting up a Ditto test harness, or reproducing a Ditto sync or merge bug.","https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Ftesting\u002FSKILL.md",[134],{"categoryNo":135,"categoryName":136,"taxonomyType":137,"taxonomyTypeDesc":138},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",[130,140,141,142,38,143,36,27,144,145,146,34,147,24,148,149,150,151,20,152],"tests","filters","code","merge","strategies","bug","missing","testing strategies","test harness","swift","for","harness","up",{"skillNo":154,"name":155,"nameZh":6,"description":156,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":157,"categories":158,"keywords":159,"publishedAt":39},"01M6C5845MAD3AEBNSN3BT61WH","sdk-setup","Ditto SDK setup, lifecycle, and production security (Flutter, JavaScript, Kotlin, Swift): DittoConfig, the authentication expiration handler, system parameters, sync start and stop, close, transports, presence, keys, permissions, revocation. Use when initializing Ditto, writing Ditto login, startup, shutdown, or background code, configuring Ditto transports, reviewing Ditto security, or when Ditto sync never starts or devices do not connect.","https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fsdk-setup\u002FSKILL.md",[],[37,160,161],"sdk setup","setup",{"skillNo":163,"name":164,"nameZh":6,"description":165,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":166,"categories":167,"keywords":168,"publishedAt":39},"01M6C580SCSJK0E5Z54AJTV242","query-sync","Ditto SDK DQL reads and writes, subscriptions, and store observers (Flutter, JavaScript, Kotlin, Swift): query parameters, MISSING vs NULL, membership filters, subscription and observer lifecycle, ON ID CONFLICT upserts, JOIN, RETURNING. Use when writing or reviewing ditto.store.execute, ditto.sync.registerSubscription, registerObserver, or DQL in an app that uses Ditto, or when Ditto data does not sync or a Ditto query returns nothing.","https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fquery-sync\u002FSKILL.md",[],[169,170,36],"query","query sync",{"skillNo":172,"name":173,"nameZh":6,"description":174,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":175,"categories":176,"keywords":177,"publishedAt":39},"01M6C57X4C3TQSWZJC882ECQV2","performance-observability","Ditto SDK store observer performance and diagnostics (Flutter, JavaScript, Kotlin, Swift): observer lifecycle, backpressure (registerObserverV2, signalNext, suspending handlers), narrow UI updates, differs, redundant writes, indexes, ADVISE, EXPLAIN, PROFILE, logging, and system: collections. Use when a Ditto query is slow, a screen showing Ditto data janks, Ditto observers grow memory, Ditto upserts repeat, or when setting up Ditto logging.","https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fperformance-observability\u002FSKILL.md",[],[178,179,180],"performance observability","performance","observability",{"skillNo":182,"name":183,"nameZh":6,"description":184,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":185,"categories":186,"keywords":187,"publishedAt":39},"01M6C57V1EZKA9B5W1G4F00HAH","guide","Searches the complete Ditto SDK best practices guide (SDK 5.2.0, Flutter, JavaScript, Kotlin, Swift) bundled with this plugin, for answers the focused ditto skills do not cover. Use to look up a Ditto API, DQL keyword or function, system parameter, error message, an SDK's API or behavior, or the reasoning behind a rule, or when a Ditto question spans several topics.","https:\u002F\u002Fgithub.com\u002Fditto-examples\u002Fditto-cookbook\u002Fblob\u002Fmain\u002Fplugins\u002Fditto\u002Fskills\u002Fguide\u002FSKILL.md",[],[183,152,188,189,190,191,192,24,193,194,150,195,196,197,22,26,198,199,33,200],"system","plugin","error","kotlin","flutter","javascript","topics","complete","message","do","api","best practices","question"]