Filter trait and returns a FilterResult containing both kept and removed candidates.
Overview
Filters implement an asynchronousfilter method that partitions candidates into kept and removed lists. Filters can optionally implement an enable method to conditionally activate based on query parameters.
Available Filters
AgeFilter
Removes tweets older than a specified duration using Snowflake ID timestamps.Maximum age threshold for tweets. Tweets older than this duration are filtered out.
home-mixer/filters/age_filter.rs
AuthorSocialgraphFilter
Removes candidates from authors that the viewer has blocked or muted. Purpose: Respects user preferences and social graph settings Logic:- Checks
query.user_features.blocked_user_ids - Checks
query.user_features.muted_user_ids - Removes candidates where author matches either list
- Short-circuits if both lists are empty for performance
home-mixer/filters/author_socialgraph_filter.rs
CoreDataHydrationFilter
Filters out candidates that failed to hydrate essential data from backend services. Purpose: Ensures all candidates have minimum required data for display Criteria:- Author ID must be non-zero
- Tweet text must be non-empty (after trimming)
home-mixer/filters/core_data_hydration_filter.rs
DedupConversationFilter
Keeps only the highest-scored candidate per conversation branch. Purpose: Prevents multiple tweets from the same conversation thread appearing in the feed Algorithm:- Groups candidates by conversation ID (derived from ancestors)
- For each conversation, keeps only the highest-scoring tweet
- Removes all other tweets from that conversation
home-mixer/filters/dedup_conversation_filter.rs
DropDuplicatesFilter
Removes duplicate tweets based on tweet ID. Purpose: Ensures each unique tweet appears at most once in the feed Implementation: Uses aHashSet to track seen tweet IDs
home-mixer/filters/drop_duplicates_filter.rs
IneligibleSubscriptionFilter
Filters out subscription-only posts from authors the viewer hasn’t subscribed to. Purpose: Enforces subscription access controls Logic:- If
candidate.subscription_author_idisNone, keep the candidate (not subscription-gated) - If
Some(author_id), check if viewer is subscribed to that author - Remove if not subscribed
home-mixer/filters/ineligible_subscription_filter.rs
MutedKeywordFilter
Filters out tweets containing keywords the user has muted.Tokenizer for processing tweet text and muted keywords
- Tokenizes user’s muted keywords
- Creates a
UserMutesmatcher with token sequences - Tokenizes each candidate’s tweet text
- Removes candidates matching any muted keyword pattern
home-mixer/filters/muted_keyword_filter.rs
PreviouslySeenPostsFilter
Filters out posts the user has already seen using Bloom filters and explicit seen ID lists. Purpose: Prevents showing the same content multiple times Data Sources:query.seen_ids: Explicit list of seen post IDs from the clientquery.bloom_filter_entries: Probabilistic data structure for efficient seen-post checks
home-mixer/filters/previously_seen_posts_filter.rs
PreviouslyServedPostsFilter
Filters out posts that have already been served in previous responses (used for pagination). Conditional Activation: Only enabled for bottom requests (pagination)home-mixer/filters/previously_served_posts_filter.rs
query.served_ids and filters candidates whose IDs (or related post IDs) appear in that set
RetweetDeduplicationFilter
Deduplicates retweets, keeping only the first occurrence of a tweet. Purpose: Prevents seeing both an original tweet and retweets of it Algorithm:- Track seen tweet IDs in a
HashSet - For original tweets: mark ID as seen and keep
- For retweets: check if retweeted tweet ID is already seen
- Keep first occurrence, remove subsequent ones
home-mixer/filters/retweet_deduplication_filter.rs
SelfTweetFilter
Removes tweets where the author is the viewer. Purpose: Prevents users from seeing their own tweets in the For You feed Implementation:home-mixer/filters/self_tweet_filter.rs
VFFilter
Visibility Filtering - applies safety and policy rules to filter inappropriate content. Purpose: Enforces platform safety policies and content guidelines Logic:- Checks
candidate.visibility_reasonfield - If
FilteredReason::SafetyResultindicatesAction::Drop, removes candidate - Removes candidates with any other filtered reason
home-mixer/filters/vf_filter.rs
Filter Pipeline Order
Filters are typically applied in a specific order to optimize performance:- CoreDataHydrationFilter - Remove invalid candidates early
- VFFilter - Apply safety rules
- SelfTweetFilter - Remove viewer’s own tweets
- AuthorSocialgraphFilter - Respect blocks and mutes
- DropDuplicatesFilter - Remove duplicate IDs
- PreviouslySeenPostsFilter - Filter previously seen content
- PreviouslyServedPostsFilter - Filter paginated content
- AgeFilter - Remove stale content
- RetweetDeduplicationFilter - Deduplicate retweets
- DedupConversationFilter - Deduplicate conversations
- MutedKeywordFilter - Apply keyword mutes
- IneligibleSubscriptionFilter - Enforce subscription access