package agent

// advanceAckEpochLocked fences late runtime acknowledgements from
// the prior provider turn. The caller must hold ap.mu.
func (ap *Process) advanceAckEpochLocked() {
	if ap == nil {
		return
	}
	ap.ackEpoch++
	// Advancing the ack epoch ends the authoritative request for the ordinary
	// drain, stop, and exit paths that call it, so the turn's message-send
	// scope retires with it. A successful InterruptAndDeliver starts the next
	// authoritative request WITHOUT advancing the epoch and retires
	// explicitly.
	ap.resetSendScopeLocked()
	ap.resetTurnDeliveryLocked()
}

func (ap *Process) advanceAckEpoch() {
	if ap == nil {
		return
	}
	ap.mu.Lock()
	ap.advanceAckEpochLocked()
	ap.mu.Unlock()
}
