{"record":{"id":"792490c86884d407","repo":"astrid-runtime/astrid","slug":"capsule-metadata-authority-does-not-match-source-m","errorCode":null,"errorMessage":"capsule metadata/authority does not match source manifest","messagePattern":"capsule metadata/authority does not match source manifest","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-capsule-install/src/storage.rs","lineNumber":427,"sourceCode":"/// conflict instead of silently overwriting a concurrent update.\npub fn publish_directory_package(\n    store: &Arc<RuntimePrincipalStore>,\n    principal: &PrincipalId,\n    source_dir: &Path,\n    target_dir: &Path,\n    meta: &CapsuleMeta,\n    authority: &InstalledAuthority,\n) -> anyhow::Result<()> {\n    let uid = store\n        .principal_directory()\n        .uid_for(principal)\n        .with_context(|| format!(\"resolve durable uid for principal {principal}\"))?;\n    let (manifest_id, manifest_version) = manifest_identity(source_dir)?;\n    if authority.capsule_id != manifest_id\n        || authority.version != manifest_version\n        || meta.version != authority.version\n    {\n        bail!(\"capsule metadata/authority does not match source manifest\");\n    }\n    let archive = canonical_capsule_archive(source_dir)?;\n    let verification = artifact::verify_archive_bytes(&archive)\n        .context(\"verify canonical durable capsule archive\")?;\n    let mut durable_authority = authority.clone();\n    // Directory approval binds the complete checked source tree, while the\n    // durable package intentionally omits build/VCS/cache material. Rebind the\n    // receipt to the deterministic package produced by that trusted transform;\n    // the manifest/capability/WASM pins remain unchanged and are verified\n    // again below before publication succeeds.\n    verification\n        .content_digest()\n        .clone_into(&mut durable_authority.content_digest);\n    let metadata = fs::read(target_dir.join(\"meta.json\")).with_context(|| {\n        format!(\n            \"read generated capsule metadata from {}\",\n            target_dir.display()\n        )","sourceCodeStart":409,"sourceCodeEnd":445,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-capsule-install/src/storage.rs#L409-L445","documentation":"publish_directory_package refuses to publish a capsule directory when its identity disagrees with the approved authority. The library computes the manifest id/version from the source directory and requires that authority.capsule_id, authority.version, and meta.version all agree before creating the durable archive. This is an integrity guard ensuring you publish exactly the capsule that was approved.","triggerScenarios":"Calling publish_directory_package(source_dir, ...) where (a) authority.capsule_id != manifest_identity(source_dir).id, (b) authority.version != manifest version, or (c) meta.version != authority.version — i.e. the directory was edited, re-versioned, or the wrong authority/meta was passed after approval.","commonSituations":"Editing capsule metadata or source after obtaining directory approval; bumping the version in one place (Cargo/meta/manifest) but not the others; passing an authority fetched for a different capsule directory; stale cached meta file next to a regenerated manifest.","solutions":["Regenerate the directory approval/authority against the current source tree so capsule_id and version match manifest_identity(source_dir).","Align capsule meta.version, the manifest version, and authority.version to the same value before publishing.","Verify you are passing the authority produced for this exact source_dir, not another capsule's.","If the source changed intentionally, re-run the full publish/approval workflow from scratch instead of reusing the old authority."],"exampleFix":"// before\nlet authority = load_stale_authority();\npublish_directory_package(&source_dir, &authority, &meta)?;\n// after\nlet (manifest_id, manifest_version) = manifest_identity(&source_dir)?;\nassert_eq!(authority.capsule_id, manifest_id);\nassert_eq!(authority.version, manifest_version);\nassert_eq!(meta.version, authority.version);\npublish_directory_package(&source_dir, &authority, &meta)?;","handlingStrategy":"validation","validationCode":"let (id, ver) = manifest_identity(&source_dir)?;\nif authority.capsule_id != id || authority.version != ver || meta.version != authority.version {\n    return Err(anyhow!(\"publish aborted: authority/meta do not match source manifest\"));\n}\npublish_directory_package(&source_dir, &authority, &meta)?;","typeGuard":null,"tryCatchPattern":"match publish_directory_package(&src, &authority, &meta) {\n    Ok(()) => info!(\"published\"),\n    Err(e) if e.to_string().contains(\"does not match source manifest\") => {\n        warn!(\"source changed since approval; re-approving\");\n        reapprove_and_publish(&src)?;\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always derive the authority from the same source_dir you publish, in the same run.","Keep version in a single source of truth mirrored into meta and manifest by one build step.","Never reuse a directory approval after editing the source tree; re-run the approval workflow."],"tags":["capsule","integrity","version-mismatch","publish"],"backgroundTag":"schema-validation-failed","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}