The network store
Every HappyProto instance reads public atproto records from one shared copy of the network: the network store. When your instance tracks a collection, it reads that collection’s records from the store instead of keeping its own copy. A collection new to the store is crawled once, then kept up to date for every instance that tracks it.
What it holds, and what it doesn’t
The store holds public records from atproto repositories, for the collections HappyProto instances track. It holds no blobs, such as images.
These never reach the shared store, and stay on your instance alone:
- records in atproto spaces;
- local-only writes;
- anything else your instance keeps for itself.
Writes to a user’s repository go to their PDS, and reach the store from the network like any other record. A change your instance makes to a shared record on its own stays your instance’s, on top of the network’s record.
When an account is deleted or taken down on the network, or a record is deleted, the store drops it, and your instance stops showing it. The Terms of Service ask you to respect deletions in what you build too.
What counts against your storage
Shared collections in the store don’t count against your instance’s storage, however large they are. Only what stays on your instance, listed above, counts. The project’s Usage tab shows it.
When the store is unavailable
If the store is down or unreachable:
- reads of shared collections, from default XRPC queries and from scripts,
answer
503 ServiceUnavailable; - writes to the user’s PDS still succeed, and your instance shows the new record once the store is back.
Deep pages
Default XRPC list queries page by offset, and deep offsets get slower: a page costs time in proportion to how far in it starts. Script queries page by keyset and don’t have this cost, so use a script for endpoints that page deep into large collections.
Backfills
A backfill on HappyProto runs your record scripts’ create handlers over the records the store holds for a collection.
- The store already holds the collection: the backfill runs your record scripts over its records right away, and completes with their count.
- The store is crawling it, or holds none of it yet: the backfill asks the store to crawl it if it needs to, then shows Waiting for the Network store’s crawl until the crawl finishes. Records reach your instance as the crawl finds them, and your record scripts run on each as it arrives. How long that takes depends on how many records the collection has across the network.
If the store’s last crawl of a collection found nothing or failed, the store crawls it again on its own: about 5 minutes later the first time, then at growing intervals. The backfill shows when the next attempt is due.
A backfill over a collection with no record script completes with nothing to run. Otherwise, its note says what the crawl found:
| Note | What happens |
|---|---|
| No records | The backfill completes with 0 records. |
| The crawl failed | The backfill fails. The store crawls the collection again later, and your record scripts run on its records then. |
| The crawl never started | The backfill fails. If the store crawls the collection later, your record scripts run on its records then. If it never does, email support@happyproto.at. |
| The crawl was cancelled | The backfill fails. Email support@happyproto.at to have the collection crawled. |
Backfill runs also start on their own: when your instance starts, when it starts tracking a collection, and every minute for a run that failed or is out of date. A failed run waits until the store’s crawl of the collection is underway again. A run you pause stays paused, and one you cancel stays cancelled.
Make record scripts safe to run twice
The same record can reach your record script’s create handler more than once: a failed run starts again, a backfill you start runs over the collection again, and tracking a collection again starts a fresh run. Write record scripts so that running one twice for the same record leaves the same result as running it once.
- Write by the record’s key, replacing what’s there, rather than adding a new entry each time.
- Don’t keep running totals that go up by one on every call. Count from the stored data instead.
- Check before doing anything that should happen only once.