FIFO execution of polynomial request clients #
Clients have stable identities and at most one outstanding request. A shared service answers requests in FIFO order; responses travel through the same queue before resuming their client. Each request carries a fresh ticket, and a response resumes only the matching waiting client. Schedules explicitly distinguish client activation from packet delivery. One RPC therefore requires three activations, even when the service computation itself is pure.
The service's monadic effect is atomic at this runtime boundary. Its internal cost is separate
from packet-delivery fuel. No fairness or completion assumption is built into finite execution.
Typed response traffic uses PolyFun's Interface.RoutedPacket vocabulary.
State.initial starts every client ready, with no traffic and a fresh ticket counter.
ClientState.result observes a returned client without discarding the network state.
A client either has executable code or awaits one particular response.
- ready {p : PFunctor.{0, 0}} {α : Type} (program : p.FreeM α) : ClientState p α
- waiting {p : PFunctor.{0, 0}} {α : Type} (ticket : ℕ) (query : p.A) (next : p.B query → p.FreeM α) : ClientState p α
Instances For
Requests and typed responses share one FIFO queue.
- request {Client : Type} {p : PFunctor.{0, 0}} (client : Client) (ticket : ℕ) (query : p.A) : Envelope Client p
- response {Client : Type} {p : PFunctor.{0, 0}} (ticket : ℕ) (reply : Interface.RoutedPacket p Client) : Envelope Client p
Instances For
The complete runtime state, including pending traffic and delivered responses.
- clients : Client → ClientState p α
Residual code or the single pending continuation of each static client.
- service : S
Private state shared by all calls to the service.
Outstanding requests and responses, oldest packet first.
- nextTicket : ℕ
Fresh ticket reserved for the next emitted request.
- transcript : List (Interface.RoutedPacket p Client)
Responses actually delivered to matching clients, in delivery order.
Instances For
Initialize ready clients and a service with no outstanding or delivered traffic.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Observe a completed client without discarding any pending network state.
Equations
- (Interaction.Execution.RequestNetwork.ClientState.ready (PFunctor.FreeM.pure value)).result = some value
- x✝.result = none
Instances For
A schedule either activates a client or delivers the oldest queued packet.
- client {Client : Type} (id : Client) : Activation Client
- deliver {Client : Type} : Activation Client
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Interaction.Execution.RequestNetwork.instDecidableEqActivation.decEq Interaction.Execution.RequestNetwork.Activation.deliver Interaction.Execution.RequestNetwork.Activation.deliver = isTrue ⋯
Instances For
Emit one request and suspend its client. Waiting and returned clients emit nothing.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A returned client emits nothing.
A ready client at an operation node emits that request. Stated on the simp normal form
FreeM.lift a >>= next of the node, as it appears after constructor normalisation.
A suspended client cannot enqueue a second request.
Resume a waiting client only when both ticket and dependent query tag match.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Deliver the oldest packet. Servicing a request appends its response at the queue's tail.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Execute one scheduled activation, including a no-op activation in its fuel count.
Equations
- Interaction.Execution.RequestNetwork.step impl (Interaction.Execution.RequestNetwork.Activation.client id) state = pure (Interaction.Execution.RequestNetwork.emit id state)
- Interaction.Execution.RequestNetwork.step impl Interaction.Execution.RequestNetwork.Activation.deliver state = Interaction.Execution.RequestNetwork.deliver impl state
Instances For
Execute an explicit finite schedule. Unserviced packets remain in the returned state.
Equations
- Interaction.Execution.RequestNetwork.run impl [] x✝ = pure x✝
- Interaction.Execution.RequestNetwork.run impl (action :: rest) x✝ = Interaction.Execution.RequestNetwork.step impl action x✝ >>= Interaction.Execution.RequestNetwork.run impl rest
Instances For
Splitting a schedule retains all pending traffic, tickets, and private service state.
A stale ticket cannot resume a waiting client or enter its delivered transcript.
Three activations complete one query when the queue starts empty. The continuation sees the actual service answer, and the final transcript records that answer with its stable client id.