Commit Graph

31 Commits

Author SHA1 Message Date
Agent Zero
770828f7e9 merge: resolve conflict with evaluate tool in mod.rs 2026-04-04 10:03:18 +00:00
02a9d74be9 Merge pull request 'feat(tools): add evaluate MCP tool (#37)' (#50) from feature/truth-evaluate-tool into main
Merge evaluate MCP tool (#37)
2026-04-04 10:02:27 +00:00
Agent Zero
e181dad8c7 fix: add missing warn import, cast f64 similarity to f32 2026-04-04 09:47:10 +00:00
Agent Zero
8d0f944513 feat(truth): add background truth scoring worker (#36) 2026-04-04 04:07:58 +00:00
Agent Zero
40d5ab2595 feat(tools): add truth_status MCP tool (#38) 2026-04-04 04:07:28 +00:00
Agent Zero
38a621da55 feat(tools): add evaluate MCP tool (#37) 2026-04-04 04:05:11 +00:00
50d0a944b5 Merge pull request 'feat(truth): add scoring pipeline module (#34)' (#48) from feature/truth-scorer into main
Merge truth scoring pipeline module (#34)
2026-04-04 03:57:59 +00:00
075d06a2ec Merge pull request 'feat(query): surface truth scoring fields in query responses (#39)' (#47) from feature/truth-query into main
Merge enhanced query responses with truth fields (#39)
2026-04-04 03:57:52 +00:00
Agent Zero
a7a070024a feat(truth): add scoring pipeline module (#34)
Implement truth scoring orchestrator that ties PLN + ECAN together:

New types:
- TruthCategory: verified/plausible/unverified/contradicted enum
- ScorerConfig: pipeline configuration (thresholds, ECAN params)
- RelatedMemory: cross-reference result with similarity + existing scores
- ScoringResult: complete scoring output with TV, confidence, category, ECAN

Core functions:
- score_memory(): orchestrates evidence classification, PLN scoring,
  ECAN computation, and categorization
- is_contradiction(): heuristic negation-asymmetry detection
- categorize(): rule-based category assignment

Scoring pipeline:
1. Classify related memories as confirmations or contradictions
2. Scale confidence by cosine similarity (closer = stronger evidence)
3. Apply PLN score_with_evidence for truth value computation
4. Run ECAN cycle (re-score) or initialize (first score)
5. Categorize based on TV, confirmations, and contradictions

13 unit tests covering all scoring paths, categories, contradiction
detection, ECAN initialization/cycling, and output bounds.

Part of #29
2026-04-04 03:15:17 +00:00
Agent Zero
6c280849c0 feat(query): surface truth scoring fields in query responses (#39) 2026-04-04 03:13:11 +00:00
Agent Zero
04f4809b7c feat(db): add truth scoring database helpers (#35)
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
2026-04-04 03:11:38 +00:00
Agent Zero
b6ce2fdeda merge: resolve conflict with main — combine PLN and ECAN in truth/mod.rs 2026-04-04 03:09:48 +00:00
cdbc8529a2 Merge pull request 'feat(truth): add PLN deduction engine (#32)' (#45) from feature/truth-pln into main
Merge PLN deduction engine (#32)
2026-04-04 03:09:04 +00:00
f0235d8e6e Merge pull request 'feat(db): add truth scoring columns migration (#31)' (#43) from feature/truth-migration into main
Merge truth scoring columns migration (#31)
2026-04-04 03:08:58 +00:00
Agent Zero
3f11f8f531 fix(config): close missing brace in Default impl for Config 2026-04-04 02:29:51 +00:00
Agent Zero
1672d5a145 feat(truth): add PLN deduction engine (#32)
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
2026-04-04 02:14:01 +00:00
Agent Zero
5e746e4425 feat(truth): add ECAN attention economy module (#33)
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
2026-04-04 02:12:47 +00:00
Agent Zero
5f9d884187 feat(db): add truth scoring columns migration (#31)
Add V5__truth_scoring.sql migration:
- truth_value (REAL): 0.0-1.0 truth score from PLN reasoning
- truth_confidence (REAL): 0.0-1.0 confidence in the score
- truth_category (TEXT): verified/plausible/unverified/contradicted
- truth_evaluated_at (TIMESTAMPTZ): when last scored
- ecan_sti (REAL): Short-Term Importance (recency-weighted)
- ecan_lti (REAL): Long-Term Importance (reliability)

Partial indexes for efficient unscored memory queries.
Update MemoryRecord struct with optional truth fields.

Part of #29
2026-04-04 02:10:15 +00:00
Agent Zero
38b1150838 feat(config): add TruthConfig for truth scoring engine (#30)
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
2026-04-04 02:05:36 +00:00
Agent Zero
026ae27366 Scope memories by API token and add shared-token e2e coverage 2026-04-01 23:30:58 -04:00
Agent Zero
1d485ca5c9 Fix dedup threshold postgres type 2026-03-24 06:07:06 +00:00
Agent Zero
9be138db94 Fix dedup database client trait import 2026-03-24 05:45:07 +00:00
Agent Zero
61d6448b44 Add server-side deduplication on ingest 2026-03-24 05:40:30 +00:00
Agent Zero
5d5c042dd1 Add TTL expiry for transient facts 2026-03-24 03:20:10 +00:00
Agent Zero
1314015479 Fix hybrid query parameter types 2026-03-24 02:12:41 +00:00
Agent Zero
0ba37f8573 Add hybrid text plus vector memory search 2026-03-22 22:38:14 +00:00
Agent Zero
26c96b41dd Fix MCP transport compatibility and batch_store e2e coverage 2026-03-22 03:18:08 +00:00
Agent Zero
1b42989dbb Fix Issue #12 tests and add OpenBrain repo guidance 2026-03-19 13:19:50 -04:00
Agent Zero
03e8f246d1 Implement batch_store endpoint for Issue #12 2026-03-19 15:59:34 +00:00
Agent Zero
403b95229e feat: implement batch_store endpoint (Issue #12)
- 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
2026-03-19 15:30:32 +00:00
Agent Zero
774982dc5a Initial public release 2026-03-07 13:41:36 -05:00