provenance: new_relation takes explicit provenance parameter

Remove POC_PROVENANCE env var lookup from new_relation - callers
now pass provenance explicitly. This fixes tracking when the env
var wasn't set correctly.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-15 01:39:58 -04:00
parent 5d6e663b60
commit cc29cd2225
2 changed files with 3 additions and 5 deletions

View file

@ -201,7 +201,6 @@ pub fn new_node(key: &str, content: &str) -> Node {
}
/// 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],
@ -209,10 +208,8 @@ pub fn new_relation(
strength: f32,
source_key: &str,
target_key: &str,
provenance: &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,
@ -221,7 +218,7 @@ pub fn new_relation(
target: target_uuid,
rel_type,
strength,
provenance,
provenance: provenance.to_string(),
deleted: false,
source_key: source_key.to_string(),
target_key: target_key.to_string(),

View file

@ -196,6 +196,7 @@ pub fn apply_digest_links(store: &mut Store, links: &[DigestLink]) -> (usize, us
store::RelationType::Link,
0.5,
&source, &target,
"agent:digest",
);
if store.add_relation(rel).is_ok() {
println!(" + {}{}", source, target);