refactor: generalize recommendation pipeline — candidate → rank → render stages #80

Closed
opened 2026-04-16 15:25:11 +00:00 by alvis · 0 comments
Owner

Motivation

The current recommender mixes candidate fetching, feature extraction, policy selection, and tip serving in one function. As we add AI-generated tips, multiple signal sources, and more policies, this becomes unmaintainable.

Design

Split POST /recommend into a staged pipeline:

1. CandidateGenerator[] → Signal[]     (pluggable sources)
2. FeatureExtractor → FeatureVector[]   (per-candidate features + global context)
3. RankingPolicy → scored candidates    (bandit, ML model, heuristic)
4. TipRenderer → final tip text         (pass-through, LLM polish, template)
5. DeliveryDecision → serve or defer     (timing, quiet hours, fatigue)

Each stage is an interface. Pipeline composition is config-driven.

Tasks

  • Define CandidateGenerator, FeatureExtractor, RankingPolicy, TipRenderer interfaces
  • Refactor existing code into these stages (no behavior change)
  • Pipeline config: which generators, which policy, which renderer
  • Shadow pipeline support (run two full pipelines, compare outputs)
  • Metrics per stage (latency, candidate count, score distribution)
  • ADR for pipeline architecture
## Motivation The current recommender mixes candidate fetching, feature extraction, policy selection, and tip serving in one function. As we add AI-generated tips, multiple signal sources, and more policies, this becomes unmaintainable. ## Design Split `POST /recommend` into a staged pipeline: ``` 1. CandidateGenerator[] → Signal[] (pluggable sources) 2. FeatureExtractor → FeatureVector[] (per-candidate features + global context) 3. RankingPolicy → scored candidates (bandit, ML model, heuristic) 4. TipRenderer → final tip text (pass-through, LLM polish, template) 5. DeliveryDecision → serve or defer (timing, quiet hours, fatigue) ``` Each stage is an interface. Pipeline composition is config-driven. ## Tasks - [ ] Define `CandidateGenerator`, `FeatureExtractor`, `RankingPolicy`, `TipRenderer` interfaces - [ ] Refactor existing code into these stages (no behavior change) - [ ] Pipeline config: which generators, which policy, which renderer - [ ] Shadow pipeline support (run two full pipelines, compare outputs) - [ ] Metrics per stage (latency, candidate count, score distribution) - [ ] ADR for pipeline architecture
alvis added this to the M2 — AI tips + multi-source signals milestone 2026-04-16 15:25:11 +00:00
alvis closed this issue 2026-04-17 14:22:49 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: alvis/oO#80