Class: SkillBench::Services::TrendRecorderService
- Inherits:
-
Object
- Object
- SkillBench::Services::TrendRecorderService
- Defined in:
- lib/skill_bench/services/trend_recorder_service.rb
Overview
Records evaluation results and computes trends.
Constant Summary collapse
- WRITE_MUTEX =
Serializes the load -> append -> write of the shared trend history file. Batch runs (BatchRunnerService) execute evals concurrently and the trend file is process-global shared state; without this lock, concurrent records race on the temp-file rename and silently lose appended entries.
Mutex.new
Class Method Summary collapse
-
.call(result, eval_name, skill_names) ⇒ Hash
Records evaluation results and computes trends.
Instance Method Summary collapse
-
#call ⇒ Hash
Records evaluation results and computes trends.
-
#initialize(result, eval_name, skill_names) ⇒ TrendRecorderService
constructor
A new instance of TrendRecorderService.
Constructor Details
#initialize(result, eval_name, skill_names) ⇒ TrendRecorderService
Returns a new instance of TrendRecorderService.
29 30 31 32 33 |
# File 'lib/skill_bench/services/trend_recorder_service.rb', line 29 def initialize(result, eval_name, skill_names) @result = result @eval_name = eval_name @skill_names = skill_names end |
Class Method Details
.call(result, eval_name, skill_names) ⇒ Hash
Records evaluation results and computes trends.
22 23 24 |
# File 'lib/skill_bench/services/trend_recorder_service.rb', line 22 def self.call(result, eval_name, skill_names) new(result, eval_name, skill_names).call end |
Instance Method Details
#call ⇒ Hash
Records evaluation results and computes trends.
Loads the trend history once and reuses it for both the trend computation and the append+write, avoiding a duplicate parse per run.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/skill_bench/services/trend_recorder_service.rb', line 41 def call tracker = TrendTracker.new enriched = @result.merge(eval_name: @eval_name, skill_names: @skill_names) trend, record_result = record_atomically(tracker, enriched) record_success = record_result.is_a?(Hash) && record_result[:success] unless record_success = if record_result.is_a?(Hash) record_result.dig(:response, :error, :message) || record_result.dig(:error, :message) || 'Unknown error' else 'Unexpected record response' end SkillBench::ErrorLogger.log_error( StandardError.new(), "Trend tracking record failed for eval #{@eval_name}" ) return { success: false, response: { error: { message: "Trend tracking record failed: #{}", record_result: record_result } } } end { success: true, trend: trend } rescue StandardError => e SkillBench::ErrorLogger.log_error(e, 'Trend tracking failed') { success: false, response: { error: { message: e. } } } end |