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])


1061
1062
1063
1064
# File 'lib/ast/merge/git/local_benchmark.rb', line 1061

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])


1057
1058
1059
# File 'lib/ast/merge/git/local_benchmark.rb', line 1057

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

Instance Method Details

#buildHash[String, untyped]

Returns:

  • (Hash[String, untyped])


1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
# File 'lib/ast/merge/git/local_benchmark.rb', line 1066

def build
  pairs = @results.group_by { |result| result['case_id'] }.values.map { |items| transition(items) }
  false_auto_merges = candidate_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' => candidate_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,
      'competitive' => competitive
    },
    '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