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}. - Heads
Data - The
dataof areplica.headsframe:{"h":[[…]]}. - Pull
Request - 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. - Pushed
Head - One head in a
replica.headspush:["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.
- Sync
Entry - One entry of a device check:
[pullCapability, schema, epoch, version], plus the resume key of a paged full copy as a fifth element. - Sync
Reply - The
resultofcore.replica.sync:{"r":[…]}, aligned with the request’s entries by index. - Sync
Request - The payload of
core.replica.sync:{"c":[[…],[…]]}, plus"origin":"background"on checks no person is waiting for. - Window
Days - A positive history window representable on a JavaScript device.
- Windowed
Announce - An announcement for one custom day window of a recent collection.
- Windowed
Pull Request - 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.
- Windowed
Sync Entry - A device check that can also carry the six-slot custom-window form.
- Windowed
Sync Request - Parse a batch with any mixture of ordinary, paged, and custom-window checks.
Enums§
- Announce
Reply - 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). - Pull
Reply - An app’s answer to one pull (section 4.2).
- Sync
Answer - The node’s answer for one entry of a check (section 4.3):
0, the changes (withoute, which the device already holds), a full copy, or an error. - Sync
Error Code - 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
ordmagnitude and the largest version: 2^53 − 1, exact in a JavaScript number. - MAX_
SYNC_ ENTRIES - Entries in one
core.replica.syncrequest. - MAX_
SYNC_ REPLY_ BYTES - A whole
core.replica.syncreply (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 (
isWithinReplicaValueDepthinclient/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. Seevalue_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
valuenests no deeper thanMAX_VALUE_DEPTHlevels. 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’sisWithinReplicaValueDepthand the TypeScript helper’sisWithinValueDepth;tests/fixtures/value-depth.jsonholds the shared cases.