fix(relay): allow deleting archived channels - #7569
Open
hyein-cbio wants to merge 1 commit into
Open
hyein-cbio wants to merge 1 commit into
hyein-cbio wants to merge 1 commit into
Conversation
Archive is a write-lock, not a tombstone. Owners could unarchive (kind:9002 archived=false) but not delete (kind:9008), so ephemeral huddle backing channels archived on hang-up or by the TTL reaper could not be removed. Signed-off-by: Hyein Cho <hyein.cho.cbio@gmail.com>
🔐 Codex Security Review
|
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.
Summary
Archive is a write-lock, not a tombstone. Owners could unarchive a channel (
kind:9002+archived=false) but could not delete it (kind:9008), so the relay rejected delete withinvalid: channel is archived.That left ephemeral huddle backing channels stuck: hang-up and the TTL reaper archive them, and there was no way to remove them afterward.
This change extracts a shared helper,
allow_event_on_archived_channel, used by both production gates (ingestandvalidate_admin_event). The only mutations that remain valid on an archived channel are:kind:9002+archived=false)kind:9008)Everything else stays rejected (messages, membership, rename,
kind:9005). Kind9008still requires owner (or owner-of-owner-agent) authorization.soft_delete_channelalready keys ondeleted_at IS NULL, notarchived_at, so delete after archive actually lands.Related issue
Same bug as #2954. Open PRs for it: #2988, #4669. Both last moved 2026-08-19. This is not a new diagnosis.
Compared with #2988 and #4669
All three PRs touch the same three files and the same two archived-channel guards. They are the same fix, restated.
#2988 (July, Fixes #2954) is the original. It inlines
is_deleteat both gates instead of sharing a helper, so the two exceptions can drift again. It has no unit test. Its ignored e2e is the strongest of the three: archive/unarchive/re-archive with a nonce so duplicate event ids cannot skip side effects; name-edit still hitschannel is archived; non-owner 9008 fails withonly owner can delete group(auth ran, not the archive guard); owner delete then unarchive fails withchannel not found. It still callsget_channel.#4669 (August) is the shared-helper version of that idea (
archived_channel_allows_event) and usesKIND_NIP29_DELETE_GROUP/KIND_NIP29_EDIT_METADATA. Unit tests only cover allow-9008, unarchive vs archive, and reject-9000. E2E is owner archive-then-deleteaccepted, like this PR. It also still callsget_channel.This PR keeps the shared helper, on current
main(get_channel_for_event_write). The unit table is stricter than #4669: it also rejects name-only9002,9005, and kind 1. Comments pin 9008 to huddle hang-up and the TTL reaper. The helper uses9008/9002literals to match nearbyside_effects.rsmatch arms; #2988 and #4669 are better on that point. The e2e is weaker than #2988: it does not prove non-owner auth, post-delete disappearance, or that a rename still hits the write-lock.If maintainers want one of these, #2988 has the issue link and the better live-path test; #4669 and this PR have the better gate structure. This one is the rebase onto today's call sites.
Testing
archived_channel_allows_unarchive_and_delete_group_onlybinds the production helper: allows 9008 and 9002archived=false; rejects 9002archived=true, name-only 9002, 9000, 9005, and kind 1. Ran locally: pass.test_owner_can_delete_archived_channeldrives archive then 9008 through ingest.#[ignore]like the rest ofe2e_relay.rs(needs a live relay). Weaker than fix(relay): allow owner to delete archived channels #2988's e2e, as above.