diff --git a/poc-memory/src/agents/knowledge.rs b/poc-memory/src/agents/knowledge.rs index cbefe2b..3fa4b53 100644 --- a/poc-memory/src/agents/knowledge.rs +++ b/poc-memory/src/agents/knowledge.rs @@ -97,7 +97,8 @@ impl Confidence { // --------------------------------------------------------------------------- pub fn parse_write_nodes(text: &str) -> Vec { - let re = Regex::new(r"(?s)WRITE_NODE\s+(\S+)\s*\n(.*?)END_NODE").unwrap(); + // Match WRITE_NODE or **WRITE_NODE** with optional backtick-wrapped key + let re = Regex::new(r"(?s)\*{0,2}WRITE_NODE\*{0,2}\s+`?(\S+?)`?\s*\n(.*?)\*{0,2}END_NODE\*{0,2}").unwrap(); let conf_re = Regex::new(r"(?i)CONFIDENCE:\s*(high|medium|low)").unwrap(); let covers_re = Regex::new(r"COVERS:\s*(.+)").unwrap(); @@ -131,7 +132,8 @@ pub fn parse_write_nodes(text: &str) -> Vec { } pub fn parse_links(text: &str) -> Vec { - let re = Regex::new(r"(?m)^LINK\s+(\S+)\s+(\S+)").unwrap(); + // Match LINK or **LINK** with optional backtick-wrapped keys + let re = Regex::new(r"(?m)^\*{0,2}LINK\*{0,2}\s+`?([^\s`]+)`?\s+`?([^\s`]+)`?").unwrap(); re.captures_iter(text) .map(|cap| Action { kind: ActionKind::Link { @@ -333,6 +335,8 @@ pub fn apply_action( Some(n) => n.uuid, None => return false, }; + // Default strength 0.3 — caller should run Jaccard normalization + // after batch apply if needed (building graph per-link is too expensive) let mut rel = new_relation( source_uuid, target_uuid, RelationType::Link,