mirror of
https://gitea.ingwaz.work/Ingwaz/openbrain-mcp.git
synced 2026-06-15 22:07:08 +00:00
Merge pull request 'feat(config): add TruthConfig for truth scoring engine (#30)' (#42) from feature/truth-config into main
Merge TruthConfig foundation (#30)
This commit is contained in:
24
.env.example
24
.env.example
@@ -42,3 +42,27 @@ OPENBRAIN__AUTH__ENABLED=false
|
|||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
RUST_LOG=info,openbrain_mcp=debug
|
RUST_LOG=info,openbrain_mcp=debug
|
||||||
|
|
||||||
|
# Truth Engine (optional)
|
||||||
|
# Enable the background truth scoring worker. When enabled, stored memories
|
||||||
|
# are continuously evaluated for truthfulness using PLN deduction, ECAN
|
||||||
|
# attention economy, and cross-referencing against related memories.
|
||||||
|
OPENBRAIN__TRUTH__ENABLED=false
|
||||||
|
# Seconds between scoring cycles (default: 300 = 5 minutes)
|
||||||
|
OPENBRAIN__TRUTH__SCORING_INTERVAL_SECONDS=300
|
||||||
|
# Number of memories to score per cycle (default: 50)
|
||||||
|
OPENBRAIN__TRUTH__BATCH_SIZE=50
|
||||||
|
# Seconds before a scored memory is re-evaluated (default: 86400 = 24 hours)
|
||||||
|
OPENBRAIN__TRUTH__RESCORE_AFTER_SECONDS=86400
|
||||||
|
# PLN base confidence for deduction chains (0.0–1.0, default: 0.85)
|
||||||
|
OPENBRAIN__TRUTH__PLN_BASE_CONFIDENCE=0.85
|
||||||
|
# ECAN STI decay rate per cycle (0.0–1.0, default: 0.95)
|
||||||
|
OPENBRAIN__TRUTH__ECAN_DECAY_RATE=0.95
|
||||||
|
# ECAN attention spread factor (default: 0.05)
|
||||||
|
OPENBRAIN__TRUTH__ECAN_SPREAD_FACTOR=0.05
|
||||||
|
# Similarity threshold for contradiction detection (0.0–1.0, default: 0.85)
|
||||||
|
OPENBRAIN__TRUTH__CONTRADICTION_THRESHOLD=0.85
|
||||||
|
# Truth value threshold for "verified" categorization (0.0–1.0, default: 0.8)
|
||||||
|
OPENBRAIN__TRUTH__VERIFICATION_THRESHOLD=0.8
|
||||||
|
# Max related memories to cross-reference per scoring (default: 10)
|
||||||
|
OPENBRAIN__TRUTH__CROSS_REF_LIMIT=10
|
||||||
|
|||||||
115
src/config.rs
115
src/config.rs
@@ -15,6 +15,7 @@ pub struct Config {
|
|||||||
pub dedup: DedupConfig,
|
pub dedup: DedupConfig,
|
||||||
pub ttl: TtlConfig,
|
pub ttl: TtlConfig,
|
||||||
pub auth: AuthConfig,
|
pub auth: AuthConfig,
|
||||||
|
pub truth: TruthConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Server configuration
|
/// Server configuration
|
||||||
@@ -71,6 +72,41 @@ pub struct TtlConfig {
|
|||||||
pub cleanup_interval_seconds: u64,
|
pub cleanup_interval_seconds: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Truth scoring engine configuration
|
||||||
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
|
pub struct TruthConfig {
|
||||||
|
/// Enable truth scoring background worker
|
||||||
|
#[serde(default = "default_truth_enabled")]
|
||||||
|
pub enabled: bool,
|
||||||
|
/// Seconds between scoring cycles
|
||||||
|
#[serde(default = "default_scoring_interval_seconds")]
|
||||||
|
pub scoring_interval_seconds: u64,
|
||||||
|
/// Number of memories to score per cycle
|
||||||
|
#[serde(default = "default_truth_batch_size")]
|
||||||
|
pub batch_size: usize,
|
||||||
|
/// Seconds before a scored memory is re-evaluated
|
||||||
|
#[serde(default = "default_rescore_after_seconds")]
|
||||||
|
pub rescore_after_seconds: u64,
|
||||||
|
/// Base confidence for PLN deduction chains
|
||||||
|
#[serde(default = "default_pln_base_confidence")]
|
||||||
|
pub pln_base_confidence: f32,
|
||||||
|
/// ECAN STI decay rate per cycle (0.0–1.0)
|
||||||
|
#[serde(default = "default_ecan_decay_rate")]
|
||||||
|
pub ecan_decay_rate: f32,
|
||||||
|
/// ECAN attention spread factor
|
||||||
|
#[serde(default = "default_ecan_spread_factor")]
|
||||||
|
pub ecan_spread_factor: f32,
|
||||||
|
/// Similarity threshold above which conflicting memories are contradictions
|
||||||
|
#[serde(default = "default_contradiction_threshold")]
|
||||||
|
pub contradiction_threshold: f32,
|
||||||
|
/// Truth value threshold for "verified" categorization
|
||||||
|
#[serde(default = "default_verification_threshold")]
|
||||||
|
pub verification_threshold: f32,
|
||||||
|
/// Max related memories to cross-reference per scoring
|
||||||
|
#[serde(default = "default_cross_ref_limit")]
|
||||||
|
pub cross_ref_limit: i64,
|
||||||
|
}
|
||||||
|
|
||||||
/// Authentication configuration
|
/// Authentication configuration
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
pub struct AuthConfig {
|
pub struct AuthConfig {
|
||||||
@@ -139,6 +175,38 @@ fn default_auth_enabled() -> bool {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Truth engine defaults
|
||||||
|
fn default_truth_enabled() -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
fn default_scoring_interval_seconds() -> u64 {
|
||||||
|
300
|
||||||
|
}
|
||||||
|
fn default_truth_batch_size() -> usize {
|
||||||
|
50
|
||||||
|
}
|
||||||
|
fn default_rescore_after_seconds() -> u64 {
|
||||||
|
86400
|
||||||
|
}
|
||||||
|
fn default_pln_base_confidence() -> f32 {
|
||||||
|
0.85
|
||||||
|
}
|
||||||
|
fn default_ecan_decay_rate() -> f32 {
|
||||||
|
0.95
|
||||||
|
}
|
||||||
|
fn default_ecan_spread_factor() -> f32 {
|
||||||
|
0.05
|
||||||
|
}
|
||||||
|
fn default_contradiction_threshold() -> f32 {
|
||||||
|
0.85
|
||||||
|
}
|
||||||
|
fn default_verification_threshold() -> f32 {
|
||||||
|
0.8
|
||||||
|
}
|
||||||
|
fn default_cross_ref_limit() -> i64 {
|
||||||
|
10
|
||||||
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
/// Load configuration from environment variables
|
/// Load configuration from environment variables
|
||||||
pub fn load() -> Result<Self> {
|
pub fn load() -> Result<Self> {
|
||||||
@@ -167,6 +235,41 @@ impl Config {
|
|||||||
)?
|
)?
|
||||||
// Auth settings
|
// Auth settings
|
||||||
.set_default("auth.enabled", default_auth_enabled())?
|
.set_default("auth.enabled", default_auth_enabled())?
|
||||||
|
// Truth engine settings
|
||||||
|
.set_default("truth.enabled", default_truth_enabled())?
|
||||||
|
.set_default(
|
||||||
|
"truth.scoring_interval_seconds",
|
||||||
|
default_scoring_interval_seconds() as i64,
|
||||||
|
)?
|
||||||
|
.set_default("truth.batch_size", default_truth_batch_size() as i64)?
|
||||||
|
.set_default(
|
||||||
|
"truth.rescore_after_seconds",
|
||||||
|
default_rescore_after_seconds() as i64,
|
||||||
|
)?
|
||||||
|
.set_default(
|
||||||
|
"truth.pln_base_confidence",
|
||||||
|
default_pln_base_confidence() as f64,
|
||||||
|
)?
|
||||||
|
.set_default(
|
||||||
|
"truth.ecan_decay_rate",
|
||||||
|
default_ecan_decay_rate() as f64,
|
||||||
|
)?
|
||||||
|
.set_default(
|
||||||
|
"truth.ecan_spread_factor",
|
||||||
|
default_ecan_spread_factor() as f64,
|
||||||
|
)?
|
||||||
|
.set_default(
|
||||||
|
"truth.contradiction_threshold",
|
||||||
|
default_contradiction_threshold() as f64,
|
||||||
|
)?
|
||||||
|
.set_default(
|
||||||
|
"truth.verification_threshold",
|
||||||
|
default_verification_threshold() as f64,
|
||||||
|
)?
|
||||||
|
.set_default(
|
||||||
|
"truth.cross_ref_limit",
|
||||||
|
default_cross_ref_limit(),
|
||||||
|
)?
|
||||||
// Load from environment with OPENBRAIN_ prefix
|
// Load from environment with OPENBRAIN_ prefix
|
||||||
.add_source(
|
.add_source(
|
||||||
config::Environment::with_prefix("OPENBRAIN")
|
config::Environment::with_prefix("OPENBRAIN")
|
||||||
@@ -231,6 +334,18 @@ impl Default for Config {
|
|||||||
enabled: default_auth_enabled(),
|
enabled: default_auth_enabled(),
|
||||||
api_keys: Vec::new(),
|
api_keys: Vec::new(),
|
||||||
},
|
},
|
||||||
|
truth: TruthConfig {
|
||||||
|
enabled: default_truth_enabled(),
|
||||||
|
scoring_interval_seconds: default_scoring_interval_seconds(),
|
||||||
|
batch_size: default_truth_batch_size(),
|
||||||
|
rescore_after_seconds: default_rescore_after_seconds(),
|
||||||
|
pln_base_confidence: default_pln_base_confidence(),
|
||||||
|
ecan_decay_rate: default_ecan_decay_rate(),
|
||||||
|
ecan_spread_factor: default_ecan_spread_factor(),
|
||||||
|
contradiction_threshold: default_contradiction_threshold(),
|
||||||
|
verification_threshold: default_verification_threshold(),
|
||||||
|
cross_ref_limit: default_cross_ref_limit(),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user