From 521d9c52580bc1e9a2a2367f598a87e3664c4250 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Mon, 3 Aug 2026 08:32:28 -0400 Subject: [PATCH] Verify stored audit heads --- src/storage/audit.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/storage/audit.rs b/src/storage/audit.rs index a3acc99..f839a61 100644 --- a/src/storage/audit.rs +++ b/src/storage/audit.rs @@ -92,10 +92,21 @@ impl StateStore { }); } } + let heads = self.audit_heads(folder_id)?; + for head in &heads { + let expected = expected_by_author.get(&head.author_device_id); + if expected == Some(&(head.sequence, head.event_hash.clone())) { + continue; + } + faults.push(AuditIntegrityFault { + author_device_id: head.author_device_id.clone(), + detail: "stored audit head does not match its event chain".to_owned(), + }); + } faults.extend(self.audit_integrity_faults(folder_id)?); Ok(AuditVerification { event_count: events.len(), - heads: self.audit_heads(folder_id)?, + heads, faults, }) } -- 2.51.2