shakrs-json-parser 0.1.0

Parser, validator, scaffolder, and canonical formatter for the shakrs.json workspace config. Zero I/O; no policy-registry knowledge.
Documentation
//! `Waiver`: a single suppression of one of our findings.

use garde::Validate;
use serde::{Deserialize, Serialize};

/// Suppresses one finding: the configured setting named by `key` at
/// `subject` (optionally narrowed by `selector`) may differ from what a
/// policy wants.
///
/// `key` is the engine's in-file key (e.g.
/// `[workspace.lints.clippy].unwrap_used`), exactly as it appears on the
/// report finding it suppresses; it is stable across Shakrs refactors.
/// The waiver never names a policy: a finding is about a config key's state,
/// not about which policy flagged it.
#[derive(Debug, Clone, Serialize, Deserialize, Validate)]
#[serde(deny_unknown_fields)]
pub struct Waiver {
    /// The engine's in-file key of the enforced setting, e.g.
    /// `[workspace.lints.clippy].unwrap_used`.
    #[garde(length(min = 1))]
    pub key: String,
    /// Workspace-relative file the finding is about, e.g. `Cargo.toml`.
    #[garde(length(min = 1))]
    pub subject: String,
    /// Optional finer locator within `subject`, for keys that can fire more
    /// than once per file (e.g. a dependency name). `None` when `key` alone
    /// identifies the finding; when present it must be non-empty.
    #[garde(inner(length(min = 1)))]
    pub selector: Option<String>,
    /// Non-empty human explanation for why the drift is accepted.
    #[garde(length(min = 1))]
    pub reason: String,
}