Wardrik.Statement (wardrik_protocol v0.1.0-rc.1)

Copy Markdown

Allows actions on the resources its patterns match, like an IAM statement.

Wardrik.Statement.new(roles: [:reader, :messenger], resources: ["acme/agent/*"])
Wardrik.Statement.new(actions: ["agent.*"], resources: ["acme/@jon/*"])

In a pattern, * matches any run of characters, including /. ? matches one character.

Roles

A role is a named set of actions:

RoleActions
:readeragent.read, agent.events, connection.read, mcp_server.read, ceiling.read
:messengeragent.ask, agent.cancel, agent.clear
:approveragent.decide
:defineragent.define, agent.spawn, agent.stop, agent.forget, connection.connect, mcp_server.add
:workeragent.serve, offering tools to the agents it covers
:ownerevery action

Summary

Functions

Builds a statement from the protocol's JSON.

Builds a statement.

Returns {:ok, role} for a role's name, as :reader for "reader", or :error.

Returns the statement as the protocol's JSON.

Types

t()

@type t() :: %Wardrik.Statement{actions: [String.t()], resources: [String.t()]}

Functions

from_json(map)

@spec from_json(map()) :: t()

Builds a statement from the protocol's JSON.

new(opts)

@spec new(keyword()) :: t()

Builds a statement.

Wardrik.Statement.new(roles: [:reader], actions: ["agent.ask"], resources: ["acme/agent/*"])

Options

  • :resources - patterns of the resources it covers.
  • :actions - actions it allows. [] unless set.
  • :roles - roles whose actions it allows too. [] unless set.

Raises ArgumentError for an unknown option, and KeyError for an unknown role.

role(name)

@spec role(String.t()) :: {:ok, atom()} | :error

Returns {:ok, role} for a role's name, as :reader for "reader", or :error.

to_json(statement)

@spec to_json(t()) :: map()

Returns the statement as the protocol's JSON.