Skip to main content

ConfigDiff

Struct ConfigDiff 

Source
pub struct ConfigDiff {
    pub rules_to_rerun: HashSet<String>,
    pub rules_disabled: HashSet<String>,
    pub allow_lists_changed: bool,
    pub severities_changed: bool,
    pub walk_exclude_changed: bool,
}
Expand description

Surgical-invalidation diff between two rule configurations.

Produced by ConfigDiff::compute to classify what changed between an old (RulesConfig, WalkConfig) snapshot and a new one. Consumers (the daemon’s config-reload handler) use the classification to pick the cheapest correct invalidation strategy:

  • Tier 1 (filter-only): severities, allow-lists, or enabled = false changed. The cached findings are still correct — applying the new config’s filter at serve time is enough. No re-evaluation.
  • Tier 2 (per-rule re-run): specific rules’ behavior changed (newly enabled, rule-specific config field, or backing .scm file edited). Only those rules need to be re-evaluated; everything else stays cached.
  • Tier 3 (full reprime): [walk] exclude changed (file set differs) or the diff doesn’t fit the above. Conservative fallback.

.scm rule-definition file diffs are tracked outside this struct because this crate has no filesystem dependency; the daemon hashes .normalize/rules/** itself and unions its result into rules_to_rerun before consulting ConfigDiff::is_filter_only / ConfigDiff::requires_full_reprime.

Fields§

§rules_to_rerun: HashSet<String>

Rules whose evaluation behavior changed (newly-enabled, rule-specific config field, or .scm definition edited). These need to be re-run.

§rules_disabled: HashSet<String>

Rules that became disabled. Their cached findings should be dropped at serve time (no re-run needed).

§allow_lists_changed: bool

True if any allow-list (per-rule allow or top-level global-allow) changed without a corresponding behavior change. Filter at serve time.

§severities_changed: bool

True if any rule’s severity changed without a corresponding behavior change. Override severity at serve time.

§walk_exclude_changed: bool

True if [walk] exclude changed. Forces a full reprime (Tier 3) because the file set may differ.

Implementations§

Source§

impl ConfigDiff

Source

pub fn compute( old_rules: &RulesConfig, new_rules: &RulesConfig, old_walk: &WalkConfig, new_walk: &WalkConfig, ) -> Self

Compute a diff describing what changed between old and new.

The diff classifies each per-rule change into the cheapest tier that’s still correct. Adding/removing a rule entry that flips enabled from the implicit default is treated the same as toggling it explicitly.

Source

pub fn is_filter_only(&self) -> bool

True if this diff can be honored by re-filtering cached findings at serve time, with no re-evaluation.

Specifically: no rule needs re-running and [walk] exclude is unchanged. Allow-list, severity, and enabled = false changes are all filter-only because the cached findings are a superset of the new answer — dropping disabled rules / allow-matched paths and overriding severities at serve time produces the correct result.

Source

pub fn requires_full_reprime(&self) -> bool

True if this diff requires a full reprime (Tier 3).

Today only walk_exclude_changed triggers this; future fields that can’t be expressed as either filter-only or per-rule re-run should extend this check.

Source

pub fn is_empty(&self) -> bool

True if this diff has no observable effect.

Trait Implementations§

Source§

impl Clone for ConfigDiff

Source§

fn clone(&self) -> ConfigDiff

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 ConfigDiff

Source§

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

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

impl Default for ConfigDiff

Source§

fn default() -> ConfigDiff

Returns the “default value” for a type. Read more

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.