{"record":{"id":"1278b727c4d824da","repo":"astrid-runtime/astrid","slug":"gateway-is-not-wired-to-a-live-event-bus-admin-op","errorCode":null,"errorMessage":"gateway is not wired to a live event bus; admin operations unavailable","messagePattern":"gateway is not wired to a live event bus; admin operations unavailable","errorType":"http","errorClass":"GatewayError::Internal","httpStatus":500,"severity":"error","filePath":"crates/astrid-gateway/src/state.rs","lineNumber":419,"sourceCode":"        Ok(())\n    }\n\n    /// Build a bus-direct admin client bound to `caller`. Routes\n    /// hosted in this same process talk to the kernel over the\n    /// shared event bus rather than the Unix socket — bypasses the\n    /// `astrid-capsule-cli` proxy entirely and removes the 19 RPS\n    /// admin-throughput ceiling the socket path imposes.\n    ///\n    /// # Errors\n    /// Returns an internal error if the state was built without a\n    /// live event bus (the standalone tests-only constructor). In\n    /// production the daemon always wires it up.\n    pub fn admin_client(\n        &self,\n        caller: astrid_core::PrincipalId,\n    ) -> Result<crate::bus_admin::BusAdminClient, crate::error::GatewayError> {\n        let bus = self.event_bus.clone().ok_or_else(|| {\n            crate::error::GatewayError::Internal(anyhow::anyhow!(\n                \"gateway is not wired to a live event bus; admin operations unavailable\"\n            ))\n        })?;\n        let session_id = self.session_id.as_ref().ok_or_else(|| {\n            crate::error::GatewayError::Internal(anyhow::anyhow!(\n                \"gateway is not wired to a live kernel session; admin operations unavailable\"\n            ))\n        })?;\n        Ok(crate::bus_admin::BusAdminClient::new(\n            bus,\n            caller,\n            session_id.0,\n        ))\n    }\n\n    /// Build a bus-direct admin client for an authenticated caller, carrying\n    /// the caller's device scope through to the kernel cap-gate.\n    ///","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-gateway/src/state.rs#L401-L437","documentation":"An admin bus operation was requested but the GatewayState was constructed without an event bus. BusAdminClient needs a live bus connection to reach the daemon; without it, no admin operation can proceed, so admin_client() returns GatewayError::Internal. In production the daemon always wires the bus, so this normally indicates a standalone/test or misconfigured gateway.","triggerScenarios":"Calling admin_client() (directly or via admin_client_for / assert_live_audit_revocation) on a GatewayState built by the tests-only constructor or a bootstrap path that leaves the event_bus field None.","commonSituations":"Running the gateway in standalone/dev mode without bus wiring; a configuration path that skips event-bus initialization; unit tests exercising admin endpoints against an unwired state.","solutions":["Wire the event bus into GatewayState at construction time (use the production constructor/daemon wiring path)","Check gateway startup config so the event bus is initialized before routes are served","Guard admin routes to return 503/404 when running in standalone mode instead of exercising the bus","In tests, build the state with a live (in-memory) bus rather than the tests-only constructor"],"exampleFix":"// before\nlet state = GatewayState::new_standalone(config); // no event_bus\n// after\nlet state = GatewayState::new(config, event_bus, session_id)?; // wired","handlingStrategy":"validation","validationCode":"fn admin_ready(state: &GatewayState) -> bool {\n    state.event_bus.is_some()\n}","typeGuard":"fn wired_bus(state: &GatewayState) -> Option<Arc<EventBus>> {\n    state.event_bus.clone()\n}","tryCatchPattern":"match state.admin_client(caller) {\n    Ok(client) => use_client(client).await,\n    Err(GatewayError::Internal(e)) if e.to_string().contains(\"not wired to a live event bus\") => {\n        Err(StatusCode::SERVICE_UNAVAILABLE)\n    }\n    Err(e) => Err(e.into()),\n}","preventionTips":["Always construct GatewayState through the production wiring path that sets event_bus","Add a readiness probe that fails startup if the bus is not wired","Return 503 from admin routes when the gateway is in standalone mode"],"tags":["configuration","event-bus","admin"],"backgroundTag":"missing-configuration","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}