Skip to main content

Violation

Struct Violation 

Source
#[non_exhaustive]
pub struct Violation { pub kind: BoundaryKind, pub target: String, pub rule: String, pub finding: String, pub reason: String, pub severity: Severity, pub baselined: bool, pub file: Option<String>, pub anchor: Option<String>, pub polarity: Option<Polarity>, }
Expand description

One violated boundary. severity is the producing boundary’s severity, so the exit-code decision and the report can treat enforce and warn findings apart. baselined is set when baseline gating records the violation in a baseline; a baselined violation does not fail the reaction.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§kind: BoundaryKind

Which kind of boundary produced this violation.

§target: String

The governed target (crate name, or module path for a module boundary).

§rule: String

The rule label that was violated.

§finding: String

The offending finding (e.g. the dependency name, or the imported module path).

§reason: String

The boundary’s reason — the repair hint.

§severity: Severity

The producing boundary’s severity.

§baselined: bool

Whether this violation is recorded in the active baseline (so it does not fail).

§file: Option<String>

The offending source file, when the producing dimension genuinely observes one — a faithful byproduct of the scan (e.g. the file a forbidden import sits in). None when the violation has no single source file (a dependency edge, a seam name) or the dimension does not yet observe a per-element file. Set via Violation::with_file, not the constructor, so adding it leaves Violation::new non-breaking; it is not part of the baseline identity (Violation::id), so it never affects baseline matching.

§anchor: Option<String>

The producing boundary’s durable governance anchor — a stable pointer (e.g. "ADR-014") into the project’s governance, distinct from the free-text reason sentence, which accretes ephemeral refs (PR numbers, handles, “recently”) that rot faster than the invariant they justify. None when the boundary declared none. Set via Violation::with_anchor, not the constructor, so adding it leaves Violation::new non-breaking; like file, it is metadata, not part of the baseline identity (Violation::id), so it never affects baseline matching, and it is never a reaction input — a pure durable pointer.

§polarity: Option<Polarity>

The repair direction of a boundary-drift violation (Polarity) — DenyBreach (remove the offending code) or AllowlistGap (remove, or declare the intent). Derived from the producing rule’s type at the reaction site, set via Violation::with_polarity, not the constructor. None for a violation off the boundary-drift axis (the runtime CI-audit coverage violations), whose repair is read from the reason/finding. Like file/anchor, it is metadata: not part of the baseline identity (Violation::id) — being a pure function of the rule it is constant for a given identity anyway — and never a reaction input.

Implementations§

Source§

impl Violation

Source

pub fn new( kind: BoundaryKind, target: String, rule: String, finding: String, reason: String, severity: Severity, ) -> Violation

Build a violation an engine has just observed: baselined starts false and is set later by apply_baseline. The constructor a dimension crate needs because Violation is #[non_exhaustive] and cannot be struct-literal-built across the crate boundary.

Source

pub fn with_file(self, file: Option<String>) -> Violation

Attach the offending source file, consuming and returning self so a dimension can fold it into construction: Violation::new(…).with_file(Some(path)). Kept off Violation::new on purpose — the constructor’s signature stays stable (non-breaking) and dimensions that observe no file simply never call this. The file is metadata, never part of the baseline identity (Violation::id).

Source

pub fn with_anchor(self, anchor: Option<String>) -> Violation

Attach the producing boundary’s durable governance anchor, consuming and returning self so a dimension can fold it into construction: Violation::new(…).with_anchor(boundary…). Kept off Violation::new on purpose — the constructor’s signature stays stable (non-breaking), and a boundary that declared no anchor simply never calls this (or passes None). The anchor is metadata, never part of the baseline identity (Violation::id).

Source

pub fn with_polarity(self, polarity: Polarity) -> Violation

Stamp the violation’s repair-direction Polarity, consuming and returning self so a dimension can fold it into construction: Violation::new(…).with_polarity(rule.polarity()). Takes a concrete Polarity (not an Option) because a reaction site that stamps one always knows it; a violation off the boundary-drift axis simply never calls this, leaving None. The polarity is metadata, never part of the baseline identity (Violation::id).

Source

pub fn id(&self) -> ViolationId

The (target, rule, finding) identity used to match against a baseline.

Source

pub fn to_json(&self) -> Value

The canonical JSON rendering of one violation — the per-type projection the report-document assembly composes. The model owns this shape so every dimension renders its violations identically.

Trait Implementations§

Source§

impl Clone for Violation

Source§

fn clone(&self) -> Violation

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Violation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Violation

Source§

impl PartialEq for Violation

Source§

fn eq(&self, other: &Violation) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Violation

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.