triangle-close: bulk lateral linking for clustering coefficient

New command: `poc-memory triangle-close [MIN_DEG] [SIM] [MAX_PER_HUB]`

For each node above min_degree, finds pairs of its neighbors that
aren't directly connected and have text similarity above threshold.
Links them. This turns hub-spoke patterns into triangles, directly
improving clustering coefficient and schema fit.

First run results (default params: deg≥5, sim≥0.3, max 10/hub):
- 636 hubs processed, 5046 lateral links added
- cc: 0.14 → 0.46  (target: high)
- fit: 0.09 → 0.32  (target ≥0.2)
- σ:  56.9 → 84.4  (small-world coefficient improved)

Also fixes separator agent prompt: truncate interference pairs to
batch count (was including all 1114 pairs = 1.3M chars).
This commit is contained in:
ProofOfConcept 2026-03-01 07:35:29 -05:00
parent 6bc11e5fb6
commit 6c7bfb9ec4
2 changed files with 108 additions and 0 deletions

View file

@ -87,6 +87,7 @@ fn main() {
"link-impact" => cmd_link_impact(&args[2..]),
"consolidate-session" => cmd_consolidate_session(),
"consolidate-full" => cmd_consolidate_full(),
"triangle-close" => cmd_triangle_close(&args[2..]),
"daily-check" => cmd_daily_check(),
"apply-agent" => cmd_apply_agent(&args[2..]),
"digest" => cmd_digest(&args[2..]),
@ -149,6 +150,8 @@ Commands:
link-impact SOURCE TARGET Simulate adding an edge, report topology impact
consolidate-session Analyze metrics, plan agent allocation
consolidate-full Autonomous: plan agents apply digests links
triangle-close [DEG] [SIM] [MAX]
Close triangles: link similar neighbors of hubs
daily-check Brief metrics check (for cron/notifications)
apply-agent [--all] Import pending agent results into the graph
digest daily [DATE] Generate daily episodic digest (default: today)
@ -437,6 +440,26 @@ fn cmd_consolidate_full() -> Result<(), String> {
digest::consolidate_full(&mut store)
}
fn cmd_triangle_close(args: &[String]) -> Result<(), String> {
let min_degree: usize = args.first()
.and_then(|s| s.parse().ok())
.unwrap_or(5);
let sim_threshold: f32 = args.get(1)
.and_then(|s| s.parse().ok())
.unwrap_or(0.3);
let max_per_hub: usize = args.get(2)
.and_then(|s| s.parse().ok())
.unwrap_or(10);
println!("Triangle closure: min_degree={}, sim_threshold={}, max_per_hub={}",
min_degree, sim_threshold, max_per_hub);
let mut store = capnp_store::Store::load()?;
let (hubs, added) = neuro::triangle_close(&mut store, min_degree, sim_threshold, max_per_hub);
println!("\nProcessed {} hubs, added {} lateral links", hubs, added);
Ok(())
}
fn cmd_daily_check() -> Result<(), String> {
let store = capnp_store::Store::load()?;
let report = neuro::daily_check(&store);