Skip to main content

Module duplex_gate

Module duplex_gate 

Source
Expand description

BIDIR-8 (BIDIR-5’s rule): the gate over a duplex call — open, admit, re-verify on the gate’s grants generation, answer, audit. BIDIR-8 (BIDIR-5’s rule, made a library) — the gate over a duplex call.

A duplex call is params, then an input half and an output half (BIDIR-1). DuplexGate::open decides it as the grant gate decides any call — once, the method’s grant on its target, within the ceiling — and takes the call’s place on its connection (CallCounter: in a server, plexus-transport’s ConnectionCalls, one per connection, a duplex call counted as one call). The DuplexCall it answers holds the caller and admits each input frame without asking the gate:

whenthe gate doesrefusal (error_kind)ends the call?
openGate::check onceforbidden {grant, scope, roles, held_on} / unauthenticatednever opens
open, past the connection’s callscount it as any calltoo_many_calls {max}never opens
an input frame from another connectioncompare connection idsnot_this_call (to the sender)no
an input frame past creditcompare seq with the credit grantedpast_credit {seq, credit}yes
an input frame past a ceiling its method opted into, or past what one call may holdcount items and bytestoo_much_input {limit, max}yes
an input frame out of sequencethe transport compares seq with the next expectedout_of_sequence {seq, expected}yes
the gate’s grants generation moves (grant, revoke, role edit, team, sign-out)Gate::check once per callforbidden / unauthenticatedyes, items after it dropped
the sign-in’s expirythe call’s own timer: the caller proves no oneunauthenticatedyes
a question answeredAnswerer: own connection; a person; or a grant on the target (Gate::check once per answer)not_this_call / person_required / forbiddenno

A frame’s admission is: the half is open, the frame is the call’s own connection’s, the gate’s generation is the one last verified (one atomic load), the frame is within credit and the ceiling. So a revoke reaches every open call at the generation’s move — DuplexCall::input selects on it, so a quiet call ends then too — and no item ever costs a gate check. The generation is the gate’s own (Gate::generation, plexus-auth-core): every service that keeps a gate keeps one, and moves it with Gate::moved wherever it writes a grant.

Every typed refusal is one audit record (AuditRecordKind::DuplexRefused), built only when it happens and offered to a bounded AuditQueue that never waits (DuplexGate::with_audit): an admitted frame allocates nothing.

BIDIR-6’s call slot (super::input), keyed by (connection, subscription), feeds DuplexCall::input one InputFrame for each {ns}.input {subscription, seq, items}. seq counts frames; credit counts items, so a frame carries how many it holds.

Structs§

CallCeiling
The gate’s terms for a duplex call (plexus-auth-core), re-exported so a caller of this module needs no second import. What one call may take in (BIDIR-1: “every item that flows has a limit”). Beside the transport’s per-connection call count, which counts a duplex call as one call.
CallPlace
A call’s place on its connection, held for as long as the call is open and given back when dropped — whatever the counter keeps behind it.
CallRef
The gate’s terms for a duplex call (plexus-auth-core), re-exported so a caller of this module needs no second import. BIDIR-8: which call a refusal was about — the connection it runs on and its subscription there (the slot BIDIR-6 keys a duplex call by).
ConnId
A connection, as the transport numbers it.
CreditLine
The credit a call has granted, shared with whoever grants it: the transport’s pipe grants as the handler consumes, on a call that DuplexCall::input has taken.
DuplexCall
One open duplex call, holding its caller (the module docs).
DuplexGate
The gate over duplex calls: a Gate (and its grants generation, which says when to ask it again), the audit, and the clock expiry is read by.
GrantsGeneration
BIDIR-8 (BIDIR-5’s finding): the grants generation — a count every write that could change one of the gate’s answers moves (GrantsMove). It is the gate’s: whoever holds an answer across time (a duplex call’s caller, a watch) records the generation it was decided at and asks the gate again only when it has moved — once per move, never per item. Cheap to clone (two Arcs, one count); a read is one atomic load; a move wakes every subscriber.
InputFrame
One input frame as the transport hands it over: which connection sent it, its seq, what it holds, how many items that is, and their size on the wire.

Enums§

Answerer
The gate’s terms for a duplex call (plexus-auth-core), re-exported so a caller of this module needs no second import. Who may answer a question a method asks mid-call — an output item that expects a reply (BIDIR-1 mechanism). The method declares it (#[method(answer_by = "…")], BIDIR-1 answerer).
DuplexRefusal
Why the gate refused a duplex call, a frame or an answer — each typed on the wire as an error item with its error_kind.
DuplexRefusalCode
The gate’s terms for a duplex call (plexus-auth-core), re-exported so a caller of this module needs no second import. BIDIR-8: every typed refusal the gate makes over a duplex call — its error_kind on the wire, and the reason of its audit record (AuditRecordKind::DuplexRefused).
GrantsMove
BIDIR-8: what moved the grants generation (Gate::moved) — every write that could change an answer the gate gave.
Overrun
What the transport found wrong with a frame when it arrived. It holds nothing past the first one, so the frame says so and goes through the same admission as any other, whenever that comes: DuplexCall::admit refuses it, whatever the credit has become since.

Traits§

CallCounter
The calls open on one connection, as whoever counts them keeps them — plexus-transport’s ConnectionCalls in a server (BIDIR-8: the count is the transport’s, so no service writes it). A duplex call is one call.

Type Aliases§

Clock
The wall clock, in unix seconds: when a sign-in expires.