pub struct Rule {Show 16 fields
pub id: String,
pub trigger: String,
pub action: String,
pub anchor_file: Option<String>,
pub anchor_hash: Option<String>,
pub created: String,
pub last_hit: String,
pub hits: u64,
pub ttl_days: u32,
pub superseded_by: Option<String>,
pub status: RuleStatus,
pub source_session: String,
pub source_event: Option<String>,
pub shows: u64,
pub revoked_reason: Option<String>,
pub category: RuleCategory,
}Expand description
A learned rule with TTL decay.
Fields§
§id: String§trigger: String§action: String§anchor_file: Option<String>§anchor_hash: Option<String>§created: String§last_hit: String§hits: u64§ttl_days: u32§superseded_by: Option<String>§status: RuleStatus§source_session: String§source_event: Option<String>§shows: u64Times this rule’s enforcement was shown to a user (e.g. PreToolUse
matches). Unlike hits, shows never update last_hit, never promote
Proposed -> Active, and never reactivate Dormant/Settled rules
(GH-813: hit-on-every-Bash-call kept noise rules alive forever).
revoked_reason: Option<String>Why this rule was revoked (only set when revoked via revoke).
category: RuleCategoryImplementations§
Source§impl Rule
impl Rule
Sourcepub fn is_enforceable(&self) -> bool
pub fn is_enforceable(&self) -> bool
Check if this rule is enforceable (Active status).
Sourcepub fn record_hit(&mut self)
pub fn record_hit(&mut self)
Record a trigger hit: increment counter and reset TTL.
Sourcepub fn record_shown(&mut self)
pub fn record_shown(&mut self)
Record that this rule’s enforcement was shown to the user.
Increments the show counter only: last_hit is NOT updated, Proposed
rules are NOT promoted, and Dormant/Settled rules are NOT reactivated
(GH-813: shows are pure statistics and must not reset the TTL).
Sourcepub fn days_since_last_hit(&self) -> Option<i64>
pub fn days_since_last_hit(&self) -> Option<i64>
Compute days since last hit.
Sourcepub fn apply_time_decay(&mut self)
pub fn apply_time_decay(&mut self)
Apply time-based decay to this rule’s status.