Skip to main content

spec_driven_docs/commands/
verify.rs

1//! `verify` subcommand: runtime-shape.
2//!
3//! Resolves the target, runs the verifier, prints its report, and turns any
4//! failure into the red exit. Verification semantics live in
5//! `services::verifier`.
6
7use crate::cli::verify::VerifyArgs;
8use crate::context::AppContext;
9use crate::error::AppError;
10use crate::output;
11use crate::services::verifier::verify;
12
13/// Verify an installed instance offline.
14///
15/// # Errors
16///
17/// [`AppError::Violations`] when checks failed; manifest and I/O errors
18/// when the verifier could not run.
19pub fn run(ctx: &AppContext, args: VerifyArgs) -> Result<(), AppError> {
20    let target = if args.target.is_absolute() {
21        args.target
22    } else if args.target == "." {
23        ctx.cwd.clone()
24    } else {
25        return Err(AppError::Usage("target must be absolute or .".to_string()));
26    };
27    let report = verify(
28        &target,
29        &crate::release::embedded::EmbeddedReleaseBundle::new(),
30    )?;
31    for line in &report.lines {
32        output::line(line);
33    }
34    if report.failures > 0 {
35        return Err(AppError::Violations {
36            count: report.failures,
37        });
38    }
39    Ok(())
40}