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) }