MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / emit_session_node

Method emit_session_node

atomic-core/src/pristine/txn/write/session_kg.rs:300–327  ·  view source on GitHub ↗

Upsert the session node with its current lifecycle metadata.

(&mut self, record: &SessionRecord)

Source from the content-addressed store, hash-verified

298
299 /// Upsert the session node with its current lifecycle metadata.
300 pub(crate) fn emit_session_node(&mut self, record: &SessionRecord) -> PristineResult<()> {
301 let node = KgNode::new(
302 session_node_id(&record.session_id),
303 "session",
304 &record.session_id,
305 "session_ledger",
306 )
307 .with_metadata(serde_json::json!({
308 "rdf_type": entity_type::SESSION,
309 "view": record.view_name,
310 "parent_view": record.parent_view,
311 "status": if record.ended_at.is_some() { "ended" } else { "active" },
312 "turn_count": record.turn_count,
313 "json_path": record.json_path,
314 }));
315 self.upsert_kg_node(&node)?;
316
317 // session ON_VIEW view — shares the enrichment's view vocabulary so
318 // `neighbors view:X` surfaces sessions alongside changes and files.
319 if let Some(view) = &record.view_name {
320 self.upsert_kg_edge(&KgEdge::new(
321 session_node_id(&record.session_id),
322 format!("view:{}", view),
323 edge_kind::ON_VIEW,
324 ))?;
325 }
326 Ok(())
327 }
328
329 /// Emit one turn row's nodes and edges.
330 ///

Callers 4

rewrite_session_turnsMethod · 0.80
index_empty_sessionMethod · 0.80
emit_turn_kgMethod · 0.80

Calls 4

session_node_idFunction · 0.85
upsert_kg_nodeMethod · 0.80
upsert_kg_edgeMethod · 0.80
with_metadataMethod · 0.45

Tested by

no test coverage detected