Struct AppState
pub struct AppState {Show 36 fields
pub config: Arc<RwLock<Config>>,
pub config_write_lock: Arc<Mutex<()>>,
pub model_provider: Arc<dyn ModelProvider>,
pub model: String,
pub temperature: Option<f64>,
pub mem: Arc<dyn Memory>,
pub memory_strategy: Arc<dyn MemoryStrategy>,
pub auto_save: bool,
pub pairing: Arc<PairingGuard>,
pub trust_forwarded_headers: bool,
pub rate_limiter: Arc<GatewayRateLimiter>,
pub auth_limiter: Arc<AuthRateLimiter>,
pub idempotency_store: Arc<IdempotencyStore>,
pub gmail_push: Option<Arc<GmailPushChannel>>,
pub observer: Arc<dyn Observer>,
pub tools_registry: Arc<Vec<ToolSpec>>,
pub tools_registry_by_agent: Arc<HashMap<String, Arc<Vec<ToolSpec>>>>,
pub cost_tracker: Option<Arc<CostTracker>>,
pub event_tx: Sender<Value>,
pub event_buffer: Arc<EventBuffer>,
pub shutdown_tx: Sender<bool>,
pub reload_tx: Option<Sender<bool>>,
pub node_registry: Arc<NodeRegistry>,
pub mdns_peer_registry: MdnsPeerRegistry,
pub path_prefix: String,
pub web_dist_dir: Option<PathBuf>,
pub session_backend: Option<Arc<dyn SessionBackend>>,
pub session_queue: Arc<SessionActorQueue>,
pub device_registry: Option<Arc<DeviceRegistry>>,
pub pending_pairings: Option<Arc<PairingStore>>,
pub canvas_store: CanvasStore,
pub cancel_tokens: Arc<Mutex<HashMap<String, CancellationToken>>>,
pub pending_reload: Arc<AtomicBool>,
pub tui_registry: Option<Arc<TuiRegistry>>,
pub sop_engine: Option<Arc<Mutex<SopEngine>>>,
pub sop_audit: Option<Arc<SopAuditLogger>>,
}Expand description
Shared state for all axum handlers
Fields§
§config: Arc<RwLock<Config>>§config_write_lock: Arc<Mutex<()>>Serializes the read-mutate-save-swap critical section of every HTTP
handler that mutates config (per-property PUT/DELETE/PATCH, map-key
create/delete/rename, channel bind, config migrate, section select,
quickstart apply, cron settings patch, pairing-token persistence). A
tokio mutex, not parking_lot, because the guard must survive the
.await on config-save I/O. Mirrors
RpcContext::config_write_lock in the RPC path.
Invariant: every mutation of config must happen while holding this
mutex, acquired before the first config read-for-modify and held
through the swap that installs the mutated snapshot. Never acquire it
while holding a config guard — lock order is this mutex first,
config second, always. A writer that bypasses this lock and swaps
the live config while a concurrent writer’s save is in flight loses
that writer’s change — clobbered in memory and, if its save hadn’t
landed yet, on disk too.
model_provider: Arc<dyn ModelProvider>§model: String§temperature: Option<f64>None means “let the provider decide” — required for models
(e.g. claude-opus-4-7) that reject the field. Always preserve
Option<f64> end-to-end; never substitute a hardcoded default.
mem: Arc<dyn Memory>§memory_strategy: Arc<dyn MemoryStrategy>§auto_save: bool§pairing: Arc<PairingGuard>§trust_forwarded_headers: bool§rate_limiter: Arc<GatewayRateLimiter>§auth_limiter: Arc<AuthRateLimiter>§idempotency_store: Arc<IdempotencyStore>§gmail_push: Option<Arc<GmailPushChannel>>Gmail Pub/Sub push notification channel
observer: Arc<dyn Observer>Observability backend for metrics scraping
tools_registry: Arc<Vec<ToolSpec>>Registered tool specs (for web dashboard tools page). This is the
default (no ?agent=) listing, seeded from the deterministically
smallest enabled agent alias.
tools_registry_by_agent: Arc<HashMap<String, Arc<Vec<ToolSpec>>>>Per-agent tool-spec listings keyed by agent alias, powering the
agent-aware GET /api/tools?agent=<alias> view so the WebUI Tools
page can show each agent’s scoped tool set. Falls back to
tools_registry for an unknown or omitted alias.
cost_tracker: Option<Arc<CostTracker>>Cost tracker (optional, for web dashboard cost page)
event_tx: Sender<Value>SSE broadcast channel for real-time events
event_buffer: Arc<EventBuffer>Ring buffer of recent events for history replay
shutdown_tx: Sender<bool>Shutdown signal sender for graceful shutdown
reload_tx: Option<Sender<bool>>Reload signal sender owned by the daemon. /admin/reload writes true
here; the daemon’s wait loop reacts and re-instantiates every
subsystem in place. None when running standalone (zeroclaw gateway start)
— reload then degrades to a 503 with a clear message.
node_registry: Arc<NodeRegistry>Registry of dynamically connected nodes
mdns_peer_registry: MdnsPeerRegistryLAN-local peer hints discovered by multicast. These are informational only; they never authorize or connect a peer.
path_prefix: StringPath prefix for reverse-proxy deployments (empty string = no prefix)
web_dist_dir: Option<PathBuf>Filesystem path to web/dist/ for serving the dashboard (None = API-only)
session_backend: Option<Arc<dyn SessionBackend>>Session backend for persisting gateway WS chat sessions
session_queue: Arc<SessionActorQueue>Per-session actor queue for serializing concurrent turns
device_registry: Option<Arc<DeviceRegistry>>Device registry for paired device management
pending_pairings: Option<Arc<PairingStore>>Pending pairing request store
canvas_store: CanvasStoreShared canvas store for Live Canvas (A2UI) system
cancel_tokens: Arc<Mutex<HashMap<String, CancellationToken>>>Per-session cancellation tokens for aborting in-flight agent responses.
Key is session_key (e.g. gw_<session_id>), value is the token for the
current turn. Entries are inserted before each turn and removed after
completion (normal or cancelled).
pending_reload: Arc<AtomicBool>§tui_registry: Option<Arc<TuiRegistry>>TUI session registry from the daemon (for /api/tuis endpoint).
None when the gateway runs standalone without a daemon.
sop_engine: Option<Arc<Mutex<SopEngine>>>Shared SOP engine from the daemon (for WS agent sessions).
None when the gateway runs standalone — sessions build their own.
sop_audit: Option<Arc<SopAuditLogger>>Shared SOP audit logger from the daemon (for WS agent sessions).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for AppState
impl !UnwindSafe for AppState
impl Freeze for AppState
impl Send for AppState
impl Sync for AppState
impl Unpin for AppState
impl UnsafeUnpin for AppState
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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