Fix Brazil election filter excluding a listed viewer's own id - #53
Open
Pitchfork-and-Torch wants to merge 1 commit into
Open
Fix Brazil election filter excluding a listed viewer's own id#53Pitchfork-and-Torch wants to merge 1 commit into
Pitchfork-and-Torch wants to merge 1 commit into
Conversation
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
marked this pull request as ready for review
August 14, 2026 22:23
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.
Bug
Brazil2026ElectionFiltertreats a user as excluded when they are on the Electoral Court list and not inquery.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:
retweeted_user_id == query.user_id)quoted_user_id == query.user_id)ancestor_usersincludes the viewerSelfTweetFilteralready removes the viewer's own posts. This hole is the amplification / thread-context path.SelfReplyChainFilteralready insertsquery.user_idinto 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_idinto the allowed set beforeshould_remove.is_excluded_authoris unchanged: listed and!followed_user_ids.contains. Unfollowed listed authors, retweets, quotes, and ancestors still drop.Tests
Lane:
home-mixer/filters/brazil_2026_election_filter.rsonly. Based onxai-org/x-algorithmmain (c65aa179).