LearningManager

Struct LearningManager 

Source
pub struct LearningManager { /* private fields */ }
Expand description

Central coordinator for all learning operations

Implementations§

Source§

impl LearningManager

Source

pub fn new(scope: RuleScope) -> Self

Create a new learning manager with the specified scope

Source

pub fn with_config(config: LearningConfig) -> Result<Self>

Create a new learning manager with custom configuration

Source

pub async fn get_config(&self) -> LearningConfig

Get the current configuration

Source

pub async fn set_config(&self, config: LearningConfig) -> Result<()>

Update the configuration

Source

pub async fn get_scope(&self) -> RuleScope

Get the current learning scope

Source

pub async fn is_enabled(&self) -> bool

Check if learning is enabled

Source

pub async fn set_enabled(&self, enabled: bool)

Enable or disable learning

Source

pub async fn load_scope_configuration(&self) -> Result<ScopeConfiguration>

Load scope configuration from project/user/defaults hierarchy

Source

pub async fn get_scope_configuration(&self) -> ScopeConfiguration

Get the current scope configuration

Source

pub async fn set_scope_configuration( &self, config: ScopeConfiguration, ) -> Result<()>

Update the scope configuration

Source

pub async fn is_scope_learning_enabled(&self) -> bool

Check if learning is enabled for the current scope

Source

pub async fn set_scope_learning_enabled(&self, enabled: bool)

Enable or disable learning for the current scope

Source

pub async fn is_project_only_learning(&self) -> bool

Check if project-only learning is enabled

Source

pub async fn set_project_only_learning(&self, project_only: bool)

Enable or disable project-only learning

Source

pub async fn is_approval_required(&self) -> bool

Check if approval is required for new rules

Source

pub async fn set_approval_required(&self, required: bool)

Enable or disable approval requirement for new rules

Source

pub async fn get_max_rules(&self) -> usize

Get the maximum number of rules for the current scope

Source

pub async fn set_max_rules(&self, max_rules: usize) -> Result<()>

Set the maximum number of rules for the current scope

Source

pub async fn get_retention_days(&self) -> u32

Get the retention period in days for the current scope

Source

pub async fn set_retention_days(&self, retention_days: u32) -> Result<()>

Set the retention period in days for the current scope

Source

pub async fn save_scope_configuration_to_project(&self) -> Result<()>

Save scope configuration to project-level config file

Source

pub async fn save_scope_configuration_to_user(&self) -> Result<()>

Save scope configuration to user-level config file

Source

pub async fn get_rules_for_scope(&self) -> Result<Vec<Rule>>

Get rules filtered by current scope

Source

pub async fn get_rules_by_scope(&self, scope: RuleScope) -> Result<Vec<Rule>>

Get rules filtered by specific scope

Source

pub async fn check_scope_interference( &self, scope1: RuleScope, scope2: RuleScope, ) -> Result<bool>

Check if rules from different scopes interfere

Source

pub async fn capture_decision(&self, decision: Decision) -> Result<String>

Capture a decision with full metadata

Source

pub async fn get_decisions(&self) -> Vec<Decision>

Get all captured decisions

Source

pub async fn get_decisions_by_type(&self, decision_type: &str) -> Vec<Decision>

Get decisions by type

Source

pub async fn get_decisions_by_context( &self, context: &DecisionContext, ) -> Vec<Decision>

Get decisions by context

Source

pub async fn get_decision(&self, decision_id: &str) -> Result<Decision>

Get a specific decision by ID

Source

pub async fn replay_decisions(&self) -> Vec<Decision>

Replay decisions for validation

Source

pub async fn replay_decisions_for_context( &self, context: &DecisionContext, ) -> Vec<Decision>

Replay decisions for a specific context

Source

pub async fn decision_count(&self) -> usize

Get the number of captured decisions

Source

pub async fn clear_decisions(&self)

Clear all decisions

Source

pub async fn get_decision_statistics(&self) -> DecisionStatistics

Get decision statistics

Source

pub async fn store_rule(&self, rule: Rule) -> Result<String>

Store a rule (with validation)

Source

pub async fn get_rule(&self, rule_id: &str) -> Result<Rule>

Get a rule by ID

Source

pub async fn get_rules(&self) -> Result<Vec<Rule>>

Get all rules

Source

pub async fn delete_rule(&self, rule_id: &str) -> Result<()>

Delete a rule

Source

pub async fn update_rule(&self, rule: Rule) -> Result<String>

Update a rule (with validation)

Source

pub fn validate_rule(&self, rule: &Rule) -> Result<()>

Validate a rule without storing it

Source

pub fn validate_rule_with_report(&self, rule: &Rule) -> ValidationReport

Get a detailed validation report for a rule

Source

pub async fn check_rule_conflicts(&self, rule: &Rule) -> Result<()>

Check if a rule conflicts with existing rules

Source

pub async fn get_rules_by_pattern(&self, pattern: &str) -> Result<Vec<Rule>>

Get rules by pattern

Source

pub async fn get_rules_by_source(&self, source: RuleSource) -> Result<Vec<Rule>>

