Skip to main content

Module wire

Module wire 

Source
Expand description

The replication contract’s wire shapes (Phase 3 spec, section 4), byte for byte.

Every type here serializes to the compact JSON the contract prints, with the keys in the contract’s order, whatever serde_json features the build unifies. Deserialization is lenient where the contract is: it ignores keys it does not know (the capability router stamps caller and caller_ingress into every payload) and accepts the short forms of a row entry.

The golden fixtures in tests/fixtures/ hold the exact bytes; the TypeScript helper and the client kernel read the same files.

Structs§

Announce
The payload of core.replica.announce: {"c":"friends.people.pull","e":"k3f9a2c1","v":42}.
HeadsData
The data of a replica.heads frame: {"h":[[…]]}.
PullRequest
The request the node sends an app’s pull capability: {"e":"k3f9a2c1","v":41,"s":1,"l":500} plus "a" when resuming a paged full copy.
PushedHead
One head in a replica.heads push: ["friends.people.pull","k3f9a2c1",42].
Row
One row of a collection: a key, any JSON value, its order in the list and the group it belongs to.
SyncEntry
One entry of a device check: [pullCapability, schema, epoch, version], plus the resume key of a paged full copy as a fifth element.
SyncReply
The result of core.replica.sync: {"r":[…]}, aligned with the request’s entries by index.
SyncRequest
The payload of core.replica.sync: {"c":[[…],[…]]}, plus "origin":"background" on checks no person is waiting for.
WindowDays
A positive history window representable on a JavaScript device.
WindowedAnnounce
An announcement for one custom day window of a recent collection.
WindowedPullRequest
The provider request for one of a recent collection’s windows (ADR-395). Older four/five-slot requests reach the same provider without a day count.
WindowedSyncEntry
A device check that can also carry the six-slot custom-window form.
WindowedSyncRequest
Parse a batch with any mixture of ordinary, paged, and custom-window checks.

Enums§

AnnounceReply
The node’s answer to an announce: {"ok":true}, or {"rotate":true} when it has handed out a higher version of that epoch (the app’s data went back in time).
PullReply
An app’s answer to one pull (section 4.2).
SyncAnswer
The node’s answer for one entry of a check (section 4.3): 0, the changes (without e, which the device already holds), a full copy, or an error.
SyncErrorCode
Why the node could not answer one entry of a check.

Constants§

ANNOUNCE_CAPABILITY
The app’s “my head moved” notice (node core).
HEADS_EVENT
The node’s push to connected devices.
MAX_EPOCH_CHARS
An epoch: 1–16 characters of [a-z0-9].
MAX_KEY_BYTES
A row key: 1–256 bytes of UTF-8 with no control characters.
MAX_PART_BYTES
A row’s part: 0–128 bytes of UTF-8.
MAX_REPLY_ROW_BYTES
The encoded bytes of the rows one reply carries for one collection.
MAX_ROWS_PER_REPLY
The rows (upserts plus deletes) one reply carries for one collection.
MAX_SAFE_INTEGER
The largest ord magnitude and the largest version: 2^53 − 1, exact in a JavaScript number.
MAX_SYNC_ENTRIES
Entries in one core.replica.sync request.
MAX_SYNC_REPLY_BYTES
A whole core.replica.sync reply (under node-wire’s 1 MiB frame).
MAX_VALUE_BYTES
A row value’s encoded (compact JSON) size.
MAX_VALUE_DEPTH
The deepest a row’s value may nest, counted as the device’s storage counts it (isWithinReplicaValueDepth in client/ports/src/replica.js): the value is level 1 and each container adds a level for what it holds, so 127 nested containers are accepted and 128 refused. That is exactly what serde_json’s default recursion limit (128) parses, so the node can read every value the helper serves. See value_within_depth.
SCHEMA_UNSUPPORTED_PREFIX
The capability error prefix for a schema the app does not serve.
SYNC_CAPABILITY
The device’s batched check (node core).

Functions§

is_epoch
[a-z0-9]{1,16}.
validate_key
A row key: 1–256 bytes, no control characters.
value_within_depth
Whether value nests no deeper than MAX_VALUE_DEPTH levels. Walks the value with an explicit stack and stops at the first level past the limit, so a deep value is refused without using the call stack. The same rule as the device’s isWithinReplicaValueDepth and the TypeScript helper’s isWithinValueDepth; tests/fixtures/value-depth.json holds the shared cases.