sync-subscriptions
Skill4 starsChanged 9 days agoMITView on GitHub
Use when designing or debugging Ditto sync subscriptions (registerSubscription): accepted SELECT queries, receive-side filtering, missing documents, multihop relay coverage, flooding, persistence and cancellation. Covers SDK 4.14.x, 5.0.x, 5.1.x and 5.2.0. Language-agnostic; per-language API syntax belongs to the Ditto SDK skill.
In this repository8 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- data-modelingSkill
- data-streamsSkill
- ditto-mesh-networkingSkill
- kotlin-sdkSkill
- swift-sdkSkill
- write-dqlSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Read only the matching reference or section.
- Very specific: line 22
Use the language's Ditto SDK skill for calls and write-dql for local queries.
- Distinctive: line 23
If those skills are unavailable, use the official links below.
- Very specific: line 35
Start with SELECT * FROM collection WHERE ...: subscriptions sync whole documents, not projections.
- Distinctive: line 65
Default sync sessions are pairwise (5.1's opt-in multicast beta is a separate mode).
- Distinctive: line 71
If A holds all cars, B subscribes only to blue cars, and C wants all cars but connects only through B, C receives only blue cars.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Ditto Sync Subscriptions
A subscription declares what this peer wants other peers to send it. It copies
matching documents into the local store; a store query/observer reads that store.
Production apps typically need both. This skill owns subscription semantics, not
per-language registerSubscription spelling or local DQL query syntax.
Supports Ditto SDK 4.14.x (LTS), 5.0.x, 5.1.x and 5.2.0. Confirm the target version before using version-sensitive clauses.
For 5.2.0 diagnostics and document-size enforcement during replication, read how-subscriptions-work.md.
Start with the task
Read only the matching reference or section; do not read every file or the README.
Use the language's Ditto SDK skill for calls and write-dql for local queries.
If those skills are unavailable, use the official links below.
| Task | Read |
| Lifecycle, deltas, dedup/refcounting, cancellation, attachment behavior | how-subscriptions-work.md |
| A rejected query or exact version-specific restrictions/errors | query-limitations.md |
| Missing data across a relay, pairwise sessions or flooding | mesh-and-flooding.md |
| Work through a topology | mesh-scenarios.md, matching scenario only |
| Design stable production subscriptions | best-practices.md |
Query rules
Start with SELECT * FROM collection WHERE ...: subscriptions sync whole documents,
not projections. The supported subset differs from local store queries.
SELECT *is required. Projections, JOINs, multiple collections,USE IDS,DISTINCT, grouping/aggregates and non-SELECT statements are rejected.WHEREfilters one collection.USE INDEX/planner directives are accepted.- 4.14.x:
LIMIT/ORDER BYare accepted but stateful and discouraged. 5.x: rejected by default.OFFSETalone is accepted on all supported lines. - To sync only some fields, split the collection or move binary data to attachments. Filter/sort a view with a local store query rather than repeatedly replacing a subscription for each view change.
Exact error strings and the reasons for the restrictions are in
references/query-limitations.md; read it when constructing or debugging a query.
Lifetime and local storage
- Subscriptions filter incoming data. Local writes land in the local store regardless of subscriptions; local queries can read everything stored locally.
- Registrations are in memory: re-register at each app start. Previously synced documents survive native app restarts; browser JS storage is in memory only.
- A document that stops matching gets one final update and remains in the store.
Removal is explicit:
EVICTis local;DELETEwrites a replicating tombstone. - Attachments normally sync a token, with bytes explicitly fetched.
ALTER SYSTEM SET attachments_auto_fetch = trueenables automatic fetching. - Handle teardown is SDK-specific. In C++ and Rust, dropping a handle does not cancel
its subscription: call
cancel(). Check the language SDK guidance for ownership.
Trace every hop for missing data
Default sync sessions are pairwise (5.1's opt-in multicast beta is a separate mode). Two rules explain the relay bottleneck:
- A peer offers documents it holds, filtered by the recipient's subscriptions.
- A peer holds its own writes plus documents received through its own subscriptions.
If A holds all cars, B subscribes only to blue cars, and C wants all cars but connects only through B, C receives only blue cars. B cannot relay the other cars it never received. Sync is transitive with no hop limit, but relays are not transparent pipes. A new path to a holder can fill the gap. Audit subscriptions and holdings at every hop before changing the endpoints' queries.
Ditto Server follows the same receive-filter and permission rules. A cloud path fills the gap only if the server holds the missing documents and can serve them to C; cloud connectivity alone does not establish complete data coverage.
Official references
- Syncing Data: concepts.
- Managing Subscriptions: SDK calls.
- Sync Handling: operations.
- Stateful Subscription Performance: LIMIT/ORDER BY costs.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

