:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(replay-vision): calibrate the jev watchable bar and report score samples (#110413)
Kim Svatos Duganaca3e9f4b588
diff --git a/products/replay_vision/backend/jev_watch_feed.py b/products/replay_vision/backend/jev_watch_feed.pyindex e8deb880ea9b..b5ebfcf8c5af 100644--- a/products/replay_vision/backend/jev_watch_feed.py+++ b/products/replay_vision/backend/jev_watch_feed.py@@ -76,8 +76,11 @@ JEV_SEEN_PENALTY = 0.3# Below this probability a judged row carries no evidence: it falls to the same recency filler tier# as an unjudged row, so its card never claims the model judged it worth watching, and a judged-low# row cannot outrank a fresh observation the sweep has not seen yet. Tier membership uses the raw-# probability; the seen penalty only orders rows inside the evidence tier.-JEV_WATCHABLE_MIN = 0.5+# probability; the seen penalty only orders rows inside the evidence tier. JevK5 compresses the+# scale: it scores sessions with real friction near 0.3 and routine sessions near 0.1, so a higher+# bar empties the tier. Recalibrate from the judged event's watchability quantiles and top_scored+# sample, and bump the cache version below with any change here.+JEV_WATCHABLE_MIN = 0.3# One incident can put many near-identical watchable sessions on one scanner, and a pure probability# sort would fill the top of the feed with them. Hold each scanner to this share of the evidence# tier as it is placed (same intent as WATCH_FEED_MAX_SIGNAL_SHARE in the weighted ranker), with a@@ -93,7 +96,10 @@ WINDOW_CHUNK_SIZE = MAX_QUESTIONS_PER_REQUEST_MAX_TITLE_CHARS = 300_MAX_PROSE_CHARS = 1500_MAX_TAGS = 20-_WATCH_RANK_REDIS_PREFIX = "replay-vision:jev-watch-rank:"+# The judged set records sub-threshold rows without their scores, so a JEV_WATCHABLE_MIN change+# only reaches rows judged after it. Bump the version with the threshold: the sweep re-judges+# every window into a fresh cache, and the old keys lapse by TTL.+_WATCH_RANK_REDIS_PREFIX = "replay-vision:jev-watch-rank:v2:"# Judgments are append-only per observation and the sweep prunes entries that leave the window, so# a long lifetime is resilience, not staleness: the cache survives a day of failed sweeps before# the feed falls back to the recency filler tier and coverage rebuilds at the judging cap per hour.diff --git a/products/replay_vision/backend/temporal/jev_watch_rank/activities.py b/products/replay_vision/backend/temporal/jev_watch_rank/activities.pyindex 5414841e359e..448e29c0b432 100644--- a/products/replay_vision/backend/temporal/jev_watch_rank/activities.py+++ b/products/replay_vision/backend/temporal/jev_watch_rank/activities.py@@ -228,6 +228,15 @@ async def _judge_watch_ranks(inputs: JevWatchRankSweepInputs) -> JevWatchRankSweinput_tokens += judgment.input_tokensestimated_cost += judgment.estimated_cost_usdwith suppress(Exception):+ # Sub-threshold scores are cached nowhere, so this event is the only record of the+ # score distribution — it is the data JEV_WATCHABLE_MIN is calibrated from.+ scores = sorted(judgment.probabilities.values())+ top_scored = [+ {"id": oid, "p": round(probability, 3)}+ for oid, probability in sorted(+ judgment.probabilities.items(), key=lambda entry: entry[1], reverse=True+ )[:5]+ ]posthoganalytics.capture(event="replay_vision_jev_watch_rank_judged",distinct_id=f"team-{team_id}",@@ -239,6 +248,10 @@ async def _judge_watch_ranks(inputs: JevWatchRankSweepInputs) -> JevWatchRankSwe"mean_watchability": (fmean(judgment.probabilities.values()) if judgment.probabilities else None),+ "watchable_count": sum(1 for probability in scores if probability >= JEV_WATCHABLE_MIN),+ "watchability_p90": scores[int(0.9 * (len(scores) - 1))] if scores else None,+ "watchability_max": scores[-1] if scores else None,+ "top_scored": top_scored,"chunks": judgment.chunks,"failed_chunks": judgment.failed_chunks,"chunk_error_types": judgment.chunk_error_types,diff --git a/products/replay_vision/backend/tests/test_jev_watch_feed.py b/products/replay_vision/backend/tests/test_jev_watch_feed.pyindex 5a564a68d3a6..103b0fcb8112 100644--- a/products/replay_vision/backend/tests/test_jev_watch_feed.py+++ b/products/replay_vision/backend/tests/test_jev_watch_feed.py@@ -432,7 +432,7 @@ class TestJevWatchRankSweep(BaseTest):patch(flag, side_effect=self._flag_arm("jev-shadow")),patch(region, return_value=True),patch(_API) as api,- patch("posthoganalytics.capture"),+ patch("posthoganalytics.capture") as captured,):api.decide_when_available.side_effect = _answer_every_question(0.7)result = async_to_sync(_judge_watch_ranks)(JevWatchRankSweepInputs())@@ -440,6 +440,16 @@ class TestJevWatchRankSweep(BaseTest):assert result.scanners_judged == 1assert result.observations_judged == 2assert load_watch_ranks(self.team.id, [scanner.id]) == {str(first.id): 0.7, str(second.id): 0.7}+ # Sub-threshold scores are cached nowhere, so the judged event must carry the score sample+ # the threshold is calibrated from.+ judged = [+ call for call in captured.call_args_list if call.kwargs["event"] == "replay_vision_jev_watch_rank_judged"+ ]+ payload = judged[0].kwargs["properties"]+ assert payload["watchable_count"] == 2+ assert payload["watchability_max"] == 0.7+ assert sorted(entry["id"] for entry in payload["top_scored"]) == sorted([str(first.id), str(second.id)])+ assert all(entry["p"] == 0.7 for entry in payload["top_scored"])with (patch(flag, side_effect=self._flag_arm("jev-shadow")),