Skip to main content

Module gate

Module gate 

Source
Expand description

The runtime permission gate: evaluate, ask, await, time out (#7948).

Why: config says what an operator wrote and matcher says which rule applies; this module turns a tool call into “dispatch it” or “refuse it”, including the suspend-and-await path an ask rule needs, behind one call at the agent loop’s dispatch site. What: PermissionMode (the headless escape hatch), Decision (the pure evaluation), Outcome/DenySource (the final answer), PermissionEvents (the emit seam SessionRegistry implements), PermissionContext (the session-scoped half), and PermissionGate (one agent’s gate).

An agent with no permissions: block short-circuits to Allow after the legacy allowlist check, and HARNESS_REGISTERED_TOOLS skips that check entirely, so stock bundled agents are unaffected. Test: permissions::tests::gate_tests — the whole module.

Structs§

PermissionContext
The session-scoped, agent-independent half of a gate’s configuration.
PermissionGate
One agent’s permission gate — the object the agent loop holds.

Enums§

Decision
The pure evaluation of a tool call against an agent’s configuration.
DenySource
Why a call was refused, and what Event::PermissionResolved.source says. Test: headless_ask_is_denied, timed_out_ask_is_denied, client_deny_is_denied.
Outcome
The gate’s final answer for one tool call. Test: deny_message_names_the_rule.
PermissionMode
What a run does with an ask it cannot put to a client.

Constants§

ALLOW_ASKS_SOURCE
Event::PermissionResolved.source for an ask that PermissionMode::AllowAsks approved without a client (#7948).
DEFAULT_ASK_TIMEOUT_SECS
How long an unanswered ask waits before resolving to deny.
HARNESS_REGISTERED_TOOLS
The tools the HARNESS registers on an agent’s behalf, exempt from the legacy tcode_tools allowlist (#7948).
PERMISSION_MODE_ENV
Environment fallback for PermissionMode when no CLI flag is given.
REMEMBERED_SOURCE
Event::PermissionResolved.source for an ask a grant this session already remembers satisfied, with no client round trip (#7948).

Traits§

PermissionEvents
The emit seam for the two permission events.