pub use brainwires_core;
pub mod api;
pub mod cache;
pub mod collector;
pub mod inference;
pub mod matcher;
pub mod truth;
pub mod personal;
pub use api::KnowledgeApiClient;
pub use cache::BehavioralKnowledgeCache;
pub use collector::{LearningCollector, detect_correction};
pub use inference::TruthInferenceEngine;
pub use matcher::ContextMatcher;
pub use truth::{BehavioralTruth, TruthCategory, TruthSource};
pub use personal::{
PersonalFact, PersonalFactCategory, PersonalFactCollector, PersonalFactMatcher,
PersonalFactSource, PersonalKnowledgeApiClient, PersonalKnowledgeCache,
PersonalKnowledgeSettings,
};
#[derive(Debug, Clone)]
pub struct KnowledgeSettings {
pub enabled: bool,
pub enable_explicit_learning: bool,
pub enable_implicit_learning: bool,
pub enable_aggressive_learning: bool,
pub min_confidence_to_apply: f32,
pub min_confidence_to_prompt: f32,
pub failure_threshold: u32,
pub ema_alpha: f32,
pub decay_days: u32,
pub sync_interval_secs: u64,
pub offline_queue_size: usize,
pub show_applied_truths: bool,
pub show_conflict_prompts: bool,
}
impl Default for KnowledgeSettings {
fn default() -> Self {
Self {
enabled: true,
enable_explicit_learning: true,
enable_implicit_learning: true,
enable_aggressive_learning: true,
min_confidence_to_apply: 0.5,
min_confidence_to_prompt: 0.7,
failure_threshold: 3,
ema_alpha: 0.1,
decay_days: 30,
sync_interval_secs: 300,
offline_queue_size: 100,
show_applied_truths: true,
show_conflict_prompts: true,
}
}
}
impl KnowledgeSettings {
pub fn full() -> Self {
Self::default()
}
pub fn explicit_only() -> Self {
Self {
enable_implicit_learning: false,
enable_aggressive_learning: false,
..Self::default()
}
}
pub fn disabled() -> Self {
Self {
enabled: false,
..Self::default()
}
}
}
pub mod prelude {
pub use super::KnowledgeSettings;
pub use super::cache::BehavioralKnowledgeCache;
pub use super::collector::LearningCollector;
pub use super::inference::TruthInferenceEngine;
pub use super::matcher::ContextMatcher;
pub use super::personal::PersonalKnowledgeCache;
pub use super::personal::{
PersonalFact, PersonalFactCategory, PersonalFactCollector, PersonalFactMatcher,
PersonalFactSource, PersonalKnowledgeSettings,
};
pub use super::truth::{BehavioralTruth, TruthCategory, TruthSource};
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_default_settings() {
let settings = KnowledgeSettings::default();
assert!(settings.enabled);
assert!(settings.enable_explicit_learning);
assert!(settings.enable_implicit_learning);
assert!(settings.enable_aggressive_learning);
assert_eq!(settings.min_confidence_to_apply, 0.5);
assert_eq!(settings.failure_threshold, 3);
}
#[test]
fn test_explicit_only_settings() {
let settings = KnowledgeSettings::explicit_only();
assert!(settings.enabled);
assert!(settings.enable_explicit_learning);
assert!(!settings.enable_implicit_learning);
assert!(!settings.enable_aggressive_learning);
}
#[test]
fn test_disabled_settings() {
let settings = KnowledgeSettings::disabled();
assert!(!settings.enabled);
}
}