hub differentiation + refine_target for automatic section targeting
Pattern separation for memory graph: when a file-level node (e.g. identity.md) has section children, redistribute its links to the best-matching section using cosine similarity. - differentiate_hub: analyze hub, propose link redistribution - refine_target: at link creation time, automatically target the most specific section instead of the file-level hub - Applied refine_target in all four link creation paths (digest links, journal enrichment, apply consolidation, link-add command) - Saturated hubs listed in agent topology header with "DO NOT LINK" This prevents hub formation proactively (refine_target) and remediates existing hubs (differentiate command). Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
parent
3afc947b88
commit
4530837057
3 changed files with 334 additions and 7 deletions
|
|
@ -9,6 +9,7 @@
|
|||
// 5. Extracts links and saves agent results
|
||||
|
||||
use crate::capnp_store::{self, Store};
|
||||
use crate::neuro;
|
||||
|
||||
use regex::Regex;
|
||||
use std::fs;
|
||||
|
|
@ -803,6 +804,11 @@ pub fn apply_digest_links(store: &mut Store, links: &[DigestLink]) -> (usize, us
|
|||
}
|
||||
};
|
||||
|
||||
// Refine target to best-matching section if available
|
||||
let source_content = store.nodes.get(&source)
|
||||
.map(|n| n.content.as_str()).unwrap_or("");
|
||||
let target = neuro::refine_target(store, source_content, &target);
|
||||
|
||||
if source == target { skipped += 1; continue; }
|
||||
|
||||
// Check if link already exists
|
||||
|
|
@ -1070,6 +1076,11 @@ pub fn journal_enrich(
|
|||
None => { println!(" SKIP {} (no matching journal node)", target); continue; }
|
||||
};
|
||||
|
||||
// Refine target to best-matching section
|
||||
let source_content = store.nodes.get(&source_key)
|
||||
.map(|n| n.content.as_str()).unwrap_or("");
|
||||
let resolved = neuro::refine_target(store, source_content, &resolved);
|
||||
|
||||
let source_uuid = match store.nodes.get(&source_key) {
|
||||
Some(n) => n.uuid,
|
||||
None => continue,
|
||||
|
|
@ -1301,6 +1312,11 @@ pub fn apply_consolidation(store: &mut Store, do_apply: bool, report_file: Optio
|
|||
Err(e) => { println!(" ? {} → {}: {}", src, tgt, e); skipped += 1; continue; }
|
||||
};
|
||||
|
||||
// Refine target to best-matching section
|
||||
let source_content = store.nodes.get(&source)
|
||||
.map(|n| n.content.as_str()).unwrap_or("");
|
||||
let target = neuro::refine_target(store, source_content, &target);
|
||||
|
||||
let exists = store.relations.iter().any(|r|
|
||||
r.source_key == source && r.target_key == target && !r.deleted
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue