Repository navigation
feat(feed): explore_budget_v1 — labeling budget, fresh-viral, idle-return first slot - #367
Merged
Merged
Conversation
…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
force-pushed
the
feat/explore-budget-fresh-viral
branch
from
October 30, 2026 17:38
9808fec to
2734258
Compare
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.
Why
Moderators get
low_sent_poolin 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 withnmemes_sent >= 30)low_sent_poolserves 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 (existingRECOMMENDATION_DEMOTE_*). An unfilled quota already falls through to the blend (remaining_limit).like_spread_and_recent_memes(fresh_viral=True)is registered as enginefresh_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.like_spread_and_recent_memesinstead oflr_smoothed. For moderators, that meme goes before the labeling memes.ix_meme_ok_created_at: partialmeme(created_at) WHERE status='ok', built CONCURRENTLY and safe to rerun.Kill switch:
EXPLORE_BUDGET_V1_ENABLED=falseputs everyone on control. Control behavior is unchanged.Latency (prod EXPLAIN ANALYZE, heaviest 3-language moderator)
The "index-equivalent" plan bounds
meme.idto 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 picksix_meme_ok_created_at.Measurement
experiments/active/2026-10-30-explore-budget.mdsets the decision rule, with a check on 2026-11-20.docs/analyst/explore-budget-v1.sqlis one read-only SELECT. It was validated on prod against an existing experiment cohort and runs in about 12s.Tests
Host-mode against a throwaway Postgres 14 and Redis:
tests/feed_turn/test_planner.pyplustests/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.pyis pinned to control, because its fixed test user hashes into treatment.Risks
experiment_assignmentlookup (unique index).