pub trait PermissionEvents: Send + Sync {
// Required methods
fn permission_requested(
&self,
session_id: &str,
request_id: &str,
agent: &str,
agent_id: &str,
tool: &str,
subject: &str,
rule: &str,
);
fn permission_resolved(
&self,
session_id: &str,
request_id: &str,
agent: &str,
agent_id: &str,
decision: &str,
source: &str,
);
fn prompter_attached(&self, session_id: &str) -> bool;
}Expand description
The emit seam for the two permission events.
Why: SessionRegistry is the sole assigner of an event’s seq, so this
module publishes through a trait instead of depending on the session layer
(the same direction ToolEventSink points).
Test: ask_emits_requested_then_resolved.
Required Methods§
Sourcefn permission_requested(
&self,
session_id: &str,
request_id: &str,
agent: &str,
agent_id: &str,
tool: &str,
subject: &str,
rule: &str,
)
fn permission_requested( &self, session_id: &str, request_id: &str, agent: &str, agent_id: &str, tool: &str, subject: &str, rule: &str, )
An ask is now waiting on a client. The parameters are independent
event fields, mirroring SessionRegistry::record_tool_finished.
Sourcefn permission_resolved(
&self,
session_id: &str,
request_id: &str,
agent: &str,
agent_id: &str,
decision: &str,
source: &str,
)
fn permission_resolved( &self, session_id: &str, request_id: &str, agent: &str, agent_id: &str, decision: &str, source: &str, )
An ask reached a decision (or ran out of time).
Sourcefn prompter_attached(&self, session_id: &str) -> bool
fn prompter_attached(&self, session_id: &str) -> bool
Whether anything is consuming this session’s events, and so could see a prompt and answer it.
Why (#8100): a daemon task.run always holds broker state, so
PermissionContext::ask.is_some() says only that a rendezvous EXISTS —
never that a client is on the other end of it. A headless run therefore
sat out the full DEFAULT_ASK_TIMEOUT_SECS per ask rule and then
denied anyway. This is the question that distinguishes the two, asked of
the same object that publishes the prompt.
What: the answer is about session_id and no other — a process-wide
reading is wrong, because one watched PM session dispatching headless
task.run sub-agents would then mark every sub-agent as watched and
restore the stall for all of them. No default: an implementor must
answer deliberately, since true wrongly restores the 300 s stall and
false wrongly denies an operator who was watching. A sink that cannot
tell must answer false — an event nobody consumes is a prompt nobody
sees.
Test: ask_without_an_attached_prompter_denies_immediately,
an_ask_on_an_unwatched_session_is_headless_while_a_sibling_is_watched,
ask_emits_requested_then_resolved.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl PermissionEvents for SessionRegistry
(#7948) The registry is the permission gate’s event sink.
Why: SessionRegistry::record is the sole assigner of an event’s seq;
implementing the trait here keeps crate::permissions free of a registry
dependency.
What: a session_not_found is logged at debug and dropped. It affects
only the event, never the decision: the gate still waits for an answer or
the timeout, and a timeout denies.
Test: registry_tests::record_permission_requested_publishes_event,
registry_tests::record_permission_resolved_publishes_event.