Get rules by source

Source

pub async fn get_rules_by_confidence( &self, min_confidence: f32, ) -> Result<Vec<Rule>>

Get rules by confidence

Source

pub async fn get_rules_by_usage(&self) -> Result<Vec<Rule>>

Get rules sorted by usage

Source

pub async fn get_rules_by_usage_count( &self, min_usage: u64, ) -> Result<Vec<Rule>>

Get rules by usage count

Source

pub async fn get_rules_by_success_rate( &self, min_success_rate: f32, ) -> Result<Vec<Rule>>

Get rules by success rate

Source

pub async fn rule_count(&self) -> Result<usize>

Get rule count

Source

pub async fn clear_rules(&self) -> Result<()>

Clear all rules

Source

pub async fn load_rules(&self) -> Result<()>

Load all rules into cache

Source

pub fn detect_rule_conflict(rule1: &Rule, rule2: &Rule) -> bool

Detect if two rules conflict

Source

pub async fn find_rule_conflicts(&self) -> Result<Vec<(Rule, Rule)>>

Find all conflicts in the current rules

Source

pub async fn check_rule_conflicts_before_storage( &self, rule: &Rule, ) -> Result<()>

Check if a rule conflicts with existing rules before storage

Source

pub async fn get_rule_by_pattern_with_precedence( &self, pattern: &str, ) -> Result<Option<Rule>>

Apply scope precedence to get the highest priority rule for a pattern

Source

pub async fn get_rules_by_pattern_with_precedence( &self, pattern: &str, ) -> Result<Vec<Rule>>

Get all rules for a pattern, applying scope precedence

Source

pub async fn resolve_all_conflicts(&self) -> Result<Vec<Rule>>

Resolve conflicts in all rules by applying scope precedence

Source

pub async fn check_cross_scope_conflicts( &self, project_rules: &[Rule], global_rules: &[Rule], ) -> Vec<(Rule, Rule)>

Check for conflicts between project and global rules

Source

pub fn log_conflict_resolution( selected_rule: &Rule, conflicting_rules: &[Rule], ) -> String

Log conflict resolution decision

Source

pub async fn store_pattern(&self, pattern: LearnedPattern) -> Result<String>

Store a pattern

Source

pub async fn get_pattern(&self, pattern_id: &str) -> Result<LearnedPattern>

Get a pattern

Source

pub async fn get_patterns(&self) -> Vec<LearnedPattern>

Get all patterns

Source

pub async fn get_patterns_by_type( &self, pattern_type: &str, ) -> Vec<LearnedPattern>

Get patterns by type

Source

pub async fn delete_pattern(&self, pattern_id: &str) -> Result<()>

Delete a pattern

Source

pub fn get_scope_path(&self, scope: RuleScope) -> Result<PathBuf>

Get the storage path for a given scope

Source

pub async fn extract_patterns(&self) -> Result<Vec<LearnedPattern>>

Extract patterns from decision history

Source

pub async fn extract_patterns_with_analysis( &self, ) -> Result<Vec<(LearnedPattern, PatternAnalysis)>>

Extract patterns from decision history with detailed analysis

Source

pub async fn validate_pattern(&self, pattern: &LearnedPattern) -> Result<f32>

Validate a pattern against historical decisions

Source

pub async fn update_pattern_confidence( &self, pattern_id: &str, validation_score: f32, ) -> Result<()>

Update pattern confidence based on validation results

Source

pub async fn validate_pattern_comprehensive( &self, pattern: &LearnedPattern, ) -> Result<ValidationResult>

Validate a pattern using the pattern validator

Source

pub async fn validate_patterns( &self, patterns: &[LearnedPattern], ) -> Result<Vec<ValidationResult>>

Validate multiple patterns

Source

pub async fn get_pattern_validation_statistics( &self, ) -> Result<ValidationStatistics>

Get validation statistics for all stored patterns

Source

pub async fn validate_and_update_pattern( &self, pattern_id: &str, ) -> Result<ValidationResult>

Validate and update pattern confidence based on validation results

Source

pub async fn capture_and_store_patterns(&self) -> Result<Vec<String>>

Capture patterns from recent decisions and store them

Source

pub async fn get_patterns_by_confidence( &self, min_confidence: f32, ) -> Vec<LearnedPattern>

Get patterns by confidence threshold

Source

pub async fn get_patterns_by_confidence_sorted(&self) -> Vec<LearnedPattern>

Get patterns sorted by confidence

Source

pub async fn get_patterns_by_occurrences(&self) -> Vec<LearnedPattern>

Get patterns sorted by occurrences

Source

pub async fn pattern_count(&self) -> usize

Get pattern count

Source

pub async fn clear_patterns(&self)

Clear all patterns

Source

pub async fn request_rule_promotion(&self, rule: Rule) -> Result<RuleReview>

Request promotion of a rule from project to global scope

Source

pub async fn get_pending_promotion(&self, rule_id: &str) -> Result<RuleReview>

Get a pending promotion for review

Source

pub async fn get_pending_promotions(&self) -> Vec<RuleReview>

