naming agent: resolve node names before creation
Any time an agent creates a new node (WRITE_NODE) or the fact miner stores extracted facts, a naming sub-agent now checks for conflicts and ensures the key is meaningful: - find_conflicts() searches existing nodes via component matching - Haiku LLM decides: CREATE (good name), RENAME (better name), or MERGE_INTO (fold into existing node) - WriteNode actions may be converted to Refine on MERGE_INTO Also updates the rename agent to handle _facts-<UUID> nodes — these are no longer skipped, and the prompt explains how to name them based on their domain/claim content.
This commit is contained in:
parent
15dedea322
commit
b62fffc326
5 changed files with 281 additions and 6 deletions
|
|
@ -245,7 +245,7 @@ pub fn mine_and_store(
|
|||
.map(|n| n.to_string_lossy().to_string())
|
||||
.unwrap_or_else(|| "unknown".into());
|
||||
|
||||
let key = format!("_facts-{}", filename.trim_end_matches(".jsonl"));
|
||||
let proposed_key = format!("_facts-{}", filename.trim_end_matches(".jsonl"));
|
||||
|
||||
// Always write a marker so we don't re-queue empty transcripts
|
||||
let json = if facts.is_empty() {
|
||||
|
|
@ -256,6 +256,25 @@ pub fn mine_and_store(
|
|||
};
|
||||
|
||||
let mut store = store::Store::load()?;
|
||||
|
||||
// Run naming resolution to get a good key (and possibly merge into existing)
|
||||
let resolution = super::knowledge::resolve_naming(&store, &proposed_key, &json);
|
||||
let key = match resolution {
|
||||
super::knowledge::NamingResolution::Create(k) => k,
|
||||
super::knowledge::NamingResolution::MergeInto(existing_key) => {
|
||||
// Merge: append facts to existing node's content
|
||||
eprintln!(" Merging facts into existing node: {}", existing_key);
|
||||
if let Some(node) = store.nodes.get(existing_key.as_str()) {
|
||||
let merged = format!("{}\n\n{}", node.content, json);
|
||||
store.upsert_provenance(&existing_key, &merged, Provenance::AgentFactMine)?;
|
||||
store.save()?;
|
||||
return Ok(facts.len());
|
||||
}
|
||||
// Fallback if existing node disappeared
|
||||
proposed_key
|
||||
}
|
||||
};
|
||||
|
||||
store.upsert_provenance(&key, &json, Provenance::AgentFactMine)?;
|
||||
store.save()?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue