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.

feat(signals): move the remaining inbox ranking heads to the everyone cohort (#110913)

posthog[bot]a220dc1963b4
diff --git a/docs/internal/inbox-ranking-training.md b/docs/internal/inbox-ranking-training.md
index f778b94f3616..195f6bbac749 100644
--- a/docs/internal/inbox-ranking-training.md
+++ b/docs/internal/inbox-ranking-training.md
@@ -6,7 +6,7 @@ Birth days use the UTC interval returned by `snapshot_bounds`, including the sta
The label comes from the snapshot `horizon_days` later, including outcomes already present on the birth day.
The `pr_merged` head includes every report and reads merges within 14 days.
-The `dismiss_wrong` head includes impressed reports and reads wrong-dismissal outcomes within 14 days.
+The `dismiss_wrong` head includes every report and reads wrong-dismissal outcomes 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.
@@ -23,23 +23,22 @@ See the [ranking DAG README](../../products/signals/dags/inbox_ranking/README.md
## What each probability means
Each head is conditioned on its cohort (`training/heads.py`).
-The cohort is read at the horizon snapshot, so "shown" means shown at any time before the horizon.
-`p_open` and the other cohort-conditioned heads are not unconditional probabilities.
+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 \| shown) | 3d |
-| `action` | P(create-PR click or discuss \| shown) | 7d |
-| `discuss` | P(discuss \| shown) | 7d |
-| `dismiss_wrong` | P(dismissed as wrong \| shown) | 14d |
-| `reviewer_fix` | P(reviewers corrected \| shown) | 14d |
-| `thumbs_up` | P(thumbs up \| opened) | 7d |
-| `pr_created` | P(PR created) over every report | 7d |
-| `pr_merged` | P(PR merged) over every report | 14d |
-| `refund` | P(refund) over every report | 14d |
-
-Each head in `metadata.json` records `cohort` (`impressed`, `opened` or `everyone`) and `horizon_days`.
+| 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 |
+| `refund` | P(refund) over every report | 14d |
+
+Each head in `metadata.json` records `cohort` (`everyone`) and `horizon_days`.
## Row budget
diff --git a/products/signals/dags/inbox_ranking/README.md b/products/signals/dags/inbox_ranking/README.md
index 97fc0ec19667..93bcb2f614b3 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 dismiss_wrong / pr_merged / refund / reviewer_fix). 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` and `action`), 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). 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` and `action`), 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.
@@ -118,13 +118,13 @@ The reader is `score_reports` in `products/signals/backend/ranking/scorer.py`. I
| --------------- | --------------------- | -------------- |
| `open` | Every report | 3 |
| `action` | Every report | 7 |
-| `dismiss_wrong` | Impressed reports | 14 |
+| `dismiss_wrong` | Every report | 21 |
| `pr_created` | Every report | 7 |
| `pr_merged` | Every report | 14 |
-| `discuss` | Impressed reports | 7 |
+| `discuss` | Every report | 7 |
| `refund` | Every report | 14 |
-| `thumbs_up` | Opened reports | 7 |
-| `reviewer_fix` | Impressed reports | 14 |
+| `thumbs_up` | Every report | 7 |
+| `reviewer_fix` | Every report | 14 |
`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.
@@ -132,7 +132,7 @@ Self-driving's own `task` and `system` writes do not count: they are internal op
A resolve without a reason is the automatic resolve after a tracked PR merges, so it does not count either.
`thumbs_up` (a positive rating on the report body) and `reviewer_fix` (a suggested reviewer added or removed) are the explicit human-feedback pair.
-Both are rare — about 1% of opened reports and 1.5% of impressed reports — so neither clears its holdout bar on a single day.
+Both are rare, so neither clears its holdout bar on a single day.
They are carried for the pooled newborn grade and as scorer inputs, not for a holdout AUC, and the promotion gate keeps ignoring an unreadable head.
Every training series resets on the first partition after deploy.
@@ -149,7 +149,7 @@ Two assets add the missing number, an offline batch proxy for performance on rep
At the full horizon, the cohort, label and provenance rules are the trainer's own, so the baked unseen AUC is directly comparable to the holdout AUC of the same head and model version. The gap between the two series is the overfitting read the promotion gate cannot see.
-Four events carry the scores and baked results to the dashboard, next to the training events: `inbox_ranking_unseen_report_scored` per (report, model) with `p_<head>`, the raw feature inputs, and `pool` (which pool definition produced the row), `inbox_ranking_unseen_head_graded` per (model, head) with `readable` (whether the head's holdout could be read on the model that wrote the scores), `rows`, `positives`, `birth_day_positives` (of the positives, how many landed on the report's birth day), `base_rate`, `mean_score`, `expected_calibration_error`, `auc` and `recency_auc`, `inbox_ranking_unseen_calibration` per (model, head, decile) with `bucket`, `rows`, `positives`, `mean_score` and `realized_rate` (one event per decile, because a table on the head event would be an array no insight can break down), and `inbox_ranking_unseen_report_graded` per (report, model, horizon) with `p_<head>`, `in_cohort_<head>` and `outcome_<head>` for a calibration read on the raw rows. Both graded events are stamped on the day the outcome was read and carry `scoring_partition`, the day the report was scored, so a chart can be built on either axis. Both also carry `pool`, read back from the scores object, so an AUC series never mixes two pool definitions: the grader reads scores from up to 14 days earlier, so the days after a pool change grade both populations. A scores object written before the column existed reads as `sampled`, the pool the old seeded sample defined.
+Four events carry the scores and baked results to the dashboard, next to the training events: `inbox_ranking_unseen_report_scored` per (report, model) with `p_<head>`, the raw feature inputs, and `pool` (which pool definition produced the row), `inbox_ranking_unseen_head_graded` per (model, head) with `readable` (whether the head's holdout could be read on the model that wrote the scores), `rows`, `positives`, `birth_day_positives` (of the positives, how many landed on the report's birth day), `base_rate`, `mean_score`, `expected_calibration_error`, `auc` and `recency_auc`, `inbox_ranking_unseen_calibration` per (model, head, decile) with `bucket`, `rows`, `positives`, `mean_score` and `realized_rate` (one event per decile, because a table on the head event would be an array no insight can break down), and `inbox_ranking_unseen_report_graded` per (report, model, horizon) with `p_<head>`, `in_cohort_<head>` and `outcome_<head>` for a calibration read on the raw rows. Both graded events are stamped on the day the outcome was read and carry `scoring_partition`, the day the report was scored, so a chart can be built on either axis. Both also carry `pool`, read back from the scores object, so an AUC series never mixes two pool definitions: the grader reads scores from up to the longest head horizon (21 days) earlier, so the days after a pool change grade both populations. A scores object written before the column existed reads as `sampled`, the pool the old seeded sample defined.
#### Reading one rendering against another
diff --git a/products/signals/dags/inbox_ranking/tests/test_training.py b/products/signals/dags/inbox_ranking/tests/test_training.py
index 545a4fc307c8..d97afb905c0e 100644
--- a/products/signals/dags/inbox_ranking/tests/test_training.py
+++ b/products/signals/dags/inbox_ranking/tests/test_training.py
@@ -307,7 +307,7 @@ def test_build_examples_is_a_scoring_moment_with_a_future_label():
def test_assemble_snapshot_makes_never_labeled_reports_negatives_and_drops_untrusted_status_rows():
head = HEADS_BY_NAME["pr_created"]
wrong_head = HEADS_BY_NAME["dismiss_wrong"]
- assert wrong_head.horizon_days == 14
+ assert wrong_head.horizon_days == 21
later = D0 + datetime.timedelta(days=head.horizon_days)
ids = ["a", "b", "c", "gone"]
# a: status telemetry names another tenant -> provenance fails; b: no label row at all;
@@ -343,9 +343,10 @@ def test_assemble_snapshot_makes_never_labeled_reports_negatives_and_drops_untru
# pr_created reads the tasks webhook, so a's untrusted status telemetry does not exclude it there.
pr = build_examples(snapshots, head, TABULAR_FEATURE_SET).set_index("report_id")["label"].to_dict()
assert pr == {"a": 0, "b": 0, "c": 1, "gone": 1}
- # dismiss_wrong reads the status stream: a is dropped, b was never impressed, c is a positive.
+ # dismiss_wrong reads the status stream: a is dropped, b was never impressed but is a negative,
+ # c is a positive.
wrong = build_examples(snapshots, wrong_head, TABULAR_FEATURE_SET).set_index("report_id")["label"].to_dict()
- assert wrong == {"c": 1}
+ assert wrong == {"b": 0, "c": 1}
def test_build_examples_drops_state_rows_read_long_after_their_snapshot():
@@ -403,12 +404,12 @@ def test_dismissed_as_wrong_prefers_the_cumulative_count(frame, expected):
[True, True, True, True],
[True, True, True, False],
),
- # discuss: cohort is impressed reports, label is a discuss action.
+ # discuss: cohort is everyone, so a never-impressed report counts; label is a discuss action.
(
"discuss",
- pd.DataFrame({"impression_unit_count": [1, 1, 0], "discuss_count": [2, 0, 0]}),
- [True, True, False],
- [True, False, False],
+ pd.DataFrame({"impression_unit_count": [1, 1, 0], "discuss_count": [2, 0, 1]}),
+ [True, True, True],
+ [True, False, True],
),
# refund: cohort is everyone, label is a refund event.
(
@@ -417,25 +418,25 @@ def test_dismissed_as_wrong_prefers_the_cumulative_count(frame, expected):
[True, True, True],
[True, False, False],
),
- # thumbs_up: cohort is opened reports, label is a positive rating.
+ # thumbs_up: cohort is everyone, so a never-opened report is a negative; label is a positive rating.
(
"thumbs_up",
pd.DataFrame({"open_count": [1, 1, 0], "feedback_positive_count": [1, 0, 0]}),
- [True, True, False],
+ [True, True, True],
[True, False, False],
),
- # reviewer_fix: cohort is impressed reports, and an add or a remove is the same label.
+ # reviewer_fix: cohort is everyone, and an add or a remove is the same label.
(
"reviewer_fix",
pd.DataFrame(
{
"impression_unit_count": [1, 1, 1, 0],
- "reviewer_add_count": [1, 0, 0, 0],
+ "reviewer_add_count": [1, 0, 0, 1],
"reviewer_remove_count": [0, 2, 0, 0],
}
),
- [True, True, True, False],
- [True, True, False, False],
+ [True, True, True, True],
+ [True, True, False, True],
),
],
)
@@ -1066,23 +1067,24 @@ def test_unseen_daily_evaluations_keep_baked_events_at_each_heads_horizon(
assert {row["head"] for row in calibration} == baked_heads
[email protected]("impressions", [0, 1])
-def test_daily_evaluation_keeps_empty_and_single_class_cohorts_explicit(impressions):
[email protected]("labeled", [0, 1])
+def test_daily_evaluation_keeps_empty_and_single_class_cohorts_explicit(labeled):
head = HEADS_BY_NAME["discuss"]
+ # A report with no labels row is outside every cohort, so the unlabeled case is an empty cohort.
graded = graded_rows(
_scores(["pending"], head_readable=[False], classification_threshold=[0.2]),
- _labels(["pending"], impression_unit_count=[impressions]),
+ _labels(["pending" if labeled else "other"]),
head,
pool=POOL_NAME,
)
(grade,) = head_grades(graded, head, pool=POOL_NAME, scoring_partition=D0.isoformat(), include_empty=True)
- assert (grade.scored_rows, grade.rows, grade.positives) == (1, impressions, 0)
+ assert (grade.scored_rows, grade.rows, grade.positives) == (1, labeled, 0)
assert (grade.auc, grade.recency_auc, grade.null_auc) == (None, None, None)
assert grade.readable is False
assert grade.classification.threshold == 0.2
- assert (grade.classification.true_positives or 0) + (grade.classification.false_positives or 0) == impressions
+ assert (grade.classification.true_positives or 0) + (grade.classification.false_positives or 0) == labeled
assert grade.classification.recall is None
- if not impressions:
+ if not labeled:
assert (grade.mean_score, grade.base_rate, grade.expected_calibration_error) == (None, None, None)
assert head_grades(graded, head, pool=POOL_NAME, scoring_partition=D0.isoformat()) == []
diff --git a/products/signals/dags/inbox_ranking/training/heads.py b/products/signals/dags/inbox_ranking/training/heads.py
index 401509766e29..b470f53c27a1 100644
--- a/products/signals/dags/inbox_ranking/training/heads.py
+++ b/products/signals/dags/inbox_ranking/training/heads.py
@@ -8,6 +8,11 @@ must still be 0) and the snapshot `horizon_days` later (the label). The report's
exception: it has no earlier scoring moment, so an outcome already visible there is a future
positive for that moment rather than an outcome of an earlier one, and the label may already be 1.
+Every head reads the `everyone` cohort, so each `p_<head>` is a probability over the
+same reports and the heads can be compared and combined. Impressions are not a label gate: only the
+cloud inbox list emits them, and a report reached from Slack, the desktop app or MCP often has none.
+The dataset keeps them for position bias and the shadow grades.
+
`action` counts intent from any surface: the inbox UI, external coding agents over MCP, the CLI,
Slack and the desktop app. Self-driving's own `task` and `system` writes are excluded, because
they are internal operational work and not a person acting on the report.
@@ -31,10 +36,6 @@ def _count(frame: pd.DataFrame, column: str) -> pd.Series:
return frame[column].fillna(0).astype(int) if column in frame else pd.Series(0, index=frame.index)
-def impressed(frame: pd.DataFrame) -> pd.Series:
- return _count(frame, "impression_unit_count") > 0
-
-
def everyone(frame: pd.DataFrame) -> pd.Series:
return pd.Series(True, index=frame.index)
@@ -141,13 +142,15 @@ HEADS: tuple[Head, ...] = (
label_columns=ACTION_LABEL_COLUMNS,
status_labels=True,
),
- # Of the reports users saw, which were dismissed as wrong / unclear / intentional - the
- # precision-failure negative. already_fixed and wontfix_irrelevant are deliberately not here.
+ # Which reports were dismissed as wrong / unclear / intentional - the precision-failure negative.
+ # already_fixed and wontfix_irrelevant are deliberately not here. Cohort is every report: a
+ # dismissal from another surface often has no list impression. A dismissal with a reason lands
+ # late, so 21 days labels fewer late dismissals as negatives than 14 did.
Head(
name="dismiss_wrong",
- cohort=impressed,
+ cohort=everyone,
label=dismissed_as_wrong,
- horizon_days=14,
+ horizon_days=21,
min_holdout_positives=30,
status_labels=True,
),
@@ -163,11 +166,12 @@ HEADS: tuple[Head, ...] = (
min_holdout_positives=30,
label_columns=("pr_merged_count",),
),
- # Of the reports users saw, which drew a discuss? A subset of the action head, which is fine - each
- # head trains independently.
+ # Which reports drew a discuss? Cohort is every report: a discuss from Slack, the desktop app or
+ # MCP often has no list impression. A subset of the action head, which is fine - each head trains
+ # independently.
Head(
name="discuss",
- cohort=impressed,
+ cohort=everyone,
label=discussed,
horizon_days=7,
min_holdout_positives=30,
@@ -185,23 +189,25 @@ HEADS: tuple[Head, ...] = (
min_holdout_positives=20,
label_columns=("refund_count",),
),
- # Of the reports someone opened, which drew a thumbs up at the end of the body? Every thumbed
- # report was opened first, so the cohort loses nothing. About one opened report in a hundred
- # gets one, so the holdout AUC stays noise for weeks and the pooled newborn grade is the read.
+ # Which reports drew a thumbs up at the end of the body? Cohort is every report, so the
+ # probability is on the same population as the other heads. Every thumbed report was opened,
+ # so this loses no positives and only adds negatives. The label is rare, so the holdout AUC
+ # stays noise for weeks and the pooled newborn grade is the read.
Head(
name="thumbs_up",
- cohort=opened,
+ cohort=everyone,
label=thumbed_up,
horizon_days=7,
min_holdout_positives=10,
label_columns=("feedback_positive_count",),
),
- # Of the reports users saw, which had their suggested reviewers corrected? An add and a remove
- # are one label: a removal alone is housekeeping that usually follows a PR, while the pair reads
- # as "a person corrected the reviewers". As slow to land as dismiss_wrong, hence the 14 days.
+ # Which reports had their suggested reviewers corrected? Cohort is every report: a correction
+ # from another surface often has no list impression. An add and a remove are one label: a
+ # removal alone is housekeeping that usually follows a PR, while the pair reads as "a person
+ # corrected the reviewers". Slow to land, hence the 14 days.
Head(
name="reviewer_fix",
- cohort=impressed,
+ cohort=everyone,
label=reviewer_fixed,
horizon_days=14,
min_holdout_positives=20,