Class LeaseRenewer

java.lang.Object
at.aimon.session.web.internal.LeaseRenewer

public final class LeaseRenewer extends Object
Periodically extends a ConversationLock.LockHandle's lease (design §7.4) on a manager-owned ScheduledExecutorService.

The renewer is intentionally separate from the turn-execution thread: when a turn blocks on an LLM call or a tool, the lease must still be renewed by an unrelated scheduler tick or the lock will silently expire and another node may race ahead. The recommended interval is lease/3.

When ConversationLock.extend(LockHandle, Duration) returns false — the fencing token no longer matches because the lease already expired — the onExtendFailed hook is invoked exactly once. The hook is the manager's signal to interrupt the turn with InterruptReason.LEASE_LOST. Subsequent ticks become no-ops because the lostLease flag latches.

If an idempotency entry is associated with this turn, the optional IdempotencyStore.touch(String, String) call piggybacks the secondary-TTL refresh on each successful extend so the holder-loss sweeper does not pick the entry as stale while the holder is alive (design §9.2 stale cleanup).