fix(relay): soft-delete workflow definition event on workflow delete - #4318
Open
iroiro147 wants to merge 1 commit into
Open
fix(relay): soft-delete workflow definition event on workflow delete#4318iroiro147 wants to merge 1 commit into
iroiro147 wants to merge 1 commit into
Conversation
`buzz workflows delete` removes the `workflows` row and invalidates the engine cache (so triggers fail correctly), but the kind:30620 definition event itself stayed live — `workflows list` and `workflows get` were still reading it via Nostr REQ, so every surface an operator could inspect reported the workflow as live. Triggering afterwards was the only way to find out it was gone. The generic addressable-events arm in `handle_a_tag_deletion` already soft-deletes by coordinate; the workflow arm never did. Extend the workflow arm to call `soft_delete_by_coordinate(30620, pubkey, d_tag)` once the row has been successfully deleted — gated on the delete succeeding so a failed match can't tombstone a live workflow's event. Refs: block#2879 Signed-off-by: Sarthak Singh <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.
What
Makes
buzz workflows deleteactually hide the workflow from every read path — not just from triggers.Why (bug report)
Filer verified end-to-end on v0.4.26 against the live relay:
The row delete succeeded; only the trigger endpoint knew. Operators monitoring the relay via
list/getcouldn't tell deleted from live without attempting a trigger.Root cause
handle_a_tag_deletionincrates/buzz-relay/src/handlers/side_effects.rsdispatches on thekindin theatag. TheKIND_WORKFLOW_DEFarm calleddelete_workflow_for_ownerandinvalidate_channel_workflows, then returned — it never soft-deleted the kind:30620 event row itself. The generic addressable-events arm below it (is_parameterized_replaceable) does callsoft_delete_by_coordinate, but the workflow branch returns first.The generic arm's doc comment even called this out:
That "separate concern" is exactly this bug. The "by design" doesn't survive contact with the actual read paths:
workflows listandworkflows getboth query the kind:30620 event via REQ, so a live event row made the relay keep reporting the deleted workflow.How
()).Some: decode thepubkey_hexfrom theatag and callsoft_delete_by_coordinate(30620, pubkey, d_tag)on the live event row, with the standardcreated_atcutoff so a stale deletion event cannot tombstone a newer replacement head.delete_workflow_for_ownerfails (owner mismatch, etc.), the event row is left alone. A failed delete must not be able to hide a live workflow.Files
crates/buzz-relay/src/handlers/side_effects.rs—handle_a_tag_deletionworkflow arm, +54 / −1.Verification
cargo check -p buzz-relay --lib— clean.cargo test -p buzz-relay --lib workflow— 17/17 pass.cargo test -p buzz-relay --lib— 827 pass, 9 fail (identical to baselinemain; pre-existing media/admin/env-gated tests unrelated to this change).Behavior
workflows delete(row + event)workflows listafter deleteworkflows getafter deleteworkflows triggerafter delete400 workflow not found400 workflow not found(unchanged)Closes #2879.