memory-search: add --query mode and prompt key boost

Two changes:

1. New -q/--query flag for direct search without hook machinery.
   Useful for debugging: memory-search -q inner-life-sexuality-intimacy
   shows seeds, spread results, and rankings.

2. Prompt key boost: when the current prompt contains a node key
   (>=5 chars) as a substring, boost that term by +10.0. This ensures
   explicit mentions fire as strong seeds for spread, while the graph
   still determines what gets pulled in.

Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-03-13 15:26:35 -04:00
parent 5024cf7002
commit 1da712874b
3 changed files with 100 additions and 8 deletions

View file

@ -9,8 +9,8 @@
// - Conversation fragment selection (for observation agent)
use crate::graph::Graph;
use super::llm;
use crate::spectral;
use super::llm;
use crate::store::{self, Store, new_relation, RelationType};
use regex::Regex;
@ -940,13 +940,20 @@ fn run_cycle(
depth_db.save(&mut store);
// Recompute spectral if anything changed
// Recompute spectral at most once per hour — O(n³) is expensive at 14k+ nodes
if total_applied > 0 {
eprintln!("\n Recomputing spectral embedding...");
let graph = store.build_graph();
let result = spectral::decompose(&graph, 8);
let emb = spectral::to_embedding(&result);
spectral::save_embedding(&emb).ok();
let stale = spectral::embedding_path()
.metadata()
.and_then(|m| m.modified())
.map(|t| t.elapsed().unwrap_or_default() > std::time::Duration::from_secs(3600))
.unwrap_or(true);
if stale {
eprintln!("\n Recomputing spectral embedding (>1h stale)...");
let graph = store.build_graph();
let result = spectral::decompose(&graph, 8);
let emb = spectral::to_embedding(&result);
spectral::save_embedding(&emb).ok();
}
}
let graph = store.build_graph();