Implement NIP-91: AND operator in filters - #6
Open
mattn wants to merge 6 commits into
Open
Conversation
mattn
force-pushed
the
feat/nip-91-and-operator
branch
from
June 18, 2026 09:44
a691c2c to
a869a0e
Compare
Add support for the AND operator in REQ filters as proposed in nostr-protocol/nips#2252 (NIP-91 / NIP-119). Filter keys prefixed with "&" require every listed value to be present on a tag of that name, complementing the existing "#"-prefixed OR semantics.
Split the single test_send_records_and_tags case into seven targeted subtests covering basic match, empty result, single-value parity with OR, OR-semantics regression, multiple AND tag names, AND combined with OR, and COUNT queries.
Move matched_filters from main.cxx (static, untestable) into cagliostr.hxx as inline so the test binary can link against it without pulling in main. Add direct tests covering id/author/kind, since/until, OR tags, AND tags (single key, multiple keys, combined with OR, ignoring extra tag elements), search, and multi-filter OR semantics.
Advertise max_tags_and and max_tags_per_and (both 20) in the NIP-11 limitation block as recommended by the NIP-91 proposal, and reject filters that exceed either limit in make_filter so the advertised values are actually authoritative.
Rebase integration fixups: - pass the new has_more argument (nullptr) to send_records in the AND-filter tests, matching the NIP-67 EOSE hint signature change - empty content now fails search instead of bypassing it, per the upstream fix dropping the !ev.content.empty() guard
mattn
force-pushed
the
feat/nip-91-and-operator
branch
from
June 27, 2026 09:50
a869a0e to
2a60282
Compare
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.
Implements the AND operator for REQ filters proposed in nostr-protocol/nips#2252 (rendered as NIP-119). Filter keys prefixed with
&(e.g.&t) require an event to carry a tag of that name for every listed value, in contrast to the existing#-prefixed OR semantics. Both the in-memory subscription matcher and the SQLite/PostgreSQL storage queries were updated, and storage-level tests were added covering AND-only, OR-only, and combined-with-kinds filters.