buzz icon indicating copy to clipboard operation
buzz copied to clipboard

relay: NIP-09 a-tag deletion is a no-op for kind:30023 (and all non-workflow addressables)

Open tlongwell-block opened this issue 6 months ago • 2 comments

Summary

handle_a_tag_deletion in crates/sprout-relay/src/handlers/side_effects.rs (≈line 1330) only implements a side-effect branch for KIND_WORKFLOW_DEF. All other addressable kinds — including kind:30023 (NIP-23 long-form) — fall through to the _ => arm which only emits a debug log. The kind:5 deletion event is accepted and stored, but the targeted addressable row is never soft-deleted, so subsequent REQs still return it.

Why this matters

sprout-cli is gaining notes rm for the team knowledge-base workflow (NIP-23 editable notes). The semantically correct NIP-09 deletion of a parameterized-replaceable note targets its a coordinate (30023:<pubkey>:<slug>), not just the event id — otherwise a future re-set of the same slug could be shadowed by a stale tombstone or cause confusion about which event id is authoritative.

The CLI's v1 workaround is to include both an e-tag (current event id, which works via the existing soft-delete path) and an a-tag (forward-compatible, currently a no-op). Once this relay-side gap is closed, rm becomes more robust without any CLI change.

Code pointers

  • crates/sprout-relay/src/handlers/side_effects.rs:1330 — handle_a_tag_deletion; the _ => branch is the gap.
  • crates/sprout-db/src/event.rs — soft_delete_event(event_id) exists; no soft_delete_by_coordinate analogue.
  • Read-path filtering in crates/sprout-relay/src/handlers/req.rs already gates on deleted_at IS NULL, so once the side-effect path soft-deletes the row, REQs hide it automatically.

Proposed fix (sketch, non-binding)

  1. Add sprout_db::event::soft_delete_addressable(pool, kind, pubkey, d_tag) -> Result<bool> that updates deleted_at on the row matching (kind, pubkey, d_tag). The d_tag column already exists and is indexed for NIP-33 kinds.
  2. In handle_a_tag_deletion, replace the unconditional _ => debug log with a call to that helper for any parameterized-replaceable kind (or a documented allowlist if we want to be cautious). Workflow-specific logic stays where it is.

Validation already done

  • e-tag deletion path works fully for kind:30023 (deleted_at set; REQs hide it).
  • a-tag kind:5 events are accepted by validation (validate_standard_deletion_event correctly checks author ownership via pubkey-in-coordinate), but have no DB-level effect.

Scope

Out of scope: rebroadcast / discovery of the deletion event to other relays. This issue is purely about the local read-path consistency.

tlongwell-block avatar May 21 '26 23:05 tlongwell-block

This was fixed by merged PR #719 and appears stale.

Current main has the exact generic NIP-33 branch requested here: every parameterized-replaceable kind other than the workflow-specific branch calls soft_delete_by_coordinate, including kind 30023: https://github.com/block/buzz/blob/7e34bee62cacaa9d8a96c14d5892a471b59a1983/crates/buzz-relay/src/handlers/side_effects.rs#L2038-L2079

The database helper updates the live row matching (community_id, kind, pubkey, d_tag) and returns whether a row was affected: https://github.com/block/buzz/blob/7e34bee62cacaa9d8a96c14d5892a471b59a1983/crates/buzz-db/src/event.rs#L719-L749

There is also an issue-specific relay regression test that publishes kind 30023, deletes it with an a coordinate, and verifies the subsequent REQ is empty: https://github.com/block/buzz/blob/7e34bee62cacaa9d8a96c14d5892a471b59a1983/crates/buzz-test-client/tests/e2e_long_form.rs#L312-L390

The implementation landed in commit 504cfea20ddb0d9c6e86915d37eb590cd0d766c9 via #719: https://github.com/block/buzz/commit/504cfea20ddb0d9c6e86915d37eb590cd0d766c9

I confirmed the relevant Rust crates compile while checking this issue; the exact relay regression remains an ignored test requiring a live relay, so I did not claim a fresh E2E pass. Suggested maintainer action: close as completed by #719. #717 remains the separately scoped workflow-row case and has open PR #2268.

BradGroux avatar Jul 22 '26 10:07 BradGroux

Fixed by https://github.com/block/buzz/pull/719

ngthuydiem avatar Oct 05 '26 23:10 ngthuydiem