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. distant entities can be addressed as if they were local.
Relays exchange *Syndicate Protocol* messages across a [transport](./glossary.md#transport). A 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 *transport* is the underlying medium connecting one relay to its counterpart(s). For example, a
network. For example, a TLS-on-TCP/IP socket may connect a pair of relays to one another, or a TLS-on-TCP/IP socket may connect a pair of relays to one another, or a UDP multicast socket may
UDP multicast socket may connect an entire group of relays across an connect an entire group of relays across an ethernet.[^relaying-over-syndicate]
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 **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. [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 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 [OID](./glossary.md#oid) in each `TurnEvent` selects an entity known to the recipient. If a
`Event` is either publication of an assertion, retraction of a previously-published assertion, particular `TurnEvent`'s OID is not mapped to an entity, the `TurnEvent` is silently ignored,
delivery of a single message, or a [synchronization](./glossary.md#synchronization) event. 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 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 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 - 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. ([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 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` 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 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. OID is looked up in the import membrane.
- If no `WireSymbol` exists in the import membrane, one is created, mapping the OID to a - 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*. - 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. 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 - 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 - If a `WireSymbol` exists for the OID, and the `WireRef` is not
[attenuated](#attenuation-of-authority), the associated ref is substituted into *v*. If [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*. `WireRef` before its substitution into *v*.
- In each case, the `WireSymbol` associated with the OID has its reference count incremented - 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 - 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 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*. 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)
- Otherwise, it refers to a previously-imported entity. referencing a previously-imported remote entity:
- If the local entity reference has not been attenuated subsequent to its import, the OID it - 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 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 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 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 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 membrane, with ref denoting the attenuated local reference, and the new OID is substituted
substituted as a `mine`-variant `WireRef` into *v*. as a `mine`-variant `WireRef` into *v*.
## Relay entities ## 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 [`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 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). [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 The session starts with the first packet and ends with transport disconnection. If either peer
disconnect the transport upon syntax error. A responding server MUST support the binary syntax, in a connection detects a syntax error, it MUST disconnect the transport. A responding server
and MAY also support the text syntax. It can autodetect the syntax variant by following [the MUST support the binary syntax, and MAY also support the text syntax. It can autodetect the
rules in the syntax variant by following [the rules in the
specification](https://preserves.gitlab.io/preserves/preserves.html#appendix-autodetection-of-textual-or-binary-syntax): 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. 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 `Packet`s encoded in either binary or text syntax are self-delimiting. However, peers using