From 51ee082faf470eaddf113064eb71020ca1b2f06f Mon Sep 17 00:00:00 2001 From: ProofOfConcept Date: Sat, 14 Mar 2026 12:27:30 -0400 Subject: [PATCH] provenance: set POC_PROVENANCE for agent subprocesses, Jaccard initial strength MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent subprocess calls now set POC_PROVENANCE=agent:{name} so any nodes/links created via tool calls are tagged with the creating agent. This makes agent transcripts indistinguishable from conscious sessions in format — important for future model training. new_relation() now reads POC_PROVENANCE env var directly (raw string, not enum) since agent names are dynamic. link-add now computes initial strength from Jaccard similarity instead of hardcoded 0.8. New links start at a strength reflecting actual neighborhood overlap. Co-Authored-By: Kent Overstreet --- poc-memory/src/agents/llm.rs | 3 +++ poc-memory/src/main.rs | 9 +++++++-- poc-memory/src/store/types.rs | 8 ++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/poc-memory/src/agents/llm.rs b/poc-memory/src/agents/llm.rs index 9ae6575..4a0a742 100644 --- a/poc-memory/src/agents/llm.rs +++ b/poc-memory/src/agents/llm.rs @@ -93,6 +93,9 @@ fn call_model_with_tools(agent: &str, model: &str, prompt: &str, // Tell hooks this is a daemon agent call, not interactive cmd.env("POC_AGENT", "1"); + // Set provenance so any nodes/links created by tool calls are tagged + cmd.env("POC_PROVENANCE", format!("agent:{}", agent)); + let start = std::time::Instant::now(); let mut child = unsafe { diff --git a/poc-memory/src/main.rs b/poc-memory/src/main.rs index b17c64b..43bdd17 100644 --- a/poc-memory/src/main.rs +++ b/poc-memory/src/main.rs @@ -1642,14 +1642,19 @@ fn cmd_link_add(source: &str, target: &str, reason: &[String]) -> Result<(), Str return Ok(()); } + // Compute initial strength from Jaccard neighborhood similarity + let graph = store.build_graph(); + let jaccard = graph.jaccard(&source, &target); + let strength = (jaccard * 3.0).clamp(0.1, 1.0); + let rel = store::new_relation( source_uuid, target_uuid, - store::RelationType::Link, 0.8, + store::RelationType::Link, strength, &source, &target, ); store.add_relation(rel)?; store.save()?; - println!("Linked: {} → {} ({})", source, target, reason); + println!("Linked: {} → {} (strength={:.2}, {})", source, target, strength, reason); Ok(()) } diff --git a/poc-memory/src/store/types.rs b/poc-memory/src/store/types.rs index 541c7a8..2d95a61 100644 --- a/poc-memory/src/store/types.rs +++ b/poc-memory/src/store/types.rs @@ -560,7 +560,8 @@ pub fn new_visit(node_uuid: [u8; 16], node_key: &str, agent: &str, outcome: &str pub(crate) fn visits_path() -> PathBuf { memory_dir().join("visits.capnp") } -/// Create a new relation +/// Create a new relation. +/// Provenance is set from POC_PROVENANCE env var if present, else "manual". pub fn new_relation( source_uuid: [u8; 16], target_uuid: [u8; 16], @@ -569,6 +570,9 @@ pub fn new_relation( source_key: &str, target_key: &str, ) -> Relation { + // Use raw env var for provenance — agent names are dynamic + let provenance = std::env::var("POC_PROVENANCE") + .unwrap_or_else(|_| "manual".to_string()); Relation { uuid: *Uuid::new_v4().as_bytes(), version: 1, @@ -577,7 +581,7 @@ pub fn new_relation( target: target_uuid, rel_type, strength, - provenance: "manual".to_string(), + provenance, deleted: false, source_key: source_key.to_string(), target_key: target_key.to_string(),