Class: Phronomy::Tool::ScopePolicy
- Inherits:
-
Object
- Object
- Phronomy::Tool::ScopePolicy
- Defined in:
- lib/phronomy/tool/scope_policy.rb
Overview
Evaluates whether a tool with a given scope may execute.
A ScopePolicy is a callable that receives +(tool_class, scope, agent)+ and returns one of: +:allow+ — proceed immediately without an approval gate. +:reject+ — block execution; the tool returns a denial message. +:approve+ — delegate to the agent's approval handler (if registered); when no handler is registered the call is rejected.
The Default instance is used automatically when no custom policy is configured on an agent.
Constant Summary collapse
- APPROVAL_REQUIRED_SCOPES =
Scopes that must go through an approval gate before execution.
%i[write admin external_network filesystem process external_process].freeze
- ALWAYS_ALLOWED_SCOPES =
Scopes that are always permitted without approval.
%i[read_only].freeze
- DEFAULT =
Shared singleton used when no custom policy is configured.
new.freeze
Instance Method Summary collapse
-
#call(_tool_class, scope, _agent) ⇒ :allow, ...
private
Returns +:allow+ for always-allowed scopes, +:approve+ for high-risk scopes, and +:allow+ for anything else (including +nil+).
Instance Method Details
#call(_tool_class, scope, _agent) ⇒ :allow, ...
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns +:allow+ for always-allowed scopes, +:approve+ for high-risk scopes, and +:allow+ for anything else (including +nil+).
39 40 41 42 43 44 |
# File 'lib/phronomy/tool/scope_policy.rb', line 39 def call(_tool_class, scope, _agent) return :allow if scope.nil? || ALWAYS_ALLOWED_SCOPES.include?(scope) return :approve if APPROVAL_REQUIRED_SCOPES.include?(scope) :allow end |