Module: Legion::Isolation
- Defined in:
- lib/legion/isolation.rb
Defined Under Namespace
Classes: Context
Class Method Summary collapse
Class Method Details
.current ⇒ Object
27 28 29 |
# File 'lib/legion/isolation.rb', line 27 def current Thread.current[:legion_isolation_context] end |
.enforce_tool_access!(tool_name) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/legion/isolation.rb', line 39 def enforce_tool_access!(tool_name) ctx = current return true unless ctx raise SecurityError, "Agent #{ctx.agent_id} not authorized for tool: #{tool_name}" unless ctx.tool_allowed?(tool_name) true end |
.with_context(context) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/legion/isolation.rb', line 31 def with_context(context) previous = Thread.current[:legion_isolation_context] Thread.current[:legion_isolation_context] = context yield ensure Thread.current[:legion_isolation_context] = previous end |