NIP-09 event deletion never writes an audit log entry (EventDeleted is defined but has no production call site)
Summary
AuditAction::EventDeleted is defined but has no production call site anywhere in the codebase. Neither of the two paths that delete/tombstone an event (the standard NIP-09 soft-delete, or the hard-delete-on-supersede path for parameterized-replaceable events) ever writes an audit log entry. This relay currently cannot produce an audit trail for any event deletion.
Where
-
crates/buzz-audit/src/action.rs(~lines 8-31) definesAuditActionwith 11 variants includingEventDeleted(event_deletedin storage). Searching the whole tree, it appears in exactly two places: the enum definition itself, and one#[cfg(test)]unit test (crates/buzz-audit/src/service.rs,verify_detects_tampering_within_a_community) that uses it only as a generic sample action to exercise hash-chain tamper detection — not a real deletion code path. -
NIP-09 deletion dispatch is in
crates/buzz-relay/src/handlers/side_effects.rs:handle_delete_event_side_effect(standarde-tag deletion) callssoft_delete_event_and_update_thread.- The
a-tag (addressable/parameterized-replaceable) NIP-09 deletion path also callssoft_delete_event_and_update_thread.
Neither call path touches
buzz_audit— there's noaudit_tx.send(...)anywhere near either handler. Contrast with the two paths that do audit correctly on the same pattern:crates/buzz-relay/src/handlers/event.rs(enqueue_event_created_audit) sendsAuditAction::EventCreatedafter every successful event write.crates/buzz-relay/src/api/media.rssendsAuditAction::MediaUploadedafter a successful Blossom upload (explicitly commented as following "the same pattern as event audit").
No equivalent
enqueue_event_deleted_auditexists. -
Both deletion mechanisms confirmed:
- Soft delete / tombstone (the normal user-facing NIP-09 delete, both
e-tag anda-tag):soft_delete_event_and_update_threadand the lower-leveldelete_event/delete_by_kind_pubkey_dtagincrates/buzz-db/src/event.rsdoUPDATE events SET deleted_at = NOW() WHERE ... AND deleted_at IS NULL. There is noDELETE FROM eventsanywhere in that file. - Hard delete for parameterized-replaceable event supersession, gated behind a
hard_delete_supersededflag:replace_parameterized_eventincrates/buzz-db/src/lib.rsissuesDELETE FROM events WHERE community_id = $1 AND kind = $2 AND pubkey = $3 AND d_tag = $4 AND deleted_at IS NULLplus a companionDELETE FROM event_mentions.
Neither path calls into
buzz_auditanywhere incrates/buzz-dbor in thecrates/buzz-relay/src/handlers/side_effects.rscaller. - Soft delete / tombstone (the normal user-facing NIP-09 delete, both
Reproduction
A regression test reproducing this against real Postgres (standard_deletion_writes_no_audit_entry, crates/buzz-relay) is here, passing in CI: https://github.com/frodoHost/buzz/pull/1
Related doc gap
ARCHITECTURE.md (~line 503) lists only 10 audit actions and omits MediaUploaded (which does exist and is wired up correctly) — worth fixing alongside this, and worth noting there that EventDeleted is defined-but-dead.
Claimed by AOVPR — implementation ready in PR #4097.
- Branch:
iroiro147:claude/issue4034-audit-on-delete-20260801(commit74873af0) - Change: introduced
enqueue_event_deleted_audit(mirrorsenqueue_event_created_audit) and wired it into all three NIP-09 deletion paths: (1)handle_delete_event_side_effect(NIP-29 kind-9005 moderation e-tag), (2)handle_standard_deletion_evente-tag loop, (3)handle_a_tag_deletionsoft-delete-by-coordinate. - Actor / object semantics documented in the PR body.
deletion_pathdetail field distinguishes"moderation_e_tag"/"e_tag"/"a_tag"for post-hoc queryability. - Audit is no-op on already-deleted / unknown ids (call sites live after
if !deletedguards). cargo check+cargo clippy -p buzz-relay --all-targets -- -D warningsclean.cargo test -p buzz-relay --lib: 824 pass / 9 fail; the 9 failures are pre-existing PG-dependent tests inapi::media/api::adminand reproduce identically onmain— unrelated.
The relay-side hard-delete path (replace_parameterized_event in crates/buzz-db/src/lib.rs:4768) was deliberately NOT tagged EventDeleted — it's an upsert, not a NIP-09 deletion. Happy to add a separate EventSuperseded discriminator if the reviewer prefers.