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

Method get_session_phases

atomic-core/src/pristine/txn/read.rs:1216–1240  ·  view source on GitHub ↗

Get phase timing breakdown for a provenance graph. Returns timing data for each phase in the turn. Populated from the per-phase token breakdown that Sherpa graphs carry; empty for agents that do not emit phase timing.

(
        &self,
        provenance_id: u64,
    )

Source from the content-addressed store, hash-verified

1214 /// per-phase token breakdown that Sherpa graphs carry; empty for agents
1215 /// that do not emit phase timing.
1216 pub fn get_session_phases(
1217 &self,
1218 provenance_id: u64,
1219 ) -> PristineResult<Vec<crate::change::session::PhaseTimingEntry>> {
1220 use crate::change::session::{encode_session_prefix, PhaseTimingEntry};
1221
1222 let table = self.txn.open_table(SESSION_PHASES)?;
1223 let mut phases = Vec::new();
1224
1225 // Bounded prefix scan: all phase keys for this provenance_id lie in
1226 // [prefix(id), prefix(id+1)).
1227 let start = encode_session_prefix(provenance_id);
1228 let end = encode_session_prefix(provenance_id.saturating_add(1));
1229 for result in table.range::<&[u8; 16]>(&start..&end)? {
1230 let (_key, value) = result?;
1231 match PhaseTimingEntry::from_bytes(value.value()) {
1232 Ok(entry) => phases.push(entry),
1233 Err(e) => {
1234 log::warn!("Failed to deserialize phase timing entry: {}", e);
1235 }
1236 }
1237 }
1238
1239 Ok(phases)
1240 }
1241
1242 /// Get intent metadata for a provenance graph.
1243 ///

Callers

nothing calls this directly

Calls 3

encode_session_prefixFunction · 0.85
valueMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected