Class: Woods::Console::Confirmation
- Inherits:
-
Object
- Object
- Woods::Console::Confirmation
- Defined in:
- lib/woods/console/confirmation.rb
Overview
Human-in-the-loop confirmation protocol for Tier 4 tools.
Supports three modes:
-
‘:auto_approve` — Always approve (for testing/trusted environments)
-
‘:auto_deny` — Always deny (for locked-down environments)
-
‘:callback` — Delegates to a callable that returns true/false
Tracks confirmation history for audit purposes.
Constant Summary collapse
- VALID_MODES =
%i[auto_approve auto_deny callback].freeze
Instance Attribute Summary collapse
-
#history ⇒ Array<Hash>
readonly
History of confirmation requests and outcomes.
Instance Method Summary collapse
-
#initialize(mode:, callback: nil) ⇒ Confirmation
constructor
A new instance of Confirmation.
-
#request_confirmation(tool:, description:, params:) ⇒ Object
Request confirmation for a Tier 4 operation.
Constructor Details
#initialize(mode:, callback: nil) ⇒ Confirmation
Returns a new instance of Confirmation.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/woods/console/confirmation.rb', line 38 def initialize(mode:, callback: nil) unless VALID_MODES.include?(mode) raise ArgumentError, "Invalid mode: #{mode}. Must be one of: #{VALID_MODES.join(', ')}" end raise ArgumentError, 'Callback required for callback mode' if mode == :callback && callback.nil? @mode = mode @callback = callback @history = [] end |
Instance Attribute Details
#history ⇒ Array<Hash> (readonly)
Returns History of confirmation requests and outcomes.
33 34 35 |
# File 'lib/woods/console/confirmation.rb', line 33 def history @history end |
Instance Method Details
#request_confirmation(tool:, description:, params:) ⇒ Object
Request confirmation for a Tier 4 operation.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/woods/console/confirmation.rb', line 56 def request_confirmation(tool:, description:, params:) approved = evaluate(tool: tool, description: description, params: params) @history << { tool: tool, description: description, params: params, approved: approved, timestamp: Time.now.utc.iso8601 } return if approved raise ConfirmationDeniedError, "Confirmation denied for #{tool}: #{description}" end |