{"record":{"id":"056240d51e28e898","repo":"astrid-runtime/astrid","slug":"failed-to-add-capsule-view-e","errorCode":null,"errorMessage":"Failed to add capsule view: {e}","messagePattern":"Failed to add capsule view: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-kernel/src/lib.rs","lineNumber":1753,"sourceCode":"        if system_runtime && !manifest.mcp_servers.is_empty() {\n            anyhow::bail!(\n                \"system-resident capsule '{id}' cannot host principal-bearing stdio MCP servers\"\n            );\n        }\n        self.verify_workspace_capsule_tree(&runtime_dir)?;\n\n        // Mutable runtimes are authority-scoped. A principal always receives a\n        // fresh runtime for its immutable UID; only an explicitly classified\n        // SystemResident service may attach another view to one runtime.\n        {\n            let mut registry = self.capsules.write().await;\n            if registry.get_for(principal, &id).is_some() {\n                return Ok(());\n            }\n            if system_runtime && registry.contains_system_runtime(&id, &wasm_hash) {\n                registry\n                    .register_existing(&id, &wasm_hash, principal)\n                    .map_err(|e| anyhow::anyhow!(\"Failed to add capsule view: {e}\"))?;\n                if let Some(capsule) = registry.get_for(principal, &id) {\n                    capsule.resume_for(principal);\n                }\n                return Ok(());\n            }\n        }\n        if system_runtime && principal != &PrincipalId::default() {\n            anyhow::bail!(\n                \"system-resident capsule '{id}' must be created by the operator/default view before dependents attach\"\n            );\n        }\n        // System residency is an operator/admin classification, not a host\n        // path ancestry claim. The source directory is a disposable\n        // materialization of the durable package registry; `system_capsules`\n        // is the authenticated admission set and the installed authority\n        // receipt was verified above.\n\n        let principal_uid = self.runtime_principal_uid(system_runtime, principal, &id)?;","sourceCodeStart":1735,"sourceCodeEnd":1771,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-kernel/src/lib.rs#L1735-L1771","documentation":"Thrown when registering an existing system-runtime capsule view fails: `registry.register_existing(&id, &wasm_hash, principal)` returned an error while trying to attach a known system runtime capsule (matched by id and wasm hash) to a principal. The registry's error is wrapped as 'Failed to add capsule view'.","triggerScenarios":"Calling the capsule-ensure path for a principal when the capsule is already known system runtime, but register_existing rejects the registration — e.g. hash mismatch with the registered system runtime, conflicting existing registration, or registry backend error.","commonSituations":"Kernel/runtime upgrade changed the wasm hash so it no longer matches the stored system runtime; corrupted registry state; duplicate id with a different hash.","solutions":["Verify the wasm_hash matches the registered system runtime for that capsule id.","Rebuild/re-sync the registry state if it is inconsistent with installed runtimes.","Inspect the wrapped `{e}` source from register_existing for the concrete rejection reason.","Ensure the capsule id is not colliding with another capsule carrying a different hash."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// confirm hash matches the registered system runtime before register_existing\nlet known = registry.contains_system_runtime(&id, &wasm_hash);\nanyhow::ensure!(known, \"wasm hash does not match registered system runtime for {id}\");","typeGuard":null,"tryCatchPattern":"match ensure_capsule_view(&mut registry, principal, &id, &wasm_hash, system_runtime) {\n    Err(e) if e.to_string().contains(\"Failed to add capsule view\") => {\n        // inspect inner register_existing error; re-sync registry or rebuild runtime\n    }\n    other => other,\n}","preventionTips":["Keep wasm hashes in sync across kernel/runtime upgrades.","Avoid duplicate capsule ids with differing hashes.","Persist registry state atomically to prevent corruption."],"tags":["registry","rust","kernel","wasm"],"backgroundTag":"invalid-state-transition","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}