#lang syndicate
;; Internal server and federation protocol

(provide (all-defined-out))

;; Client-server internal protocol
;; Received packets from server are relayed via one of these.
(message-struct server-packet (address packet))
;; Like `server-connected`, but for reflecting `tcp-accepted` to the
;; client end of a client-server connection without reordering wrt
;; `server-packet` messages. Implementation-facing, where
;; `server-connected` is part of the API.
(assertion-struct server-transport-connected (address))
;; Like `server-connected`, but for reflecting the state of the
;; session to the transport driver. Observation of
;; `server-session-connected` is not creative (of `server-connected`),
;; unlike observation of `server-connected`.
(assertion-struct server-session-connected (address))

;; Internal connection protocol
(assertion-struct server-poa (connection-id)) ;; "Point of Attachment"
(assertion-struct server-poa-ready (connection-id))
(assertion-struct message-poa->server (connection-id body))
(assertion-struct message-server->poa (connection-id body))

;; Internal isolation -- these are isomorphic to `to-server` and `from-server`!
;;                       (and, for that matter, to `outbound` and `inbound`!)
(assertion-struct server-proposal (scope body)) ;; suggestions (~ actions)
(assertion-struct server-envelope (scope body)) ;; decisions (~ events)

(assertion-struct server-active (scope))

;; Federated links generally
(assertion-struct federated-link (id scope))
(assertion-struct federated-link-ready (id))
