Class: Necropsy::Bench::ReviewQueue

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

Overview

Builds a deterministic, explicitly-unreviewed queue from normalized reports. The queue is evidence collection tooling; it never supplies labels or passes the public claim gate by itself.

Constant Summary collapse

ACTIONABLE_STATES =
%w[unreachable unused candidate].freeze
HIGH_CONFIDENCES =
%w[high certain].freeze
CONFIDENCE_ORDER =
{ 'certain' => 0, 'high' => 1, 'medium' => 2, 'low' => 3 }.freeze
VERSION =
1

Instance Method Summary collapse

Constructor Details

#initialize(reports:, target_reviewed_high: 300, limit: nil) ⇒ ReviewQueue

Returns a new instance of ReviewQueue.



17
18
19
20
21
22
23
24
# File 'lib/necropsy/bench/review_queue.rb', line 17

def initialize(reports:, target_reviewed_high: 300, limit: nil)
  @reports = reports
  @target_reviewed_high = Integer(target_reviewed_high)
  @limit = limit.nil? ? @target_reviewed_high : Integer(limit)
  validate_options!
rescue ArgumentError, TypeError
  raise Error, 'Review queue target and limit must be integers'
end

Instance Method Details

#callObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/necropsy/bench/review_queue.rb', line 26

def call
  validate_reports!
  available = actionable_entries
  entries = available.sort_by { |entry| sort_key(entry) }.first(limit)
  high_entries = entries.select { |entry| HIGH_CONFIDENCES.include?(entry.fetch('confidence')) }
  {
    'schema_version' => VERSION,
    'status' => 'pending',
    'selection' => 'actionable findings, confidence ascending, then corpus and identity',
    'target_reviewed_high_candidates' => target_reviewed_high,
    'available_actionable_candidates' => available.length,
    'queued_candidates' => entries.length,
    'reviewed_candidates' => 0,
    'reviewed_high_candidates' => 0,
    'pending_candidates' => entries.length,
    'pending_high_candidates' => high_entries.length,
    'target_shortfall' => [target_reviewed_high - high_entries.length, 0].max,
    'claim_gate_passed' => false,
    'corpora' => corpus_summary(available, entries),
    'provenance' => provenance,
    'entries' => entries
  }
end