pub struct RulesStore {
pub rules: Vec<Rule>,
pub last_decay_run: Option<String>,
}Expand description
The rules store: manages rules.json persistence and lifecycle.
Fields§
§rules: Vec<Rule>§last_decay_run: Option<String>Implementations§
Source§impl RulesStore
impl RulesStore
Sourcepub fn load(path: &Path) -> Self
pub fn load(path: &Path) -> Self
Load rules store from disk. Returns default if file doesn’t exist.
Sourcepub fn project_rules_path(project_id: &str) -> PathBuf
pub fn project_rules_path(project_id: &str) -> PathBuf
Resolve the rules.json path for a project.
Sourcepub fn global_rules_path() -> PathBuf
pub fn global_rules_path() -> PathBuf
Resolve the global rules.json path (~/.edda/rules.json).
Sourcepub fn load_project(project_id: &str) -> Self
pub fn load_project(project_id: &str) -> Self
Load project-scoped rules.
Sourcepub fn save_project(&self, project_id: &str) -> Result<()>
pub fn save_project(&self, project_id: &str) -> Result<()>
Save project-scoped rules.
Sourcepub fn active_rules(&self) -> Vec<&Rule>
pub fn active_rules(&self) -> Vec<&Rule>
Get all active (enforceable) rules.
Sourcepub fn alive_rules(&self) -> Vec<&Rule>
pub fn alive_rules(&self) -> Vec<&Rule>
Get all alive rules (not dead/superseded).
Sourcepub fn propose_rule(
&mut self,
trigger: String,
action: String,
anchor_file: Option<String>,
category: RuleCategory,
source_session: String,
source_event: Option<String>,
) -> String
pub fn propose_rule( &mut self, trigger: String, action: String, anchor_file: Option<String>, category: RuleCategory, source_session: String, source_event: Option<String>, ) -> String
Add a new rule proposal. If a rule with the same trigger already exists and is alive, increment its hits instead (confirmation).
Sourcepub fn run_decay_cycle(&mut self)
pub fn run_decay_cycle(&mut self)
Run the full decay cycle on all rules.
- Time decay: check TTL against last_hit
- Anchor decay: check if anchored file changed
- Enforce active window cap (~15)
Sourcepub fn record_matched_shows(&mut self, matched_ids: &[String])
pub fn record_matched_shows(&mut self, matched_ids: &[String])
Record shows for matched rules. Unlike record_matched_hits, this
never resets the TTL or reactivates decayed rules (GH-813).
Sourcepub fn revoke_rule(&mut self, id: &str, reason: String) -> bool
pub fn revoke_rule(&mut self, id: &str, reason: String) -> bool
Revoke a rule by ID. Returns false when the ID is unknown.
Sourcepub fn gc_dead_rules(&mut self) -> usize
pub fn gc_dead_rules(&mut self) -> usize
Garbage-collect dead rules (remove from store entirely).
Sourcepub fn find_by_trigger(&self, trigger_pattern: &str) -> Vec<&Rule>
pub fn find_by_trigger(&self, trigger_pattern: &str) -> Vec<&Rule>
Find rules matching a given trigger pattern (substring match).
Sourcepub fn stats(&self) -> StoreStats
pub fn stats(&self) -> StoreStats
Summary statistics.
Trait Implementations§
Source§impl Clone for RulesStore
impl Clone for RulesStore
Source§fn clone(&self) -> RulesStore
fn clone(&self) -> RulesStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more