New structs:
- TruthScoreUpdate: parameters for updating truth scores
- TruthStats: aggregated truth scoring statistics
- ScoringCandidate: lightweight record for the scoring worker
New Database methods:
- get_unscored_memories(): fetch unscored memories FIFO
- get_stale_memories(): fetch memories due for re-evaluation
- update_truth_score(): update single memory truth fields
- batch_update_truth_scores(): transactional batch update
- get_truth_stats(): aggregate stats with category breakdown
Uses partial index idx_memories_truth_unevaluated for efficient
unscored memory queries.
Part of #29
Implement Probabilistic Logic Networks (PLN) inference rules:
- TruthValue struct with clamped strength/confidence
- deduction(): chain two implications A->B and B->C
- revision(): merge two independent truth estimates
- negation(): logical NOT (inverts strength, preserves confidence)
- conjunction(): logical AND (multiply strength, min confidence)
- score_with_evidence(): combine base score with confirmations and contradictions
10 unit tests covering basic operations, boundary cases,
symmetry, zero-confidence handling, and output bounds.
Part of #29
Implement Economic Attention Network (ECAN) for memory importance management:
- EcanParams: decay_rate, beta, spread_factor, threshold
- decay_sti(): STI decay toward zero over time
- update_lti(): LTI accumulation weighted by STI, penalized below threshold
- spread(): boost STI for confirmed memories
- cycle(): full decay + LTI update weighted by truth value
- initialize(): compute initial STI/LTI from truth value and confidence
14 unit tests covering decay convergence, LTI growth/penalty,
spread clamping, cycle behavior, initialization, and bounds.
Part of #29
Add TruthConfig struct to config.rs with all truth engine parameters:
- enabled, scoring_interval_seconds, batch_size, rescore_after_seconds
- pln_base_confidence, ecan_decay_rate, ecan_spread_factor
- contradiction_threshold, verification_threshold, cross_ref_limit
All settings configurable via OPENBRAIN__TRUTH__* env vars with sensible defaults.
Update .env.example with full documentation of new variables.
Update Config::load() builder and Default impl.
Part of #29
- Add batch_store tool accepting 1-50 entries per call
- Single DB transaction for atomicity
- Returns individual IDs/status per entry
- Add batch_store_memories() to Database layer
- Add 6 test cases
- Backward compatible - existing store unchanged
Expected impact: 50-60% reduction in store API calls