Skip to content

feat: /search groupings, include_state, left-room search#240

Merged
sufforest merged 1 commit into
mainfrom
wzy/search-spec-gaps
Jul 4, 2026
Merged

feat: /search groupings, include_state, left-room search#240
sufforest merged 1 commit into
mainfrom
wzy/search-spec-gaps

Conversation

@sufforest

Copy link
Copy Markdown
Owner

PR 3 (final polish) of the full-text search feature. Adds the remaining spec surface of POST /v3/search.

What's added

  • Groupings (groupings.group_by): partitions results by room_id and/or sender into the groups block ({group_value: {results, order}}), order = best member rank.
  • include_state: returns the current state of each joined room in the results. Gated to currently-joined rooms — a departed member must not learn how a room's state changed after they left (Synapse never hits this since it doesn't search left rooms).
  • Left-room search: the room seed is now joined ∪ left, so search covers rooms the user has left, bounded to what they could see before leaving via the per-event leave-cap (bans handled the same way, capped at the ban).

Hardening (found by review): the shared read gate (resolve_reader, used by /messages, /context, /event too) now fails closed for a departed caller with no recorded leave position — it applies per-event history-visibility instead of returning post-departure events. Latent before, but reachable now that search auto-enumerates every left room.

Tests: groupings partition-by-room/sender, include_state returns m.room.create-bearing state, left-room search bounded by leave (and no state leak), banned-user search capped at ban (no post-ban events, no state).

Known limitation (documented in code): a very active left room can under-return — the newest-1000 candidate window may be all post-leave. Fine for quiet/small left rooms and still ahead of Synapse (no left-room search at all); a leave-cap-relative scan bound is a possible follow-up.

completes the spec surface of POST /search: groupings.group_by
(room_id / sender), include_state (current state of the joined rooms in
the results), and searching rooms the user has left — bounded to what
they could see before leaving via the per-event leave-cap.

include_state is gated to currently-joined rooms so a departed member
never learns how a room's state changed after they left. and the shared
read gate now fails closed for a departed caller with no recorded leave
position (legacy rooms): it applies the per-event history-visibility
filter instead of returning post-departure events — reachable now that
search auto-enumerates every left room.
@sufforest sufforest merged commit df0eafc into main Jul 4, 2026
11 checks passed
@sufforest sufforest deleted the wzy/search-spec-gaps branch July 4, 2026 23:21
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