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.

fix(self-driving): Undergroup less (#75963)

Michael Matlokaa25c46bde387
diff --git a/products/signals/backend/temporal/grouping.py b/products/signals/backend/temporal/grouping.py
index 663eff3950dc..ee629a606f3b 100644
--- a/products/signals/backend/temporal/grouping.py
+++ b/products/signals/backend/temporal/grouping.py
@@ -269,6 +269,7 @@ IMPORTANT: Signals should be grouped if they are meaningfully related, not just
- A session behaviour anomaly AND an insight alert about the same user flow SHOULD match (related by user journey)
- Two "experiment reached significance" signals from DIFFERENT, unrelated experiments should NOT match
- Two signals about the SAME experiment (e.g., significance + follow-up analysis) SHOULD match
+- Two error-tracking signals from the SAME underlying defect or resolved by the same fix applied at different call sites SHOULD match, even if they surface in different files, components, or pages (they resolve to one fix)
You will receive:
1. A new signal with its description and source information
@@ -310,25 +311,24 @@ You will receive:
Your job:
1. Write a single PR title (max 70 chars) that covers ALL signals in the group INCLUDING the new one.
-2. Judge: is this PR title specific enough that one engineer could ship it in a single pull request?
+2. Judge: would ONE focused change resolve every signal in the group? If a single fix — even one applied at several call sites — addresses them all, they belong in one PR.
-A SPECIFIC PR title targets one feature, one bug, one component, or one tightly-scoped change:
-- "Fix date picker timezone handling in insights" — SPECIFIC (one component, one bug type)
-- "Add K8s liveness probe and fix feature flag caching" — SPECIFIC (one infra concern, tightly related)
-- "Fix funnel conversion calculation for time-based bins" — SPECIFIC (one feature, one issue)
+Judge by the FIX, not by where the symptom appears. Signals that share a single root cause, or that one shared change would resolve, belong in ONE PR even when the error surfaces in different files, components, or pages. The same guard, the same null-check, the same handler fix applied across many call sites is still one pull request.
-A VAGUE PR title is a catch-all that no single engineer would take on:
-- "Fix various PostHog AI issues" — VAGUE (multiple unrelated areas)
-- "Multiple workflow and integration improvements" — VAGUE (different systems)
-- "Address feature flag and authentication concerns" — VAGUE (unrelated domains)
+SPECIFIC — one root cause or one shared fix, so one engineer ships it in a single PR:
+- "Fix date picker timezone handling in insights" — one component, one bug
+- "Guard empty i18n translation keys in the missing-key handler" — one shared guard silences the empty-key errors surfacing across the calendar, settings, and event views
+- "Treat handled 404s as null instead of reporting them" — one interceptor-level fix stops the 404 noise from several endpoints
+- "Fix funnel conversion calculation for time-based bins" — one feature, one issue
-IMPORTANT: Err on the side of REJECTING. A good PR addresses ONE concern, even if that concern has multiple symptoms.
+Reject the group only when the signals need SEPARATE, unrelated fixes that no single engineer would take on together, such as "Fix various PostHog AI issues" or "Address feature flag and authentication concerns".
-Red flags that the group is too broad:
-- You need words like "various", "multiple", "and" (connecting unrelated things), or "improvements"
-- The signals share a keyword (e.g. "workflows", "flags", "Next.js") but address different problems
-- You'd assign the signals to different engineers based on expertise
-- The PR touches multiple unrelated systems or components
+None of these are reasons to split:
+- The same fix touches several files, call sites, or components
+- The signals surface in different pages, views, or systems but share one root cause or one remedy
+- The signals describe different symptoms of the same underlying behaviour
+
+When you are unsure, name the single change that would resolve every signal in the group. If you can name it, they belong in one PR. If you cannot, they belong apart.
Respond with valid JSON only:
{"pr_title": "...", "specific_enough": true/false, "reason": "..."}"""
diff --git a/products/signals/eval/AGENTS.md b/products/signals/eval/AGENTS.md
index 222606313c98..1774e3a44fe8 100644
--- a/products/signals/eval/AGENTS.md
+++ b/products/signals/eval/AGENTS.md
@@ -5,7 +5,7 @@ Measures how well the pipeline clusters incoming signals into reports, compared
## What it tests
-The eval feeds 92 synthetic signals (from 42 ground-truth groups) through the **real** pipeline:
+The eval feeds 111 synthetic signals (from 48 ground-truth groups) through the **real** pipeline:
LLM query generation, embedding search, LLM matching, specificity verification, summarization, safety judging, and actionability judging.
Infrastructure is mocked — an in-memory embedding store (`mock.py`) replaces ClickHouse + Kafka, and a `ReportStore` replaces Postgres.
@@ -102,7 +102,7 @@ Five eval experiments, each with their own metrics:
| `mock.py` | `EmbeddingStore` (in-memory vector store) and `ReportStore` (in-memory report DB) |
| `capture.py` | `capture_evaluation()` helper — formats and sends `$ai_evaluation` events |
| `data_spec.py` | `EvalSignalSpec` / `EvalGroupSpec` — signal and group specifications |
-| `fixtures/grouping_data.py` | Ground-truth dataset: 42 groups, 92 signals across Zendesk/GitHub/Linear |
+| `fixtures/grouping_data.py` | Ground-truth: 48 groups, 111 signals across Zendesk/GitHub/Linear/error tracking |
| `cache/embeddings.json` | Disk cache for OpenAI embeddings (auto-generated, avoids redundant API calls) |
## Clearing eval data
diff --git a/products/signals/eval/eval_grouping_e2e.py b/products/signals/eval/eval_grouping_e2e.py
index a30f602824f4..ae9d47e95cb2 100644
--- a/products/signals/eval/eval_grouping_e2e.py
+++ b/products/signals/eval/eval_grouping_e2e.py
@@ -69,6 +69,8 @@ from products.signals.eval.conftest import EVAL_TEAM_ID
from products.signals.eval.fixtures.grouping_data import GROUP_DATA
from products.signals.eval.mock import EmbeddingStore, ReportStore
+TRANSPORT_RETRIES = 3
+
class EvalGroupingPipeline:
def _eval_team(self):
@@ -124,10 +126,11 @@ class EvalGroupingPipeline:
async with sem:
await self.run_signal_pipeline(record_id, case)
- async def run_signal_pipeline(self, record_id: int, case: EvalSignalCase):
+ async def run_signal_pipeline(self, record_id: int, case: EvalSignalCase, attempt: int = 0):
"""Run a single signal through the pre-emit pipeline."""
- self.progress.signal_started()
+ if attempt == 0:
+ self.progress.signal_started()
try:
description = await self.pre_emit(record_id, case)
@@ -158,8 +161,15 @@ class EvalGroupingPipeline:
self._persist_signal(record_id, description, case, specificity_result, signal_embedding)
self.progress.signal_done()
- except BaseException:
+ except BaseException as e:
logging.getLogger(__name__).exception("Signal %d (group %d) failed", record_id, case.group_index)
+ # A dropped connection would otherwise silently shrink the dataset, which reads as a
+ # grouping difference when comparing two runs. Nothing is persisted until the last step,
+ # so replaying the signal is safe.
+ if attempt < TRANSPORT_RETRIES and not isinstance(e, asyncio.CancelledError):
+ await asyncio.sleep(2**attempt)
+ await self.run_signal_pipeline(record_id, case, attempt + 1)
+ return
self.progress.signal_dropped()
async def _prepare(
diff --git a/products/signals/eval/fixtures/grouping_data.py b/products/signals/eval/fixtures/grouping_data.py
index 86ada2895f77..2d8dc97c756e 100644
--- a/products/signals/eval/fixtures/grouping_data.py
+++ b/products/signals/eval/fixtures/grouping_data.py
@@ -1820,4 +1820,62 @@ GROUP_DATA = [
),
],
),
+ # --- Group 47: Same empty-i18n-key defect surfacing across different components ---
+ # One shared guard in the missing-key handler resolves every one of these, so they
+ # belong in ONE report/PR. They surface in different components (calendar, settings,
+ # event views), which previously fragmented them into many near-identical reports —
+ # the "judge by symptom surface, not by the fix" failure the specificity gate had.
+ EvalGroupSpec(
+ scenario="An empty i18n translation key reaches the missing-key handler from several UI surfaces; one guard fixes them all",
+ signals=[
+ EvalSignalSpec(
+ source=E,
+ title="[i18n] Missing Key: common:",
+ body=(
+ "An empty translation key ('common:') is reported to error tracking from the calendar "
+ "event render path.\n"
+ "handleMissingKey in src/lib/i18n/I18nErrorTracking.ts line 42\n"
+ "missingKeyHandler in src/lib/i18n/I18n.ts line 88\n"
+ "renderEventContent in src/components/WorkOrders/CalendarV2/components/OperationEvent/index.tsx line 51\n"
+ "A dynamic t() key was blank at render time. 1 occurrence, 1 user."
+ ),
+ ),
+ EvalSignalSpec(
+ source=E,
+ title="[i18n] Missing Key: common:",
+ body=(
+ "Empty translation key ('common:') reported to error tracking from the scheduling "
+ "calendar.\n"
+ "handleMissingKey in src/lib/i18n/I18nErrorTracking.ts line 42\n"
+ "missingKeyHandler in src/lib/i18n/I18n.ts line 88\n"
+ "Calendar in src/components/Scheduling/components/Calendar/index.tsx line 133\n"
+ "Same empty/undefined key handed to t() in a different calendar surface."
+ ),
+ ),
+ EvalSignalSpec(
+ source=E,
+ title="[i18n] Missing Key: common:",
+ body=(
+ "Empty translation key ('common:') reported to error tracking from the event type "
+ "selector in settings.\n"
+ "handleMissingKey in src/lib/i18n/I18nErrorTracking.ts line 42\n"
+ "missingKeyHandler in src/lib/i18n/I18n.ts line 88\n"
+ "EventTypeSelector in src/components/Settings/EventTypeSelector.tsx line 27\n"
+ "A t('') placeholder call fires the missing-key handler with an empty key."
+ ),
+ ),
+ EvalSignalSpec(
+ source=E,
+ title="[i18n] Missing Key: common:",
+ body=(
+ "Empty translation key ('common:') reported to error tracking from the FullCalendar "
+ "event render.\n"
+ "handleMissingKey in src/lib/i18n/I18nErrorTracking.ts line 42\n"
+ "missingKeyHandler in src/lib/i18n/I18n.ts line 88\n"
+ "eventDidMount in src/components/WorkOrders/CalendarV2/components/OperationEvent/render.tsx line 74\n"
+ "Same defect: guard empty keys once in the missing-key handler."
+ ),
+ ),
+ ],
+ ),
]
diff --git a/products/signals/eval/mock.py b/products/signals/eval/mock.py
index f0b33cd99bd8..8d84dce8d09a 100644
--- a/products/signals/eval/mock.py
+++ b/products/signals/eval/mock.py
@@ -55,8 +55,12 @@ class EmbeddingStore:
def _save_disk_cache(self) -> None:
self.CACHE_PATH.parent.mkdir(parents=True, exist_ok=True)
- with open(self.CACHE_PATH, "w") as f:
+ # Rewritten on every cache miss, so an interrupted run would otherwise leave behind a
+ # truncated file that no later run can parse.
+ temp_path = self.CACHE_PATH.with_suffix(".json.tmp")
+ with open(temp_path, "w") as f:
json.dump(self._embedding_cache, f)
+ temp_path.replace(self.CACHE_PATH)
async def embed(self, content: str) -> list[float]:
"""Generate and cache an embedding. Returns cached result if available."""