Struct RpcContext
pub struct RpcContext {Show 15 fields
pub config: Arc<RwLock<Config>>,
pub config_write_lock: Arc<Mutex<()>>,
pub sessions: Arc<SessionStore>,
pub session_backend: Option<Arc<dyn SessionBackend>>,
pub memory: Option<Arc<dyn Memory>>,
pub cost_tracker: Option<Arc<CostTracker>>,
pub event_tx: Option<Sender<Value>>,
pub reload_tx: Option<Sender<bool>>,
pub gateway_shutdown_tx: Option<Sender<bool>>,
pub approval_pending: Arc<ApprovalPendingMap>,
pub tui_registry: Arc<TuiRegistry>,
pub acp_session_store: Option<Arc<AcpSessionStore>>,
pub sop_engine: Option<Arc<Mutex<SopEngine>>>,
pub sop_audit: Option<Arc<SopAuditLogger>>,
pub hooks: Option<Arc<HookRunner>>,
}Expand description
Daemon-wide state shared across all RPC connections.
Fields§
§config: Arc<RwLock<Config>>Live config behind a read-write lock so config/set can mutate
without a full daemon reload. Mirrors the gateway’s
Arc<RwLock<Config>> pattern.
config_write_lock: Arc<Mutex<()>>Serializes the read-mutate-flush critical section of every RPC
handler that mutates config (config/set, config/delete, map-key
create/delete/rename, alias rename, quickstart/apply). A tokio
mutex, not parking_lot, because the guard must survive the
.await on config-save I/O.
Invariant: every mutation of config must happen while holding
this mutex, acquired before the first config read-for-modify or
write and held through the flush that persists it. Never acquire
it while holding a config guard — lock order is this mutex
first, config second, always. A writer that bypasses this lock
and re-dirties a just-saved path while a flush is mid-save loses
disk persistence for that write (memory keeps it, but the dirty
flag is cleared by the concurrent flush).
sessions: Arc<SessionStore>In-memory session store for active RPC sessions.
session_backend: Option<Arc<dyn SessionBackend>>Persistent session backend (SQLite / JSONL) for history and
session metadata. None when persistence is disabled.
memory: Option<Arc<dyn Memory>>Memory subsystem (dyn Memory from zeroclaw-api).
cost_tracker: Option<Arc<CostTracker>>Cost tracking. None when cost tracking is disabled.
event_tx: Option<Sender<Value>>Daemon-wide event broadcast. RPC handlers subscribe to forward
events as JSON-RPC notifications (logs/subscribe).
reload_tx: Option<Sender<bool>>Write true to trigger a daemon-level config reload. Mirrors
the gateway’s /admin/reload mechanism.
gateway_shutdown_tx: Option<Sender<bool>>Write true to ask the current gateway listener to shut down before
daemon reload rebinds the same address.
approval_pending: Arc<ApprovalPendingMap>In-flight approval requests waiting for session/approve RPC calls.
tui_registry: Arc<TuiRegistry>Live TUI client registry. Tracks connected TUI sessions by UID. Source of truth for “which TUIs are connected right now.”
acp_session_store: Option<Arc<AcpSessionStore>>ACP session persistence. Opened (and the DB file created) at
daemon boot under <data_dir>/sessions/acp-sessions.db. None
when the store could not be opened (read-only FS, bad perms) —
callers must treat persistence as best-effort.
sop_engine: Option<Arc<Mutex<SopEngine>>>Shared SOP engine from the daemon (for RPC/TUI agent sessions).
None when standalone — sessions build their own.
sop_audit: Option<Arc<SopAuditLogger>>§hooks: Option<Arc<HookRunner>>Lifecycle hook runner. None when hooks are disabled in config.
Implementations§
Source§impl RpcContext
impl RpcContext
pub fn for_live_test(config: Config, sessions: Arc<SessionStore>) -> Arc<Self> ⓘ
Auto Trait Implementations§
impl Freeze for RpcContext
impl !RefUnwindSafe for RpcContext
impl Send for RpcContext
impl Sync for RpcContext
impl Unpin for RpcContext
impl UnsafeUnpin for RpcContext
impl !UnwindSafe for RpcContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more