Raxol.Agent.Sandbox.SendAgent (Raxol Agent v2.6.0)

Copy Markdown View Source

Inter-agent messaging isolation dimension for Raxol.Agent.Sandbox.

Gates Raxol.Agent.Directive.SendAgent directives by matching the target agent's id.

Constructors

Sandbox.SendAgent.none()
  # abstain; any target allowed

Sandbox.SendAgent.deny_all()
  # block every inter-agent message

Sandbox.SendAgent.allow_only([:worker_a, :worker_b])
  # allow only those target ids

Sandbox.SendAgent.allow_only(fn id -> is_atom(id) end)
  # arbitrary predicate

Sandbox.SendAgent.deny([:dangerous_agent])
  # block those target ids; allow others

Target ids are arbitrary terms (atoms in practice, but the framework does not constrain). List matching uses in/2; predicate matching uses fun.(id) and coerces with !!.

Summary

Functions

Construct an allow-only sandbox. Accepts a list of target ids or a 1-arity predicate.

Whether the target id is permitted by this sandbox.

Construct a deny sandbox. Accepts a list of target ids or a 1-arity predicate.

Construct a deny-all send-agent sandbox.

Construct a no-op send-agent sandbox (abstain).

Types

mode()

@type mode() ::
  :none
  | :deny_all
  | {:allow_only, [term()] | (term() -> boolean())}
  | {:deny, [term()] | (term() -> boolean())}

t()

@type t() :: %Raxol.Agent.Sandbox.SendAgent{mode: mode()}

Functions

allow_only(list_or_fun)

@spec allow_only([term()] | (term() -> boolean())) :: t()

Construct an allow-only sandbox. Accepts a list of target ids or a 1-arity predicate.

allowed?(send_agent, target_id)

@spec allowed?(t(), term()) :: boolean()

Whether the target id is permitted by this sandbox.

deny(list_or_fun)

@spec deny([term()] | (term() -> boolean())) :: t()

Construct a deny sandbox. Accepts a list of target ids or a 1-arity predicate.

deny_all()

@spec deny_all() :: t()

Construct a deny-all send-agent sandbox.

none()

@spec none() :: t()

Construct a no-op send-agent sandbox (abstain).