From 7d0b86afb86310c398eb742e11548df33ce1f788 Mon Sep 17 00:00:00 2001 From: noah Date: Sat, 17 Oct 2026 10:03:34 -0600 Subject: [PATCH] Expose running build verification in toolkit CLI --- crates/alkane-cli/Cargo.toml | 1 + crates/alkane-cli/src/main.rs | 36 +++++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/crates/alkane-cli/Cargo.toml b/crates/alkane-cli/Cargo.toml index 64a6fc75..80479233 100644 --- a/crates/alkane-cli/Cargo.toml +++ b/crates/alkane-cli/Cargo.toml @@ -7,3 +7,4 @@ license.workspace = true [dependencies] alkane-core = { path = "../alkane-core" } alkane-artifacts = { path = "../alkane-artifacts" } +alkane-access = { path = "../alkane-access" } diff --git a/crates/alkane-cli/src/main.rs b/crates/alkane-cli/src/main.rs index 039c54bf..cd9819ad 100644 --- a/crates/alkane-cli/src/main.rs +++ b/crates/alkane-cli/src/main.rs @@ -1,14 +1,22 @@ // SPDX-License-Identifier: MIT //! Headless entry point for read-only artifact verification. +use alkane_access::{parse_build_marker, verify_build_marker, Probe, SshTarget}; use alkane_artifacts::{seed_manifest, verify_file}; +use std::io; +use std::net::IpAddr; use std::path::Path; fn run() -> Result<(), Box> { let args: Vec<_> = std::env::args().collect(); - if args.len() != 4 || args[1] != "verify-artifact" { - return Err("usage: alkane-cli verify-artifact ".into()); + match args.get(1).map(String::as_str) { + Some("verify-artifact") if args.len() == 4 => verify_artifact(&args), + Some("verify-running-build") if args.len() == 8 => verify_running_build(&args), + _ => Err("usage: alkane-cli verify-artifact \n alkane-cli verify-running-build ".into()), } +} + +fn verify_artifact(args: &[String]) -> Result<(), Box> { let record = seed_manifest()? .into_iter() .find(|item| item.path == Path::new(&args[2])) @@ -23,6 +31,30 @@ fn run() -> Result<(), Box> { Ok(()) } +fn verify_running_build(args: &[String]) -> Result<(), Box> { + let address: IpAddr = args[2].parse()?; + let expected_text = format!( + "board={}\nsdk_revision={}\nos_revision={}\n", + args[5], args[6], args[7] + ); + let expected = parse_build_marker(expected_text.as_bytes()) + .map_err(|error| io::Error::other(format!("invalid expected build: {error:?}")))?; + let target = SshTarget::new(address, 22, &args[3], Path::new(&args[4])) + .map_err(|error| io::Error::other(format!("SSH target: {error:?}")))?; + let raw = target + .probe(Probe::AlkaneBuildMarker) + .map_err(|error| io::Error::other(format!("running build read: {error:?}")))?; + let observed = parse_build_marker(&raw) + .map_err(|error| io::Error::other(format!("running build marker: {error:?}")))?; + verify_build_marker(&observed, &expected) + .map_err(|error| io::Error::other(format!("build comparison: {error:?}")))?; + println!( + "verified running build {} {} {}", + observed.board, observed.sdk_revision, observed.os_revision + ); + Ok(()) +} + fn main() { if let Err(error) = run() { eprintln!("artifact verification failed: {error}");