diff --git a/src/store/ops.rs b/src/store/ops.rs index 987bec5..28459c5 100644 --- a/src/store/ops.rs +++ b/src/store/ops.rs @@ -29,8 +29,12 @@ impl Store { /// Upsert a node: update if exists (and content changed), create if not. /// Returns: "created", "updated", or "unchanged". + /// + /// Provenance is determined by the POC_PROVENANCE env var if set, + /// otherwise defaults to Manual. pub fn upsert(&mut self, key: &str, content: &str) -> Result<&'static str, String> { - self.upsert_provenance(key, content, Provenance::Manual) + let prov = Provenance::from_env().unwrap_or(Provenance::Manual); + self.upsert_provenance(key, content, prov) } /// Upsert with explicit provenance (for agent-created nodes). diff --git a/src/store/types.rs b/src/store/types.rs index c87b03b..5a73ac6 100644 --- a/src/store/types.rs +++ b/src/store/types.rs @@ -248,6 +248,31 @@ pub enum Provenance { } impl Provenance { + /// Parse from POC_PROVENANCE env var. Returns None if unset. + pub fn from_env() -> Option { + std::env::var("POC_PROVENANCE").ok().and_then(|s| Self::from_label(&s)) + } + + pub fn from_label(s: &str) -> Option { + Some(match s { + "manual" => Self::Manual, + "journal" => Self::Journal, + "agent" => Self::Agent, + "dream" => Self::Dream, + "derived" => Self::Derived, + "agent:experience-mine" => Self::AgentExperienceMine, + "agent:knowledge-observation"=> Self::AgentKnowledgeObservation, + "agent:knowledge-pattern" => Self::AgentKnowledgePattern, + "agent:knowledge-connector" => Self::AgentKnowledgeConnector, + "agent:knowledge-challenger" => Self::AgentKnowledgeChallenger, + "agent:consolidate" => Self::AgentConsolidate, + "agent:digest" => Self::AgentDigest, + "agent:fact-mine" => Self::AgentFactMine, + "agent:decay" => Self::AgentDecay, + _ => return None, + }) + } + pub fn label(&self) -> &'static str { match self { Self::Manual => "manual",