code: private void keepAliveSession(long index, long timestamp, long commandSequence, long eventIndex, ServerSessionContext session, CompletableFuture<Void> future, ThreadContext context) {
      if (!log.isOpen()) {
        context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed")));
        return;
      }
  
      // If the session is already in an inactive state, complete the future exceptionally.
      if (!session.state().active()) {
        context.executor().execute(() -> future.completeExceptionally(new UnknownSessionException("inactive session: " + session.id())));
        return;
      }
  
      // Trigger scheduled callbacks in the state machine.
      executor.tick(index, timestamp);
  
      // Update the state machine context with the keep-alive entry's index. This ensures that events published
      // as a result of asynchronous callbacks will be executed at the proper index with SEQUENTIAL consistency.
      executor.init(index, Instant.ofEpochMilli(timestamp), ServerStateMachineContext.Type.COMMAND);
  
      session.clearResults(commandSequence).resendEvents(eventIndex);
  
      // Calculate the last completed index.
      long lastCompleted = calculateLastCompleted(index);
  
      // Callbacks in the state machine may have been triggered by the execution of the keep-alive.
      // Get any futures for scheduled tasks and await their completion, then update the highest
      // index completed for all sessions to allow log compaction to progress.
      executor.commit();
      context.executor().execute(() -> {
        setLastCompleted(lastCompleted);
        future.complete(null);
      });
    }
docs: Applies a keep alive for a session.