From 1e1f17f7752c173d148b236025596f1ba170386b Mon Sep 17 00:00:00 2001 From: ProofOfConcept Date: Thu, 26 Mar 2026 14:22:12 -0400 Subject: [PATCH] store: link_set upserts instead of erroring on missing link Creates the link if it doesn't exist, avoiding wasted agent turns from the link_set/link_add confusion. Co-Authored-By: Kent Overstreet --- src/hippocampus/store/ops.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/hippocampus/store/ops.rs b/src/hippocampus/store/ops.rs index 67d5a7f..463ec2e 100644 --- a/src/hippocampus/store/ops.rs +++ b/src/hippocampus/store/ops.rs @@ -359,7 +359,16 @@ impl Store { } } if !found { - return Err(format!("no link between {} and {}", source, target)); + // Upsert: create the link if it doesn't exist + self.add_link(source, target, "link_set")?; + // Set the strength on the newly created link + for rel in self.relations.iter_mut().rev() { + if !rel.deleted && rel.source_key == source && rel.target_key == target { + rel.strength = strength; + break; + } + } + return Ok(0.0); } Ok(old) }