Skip to main content

harn_cli/package/manifest/
check_config.rs

1use std::collections::HashMap;
2
3use serde::Deserialize;
4
5/// Severity override for preflight diagnostics. `error` (default) fails
6/// `harn check`; `warning` reports but does not fail; `off` suppresses
7/// entirely. Accepted via `[check].preflight_severity` in harn.toml so
8/// repos with hosts that do not expose every capability statically can
9/// keep the checker running on genuine type errors.
10#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
11pub enum PreflightSeverity {
12    #[default]
13    Error,
14    Warning,
15    Off,
16}
17
18impl PreflightSeverity {
19    pub fn from_opt(raw: Option<&str>) -> Self {
20        match raw.map(|s| s.to_ascii_lowercase()) {
21            Some(v) if v == "warning" || v == "warn" => Self::Warning,
22            Some(v) if v == "off" || v == "allow" || v == "silent" => Self::Off,
23            _ => Self::Error,
24        }
25    }
26}
27
28#[derive(Debug, Default, Clone, Deserialize)]
29pub struct CheckConfig {
30    #[serde(default)]
31    pub strict: bool,
32    #[serde(default)]
33    pub strict_types: bool,
34    /// Explicit operator declaration that these sources are loaded only by a
35    /// trusted Rust host-dispatch boundary.
36    #[serde(default)]
37    pub trusted_host_dispatch: bool,
38    #[serde(default)]
39    pub disable_rules: Vec<String>,
40    #[serde(default)]
41    pub host_capabilities: HashMap<String, Vec<String>>,
42    #[serde(default, alias = "host_capabilities_file")]
43    pub host_capabilities_path: Option<String>,
44    #[serde(default)]
45    pub bundle_root: Option<String>,
46    /// Downgrade or suppress preflight diagnostics. See
47    /// [`PreflightSeverity`].
48    #[serde(default, alias = "preflight-severity")]
49    pub preflight_severity: Option<String>,
50    /// List of `"capability.operation"` strings that should be accepted
51    /// by preflight without emitting a diagnostic, even if the operation
52    /// is not in the default or loaded capability manifest.
53    #[serde(default, alias = "preflight-allow")]
54    pub preflight_allow: Vec<String>,
55}