SSyncropel Docs

Reads, budgets and cursors

What a read costs the server, the refusals it can answer, how counts and page cursors behave, and which callers can filter on which fields.

Every read has a time limit and can be cancelled. This page describes what you see when you call the API.

Read refusals

Each answers with a JSON body carrying code, and the X-Syncropel-Refusal header. A refusal that can succeed later also carries Retry-After and Cache-Control: no-store.

StatusCodeWhenWhat to do
503READ_BUDGET_EXCEEDEDA read ran past its time limit (interactive reads: 3 s; exports and background work have their own limits; every limit is doubled for 60 s after the server starts), or the client went away. The body is {code, budget_ms, door, retry_after_secs}. /health never answers it.Wait Retry-After seconds and retry. Narrow the request (a body.kind filter, a thread scope, a smaller limit) if it keeps happening.
429READ_IN_FLIGHTOne scanning read per person runs at a time. A second one from the same person waits its turn (up to 3 s, in arrival order) and then runs. You get this answer only when the wait runs out or too many reads are already waiting. The owner is never refused. Retry-After is the time left for the first read.Send one scanning read at a time per person, and retry after Retry-After.
409READ_STOPPED_BY_ERASEAn export began, then an erase happened before it finished. None of its output is served.Run the export again.

Known limit: the first read after the server starts can take longer than 3 s, so a client that sends several reads at once may see the later ones refused. Later reads answer normally.

Suggested wording to show people:

  • READ_BUDGET_EXCEEDED: "This is taking longer than it should, so it stopped. Try again in a moment."
  • READ_IN_FLIGHT: "Something you asked for is still loading. Try again in a moment."
  • READ_STOPPED_BY_ERASE: "This export stopped partway because the workspace changed. Run it again." A message shown to a person should not say that an erase happened.

Counts

On a record read (POST /v1/records/query and the thread read) the count is bounded:

  • A filter on a thread alone uses the thread's own count.
  • Any other count stops at 250 ms. When it stops, read.total is null and read.total_at_least carries the count reached. total_at_least is present only when the count was bounded.
  • Send "total": "skip" to count nothing. capped and has_more stay exact.

Read total_at_least when total is null. Don't treat a null total as zero.

A created_at sort returns records in the order they were written.

A ledger page's limit is capped at the ledger's row_ceiling; follow next_cursor for the rest. A ledger with no ceiling uses the default page size.

Page cursors

A page cursor (next_cursor, sent back as cursor) is opaque. Send it back unchanged.

  • A cursor is tied to what you are allowed to read. Other people's activity doesn't affect it. A change to your own access ends it.
  • An edited, hand-built or mismatched cursor answers 400 CURSOR_INVALID. So does a cursor from before a server upgrade. Start again from the first page.
  • The cursor carries the total, so later pages don't count again. After an erase the total is recounted.
  • Ledger row cursors (before=<clock>) are a different kind of cursor, and these rules don't apply to them.

Person-facing words for CURSOR_INVALID: "This list changed since that page. Start again from the top."

Filtering is decided by who you are

A filter, sort, group, aggregate, distinct-values call or text search on a field the caller can't read is refused:

{ "code": "QUERY_FIELD_NOT_READABLE", "field": "body.title" }

The status is 400. The answer depends on the field and who you are, never on the data, so it is the same whether or not matching records exist. It applies to POST /v1/records/query (plain, aggregation, and standing queries), MCP find, reductions, ledger pages (filter, sort, q, a chosen view) and values, ledger stats, a run's read_thread filter, and app reads. On aggregates this code is used instead of 403 REDUCTION_FIELD_WITHHELD.

Who can filter on what:

  • The owner (the owner's session or key, a local connection, or an unrestricted admin credential) reads everything. An admin credential limited to a thread or namespace, or with a read limit, is restricted like anyone else.
  • Everyone else can filter on the routing fields only: body.kind, schema_version, idem, classes_read, declassified, and the record's own fields (thread, actor, act, clock, id). A member can't filter, sort or group on other body fields, even ones they can read.
  • Declared views allow more: a saved view on a conversation, and a ledger view or reduction whose serves.class names its audience (views[].serves: {class, level?}), allow filter, sort, group and values on the columns that audience can already read.
  • Own writes. POST /v1/records/query takes "own_writes": true and serves the records the caller's own credential wrote (the same service account, session or grant). On that surface body filters and sort are admitted, except on a field that is hidden by its class, sealed, or erased. An aggregate or group_by with own_writes is 400 INVALID_QUERY. Own writes follow the service account, so rotating its token (POST /v1/tokens/{id}/rotate) keeps them. Creating a replacement account does not. If few of your records match and you add no other filter, the read scans to fill a page, so filter by body.kind.
  • Find. A guest's or member's find (MCP and GET /v1/find) is refused with the same code, because find searches record text. Read the records of the conversations you're in instead: read_thread, or POST /v1/records/query by kind.

Suggested wording for people: "Only the workspace's owner can search or filter by this."

Sequence numbers for restricted readers

For a guest, a credential limited to certain threads, or a run limited to certain classes, as_of_seq is the highest sequence number among the rows that reader may see (or the reader's own min_seq, or 0). The same applies to min_seq_met, a subscription's watermark_seq, a watch stream's cursor, a batch's committed_through and rights.as_of_seq. It doesn't change for a write the reader can't see, and it can go down when the reader's access shrinks. Don't treat it as workspace-wide or always increasing, and compare it only with numbers served to the same reader. The owner, an admin and a full member see the workspace-wide value.

Known limit: each row a restricted reader receives still carries its workspace sequence, so a gap between two rows reflects writes the reader can't see.

Server-Timing

Only the owner gets the Server-Timing header: the owner, the owner's session, an unrestricted admin, or a caller on the local socket. Everyone else, including public pages, gets none. On routes that need no sign-in (/health, /health/ready, /, /v1/capabilities, /site/*) it is sent only to local connections (the socket, --insecure-localhost, or auth.required=false), not to a caller that merely sent no credential. To read timing, use the owner's credential on a /v1 endpoint, or the socket.

Health

  • Without a credential, /health returns writeback as {attach, attach_fact} only. To read writeback.epoch, backlog_now, last_attach, lists or files_backfill, send the owner's bearer, read /v1/health, or use the Unix socket (~/.syncro/run/spl.sock).
  • /v1/health serves read_pool {in_flight_reads, in_flight_writes, pool_size} to the owner only.

See also

On this page