Class: Necropsy::Bench::ClaimGate

Inherits:
Object
  • Object
show all
Defined in:
lib/necropsy/bench/claim_gate.rb

Overview

Final, configurable gate for a public accuracy claim. It is deliberately disabled unless a release config opts in with claim_gate.

Constant Summary collapse

ACTIONABLE_STATES =
%w[unreachable unused candidate].freeze

Instance Method Summary collapse

Constructor Details

#initialize(config:, reports:, summary:, adversarial_results:) ⇒ ClaimGate

Returns a new instance of ClaimGate.



10
11
12
13
14
15
# File 'lib/necropsy/bench/claim_gate.rb', line 10

def initialize(config:, reports:, summary:, adversarial_results:)
  @config = config || {}
  @reports = reports || {}
  @summary = summary || {}
  @adversarial_results = Array(adversarial_results)
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/necropsy/bench/claim_gate.rb', line 17

def call
  policy = normalized_policy
  return { 'schema_version' => 1, 'enforced' => false, 'passed' => true } unless policy

  checks = {
    'corpus_count' => reports.length >= policy.fetch('minimum_corpora'),
    'category_coverage' => category_coverage?(policy.fetch('required_categories')),
    'high_candidates_explained' => unexplained_high_candidates.empty?,
    'adversarial_suites' => adversarial_results.all? { |result| result['passed'] == true },
    'candidate_precision' => precision_measured?,
    'candidate_yield' => candidate_yield?
  }
  checks['reviewed_high_target'] = reviewed_high_count >= policy.fetch('minimum_reviewed_high')
  {
    'schema_version' => 1,
    'enforced' => true,
    'policy' => policy,
    'checks' => checks,
    'unexplained_high_candidates' => unexplained_high_candidates,
    'reviewed_high_candidates' => reviewed_high_count,
    'passed' => checks.values.all?
  }
end