X Algorithm Architecture
Master reference for the X (Twitter) recommendation engine architecture, specifically the HomeMixer orchestration layer, ProductMixer functional components, and the Scala-to-Rust candidate pipeline bridge.
Context
The X recommendation engine operates as a "Lambda Architecture" variant. The orchestration layer (HomeMixer) is written in Scala using the ProductMixer framework, which defines the business logic graph. High-compute tasks (Candidate Retrieval, Scoring) are offloaded to optimized services (Rust/C++/Java).
For detailed technical breakdowns, see:
What it does
- Maps the Request Graph: Traces the execution path from
HomeMixer down to leaf services like Earlybird (Search) and Navi (ML Scoring).
- Defines ProductMixer Traits: Explains the specific Scala traits used to build feed features:
CandidateSource, Filter, Scorer, Gate, Selector, and SideEffect.
- Identifies Data Models: Recognizes key data structures like
SimClusters (Community Embeddings), TwHIN (Knowledge Graph), and RealGraph (User Interaction probabilities).
- Locates Logic: Helps determine if logic resides in the orchestration layer (Scala) or the compute layer (Rust/Thrift).
Guidelines
- Directory Navigation:
home-mixer/: Main orchestration logic for the timeline.
product-mixer/: Core framework defining how pipelines are built.
cr-mixer/: Content Recommender Mixer (Out-of-Network retrieval logic).
navi/: ML Model serving infrastructure (Heavy Ranker host).
visibility-lib/: Rust-based filtering logic (Safety, Blocks, Mutes).
- ProductMixer Hierarchy: The system is composed of pipelines.
- Mixer Pipeline: The top-level entry (e.g., "For You").
- Candidate Pipeline: Parallel fetching of candidates (e.g., "In-Network", "Ads", "Who to Follow").
- Functional Components: Atomic units of logic (
Filter, Scorer, Hydrator).
- Scoring Stages: distinguish between Light Ranking (fast, heuristic-based, often inside
Earlybird) and Heavy Ranking (full neural network, hosted in Navi).
- Candidate Isolation: In the Heavy Ranker (MaskNet/Transformer), candidates are scored in a batch but cannot attend to each other (no cross-candidate attention). They only attend to the User Context.
- Thrift Boundaries: Scala components communicate with Rust services via Thrift. If a field isn't in the Thrift definition,
HomeMixer cannot see it.
- Feature Stores: Understand that
SignalIngester and UserSignalService provide the raw interaction data that feeds SimClusters and RealGraph.
Example Trigger Prompts
- "/trace-feed ForYou"
- "/trace-feed HomeMixer → HeavyRanker"
- "/trace-feed CandidateSource vs Gate in ProductMixer"
- "Where are SimClusters embeddings injected in the pipeline?"
- "Explain cr-mixer’s Out-of-Network candidate generation"
- "How does visibility-lib enforce feed filtering?"
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: x-architecture3description: Use this skill when reasoning about the distributed system design, service orchestration, or request lifecycle of the X recommendation engine. It is essential for tasks involving the "For You" timeline construction, HomeMixer logic, or ProductMixer component definitions.4---56# X Algorithm Architecture78Master reference for the X (Twitter) recommendation engine architecture, specifically the HomeMixer orchestration layer, ProductMixer functional components, and the Scala-to-Rust candidate pipeline bridge.910## Context1112The X recommendation engine operates as a "Lambda Architecture" variant. The orchestration layer (**HomeMixer**) is written in Scala using the **ProductMixer** framework, which defines the business logic graph. High-compute tasks (Candidate Retrieval, Scoring) are offloaded to optimized services (Rust/C++/Java).1314For detailed technical breakdowns, see:15- [Pipeline Lifecycle](./references/pipeline-lifecycle.md)16- [Service Map](./references/service-map.md)1718## What it does1920* **Maps the Request Graph:** Traces the execution path from `HomeMixer` down to leaf services like `Earlybird` (Search) and `Navi` (ML Scoring).21* **Defines ProductMixer Traits:** Explains the specific Scala traits used to build feed features: `CandidateSource`, `Filter`, `Scorer`, `Gate`, `Selector`, and `SideEffect`.22* **Identifies Data Models:** Recognizes key data structures like `SimClusters` (Community Embeddings), `TwHIN` (Knowledge Graph), and `RealGraph` (User Interaction probabilities).23* **Locates Logic:** Helps determine if logic resides in the orchestration layer (Scala) or the compute layer (Rust/Thrift).2425## Guidelines2627* **Directory Navigation:**28 * `home-mixer/`: Main orchestration logic for the timeline.29 * `product-mixer/`: Core framework defining how pipelines are built.30 * `cr-mixer/`: Content Recommender Mixer (Out-of-Network retrieval logic).31 * `navi/`: ML Model serving infrastructure (Heavy Ranker host).32 * `visibility-lib/`: Rust-based filtering logic (Safety, Blocks, Mutes).33* **ProductMixer Hierarchy:** The system is composed of pipelines.34 1. **Mixer Pipeline:** The top-level entry (e.g., "For You").35 2. **Candidate Pipeline:** Parallel fetching of candidates (e.g., "In-Network", "Ads", "Who to Follow").36 3. **Functional Components:** Atomic units of logic (`Filter`, `Scorer`, `Hydrator`).37* **Scoring Stages:** distinguish between **Light Ranking** (fast, heuristic-based, often inside `Earlybird`) and **Heavy Ranking** (full neural network, hosted in `Navi`).38* **Candidate Isolation:** In the Heavy Ranker (MaskNet/Transformer), candidates are scored in a batch but *cannot* attend to each other (no cross-candidate attention). They only attend to the User Context.39* **Thrift Boundaries:** Scala components communicate with Rust services via Thrift. If a field isn't in the Thrift definition, `HomeMixer` cannot see it.40* **Feature Stores:** Understand that `SignalIngester` and `UserSignalService` provide the raw interaction data that feeds `SimClusters` and `RealGraph`.4142## Example Trigger Prompts4344* "/trace-feed ForYou"45* "/trace-feed HomeMixer → HeavyRanker"46* "/trace-feed CandidateSource vs Gate in ProductMixer"47* "Where are SimClusters embeddings injected in the pipeline?"48* "Explain cr-mixer’s Out-of-Network candidate generation"49* "How does visibility-lib enforce feed filtering?"5051---52> Converted and distributed by [TomeVault](https://tomevault.io/claim/elemontcapital) — claim your Tome and manage your conversions.53<!-- tomevault:4.0:skill_md:2026-04-13 -->