From 2fd35289a22aef5344653d16665123bba1a41721 Mon Sep 17 00:00:00 2001 From: Logan Johnson Date: Thu, 8 Oct 2026 14:27:01 -0400 Subject: [PATCH] feat(relay): let group-state filters opt in to system channels A filter on kinds 39000-39003 with #t:["system"] or any #P now also returns the system channels the reader can read (member, or open), and then matches as usual. kind:39000 to 39003 already carry ["t", ] and ["P", ], so this needs no new filter key. Existing clients send neither on these kinds, so they still never see a system channel. This makes the lookups a consumer needs work in one SQL-backed filter: - {kinds:[39002], #p:[me], #t:["system"]} lists my system channels; - {kinds:[39000], #t:["system"]} lists the open ones; - {kinds:[39000], #P:[creator], #t:[label]} finds one creator's labeled channel, system or not. The opt-in applies per filter, on REQ, COUNT and the HTTP bridge. NOSTR.md documents the system channel query rules. Signed-off-by: Logan Johnson Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz> --- NOSTR.md | 18 +++ .../handlers/system_channel_postgres_tests.rs | 120 ++++++++++++++++++ .../src/handlers/system_channels.rs | 83 +++++++++++- 3 files changed, 216 insertions(+), 5 deletions(-) diff --git a/NOSTR.md b/NOSTR.md index f869035a1b..28a154e1db 100644 --- a/NOSTR.md +++ b/NOSTR.md @@ -134,6 +134,24 @@ label set with more than 8 labels, a label that is not 1-64 characters from `a-z`, `0-9`, `.`, `:` and `-`, or a label equal to a channel type name (`stream`, `forum`, `dm`, `workflow`, `system`). +**System channels.** A channel with `channel_type` `system` exists only for +access control, for example to hold config that only an agent and its owner +can read. It is an ordinary channel in every other way, but queries leave it +out unless they ask for it: + +- A filter that does not name it, for example a REQ with no `#h`, a COUNT, + a NIP-50 search, or kind:39002 `#p:[me]`, does not return it. +- A filter that names it with `#h`, or with `#d` on kinds 39000–39003, reads + it under the ordinary rules: the reader is a member, or it is open. +- A filter on kinds 39000–39003 with `#t:["system"]` or any `#P` also + returns the system channels the reader can read, then matches as usual. + For example, `{kinds:[39000], #P:[], #t:[