namespace Mbproxy.Proxy.Multiplexing;
///
/// One upstream party interested in a single backend round-trip. Carries the upstream
/// pipe to deliver the response to AND the original MBAP TxId that the party sent — the
/// multiplexer must rewrite the response's MBAP TxId back to
/// before handing the frame to the pipe, so each upstream sees the proxy as transparent.
///
/// Read coalescing fans out a single backend response to multiple upstream parties
/// via this record. Do not collapse this into a single field on
/// .
///
internal sealed record InterestedParty(UpstreamPipe Pipe, ushort OriginalTxId);
///
/// Per-backend-request correlation record. Stored in keyed
/// by the proxy-assigned TxId; looked up by the backend reader task to:
///
/// - Restore each interested party's original MBAP TxId before forwarding
/// the response upstream (transparent multiplexing contract).
/// - Provide the BCD rewriter with the originating request's
/// StartAddress / Qty for FC03/FC04 response decoding — the response
/// PDU itself does not carry the start address.
/// - Measure backend round-trip time via .
///
///
/// The list shape is the load-bearing seam that
/// read coalescing uses to fan out a single PLC response to multiple upstream clients.
/// Reviewer note: do not simplify back to a single UpstreamPipe field.
///
internal sealed record InFlightRequest(
byte UnitId,
byte Fc,
ushort StartAddress,
ushort Qty,
IReadOnlyList InterestedParties,
DateTimeOffset SentAtUtc,
int ResolvedCacheTtlMs = 0);