Load managed layers with the native artifact verifier
This commit is contained in:
parent
297c970bc8
commit
715bbe18b5
4 changed files with 26 additions and 16 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
|
@ -37,7 +37,10 @@ name = "archipelago-composer"
|
|||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"archipelago-contracts",
|
||||
"libc",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
19
SERVICE.md
19
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
|
||||
|
|
|
|||
|
|
@ -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"));
|
||||
|
|
|
|||
|
|
@ -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}))?;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue