1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
use clap::{Parser, Subcommand};
pub mod baseline;
pub mod bundle;
pub mod common;
pub mod coverage;
pub mod describe;
pub mod evidence;
pub mod import;
pub mod mcp;
pub mod policy;
pub mod posture;
pub mod project_enforcement_health;
pub mod project_otel;
pub mod registry;
pub mod replay;
pub mod run;
pub mod runtime;
pub mod sim;
pub mod trust_basis;
pub mod trust_card;
pub use baseline::*;
pub use bundle::*;
pub use common::*;
pub use coverage::*;
pub use describe::*;
pub use evidence::*;
pub use import::*;
pub use mcp::*;
pub use policy::*;
pub use posture::*;
pub use project_enforcement_health::*;
pub use project_otel::*;
pub use registry::*;
pub use replay::*;
pub use run::*;
pub use runtime::*;
pub use sim::*;
pub use trust_basis::*;
pub use trust_card::*;
#[derive(Parser)]
#[command(
name = "assay",
version,
about = "CI-native evidence and trust compiler for agent runtime governance"
)]
pub struct Cli {
/// Suppress the `Running N tests...` banner and progress-sink lines of
/// run/ci/watch/replay only. Place BEFORE the subcommand
/// (`assay --quiet run ...`); it never silences diagnostics and never
/// reaches another command's own `--quiet`. Env ASSAY_QUIET enables the
/// same (empty counts as unset) — see docs/reference/cli.
#[arg(long, short)]
pub quiet: bool,
/// Colored operator diagnostics: auto, always, or never (global,
/// default auto). Env ASSAY_COLOR carries the same vocabulary (empty
/// counts as unset). The explicit flag beats the env.
#[arg(long, value_enum, global = true)]
pub color: Option<ColorChoice>,
/// Fail closed instead of prompting: any code path that would prompt
/// refuses with exit 2 and names the remedy. Place BEFORE the
/// subcommand (`assay --non-interactive doctor --fix ...`); it never
/// assumes defaults. Env ASSAY_NON_INTERACTIVE enables the same (empty
/// counts as unset) — see docs/reference/cli.
#[arg(long)]
pub non_interactive: bool,
#[command(subcommand)]
pub cmd: Command,
}
impl Cli {
/// Resolve the caller posture from the top-level flags plus the live
/// `ASSAY_QUIET` / `ASSAY_COLOR` / `ASSAY_NON_INTERACTIVE` environment.
/// Called once in `main` before dispatch; an invalid env value is a usage
/// error (exit 2), exactly as the old clap `env =` binding reported it.
pub(crate) fn resolve_posture(&self) -> Result<(bool, ColorChoice, bool), String> {
posture::resolve_posture_with(
self.quiet,
self.color,
self.effective_non_interactive(),
std::env::var_os(posture::QUIET_ENV).as_deref(),
std::env::var_os(posture::COLOR_ENV).as_deref(),
std::env::var_os(posture::NON_INTERACTIVE_ENV).as_deref(),
)
}
/// The effective non-interactive posture: the top-level flag OR the
/// hidden `setup --non-interactive` alias. The alias covers only the
/// setup command, but both spellings feed the same refusal check, so the
/// paths the alias covers behave identically to the top-level posture.
pub(crate) fn effective_non_interactive(&self) -> bool {
self.non_interactive || matches!(&self.cmd, Command::Setup(args) if args.non_interactive)
}
}
impl Cli {
pub(crate) fn machine_output_verify_enabled(&self) -> Option<bool> {
matches!(
&self.cmd,
Command::Policy(PolicyArgs {
cmd: PolicyCommand::Validate(args)
}) if args.is_json()
)
.then_some(true)
.or_else(|| match &self.cmd {
Command::Coverage(args)
if args.input.is_none() && args.format == Some(CoverageFormat::Json) =>
{
// Coverage has no signature-verification switch. Keep the inherited Summary
// convention used by classified machine-output paths; this flag selects the
// envelope and does not claim every internal coverage failure is classified.
Some(true)
}
Command::Evidence(EvidenceArgs {
cmd: crate::cli::commands::evidence::EvidenceCmd::Show(args),
}) if args.format == ShowFormat::Json => Some(!args.no_verify),
_ => None,
})
}
}
#[derive(Subcommand)]
pub enum Command {
/// Run an evaluation suite and write run artifacts
Run(RunArgs),
/// Run the CI gate and emit CI report artifacts
Ci(CiArgs),
/// Create starter Assay config and trace fixtures
Init(InitArgs),
/// Manage quarantined or flaky tests
Quarantine(QuarantineArgs),
/// Inspect or transform trace inputs
Trace(TraceArgs),
/// Calibrate thresholds from previous run artifacts
Calibrate(CalibrateArgs),
/// Record or compare score baselines
Baseline(BaselineArgs),
/// Validate config and trace files without a full run
Validate(ValidateArgs),
/// Diagnose local setup, config, and trace health
Doctor(DoctorArgs),
/// Watch config/policy/trace files and rerun on changes
Watch(WatchArgs),
/// Import external artifacts into Assay-compatible data
Import(ImportArgs),
/// Migrate older config or policy formats
Migrate(MigrateArgs),
/// Report policy and trace coverage
Coverage(CoverageArgs),
/// Project assay evidence into the OTel GenAI + OpenInference view (`assay.otel_projection.v0`)
ProjectOtel(ProjectOtelArgs),
/// Project one health document or verified degradation bundle
ProjectEnforcementHealth(ProjectEnforcementHealthArgs),
/// Explain a test result or trace decision
Explain(super::commands::explain::ExplainArgs),
/// Generate and run the local demo project
Demo(DemoArgs),
/// Generate CI workflow scaffolding
InitCi(InitCiArgs),
/// Apply supported automatic fixes
Fix(FixArgs),
/// MCP runtime, discovery, kill-switch, and tool signing commands
Mcp(McpArgs),
/// Registry carrier commands (supply-chain-conformance emitter)
Registry(RegistryArgs),
/// Print Assay version information
Version,
/// Enumerate the CLI contract at a command path
Describe(DescribeArgs),
/// Validate, format, and migrate policies
Policy(PolicyArgs),
/// Runtime eBPF Monitor (Linux only)
Monitor(super::commands::monitor::MonitorArgs),
/// Internal Assay-Runner Phase 1 spike command
#[cfg(feature = "runner")]
#[command(name = "runner-spike", hide = true)]
RunnerSpike(super::commands::runner_spike::RunnerSpikeArgs),
/// Manage multi-run profiles for stability analysis
Profile(super::commands::profile::ProfileArgs),
/// Run a command in a sandbox with optional Landlock filesystem and TCP-connect egress enforcement
Sandbox(SandboxArgs),
/// Evidence bundles, imports, verification, and stores
Evidence(EvidenceArgs),
/// Replay bundle management (create/verify)
Bundle(BundleArgs),
/// Replay a run from a replay bundle
Replay(ReplayArgs),
/// Attack Simulation (Hardening/Compliance)
#[cfg(feature = "sim")]
Sim(SimArgs),
/// Interactive installer and environment setup
Setup(SetupArgs),
/// Generate canonical trust-basis artifacts from verified evidence bundles
#[command(name = "trust-basis")]
TrustBasis(TrustBasisArgs),
/// Generate trust card artifacts (JSON, Markdown, and static HTML) from verified bundles
#[command(name = "trust-card", alias = "trustcard")]
TrustCard(TrustCardArgs),
}
#[derive(Parser, Debug)]
pub struct ToolArgs {
#[command(subcommand)]
pub cmd: super::commands::tool::ToolCmd,
}
#[cfg(test)]
mod tests;