interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

GitHub aien-dev/aien-sovereign-core-mv#169 (code only)

closed derived 0130a49b2b5da0b9 #169

Imported from GitHub aien-dev/aien-sovereign-core-mv#169 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 40dd3732f1e4172c25f7110e444487883b676386 · Head 835d60b3ac41fef2b92ea05ab647cc54fad205b6

Apply it

git checkout -b patch-0130a49b2b5da0b9 40dd3732f1e4172c25f7110e444487883b676386
curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/0130a49b2b5da0b9.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aien-sovereign-core-mv
169
835d60b3ac41fef2b92ea05ab647cc54fad205b6
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":169,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/169","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:11Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.github/workflows/verify-closure.yml b/.github/workflows/verify-closure.yml
new file mode 100644
index 00000000..2cb618c9
--- /dev/null
+++ b/.github/workflows/verify-closure.yml
@@ -0,0 +1,55 @@
+name: Verify Closure
+
+"on":
+  push:
+    branches: [main]
+    paths:
+      - "crates/aien-closure/**"
+      - "crates/aien-proof/**"
+      - ".github/workflows/verify-closure.yml"
+  pull_request:
+    branches: [main]
+    paths:
+      - "crates/aien-closure/**"
+      - "crates/aien-proof/**"
+      - ".github/workflows/verify-closure.yml"
+  workflow_dispatch:
+
+permissions:
+  contents: read
+
+jobs:
+  verify-closure:
+    name: verify-closure build, tests, seeded fixture run
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout Source
+        uses: actions/checkout@v4
+
+      - name: Checkout Sibling Protocols Dependency
+        uses: actions/checkout@v4
+        with:
+          repository: aien-dev/aien-protocols
+          ref: 7ac6facb630ca7e9a6ab4125b292203fe2bb6687
+          path: aien-protocols
+
+      - name: Setup Sibling Dependencies
+        run: |
+          mkdir -p ../aien-protocols
+          cp -r aien-protocols/* ../aien-protocols/
+
+      - name: Install Stable Rust Toolchain
+        uses: dtolnay/rust-toolchain@stable
+
+      - name: Build verify-closure
+        run: cargo build --locked -p aien-closure --bin verify-closure
+
+      - name: Test aien-closure
+        run: cargo test --locked -p aien-closure
+
+      # The real repo has no closure.toml manifests yet (stage 6 adds them), so
+      # this runs only against the seeded in-repo fixture and its receipt store.
+      - name: Run verify-closure on the seeded fixture
+        working-directory: crates/aien-closure/tests/fixtures/seeded
+        run: |
+          "$GITHUB_WORKSPACE/target/debug/verify-closure" --root . --store store
diff --git a/Cargo.lock b/Cargo.lock
index 1fd50812..f611b9de 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -75,6 +75,15 @@ dependencies = [
  "tokio",
 ]
 
+[[package]]
+name = "aien-closure"
+version = "0.1.0"
+dependencies = [
+ "aien-proof",
+ "blake3",
+ "serde_json",
+]
+
 [[package]]
 name = "aien-evaluation-protocol"
 version = "0.1.0"
diff --git a/Cargo.toml b/Cargo.toml
index c7b61ffd..9040371d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -36,6 +36,7 @@ members = [
     "crates/aien-campaign-verifier",
     "crates/aien-proof",
     "crates/crumbs",
+    "crates/aien-closure",
     "tools/aien-test",
 ]
 
diff --git a/crates/aien-closure/Cargo.toml b/crates/aien-closure/Cargo.toml
new file mode 100644
index 00000000..f443a886
--- /dev/null
+++ b/crates/aien-closure/Cargo.toml
@@ -0,0 +1,20 @@
+[package]
+name = "aien-closure"
+version.workspace = true
+edition.workspace = true
+license.workspace = true
+authors.workspace = true
+description = "verify-closure: CI bridge that checks every internal dependency has verified aien-proof evidence"
+
+[dependencies]
+aien-proof = { path = "../aien-proof" }
+blake3 = "1.8"
+serde_json = "1.0"
+
+[lib]
+name = "aien_closure"
+path = "src/lib.rs"
+
+[[bin]]
+name = "verify-closure"
+path = "src/main.rs"
diff --git a/crates/aien-closure/README.md b/crates/aien-closure/README.md
new file mode 100644
index 00000000..d462bd5d
--- /dev/null
+++ b/crates/aien-closure/README.md
@@ -0,0 +1,106 @@
+# aien-closure (`verify-closure`)
+
+Verified Crumb, stage 5. This is a CI bridge: it makes today's Rust and C
+code obey the rule "every internal dependency has verified evidence" before
+Omega's compiler owns dependency resolution. When Omega's `import` resolves
+dependencies through the verified library, this tool is retired or reduced to
+a cross-check.
+
+It reuses aien-proof for the receipt format. Receipt identity is
+`aien_proof::evidence::receipt_id` (BLAKE3 over the canonical encoding), and
+chains are checked with `aien_proof::chain::verify_chain`. Nothing here
+re-implements the hash.
+
+## What it checks
+
+`verify-closure --root <repo> [--store <receipt dir>] [--write-lock]`
+
+1. Rebuild the internal graph with `cargo metadata --offline --locked
+   --no-deps`. Edges are path dependencies between workspace members (normal
+   and build kinds; dev dependencies are not part of the built artifact).
+2. Read `closure.toml` from each crate directory that has one.
+3. Every edge must be declared in the manifest and pinned to the receipt id of
+   the dependency, which must itself have a manifest with that receipt.
+4. Each component receipt must exist in `<store>/receipts/<id>.json`, hash to
+   its id, and the whole receipt chain must verify as PASS.
+5. The receipt must have been taken at the source digest the manifest records,
+   and the current source must still have that digest.
+6. No cycles. No dirty or TEST_ONLY_TRUST receipts anywhere in the chain.
+7. `closure.lock` must equal the closure rebuilt from the manifests.
+
+If no manifest exists at all, the run fails (UNVERIFIED_DEPENDENCY). The store
+defaults to `$AIEN_PROOF_DIR`, else `~/.local/state/aien-proof`.
+
+## The nine codes
+
+Output is one line per finding, `FINDING <CODE> component=<name> detail=<text>`,
+then `SUMMARY status=<PASS|FAIL> findings=<n> components=<n>`. Exit code is 0
+on PASS, 1 on an internal error, 2 on a usage error, and otherwise the code of
+the first finding (sorted by the order below, then component).
+
+| Exit | Code | Raised when |
+| --- | --- | --- |
+| 10 | UNVERIFIED_DEPENDENCY | a dependency has no manifest, a manifest is malformed, a declared dep is not a real edge, the chain does not verify as PASS, the receipt tier is below the profile, or no manifest exists |
+| 11 | MISSING_RECEIPT | a receipt id (component or any chain member) is not in the store |
+| 12 | RECEIPT_HASH_MISMATCH | a receipt file does not hash to its id, or is not a valid receipt |
+| 13 | DEPENDENCY_NOT_PINNED | a dep has no receipt pin, the pin differs from the dep's receipt, the receipt does not depend on the pinned receipt, or `closure.lock` is missing or differs |
+| 14 | DEPENDENCY_CYCLE | the internal graph or the receipt graph has a cycle |
+| 15 | STALE_RECEIPT | current source digest differs from the manifest, or the receipt does not record the manifest's source digest |
+| 16 | UNDECLARED_IMPORT | the graph has an edge the manifest does not declare |
+| 17 | TAINTED_ARTIFACT | a receipt in the chain was recorded from a dirty tree or is TEST_ONLY_TRUST |
+| 18 | UNKNOWN_VERIFIER_PROFILE | the manifest names a profile this verifier does not know |
+
+Profiles: `host-v1` needs tier HOST_TEST or better, `qemu-v1` needs QEMU or
+better, `production-v1` needs PRODUCTION. Tier comparison is
+`aien_proof::chain::tier_satisfies`, so a QEMU receipt never satisfies a
+physical requirement.
+
+## How a component gets a manifest
+
+Put a `closure.toml` in the crate directory. Strict, line based, no comments,
+no blank lines, no tabs, one trailing newline:
+
+```text
+closure-manifest v1
+component aien-scheduler
+profile host-v1
+receipt <64 hex: receipt id that qualifies this component>
+source blake3:<64 hex: source digest the receipt was taken at>
+dep aien-kv-cache <64 hex: receipt id of aien-kv-cache>
+dep aien-platform <64 hex>
+```
+
+Steps:
+
+1. Qualify every dependency first (leaves up), each with its own manifest.
+2. Compute the source digest of the crate. It is BLAKE3 over all regular files
+   in the crate directory in sorted path order, excluding `target`, `.git`,
+   `closure.toml` and `closure.lock` (see `src/digest.rs` for the exact byte
+   layout). Symlinks in a crate directory are an error.
+3. Record an aien-proof receipt whose `input_artifacts` contains
+   `blake3:<source digest>`, whose `dependencies` contain the receipt ids of
+   the dependencies, and whose result is PASS from a clean tree.
+4. Write the manifest, then run `verify-closure --root . --write-lock` to
+   produce `closure.lock`, and commit both.
+
+Any source change makes the receipt stale on purpose. Re-qualify, then update
+the manifest.
+
+## C components (for Omega, not wired to CI yet)
+
+`graph::scan_c_includes(src_dir, include_root)` builds a file level graph from
+quoted `#include "..."` lines. An include resolves against the including
+file's directory, then against `include_root` (the `-I` directory, `src` for
+Omega). Unresolved quoted includes are returned, not dropped. Limitation: block
+comments and `#if 0` regions are not understood, so a commented out include
+still counts, which errs on the strict side. It is unit tested on a fixture
+directory only.
+
+## Tests
+
+`cargo test -p aien-closure` seeds a fixture workspace (`tests/fixtures/seeded`)
+into a temp directory with receipts built through aien-proof's own API, then
+checks one PASS case and at least one failing case per code, each asserting the
+exact finding and the binary's exit code. The committed seeded fixture (with
+store) is what `.github/workflows/verify-closure.yml` runs against. To rewrite
+it: `cargo test -p aien-closure -- --ignored regenerate_committed_fixture`.
diff --git a/crates/aien-closure/src/digest.rs b/crates/aien-closure/src/digest.rs
new file mode 100644
index 00000000..39bf4635
--- /dev/null
+++ b/crates/aien-closure/src/digest.rs
@@ -0,0 +1,70 @@
+//! Source digest of a component directory.
+//!
+//! BLAKE3 over every regular file under the directory, in byte-sorted
+//! relative-path order, skipping `target`, `.git`, `closure.toml` and
+//! `closure.lock` (the manifest records the digest, so it cannot be part of
+//! it). Each file contributes `u64be(len(path)) path u64be(len(bytes)) bytes`
+//! under the domain `AIEN_CLOSURE_SOURCE_V1`. Symlinks and other non-regular
+//! files are an error, never silently skipped.
+
+use std::fs;
+use std::path::{Path, PathBuf};
+
+pub const DOMAIN: &[u8] = b"AIEN_CLOSURE_SOURCE_V1";
+const SKIP_DIRS: &[&str] = &["target", ".git"];
+const SKIP_FILES: &[&str] = &["closure.toml", "closure.lock"];
+
+fn collect(base: &Path, dir: &Path, out: &mut Vec<PathBuf>) -> Result<(), String> {
+    let entries = fs::read_dir(dir).map_err(|e| format!("cannot read {}: {e}", dir.display()))?;
+    for entry in entries {
+        let entry = entry.map_err(|e| e.to_string())?;
+        let path = entry.path();
+        let name = entry.file_name().to_string_lossy().into_owned();
+        let ty = entry.file_type().map_err(|e| e.to_string())?;
+        if ty.is_dir() {
+            if SKIP_DIRS.contains(&name.as_str()) {
+                continue;
+            }
+            collect(base, &path, out)?;
+        } else if ty.is_file() {
+            if dir == base && SKIP_FILES.contains(&name.as_str()) {
+                continue;
+            }
+            out.push(path);
+        } else {
+            return Err(format!(
+                "non-regular file in component source: {}",
+                path.display()
+            ));
+        }
+    }
+    Ok(())
+}
+
+/// Returns the lowercase hex digest (64 digits).
+pub fn source_digest(dir: &Path) -> Result<String, String> {
+    let mut files = Vec::new();
+    collect(dir, dir, &mut files)?;
+    let mut keyed: Vec<(String, PathBuf)> = files
+        .into_iter()
+        .map(|p| {
+            let rel = p
+                .strip_prefix(dir)
+                .unwrap_or(&p)
+                .to_string_lossy()
+                .replace('\\', "/");
+            (rel, p)
+        })
+        .collect();
+    keyed.sort_by(|a, b| a.0.as_bytes().cmp(b.0.as_bytes()));
+    let mut h = blake3::Hasher::new();
+    h.update(DOMAIN);
+    for (rel, path) in keyed {
+        let bytes = fs::read(&path).map_err(|e| format!("cannot read {}: {e}", path.display()))?;
+        h.update(&(rel.len() as u64).to_be_bytes());
+        h.update(rel.as_bytes());
+        h.update(&(bytes.len() as u64).to_be_bytes());
+        h.update(&bytes);
+    }
+    Ok(h.finalize().to_hex().to_string())
+}
diff --git a/crates/aien-closure/src/error.rs b/crates/aien-closure/src/error.rs
new file mode 100644
index 00000000..c7e37283
--- /dev/null
+++ b/crates/aien-closure/src/error.rs
@@ -0,0 +1,97 @@
+//! The nine finding codes and their exit codes.
+
+use std::fmt;
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+pub enum Code {
+    UnverifiedDependency,
+    MissingReceipt,
+    ReceiptHashMismatch,
+    DependencyNotPinned,
+    DependencyCycle,
+    StaleReceipt,
+    UndeclaredImport,
+    TaintedArtifact,
+    UnknownVerifierProfile,
+}
+
+pub const ALL: [Code; 9] = [
+    Code::UnverifiedDependency,
+    Code::MissingReceipt,
+    Code::ReceiptHashMismatch,
+    Code::DependencyNotPinned,
+    Code::DependencyCycle,
+    Code::StaleReceipt,
+    Code::UndeclaredImport,
+    Code::TaintedArtifact,
+    Code::UnknownVerifierProfile,
+];
+
+impl Code {
+    pub fn as_str(self) -> &'static str {
+        match self {
+            Code::UnverifiedDependency => "UNVERIFIED_DEPENDENCY",
+            Code::MissingReceipt => "MISSING_RECEIPT",
+            Code::ReceiptHashMismatch => "RECEIPT_HASH_MISMATCH",
+            Code::DependencyNotPinned => "DEPENDENCY_NOT_PINNED",
+            Code::DependencyCycle => "DEPENDENCY_CYCLE",
+            Code::StaleReceipt => "STALE_RECEIPT",
+            Code::UndeclaredImport => "UNDECLARED_IMPORT",
+            Code::TaintedArtifact => "TAINTED_ARTIFACT",
+            Code::UnknownVerifierProfile => "UNKNOWN_VERIFIER_PROFILE",
+        }
+    }
+
+    /// Process exit code. 0 is PASS, 1 is an internal error, 2 is a usage
+    /// error, so findings start at 10.
+    pub fn exit_code(self) -> i32 {
+        match self {
+            Code::UnverifiedDependency => 10,
+            Code::MissingReceipt => 11,
+            Code::ReceiptHashMismatch => 12,
+            Code::DependencyNotPinned => 13,
+            Code::DependencyCycle => 14,
+            Code::StaleReceipt => 15,
+            Code::UndeclaredImport => 16,
+            Code::TaintedArtifact => 17,
+            Code::UnknownVerifierProfile => 18,
+        }
+    }
+}
+
+impl fmt::Display for Code {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        f.write_str(self.as_str())
+    }
+}
+
+/// One machine-readable finding.
+#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
+pub struct Finding {
+    pub code: Code,
+    pub component: String,
+    pub detail: String,
+}
+
+impl Finding {
+    pub fn new(code: Code, component: &str, detail: impl Into<String>) -> Self {
+        Finding {
+            code,
+            component: component.to_string(),
+            detail: detail.into(),
+        }
+    }
+
+    /// `FINDING <CODE> component=<name> detail=<one line text>`
+    pub fn line(&self) -> String {
+        let detail: String = self
+            .detail
+            .chars()
+            .map(|c| if c.is_control() { ' ' } else { c })
+            .collect();
+        format!(
+            "FINDING {} component={} detail={}",
+            self.code, self.component, detail
+        )
+    }
+}
diff --git a/crates/aien-closure/src/graph.rs b/crates/aien-closure/src/graph.rs
new file mode 100644
index 00000000..85f24154
--- /dev/null
+++ b/crates/aien-closure/src/graph.rs
@@ -0,0 +1,306 @@
+//! Dependency graph reconstruction: Rust (cargo metadata) and C (quoted
+//! `#include` scanner), plus cycle detection shared by both.
+
+use serde_json::Value;
+use std::collections::{BTreeMap, BTreeSet};
+use std::fs;
+use std::path::{Path, PathBuf};
+use std::process::Command;
+
+/// node -> set of nodes it depends on.
+pub type Graph = BTreeMap<String, BTreeSet<String>>;
+
+/// A workspace package that is a node of the internal graph.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Package {
+    pub name: String,
+    pub dir: PathBuf,
+    /// Internal path dependencies (normal and build kinds), by package name.
+    pub deps: BTreeSet<String>,
+}
+
+/// Parse `cargo metadata --no-deps` output. Only workspace members are nodes.
+/// An edge is a dependency that has a `path` and names another member. Dev
+/// dependencies are not part of the built artifact and are skipped.
+pub fn packages_from_metadata(meta: &Value) -> Result<Vec<Package>, String> {
+    let members: BTreeSet<&str> = meta["workspace_members"]
+        .as_array()
+        .ok_or("metadata has no workspace_members")?
+        .iter()
+        .filter_map(Value::as_str)
+        .collect();
+    let pkgs: Vec<&Value> = meta["packages"]
+        .as_array()
+        .ok_or("metadata has no packages")?
+        .iter()
+        .filter(|p| p["id"].as_str().is_some_and(|id| members.contains(id)))
+        .collect();
+    let names: BTreeSet<&str> = pkgs.iter().filter_map(|p| p["name"].as_str()).collect();
+    let mut out = Vec::new();
+    for p in &pkgs {
+        let name = p["name"].as_str().ok_or("package without name")?;
+        let manifest = p["manifest_path"]
+            .as_str()
+            .ok_or("package without manifest_path")?;
+        let dir = Path::new(manifest)
+            .parent()
+            .ok_or("bad manifest_path")?
+            .to_path_buf();
+        let mut deps = BTreeSet::new();
+        for d in p["dependencies"].as_array().into_iter().flatten() {
+            if d["kind"].as_str() == Some("dev") || d["path"].is_null() {
+                continue;
+            }
+            if let Some(dn) = d["name"].as_str() {
+                if names.contains(dn) && dn != name {
+                    deps.insert(dn.to_string());
+                }
+            }
+        }
+        out.push(Package {
+            name: name.to_string(),
+            dir,
+            deps,
+        });
+    }
+    out.sort_by(|a, b| a.name.cmp(&b.name));
+    Ok(out)
+}
+
+/// Run `cargo metadata --offline --locked --no-deps` in `root`.
+pub fn cargo_packages(root: &Path) -> Result<Vec<Package>, String> {
+    let out = Command::new("cargo")
+        .args([
+            "metadata",
+            "--format-version",
+            "1",
+            "--offline",
+            "--locked",
+            "--no-deps",
+        ])
+        .current_dir(root)
+        .output()
+        .map_err(|e| format!("cannot run cargo: {e}"))?;
+    if !out.status.success() {
+        return Err(format!(
+            "cargo metadata failed: {}",
+            String::from_utf8_lossy(&out.stderr).trim()
+        ));
+    }
+    let meta: Value =
+        serde_json::from_slice(&out.stdout).map_err(|e| format!("bad metadata JSON: {e}"))?;
+    packages_from_metadata(&meta)
+}
+
+pub fn graph_of(packages: &[Package]) -> Graph {
+    packages
+        .iter()
+        .map(|p| (p.name.clone(), p.deps.clone()))
+        .collect()
+}
+
+/// Returns one cycle as a path `a -> b -> ... -> a` if the graph has any.
+/// Iterative, so a deep graph cannot overflow the stack.
+pub fn find_cycle(g: &Graph) -> Option<Vec<String>> {
+    #[derive(Clone, Copy, PartialEq)]
+    enum Mark {
+        Open,
+        Done,
+    }
+    let mut mark: BTreeMap<&str, Mark> = BTreeMap::new();
+    for start in g.keys() {
+        if mark.contains_key(start.as_str()) {
+            continue;
+        }
+        let mut stack: Vec<(&str, Vec<&str>)> = vec![(
+            start.as_str(),
+            g[start].iter().map(String::as_str).collect(),
+        )];
+        mark.insert(start.as_str(), Mark::Open);
+        while let Some((node, todo)) = stack.last_mut() {
+            let node = *node;
+            match todo.pop() {
+                Some(next) => match mark.get(next) {
+                    Some(Mark::Open) => {
+                        let mut path: Vec<String> = stack
+                            .iter()
+                            .map(|(n, _)| n.to_string())
+                            .skip_while(|n| n != next)
+                            .collect();
+                        path.push(next.to_string());
+                        return Some(path);
+                    }
+                    Some(Mark::Done) => {}
+                    None => {
+                        mark.insert(next, Mark::Open);
+                        let kids = g
+                            .get(next)
+                            .map(|s| s.iter().map(String::as_str).collect())
+                            .unwrap_or_default();
+                        stack.push((next, kids));
+                    }
+                },
+                None => {
+                    mark.insert(node, Mark::Done);
+                    stack.pop();
+                }
+            }
+        }
+    }
+    None
+}
+
+/// Transitive closure of `start` (excluding `start` itself unless cyclic).
+pub fn closure_of(g: &Graph, start: &str) -> BTreeSet<String> {
+    let mut seen = BTreeSet::new();
+    let mut todo: Vec<&str> = g
+        .get(start)
+        .into_iter()
+        .flatten()
+        .map(String::as_str)
+        .collect();
+    while let Some(n) = todo.pop() {
+        if seen.insert(n.to_string()) {
+            todo.extend(g.get(n).into_iter().flatten().map(String::as_str));
+        }
+    }
+    seen
+}
+
+/// Result of scanning C sources for quoted includes.
+#[derive(Debug, Default, PartialEq, Eq)]
+pub struct CScan {
+    /// Files (named relative to the include root) and the files they include.
+    pub graph: Graph,
+    /// (file, include text) pairs that resolved to no file. Callers must treat
+    /// these as findings, never ignore them.
+    pub unresolved: Vec<(String, String)>,
+}
+
+/// Extract the target of a quoted include from one source line, if any. Only
+/// lines whose first token is `#include "..."` count (leading and inner
+/// whitespace allowed). Block comments and `#if 0` regions are NOT understood;
+/// a commented out include is still reported, which errs on the strict side.
+pub fn quoted_include(line: &str) -> Option<&str> {
+    let rest = line.trim_start().strip_prefix('#')?.trim_start();
+    let rest = rest.strip_prefix("include")?.trim_start();
+    let rest = rest.strip_prefix('"')?;
+    let end = rest.find('"')?;
+    Some(&rest[..end])
+}
+
+fn walk_c(dir: &Path, out: &mut Vec<PathBuf>) -> Result<(), String> {
+    for entry in fs::read_dir(dir).map_err(|e| format!("cannot read {}: {e}", dir.display()))? {
+        let path = entry.map_err(|e| e.to_string())?.path();
+        if path.is_dir() {
+            walk_c(&path, out)?;
+        } else if matches!(path.extension().and_then(|e| e.to_str()), Some("c" | "h")) {
+            out.push(path);
+        }
+    }
+    Ok(())
+}
+
+/// Scan every `.c` and `.h` under `src_dir`. An include resolves first against
+/// the including file's directory, then against `include_root` (the `-I`
+/// directory). Nodes are named relative to `include_root`, or to `src_dir`
+/// when a file lies outside it.
+pub fn scan_c_includes(src_dir: &Path, include_root: &Path) -> Result<CScan, String> {
+    let canon = |p: &Path| fs::canonicalize(p).map_err(|e| format!("{}: {e}", p.display()));
+    let src_dir = canon(src_dir)?;
+    let include_root = canon(include_root)?;
+    let name_of = |p: &Path| -> String {
+        let rel = p
+            .strip_prefix(&include_root)
+            .or_else(|_| p.strip_prefix(&src_dir))
+            .unwrap_or(p);
+        rel.to_string_lossy().replace('\\', "/")
+    };
+    let mut files = Vec::new();
+    walk_c(&src_dir, &mut files)?;
+    files.sort();
+    let mut scan = CScan::default();
+    for file in &files {
+        let me = name_of(file);
+        let text =
+            fs::read_to_string(file).map_err(|e| format!("cannot read {}: {e}", file.display()))?;
+        let deps = scan.graph.entry(me.clone()).or_default();
+        for line in text.lines() {
+            let Some(inc) = quoted_include(line) else {
+                continue;
+            };
+            let here = file.parent().map(|d| d.join(inc));
+            let there = include_root.join(inc);
+            let hit = [here, Some(there)]
+                .into_iter()
+                .flatten()
+                .find(|c| c.is_file())
+                .and_then(|c| fs::canonicalize(c).ok());
+            match hit {
+                Some(p) => {
+                    deps.insert(name_of(&p));
+                }
+                None => scan.unresolved.push((me.clone(), inc.to_string())),
+            }
+        }
+    }
+    Ok(scan)
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    fn g(edges: &[(&str, &[&str])]) -> Graph {
+        edges
+            .iter()
+            .map(|(k, v)| (k.to_string(), v.iter().map(|s| s.to_string()).collect()))
+            .collect()
+    }
+
+    #[test]
+    fn cycle_found_and_absent() {
+        assert!(find_cycle(&g(&[("a", &["b"]), ("b", &["c"]), ("c", &[])])).is_none());
+        let c = find_cycle(&g(&[("a", &["b"]), ("b", &["c"]), ("c", &["b"])])).unwrap();
+        assert_eq!(c, vec!["b", "c", "b"]);
+        assert!(find_cycle(&g(&[("a", &["a"])])).is_some());
+    }
+
+    #[test]
+    fn closure_is_transitive() {
+        let gr = g(&[("a", &["b"]), ("b", &["c"]), ("c", &[])]);
+        let c: Vec<String> = closure_of(&gr, "a").into_iter().collect();
+        assert_eq!(c, vec!["b", "c"]);
+    }
+
+    #[test]
+    fn include_line_parsing() {
+        assert_eq!(quoted_include("#include \"a/b.h\""), Some("a/b.h"));
+        assert_eq!(quoted_include("  #  include   \"x.h\" // c"), Some("x.h"));
+        assert_eq!(quoted_include("#include <stdio.h>"), None);
+        assert_eq!(quoted_include("int x; // #include \"no.h\""), None);
+    }
+
+    #[test]
+    fn c_scanner_on_fixture_dir() {
+        let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/c-include");
+        let scan = scan_c_includes(&root.join("src"), &root.join("src")).unwrap();
+        let deps = |n: &str| -> Vec<&str> { scan.graph[n].iter().map(String::as_str).collect() };
+        assert_eq!(deps("main.c"), vec!["lib/a.h", "lib/b.h"]);
+        assert_eq!(deps("lib/a.h"), vec!["lib/b.h"]);
+        assert_eq!(deps("lib/b.h"), Vec::<&str>::new());
+        assert_eq!(
+            scan.unresolved,
+            vec![("main.c".to_string(), "missing.h".to_string())]
+        );
+        assert!(find_cycle(&scan.graph).is_none());
+    }
+
+    #[test]
+    fn c_scanner_sees_header_cycle() {
+        let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/c-cycle");
+        let scan = scan_c_includes(&root, &root).unwrap();
+        assert!(scan.unresolved.is_empty());
+        assert!(find_cycle(&scan.graph).is_some());
+    }
+}
diff --git a/crates/aien-closure/src/lib.rs b/crates/aien-closure/src/lib.rs
new file mode 100644
index 00000000..65a1b340
--- /dev/null
+++ b/crates/aien-closure/src/lib.rs
@@ -0,0 +1,14 @@
+//! aien-closure: the `verify-closure` bridge (Verified Crumb stage 5).
+//!
+//! Rebuilds the internal dependency graph of a workspace and checks that every
+//! internal edge is declared in a `closure.toml` manifest and backed by a
+//! verified aien-proof receipt. Fails closed: any finding is a non-zero exit.
+
+pub mod digest;
+pub mod error;
+pub mod graph;
+pub mod manifest;
+pub mod verify;
+
+pub use error::{Code, Finding};
+pub use verify::{verify, Options, Outcome};
diff --git a/crates/aien-closure/src/main.rs b/crates/aien-closure/src/main.rs
new file mode 100644
index 00000000..f3b73548
--- /dev/null
+++ b/crates/aien-closure/src/main.rs
@@ -0,0 +1,72 @@
+//! `verify-closure --root <repo> [--store <receipt dir>] [--write-lock]`
+//!
+//! Exit 0 PASS. Exit 1 internal error. Exit 2 usage error. Otherwise the exit
+//! code of the first finding (sorted by code, then component), 10 to 18.
+
+use aien_closure::{verify, Options};
+use std::path::PathBuf;
+use std::process::ExitCode;
+
+fn usage() -> ExitCode {
+    eprintln!("usage: verify-closure --root <repo> [--store <receipt dir>] [--write-lock]");
+    ExitCode::from(2)
+}
+
+fn default_store() -> PathBuf {
+    std::env::var_os("AIEN_PROOF_DIR")
+        .map(PathBuf::from)
+        .unwrap_or_else(|| {
+            std::env::var_os("HOME")
+                .map(PathBuf::from)
+                .unwrap_or_else(|| PathBuf::from("."))
+                .join(".local/state/aien-proof")
+        })
+}
+
+fn main() -> ExitCode {
+    let mut root = None;
+    let mut store = None;
+    let mut write_lock = false;
+    let mut args = std::env::args().skip(1);
+    while let Some(a) = args.next() {
+        match a.as_str() {
+            "--root" => root = args.next().map(PathBuf::from),
+            "--store" => store = args.next().map(PathBuf::from),
+            "--write-lock" => write_lock = true,
+            _ => return usage(),
+        }
+    }
+    let Some(root) = root else {
+        return usage();
+    };
+    let opts = Options {
+        root,
+        store: store.unwrap_or_else(default_store),
+        write_lock,
+    };
+    match verify(&opts) {
+        Err(e) => {
+            println!(
+                "SUMMARY status=ERROR findings=0 components=0 detail={}",
+                e.replace('\n', " ")
+            );
+            ExitCode::from(1)
+        }
+        Ok(out) => {
+            for (name, id) in &out.passed {
+                println!("PASS component={name} receipt={id}");
+            }
+            for f in &out.findings {
+                println!("{}", f.line());
+            }
+            let code = out.findings.first().map_or(0, |f| f.code.exit_code());
+            println!(
+                "SUMMARY status={} findings={} components={}",
+                if out.ok() { "PASS" } else { "FAIL" },
+                out.findings.len(),
+                out.components
+            );
+            ExitCode::from(code as u8)
+        }
+    }
+}
diff --git a/crates/aien-closure/src/manifest.rs b/crates/aien-closure/src/manifest.rs
new file mode 100644
index 00000000..e63acbb2
--- /dev/null
+++ b/crates/aien-closure/src/manifest.rs
@@ -0,0 +1,194 @@
+//! `closure.toml`: strict, line based component manifest, in the style of the
+//! aien-test `.gate` format. Despite the file name it is not general TOML.
+//!
+//! ```text
+//! closure-manifest v1
+//! component aien-scheduler
+//! profile host-v1
+//! receipt <64 hex>
+//! source blake3:<64 hex>
+//! dep aien-kv-cache <64 hex receipt id of that dependency>
+//! dep aien-platform
+//! ```
+//!
+//! Rules: first line is the header; `component`, `profile`, `receipt` and
+//! `source` appear exactly once; `dep` lines are unique per name; no tabs, no
+//! CR, no blank lines, no comments, no trailing whitespace, no unknown keys. A
+//! `dep` line without a receipt id parses (it is reported as
+//! DEPENDENCY_NOT_PINNED by the verifier, not hidden here).
+
+use std::collections::BTreeMap;
+
+pub const FILE_NAME: &str = "closure.toml";
+pub const HEADER: &str = "closure-manifest v1";
+pub const MAX_BYTES: usize = 64 * 1024;
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Manifest {
+    pub component: String,
+    pub profile: String,
+    /// Receipt id (lowercase hex) that qualifies this component.
+    pub receipt: String,
+    /// `blake3:<hex>` digest of the component source the receipt was taken at.
+    pub source: String,
+    /// Declared internal deps: name -> pinned receipt id of that dependency.
+    pub deps: BTreeMap<String, Option<String>>,
+}
+
+pub fn is_hex64(s: &str) -> bool {
+    s.len() == 64
+        && s.bytes()
+            .all(|b| b.is_ascii_digit() || (b'a'..=b'f').contains(&b))
+}
+
+fn is_name(s: &str) -> bool {
+    !s.is_empty()
+        && s.bytes()
+            .all(|b| b.is_ascii_alphanumeric() || b == b'_' || b == b'-' || b == b'.')
+}
+
+pub fn parse(text: &str) -> Result<Manifest, String> {
+    if text.len() > MAX_BYTES {
+        return Err("manifest too large".into());
+    }
+    if text.starts_with('\u{feff}') {
+        return Err("BOM not allowed".into());
+    }
+    if text.contains('\r') || text.contains('\t') {
+        return Err("tabs and CR are not allowed".into());
+    }
+    let body = text
+        .strip_suffix('\n')
+        .ok_or("file must end with a single newline")?;
+    let mut lines = body.split('\n').enumerate();
+    match lines.next() {
+        Some((_, l)) if l == HEADER => {}
+        _ => return Err(format!("line 1: expected header {HEADER:?}")),
+    }
+    let mut component = None;
+    let mut profile = None;
+    let mut receipt = None;
+    let mut source = None;
+    let mut deps: BTreeMap<String, Option<String>> = BTreeMap::new();
+    for (i, line) in lines {
+        let n = i + 1;
+        if line.is_empty() || line != line.trim() {
+            return Err(format!("line {n}: blank line or stray whitespace"));
+        }
+        let parts: Vec<&str> = line.split(' ').collect();
+        if parts.iter().any(|p| p.is_empty()) {
+            return Err(format!("line {n}: repeated spaces"));
+        }
+        match (parts[0], parts.len()) {
+            ("component", 2) | ("profile", 2) => {
+                if !is_name(parts[1]) {
+                    return Err(format!("line {n}: bad name {:?}", parts[1]));
+                }
+                let slot = if parts[0] == "component" {
+                    &mut component
+                } else {
+                    &mut profile
+                };
+                if slot.replace(parts[1].to_string()).is_some() {
+                    return Err(format!("line {n}: duplicate {}", parts[0]));
+                }
+            }
+            ("receipt", 2) => {
+                if !is_hex64(parts[1]) {
+                    return Err(format!("line {n}: receipt must be 64 lowercase hex"));
+                }
+                if receipt.replace(parts[1].to_string()).is_some() {
+                    return Err(format!("line {n}: duplicate receipt"));
+                }
+            }
+            ("source", 2) => {
+                let ok = parts[1].strip_prefix("blake3:").is_some_and(is_hex64);
+                if !ok {
+                    return Err(format!(
+                        "line {n}: source must be blake3:<64 lowercase hex>"
+                    ));
+                }
+                if source.replace(parts[1].to_string()).is_some() {
+                    return Err(format!("line {n}: duplicate source"));
+                }
+            }
+            ("dep", 2) | ("dep", 3) => {
+                if !is_name(parts[1]) {
+                    return Err(format!("line {n}: bad dep name {:?}", parts[1]));
+                }
+                let pin = match parts.get(2) {
+                    Some(p) if is_hex64(p) => Some(p.to_string()),
+                    Some(_) => return Err(format!("line {n}: dep pin must be 64 lowercase hex")),
+                    None => None,
+                };
+                if deps.insert(parts[1].to_string(), pin).is_some() {
+                    return Err(format!("line {n}: duplicate dep {}", parts[1]));
+                }
+            }
+            (key, _) => return Err(format!("line {n}: unknown or malformed key {key:?}")),
+        }
+    }
+    Ok(Manifest {
+        component: component.ok_or("missing component")?,
+        profile: profile.ok_or("missing profile")?,
+        receipt: receipt.ok_or("missing receipt")?,
+        source: source.ok_or("missing source")?,
+        deps,
+    })
+}
+
+pub fn render(m: &Manifest) -> String {
+    let mut s = format!(
+        "{HEADER}\ncomponent {}\nprofile {}\nreceipt {}\nsource {}\n",
+        m.component, m.profile, m.receipt, m.source
+    );
+    for (name, pin) in &m.deps {
+        match pin {
+            Some(p) => s.push_str(&format!("dep {name} {p}\n")),
+            None => s.push_str(&format!("dep {name}\n")),
+        }
+    }
+    s
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    fn sample() -> Manifest {
+        let mut deps = BTreeMap::new();
+        deps.insert("b".to_string(), Some("1".repeat(64)));
+        deps.insert("c".to_string(), None);
+        Manifest {
+            component: "a".into(),
+            profile: "host-v1".into(),
+            receipt: "2".repeat(64),
+            source: format!("blake3:{}", "3".repeat(64)),
+            deps,
+        }
+    }
+
+    #[test]
+    fn round_trips() {
+        let m = sample();
+        assert_eq!(parse(&render(&m)).unwrap(), m);
+    }
+
+    #[test]
+    fn rejects_malformed() {
+        let good = render(&sample());
+        for bad in [
+            good.replace("closure-manifest v1", "closure-manifest v2"),
+            good.replace('\n', "\r\n"),
+            good.trim_end().to_string(),
+            format!("{good}\n"),
+            format!("{good}extra thing\n"),
+            format!("{good}component again\n"),
+            good.replace("profile host-v1\n", ""),
+            good.replace(&"2".repeat(64), "XYZ"),
+            format!("{good}dep b\n"),
+        ] {
+            assert!(parse(&bad).is_err(), "should reject:\n{bad}");
+        }
+    }
+}
diff --git a/crates/aien-closure/src/verify.rs b/crates/aien-closure/src/verify.rs
new file mode 100644
index 00000000..c0ad12c5
--- /dev/null
+++ b/crates/aien-closure/src/verify.rs
@@ -0,0 +1,387 @@
+//! The verification pipeline behind `verify-closure`.
+
+use crate::digest::source_digest;
+use crate::error::{Code, Finding};
+use crate::graph::{cargo_packages, closure_of, find_cycle, graph_of, Package};
+use crate::manifest::{self, Manifest};
+use aien_proof::chain::{tier_satisfies, verify_chain};
+use aien_proof::evidence::{receipt_id, Receipt, Tier, Verdict, RECEIPT_DIR};
+use std::collections::{BTreeMap, BTreeSet};
+use std::fs;
+use std::path::{Path, PathBuf};
+
+pub const LOCK_FILE: &str = "closure.lock";
+pub const LOCK_HEADER: &str = "closure-lock v1";
+
+pub struct Options {
+    pub root: PathBuf,
+    pub store: PathBuf,
+    /// Write `closure.lock` (only when no other finding exists) before
+    /// comparing, so a fresh lock verifies.
+    pub write_lock: bool,
+}
+
+pub struct Outcome {
+    pub findings: Vec<Finding>,
+    /// Number of components that carry a manifest.
+    pub components: usize,
+    /// Components with no findings.
+    pub passed: Vec<(String, String)>,
+}
+
+impl Outcome {
+    pub fn ok(&self) -> bool {
+        self.findings.is_empty()
+    }
+}
+
+/// Minimum receipt tier a verifier profile demands. Unknown profiles have no
+/// entry, which the verifier reports as UNKNOWN_VERIFIER_PROFILE.
+pub fn profile_min_tier(profile: &str) -> Option<Tier> {
+    match profile {
+        "host-v1" => Some(Tier::HostTest),
+        "qemu-v1" => Some(Tier::Qemu),
+        "production-v1" => Some(Tier::Production),
+        _ => None,
+    }
+}
+
+enum Load {
+    Missing,
+    Mismatch(String),
+    Ok(Box<Receipt>),
+}
+
+fn receipt_path(store: &Path, id: &str) -> PathBuf {
+    store.join(RECEIPT_DIR).join(format!("{id}.json"))
+}
+
+/// Read a receipt by claimed id and recompute its identity with aien-proof.
+fn load(store: &Path, id: &str) -> Load {
+    let Ok(bytes) = fs::read(receipt_path(store, id)) else {
+        return Load::Missing;
+    };
+    let r: Receipt = match serde_json::from_slice(&bytes) {
+        Ok(r) => r,
+        Err(e) => return Load::Mismatch(format!("not a valid receipt: {e}")),
+    };
+    match receipt_id(&r) {
+        Err(e) => Load::Mismatch(e),
+        Ok(c) if c != id || r.id.to_ascii_lowercase() != id => Load::Mismatch(format!(
+            "file {id} has canonical identity {c} and claims {}",
+            r.id
+        )),
+        Ok(_) => Load::Ok(Box::new(r)),
+    }
+}
+
+struct ChainFacts {
+    findings: Vec<(Code, String)>,
+    tainted: Vec<String>,
+    root: Option<Box<Receipt>>,
+}
+
+/// Walk the receipt graph from `id`, classifying missing, mismatched and
+/// tainted receipts. Tainted means recorded dirty or TEST_ONLY_TRUST.
+fn walk_receipts(store: &Path, id: &str) -> ChainFacts {
+    let mut facts = ChainFacts {
+        findings: vec![],
+        tainted: vec![],
+        root: None,
+    };
+    let mut seen = BTreeSet::new();
+    let mut todo = vec![id.to_string()];
+    while let Some(cur) = todo.pop() {
+        if !seen.insert(cur.clone()) {
+            continue;
+        }
+        match load(store, &cur) {
+            Load::Missing => facts
+                .findings
+                .push((Code::MissingReceipt, format!("receipt {cur} not in store"))),
+            Load::Mismatch(m) => facts
+                .findings
+                .push((Code::ReceiptHashMismatch, format!("receipt {cur}: {m}"))),
+            Load::Ok(r) => {
+                if r.dirty {
+                    facts
+                        .tainted
+                        .push(format!("{cur} recorded from a dirty tree"));
+                }
+                if r.tier == Tier::TestOnlyTrust {
+                    facts.tainted.push(format!("{cur} is TEST_ONLY_TRUST"));
+                }
+                todo.extend(r.dependencies.iter().map(|d| d.to_ascii_lowercase()));
+                if cur == id {
+                    facts.root = Some(r);
+                }
+            }
+        }
+    }
+    facts
+}
+
+fn check_component(
+    m: &Manifest,
+    pkg: &Package,
+    manifests: &BTreeMap<String, Manifest>,
+    store: &Path,
+    out: &mut Vec<Finding>,
+) {
+    let name = m.component.as_str();
+    let mut add = |code: Code, detail: String| out.push(Finding::new(code, name, detail));
+
+    // Profile.
+    let min_tier = profile_min_tier(&m.profile);
+    if min_tier.is_none() {
+        add(
+            Code::UnknownVerifierProfile,
+            format!("profile {:?} is not known to this verifier", m.profile),
+        );
+    }
+
+    // Edges: every actual edge declared and pinned to the dep's own receipt.
+    for dep in &pkg.deps {
+        match m.deps.get(dep) {
+            None => add(
+                Code::UndeclaredImport,
+                format!("edge to {dep} is not declared in {}", manifest::FILE_NAME),
+            ),
+            Some(pin) => match manifests.get(dep) {
+                None => add(
+                    Code::UnverifiedDependency,
+                    format!("dependency {dep} has no {}", manifest::FILE_NAME),
+                ),
+                Some(dm) => match pin {
+                    None => add(
+                        Code::DependencyNotPinned,
+                        format!("dep {dep} declared without a receipt pin"),
+                    ),
+                    Some(p) if *p != dm.receipt => add(
+                        Code::DependencyNotPinned,
+                        format!(
+                            "dep {dep} pinned to {p} but {dep} is qualified by {}",
+                            dm.receipt
+                        ),
+                    ),
+                    Some(_) => {}
+                },
+            },
+        }
+    }
+    for dep in m.deps.keys() {
+        if !pkg.deps.contains(dep) {
+            add(
+                Code::UnverifiedDependency,
+                format!("declared dep {dep} is not an edge of the graph"),
+            );
+        }
+    }
+
+    // Receipt and chain.
+    let facts = walk_receipts(store, &m.receipt);
+    let broken = !facts.findings.is_empty();
+    for (code, detail) in facts.findings {
+        add(code, detail);
+    }
+    for t in facts.tainted {
+        add(Code::TaintedArtifact, t);
+    }
+    if let Some(root) = &facts.root {
+        // Pins must be bound inside the receipt, so the chain covers them.
+        let rdeps: BTreeSet<String> = root
+            .dependencies
+            .iter()
+            .map(|d| d.to_ascii_lowercase())
+            .collect();
+        for (dep, pin) in &m.deps {
+            if let Some(p) = pin {
+                if !rdeps.contains(p) {
+                    add(
+                        Code::DependencyNotPinned,
+                        format!(
+                            "receipt {} does not depend on pinned receipt {p} of {dep}",
+                            m.receipt
+                        ),
+                    );
+                }
+            }
+        }
+        // Source binding.
+        if !root.input_artifacts.iter().any(|a| a == &m.source) {
+            add(
+                Code::StaleReceipt,
+                format!("receipt {} was not taken at {}", m.receipt, m.source),
+            );
+        }
+        if let Some(need) = min_tier {
+            if root.tier != Tier::TestOnlyTrust && !tier_satisfies(need, root.tier) {
+                add(
+                    Code::UnverifiedDependency,
+                    format!(
+                        "receipt tier {} does not satisfy profile {}",
+                        root.tier.as_str(),
+                        m.profile
+                    ),
+                );
+            }
+        }
+        if root.result != Verdict::Pass {
+            add(
+                Code::UnverifiedDependency,
+                format!("receipt {} result is {}", m.receipt, root.result.as_str()),
+            );
+        }
+    }
+    if !broken {
+        match verify_chain(&receipt_path(store, &m.receipt), store) {
+            Err(e) => add(Code::UnverifiedDependency, format!("chain error: {e}")),
+            Ok(rep) if rep.status != Verdict::Pass => {
+                let why = rep.reasons.join("; ");
+                let code = if why.contains("dependency cycle") {
+                    Code::DependencyCycle
+                } else {
+                    Code::UnverifiedDependency
+                };
+                add(code, format!("chain {}: {why}", rep.status.as_str()));
+            }
+            Ok(_) => {}
+        }
+    }
+
+    // Current source against the digest the manifest records.
+    match source_digest(&pkg.dir) {
+        Err(e) => add(Code::StaleReceipt, format!("cannot digest source: {e}")),
+        Ok(d) => {
+            let now = format!("blake3:{d}");
+            if now != m.source {
+                add(
+                    Code::StaleReceipt,
+                    format!("source is {now} but manifest records {}", m.source),
+                );
+            }
+        }
+    }
+}
+
+/// Render the lock: header, one `component` line each, then every transitive
+/// dependency with its pinned receipt id. Sorted, so it is deterministic.
+pub fn render_lock(manifests: &BTreeMap<String, Manifest>, graph: &crate::graph::Graph) -> String {
+    let mut s = format!("{LOCK_HEADER}\n");
+    for (name, m) in manifests {
+        s.push_str(&format!("component {name} {} {}\n", m.receipt, m.source));
+        for dep in closure_of(graph, name) {
+            let id = manifests.get(&dep).map_or("-", |d| d.receipt.as_str());
+            s.push_str(&format!("needs {name} {dep} {id}\n"));
+        }
+    }
+    s
+}
+
+/// Run every check. `Err` is an internal error (cannot run cargo, cannot
+/// read the repo); callers must treat it as failure too.
+pub fn verify(opts: &Options) -> Result<Outcome, String> {
+    let packages = cargo_packages(&opts.root)?;
+    let graph = graph_of(&packages);
+    let mut findings: Vec<Finding> = Vec::new();
+
+    // Manifests.
+    let mut manifests: BTreeMap<String, Manifest> = BTreeMap::new();
+    for pkg in &packages {
+        let path = pkg.dir.join(manifest::FILE_NAME);
+        if !path.exists() {
+            continue;
+        }
+        let parsed = fs::read_to_string(&path)
+            .map_err(|e| e.to_string())
+            .and_then(|t| manifest::parse(&t))
+            .and_then(|m| {
+                if m.component == pkg.name {
+                    Ok(m)
+                } else {
+                    Err(format!(
+                        "component {:?} does not match package {:?}",
+                        m.component, pkg.name
+                    ))
+                }
+            });
+        match parsed {
+            Ok(m) => {
+                manifests.insert(pkg.name.clone(), m);
+            }
+            Err(e) => findings.push(Finding::new(
+                Code::UnverifiedDependency,
+                &pkg.name,
+                format!("bad {}: {e}", manifest::FILE_NAME),
+            )),
+        }
+    }
+    if manifests.is_empty() && findings.is_empty() {
+        findings.push(Finding::new(
+            Code::UnverifiedDependency,
+            "-",
+            format!(
+                "no {} found under {}",
+                manifest::FILE_NAME,
+                opts.root.display()
+            ),
+        ));
+    }
+
+    // Cycles.
+    if let Some(cycle) = find_cycle(&graph) {
+        findings.push(Finding::new(
+            Code::DependencyCycle,
+            &cycle[0],
+            cycle.join(" -> "),
+        ));
+    }
+
+    // Components with a manifest.
+    let by_name: BTreeMap<&str, &Package> = packages.iter().map(|p| (p.name.as_str(), p)).collect();
+    for (name, m) in &manifests {
+        check_component(
+            m,
+            by_name[name.as_str()],
+            &manifests,
+            &opts.store,
+            &mut findings,
+        );
+    }
+
+    // Lock file, only meaningful when the rest is clean.
+    if findings.is_empty() {
+        let want = render_lock(&manifests, &graph);
+        let path = opts.root.join(LOCK_FILE);
+        if opts.write_lock {
+            fs::write(&path, &want).map_err(|e| format!("cannot write {}: {e}", path.display()))?;
+        }
+        match fs::read_to_string(&path) {
+            Ok(have) if have == want => {}
+            Ok(_) => findings.push(Finding::new(
+                Code::DependencyNotPinned,
+                "-",
+                format!("{LOCK_FILE} does not match the rebuilt closure"),
+            )),
+            Err(_) => findings.push(Finding::new(
+                Code::DependencyNotPinned,
+                "-",
+                format!("{LOCK_FILE} is missing"),
+            )),
+        }
+    }
+
+    findings.sort();
+    findings.dedup();
+    let bad: BTreeSet<&str> = findings.iter().map(|f| f.component.as_str()).collect();
+    let passed = manifests
+        .iter()
+        .filter(|(n, _)| !bad.contains(n.as_str()))
+        .map(|(n, m)| (n.clone(), m.receipt.clone()))
+        .collect();
+    Ok(Outcome {
+        findings,
+        components: manifests.len(),
+        passed,
+    })
+}
diff --git a/crates/aien-closure/tests/closure.rs b/crates/aien-closure/tests/closure.rs
new file mode 100644
index 00000000..8b9a7f8c
--- /dev/null
+++ b/crates/aien-closure/tests/closure.rs
@@ -0,0 +1,297 @@
+mod common;
+
+use aien_closure::error::ALL;
+use aien_closure::{verify, Code, Options};
+use common::*;
+use std::collections::BTreeSet;
+use std::path::Path;
+use std::process::Command;
+
+fn run(root: &Path, store: &Path) -> aien_closure::Outcome {
+    verify(&Options {
+        root: root.to_path_buf(),
+        store: store.to_path_buf(),
+        write_lock: false,
+    })
+    .unwrap()
+}
+
+fn codes(root: &Path, store: &Path) -> BTreeSet<Code> {
+    let out = run(root, store);
+    for f in &out.findings {
+        eprintln!("{}", f.line());
+    }
+    out.findings.iter().map(|f| f.code).collect()
+}
+
+/// Run the real binary and return (exit code, stdout).
+fn bin(root: &Path, store: &Path) -> (i32, String) {
+    let o = Command::new(env!("CARGO_BIN_EXE_verify-closure"))
+        .args([
+            "--root",
+            root.to_str().unwrap(),
+            "--store",
+            store.to_str().unwrap(),
+        ])
+        .output()
+        .unwrap();
+    (
+        o.status.code().unwrap(),
+        String::from_utf8_lossy(&o.stdout).into_owned(),
+    )
+}
+
+/// The case must produce exactly `want`, and the binary must exit with the
+/// matching code and print one FINDING line per finding.
+fn expect_only(root: &Path, store: &Path, want: Code) {
+    assert_eq!(codes(root, store), BTreeSet::from([want]), "wrong findings");
+    let (exit, stdout) = bin(root, store);
+    assert_eq!(exit, want.exit_code(), "wrong exit code:\n{stdout}");
+    assert!(
+        stdout.contains(&format!("FINDING {} ", want.as_str())),
+        "{stdout}"
+    );
+    assert!(stdout.contains("SUMMARY status=FAIL"), "{stdout}");
+}
+
+#[test]
+fn pass_case() {
+    let (root, store, ids) = seeded(&Knobs::default());
+    let out = run(&root, &store);
+    assert!(out.ok(), "{:?}", out.findings);
+    assert_eq!(out.components, 3);
+    assert_eq!(out.passed.len(), 3);
+    let (exit, stdout) = bin(&root, &store);
+    assert_eq!(exit, 0, "{stdout}");
+    assert!(stdout.contains("SUMMARY status=PASS findings=0 components=3"));
+    assert!(stdout.contains(&format!("PASS component=alpha receipt={}", ids["alpha"])));
+    // closure.lock lists the transitive closure with ids.
+    let lock = read(&root, "closure.lock");
+    assert!(
+        lock.contains(&format!("needs alpha gamma {}", ids["gamma"])),
+        "{lock}"
+    );
+}
+
+#[test]
+fn committed_seeded_fixture_passes() {
+    let root = fixture_src();
+    let out = run(&root, &root.join("store"));
+    assert!(out.ok(), "{:?}", out.findings);
+    assert_eq!(out.components, 3);
+}
+
+/// `cargo test -- --ignored regenerate_committed_fixture` rewrites the
+/// committed manifests, lock and store. Deterministic: same sources, same bytes.
+#[test]
+#[ignore]
+fn regenerate_committed_fixture() {
+    let root = fixture_src();
+    let store = root.join("store");
+    let _ = std::fs::remove_dir_all(&store);
+    seed(&root, &store, &Knobs::default());
+}
+
+#[test]
+fn unverified_dependency() {
+    // beta depends on gamma, but gamma carries no manifest.
+    let (root, store, _) = seeded(&Knobs::default());
+    std::fs::remove_file(root.join("crates/gamma/closure.toml")).unwrap();
+    expect_only(&root, &store, Code::UnverifiedDependency);
+}
+
+#[test]
+fn missing_receipt() {
+    let (root, store, ids) = seeded(&Knobs::default());
+    std::fs::remove_file(
+        store
+            .join("receipts")
+            .join(format!("{}.json", ids["alpha"])),
+    )
+    .unwrap();
+    expect_only(&root, &store, Code::MissingReceipt);
+}
+
+#[test]
+fn receipt_hash_mismatch() {
+    // Same file name, different bytes: the content no longer hashes to its id.
+    let (root, store, ids) = seeded(&Knobs::default());
+    let p = store
+        .join("receipts")
+        .join(format!("{}.json", ids["gamma"]));
+    let text = std::fs::read_to_string(&p).unwrap();
+    assert!(text.contains("1786000000"));
+    std::fs::write(&p, text.replace("1786000000", "1786000001")).unwrap();
+    let got = codes(&root, &store);
+    assert!(got.contains(&Code::ReceiptHashMismatch), "{got:?}");
+    assert_eq!(got, BTreeSet::from([Code::ReceiptHashMismatch]));
+    assert_eq!(bin(&root, &store).0, Code::ReceiptHashMismatch.exit_code());
+}
+
+#[test]
+fn dependency_not_pinned() {
+    let (root, store, ids) = seeded(&Knobs::default());
+    let m = read(&root, "crates/alpha/closure.toml");
+    write(
+        &root,
+        "crates/alpha/closure.toml",
+        &m.replace(&format!("dep beta {}", ids["beta"]), "dep beta"),
+    );
+    expect_only(&root, &store, Code::DependencyNotPinned);
+}
+
+#[test]
+fn dependency_not_pinned_when_lock_is_stale() {
+    let (root, store, _) = seeded(&Knobs::default());
+    let lock = read(&root, "closure.lock");
+    write(
+        &root,
+        "closure.lock",
+        &lock.replace("needs alpha gamma", "needs alpha beta"),
+    );
+    expect_only(&root, &store, Code::DependencyNotPinned);
+    std::fs::remove_file(root.join("closure.lock")).unwrap();
+    expect_only(&root, &store, Code::DependencyNotPinned);
+}
+
+#[test]
+fn dependency_cycle() {
+    // gamma now depends on alpha: alpha -> beta -> gamma -> alpha.
+    let (root, store, _) = seeded(&Knobs::default());
+    let m = read(&root, "crates/gamma/Cargo.toml");
+    write(
+        &root,
+        "crates/gamma/Cargo.toml",
+        &m.replace(
+            "[dependencies]",
+            "[dependencies]\nalpha = { path = \"../alpha\" }",
+        ),
+    );
+    let got = codes(&root, &store);
+    assert!(got.contains(&Code::DependencyCycle), "{got:?}");
+    assert_eq!(bin(&root, &store).0, Code::DependencyCycle.exit_code());
+}
+
+#[test]
+fn stale_receipt() {
+    // Source changes after the receipt was taken.
+    let (root, store, _) = seeded(&Knobs::default());
+    write(
+        &root,
+        "crates/gamma/src/lib.rs",
+        "pub fn gamma() -> u32 { 4 }\n",
+    );
+    let got = codes(&root, &store);
+    assert_eq!(got, BTreeSet::from([Code::StaleReceipt]));
+    assert_eq!(bin(&root, &store).0, Code::StaleReceipt.exit_code());
+}
+
+#[test]
+fn stale_receipt_when_receipt_records_other_source() {
+    // The manifest digest is current but the receipt was taken at a different one.
+    let (root, store, ids) = seeded(&Knobs::default());
+    let p = store
+        .join("receipts")
+        .join(format!("{}.json", ids["gamma"]));
+    let text = std::fs::read_to_string(&p).unwrap();
+    let r: aien_proof::evidence::Receipt = serde_json::from_str(&text).unwrap();
+    let mut other = r.clone();
+    other.input_artifacts = vec![format!("blake3:{}", "d".repeat(64))];
+    other.id = aien_proof::evidence::receipt_id(&other).unwrap();
+    aien_proof::evidence::store_receipt(&store, &other).unwrap();
+    let m = read(&root, "crates/gamma/closure.toml");
+    write(
+        &root,
+        "crates/gamma/closure.toml",
+        &m.replace(&ids["gamma"], &other.id),
+    );
+    let got = codes(&root, &store);
+    assert!(got.contains(&Code::StaleReceipt), "{got:?}");
+}
+
+#[test]
+fn undeclared_import() {
+    // alpha gains a direct edge to gamma that its manifest does not declare.
+    let (root, store, _) = seeded(&Knobs::default());
+    let m = read(&root, "crates/alpha/Cargo.toml");
+    write(
+        &root,
+        "crates/alpha/Cargo.toml",
+        &m.replace(
+            "[dependencies]",
+            "[dependencies]\ngamma = { path = \"../gamma\" }",
+        ),
+    );
+    // Re-seed against the new graph, then drop the declaration again, so the
+    // undeclared edge is the only thing wrong.
+    seed(&root, &store, &Knobs::default());
+    let man = read(&root, "crates/alpha/closure.toml");
+    let kept: String = man
+        .lines()
+        .filter(|l| !l.starts_with("dep gamma"))
+        .map(|l| format!("{l}\n"))
+        .collect();
+    write(&root, "crates/alpha/closure.toml", &kept);
+    expect_only(&root, &store, Code::UndeclaredImport);
+}
+
+#[test]
+fn tainted_artifact_dirty() {
+    let knobs = Knobs {
+        gamma_dirty: true,
+        ..Knobs::default()
+    };
+    let (root, store, _) = seeded(&knobs);
+    expect_only(&root, &store, Code::TaintedArtifact);
+}
+
+#[test]
+fn tainted_artifact_test_only_trust() {
+    let knobs = Knobs {
+        gamma_tier: aien_proof::evidence::Tier::TestOnlyTrust,
+        ..Knobs::default()
+    };
+    let (root, store, _) = seeded(&knobs);
+    let got = codes(&root, &store);
+    assert!(got.contains(&Code::TaintedArtifact), "{got:?}");
+}
+
+#[test]
+fn unknown_verifier_profile() {
+    let knobs = Knobs {
+        alpha_profile: "bogus-v9",
+        ..Knobs::default()
+    };
+    let (root, store, _) = seeded(&knobs);
+    expect_only(&root, &store, Code::UnknownVerifierProfile);
+}
+
+#[test]
+fn nine_codes_have_distinct_exit_codes_and_names() {
+    let exits: BTreeSet<i32> = ALL.iter().map(|c| c.exit_code()).collect();
+    let names: BTreeSet<&str> = ALL.iter().map(|c| c.as_str()).collect();
+    assert_eq!(ALL.len(), 9);
+    assert_eq!(exits.len(), 9);
+    assert_eq!(names.len(), 9);
+    assert!(exits.iter().all(|e| (10..=18).contains(e)));
+}
+
+#[test]
+fn no_manifests_fails_closed() {
+    let root = temp_dir("bare");
+    copy_sources(&fixture_src(), &root);
+    let got = codes(&root, &root.join("store"));
+    assert_eq!(got, BTreeSet::from([Code::UnverifiedDependency]));
+    assert_eq!(
+        bin(&root, &root.join("store")).0,
+        Code::UnverifiedDependency.exit_code()
+    );
+}
+
+#[test]
+fn usage_error_is_exit_2() {
+    let o = Command::new(env!("CARGO_BIN_EXE_verify-closure"))
+        .output()
+        .unwrap();
+    assert_eq!(o.status.code(), Some(2));
+}
diff --git a/crates/aien-closure/tests/common/mod.rs b/crates/aien-closure/tests/common/mod.rs
new file mode 100644
index 00000000..fd056500
--- /dev/null
+++ b/crates/aien-closure/tests/common/mod.rs
@@ -0,0 +1,164 @@
+//! Fixture helpers. Receipts are built and sealed with aien-proof's own API, so
+//! every id in the store is a real canonical identity.
+#![allow(dead_code)]
+
+use aien_closure::digest::source_digest;
+use aien_closure::graph::{cargo_packages, graph_of};
+use aien_closure::manifest::{self, Manifest};
+use aien_closure::verify::{render_lock, LOCK_FILE};
+use aien_proof::evidence::{
+    receipt_id, store_receipt, Assertion, Mutation, Receipt, Tier, Verdict, SCHEMA, SCHEMA_VERSION,
+};
+use std::collections::BTreeMap;
+use std::fs;
+use std::path::{Path, PathBuf};
+use std::sync::atomic::{AtomicUsize, Ordering};
+
+static N: AtomicUsize = AtomicUsize::new(0);
+
+pub fn fixture_src() -> PathBuf {
+    Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/seeded")
+}
+
+pub fn temp_dir(tag: &str) -> PathBuf {
+    let n = N.fetch_add(1, Ordering::SeqCst);
+    let dir = std::env::temp_dir().join(format!("aien-closure-{tag}-{}-{n}", std::process::id()));
+    let _ = fs::remove_dir_all(&dir);
+    fs::create_dir_all(&dir).unwrap();
+    dir
+}
+
+/// Copy the fixture sources only (no manifests, lock, or store).
+pub fn copy_sources(src: &Path, dst: &Path) {
+    fs::create_dir_all(dst).unwrap();
+    for e in fs::read_dir(src).unwrap() {
+        let e = e.unwrap();
+        let name = e.file_name().to_string_lossy().into_owned();
+        if matches!(
+            name.as_str(),
+            "closure.toml" | "closure.lock" | "store" | "target"
+        ) {
+            continue;
+        }
+        let to = dst.join(&name);
+        if e.file_type().unwrap().is_dir() {
+            copy_sources(&e.path(), &to);
+        } else {
+            fs::copy(e.path(), to).unwrap();
+        }
+    }
+}
+
+/// Knobs that change what the seeded receipts claim.
+#[derive(Clone)]
+pub struct Knobs {
+    pub gamma_dirty: bool,
+    pub gamma_tier: Tier,
+    pub alpha_profile: &'static str,
+}
+
+impl Default for Knobs {
+    fn default() -> Self {
+        Knobs {
+            gamma_dirty: false,
+            gamma_tier: Tier::HostTest,
+            alpha_profile: "host-v1",
+        }
+    }
+}
+
+fn receipt_for(name: &str, source: &str, deps: Vec<String>, tier: Tier, dirty: bool) -> Receipt {
+    let mut r = Receipt {
+        schema: SCHEMA.to_string(),
+        version: SCHEMA_VERSION,
+        id: String::new(),
+        kind: "component-qualification".to_string(),
+        tier,
+        result: Verdict::Pass,
+        timestamp: 1_786_000_000,
+        repo: "https://github.com/aien-dev/aien-sovereign-core".to_string(),
+        commit: "a".repeat(40),
+        dirty,
+        toolchain: "rustc fixture".to_string(),
+        procedure: format!("cargo test -p {name}"),
+        machine: "host".to_string(),
+        env_class: tier.as_str().to_string(),
+        input_artifacts: vec![source.to_string()],
+        output_artifacts: vec![],
+        assertions: vec![Assertion {
+            id: "cargo_test_pass".to_string(),
+            expected: "pass".to_string(),
+            observed: "pass".to_string(),
+            pass: true,
+            source: "cargo".to_string(),
+            note: String::new(),
+        }],
+        dependencies: deps,
+        declared_mutation: Mutation::None,
+        observed_mutation: Mutation::None,
+        authority: String::new(),
+        output_digest: blake3::hash(name.as_bytes()).to_hex().to_string(),
+        external_refs: vec![],
+        ledger: None,
+        lease: None,
+        required_features: vec![],
+        reserved: String::new(),
+    };
+    r.id = receipt_id(&r).unwrap();
+    r
+}
+
+/// Seed manifests, receipts and the lock for the gamma, beta, alpha fixture.
+/// Returns component name -> receipt id.
+pub fn seed(root: &Path, store: &Path, knobs: &Knobs) -> BTreeMap<String, String> {
+    let packages = cargo_packages(root).unwrap();
+    let graph = graph_of(&packages);
+    let mut ids: BTreeMap<String, String> = BTreeMap::new();
+    let mut manifests: BTreeMap<String, Manifest> = BTreeMap::new();
+    for name in ["gamma", "beta", "alpha"] {
+        let pkg = packages.iter().find(|p| p.name == name).unwrap();
+        let source = format!("blake3:{}", source_digest(&pkg.dir).unwrap());
+        let (tier, dirty, profile) = match name {
+            "gamma" => (knobs.gamma_tier, knobs.gamma_dirty, "host-v1"),
+            "alpha" => (Tier::HostTest, false, knobs.alpha_profile),
+            _ => (Tier::HostTest, false, "host-v1"),
+        };
+        let deps: BTreeMap<String, Option<String>> = pkg
+            .deps
+            .iter()
+            .map(|d| (d.clone(), Some(ids[d].clone())))
+            .collect();
+        let dep_ids = deps.values().flatten().cloned().collect();
+        let r = receipt_for(name, &source, dep_ids, tier, dirty);
+        store_receipt(store, &r).unwrap();
+        ids.insert(name.to_string(), r.id.clone());
+        let m = Manifest {
+            component: name.to_string(),
+            profile: profile.to_string(),
+            receipt: r.id,
+            source,
+            deps,
+        };
+        fs::write(pkg.dir.join(manifest::FILE_NAME), manifest::render(&m)).unwrap();
+        manifests.insert(name.to_string(), m);
+    }
+    fs::write(root.join(LOCK_FILE), render_lock(&manifests, &graph)).unwrap();
+    ids
+}
+
+/// Seed into a fresh temp copy of the fixture. Returns (root, store, ids).
+pub fn seeded(knobs: &Knobs) -> (PathBuf, PathBuf, BTreeMap<String, String>) {
+    let root = temp_dir("ws");
+    copy_sources(&fixture_src(), &root);
+    let store = root.join("store");
+    let ids = seed(&root, &store, knobs);
+    (root, store, ids)
+}
+
+pub fn write(root: &Path, rel: &str, text: &str) {
+    fs::write(root.join(rel), text).unwrap();
+}
+
+pub fn read(root: &Path, rel: &str) -> String {
+    fs::read_to_string(root.join(rel)).unwrap()
+}
diff --git a/crates/aien-closure/tests/fixtures/c-cycle/x.h b/crates/aien-closure/tests/fixtures/c-cycle/x.h
new file mode 100644
index 00000000..a82303d5
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/c-cycle/x.h
@@ -0,0 +1 @@
+#include "y.h"
diff --git a/crates/aien-closure/tests/fixtures/c-cycle/y.h b/crates/aien-closure/tests/fixtures/c-cycle/y.h
new file mode 100644
index 00000000..82661908
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/c-cycle/y.h
@@ -0,0 +1 @@
+#include "x.h"
diff --git a/crates/aien-closure/tests/fixtures/c-include/src/lib/a.h b/crates/aien-closure/tests/fixtures/c-include/src/lib/a.h
new file mode 100644
index 00000000..6202affc
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/c-include/src/lib/a.h
@@ -0,0 +1,2 @@
+#include "b.h"
+int a(void);
diff --git a/crates/aien-closure/tests/fixtures/c-include/src/lib/b.h b/crates/aien-closure/tests/fixtures/c-include/src/lib/b.h
new file mode 100644
index 00000000..a0d832f4
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/c-include/src/lib/b.h
@@ -0,0 +1 @@
+int b(void);
diff --git a/crates/aien-closure/tests/fixtures/c-include/src/main.c b/crates/aien-closure/tests/fixtures/c-include/src/main.c
new file mode 100644
index 00000000..49535a26
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/c-include/src/main.c
@@ -0,0 +1,5 @@
+#include "lib/a.h"
+#include "lib/b.h"
+#include <stdio.h>
+#include "missing.h"
+int main(void){return 0;}
diff --git a/crates/aien-closure/tests/fixtures/seeded/Cargo.lock b/crates/aien-closure/tests/fixtures/seeded/Cargo.lock
new file mode 100644
index 00000000..ffcebd70
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/seeded/Cargo.lock
@@ -0,0 +1,21 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "alpha"
+version = "0.1.0"
+dependencies = [
+ "beta",
+]
+
+[[package]]
+name = "beta"
+version = "0.1.0"
+dependencies = [
+ "gamma",
+]
+
+[[package]]
+name = "gamma"
+version = "0.1.0"
diff --git a/crates/aien-closure/tests/fixtures/seeded/Cargo.toml b/crates/aien-closure/tests/fixtures/seeded/Cargo.toml
new file mode 100644
index 00000000..e2019306
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/seeded/Cargo.toml
@@ -0,0 +1,3 @@
+[workspace]
+resolver = "2"
+members = ["crates/alpha", "crates/beta", "crates/gamma"]
diff --git a/crates/aien-closure/tests/fixtures/seeded/closure.lock b/crates/aien-closure/tests/fixtures/seeded/closure.lock
new file mode 100644
index 00000000..309f908b
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/seeded/closure.lock
@@ -0,0 +1,7 @@
+closure-lock v1
+component alpha 54f597d22b3753e47d6bd7706b6a7a422c189024912ec4626347e860b5f44a8c blake3:b2e278b7503a88d38c307f96af9ba644c5d5c2af1b5ba521b4ae0ea934e01db8
+needs alpha beta 8e885832de2e7123555c47803547161c02196646b270d41078d8b16d4beaf765
+needs alpha gamma 7fdff014cb20a0af5b5a5b377532292be29fc15da36d434944ad4521e69de5b3
+component beta 8e885832de2e7123555c47803547161c02196646b270d41078d8b16d4beaf765 blake3:0e908df01d8f05dcd90f9767ee4f8212365c816e5099099491fcb035d0393fa0
+needs beta gamma 7fdff014cb20a0af5b5a5b377532292be29fc15da36d434944ad4521e69de5b3
+component gamma 7fdff014cb20a0af5b5a5b377532292be29fc15da36d434944ad4521e69de5b3 blake3:d17162bc8434a689bdc83a101a396bb872c0aca59c6bd2e4d8adbbbce92eb19a
diff --git a/crates/aien-closure/tests/fixtures/seeded/crates/alpha/Cargo.toml b/crates/aien-closure/tests/fixtures/seeded/crates/alpha/Cargo.toml
new file mode 100644
index 00000000..a200e669
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/seeded/crates/alpha/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "alpha"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+beta = { path = "../beta" }
diff --git a/crates/aien-closure/tests/fixtures/seeded/crates/alpha/closure.toml b/crates/aien-closure/tests/fixtures/seeded/crates/alpha/closure.toml
new file mode 100644
index 00000000..a9a0df3c
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/seeded/crates/alpha/closure.toml
@@ -0,0 +1,6 @@
+closure-manifest v1
+component alpha
+profile host-v1
+receipt 54f597d22b3753e47d6bd7706b6a7a422c189024912ec4626347e860b5f44a8c
+source blake3:b2e278b7503a88d38c307f96af9ba644c5d5c2af1b5ba521b4ae0ea934e01db8
+dep beta 8e885832de2e7123555c47803547161c02196646b270d41078d8b16d4beaf765
diff --git a/crates/aien-closure/tests/fixtures/seeded/crates/alpha/src/lib.rs b/crates/aien-closure/tests/fixtures/seeded/crates/alpha/src/lib.rs
new file mode 100644
index 00000000..bc9495e7
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/seeded/crates/alpha/src/lib.rs
@@ -0,0 +1 @@
+pub fn alpha() -> u32 { beta::beta() + 1 }
diff --git a/crates/aien-closure/tests/fixtures/seeded/crates/beta/Cargo.toml b/crates/aien-closure/tests/fixtures/seeded/crates/beta/Cargo.toml
new file mode 100644
index 00000000..ffc44ba2
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/seeded/crates/beta/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "beta"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+gamma = { path = "../gamma" }
diff --git a/crates/aien-closure/tests/fixtures/seeded/crates/beta/closure.toml b/crates/aien-closure/tests/fixtures/seeded/crates/beta/closure.toml
new file mode 100644
index 00000000..5b461cc1
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/seeded/crates/beta/closure.toml
@@ -0,0 +1,6 @@
+closure-manifest v1
+component beta
+profile host-v1
+receipt 8e885832de2e7123555c47803547161c02196646b270d41078d8b16d4beaf765
+source blake3:0e908df01d8f05dcd90f9767ee4f8212365c816e5099099491fcb035d0393fa0
+dep gamma 7fdff014cb20a0af5b5a5b377532292be29fc15da36d434944ad4521e69de5b3
diff --git a/crates/aien-closure/tests/fixtures/seeded/crates/beta/src/lib.rs b/crates/aien-closure/tests/fixtures/seeded/crates/beta/src/lib.rs
new file mode 100644
index 00000000..1c2499b7
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/seeded/crates/beta/src/lib.rs
@@ -0,0 +1 @@
+pub fn beta() -> u32 { gamma::gamma() + 2 }
diff --git a/crates/aien-closure/tests/fixtures/seeded/crates/gamma/Cargo.toml b/crates/aien-closure/tests/fixtures/seeded/crates/gamma/Cargo.toml
new file mode 100644
index 00000000..f0c1c373
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/seeded/crates/gamma/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "gamma"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+
diff --git a/crates/aien-closure/tests/fixtures/seeded/crates/gamma/closure.toml b/crates/aien-closure/tests/fixtures/seeded/crates/gamma/closure.toml
new file mode 100644
index 00000000..9b05bd59
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/seeded/crates/gamma/closure.toml
@@ -0,0 +1,5 @@
+closure-manifest v1
+component gamma
+profile host-v1
+receipt 7fdff014cb20a0af5b5a5b377532292be29fc15da36d434944ad4521e69de5b3
+source blake3:d17162bc8434a689bdc83a101a396bb872c0aca59c6bd2e4d8adbbbce92eb19a
diff --git a/crates/aien-closure/tests/fixtures/seeded/crates/gamma/src/lib.rs b/crates/aien-closure/tests/fixtures/seeded/crates/gamma/src/lib.rs
new file mode 100644
index 00000000..62effd14
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/seeded/crates/gamma/src/lib.rs
@@ -0,0 +1 @@
+pub fn gamma() -> u32 { 3 }
diff --git a/crates/aien-closure/tests/fixtures/seeded/store/receipts/54f597d22b3753e47d6bd7706b6a7a422c189024912ec4626347e860b5f44a8c.json b/crates/aien-closure/tests/fixtures/seeded/store/receipts/54f597d22b3753e47d6bd7706b6a7a422c189024912ec4626347e860b5f44a8c.json
new file mode 100644
index 00000000..871a03bc
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/seeded/store/receipts/54f597d22b3753e47d6bd7706b6a7a422c189024912ec4626347e860b5f44a8c.json
@@ -0,0 +1,42 @@
+{
+  "schema": "EvidenceReceiptV1",
+  "version": 1,
+  "id": "54f597d22b3753e47d6bd7706b6a7a422c189024912ec4626347e860b5f44a8c",
+  "kind": "component-qualification",
+  "tier": "HOST_TEST",
+  "result": "PASS",
+  "timestamp": 1786000000,
+  "repo": "https://github.com/aien-dev/aien-sovereign-core",
+  "commit": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+  "dirty": false,
+  "toolchain": "rustc fixture",
+  "procedure": "cargo test -p alpha",
+  "machine": "host",
+  "env_class": "HOST_TEST",
+  "input_artifacts": [
+    "blake3:b2e278b7503a88d38c307f96af9ba644c5d5c2af1b5ba521b4ae0ea934e01db8"
+  ],
+  "output_artifacts": [],
+  "assertions": [
+    {
+      "id": "cargo_test_pass",
+      "expected": "pass",
+      "observed": "pass",
+      "pass": true,
+      "source": "cargo",
+      "note": ""
+    }
+  ],
+  "dependencies": [
+    "8e885832de2e7123555c47803547161c02196646b270d41078d8b16d4beaf765"
+  ],
+  "declared_mutation": "NONE",
+  "observed_mutation": "NONE",
+  "authority": "",
+  "output_digest": "644a9bc57c6063e2ba4028fa73ed585170ae7db8ac7723d32be49c021a0225f5",
+  "external_refs": [],
+  "ledger": null,
+  "lease": null,
+  "required_features": [],
+  "reserved": ""
+}
diff --git a/crates/aien-closure/tests/fixtures/seeded/store/receipts/7fdff014cb20a0af5b5a5b377532292be29fc15da36d434944ad4521e69de5b3.json b/crates/aien-closure/tests/fixtures/seeded/store/receipts/7fdff014cb20a0af5b5a5b377532292be29fc15da36d434944ad4521e69de5b3.json
new file mode 100644
index 00000000..3a968a12
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/seeded/store/receipts/7fdff014cb20a0af5b5a5b377532292be29fc15da36d434944ad4521e69de5b3.json
@@ -0,0 +1,40 @@
+{
+  "schema": "EvidenceReceiptV1",
+  "version": 1,
+  "id": "7fdff014cb20a0af5b5a5b377532292be29fc15da36d434944ad4521e69de5b3",
+  "kind": "component-qualification",
+  "tier": "HOST_TEST",
+  "result": "PASS",
+  "timestamp": 1786000000,
+  "repo": "https://github.com/aien-dev/aien-sovereign-core",
+  "commit": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+  "dirty": false,
+  "toolchain": "rustc fixture",
+  "procedure": "cargo test -p gamma",
+  "machine": "host",
+  "env_class": "HOST_TEST",
+  "input_artifacts": [
+    "blake3:d17162bc8434a689bdc83a101a396bb872c0aca59c6bd2e4d8adbbbce92eb19a"
+  ],
+  "output_artifacts": [],
+  "assertions": [
+    {
+      "id": "cargo_test_pass",
+      "expected": "pass",
+      "observed": "pass",
+      "pass": true,
+      "source": "cargo",
+      "note": ""
+    }
+  ],
+  "dependencies": [],
+  "declared_mutation": "NONE",
+  "observed_mutation": "NONE",
+  "authority": "",
+  "output_digest": "039b3fa6c7a5987c410ffe6d58ab194dfc98840263841bc7c949bdd4497fd576",
+  "external_refs": [],
+  "ledger": null,
+  "lease": null,
+  "required_features": [],
+  "reserved": ""
+}
diff --git a/crates/aien-closure/tests/fixtures/seeded/store/receipts/8e885832de2e7123555c47803547161c02196646b270d41078d8b16d4beaf765.json b/crates/aien-closure/tests/fixtures/seeded/store/receipts/8e885832de2e7123555c47803547161c02196646b270d41078d8b16d4beaf765.json
new file mode 100644
index 00000000..3753b88e
--- /dev/null
+++ b/crates/aien-closure/tests/fixtures/seeded/store/receipts/8e885832de2e7123555c47803547161c02196646b270d41078d8b16d4beaf765.json
@@ -0,0 +1,42 @@
+{
+  "schema": "EvidenceReceiptV1",
+  "version": 1,
+  "id": "8e885832de2e7123555c47803547161c02196646b270d41078d8b16d4beaf765",
+  "kind": "component-qualification",
+  "tier": "HOST_TEST",
+  "result": "PASS",
+  "timestamp": 1786000000,
+  "repo": "https://github.com/aien-dev/aien-sovereign-core",
+  "commit": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+  "dirty": false,
+  "toolchain": "rustc fixture",
+  "procedure": "cargo test -p beta",
+  "machine": "host",
+  "env_class": "HOST_TEST",
+  "input_artifacts": [
+    "blake3:0e908df01d8f05dcd90f9767ee4f8212365c816e5099099491fcb035d0393fa0"
+  ],
+  "output_artifacts": [],
+  "assertions": [
+    {
+      "id": "cargo_test_pass",
+      "expected": "pass",
+      "observed": "pass",
+      "pass": true,
+      "source": "cargo",
+      "note": ""
+    }
+  ],
+  "dependencies": [
+    "7fdff014cb20a0af5b5a5b377532292be29fc15da36d434944ad4521e69de5b3"
+  ],
+  "declared_mutation": "NONE",
+  "observed_mutation": "NONE",
+  "authority": "",
+  "output_digest": "c607f0e66519ff41d34c1c8e2e312228c3cc358c0a5b75cef4b22cf8ed3875db",
+  "external_refs": [],
+  "ledger": null,
+  "lease": null,
+  "required_features": [],
+  "reserved": ""
+}