provenance: add label() method, show provenance in history output

Move provenance_label() from query.rs private function to a pub
label() method on Provenance, eliminating duplication. History command
now shows provenance, human-readable timestamps, and content size for
each version.

Handle pre-migration nodes with bogus timestamps gracefully instead
of panicking.
This commit is contained in:
ProofOfConcept 2026-03-06 21:41:26 -05:00
parent 851fc0d417
commit d3075dc235
3 changed files with 35 additions and 24 deletions

View file

@ -173,7 +173,7 @@ fn resolve_field(field: &str, key: &str, store: &Store, graph: &Graph) -> Option
"weight" => Some(Value::Num(node.weight as f64)),
"category" => Some(Value::Str(node.category.label().to_string())),
"node_type" => Some(Value::Str(node_type_label(node.node_type).to_string())),
"provenance" => Some(Value::Str(provenance_label(node.provenance).to_string())),
"provenance" => Some(Value::Str(node.provenance.label().to_string())),
"emotion" => Some(Value::Num(node.emotion as f64)),
"retrievals" => Some(Value::Num(node.retrievals as f64)),
"uses" => Some(Value::Num(node.uses as f64)),
@ -200,24 +200,6 @@ fn node_type_label(nt: NodeType) -> &'static str {
}
}
fn provenance_label(p: Provenance) -> &'static str {
match p {
Provenance::Manual => "manual",
Provenance::Journal => "journal",
Provenance::Agent => "agent",
Provenance::Dream => "dream",
Provenance::Derived => "derived",
Provenance::AgentExperienceMine => "agent:experience-mine",
Provenance::AgentKnowledgeObservation => "agent:knowledge-observation",
Provenance::AgentKnowledgePattern => "agent:knowledge-pattern",
Provenance::AgentKnowledgeConnector => "agent:knowledge-connector",
Provenance::AgentKnowledgeChallenger => "agent:knowledge-challenger",
Provenance::AgentConsolidate => "agent:consolidate",
Provenance::AgentDigest => "agent:digest",
Provenance::AgentFactMine => "agent:fact-mine",
Provenance::AgentDecay => "agent:decay",
}
}
fn rel_type_label(r: RelationType) -> &'static str {
match r {