{"record":{"id":"6c1604a282f06df1","repo":"astrid-runtime/astrid","slug":"distro-lock-capsule-expects-version-but-t","errorCode":null,"errorMessage":"Distro.lock capsule '{}' expects version {}, but the daemon registry reports {}","messagePattern":"Distro\\.lock capsule '(.+?)' expects version (.+?), but the daemon registry reports (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/init_grant.rs","lineNumber":320,"sourceCode":"        {\n            astrid_core::kernel_api::KernelResponse::CapsuleMetadata(entries) => entries,\n            astrid_core::kernel_api::KernelResponse::Error(message) => bail!(message),\n            other => bail!(\"unexpected capsule metadata response: {other:?}\"),\n        };\n        let mut installed = Vec::with_capacity(locked.len());\n        for capsule in locked {\n            let expected = CapsuleId::new(capsule.name.clone())?;\n            let entry = entries\n                .iter()\n                .find(|entry| entry.name == capsule.name)\n                .ok_or_else(|| {\n                    anyhow::anyhow!(\n                        \"Distro.lock capsule '{}' is absent from the daemon registry\",\n                        capsule.name\n                    )\n                })?;\n            if !capsule.version.is_empty() && entry.version != capsule.version {\n                bail!(\n                    \"Distro.lock capsule '{}' expects version {}, but the daemon registry reports {}\",\n                    capsule.name,\n                    capsule.version,\n                    entry.version\n                );\n            }\n            let expected_hash = capsule.hash.strip_prefix(\"blake3:\");\n            if expected_hash != entry.wasm_hash.as_deref() {\n                bail!(\n                    \"Distro.lock capsule '{}' hash disagrees with the daemon registry\",\n                    capsule.name\n                );\n            }\n            installed.push(expected.as_str().to_owned());\n        }\n        Ok::<_, anyhow::Error>(installed)\n    }\n    .await;","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/init_grant.rs#L302-L338","documentation":"During reuse of a previously generated grant set, the CLI cross-checks each capsule recorded in Distro.lock against the running daemon's registry. A capsule whose locked version differs from the registry's reported version means the daemon has a different build installed than the lockfile expects, so reusing the locked grants would be unsafe and the operation bails.","triggerScenarios":"Call validated_grant_set_for_reuse with a Distro.lock containing a non-empty capsule.version that does not exactly match entry.version returned by the daemon registry lookup.","commonSituations":"Upgrading or downgrading a capsule outside the lockfile, a daemon running older/newer installed capsules than the repo's Distro.lock, switching branches where the lockfile pins a different version, or a stale daemon registry after a partial reinstall.","solutions":["Sync the installed capsule version in the daemon with the version pinned in Distro.lock (reinstall the capsule at the locked version).","Regenerate Distro.lock so it records the version actually present in the daemon registry.","Re-run init/grant after the daemon has the correct capsules installed instead of reusing the grant set.","Check out the Distro.lock matching the deployed capsule set or revert the capsule upgrade."],"exampleFix":"// Distro.lock\ncapsules = [{ name = \"my-capsule\", version = \"1.2.0\", hash = \"blake3:...\" }]\n# after: install matching version in daemon or update lock\n# astrid install my-capsule@1.2.0  (then re-run grant)","handlingStrategy":"validation","validationCode":"let entry = registry.get(&capsule.name).ok_or_else(|| anyhow!(\"capsule absent from registry\"))?;\nif !capsule.version.is_empty() && entry.version != capsule.version {\n    return Err(anyhow!(\"version mismatch for {}\", capsule.name));\n}","typeGuard":null,"tryCatchPattern":"match resync_and_relock().await {\n    Err(e) if e.to_string().contains(\"expects version\") => reinstall_locked_version(capsule)?,\n    Err(e) => return Err(e),\n    Ok(v) => v,\n}","preventionTips":["Never hand-edit capsule versions in Distro.lock; regenerate it after upgrades.","Reinstall capsules from the lockfile after switching branches.","Keep the daemon registry and lockfile in sync as one deployment step."],"tags":["version-mismatch","lockfile","registry","cli"],"backgroundTag":"version-mismatch","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"}