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

Method deterministic_id

atomic-agent/src/event.rs:615–626  ·  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

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