Documentation
¶
Overview ¶
Package policy evaluates default-deny Rego policies inside the kernel process. Policy decisions are enforced outside the LLM and outside per-call application code; the input document is constructed by trusted kernel code, and every failure mode (missing tenant policy, evaluation error, no rule match) denies by default.
Index ¶
- Constants
- type Decision
- type Engine
- func (e *Engine) Evaluate(ctx context.Context, tenantID string, task TaskContext) Decision
- func (e *Engine) EvaluateModel(ctx context.Context, tenantID string, model ModelContext) Decision
- func (e *Engine) EvaluatePeer(ctx context.Context, tenantID string, peer PeerContext) Decision
- func (e *Engine) EvaluateTool(ctx context.Context, tenantID string, tool ToolContext) Decision
- type ModelContext
- type PeerContext
- type TaskContext
- type TenantPolicies
- type TenantPolicy
- type ToolContext
Constants ¶
const Revision = "2026-09-19/v1"
Revision identifies the embedded policy module set. It is recorded with every decision so outcomes remain auditable across policy updates.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decision ¶
type Decision struct {
Allow bool
// RequiresApproval is set when the policy gates the action on human
// approval; it is meaningful for tool decisions.
RequiresApproval bool
DenyReasons []string
}
Decision is the machine-readable policy outcome.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine evaluates the embedded policy against tenant data. Construction compiles the module and fails closed at startup on any policy defect.
func New ¶
func New(tenants TenantPolicies) (*Engine, error)
func (*Engine) EvaluateModel ¶
EvaluateModel decides whether a model reference may be called by the tenant.
func (*Engine) EvaluatePeer ¶
EvaluatePeer decides whether the tenant may send an IPC message to a receiving AgentVersion reference. It answers the tenant-wide question only; whether the sending AgentVersion was granted that peer is a capability decision, enforced separately and first.
func (*Engine) EvaluateTool ¶
EvaluateTool decides whether a tool invocation is allowed, denied, or gated on human approval for the tenant.
type ModelContext ¶
type ModelContext struct {
Name string `json:"name"`
}
ModelContext is the typed document the model rules evaluate. Name is the canonical provider/model reference.
type PeerContext ¶
type PeerContext struct {
To string `json:"to"`
}
PeerContext is the typed document the peer rules evaluate. To is the receiving AgentVersion reference taken from the fenced send, never from raw request JSON.
The message kind is deliberately absent rather than passed along unused: a field no rule reads would suggest kinds are policy-checked when they are not. Kinds have no vocabulary yet.
type TaskContext ¶
type TaskContext struct {
Priority int `json:"priority"`
}
TaskContext carries the bounded task attributes the v1alpha1 policy reads.
type TenantPolicies ¶
type TenantPolicies map[string]TenantPolicy
TenantPolicies maps tenant IDs to their policy data. A tenant without an entry is denied by default.
type TenantPolicy ¶
type TenantPolicy struct {
MaxPriority int `json:"max_priority"`
// AllowedTools lists the tool names this tenant may invoke. Empty means
// every tool is denied (default deny).
AllowedTools []string `json:"allowed_tools"`
// AllowedModels lists the provider/model references this tenant may call.
// Empty means every model is denied (default deny).
AllowedModels []string `json:"allowed_models"`
// ApprovalRequiredRisk is the tool risk level that requires human
// approval, for example "high".
ApprovalRequiredRisk string `json:"approval_required_risk"`
// AllowedPeers lists the AgentVersion references this tenant's agents may
// send IPC messages to. Matching is exact. Empty means every send is
// denied (default deny), so a tenant that has not opted in cannot message
// anyone even if its AgentVersions declare peer grants.
AllowedPeers []string `json:"allowed_peers"`
}
TenantPolicy is the tenant-attribute data the policy rules evaluate.
type ToolContext ¶
type ToolContext struct {
Name string `json:"name"`
Version string `json:"version"`
Action string `json:"action"`
Resource string `json:"resource"`
Risk string `json:"risk"`
}
ToolContext is the versioned typed document the tool rules evaluate. It is constructed by trusted kernel code from the registered descriptor and the fenced invocation identity — never from raw request JSON.