class Riffer::Guardrails::Tripwire
Captures information about a blocked guardrail execution.
When a guardrail blocks execution, a Tripwire is created to record the reason, which guardrail triggered it, and which phase it occurred in.
tripwire = Tripwire.new( reason: โPII detected in inputโ, guardrail: PiiRedactor, phase: :before, metadata: { detected_types: [:email, :phone] } )
Constants
- PHASES
Attributes
The guardrail class that triggered the block.
Optional metadata about the block.
The phase when the block occurred (:before or :after).
The reason for blocking.
Public Class Methods
Source
# File lib/riffer/guardrails/tripwire.rb, line 40 def initialize(reason:, guardrail:, phase:, metadata: nil) raise Riffer::ArgumentError, "Invalid phase: #{phase}" unless PHASES.include?(phase) @reason = reason @guardrail = guardrail @phase = phase @metadata = metadata end
Creates a new tripwire.
+reason+ - the reason for blocking. +guardrail+ - the guardrail class that blocked. +phase+ - :before or :after. +metadata+ - optional additional information.
Raises Riffer::ArgumentError if the phase is invalid.
: (reason: String, guardrail: singleton(Riffer::Guardrail), phase: Symbol, ?metadata: Hash[Symbol, untyped]?) -> void
Public Instance Methods
Source
# File lib/riffer/guardrails/tripwire.rb, line 52 def to_h { reason: reason, guardrail: guardrail.name, phase: phase, metadata: metadata } end
Converts the tripwire to a hash.
: () -> Hash[Symbol, untyped]