Skip to content

: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.

chore(signals): score only inbox reports from the last 7 days (#108425)

posthog[bot]c0e1b9e98358
diff --git a/posthog/settings/object_storage.py b/posthog/settings/object_storage.py
index a5605f2c0ca4..24d5768a06c1 100644
--- a/posthog/settings/object_storage.py
+++ b/posthog/settings/object_storage.py
@@ -120,12 +120,14 @@ INBOX_RANKING_SERVING_MIRROR_REGION = os.getenv("INBOX_RANKING_SERVING_MIRROR_RE
# bounds the vectors and matrices one call holds.
INBOX_RANKING_SCORING_BATCH_SIZE = get_from_env("INBOX_RANKING_SCORING_BATCH_SIZE", 500, type_cast=int)
# Scoring sweep (products/signals/backend/ranking/sweep.py). Off by default: the schedule still
-# ticks, but the activity returns before it reads or writes anything. The max age keeps the vector
-# read inside a few weekly partitions and well inside the 3-month vector TTL. The per-tick cap
+# ticks, but the activity returns before it reads or writes anything. The 7-day max age keeps the
+# vector read to at most two weekly partitions, because the rolling window crosses one Monday
+# boundary. It also stays well inside the 3-month vector TTL. An older report keeps its latest
+# score and does not get a new score after a manifest change. The per-tick cap
# makes the first run after enabling drain the backlog over several ticks.
INBOX_RANKING_SCORING_ENABLED = get_from_env("INBOX_RANKING_SCORING_ENABLED", False, type_cast=str_to_bool)
INBOX_RANKING_SCORING_INTERVAL_MINUTES = get_from_env("INBOX_RANKING_SCORING_INTERVAL_MINUTES", 15, type_cast=int)
-INBOX_RANKING_SCORING_MAX_AGE_DAYS = get_from_env("INBOX_RANKING_SCORING_MAX_AGE_DAYS", 30, type_cast=int)
+INBOX_RANKING_SCORING_MAX_AGE_DAYS = get_from_env("INBOX_RANKING_SCORING_MAX_AGE_DAYS", 7, type_cast=int)
INBOX_RANKING_SCORING_MAX_REPORTS_PER_TICK = get_from_env(
"INBOX_RANKING_SCORING_MAX_REPORTS_PER_TICK", 2000, type_cast=int
)
diff --git a/products/signals/backend/test/test_ranking_sweep.py b/products/signals/backend/test/test_ranking_sweep.py
index ed3b48b1ce5d..c7909ac295da 100644
--- a/products/signals/backend/test/test_ranking_sweep.py
+++ b/products/signals/backend/test/test_ranking_sweep.py
@@ -141,7 +141,7 @@ class TestReportsDueForScoring(ClickhouseTestMixin, BaseTest):
self._vector(resolved, hours_ago=5)
suppressed = self._report(status=SignalReport.Status.SUPPRESSED)
self._vector(suppressed, hours_ago=5)
- too_old = self._report(age_days=40)
+ too_old = self._report(age_days=10)
self._vector(too_old, hours_ago=5)
self._report()
other_team = Team.objects.create(organization=self.organization)