Skip to content

feat(feed): explore_budget_v1 — labeling budget, fresh-viral, idle-return first slot - #367

Merged
ohld merged 1 commit into
productionfrom
feat/explore-budget-fresh-viral
Oct 30, 2026
Merged

ohld merged 1 commit into
productionfrom
feat/explore-budget-fresh-viral

Conversation

@ohld

@ohld ohld commented Oct 30, 2026

Copy link
Copy Markdown
Member

Why

Moderators get low_sent_pool in 75% of their batches: 256k sends in 30d at LR 0.24–0.32, against 0.31–0.42 from other engines for the same users. 40% of those sends go to 180–360-day-old memes at their 21st+ send. 75% go to sources the user mostly dislikes, because the source demote is not applied there. Labeling needs about 3.9k reactions/day and low_sent delivers about 8.5k. Meanwhile regular users rarely see fresh winners, and the first feed meme after a push (lr_smoothed slot 0) is where sessions die (23% abandon).

What (behind explore_budget_v1, 50/50 per-user hash, users with nmemes_sent >= 30)

  1. Labeling budget. Moderator low_sent quota is 50% (was 75%). low_sent_pool serves only memes < 7d old with < 20 reactions. It early-stops at smoothed LR (l+1)/(n+2) < 0.25 after ≥ 10 reactions, and orders the user's disliked sources last (existing RECOMMENDATION_DEMOTE_*). An unfilled quota already falls through to the blend (remaining_limit).
  2. Fresh-viral. like_spread_and_recent_memes(fresh_viral=True) is registered as engine fresh_viral: < 72h, ≥ 20 reactions, raw LR ≥ 0.50. It gets 15% of mature blend mass, with the other engines scaled ×0.85. Blend candidates drop fresh (< 7d) memes with ≥ 20 reactions and LR < 0.40, using one PK lookup per batch.
  3. Idle-return first slot. With an empty queue (Redis TTL 1h, so idle > 1h or arriving from a push), slot 0 comes from like_spread_and_recent_memes instead of lr_smoothed. For moderators, that meme goes before the labeling memes.
  4. Migration ix_meme_ok_created_at: partial meme(created_at) WHERE status='ok', built CONCURRENTLY and safe to rerun.

Kill switch: EXPLORE_BUDGET_V1_ENABLED=false puts everyone on control. Control behavior is unchanged.

Latency (prod EXPLAIN ANALYZE, heaviest 3-language moderator)

query as-is (no index) index-equivalent range plan
low_sent control (today) 3,581 ms —
low_sent treatment 441 ms 97 ms
fresh_viral 365 ms 57 ms
bad-fresh filter (90 ids) 1.6 ms 1.6 ms

The "index-equivalent" plan bounds meme.id to the same 7d / 72h window. That is the range scan the new index gives, but measured without creating it, since prod is read-only. After deploy, verify the planner picks ix_meme_ok_created_at.

Measurement

experiments/active/2026-10-30-explore-budget.md sets the decision rule, with a check on 2026-11-20. docs/analyst/explore-budget-v1.sql is one read-only SELECT. It was validated on prod against an existing experiment cohort and runs in about 12s.

  • Primary: likes per active user per week and memes per session (per-user means, broadcasts excluded, split mod / user).
  • Guardrails: fresh RU memes with ≥ 10 reactions within 7d stay ≥ 90% (baseline 100%, n = 2251); no rise in empty-queue errors (Sentry batch diagnostics); pos2 abandonment ≤ control.

Tests

Host-mode against a throwaway Postgres 14 and Redis: tests/feed_turn/test_planner.py plus tests/recommendations/ give 255 passed, 2 skipped. Alembic upgrade/downgrade works with a single head. New tests cover the quota, the idle-return slot, the fresh_viral weight, the bad-fresh drop, control parity, a deterministic ~50/50 split with assignment persistence, and the SQL for low_sent treatment, fresh_viral and bad-fresh. test_queue_correctness.py is pinned to control, because its fixed test user hashes into treatment.

Risks

  • Moderators get fewer labels from low_sent. The guardrail covers this; if it breaks, raise the quota before killing.
  • Bad-fresh and fresh-viral use lifetime stats for memes < 7d / < 72h old as a proxy for "first 20 reactions".
  • Until the index migration runs, the treatment queries take about 0.4s for the heaviest users (still about 8× faster than today's control low_sent).
  • Each eligible batch does one experiment_assignment lookup (unique index).

…idle-return first slot

50/50 per-user experiment (nmemes_sent >= 30, kill switch EXPLORE_BUDGET_V1_ENABLED):
- low_sent_pool: moderator quota 50%, only <7d memes with <20 reactions,
  early-stop smoothed LR <0.25, disliked sources ordered last
- fresh_viral engine (<72h, >=20 reactions, LR >=0.5) at 15% of mature blend;
  blend drops fresh memes with >=20 reactions and LR <0.4
- empty queue (idle >1h / post-push): slot 0 from like_spread instead of lr_smoothed
- partial index meme(created_at) WHERE status='ok' for the fresh-window queries
- experiment doc + read-only readout SQL
@ohld
ohld force-pushed the feat/explore-budget-fresh-viral branch from 9808fec to 2734258 Compare October 30, 2026 17:38
@ohld
ohld merged commit 75a36f5 into production Oct 30, 2026
2 checks passed
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.

1 participant