Exception: Aidp::Errors::PolicyViolation
- Inherits:
-
StandardError
- Object
- StandardError
- Aidp::Errors::PolicyViolation
- Defined in:
- lib/aidp/errors.rb
Overview
Exception raised when a Rule of Two policy violation occurs Contains detailed context about the violation for logging and debugging
Instance Attribute Summary collapse
-
#current_state ⇒ Object
readonly
Returns the value of attribute current_state.
-
#flag ⇒ Object
readonly
Returns the value of attribute flag.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#suggested_mitigations ⇒ Object
readonly
Returns the value of attribute suggested_mitigations.
Instance Method Summary collapse
-
#initialize(flag:, source:, current_state:, message: nil) ⇒ PolicyViolation
constructor
A new instance of PolicyViolation.
-
#to_h ⇒ Object
Export violation details for logging.
-
#to_json(*args) ⇒ Object
JSON representation for structured logging.
Constructor Details
#initialize(flag:, source:, current_state:, message: nil) ⇒ PolicyViolation
20 21 22 23 24 25 26 27 |
# File 'lib/aidp/errors.rb', line 20 def initialize(flag:, source:, current_state:, message: nil) @flag = flag @source = source @current_state = current_state @suggested_mitigations = build_suggested_mitigations(flag, current_state) super( || ) end |
Instance Attribute Details
#current_state ⇒ Object (readonly)
Returns the value of attribute current_state.
18 19 20 |
# File 'lib/aidp/errors.rb', line 18 def current_state @current_state end |
#flag ⇒ Object (readonly)
Returns the value of attribute flag.
18 19 20 |
# File 'lib/aidp/errors.rb', line 18 def flag @flag end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
18 19 20 |
# File 'lib/aidp/errors.rb', line 18 def source @source end |
#suggested_mitigations ⇒ Object (readonly)
Returns the value of attribute suggested_mitigations.
18 19 20 |
# File 'lib/aidp/errors.rb', line 18 def suggested_mitigations @suggested_mitigations end |
Instance Method Details
#to_h ⇒ Object
Export violation details for logging
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/aidp/errors.rb', line 30 def to_h { type: "rule_of_two_violation", flag_attempted: @flag, source: @source, current_state: @current_state, suggested_mitigations: @suggested_mitigations, timestamp: Time.now.iso8601 } end |
#to_json(*args) ⇒ Object
JSON representation for structured logging
42 43 44 |
# File 'lib/aidp/errors.rb', line 42 def to_json(*args) to_h.to_json(*args) end |