Class: Airb::Systems::Governance
- Inherits:
-
VSM::Governance
- Object
- VSM::Governance
- Airb::Systems::Governance
- Defined in:
- lib/airb/systems/governance.rb
Instance Method Summary collapse
- #enforce(message, &pass) ⇒ Object
-
#initialize(workspace_root:) ⇒ Governance
constructor
A new instance of Governance.
-
#observe(bus) ⇒ Object
Capture bus reference for emitting confirm requests, etc.
Constructor Details
#initialize(workspace_root:) ⇒ Governance
Returns a new instance of Governance.
5 6 7 8 |
# File 'lib/airb/systems/governance.rb', line 5 def initialize(workspace_root:) @workspace_root = File.(workspace_root) @pending = {} # corr_id => original :tool_call message end |
Instance Method Details
#enforce(message, &pass) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/airb/systems/governance.rb', line 13 def enforce(, &pass) case .kind when :tool_call if risky?() ensure_corr_id!() @pending[.corr_id] = @bus.emit VSM::Message.new( kind: :confirm_request, payload: confirm_text(), meta: ..merge({ corr_id: .corr_id }), path: [:airb, :governance] ) return true # swallow for now; will resume on confirm_response else check_paths!() end when :confirm_response corr = .&.fetch(:corr_id, nil) if corr && (orig = @pending.delete(corr)) if .payload[:accepted] # proceed with original tool_call return pass.call(orig) else # inform user and drop @bus.emit VSM::Message.new( kind: :assistant, payload: "Cancelled.", meta: orig., path: [:airb, :governance] ) return true end end end pass.call() end |
#observe(bus) ⇒ Object
Capture bus reference for emitting confirm requests, etc.
11 |
# File 'lib/airb/systems/governance.rb', line 11 def observe(bus) = (@bus = bus) |