Files
buzz/crates/buzz-core
npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 c9a1458f5e fix(relay/core): plug COUNT existence-leak and StopReason forward-compat for NIP-AM
Two Thufir-flagged IMPORTANT fixes for PR #1445.

Count gate (COUNT existence leak):
- Add RESULT_GATED_KINDS = [KIND_DM_VISIBILITY, KIND_AGENT_TURN_METRIC] to
  kind.rs — explicit list of kinds that require per-event owner verification
  even for COUNT queries.
- Add filter_can_match_result_gated_kinds() to req.rs — returns true when
  filter has no kinds constraint (wildcard) or includes a result-gated kind.
- Add result_gated_count_safe_for_pushdown() to req.rs — safe to use fast
  SQL count_events() only when filter's #p tag is non-empty and all values
  equal the authenticated reader's pubkey.
- Apply the guard in count.rs (WS): both with-channel and without-channel
  fast-path conditions now require !needs_result_gated_filtering; both
  fallback loops now call reader_authorized_for_event per event.
- Apply the guard in bridge.rs (HTTP): same two fast-path conditions and
  same two fallback loops.
- 6 unit tests covering wildcard/explicit/safe-pushdown/unsafe cases.

StopReason forward-compatibility:
- Replace #[derive(Deserialize)] on StopReason with a custom impl that maps
  any unrecognized string to StopReason::Unknown instead of returning an
  error; NIP-AM requires consumers to accept future stopReason values.
- Add test unknown_stop_reason_maps_to_unknown_not_error: future value
  tool_limit deserializes to Unknown; token counts remain intact.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
2026-07-01 18:47:14 -04:00
..