Class: Insika::Policy::Builtin::ToolAllowlist
- Inherits:
-
Insika::Policy::Base
- Object
- Insika::Policy::Base
- Insika::Policy::Builtin::ToolAllowlist
- Defined in:
- lib/insika/policy/policy.rb
Overview
Absorbs ToolRegistry#resolve as a policy: optional without
opt-in -> deny; tools_deny -> deny ("deny always wins"); tools_allow
with the semantics (nil = all; [] = ∅; [names] = final set).
tools_allow_groups UNIONS in the groups' tools
(the group is GIVEN in the Entry metadata). Both allowlists nil = all.
Instance Method Summary collapse
Methods inherited from Insika::Policy::Base
Instance Method Details
#decide(request) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/insika/policy/policy.rb', line 53 def decide(request) profile = request.profile # optional lives in the Entry metadata; candidate_tools are # ToolRegistry::Entry (Registry::Entry with metadata). deny = request.candidate_tools .select { |e| e.[:optional] && !profile.tool_opted_in?(e.name) } .map { |e| e.name.to_s } deny += Array(profile.tools_deny).map(&:to_s) allow = allowed_names(profile, request.candidate_tools) Decision.allow(allow_tools: allow, deny_tools: deny.uniq) end |