agentleFS
getdittogetditto/agent-skills/skills/sync-subscriptions/SKILL.md

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.

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
  1. Very specific:

    Read only the matching reference or section.

    line 21
  2. Very specific:

    Use the language's Ditto SDK skill for calls and write-dql for local queries.

    line 22
  3. Distinctive:

    If those skills are unavailable, use the official links below.

    line 23
  4. Very specific:

    Start with SELECT * FROM collection WHERE ...: subscriptions sync whole documents, not projections.

    line 35
  5. Distinctive:

    Default sync sessions are pairwise (5.1's opt-in multicast beta is a separate mode).

    line 65
  6. Distinctive:

    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.

    line 71

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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.

TaskRead
Lifecycle, deltas, dedup/refcounting, cancellation, attachment behaviorhow-subscriptions-work.md
A rejected query or exact version-specific restrictions/errorsquery-limitations.md
Missing data across a relay, pairwise sessions or floodingmesh-and-flooding.md
Work through a topologymesh-scenarios.md, matching scenario only
Design stable production subscriptionsbest-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.
  • WHERE filters one collection. USE INDEX/planner directives are accepted.
  • 4.14.x: LIMIT/ORDER BY are accepted but stateful and discouraged. 5.x: rejected by default. OFFSET alone 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: EVICT is local; DELETE writes a replicating tombstone.
  • Attachments normally sync a token, with bytes explicitly fetched. ALTER SYSTEM SET attachments_auto_fetch = true enables 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:

  1. A peer offers documents it holds, filtered by the recipient's subscriptions.
  2. 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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.