Skip to content

Fix Brazil election filter excluding a listed viewer's own id - #53

Open
Pitchfork-and-Torch wants to merge 1 commit into
xai-org:mainfrom
Pitchfork-and-Torch:cursor/brazil-election-filter-4cfe
Open

Fix Brazil election filter excluding a listed viewer's own id#53
Pitchfork-and-Torch wants to merge 1 commit into
xai-org:mainfrom
Pitchfork-and-Torch:cursor/brazil-election-filter-4cfe

Conversation

@Pitchfork-and-Torch

Copy link
Copy Markdown

Bug

Brazil2026ElectionFilter treats a user as excluded when they are on the Electoral Court list and not in query.user_features.followed_user_ids.

That follow set is the social-graph following list. It never contains the viewer. So if the viewer is themselves a listed account, their own id is excluded.

That drops For You candidates that only surface the viewer:

  • someone else retweets the viewer (retweeted_user_id == query.user_id)
  • someone else quotes the viewer (quoted_user_id == query.user_id)
  • a reply whose ancestor_users includes the viewer

SelfTweetFilter already removes the viewer's own posts. This hole is the amplification / thread-context path.

SelfReplyChainFilter already inserts query.user_id into its allowed set for the same reason. This filter did not.

Existing tests used ScoredPostsQuery::default() (empty follows, user_id == 0) and never covered the follower exception or self-id.

Fix

Insert query.user_id into the allowed set before should_remove.

is_excluded_author is unchanged: listed and !followed_user_ids.contains. Unfollowed listed authors, retweets, quotes, and ancestors still drop.

Tests

  • listed author the viewer follows is kept; a different unfollowed listed author still drops
  • retweet / quote / listed ancestor of the viewer are kept
  • the same three shapes still drop when the listed id is not the viewer and is not followed
  • reply is kept when the viewer follows the listed ancestor

Lane: home-mixer/filters/brazil_2026_election_filter.rs only. Based on xai-org/x-algorithm main (c65aa179).

followed_user_ids never includes the viewer, so a listed account's
own id was treated as excluded. Retweets, quotes, and replies that
only surface the viewer were dropped from their For You.

Insert query.user_id into the allowed set (same as SelfReplyChainFilter).
Keep is_excluded_author's follow-set contains check. Add tests for the
follower exception, self-id, and unfollowed listed still dropping.

Co-authored-by: Jon Bailey <Pitchfork-and-Torch@users.noreply.github.com>
@Pitchfork-and-Torch
Pitchfork-and-Torch marked this pull request as ready for review August 14, 2026 22:23
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.

2 participants