From 715bbe18b53545a94155f916f33b62589aeb9399 Mon Sep 17 00:00:00 2001 From: Archipelago Date: Mon, 16 Nov 2026 20:50:54 +0300 Subject: [PATCH] Load managed layers with the native artifact verifier --- Cargo.lock | 3 +++ SERVICE.md | 19 +++++++++++++++++++ src/service/overlay_build.rs | 8 +------- src/service/overlays.rs | 12 +++--------- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c9718bd..3a04245 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,7 +37,10 @@ name = "archipelago-composer" version = "0.0.0" dependencies = [ "archipelago-contracts", + "libc", + "serde", "serde_json", + "sha2", ] [[package]] diff --git a/SERVICE.md b/SERVICE.md index 1e5c874..d6cb4a9 100644 --- a/SERVICE.md +++ b/SERVICE.md @@ -1,5 +1,24 @@ # archipelagod implementation checkpoint +## 2026-11-16 checkpoint: native artifact verification on the overlay path + +Managed Overlay planning no longer shells out to `python3 artifact.py`. Every +`load_layer` (PrepareSet, catalog refresh, update reapplication) and every rebuilt +overlay called `python3`, waited for a JSON document and then converted it in Rust. +`archipelago_composer::artifact::inspect` now runs the equivalent verification +in-process (`composer/src/check.rs`): strict metadata JSON without duplicate keys or +fractional numbers, lock/manifest/index binding, original ALPM identity, payload +identity with xattrs, authored sources, canonical package-contribution identity and a +complete payload-tree accounting walk. The Python checker stays embedded only for the +Python overlay-build adapters that still run inside the build sandbox. + +Seven Rust tests mirror the Python acceptance and rejection cases (valid artifact, +changed bytes, unindexed payload, substituted index, authored mismatch, metadata +symlink, persistent path). Composer now depends on `serde`, `sha2` and `libc` +(xattrs) with regenerated lockfiles; `cargo test --locked` passes for composer +(23 + 5), system (40 + 5) and the CLI (4). The Python fixtures remain for the sandbox +checker and require root because they verify ownership against uid 0. + ## 2026-11-16 checkpoint: local package import works on an installed host `archipelago extension add ./package.pkg.tar.zst` (and `--file PATH`) now routes diff --git a/src/service/overlay_build.rs b/src/service/overlay_build.rs index 01b0e56..b16b28a 100644 --- a/src/service/overlay_build.rs +++ b/src/service/overlay_build.rs @@ -54,13 +54,7 @@ pub(crate) fn rebuild(worker: &Worker, ordinal: u32, base: &Path, let checkout = parent.join(format!("rebuilt-{ordinal}")); worker.command("/usr/bin/ostree", &["--repo=/sysroot/ostree/repo", "checkout", "--force-copy", commit, checkout.to_str().ok_or_else(|| fail("Invalid built checkout path"))?], Duration::from_secs(600), true)?; - let checker = parent.join("rebuilt-artifact.py"); - fs::write(&checker, archipelago_composer::artifact::CHECKER).map_err(storage::io_error)?; - fs::write(parent.join("materialize.py"), archipelago_composer::MATERIALIZER).map_err(storage::io_error)?; - let output = worker.command("/usr/bin/python3", &["-I", "-B", checker.to_str().ok_or_else(|| fail("Invalid checker path"))?, - checkout.to_str().ok_or_else(|| fail("Invalid checkout path"))?], Duration::from_secs(600), true)?; - let checked = serde_json::from_str(&output).map_err(|_| fail("Invalid rebuilt artifact output"))?; - let artifact = archipelago_composer::artifact::read_checked(&checkout, commit, checked).map_err(fail)?; + let artifact = archipelago_composer::artifact::inspect(&checkout, commit).map_err(fail)?; if artifact.layer.id != source.layer.id || artifact.manifest != source.manifest || artifact.layer.header.snapshot_id != snapshot || artifact.lock_sha256 != result["lock_sha256"].as_str().unwrap_or("") { return Err(fail("Rebuilt artifact differs from requested declaration/target")); diff --git a/src/service/overlays.rs b/src/service/overlays.rs index 7d8ecca..a8e86c7 100644 --- a/src/service/overlays.rs +++ b/src/service/overlays.rs @@ -362,15 +362,9 @@ pub(crate) fn load_layer(worker: &Worker, commit: &str, offline: bool) -> Result worker.events.effect("overlay_workspace", json!(worker.events.id()))?; let checkout = work.join(commit); crate::updates::managed::checkout_layer(worker, commit, &checkout, offline)?; - let checker = work.join("artifact.py"); - fs::write(&checker, artifact::CHECKER).map_err(storage::io_error)?; - fs::write(work.join("materialize.py"), archipelago_composer::MATERIALIZER).map_err(storage::io_error)?; - let output = worker.command("/usr/bin/python3", &["-I", "-B", - checker.to_str().ok_or_else(|| Failure::new(ErrorCode::ExecutionFailed, "Invalid checker path"))?, - checkout.to_str().ok_or_else(|| Failure::new(ErrorCode::ExecutionFailed, "Invalid checkout path"))?], - Duration::from_secs(600), true)?; - let checked = serde_json::from_str(&output).map_err(|_| Failure::new(ErrorCode::ExecutionFailed, "Invalid artifact checker output"))?; - let result = artifact::read_checked(&checkout, commit, checked) + // Native verification reads and hashes the checkout itself; no Python + // process hands the engine a JSON index it would have to trust. + let result = artifact::inspect(&checkout, commit) .map_err(|message| Failure::new(ErrorCode::Conflict, message))?; worker.events.effect(&format!("layer_{commit}"), json!({"commit":commit,"layer":result.layer.id, "lock_sha256":result.lock_sha256,"snapshot":result.layer.header.snapshot_id}))?;