{"record":{"id":"393a67bef1212998","repo":"astrid-runtime/astrid","slug":"gateway-is-not-wired-to-a-live-event-bus-kernel-r","errorCode":null,"errorMessage":"gateway is not wired to a live event bus; kernel requests unavailable","messagePattern":"gateway is not wired to a live event bus; kernel requests unavailable","errorType":"http","errorClass":"GatewayError::Internal","httpStatus":500,"severity":"error","filePath":"crates/astrid-gateway/src/state.rs","lineNumber":472,"sourceCode":"            .with_device_key_id(caller.device_key_id.clone()))\n    }\n\n    /// Build a bus-direct kernel client bound to an authenticated caller.\n    ///\n    /// HTTP routes have already verified the bearer token and resolved the\n    /// caller/device scope. They should not re-enter the external socket\n    /// handshake, because the gateway intentionally does not possess arbitrary\n    /// agent private keys and would be downgraded to `anonymous`.\n    ///\n    /// # Errors\n    /// Returns an internal error if the state was built without a live event\n    /// bus (the standalone tests-only constructor).\n    pub fn kernel_client_for(\n        &self,\n        caller: &crate::auth::CallerContext,\n    ) -> Result<crate::bus_kernel::BusKernelClient, 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; kernel requests 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; kernel requests unavailable\"\n            ))\n        })?;\n        Ok(\n            crate::bus_kernel::BusKernelClient::new(bus, caller.principal.clone(), session_id.0)\n                .with_device_key_id(caller.device_key_id.clone()),\n        )\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-gateway/src/state.rs#L454-L490","documentation":"A kernel request (e.g. capsule metadata lookup) was attempted but the GatewayState has no event bus wired. kernel_client_for() needs the bus to reach the daemon kernel and returns GatewayError::Internal when the bus is absent.","triggerScenarios":"Calling kernel_client_for() (used by capsule_metadata_for) on a state built without an event bus — the standalone/tests-only constructor or a config path that skips bus initialization.","commonSituations":"Dev/standalone gateway mode without a daemon; misconfigured bootstrap that never creates the bus; tests hitting kernel-backed routes on an unwired state.","solutions":["Construct GatewayState with a live event bus via the production wiring path","Verify the gateway bootstrap actually initializes the bus before accepting requests","Return a clear 503 from kernel-backed routes when running standalone","In tests, supply an in-memory bus to the state constructor"],"exampleFix":"// before\nlet state = GatewayState::new_standalone(config); // event_bus: None\n// after\nlet state = GatewayState::new(config, Some(event_bus), session_id)?;","handlingStrategy":"validation","validationCode":"fn kernel_ready(state: &GatewayState) -> bool {\n    state.event_bus.is_some()\n}","typeGuard":"fn bus_available(state: &GatewayState) -> Option<Arc<EventBus>> {\n    state.event_bus.clone()\n}","tryCatchPattern":"match state.kernel_client_for(&caller) {\n    Ok(client) => capsule_metadata_for(client).await,\n    Err(GatewayError::Internal(e)) if e.to_string().contains(\"kernel requests unavailable\") => {\n        Err(StatusCode::SERVICE_UNAVAILABLE)\n    }\n    Err(e) => Err(e.into()),\n}","preventionTips":["Wire the event bus in every environment that serves kernel-backed routes","Gate kernel-dependent routes behind a readiness flag checked at request time","In tests, use an in-memory bus constructor instead of the standalone one"],"tags":["configuration","event-bus","kernel"],"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"}