docs: public void applyLogEntries() {
          // Reject logs we've applied already
          long commitIndex = state.commitIndex();
          long lastApplied = state.lastApplied();
  
          if (commitIndex == lastApplied) {
              return;
          }
  
          // If commitIndex > lastApplied: increment lastApplied, apply log[lastApplied] to state machine (§5.3)
          assert commitIndex > lastApplied
                  : "commit index: " + commitIndex + " cannot be smaller than last applied: " + lastApplied;
  
          // Apply all the preceding logs
          RaftLog raftLog = state.log();
          for (long idx = state.lastApplied() + 1; idx <= commitIndex; idx++) {
              LogEntry entry = raftLog.getLogEntry(idx);
              if (entry == null) {
                  String msg = "Failed to get log entry at index: " + idx;
                  logger.severe(msg);
                  throw new AssertionError(msg);
              }
  
              applyLogEntry(entry);
  
              // Update the lastApplied index
              state.lastApplied(idx);
          }
  
          assert status != TERMINATED || commitIndex == raftLog.lastLogOrSnapshotIndex()
                  : "commit index: " + commitIndex + " must be equal to " + raftLog.lastLogOrSnapshotIndex() + " on termination.";
  
          if (state.role() == LEADER || state.role() == FOLLOWER) {
              takeSnapshotIfCommitIndexAdvanced();
          }
      }