LemonCore. ExecApprovals
(lemon_core v0.1.0)
View Source
Tool execution approvals (shared).
This module is the shared implementation for tool execution gating. It is
intentionally placed in :lemon_core so other apps (coding_agent, gateway,
channels, control_plane) can request/resolve approvals without depending on
:lemon_router.
Approval Scopes
Approvals can be granted at different scopes:
:approve_once- Single request only (not persisted):approve_session- For the session (persisted per session_key):approve_agent- For the agent (persisted per agent_id):approve_global- Globally for all (persisted globally)
Storage Keys
- Global:
{tool, action_hash} - Agent:
{agent_id, tool, action_hash} - Session:
{session_key, tool, action_hash}
Summary
Types
@type approval_id() :: binary()
Functions
Request approval for a tool execution.
Blocks until approval is granted, denied, or times out.
Parameters
:run_id- The run requesting approval:session_id- Optional native CodingAgent session ID:session_key- Session key for routing:agent_id- Agent identifier (for agent-level approvals):node_id- Optional node identifier (for node-level approvals):tool- Tool name:action- Action details map:rationale- Optional rationale for the request:expires_in_ms- Timeout in milliseconds (default: no timeout)
Returns
{:ok, :approved, scope}- Approved at the given scope{:ok, :denied}- Denied{:error, :timeout}- Request timed out
@spec resolve(approval_id(), decision :: atom()) :: :ok
Resolve a pending approval request.
Parameters
approval_id- The approval request IDdecision- One of::approve_once- Approve this specific request:approve_session- Approve for the session:approve_agent- Approve for the agent:approve_global- Approve globally:deny- Deny the request