fix(relay): wire EventDeleted audit into all event deletion paths - #4041
Open
iroiro147 wants to merge 1 commit into
Open
fix(relay): wire EventDeleted audit into all event deletion paths#4041iroiro147 wants to merge 1 commit into
iroiro147 wants to merge 1 commit into
Conversation
…ock#4034) AuditAction::EventDeleted was defined but had no production call site — neither NIP-09 soft-delete (e-tag or a-tag) nor NIP-29 kind:9005 admin delete ever wrote an audit log entry. The relay could not produce an audit trail for any event deletion. Add enqueue_event_deleted_audit alongside the existing enqueue_event_created_audit in event.rs, following the same bounded- channel, backpressure-propagating pattern. Wire it into all three deletion paths in side_effects.rs: 1. handle_delete_event_side_effect (kind:9005 NIP-29 admin delete) 2. handle_standard_deletion_event (NIP-09 e-tag soft-delete) 3. handle_a_tag_deletion (NIP-09 a-tag coordinate soft-delete) Each call records the actor (deletion requester), the target event ID or coordinate, and a detail JSON with the delete_kind and event_kind so auditors can distinguish admin deletes from user self-deletes and coordinate-based deletions. Closes block#4034. Signed-off-by: Claude <noreply@anthropic.com> Signed-off-by: iroiro147 <sarthak.singh@juspay.in>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
AuditAction::EventDeletedis defined inbuzz-auditbut has no production call site anywhere in the codebase. Neither of the two paths that delete/tombstone an event (NIP-09 soft-delete, nor hard-delete-on-supersede for parameterized-replaceable events) ever writes an audit log entry. The relay currently cannot produce an audit trail for any event deletion.Closes #4034.
Root Cause
Three separate deletion paths in
crates/buzz-relay/src/handlers/side_effects.rsall callsoft_delete_event_and_update_thread(orsoft_delete_by_coordinate) successfully — but none of them send an audit entry tostate.audit_tx:handle_delete_event_side_effect(kind:9005, NIP-29 admin delete)handle_standard_deletion_event(NIP-09 e-tag soft-delete)handle_a_tag_deletion(NIP-09 a-tag coordinate soft-delete)Meanwhile, the event creation path (
enqueue_event_created_auditinevent.rs) and the media upload path (MediaUploadedinapi/media.rs) both correctly write audit entries. The deletion path was simply never wired up.Fix
Add
enqueue_event_deleted_auditincrates/buzz-relay/src/handlers/event.rsas a sibling toenqueue_event_created_audit, following the same pattern:.send().awaitpub(super)visibility soside_effects.rssibling handlers can call itWire it into all three deletion paths after the
deletedcheck, so we only audit actual deletions:detailJSON withdelete_kind("nip29_admin","nip09_e_tag", or"nip09_a_tag") andevent_kind/channel_idfor distinguishabilityTesting
Relay lib test suite: 823 passed, 10 failed — all 10 are pre-existing baseline failures (7 media env-gated, 2 admin env-gated, 1 telemetry flaky under parallel suite #3929), zero regressions from this change.
Related
The issue reporter also noted that
ARCHITECTURE.mddocuments only 10 audit actions and omitsMediaUploaded. That doc gap is addressed separately.