{"record":{"id":"94e2dbc9325903ce","repo":"astrid-runtime/astrid","slug":"capsule-identity-mismatch-expected-expected-94e2db","errorCode":null,"errorMessage":"capsule identity mismatch: expected '{expected}', manifest declares '{}'","messagePattern":"capsule identity mismatch: expected '(.+?)', manifest declares '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-capsule-install/src/local.rs","lineNumber":507,"sourceCode":"    home: &AstridHome,\n    options: InstallOptions,\n    target_principal: &PrincipalId,\n    expected: &CapsuleId,\n    expected_version: Option<&str>,\n    workspace_root: Option<&Path>,\n    decision: &AuthorityDecision,\n    workspace_layout: &WorkspaceLayout,\n) -> anyhow::Result<InstallOutput> {\n    let inspection = inspect_directory_for_principal_in_workspace(\n        source_dir,\n        home,\n        target_principal,\n        options.workspace,\n        workspace_root,\n        workspace_layout,\n    )?;\n    if inspection.capsule_id != *expected {\n        bail!(\n            \"capsule identity mismatch: expected '{expected}', manifest declares '{}'\",\n            inspection.capsule_id\n        );\n    }\n    if let Some(expected_version) = expected_version\n        && inspection.version != expected_version\n    {\n        bail!(\n            \"capsule version mismatch for '{expected}': expected '{expected_version}', manifest declares '{}'\",\n            inspection.version\n        );\n    }\n    let authority = authorize_install(&inspection, decision)?;\n    install_from_local_path_internal(\n        source_dir,\n        home,\n        options,\n        target_principal,","sourceCodeStart":489,"sourceCodeEnd":525,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-capsule-install/src/local.rs#L489-L525","documentation":"This error is thrown by install_from_local_path_checked_authorized_for_principal_in_workspace when a locally inspected capsule manifest's capsule id does not match the expected identity the caller supplied (ExpectedCapsuleIdentity). The install API requires that the capsule you asked to install is exactly the capsule the manifest declares; any divergence aborts the install before any state is mutated. It is a pre-flight identity check protecting against installing the wrong capsule under an authorized request.","triggerScenarios":"Calling install_from_local_path_checked_authorized_for_principal_with_layout / ..._in_workspace with an expected capsule id that differs from the `package.name` in the source directory's Capsule.toml, e.g. pointing expected='app-core' at a directory whose manifest declares 'app-utils'.","commonSituations":"Stale cached path or wrong source_dir passed after a rename of the capsule; copy-pasting an install command for a different capsule; the manifest was edited (package.name changed) after the expected identity was computed; typos in the expected id casing.","solutions":["Open the Capsule.toml in the source directory and check package.name","Pass an expected id that exactly matches package.name, or fetch the manifest first and derive the expected identity from it","If the manifest name is wrong, correct package.name in Capsule.toml and retry","Verify you are pointing at the intended source_dir, not a sibling capsule directory"],"exampleFix":"// before\nlet out = install_from_local_path_checked_authorized_for_principal_with_layout(&src, &\"app-core\".into(), None, ...)?;\n// after\nlet manifest: Manifest = toml::from_str(&std::fs::read_to_string(src.join(\"Capsule.toml\"))?)?;\nlet expected = CapsuleId::new(manifest.package.name.clone())?;\nlet out = install_from_local_path_checked_authorized_for_principal_with_layout(&src, &expected, None, ...)?;","handlingStrategy":"validation","validationCode":"fn ensure_expected_capsule(src: &Path, expected: &CapsuleId) -> anyhow::Result<()> {\n    let manifest: Manifest = toml::from_str(&std::fs::read_to_string(src.join(\"Capsule.toml\"))?)?;\n    let id = CapsuleId::new(manifest.package.name.clone())?;\n    anyhow::ensure!(&id == expected, \"source declares {id}, expected {expected}\");\n    Ok(())\n}","typeGuard":"fn manifest_matches(manifest: &Manifest, expected: &CapsuleId) -> bool {\n    CapsuleId::new(manifest.package.name.clone()).map(|id| &id == expected).unwrap_or(false)\n}","tryCatchPattern":"match install_..._checked_authorized(...) {\n    Err(e) if e.to_string().contains(\"capsule identity mismatch\") => {\n        // re-derive expected identity from the manifest and retry once\n    }\n    other => other?,\n}","preventionTips":["Always derive the expected id by parsing Capsule.toml, never hardcode it","Verify source_dir points at the exact capsule directory before installing","Watch for renames of package.name and update callers in the same commit","Add an integration test asserting expected id == manifest name"],"tags":["capsule-install","identity-mismatch","manifest"],"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-14T05:17:10.506Z"}