This commit is contained in:
Tony Garnock-Jones 2022-02-24 23:32:41 +01:00
parent d847aea1c9
commit ac68d3f3d3
1 changed files with 24 additions and 21 deletions

View File

@ -6,10 +6,9 @@ actors](./glossary.md#relay).[^analogy-to-subnets] Relays allow *indirect* commu
distant entities can be addressed as if they were local.
Relays exchange *Syndicate Protocol* messages across a [transport](./glossary.md#transport). A
*transport* is the underlying medium connecting one relay to its counterparts on a given
network. For example, a TLS-on-TCP/IP socket may connect a pair of relays to one another, or a
UDP multicast socket may connect an entire group of relays across an
ethernet.[^relaying-over-syndicate]
*transport* is the underlying medium connecting one relay to its counterpart(s). For example, a
TLS-on-TCP/IP socket may connect a pair of relays to one another, or a UDP multicast socket may
connect an entire group of relays across an ethernet.[^relaying-over-syndicate]
<!--
@ -115,11 +114,14 @@ A `Turn` is the most important packet variant. It directly reflects the
**Handling.** Each `Turn` carries [events](./glossary.md#event) to be delivered to
[entities](./glossary.md#entity) residing in the scope at the receiving end of the transport.
Each event is either publication of an assertion, retraction of a previously-published
assertion, delivery of a single message, or a [synchronization](./glossary.md#synchronization)
event.
Upon receipt of a `Turn`, the sequence of `TurnEvent`s is examined. The
[OID](./glossary.md#oid) in each `TurnEvent` selects an entity known to the recipient. Each
`Event` is either publication of an assertion, retraction of a previously-published assertion,
delivery of a single message, or a [synchronization](./glossary.md#synchronization) event.
[OID](./glossary.md#oid) in each `TurnEvent` selects an entity known to the recipient. If a
particular `TurnEvent`'s OID is not mapped to an entity, the `TurnEvent` is silently ignored,
and the remaining `TurnEvent`s in the `Turn` are processed.
The `assertion` fields of `Assert` events and the `body` fields of `Message` events may contain
any Preserves value, including embedded entity references. On the wire, these will always be
@ -469,7 +471,7 @@ For example, at least the following contribute to a `WireSymbol`'s reference cou
- The initial entry mapping a local entity ref to an well-known OID for use at session startup
([see below](#well-known-oids)) contributes a permanent reference.
- Mention of an OID in a received *or sent* `TurnEvent` adds one to the OID's reference count
- Mention of an OID in a received or sent `TurnEvent` adds one to the OID's reference count
for the duration of processing of the event. For `Assert` events in either direction, the
duration of processing is until the assertion is later retracted. For received `Message`
events, the duration of processing is until the incoming message has been forwarded on to
@ -497,7 +499,7 @@ The value is recursively traversed. As the relay comes across each embedded `Wir
OID is looked up in the import membrane.
- If no `WireSymbol` exists in the import membrane, one is created, mapping the OID to a
fresh [relay entity](#relay-entities).
fresh [relay entity](#relay-entities) for the OID.
- If a `WireSymbol` is already present, its associated ref is substituted into *v*.
@ -505,11 +507,12 @@ The value is recursively traversed. As the relay comes across each embedded `Wir
receiving peer. Its OID is looked up in the export membrane.
- If no `WireSymbol` exists for the OID, one is created, associating the OID with a dummy
inert entity ref. The dummy ref is substituted into *v*.
inert entity ref. The dummy ref is substituted into *v*. It will later be released once
the reference count of the `WireSymbol` drops to zero.
- If a `WireSymbol` exists for the OID, and the `WireRef` is not
[attenuated](#attenuation-of-authority), the associated ref is substituted into *v*. If
the `WireRef` *is* attenuated, the associated ref is wrapped with the `Caveat`s from the
the `WireRef` is attenuated, the associated ref is wrapped with the `Caveat`s from the
`WireRef` before its substitution into *v*.
- In each case, the `WireSymbol` associated with the OID has its reference count incremented
@ -529,9 +532,9 @@ The value is recursively traversed. As the relay comes across each embedded refe
- Otherwise, it is looked up in the import membrane. If *no* associated `WireSymbol` exists
there, a fresh OID and `WireSymbol` are placed in the export membrane, and the new OID is
substituted as a `mine`-variant `WireRef` into *v*.
- Otherwise, it refers to a previously-imported entity.
substituted as a `mine`-variant `WireRef` into *v*. If a `WireSymbol` exists in the import
membrane, however, the embedded reference must be a local [relay entity](#relay-entities)
referencing a previously-imported remote entity:
- If the local entity reference has not been attenuated subsequent to its import, the OID it
was imported under is substituted as a `yours`-variant `WireRef` into *v* with an empty
@ -541,8 +544,8 @@ The value is recursively traversed. As the relay comes across each embedded refe
enforce an attenuation request](#attenuation-of-authority). If it trusts the peer to
honour attenuation requests, it substitutes a `yours`-variant `WireRef` with non-empty
attenuation into *v*. Otherwise, a fresh OID and `WireSymbol` are placed in the export
membrane, with ref denoting to the attenuated local reference, and the new OID is
substituted as a `mine`-variant `WireRef` into *v*.
membrane, with ref denoting the attenuated local reference, and the new OID is substituted
as a `mine`-variant `WireRef` into *v*.
## Relay entities
@ -685,12 +688,12 @@ To use such a transport for this protocol, establish a connection and begin tran
[`Packet`s](#packet-definitions) encoded as Preserves values using either the Preserves [text
syntax](https://preserves.gitlab.io/preserves/preserves.html#textual-syntax) or the Preserves
[binary syntax](https://preserves.gitlab.io/preserves/preserves.html#compact-binary-syntax).
The session starts with the first packet and ends with transport disconnection. It MUST
disconnect the transport upon syntax error. A responding server MUST support the binary syntax,
and MAY also support the text syntax. It can autodetect the syntax variant by following [the
rules in the
The session starts with the first packet and ends with transport disconnection. If either peer
in a connection detects a syntax error, it MUST disconnect the transport. A responding server
MUST support the binary syntax, and MAY also support the text syntax. It can autodetect the
syntax variant by following [the rules in the
specification](https://preserves.gitlab.io/preserves/preserves.html#appendix-autodetection-of-textual-or-binary-syntax):
in short, the first byte of a valid binary-syntax Preserves document is guaranteed not to be
the first byte of a valid binary-syntax Preserves document is guaranteed not to be
interpretable as the start of a valid UTF-8 sequence.
`Packet`s encoded in either binary or text syntax are self-delimiting. However, peers using