- subconscious.rs: use .get(fork_point..) instead of direct slice to avoid panic when fork_point > entries.len() - dmn.rs: batch all output injections (surface, reflection, thalamus) under a single agent lock acquisition instead of three separate ones - dmn.rs: use Store::cached() instead of Store::load() when rendering surfaced memories - Add scoring persistence analysis notes Co-Authored-By: Proof of Concept <poc@bcachefs.org>
46 lines
1.5 KiB
Markdown
46 lines
1.5 KiB
Markdown
# Memory Scoring Persistence — Analysis (2026-04-07)
|
|
|
|
## Problem
|
|
|
|
Scores computed by `score_memories_incremental` are written to
|
|
`ConversationEntry::Memory::score` (in-memory, serialized to
|
|
conversation.log) but never written back to the Store. This means:
|
|
|
|
- `Node.last_scored` stays at 0 — every restart re-scores everything
|
|
- `score_weight()` in `ops.rs:304-313` exists but is never called
|
|
- Scoring is wasted work on every session start
|
|
|
|
## Fix
|
|
|
|
In `mind/mod.rs` scoring completion handler (currently ~line 341-352),
|
|
after writing scores to entries, also persist to Store:
|
|
|
|
```rust
|
|
if let Ok(ref scores) = result {
|
|
let mut ag = agent.lock().await;
|
|
// Write to entries (already done)
|
|
for (key, weight) in scores { ... }
|
|
|
|
// NEW: persist to Store
|
|
let store_arc = Store::cached().await.ok();
|
|
if let Some(arc) = store_arc {
|
|
let mut store = arc.lock().await;
|
|
for (key, weight) in scores {
|
|
store.score_weight(key, *weight as f32);
|
|
}
|
|
store.save().ok();
|
|
}
|
|
}
|
|
```
|
|
|
|
This calls `score_weight()` which updates `node.weight` and sets
|
|
`node.last_scored = now()`. The staleness check in
|
|
`score_memories_incremental` (learn.rs:325) then skips recently-scored
|
|
nodes on subsequent runs.
|
|
|
|
## Files
|
|
|
|
- `src/mind/mod.rs:341-352` — scoring completion handler (add Store write)
|
|
- `src/hippocampus/store/ops.rs:304-313` — `score_weight()` (exists, unused)
|
|
- `src/subconscious/learn.rs:322-326` — staleness check (already correct)
|
|
- `src/hippocampus/store/types.rs:219` — `Node.last_scored` field
|