Skip to content

Implement NIP-91: AND operator in filters - #6

Open
mattn wants to merge 6 commits into
mainfrom
feat/nip-91-and-operator
Open

Implement NIP-91: AND operator in filters#6
mattn wants to merge 6 commits into
mainfrom
feat/nip-91-and-operator

Conversation

@mattn

@mattn mattn commented Apr 17, 2026

Copy link
Copy Markdown
Owner

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.

@mattn
mattn force-pushed the feat/nip-91-and-operator branch from a691c2c to a869a0e Compare June 18, 2026 09:44
mattn added 6 commits June 27, 2026 18:35
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
mattn force-pushed the feat/nip-91-and-operator branch from a869a0e to 2a60282 Compare June 27, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant