Skip to main content

Module control_dispatch

Module control_dispatch 

Source
Expand description

Inbound control_request dispatch: ControlDispatchHandle routes permission checks, MCP JSON-RPC, and hook callbacks to the appropriate handler and writes the matching control_response via a clonable SharedWriter.

Internal: built once during Client::spawn, cloned and moved into a tokio::spawn’d task per inbound control_request by the reader task in crate::client::runtime. The clonable writer + the tokio::spawn mean a slow callback cannot block the read loop, and cancellation of the actor’s select! cannot drop a control_response write mid-flight.

Used the same way during the synchronous init handshake - the init loop calls ControlDispatchHandle::dispatch directly for interleaved control_requests, since no concurrent reader exists yet.

Re-exportsΒ§

use std::collections::HashMap; πŸ”’
use std::sync::Arc; πŸ”’
use crate::Error; πŸ”’
use crate::control::AllowBehavior; πŸ”’
use crate::control::ControlRequest; πŸ”’
use crate::control::ControlRequestKind; πŸ”’
use crate::control::ControlResponse; πŸ”’
use crate::control::ControlResponseKind; πŸ”’
use crate::control::ControlResponseType; πŸ”’
use crate::hooks::callback::ErasedHookCallback; πŸ”’
use crate::hooks::HookContext; πŸ”’
use crate::hooks::HookDecision; πŸ”’
use crate::hooks::HookKind; πŸ”’
use crate::mcp::orchestration::Dispatched; πŸ”’
use crate::mcp::orchestration::McpHosts; πŸ”’
use crate::mcp::protocol::JsonRpcRequest; πŸ”’
use crate::permissions::CanUseToolCallback; πŸ”’
use crate::transport::process::SharedWriter; πŸ”’
use forge_primitives::hooks::outputs::encode_updated_input_wrapper; πŸ”’
use forge_primitives::PermissionDecision; πŸ”’
use forge_primitives::ToolPermissionContext; πŸ”’

StructsΒ§

ControlDispatchHandle πŸ”’
Clonable bundle of state + writer that dispatches a single control_request. Internal - built once during Client::spawn and cloned by the reader task per inbound request.

FunctionsΒ§

control_subtype πŸ”’
The subtype a request crossed as, for a failure record that has to say which kind of control request went unanswered.