code: private CompletableFuture<QueryResponse> sequenceAndApply(QueryEntry entry) {
      // Get the client's server session. If the session doesn't exist, return an unknown session error.
      ServerSessionContext session = context.getStateMachine().executor().context().sessions().getSession(entry.getSession());
      if (session == null) {
        return CompletableFuture.completedFuture(logResponse(QueryResponse.builder()
          .withStatus(Response.Status.ERROR)
          .withError(CopycatError.Type.UNKNOWN_SESSION_ERROR)
          .build()));
      }
  
      CompletableFuture<QueryResponse> future = new CompletableFuture<>();
  
      // If the query's sequence number is less than the session's current request sequence number but greater than the
      // session's current applied sequence number, queue the request for handling once the state machine is caught up.
      if (entry.getSequence() > session.getCommandSequence()) {
        session.registerSequenceQuery(entry.getSequence(), () -> applyQuery(entry, future));
      }
      // If the query is already in sequence then just apply it.
      else {
        applyQuery(entry, future);
      }
      return future;
    }
docs: Sequences and applies the given query entry.