<commit_before>module RSpecSearchAndDestroy
  class Bisector
    attr_reader :output, :selector, :executor

    def initialize(output, selector, executor)
      @output = output
      @selector = selector
      @executor = executor
    end

    def bisect(causal_examples, failed_example)
      case causal_examples.size
      when 1
        output.found(causal_examples.first, failed_example)
        return
      when 0
        output.unable_to_bisect
        return
      end

      enabled, disabled = selector.enable_set(causal_examples)

      to_run = enabled + [failed_example]
      executor.run_examples(to_run)

      results = executor.load_run_results

      if results.failed?
        bisect(enabled, failed_example)
      else
        bisect(disabled, failed_example)
      end
    end
  end
end<commit_msg>Reduce duplication of the recursive bisect call<commit_after>module RSpecSearchAndDestroy
  class Bisector
    attr_reader :output, :selector, :executor

    def initialize(output, selector, executor)
      @output = output
      @selector = selector
      @executor = executor
    end

    def bisect(causal_examples, failed_example)
      case causal_examples.size
      when 1
        output.found(causal_examples.first, failed_example)
        return
      when 0
        output.unable_to_bisect
        return
      end

      enabled, disabled = selector.enable_set(causal_examples)

      to_run = enabled + [failed_example]
      executor.run_examples(to_run)

      results = executor.load_run_results

      next_set = results.failed? ? enabled : disabled
      bisect(next_set, failed_example)
    end
  end
end
{'fraction_non_alphanumeric': 0.06082725060827251, 'fraction_numerical': 0.0024330900243309003, 'mean_word_length': 2.688340807174888, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3003551', 'n_tokens_mistral': 505, 'n_tokens_neox': 468, 'n_words': 111}