using ZB.MOM.WW.MxGateway.Contracts.Proto;
namespace ZB.MOM.WW.MxGateway.Server.Sessions;
///
/// The result of a reconnect/resume attach
/// (, Task 12): the live
/// subscriber lease plus the replay batch and resume watermarks snapshotted atomically
/// with the registration, so the replay→live handoff has no gap and no duplicate.
///
///
/// The live event subscriber lease. Disposing it unregisters the distributor subscriber
/// and decrements the session's active-subscriber count, exactly as a fresh attach.
///
///
/// Retained events with worker sequence strictly greater than the requested
/// afterSequence, in ascending order. These must be yielded (after the optional
/// gap sentinel) before live events. Never null; empty when nothing newer is retained.
///
///
/// when events between the requested afterSequence and the
/// oldest retained event were already evicted, so the client missed unrecoverable events.
/// When the caller emits a ReplayGap sentinel before the
/// replay batch.
///
///
/// The oldest worker sequence still retained and replayable; 0 when nothing is
/// retained. Populates the ReplayGap.oldest_available_sequence field. Meaningful
/// only when is .
///
///
/// The worker sequence the live channel must resume strictly after: the highest replayed
/// sequence, or the requested afterSequence when nothing was replayed. The caller
/// applies this as the per-subscriber live filter so any event both replayed and fanned
/// into the live channel is dropped exactly once (no duplicate) while every newer event
/// is delivered (no gap).
///
public readonly record struct EventSubscriberReplayAttachment(
IEventSubscriberLease Lease,
IReadOnlyList ReplayedEvents,
bool Gap,
ulong OldestAvailableSequence,
ulong LiveResumeSequence);