Cedar-Based Policy Engine
Thepalyra-policy crate implements the core authorization logic using the Amazon Cedar policy engine crates/palyra-policy/src/lib.rs#1-6. It evaluates a PolicyRequest against a set of predefined and user-configured policies to return a PolicyDecision crates/palyra-policy/src/lib.rs#10-15.
Policy Evaluation Data Flow
When a component (like the message router or tool executor) needs to authorize an action, it constructs aPolicyRequest and a PolicyRequestContext.
| Entity | Role | Source |
|---|---|---|
PolicyRequest | Defines the principal, action, and resource (e.g., tool.execute). | crates/palyra-policy/src/lib.rs#11-15 |
PolicyRequestContext | Provides attributes like device_id, run_id, and capabilities. | crates/palyra-policy/src/lib.rs#17-26 |
PolicyEvaluationConfig | Contains allowlists for tools/skills and sensitivity flags. | crates/palyra-policy/src/lib.rs#28-38 |
Core Security Rules
The engine uses several built-in Cedar policies to establish a “deny-by-default” baseline:deny_sensitive_without_approval: Forbids any action marked as sensitive (e.g.,cron.delete,memory.purge) unlessallow_sensitive_toolsis explicitly set in the context crates/palyra-policy/src/lib.rs#100-105.allow_allowlisted_tool_execute: Permitstool.executeonly if the tool is in the allowlist and the principal/channel are authorized crates/palyra-policy/src/lib.rs#120-127.allow_read_only_actions: Provides a broad permit for non-mutating status and list actions crates/palyra-policy/src/lib.rs#107-118.
Tool Governance and Security
Tool execution is governed by theToolCallConfig, which defines the sandbox tiers and resource limits for both WASM plugins and native process execution crates/palyra-daemon/src/tool_protocol.rs#19-26.
Tool Capability Model
Tools are assignedToolCapability flags which the policy engine uses to determine sensitivity:
ProcessExec: Native process spawning.Network: Egress to external hosts.SecretsRead: Access to thepalyra-vault.FilesystemWrite: Modifying files in the workspace.
Policy to Code Mapping: Tool Execution
The following diagram illustrates how a tool execution request moves from a high-levelToolProposal to the low-level Cedar evaluation and sandbox execution.
Tool Security Pipeline
Sources: crates/palyra-daemon/src/application/run_stream/tool_flow.rs#121-174, crates/palyra-daemon/src/sandbox_runner.rs#147-151
Approval System and Lifecycle
The approval system provides human-in-the-loop (HITL) verification for high-risk actions. AnApprovalRecord is created when the policy engine or usage governance detects a need for manual intervention crates/palyra-daemon/src/usage_governance.rs#8-13.
ApprovalRiskLevel
Approvals are categorized by risk to inform UI rendering:Low: Standard budget overrides.Medium: Read-only access to sensitive data.High: Destructive actions or unverified skill execution.
Decision Scopes
Users can grant approvals with different scopes crates/palyra-daemon/src/usage_governance.rs#9-10:Once: Valid only for the specificrun_id.Session: Valid for the duration of the current session.Temporary: Valid for a specificttl_ms.Always: Persistent allowlist entry.
Usage Governance and Budgets
Theusage_governance.rs module manages cost and token consumption limits. It implements “Smart Routing” to select models based on complexity and budget crates/palyra-daemon/src/usage_governance.rs#112-130.
Budget Policies
Budgets are tracked viaUsageBudgetPolicyRecord, which monitors metrics like total_tokens or estimated_cost_usd over intervals (e.g., daily, monthly) crates/palyra-daemon/src/usage_governance.rs#92-109.
| Action | Mode | Description |
|---|---|---|
Suggest | Passive | Provides cost estimates without blocking. |
DryRun | Log-only | Evaluates policies but does not enforce limits. |
Enforced | Active | Blocks execution if hard_limit_value is exceeded. |
Skill Quarantine Mechanism
Skills (WASM plugins) undergo a mandatory audit. If a skill is not explicitly allowlisted in the configuration or has failed an integrity check, it is placed in a Quarantine state.- Audit Trail: Every skill execution proposal is recorded in the
journal_eventslog with askill_gate_decisioncrates/palyra-daemon/src/application/run_stream/tool_flow.rs#121-134. - Enforcement: The policy engine rule
allow_allowlisted_skill_executeprevents execution unless the skill’s ULID is present in theallowlisted_skillsvector of thePolicyEvaluationConfigcrates/palyra-policy/src/lib.rs#129-134.
CLI Governance Interface
Thepalyra CLI provides administrative commands to manage policies and approvals.
palyra approvals decide <ID> --decision allow --scope session: Resolves a pending HITL request crates/palyra-cli/src/commands/approvals.rs#136-143.palyra models explain: Provides a diagnostic trace of why a specific model or provider was selected or denied by the governance engine crates/palyra-cli/src/commands/models.rs#151-162.