Class: Ask::Rails::Harness::Tool
- Inherits:
-
Tool
- Object
- Tool
- Ask::Rails::Harness::Tool
- Defined in:
- lib/ask/rails/harness/tool.rb
Direct Known Subclasses
Ask::Rails::Harness::Tools::QueryDatabase, Ask::Rails::Harness::Tools::ReadFile, Ask::Rails::Harness::Tools::ReadLog, Ask::Rails::Harness::Tools::ReadModel, Ask::Rails::Harness::Tools::ReadRoutes, Ask::Rails::Harness::Tools::RouteInspector, Ask::Rails::Harness::Tools::RunCommand, Ask::Rails::Harness::Tools::SchemaGraph, Ask::Rails::Harness::Tools::SearchCodebase
Class Method Summary collapse
- .session_id ⇒ Object
-
.session_id=(id) ⇒ Object
Allow the session to set its ID for audit log correlation.
Instance Method Summary collapse
-
#call(args = {}, abort_controller = nil) ⇒ Object
Override call to add audit logging around every tool execution.
- #rails_root ⇒ Object
Class Method Details
.session_id ⇒ Object
36 37 38 |
# File 'lib/ask/rails/harness/tool.rb', line 36 def self.session_id Thread.current[:ask_session_id] end |
.session_id=(id) ⇒ Object
Allow the session to set its ID for audit log correlation. Called by the agent loop before executing a tool.
32 33 34 |
# File 'lib/ask/rails/harness/tool.rb', line 32 def self.session_id=(id) Thread.current[:ask_session_id] = id end |
Instance Method Details
#call(args = {}, abort_controller = nil) ⇒ Object
Override call to add audit logging around every tool execution. Logs the intent (sanitized params) and outcome (status, timing), but not the returned data.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ask/rails/harness/tool.rb', line 14 def call(args = {}, abort_controller = nil) start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) result = super duration_ms = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - start_time) * 1000).round AuditLog.log( session_id: Thread.current[:ask_session_id], tool_name: name, params: args, result: result, duration_ms: duration_ms ) result end |
#rails_root ⇒ Object
7 8 9 |
# File 'lib/ask/rails/harness/tool.rb', line 7 def rails_root ::Rails.root end |