Class: Ast::Merge::Git::LocalBenchmarkReport

Inherits:
Object
  • Object
show all
Defined in:
lib/ast/merge/git/local_benchmark.rb,
sig/ast/merge/git.rbs

Overview

Builds a non-scalar paired report from local benchmark raw evidence.

Constant Summary collapse

SUCCESS =

Returns:

  • (Array[String])
%w[correct_clean true_conflict].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(run) ⇒ LocalBenchmarkReport

Returns a new instance of LocalBenchmarkReport.

Parameters:

  • run (Hash[String, untyped])


746
747
748
749
# File 'lib/ast/merge/git/local_benchmark.rb', line 746

def initialize(run)
  @run = run
  @results = run.fetch('results')
end

Class Method Details

.build(run) ⇒ Hash[String, untyped]

Parameters:

  • run (Hash[String, untyped])

Returns:

  • (Hash[String, untyped])


742
743
744
# File 'lib/ast/merge/git/local_benchmark.rb', line 742

def self.build(run)
  new(run).build
end

Instance Method Details

#buildHash[String, untyped]

Returns:

  • (Hash[String, untyped])


751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
# File 'lib/ast/merge/git/local_benchmark.rb', line 751

def build
  pairs = @results.group_by { |result| result['case_id'] }.values.map { |items| transition(items) }
  false_auto_merges = eligible.select { |item| item['outcome'] == 'false_auto_merge' }
  {
    'schema_version' => 'structuredmerge.benchmark.report/v1',
    'kind' => 'paired_aggregate_report',
    'corpus_id' => @run['corpus_id'],
    'corpus_digest' => @run['corpus_digest'],
    'selection' => @run['selection'],
    'cache_identity' => @run['cache_identity'],
    'dimensions' => {
      'safety' => {
        'eligible' => eligible.length,
        'false_auto_merge_result_ids' => false_auto_merges.map { |item| item['id'] },
        'gate' => false_auto_merges.empty? ? 'pass' : 'fail',
        'non_compensable' => true
      },
      'effectiveness' => outcome_counts,
      'preservation' => {
        'eligible' => eligible.length,
        'violation_result_ids' => eligible.filter_map do |item|
          item['id'] if item.dig('dimensions', 'preservation', 'violations').any?
        end
      },
      'performance' => performance,
      'reliability' => { 'error_result_ids' => @results.filter_map do |item|
        item['id'] if item['outcome'] == 'error'
      end },
      'coverage' => coverage
    },
    'strata' => strata,
    'transitions' => pairs,
    'newly_passing_case_ids' => pairs.filter_map { |pair| pair['case_id'] if pair['newly_passing'] },
    'newly_failing_case_ids' => pairs.filter_map { |pair| pair['case_id'] if pair['newly_failing'] },
    'changed_conflict_case_ids' => pairs.filter_map { |pair| pair['case_id'] if pair['changed_conflict'] },
    'hard_gate_failed' => false_auto_merges.any?,
    'scalar_score' => nil
  }
end