Class: RailVerdict::Intelligence::AIAnalysis
- Inherits:
-
Object
- Object
- RailVerdict::Intelligence::AIAnalysis
- Defined in:
- lib/rail_verdict/intelligence/ai_analysis.rb
Constant Summary collapse
- SCHEMA_VERSION =
"1.0"- ASSESSMENTS =
%w[likely_cause needs_investigation uncertain].freeze
- CONFIDENCES =
%w[low medium high].freeze
Instance Attribute Summary collapse
-
#assessment ⇒ Object
readonly
Returns the value of attribute assessment.
-
#confidence ⇒ Object
readonly
Returns the value of attribute confidence.
-
#evidence_notes ⇒ Object
readonly
Returns the value of attribute evidence_notes.
-
#finding_id ⇒ Object
readonly
Returns the value of attribute finding_id.
-
#fingerprint ⇒ Object
readonly
Returns the value of attribute fingerprint.
-
#provenance ⇒ Object
readonly
Returns the value of attribute provenance.
-
#recommended_tests ⇒ Object
readonly
Returns the value of attribute recommended_tests.
-
#root_cause ⇒ Object
readonly
Returns the value of attribute root_cause.
-
#suggested_fix ⇒ Object
readonly
Returns the value of attribute suggested_fix.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(finding_id:, fingerprint:, assessment:, confidence:, summary:, provenance:, root_cause: nil, suggested_fix: nil, recommended_tests: [], evidence_notes: []) ⇒ AIAnalysis
constructor
A new instance of AIAnalysis.
- #to_h ⇒ Object
Constructor Details
#initialize(finding_id:, fingerprint:, assessment:, confidence:, summary:, provenance:, root_cause: nil, suggested_fix: nil, recommended_tests: [], evidence_notes: []) ⇒ AIAnalysis
Returns a new instance of AIAnalysis.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rail_verdict/intelligence/ai_analysis.rb', line 13 def initialize(finding_id:, fingerprint:, assessment:, confidence:, summary:, provenance:, root_cause: nil, suggested_fix: nil, recommended_tests: [], evidence_notes: []) @finding_id = finding_id.dup.freeze @fingerprint = fingerprint.dup.freeze @assessment = assessment.dup.freeze @confidence = confidence.dup.freeze @summary = summary.dup.freeze @root_cause = root_cause&.dup&.freeze @suggested_fix = suggested_fix&.dup&.freeze @recommended_tests = (recommended_tests || []).map { |v| v.dup.freeze }.freeze @evidence_notes = (evidence_notes || []).map { |v| v.dup.freeze }.freeze @provenance = deep_freeze(provenance.dup) validate! freeze end |
Instance Attribute Details
#assessment ⇒ Object (readonly)
Returns the value of attribute assessment.
10 11 12 |
# File 'lib/rail_verdict/intelligence/ai_analysis.rb', line 10 def assessment @assessment end |
#confidence ⇒ Object (readonly)
Returns the value of attribute confidence.
10 11 12 |
# File 'lib/rail_verdict/intelligence/ai_analysis.rb', line 10 def confidence @confidence end |
#evidence_notes ⇒ Object (readonly)
Returns the value of attribute evidence_notes.
10 11 12 |
# File 'lib/rail_verdict/intelligence/ai_analysis.rb', line 10 def evidence_notes @evidence_notes end |
#finding_id ⇒ Object (readonly)
Returns the value of attribute finding_id.
10 11 12 |
# File 'lib/rail_verdict/intelligence/ai_analysis.rb', line 10 def finding_id @finding_id end |
#fingerprint ⇒ Object (readonly)
Returns the value of attribute fingerprint.
10 11 12 |
# File 'lib/rail_verdict/intelligence/ai_analysis.rb', line 10 def fingerprint @fingerprint end |
#provenance ⇒ Object (readonly)
Returns the value of attribute provenance.
10 11 12 |
# File 'lib/rail_verdict/intelligence/ai_analysis.rb', line 10 def provenance @provenance end |
#recommended_tests ⇒ Object (readonly)
Returns the value of attribute recommended_tests.
10 11 12 |
# File 'lib/rail_verdict/intelligence/ai_analysis.rb', line 10 def recommended_tests @recommended_tests end |
#root_cause ⇒ Object (readonly)
Returns the value of attribute root_cause.
10 11 12 |
# File 'lib/rail_verdict/intelligence/ai_analysis.rb', line 10 def root_cause @root_cause end |
#suggested_fix ⇒ Object (readonly)
Returns the value of attribute suggested_fix.
10 11 12 |
# File 'lib/rail_verdict/intelligence/ai_analysis.rb', line 10 def suggested_fix @suggested_fix end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
10 11 12 |
# File 'lib/rail_verdict/intelligence/ai_analysis.rb', line 10 def summary @summary end |
Class Method Details
.from_hash(hash) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rail_verdict/intelligence/ai_analysis.rb', line 46 def self.from_hash(hash) errors = SchemaValidator.validate_ai_analysis(hash) raise ArgumentError, errors.join("; ") unless errors.empty? new( finding_id: hash.fetch("finding_id"), fingerprint: hash.fetch("fingerprint"), assessment: hash.fetch("assessment"), confidence: hash.fetch("confidence"), summary: hash.fetch("summary"), root_cause: hash["root_cause"], suggested_fix: hash["suggested_fix"], recommended_tests: hash["recommended_tests"] || [], evidence_notes: hash["evidence_notes"] || [], provenance: hash.fetch("provenance") ) end |
Instance Method Details
#to_h ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rail_verdict/intelligence/ai_analysis.rb', line 29 def to_h h = { "schema_version" => SCHEMA_VERSION, "finding_id" => finding_id, "fingerprint" => fingerprint, "assessment" => assessment, "confidence" => confidence, "summary" => summary, "provenance" => provenance } h["root_cause"] = root_cause if root_cause h["suggested_fix"] = suggested_fix if suggested_fix h["recommended_tests"] = recommended_tests unless recommended_tests.empty? h["evidence_notes"] = evidence_notes unless evidence_notes.empty? h end |