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
impl Learner
pub fn new(provider: Box<dyn Provider>, model: Option<String>) -> Self
pub fn model(&self) -> &str
Sourcepub async fn learn(
&self,
domain: &str,
user_rules: &[Rule],
learned_rules: &[Rule],
reflexions: &[Reflexion],
tallies: &BTreeMap<String, RuleTally>,
) -> Result<Option<Vec<Rule>>>
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.