Agent identity, parallel scheduling, memory-search fixes, stemmer optimization
- Agent identity injection: prepend core-personality to all agent prompts so agents dream as me, not as generic graph workers. Include instructions to walk the graph and connect new nodes to core concepts. - Parallel agent scheduling: sequential within type, parallel across types. Different agent types (linker, organize, replay) run concurrently. - Linker prompt: graph walking instead of keyword search for connections. "Explore the local topology and walk the graph until you find the best connections." - memory-search fixes: format_results no longer truncates to 5 results, pipeline default raised to 50, returned file cleared on compaction, --seen and --seen-full merged, compaction timestamp in --seen output, max_entries=3 per prompt for steady memory drip. - Stemmer optimization: strip_suffix now works in-place on a single String buffer instead of allocating 18 new Strings per word. Note for future: reversed-suffix trie for O(suffix_len) instead of O(n_rules). - Transcript: add compaction_timestamp() for --seen display. - Agent budget configurable (default 4000 from config). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7b1d6b8ad0
commit
5d6b2021f8
8 changed files with 190 additions and 71 deletions
|
|
@ -8,37 +8,42 @@ use std::collections::HashMap;
|
|||
|
||||
/// Minimal Porter stemmer — handles the most common English suffixes.
|
||||
/// Not linguistically complete but good enough for similarity matching.
|
||||
/// Single allocation: works on one String buffer throughout.
|
||||
///
|
||||
/// If this is still a hot spot, replace the sequential suffix checks
|
||||
/// with a reversed-suffix trie: single pass from the end of the word
|
||||
/// matches the longest applicable suffix in O(suffix_len) instead of
|
||||
/// O(n_rules).
|
||||
pub fn stem(word: &str) -> String {
|
||||
let w = word.to_lowercase();
|
||||
let mut w = word.to_lowercase();
|
||||
if w.len() <= 3 { return w; }
|
||||
|
||||
let w = strip_suffix(&w, "ation", "ate");
|
||||
let w = strip_suffix(&w, "ness", "");
|
||||
let w = strip_suffix(&w, "ment", "");
|
||||
let w = strip_suffix(&w, "ting", "t");
|
||||
let w = strip_suffix(&w, "ling", "l");
|
||||
let w = strip_suffix(&w, "ring", "r");
|
||||
let w = strip_suffix(&w, "ning", "n");
|
||||
let w = strip_suffix(&w, "ding", "d");
|
||||
let w = strip_suffix(&w, "ping", "p");
|
||||
let w = strip_suffix(&w, "ging", "g");
|
||||
let w = strip_suffix(&w, "ying", "y");
|
||||
let w = strip_suffix(&w, "ied", "y");
|
||||
let w = strip_suffix(&w, "ies", "y");
|
||||
let w = strip_suffix(&w, "ing", "");
|
||||
let w = strip_suffix(&w, "ed", "");
|
||||
let w = strip_suffix(&w, "ly", "");
|
||||
let w = strip_suffix(&w, "er", "");
|
||||
let w = strip_suffix(&w, "al", "");
|
||||
strip_suffix(&w, "s", "")
|
||||
strip_suffix_inplace(&mut w, "ation", "ate");
|
||||
strip_suffix_inplace(&mut w, "ness", "");
|
||||
strip_suffix_inplace(&mut w, "ment", "");
|
||||
strip_suffix_inplace(&mut w, "ting", "t");
|
||||
strip_suffix_inplace(&mut w, "ling", "l");
|
||||
strip_suffix_inplace(&mut w, "ring", "r");
|
||||
strip_suffix_inplace(&mut w, "ning", "n");
|
||||
strip_suffix_inplace(&mut w, "ding", "d");
|
||||
strip_suffix_inplace(&mut w, "ping", "p");
|
||||
strip_suffix_inplace(&mut w, "ging", "g");
|
||||
strip_suffix_inplace(&mut w, "ying", "y");
|
||||
strip_suffix_inplace(&mut w, "ied", "y");
|
||||
strip_suffix_inplace(&mut w, "ies", "y");
|
||||
strip_suffix_inplace(&mut w, "ing", "");
|
||||
strip_suffix_inplace(&mut w, "ed", "");
|
||||
strip_suffix_inplace(&mut w, "ly", "");
|
||||
strip_suffix_inplace(&mut w, "er", "");
|
||||
strip_suffix_inplace(&mut w, "al", "");
|
||||
strip_suffix_inplace(&mut w, "s", "");
|
||||
w
|
||||
}
|
||||
|
||||
fn strip_suffix(word: &str, suffix: &str, replacement: &str) -> String {
|
||||
fn strip_suffix_inplace(word: &mut String, suffix: &str, replacement: &str) {
|
||||
if word.len() > suffix.len() + 2 && word.ends_with(suffix) {
|
||||
let base = &word[..word.len() - suffix.len()];
|
||||
format!("{}{}", base, replacement)
|
||||
} else {
|
||||
word.to_string()
|
||||
word.truncate(word.len() - suffix.len());
|
||||
word.push_str(replacement);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue