SharedRulesManager

Struct SharedRulesManager 

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

Manages rule promotion, validation, versioning, and approval workflows

This manager integrates with ricecoder-learning components to:

  • Promote rules from Project → Team → Organization scope
  • Validate rules before promotion
  • Track version history with timestamps and metadata
  • Support rollback to previous versions
  • Track adoption and effectiveness metrics

§Requirements

  • Requirement 2.1: Support promotion from Project → Team → Organization
  • Requirement 2.2: Support promotion from Team → Organization
  • Requirement 2.4: Validate rules before promotion
  • Requirement 2.5: Track adoption metrics
  • Requirement 2.6: Track effectiveness metrics
  • Requirement 2.7: Support rollback to previous versions
  • Requirement 2.8: Maintain complete version history

Implementations§

Source§

impl SharedRulesManager

Source

pub fn new( rule_promoter: Arc<dyn RulePromoter>, rule_validator: Arc<dyn RuleValidator>, analytics_engine: Arc<dyn AnalyticsEngine>, ) -> Self

Create a new SharedRulesManager with the provided components

§Arguments
  • rule_promoter - Component for handling rule promotion
  • rule_validator - Component for validating rules
  • analytics_engine - Component for tracking metrics
Source

pub async fn promote_rule( &self, rule: SharedRule, from_scope: RuleScope, to_scope: RuleScope, ) -> Result<()>

Promote a rule from one scope to another

Supports promotion from Project → Team → Organization. Uses ricecoder-learning RulePromoter for promotion logic.

§Arguments
  • rule - The rule to promote
  • from_scope - Current scope of the rule
  • to_scope - Target scope for promotion
§Errors

Returns error if promotion fails or rule is invalid

Source

pub async fn validate_rule(&self, rule: &SharedRule) -> Result<ValidationReport>

Validate a rule before promotion

Uses ricecoder-learning RuleValidator to validate rules. Returns detailed validation reports including errors and warnings.

§Arguments
  • rule - The rule to validate
§Returns

Validation report with validation status, errors, and warnings

Source

pub async fn get_rule_history(&self, rule_id: &str) -> Result<Vec<SharedRule>>

Get the complete version history for a rule

Retrieves complete version history with timestamps and promotion metadata. Uses ricecoder-learning versioning system.

§Arguments
  • rule_id - ID of the rule to get history for
§Returns

Vector of SharedRule entries representing version history

Source

pub async fn rollback_rule(&self, rule_id: &str, version: u32) -> Result<()>

Rollback a rule to a previous version

Supports rollback to previous rule versions using ricecoder-learning versioning system. This is useful when a promoted rule causes issues.

§Arguments
  • rule_id - ID of the rule to rollback
  • version - Version number to rollback to
§Errors

Returns error if version doesn’t exist or rollback fails

Source

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

Track adoption metrics for a rule

Tracks adoption metrics showing percentage of team members applying the rule. Uses ricecoder-learning AnalyticsEngine for metric calculation.

§Arguments
  • rule_id - ID of the rule to track adoption for
§Returns

AdoptionMetrics with adoption percentage and trend data

Source

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

Track effectiveness metrics for a rule

Tracks effectiveness metrics measuring positive outcomes from rule application. Uses ricecoder-learning AnalyticsEngine for metric calculation.

§Arguments
  • rule_id - ID of the rule to track effectiveness for
§Returns

EffectivenessMetrics with effectiveness score and impact trend

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