assay-cli 6.20.0

Policy-as-code gate for MCP agent tool calls, with verifiable evidence and Linux kernel enforcement.
#![allow(unsafe_code)]
use clap::Parser;

pub mod aee_run_context;
pub mod aee_seal;
pub mod aee_seal_envelope;
pub mod aee_seal_key;
#[cfg(test)]
mod aee_seal_round_trip;
pub mod aee_trust_set;
pub mod backend;
pub mod caps;
mod cli;
mod cli_failure;
pub mod diagnostics;
pub mod enforcement_health_v1;
mod env_filter;
mod evidence_verify_reason;
pub mod exit_codes;
pub mod fs;
pub mod landlock_check;
pub mod landlock_net;
pub mod metrics;
mod output_write;
pub mod packs;
pub mod policy;
pub mod profile;
pub mod setup;
mod templates;

use cli::args::Cli;
use cli::commands::dispatch;
use cli_failure::CliFailure;

#[tokio::main(flavor = "multi_thread")]
async fn main() {
    if std::env::var("RUST_LOG").is_err() {
        std::env::set_var("RUST_LOG", "info");
    }
    env_logger::init();
    let cli = Cli::parse();
    let machine_output_verify_enabled = cli.machine_output_verify_enabled();
    // The posture is resolved here, once, from the top-level flags plus the
    // live ASSAY_QUIET/ASSAY_COLOR/ASSAY_NON_INTERACTIVE environment — never
    // via clap `env =`, a global `--quiet`, or a global `--non-interactive`,
    // so no path can set another command's local flag. An invalid env value
    // is a usage error, like clap's was.
    let (quiet, color, non_interactive) = match cli.resolve_posture() {
        Ok(resolved) => resolved,
        Err(message) => {
            eprintln!("error: {message}");
            std::process::exit(2);
        }
    };
    // Fail-closed for the whole process: every prompt site reads this one
    // cell through `refuse_if_prompt_not_showable`, before any TTY check.
    cli::interaction::set_non_interactive(non_interactive);
    let legacy_mode = std::env::var("MCP_CONFIG_LEGACY").ok().as_deref() == Some("1");
    let code = match dispatch(cli, legacy_mode, quiet, color, non_interactive).await {
        Ok(code) => code,
        Err(error) => match error.downcast::<CliFailure>() {
            Ok(failure) => failure.emit(machine_output_verify_enabled, color),
            Err(error) => {
                eprintln!("fatal: {error:?}");
                2 // CONFIG_ERROR from cli::commands::exit_codes::CONFIG_ERROR ideally, but hardcoded 2 is safe here
            }
        },
    };
    std::process::exit(code);
}