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,
)
| 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 { |