Get all pending promotions

Source

pub async fn pending_promotion_count(&self) -> usize

Get the number of pending promotions

Source

pub async fn approve_promotion( &self, rule_id: &str, reason: Option<String>, ) -> Result<Rule>

Approve a pending promotion and store the promoted rule

Source

pub async fn reject_promotion( &self, rule_id: &str, reason: Option<String>, ) -> Result<()>

Reject a pending promotion

Source

pub async fn get_promotion_history(&self) -> Vec<PromotionHistoryEntry>

Get promotion history

Source

pub async fn get_promotion_history_for_rule( &self, rule_id: &str, ) -> Vec<PromotionHistoryEntry>

Get promotion history for a specific rule

Source

pub async fn get_approved_promotions(&self) -> Vec<PromotionHistoryEntry>

Get approved promotions from history

Source

pub async fn get_rejected_promotions(&self) -> Vec<PromotionHistoryEntry>

Get rejected promotions from history

Source

pub async fn clear_pending_promotions(&self)

Clear all pending promotions

Source

pub async fn clear_promotion_history(&self)

Clear promotion history

Source

pub async fn apply_rule_to_context( &self, rule: &Rule, context: &GenerationContext, ) -> RuleApplicationResult

Apply a single rule to a generation context

Source

pub async fn apply_rules_to_context( &self, rules: &[Rule], context: &GenerationContext, ) -> Vec<RuleApplicationResult>

Apply multiple rules to a generation context

Source

pub async fn apply_rules_with_precedence( &self, rules: &[Rule], context: &GenerationContext, ) -> Option<RuleApplicationResult>

Apply rules with precedence to get the best matching rule

Source

pub async fn chain_rules( &self, rules: &[Rule], context: &GenerationContext, ) -> Result<Vec<RuleApplicationResult>>

Chain multiple rules together for sequential application

Source

pub async fn compose_rules( &self, rules: &[Rule], context: &GenerationContext, ) -> Result<Option<String>>

Compose multiple rules into a single action

Source

pub async fn validate_rule_application( &self, rule: &Rule, context: &GenerationContext, ) -> Result<()>

Validate that a rule can be applied to a context

Source

pub async fn get_matching_rules( &self, context: &GenerationContext, ) -> Result<Vec<Rule>>

Get all matching rules for a context

Source

pub async fn get_matching_rules_sorted( &self, context: &GenerationContext, ) -> Result<Vec<Rule>>

Get matching rules sorted by confidence

Source

pub async fn get_matching_rules_by_usage( &self, context: &GenerationContext, ) -> Result<Vec<Rule>>

Get matching rules sorted by usage

Source

pub async fn get_matching_rules_by_success( &self, context: &GenerationContext, ) -> Result<Vec<Rule>>

Get matching rules sorted by success rate

Source

pub async fn apply_learned_rules_to_generation( &self, context: &GenerationContext, ) -> Result<Option<String>>

Apply learned rules to guide code generation

Source

pub async fn apply_learned_rules_get_all( &self, context: &GenerationContext, ) -> Result<Vec<String>>

Apply learned rules and get all matching actions

Source

pub async fn apply_learned_rules_with_context( &self, generation_type: String, language: String, input: String, ) -> Result<Option<String>>

Apply learned rules with context-based matching

Source

pub async fn record_rule_application( &self, rule_id: String, success: bool, application_time_ms: f64, ) -> Result<()>

Record a rule application in analytics

Source

pub async fn get_rule_metrics( &self, rule_id: &str, ) -> Result<Option<RuleMetrics>>

Get metrics for a specific rule

Source

pub async fn get_all_rule_metrics(&self) -> Result<Vec<RuleMetrics>>

Get all rule metrics

Source

pub async fn update_rule_confidence( &self, rule_id: &str, new_confidence: f32, ) -> Result<()>

Update rule confidence based on validation results

Source

pub async fn generate_analytics_insights(&self) -> Result<AnalyticsInsights>

Generate analytics insights

Source

pub async fn clear_analytics_metrics(&self) -> Result<()>

Clear all analytics metrics

Source

pub async fn get_metrics_for_scope( &self, scope: RuleScope, ) -> Result<Vec<RuleMetrics>>

Get metrics for rules in a specific scope

Source

pub async fn export_rules_with_metrics( &self, description: Option<String>, ) -> Result<String>

Export rules with metrics to JSON

Source

pub async fn export_rules_to_file( &self, path: &Path, description: Option<String>, ) -> Result<()>

Export rules with metrics to file

Source

pub async fn import_rules_from_json(&self, json: &str) -> Result<Vec<Rule>>

Import rules from JSON with validation

Source

pub async fn import_rules_from_file(&self, path: &Path) -> Result<Vec<Rule>>

Import rules from file with validation

Source

pub async fn import_and_validate_rules( &self, json: &str, ) -> Result<(Vec<Rule>, Vec<String>)>

Import and validate rules, returning both valid and invalid rules

Source

pub async fn store_imported_rules( &self, rules: Vec<Rule>, ) -> Result<Vec<String>>

Store imported rules

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more