Class: Aidp::Evaluations::EvaluationRecord
- Inherits:
-
Object
- Object
- Aidp::Evaluations::EvaluationRecord
- Defined in:
- lib/aidp/evaluations/evaluation_record.rb
Overview
Represents a single evaluation record
An evaluation captures user feedback (good/neutral/bad) for AIDP outputs such as prompts, work units, or full work loops, along with rich context.
Constant Summary collapse
- VALID_RATINGS =
%w[good neutral bad].freeze
- VALID_TARGET_TYPES =
%w[prompt work_unit work_loop step plan review build ci_fix change_request].freeze
Instance Attribute Summary collapse
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#rating ⇒ Object
readonly
Returns the value of attribute rating.
-
#target_id ⇒ Object
readonly
Returns the value of attribute target_id.
-
#target_type ⇒ Object
readonly
Returns the value of attribute target_type.
Class Method Summary collapse
-
.from_h(hash) ⇒ Object
Create record from stored hash.
Instance Method Summary collapse
-
#bad? ⇒ Boolean
Check if rating is negative.
-
#good? ⇒ Boolean
Check if rating is positive.
-
#initialize(rating:, comment: nil, target_type: nil, target_id: nil, context: {}, id: nil, created_at: nil) ⇒ EvaluationRecord
constructor
A new instance of EvaluationRecord.
-
#neutral? ⇒ Boolean
Check if rating is neutral.
-
#to_h ⇒ Object
Convert to hash for storage.
Constructor Details
#initialize(rating:, comment: nil, target_type: nil, target_id: nil, context: {}, id: nil, created_at: nil) ⇒ EvaluationRecord
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/aidp/evaluations/evaluation_record.rb', line 26 def initialize(rating:, comment: nil, target_type: nil, target_id: nil, context: {}, id: nil, created_at: nil) @id = id || generate_id = () @comment = comment @target_type = validate_target_type(target_type) @target_id = target_id @context = context || {} @created_at = created_at || Time.now.iso8601 Aidp.log_debug("evaluation_record", "create", id: @id, rating: , target_type: @target_type, target_id: @target_id) end |
Instance Attribute Details
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
23 24 25 |
# File 'lib/aidp/evaluations/evaluation_record.rb', line 23 def comment @comment end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
23 24 25 |
# File 'lib/aidp/evaluations/evaluation_record.rb', line 23 def context @context end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
23 24 25 |
# File 'lib/aidp/evaluations/evaluation_record.rb', line 23 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
23 24 25 |
# File 'lib/aidp/evaluations/evaluation_record.rb', line 23 def id @id end |
#rating ⇒ Object (readonly)
Returns the value of attribute rating.
23 24 25 |
# File 'lib/aidp/evaluations/evaluation_record.rb', line 23 def end |
#target_id ⇒ Object (readonly)
Returns the value of attribute target_id.
23 24 25 |
# File 'lib/aidp/evaluations/evaluation_record.rb', line 23 def target_id @target_id end |
#target_type ⇒ Object (readonly)
Returns the value of attribute target_type.
23 24 25 |
# File 'lib/aidp/evaluations/evaluation_record.rb', line 23 def target_type @target_type end |
Class Method Details
.from_h(hash) ⇒ Object
Create record from stored hash
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/aidp/evaluations/evaluation_record.rb', line 53 def self.from_h(hash) hash = symbolize_keys(hash) new( id: hash[:id], rating: hash[:rating], comment: hash[:comment], target_type: hash[:target_type], target_id: hash[:target_id], context: hash[:context] || {}, created_at: hash[:created_at] ) end |
Instance Method Details
#bad? ⇒ Boolean
Check if rating is negative
72 73 74 |
# File 'lib/aidp/evaluations/evaluation_record.rb', line 72 def bad? == "bad" end |
#good? ⇒ Boolean
Check if rating is positive
67 68 69 |
# File 'lib/aidp/evaluations/evaluation_record.rb', line 67 def good? == "good" end |
#neutral? ⇒ Boolean
Check if rating is neutral
77 78 79 |
# File 'lib/aidp/evaluations/evaluation_record.rb', line 77 def neutral? == "neutral" end |
#to_h ⇒ Object
Convert to hash for storage
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/aidp/evaluations/evaluation_record.rb', line 40 def to_h { id: @id, rating: , comment: @comment, target_type: @target_type, target_id: @target_id, context: @context, created_at: @created_at } end |