{"record":{"id":"6ff0fa7f14990d08","repo":"astrid-runtime/astrid","slug":"replacement-manifest-id-does-not-match-runnin","errorCode":null,"errorMessage":"replacement manifest id '{}' does not match running capsule '{id}'","messagePattern":"replacement manifest id '(.+?)' does not match running capsule '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-kernel/src/lib.rs","lineNumber":2006,"sourceCode":"        capsule_adversarial_tests::record_workspace_source(&capsule_name, &ctx.workspace_source);\n        capsule.load(&ctx).await?;\n        Ok(capsule)\n    }\n\n    #[cfg(not(all(target_arch = \"wasm32\", target_os = \"unknown\")))]\n    async fn prepare_runtime_replacement(\n        &self,\n        id: &astrid_capsule_types::CapsuleId,\n        source_dir: &Path,\n        principal: &PrincipalId,\n        expected_scope: astrid_capsule::registry::RuntimeScope,\n    ) -> Result<PreparedRuntimeReplacement, anyhow::Error> {\n        self.verify_workspace_capsule_tree(source_dir)?;\n        let manifest_path = source_dir.join(\"Capsule.toml\");\n        let manifest = astrid_capsule::discovery::load_manifest(&manifest_path)\n            .map_err(|error| anyhow::anyhow!(error))?;\n        if manifest.package.name != id.as_str() {\n            anyhow::bail!(\n                \"replacement manifest id '{}' does not match running capsule '{id}'\",\n                manifest.package.name\n            );\n        }\n        let bound = self.capture_bound_materialization(\n            source_dir,\n            principal,\n            &manifest,\n            \"replacement source\",\n        )?;\n        let runtime_dir = bound.as_ref().map_or_else(\n            || source_dir.to_path_buf(),\n            |bound| bound.runtime_dir.clone(),\n        );\n        let manifest = bound\n            .as_ref()\n            .map_or_else(|| manifest, |bound| bound.manifest.clone());\n        let manifest_path = runtime_dir.join(\"Capsule.toml\");","sourceCodeStart":1988,"sourceCodeEnd":2024,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-kernel/src/lib.rs#L1988-L2024","documentation":"Before performing a live replacement, the kernel loads the Capsule.toml from the prepared source directory and checks that its `package.name` equals the id of the running capsule being replaced. A mismatch means the source materialization belongs to a different capsule and replacing would silently swap in unrelated code.","triggerScenarios":"Calling the replace/reload-preparation API for capsule `{id}` with a `source_dir` whose Capsule.toml declares a different `package.name` (e.g., the directory was repointed at another capsule's checkout).","commonSituations":"Pointing the replacement path at the wrong workspace member; renaming a capsule in Capsule.toml while the kernel still references the old id; copying the wrong runtime directory over the source of truth.","solutions":["Make the Capsule.toml `package.name` match the id passed to the replacement call.","Pass the correct source_dir belonging to the running capsule.","If the capsule was renamed, unload the old capsule and load the new one instead of a live replacement."],"exampleFix":"# before (Capsule.toml)\n[package]\nname = \"my-capsule-v2\"\n# after\n[package]\nname = \"my-capsule\"  # must match the running capsule id","handlingStrategy":"validation","validationCode":"let manifest = astrid_capsule::discovery::load_manifest(&source_dir.join(\"Capsule.toml\"))?;\nassert_eq!(manifest.package.name, id.as_str(), \"replacement source belongs to a different capsule\");","typeGuard":null,"tryCatchPattern":"if let Err(e) = kernel.prepare_replacement(id, &source_dir).await {\n    if e.to_string().contains(\"does not match running capsule\") {\n        return Err(anyhow!(\"check source_dir: {} points at a different capsule\", source_dir.display()));\n    }\n    return Err(e);\n}","preventionTips":["Derive source_dir from the capsule id instead of hardcoding paths.","Keep capsule renames paired with unload/load, not live replacement.","Verify Capsule.toml package.name in CI per workspace member."],"tags":["capsule-manifest","id-mismatch","live-replacement"],"backgroundTag":"invalid-argument-value","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"}