Skip to main content

Learner

Struct Learner 

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

Runs one abstraction/consolidation pass for a domain: current learned rules + unprocessed reflections in, a rewritten learned rule set out.

One combined pass rather than a separate incremental abstraction stage: the consolidation prompt already absorbs unprocessed reflexions, and at one user’s volume an incremental stage buys nothing but a second prompt to maintain. The three-stage design survives conceptually — reflections are still the evidence, this is still abstraction, and the budget it enforces is still consolidation.

Implementations§

Source§

impl Learner

Source

pub fn new(provider: Box<dyn Provider>, model: Option<String>) -> Self

Source

pub fn model(&self) -> &str

Source

pub async fn learn( &self, domain: &str, user_rules: &[Rule], learned_rules: &[Rule], reflexions: &[Reflexion], tallies: &BTreeMap<String, RuleTally>, ) -> Result<Option<Vec<Rule>>>

Consolidate reflexions into a rewritten rule set for domain.

tallies is the validation ledger folded per rule (rule_tallies), and it is what makes a rewrite self-correcting rather than merely churning. A consolidation is a full replacement — a rule the learner omits simply vanishes, since only retired rules are carried forward by finalize_rules — so dropping is already the cheap operation. Without the ledger the learner chose what to drop from the rule text alone and was as likely to drop a rule that was working as one that was not; the measurement existed and reached retirement only, which fires at a threshold and says nothing below it.

A never-validated rule is not a bad rule. It is rendered as unmeasured and the frame says so, because “no evidence” and “evidence of harm” are opposite findings and collapsing them would retire the newest rules fastest — the ones that have had least chance to be probed.

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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