: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(signals): add a dismiss_lowvalue head to inbox ranking (#110918)
posthog[bot]120d0802497d
diff --git a/docs/internal/inbox-ranking-training.md b/docs/internal/inbox-ranking-training.mdindex 93a4a6cfda99..7ee67f420d7e 100644--- a/docs/internal/inbox-ranking-training.md+++ b/docs/internal/inbox-ranking-training.md@@ -7,6 +7,7 @@ The label comes from the snapshot `horizon_days` later, including outcomes alreaThe `pr_merged` head includes every report and reads merges within 14 days.The `dismiss_wrong` head includes every report and reads wrong-dismissal outcomes within 21 days.+The `dismiss_lowvalue` head includes every report and reads `wontfix_irrelevant` dismissals within 21 days.The examples asset records `reports_missing_birth_snapshot` for observed reports born inside the lookback whose birth-day partition is missing.These reports produce no birth-grain example; reports born before the lookback do not contribute to this count.@@ -26,18 +27,19 @@ Each head is conditioned on its cohort (`training/heads.py`).Every head uses every report as its cohort, so the probabilities are over the same reports and can be compared.Each head is graded only on its cohort.-| Head | Probability | Horizon |-| --------------- | ---------------------------------------- | ------- |-| `open` | P(opened) over every report | 3d |-| `action` | P(acted on) over every report | 7d |-| `discuss` | P(discuss) over every report | 7d |-| `dismiss_wrong` | P(dismissed as wrong) over every report | 21d |-| `reviewer_fix` | P(reviewers corrected) over every report | 14d |-| `thumbs_up` | P(thumbs up) over every report | 7d |-| `pr_created` | P(PR created) over every report | 7d |-| `pr_merged` | P(PR merged) over every report | 14d |-| `fixed` | P(fixed) over every report | 21d |-| `refund` | P(refund) over every report | 14d |+| Head | Probability | Horizon |+| ------------------ | ----------------------------------------------------------- | ------- |+| `open` | P(opened) over every report | 3d |+| `action` | P(acted on) over every report | 7d |+| `discuss` | P(discuss) over every report | 7d |+| `dismiss_wrong` | P(dismissed as wrong) over every report | 21d |+| `reviewer_fix` | P(reviewers corrected) over every report | 14d |+| `thumbs_up` | P(thumbs up) over every report | 7d |+| `pr_created` | P(PR created) over every report | 7d |+| `pr_merged` | P(PR merged) over every report | 14d |+| `fixed` | P(fixed) over every report | 21d |+| `refund` | P(refund) over every report | 14d |+| `dismiss_lowvalue` | P(dismissed as real but not worth fixing) over every report | 21d |Each head in `metadata.json` records `cohort` (`everyone`) and `horizon_days`.diff --git a/products/signals/dags/inbox_ranking/README.md b/products/signals/dags/inbox_ranking/README.mdindex c3c42c3406e5..642dc6d68dc6 100644--- a/products/signals/dags/inbox_ranking/README.md+++ b/products/signals/dags/inbox_ranking/README.md@@ -83,7 +83,7 @@ s3://<bucket>/<prefix>/- **A model is a `(model_name, model_version, model_role)`.** `model_name` is the family: which features and which learner, `tabular_xgb` for the per-head XGBoost trained here. `model_version` is the partition day it was fit on, and `model_role` is `candidate` or `champion`. Each family owns a prefix under the models path and its own `champion.json`, so two families trained on the same day cannot collide, and promotion stays inside a family. A richer family is a second candidate graded on the same unseen rows, not a competitor for the tabular family's pointer.- **A feature set is one feature universe.** `products/signals/backend/ranking/features.py` holds a `FeatureSet` per universe: its name, its schema version, its ordered feature names, the report-state columns it reads, `build_matrix`, and how many rows it wants per report and per head. `tabular`, `report_embeddings` and `title_embeddings` are the three today. A candidate records the set it was fit on in its `metadata.json`, so the grader checks a model against its own set rather than one global contract, the examples asset writes one Parquet per set, and the unseen scorer builds one matrix per set and shares it across the families that read it. Adding a set means an entry in `FEATURE_SETS`; a model naming a set this build cannot produce is logged and left unscored.-- **Examples are one row per report at its birth, by default.** For partition `dt=D` the examples asset reads the report-state and labels snapshots `dt=D-lookback..D` and emits one row per report, on the snapshot of the day it was created, labeled from the snapshot `horizon_days` later (3 for open, 7 for action / pr_created / discuss / thumbs_up, 14 for pr_merged / refund / reviewer_fix, 21 for dismiss_wrong / fixed). Features are built by the feature set from that snapshot's state columns plus `age_hours`, the report's age at the snapshot. Labels are aligned to the state spine, so a report with no label event is a negative (all-zero labels), not absent. Label-only rows (no Postgres state) are skipped, as are state rows read long after their snapshot day (backfills carry current Postgres state; see `features_observed_at`) and, for the heads that read the status stream (`dismiss_wrong`, `action` and `fixed`), rows whose status telemetry fails the dataset's `label_provenance_ok` check. Birth is the moment serving scores a report, and the label that comes out is a per-report probability, which is what the inbox ordering needs. A report born before the window, or one whose birth-day snapshot is missing from it, is no example; `reports_missing_birth_snapshot` on the asset counts the second case, which is a gap in the partitions.+- **Examples are one row per report at its birth, by default.** For partition `dt=D` the examples asset reads the report-state and labels snapshots `dt=D-lookback..D` and emits one row per report, on the snapshot of the day it was created, labeled from the snapshot `horizon_days` later (3 for open, 7 for action / pr_created / discuss / thumbs_up, 14 for pr_merged / refund / reviewer_fix, 21 for dismiss_wrong / fixed / dismiss_lowvalue). Features are built by the feature set from that snapshot's state columns plus `age_hours`, the report's age at the snapshot. Labels are aligned to the state spine, so a report with no label event is a negative (all-zero labels), not absent. Label-only rows (no Postgres state) are skipped, as are state rows read long after their snapshot day (backfills carry current Postgres state; see `features_observed_at`) and, for the heads that read the status stream (`dismiss_wrong`, `action`, `fixed` and `dismiss_lowvalue`), rows whose status telemetry fails the dataset's `label_provenance_ok` check. Birth is the moment serving scores a report, and the label that comes out is a per-report probability, which is what the inbox ordering needs. A report born before the window, or one whose birth-day snapshot is missing from it, is no example; `reports_missing_birth_snapshot` on the asset counts the second case, which is a gap in the partitions.- **An outcome already visible on the birth day is a future positive.** A report born on day D has no scoring moment before D, so an outcome visible at D belongs to the moment being built rather than to an earlier one; the labels of D therefore read as their defaults for a report born on D. Most outcomes land on the birth day, so this is where the positives are: censoring on them costs the `pr_created` head most of its training signal. `<set>_<head>_birth_day_positives` on the examples asset, and `birth_day_positives` on the `inbox_ranking_examples_built` event, say how many positives the rule keeps. These rows carry a hindsight the other rows do not: the state snapshot reads `signal_count`, `total_weight`, `run_count` and the text sizes live from Postgres a few hours after day D ends, so a birth-day outcome happened before its own feature read. Both the holdout AUC and the newborn unseen grade therefore read optimistically on these rows, until the scoring sweep's timestamped score log replaces the daily snapshot as this table's source.- **Every head asks whether the outcome happened within N days of the scoring moment.** `pr_merged` includes every report, so the label covers the whole report-to-merge path without requiring a PR at birth or at the horizon.- **A set may ask for another grain**, and cap the rows one head keeps (`max_examples_per_head`, whole report-creation days, newest first). The scoring-moment grain is one row per (report, snapshot) whose head label is still 0 on that snapshot: the serving situation replayed over history, but its label is a hazard conditional on the report still being live, and one long-lived report contributes dozens of near-duplicate rows. The report grain is the first snapshot of the window where the report is a usable moment, which is later than birth only when a side input landed late. Both stay selectable for re-scoring families; nothing ships on them today. The row budget shortens the history a head is fit on and keeps each kept day whole, so the scores stay calibrated to the population of that window. The lookback is the tabular set's whatever the grain, so positives accrue over the whole window until the budget binds.@@ -114,18 +114,19 @@ The reader is `score_reports` in `products/signals/backend/ranking/scorer.py`. I### Outcome heads-| Head | Cohort at the horizon | Horizon (days) |-| --------------- | --------------------- | -------------- |-| `open` | Every report | 3 |-| `action` | Every report | 7 |-| `dismiss_wrong` | Every report | 21 |-| `pr_created` | Every report | 7 |-| `pr_merged` | Every report | 14 |-| `fixed` | Every report | 21 |-| `discuss` | Every report | 7 |-| `refund` | Every report | 14 |-| `thumbs_up` | Every report | 7 |-| `reviewer_fix` | Every report | 14 |+| Head | Cohort at the horizon | Horizon (days) |+| ------------------ | --------------------- | -------------- |+| `open` | Every report | 3 |+| `action` | Every report | 7 |+| `dismiss_wrong` | Every report | 21 |+| `pr_created` | Every report | 7 |+| `pr_merged` | Every report | 14 |+| `fixed` | Every report | 21 |+| `discuss` | Every report | 7 |+| `refund` | Every report | 14 |+| `thumbs_up` | Every report | 7 |+| `reviewer_fix` | Every report | 14 |+| `dismiss_lowvalue` | Every report | 21 |`action` counts intent from every surface, not only the cloud inbox list.A report is a positive when someone clicked an intent action in the inbox UI (create PR, implement, copy the prompt, discuss, open or view a PR, edit the reviewers, restore), or when a person or an external agent claimed it, linked a PR, left a note, discussed it in Slack, or resolved it with a reason.diff --git a/products/signals/dags/inbox_ranking/common.py b/products/signals/dags/inbox_ranking/common.pyindex ac16da86fed0..706edee3baaa 100644--- a/products/signals/dags/inbox_ranking/common.py+++ b/products/signals/dags/inbox_ranking/common.py@@ -48,6 +48,8 @@ NOT_FIXED_RESOLUTION_REASONS = ()# A dismissal that says the problem was real and is fixed somewhere.FIXED_DISMISSAL_REASONS = ("already_fixed", "fixed_outside_posthog", "pr_merged")+# A dismissal that says the problem is real but not worth fixing: a relevance failure, not a precision failure.+LOW_VALUE_DISMISSAL_REASONS = ("wontfix_irrelevant",)# Artefact actors whose writes count as a person acting on a report. `agent` is an external MCP# client that authenticates as a real user, so a person drove it. `task` is a self-driving sandboxdiff --git a/products/signals/dags/inbox_ranking/dataset/dag.py b/products/signals/dags/inbox_ranking/dataset/dag.pyindex 1ceb111d031a..1e57cca18453 100644--- a/products/signals/dags/inbox_ranking/dataset/dag.py+++ b/products/signals/dags/inbox_ranking/dataset/dag.py@@ -116,7 +116,7 @@ from products.signals.dags.inbox_ranking.dataset.queries import (valid_report_uuids,)-FEATURE_SCHEMA_VERSION = 8+FEATURE_SCHEMA_VERSION = 9STATE_TABLE = "inbox_report_state"EMBEDDINGS_TABLE = "inbox_report_embeddings"@@ -248,6 +248,8 @@ LABEL_FIELDS: list[tuple[str, pa.DataType]] = [("first_wrong_dismissed_at", _TIMESTAMP),("fixed_count", pa.int32()),("first_fixed_at", _TIMESTAMP),+ ("lowvalue_dismissal_count", pa.int32()),+ ("first_lowvalue_dismissed_at", _TIMESTAMP),("status_event_priority", pa.string()),("status_event_actionability", pa.string()),("status_event_team_id", pa.int64()),diff --git a/products/signals/dags/inbox_ranking/dataset/queries.py b/products/signals/dags/inbox_ranking/dataset/queries.pyindex 387b696f1471..1b9270fbf02f 100644--- a/products/signals/dags/inbox_ranking/dataset/queries.py+++ b/products/signals/dags/inbox_ranking/dataset/queries.py@@ -26,6 +26,7 @@ from posthog.models import Teamfrom products.signals.dags.inbox_ranking.common import (FIXED_DISMISSAL_REASONS,LABELS_EPOCH,+ LOW_VALUE_DISMISSAL_REASONS,NOT_FIXED_RESOLUTION_REASONS,WRONG_DISMISSAL_REASONS,ensure_utc,@@ -411,6 +412,7 @@ _FIXED_TRANSITION_SQL = (+ _FIXED_DISMISSAL_REASONS_SQL+ "))")+_LOW_VALUE_DISMISSAL_REASONS_SQL = ", ".join(f"'{reason}'" for reason in LOW_VALUE_DISMISSAL_REASONS)STATUS_COLUMNS = ("first_resolved_at",@@ -427,6 +429,8 @@ STATUS_COLUMNS = ("first_reasoned_resolved_at","fixed_count","first_fixed_at",+ "lowvalue_dismissal_count",+ "first_lowvalue_dismissed_at","status_event_priority","status_event_actionability","status_event_team_id",@@ -513,6 +517,15 @@ SELECT-- with another reason cannot take the label back. The fixed head reads this column.countIf(bucket_fixed = 1 AND event_team_id = latest_event_team_id) AS fixed_count,minIf(bucket_first_fixed_at, event_team_id = latest_event_team_id) AS first_fixed_at,+ -- The same cumulative count, timestamp and tenant restriction for the low-value reasons. The+ -- dismiss_lowvalue head reads this column.+ countIf(+ outcome = 'dismissed' AND bucket_lowvalue_dismissal = 1 AND event_team_id = latest_event_team_id+ ) AS lowvalue_dismissal_count,+ minIf(+ bucket_first_lowvalue_dismissed_at,+ outcome = 'dismissed' AND event_team_id = latest_event_team_id+ ) AS first_lowvalue_dismissed_at,-- These two must stay paired with latest_status_event, so coalesce/nullIf keeps argMax from-- skipping a null: a judgment artefact can be deleted, and then the latest transition-- genuinely carries none. Plain argMax would reach back to an older transition and present@@ -581,6 +594,12 @@ FROM (nullIf(minIf(events.timestamp, """+ _FIXED_TRANSITION_SQL+ """), fromUnixTimestamp(0)) AS bucket_first_fixed_at,+ max(toString(properties.dismissal_reason) IN ("""+ + _LOW_VALUE_DISMISSAL_REASONS_SQL+ + """)) AS bucket_lowvalue_dismissal,+ nullIf(minIf(events.timestamp, toString(properties.dismissal_reason) IN ("""+ + _LOW_VALUE_DISMISSAL_REASONS_SQL+ + """)), fromUnixTimestamp(0)) AS bucket_first_lowvalue_dismissed_at,nullIf(argMax(toString(properties.priority), events.timestamp), '') AS event_priority,nullIf(argMax(toString(properties.actionability), events.timestamp), '') AS event_actionability,nullIf(toString(properties.team_id), '') AS event_team_id@@ -756,6 +775,8 @@ LABEL_DEFAULTS: dict[str, Any] = {"first_wrong_dismissed_at": None,"fixed_count": 0,"first_fixed_at": None,+ "lowvalue_dismissal_count": 0,+ "first_lowvalue_dismissed_at": None,"status_event_priority": None,"status_event_actionability": None,"status_event_team_id": None,@@ -829,6 +850,7 @@ OUTCOME_FIRST_EVENT_COLUMNS: dict[str, str] = {"feedback_negative_count": "first_negative_feedback_at","wrong_dismissal_count": "first_wrong_dismissed_at","fixed_count": "first_fixed_at",+ "lowvalue_dismissal_count": "first_lowvalue_dismissed_at","pr_created_count": "first_pr_created_at","pr_merged_count": "first_pr_merged_at","pr_closed_count": "first_pr_closed_at",diff --git a/products/signals/dags/inbox_ranking/tests/test_dataset.py b/products/signals/dags/inbox_ranking/tests/test_dataset.pyindex 4ebcab03e4f0..54e1fbd0e6cc 100644--- a/products/signals/dags/inbox_ranking/tests/test_dataset.py+++ b/products/signals/dags/inbox_ranking/tests/test_dataset.py@@ -570,6 +570,21 @@ class TestStatusStream(ClickhouseTestMixin, BaseTest):assert row["first_dismissed_server_at"] == T1assert row["first_wrong_dismissed_at"] == T1+ @parameterized.expand([(datetime.timedelta(hours=1),), (datetime.timedelta(minutes=1),)])+ def test_lowvalue_dismissal_count_survives_a_restore_and_ignores_wrong_reasons(self, gap):+ # A wrong dismissal is not a low-value one. The later wontfix_irrelevant dismissal counts, and+ # the restore after it must not take the cumulative label back to 0.+ self._transition(T1, "ready", "suppressed", "analysis_wrong")+ self._transition(T1 + gap, "suppressed", "ready")+ self._transition(T1 + 2 * gap, "ready", "suppressed", "wontfix_irrelevant")+ self._transition(T1 + 3 * gap, "suppressed", "ready")++ row = self._status_row()+ assert row["wrong_dismissal_count"] == 1+ assert row["first_wrong_dismissed_at"] == T1+ assert row["lowvalue_dismissal_count"] == 1+ assert row["first_lowvalue_dismissed_at"] == T1 + 2 * gap+@parameterized.expand([(datetime.timedelta(hours=1),), (datetime.timedelta(minutes=1),)])def test_a_reasonless_first_dismissal_carries_no_reason_forward(self, gap):# A dismissal with no reason is normal: the PR-closed path suppresses a report with no@@ -673,7 +688,8 @@ class TestStatusStream(ClickhouseTestMixin, BaseTest):genuine_only = self._status_row()for status in statuses:- self._transition(T1, "ready", status, "analysis_wrong", team_id=999)+ for reason in ("analysis_wrong", "wontfix_irrelevant"):+ self._transition(T1, "ready", status, reason, team_id=999)assert self._status_row() == genuine_onlydiff --git a/products/signals/dags/inbox_ranking/tests/test_training.py b/products/signals/dags/inbox_ranking/tests/test_training.pyindex 5487caa05924..92219f16842c 100644--- a/products/signals/dags/inbox_ranking/tests/test_training.py+++ b/products/signals/dags/inbox_ranking/tests/test_training.py@@ -445,6 +445,19 @@ def test_dismissed_as_wrong_prefers_the_cumulative_count(frame, expected):[True, True, True, True],[True, True, False, True],),+ # dismiss_lowvalue: cohort is everyone, label is a low-value dismissal, never a wrong one.+ (+ "dismiss_lowvalue",+ pd.DataFrame(+ {+ "impression_unit_count": [1, 0, 1],+ "lowvalue_dismissal_count": [1, 1, 0],+ "wrong_dismissal_count": [0, 0, 1],+ }+ ),+ [True, True, True],+ [True, True, False],+ ),],)def test_new_heads_read_the_right_cohort_and_label_columns(head_name, frame, expected_cohort, expected_label):@@ -479,6 +492,7 @@ class _ParquetS3:("refund", "refund_count"),("thumbs_up", "feedback_positive_count"),("reviewer_fix", "reviewer_add_count"),+ ("dismiss_lowvalue", "lowvalue_dismissal_count"),*(("action", column) for column in ACTION_LABEL_COLUMNS),],)@@ -497,6 +511,7 @@ def test_new_head_label_columns_survive_the_load_snapshots_projection(head_name,"refund_count","feedback_positive_count","reviewer_add_count",+ "lowvalue_dismissal_count",*ACTION_LABEL_COLUMNS,)}diff --git a/products/signals/dags/inbox_ranking/training/dag.py b/products/signals/dags/inbox_ranking/training/dag.pyindex 621f52795089..b8271ad3ea0e 100644--- a/products/signals/dags/inbox_ranking/training/dag.py+++ b/products/signals/dags/inbox_ranking/training/dag.py@@ -187,6 +187,7 @@ _LABEL_COLUMNS = ("dismissal_reason","wrong_dismissal_count","fixed_count",+ "lowvalue_dismissal_count","pr_created_count","pr_merged_count","refund_count",diff --git a/products/signals/dags/inbox_ranking/training/heads.py b/products/signals/dags/inbox_ranking/training/heads.pyindex d8011e333a13..1a54f05d5ed5 100644--- a/products/signals/dags/inbox_ranking/training/heads.py+++ b/products/signals/dags/inbox_ranking/training/heads.py@@ -17,7 +17,7 @@ The dataset keeps them for position bias and the shadow grades.Slack and the desktop app. Self-driving's own `task` and `system` writes are excluded, becausethey are internal operational work and not a person acting on the report.-Mirrors the workspace `heads.py` (random-dev-internal, `inbox-ranking/`). Eight heads are dense+Mirrors the workspace `heads.py` (random-dev-internal, `inbox-ranking/`). Nine heads are denseenough to read on the holdout. `thumbs_up` and `reviewer_fix` are the explicit human-feedback pair:they are rare, so they are carried for the pooled newborn grade and as scorer inputs rather thanfor a holdout AUC. The rest stay workspace-only.@@ -89,6 +89,10 @@ def fixed(frame: pd.DataFrame) -> pd.Series:return _count(frame, "fixed_count") > 0+def dismissed_as_low_value(frame: pd.DataFrame) -> pd.Series:+ return _count(frame, "lowvalue_dismissal_count") > 0++def pr_created(frame: pd.DataFrame) -> pd.Series:return _count(frame, "pr_created_count") > 0@@ -229,6 +233,19 @@ HEADS: tuple[Head, ...] = (min_holdout_positives=20,label_columns=("reviewer_add_count", "reviewer_remove_count"),),+ # Which reports get dismissed as real but not worth fixing - the relevance-failure negative.+ # dismiss_wrong says the report was wrong; this head says it was right but not worth anyone's+ # time. Cohort is everyone, because agents over MCP dismiss reports that no list ever showed.+ # Many of these dismissals land after 14 days, hence the 21 days.+ Head(+ name="dismiss_lowvalue",+ cohort=everyone,+ label=dismissed_as_low_value,+ horizon_days=21,+ min_holdout_positives=30,+ label_columns=("lowvalue_dismissal_count",),+ status_labels=True,+ ),)HEADS_BY_NAME: dict[str, Head] = {head.name: head for head in HEADS}