Function: ltpReduce()
ltpReduce(
state,event):LtpTransition
Advance the LTP session by one inbound event: a pure function, no I/O.
Behaviour by phase:
- neutral:
enqaccepts establishment (sendAck, enter transfer);eotis a benign line reset (no-op);ack/nakare unexpected at a receiver (surfaced, never read as acceptance); aframebefore establishment is tolerated (Postel's Law), the session auto-establishes and processes it, with a warning. - transfer: a
frameis accepted (sendAck, appended, sequence advanced) only when it is trusted and carries the expected number; a duplicate of the last accepted frame is idempotently re-ACKed without re-appending; a bad or out-of-sequence frame isNAKed and dropped.eotterminates the transfer and returns to neutral (a record left open on anETBis not delivered).enqrestarts establishment.ack/nakare unexpected.
Parameters
state
The current session state.
event
The inbound event.
Returns
The next state, the actions to take, and any warnings.
Example
import { ltpInitialState, ltpReduce } from "@cosyte/astm";
// A bad-checksum frame is NAKed, never ACKed, and never appended.
const est = ltpReduce(ltpInitialState(), { type: "enq" }).state;
const bad = { trusted: false } as never;
ltpReduce(est, { type: "frame", frame: bad }).actions; // [{ type: "sendNak" }]