provenance: set POC_PROVENANCE for agent subprocesses, Jaccard initial strength
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 <kent.overstreet@linux.dev>
This commit is contained in:
parent
58a95a22a0
commit
51ee082faf
3 changed files with 16 additions and 4 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue