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

Method deterministic_id

atomic-agent/src/event.rs:616–627  ·  view source on GitHub ↗

Derive a retry-stable ID from turn identity and the complete event body.

(
        session_id: &str,
        turn_number: u32,
        generation: u64,
        timestamp_ms: i64,
        event: &ProvenanceJournalEvent,
    )

Source from the content-addressed store, hash-verified

614
615 /// Derive a retry-stable ID from turn identity and the complete event body.
616 pub fn deterministic_id(
617 session_id: &str,
618 turn_number: u32,
619 generation: u64,
620 timestamp_ms: i64,
621 event: &ProvenanceJournalEvent,
622 ) -> Result<String, ProvenanceJournalError> {
623 let bytes =
624 serde_json::to_vec(&(session_id, turn_number, generation, timestamp_ms, event))?;
625 let digest = blake3::hash(&bytes).to_hex().to_string();
626 Ok(format!("pj-{}", &digest[..32]))
627 }
628
629 pub fn validate(&self) -> Result<(), ProvenanceJournalError> {
630 if self.schema_version != PROVENANCE_JOURNAL_VERSION {

Callers

nothing calls this directly

Calls 2

hashFunction · 0.50
to_hexMethod · 0.45

Tested by

no test coverage detected