: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): lengthen open, action and fixed ranking horizons (#117518)
posthog[bot]d8965c844dae
diff --git a/docs/internal/inbox-ranking-training.md b/docs/internal/inbox-ranking-training.mdindex d99b5a4abab2..0aec94e5f6fe 100644--- a/docs/internal/inbox-ranking-training.md+++ b/docs/internal/inbox-ranking-training.md@@ -35,15 +35,15 @@ 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 |+| `open` | P(opened) over every report | 7d |+| `action` | P(acted on) over every report | 14d || `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 |+| `fixed` | P(fixed) over every report | 30d || `refund` | P(refund) over every report | 14d || `dismiss_lowvalue` | P(dismissed as real but not worth fixing) over every report | 21d |diff --git a/products/signals/dags/inbox_ranking/README.md b/products/signals/dags/inbox_ranking/README.mdindex ad41003397b7..fe1b324d83a1 100644--- a/products/signals/dags/inbox_ranking/README.md+++ b/products/signals/dags/inbox_ranking/README.md@@ -148,7 +148,7 @@ s3://<bucket>/<prefix>/- **A model is a `(model_name, model_version, model_role)`.** `model_name` is the family: which features and which learner: `report_embeddings` and `title_embeddings`, both per-head XGBoost, are the two trained here. `nn`, one ONNX network, is trained by the `signals_ml` location, and each `MODEL_FAMILIES` entry names its `learner` and the `location` that trains it. `model_version` is the partition day it was fit on, and `model_role` is the role it was scored or trained under (`candidate` on the training events; `served`, `daily_candidate` or `cross_family` on the online grade). 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 second family is a second model graded on the same online rows, not a competitor for another 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. `report_embeddings` and `title_embeddings` are the two 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 / 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.+- **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 (7 for open / pr_created / discuss / thumbs_up, 14 for action / pr_merged / refund / reviewer_fix, 21 for dismiss_wrong / dismiss_lowvalue, 30 for 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`, `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 training job's whatever the grain, so positives accrue over the whole window until the budget binds.@@ -233,12 +233,12 @@ Both regions read the same flag, so one override applies everywhere, if the regi| Head | Cohort at the horizon | Horizon (days) || ------------------ | --------------------- | -------------- |-| `open` | Every report | 3 |-| `action` | Every report | 7 |+| `open` | Every report | 7 |+| `action` | Every report | 14 || `dismiss_wrong` | Every report | 21 || `pr_created` | Every report | 7 || `pr_merged` | Every report | 14 |-| `fixed` | Every report | 21 |+| `fixed` | Every report | 30 || `discuss` | Every report | 7 || `refund` | Every report | 14 || `thumbs_up` | Every report | 7 |@@ -269,7 +269,7 @@ The model is read in three layers: **training** (train metrics), **test** (the rThe holdout grades the recipe, not the model that ships: the shipped booster is refit on train plus holdout, and every holdout row comes from the same snapshots the trainer saw.Two assets add the missing number, from the scores the sweep actually wrote for reports no model trained on.-- **`inbox_ranking_served_scores` (dt=D)** (`training/served.py`) takes the dt=D state rows of the reports **created on D**, the pool the rows tag `pool=newborn`. A newborn has no scoring moment before D, and the dt=D examples stop at D minus the head's horizon (3 days at the shortest), so no example can cover it. It reads this deployment's `inbox_ranking_report_scored` events for that pool inside D and keeps the earliest `scored` event per (report, model key), so every model the manifest named is graded: the served champion, the served family's `daily_candidate`, and the other families' `cross_family` champions. `model_role` comes from the event's roles: `served` when they hold it, else the first role, else `candidate`. The sweep scores a candidate only after a manifest names it, so a candidate's online cohort starts the day after it was trained. Every head a model fit is scored, readable or not, and each row carries `head_readable` and the model's own `classification_threshold`. One Parquet row per (report, model key, head) carries the score, `age_hours`, `label_at_scoring` (the head outcome that had already happened when the report was scored, which for a newborn is one that landed on its own birth day, so the grade keeps it; a status-label head's rows are still dropped on it, because no scores column carries the scoring-day `label_provenance_ok` that the example builder checks), `model_name`, `model_role`, and `pool`. `served_pool_coverage` and `pool_coverage_by_model` say how much of the pool each model covered. A re-run that reads no event is refused when the partition already holds rows, and so is one that reads fewer families than the object already holds. Rows of a retired family (`RETIRED_MODEL_NAMES`) are dropped on read, and the rewrite guard does not require them.+- **`inbox_ranking_served_scores` (dt=D)** (`training/served.py`) takes the dt=D state rows of the reports **created on D**, the pool the rows tag `pool=newborn`. A newborn has no scoring moment before D, and the dt=D examples stop at D minus the head's horizon (7 days at the shortest), so no example can cover it. It reads this deployment's `inbox_ranking_report_scored` events for that pool inside D and keeps the earliest `scored` event per (report, model key), so every model the manifest named is graded: the served champion, the served family's `daily_candidate`, and the other families' `cross_family` champions. `model_role` comes from the event's roles: `served` when they hold it, else the first role, else `candidate`. The sweep scores a candidate only after a manifest names it, so a candidate's online cohort starts the day after it was trained. Every head a model fit is scored, readable or not, and each row carries `head_readable` and the model's own `classification_threshold`. One Parquet row per (report, model key, head) carries the score, `age_hours`, `label_at_scoring` (the head outcome that had already happened when the report was scored, which for a newborn is one that landed on its own birth day, so the grade keeps it; a status-label head's rows are still dropped on it, because no scores column carries the scoring-day `label_provenance_ok` that the example builder checks), `model_name`, `model_role`, and `pool`. `served_pool_coverage` and `pool_coverage_by_model` say how much of the pool each model covered. A re-run that reads no event is refused when the partition already holds rows, and so is one that reads fewer families than the object already holds. Rows of a retired family (`RETIRED_MODEL_NAMES`) are dropped on read, and the rewrite guard does not require them.- **`inbox_ranking_unseen_graded` (dt=D)** reads saved scores from D back through each head's horizon and evaluates them against the dt=D labels. Daily head evaluations include both unbaked and baked metrics, marked by `is_mature`; existing head, report and calibration grade events remain baked-only at `D - horizon_days`. See [baked and unbaked unseen metrics](../../../../docs/internal/inbox-ranking-training.md#baked-and-unbaked-unseen-metrics) for the event contract and chart revision rules. It keeps the rows whose cohort holds at D, reads the outcome with `Head.label`, and reports the AUC per model and head next to two comparison lines on the same rows: `recency_auc`, the AUC of ranking newest first by `report_created_at`, and `null_auc` / `null_auc_std`, the mean and spread of the AUC over seeded permutations of the scores. The mean is 0.5 by construction; the spread is the noise band a per-day AUC has to clear before a gap between two families means anything. It also reads the calibration of those scores, which no AUC can see: the in-cohort rows are cut into score deciles by rank (`training/calibration.py`, shared with the trainer so both sides cut them the same way), and each decile's mean score is compared against the rate the outcome actually happened at. A run of equal scores stays in one decile, so a head reports fewer deciles rather than a gap that only reflects the row order. Read each grade with the model's `pool_coverage_by_model`: a key that joined the manifest part of the way through D grades only part of the pool.At the full horizon, the cohort, label and provenance rules are the trainer's own, so the baked online 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.@@ -295,7 +295,7 @@ The `title_embeddings` and `report_embeddings` families are trained and graded t- **Read the uncertainty before the sign.** `null_auc_std` on each grade is the spread a per-day AUC has on those rows. A difference inside that band is inconclusive, not evidence that the two renderings carry the same signal. Pool about 30 days before treating a direction as real.- **Carry coverage and positives with every figure.** `pool_coverage_by_model` on the scores asset says how much of the pool each model scored, and `rows` / `positives` / `birth_day_positives` on each grade say how much outcome the AUC rests on. A family graded largely on its missing branch reads low for a reason that is not the text.- **Keep the baselines on the same rows.** `recency_auc` and the other embedding family are reported on the same grade, so the reading is title against combined against newest-first, not against numbers from another day.-- **Read `open` first.** It has the shortest horizon (3 days), so its labels mature first; `action` and `pr_created` follow at 7 days. Emission is forward-only and a moment only takes a vector that had already landed, so both families accrue from the first partition after their input starts flowing.+- **Read `open` first.** It has the shortest horizon (7 days, shared with `pr_created`) and the most positives, so its labels mature first; `action` follows at 14 days. Emission is forward-only and a moment only takes a vector that had already landed, so both families accrue from the first partition after their input starts flowing.- **This is not an online experiment.** Every row is a live birth-day score graded against a later snapshot, and the outcomes it grades happened under the order the inbox actually served. A gap between two families is a difference in rank quality on logged outcomes, not a causal claim about what the inbox would do differently.Nothing in this read changes what the inbox serves. The scoring sweep serves the family the manifest names (`INBOX_RANKING_SERVED_FAMILY`), promotion stays inside a family, and `INBOX_RANKING_AUTO_PROMOTE` gates the pointer rewrite; a rendering that wins here earns a separate decision, not an automatic promotion.diff --git a/products/signals/dags/inbox_ranking/tests/test_multihead.py b/products/signals/dags/inbox_ranking/tests/test_multihead.pyindex 3844d5352827..f37861fae0f5 100644--- a/products/signals/dags/inbox_ranking/tests/test_multihead.py+++ b/products/signals/dags/inbox_ranking/tests/test_multihead.py@@ -24,7 +24,7 @@ from products.signals.dags.inbox_ranking.training.examples import Snapshot, cap_from products.signals.dags.inbox_ranking.training.heads import ACTION_LABEL_COLUMNSD0 = datetime.date(2026, 8, 1)-DAYS = 40+DAYS = 49REPORTS_PER_DAY = 12HOLDOUT_DAYS = 7TEAMS = (2, 3)diff --git a/products/signals/dags/inbox_ranking/tests/test_training.py b/products/signals/dags/inbox_ranking/tests/test_training.pyindex dc94ac1cd87e..c3fae4c1a0c2 100644--- a/products/signals/dags/inbox_ranking/tests/test_training.py+++ b/products/signals/dags/inbox_ranking/tests/test_training.py@@ -867,7 +867,7 @@ def test_pr_merged_is_a_merge_from_birth_rather_than_a_merge_given_a_pr():def test_reports_missing_birth_snapshot_counts_only_the_ones_a_partition_gap_costs(monkeypatch):gap = D0 + datetime.timedelta(days=1)- dates = [D0 + datetime.timedelta(days=offset) for offset in range(6)]+ dates = [D0 + datetime.timedelta(days=offset) for offset in range(3 + HEADS_BY_NAME["open"].horizon_days)]ids = ["born_in_the_gap", "older", "utc_start", "utc_end", "label_only"]created = [pd.Timestamp(gap, tz="UTC") + pd.Timedelta(hours=9),@@ -1513,7 +1513,7 @@ def test_training_events_carry_the_dashboard_contract(monkeypatch):["a"], model_version=["2026-08-25"], score=[0.8], label_at_scoring=[True], classification_threshold=[0.3])graded = graded_rows(scores, _labels(["a"], open_count=[1]), HEADS_BY_NAME["open"], pool=POOL_NAME)- grades = head_grades(graded, HEADS_BY_NAME["open"], pool=POOL_NAME, scoring_partition="2026-08-22")+ grades = head_grades(graded, HEADS_BY_NAME["open"], pool=POOL_NAME, scoring_partition="2026-08-18")events = [*candidate_events(metadata),*examples_events(@@ -1568,7 +1568,7 @@ def test_training_events_carry_the_dashboard_contract(monkeypatch):),*unseen_report_graded_events(run_id="run-1",- rows=report_grade_rows({"open": graded}, pool=POOL_NAME, horizon_days=3, scoring_partition="2026-08-22"),+ rows=report_grade_rows({"open": graded}, pool=POOL_NAME, horizon_days=7, scoring_partition="2026-08-18"),),]client = _patch_capture(monkeypatch, cloud=True, debug=False)@@ -1631,9 +1631,9 @@ def test_training_events_carry_the_dashboard_contract(monkeypatch):assert {"head": "open","model_role": CANDIDATE_ROLE,- "scoring_partition": "2026-08-22",+ "scoring_partition": "2026-08-18","pool": POOL_NAME,- "horizon_days": 3,+ "horizon_days": 7,"rows": 1,"positives": 1,"birth_day_positives": 1,@@ -1650,7 +1650,7 @@ def test_training_events_carry_the_dashboard_contract(monkeypatch):calibration_props = by_event["inbox_ranking_unseen_calibration"][0]["properties"]assert {"head": "open",- "scoring_partition": "2026-08-22",+ "scoring_partition": "2026-08-18","pool": POOL_NAME,"bucket": 1,"rows": 1,@@ -1670,9 +1670,9 @@ def test_training_events_carry_the_dashboard_contract(monkeypatch):assert {"report_id": "a","model_role": CANDIDATE_ROLE,- "scoring_partition": "2026-08-22",+ "scoring_partition": "2026-08-18","pool": POOL_NAME,- "horizon_days": 3,+ "horizon_days": 7,"in_cohort_open": True,"outcome_open": True,"p_open": 0.8,@@ -2184,7 +2184,7 @@ def test_candidate_metadata_declares_the_set_it_was_fit_on(family):def test_build_examples_carries_the_columns_of_the_set_it_is_given():# The examples Parquet is per feature set, so a second set's object holds its own features.ids = ["a"]- later = D0 + datetime.timedelta(days=3)+ later = D0 + datetime.timedelta(days=HEADS_BY_NAME["open"].horizon_days)snapshots = {D0: Snapshot(date=D0, state=_state(ids), labels=_labels(ids)),later: Snapshot(date=later, state=_state(ids), labels=_labels(ids, open_count=[2])),diff --git a/products/signals/dags/inbox_ranking/training/heads.py b/products/signals/dags/inbox_ranking/training/heads.pyindex 4509d910f0bc..38b9414397e9 100644--- a/products/signals/dags/inbox_ranking/training/heads.py+++ b/products/signals/dags/inbox_ranking/training/heads.py@@ -136,16 +136,18 @@ class Head:HEADS: tuple[Head, ...] = (# Which reports got opened by anyone? Cohort is every report: opens from a deeplink, the desktop- # app or any other surface count, and those often have no list impression.- Head(name="open", cohort=everyone, label=opened, horizon_days=3, min_holdout_positives=50),+ # app or any other surface count, and those often have no list impression. Many opens land after+ # the first few days, so 7 days labels fewer late opens as negatives than 3 did.+ Head(name="open", cohort=everyone, label=opened, horizon_days=7, min_holdout_positives=50),# Which reports did someone act on, from any surface? The cohort is everyone, because a report# worked from Slack, the desktop app or an agent was often never impressed in the cloud list.# The label reads the status stream (a reasoned resolve), so it needs the provenance check.+ # Many actions land in the second week, so 14 days labels fewer late actions as negatives than 7 did.Head(name="action",cohort=everyone,label=acted,- horizon_days=7,+ horizon_days=14,min_holdout_positives=30,label_columns=ACTION_LABEL_COLUMNS,status_labels=True,@@ -176,12 +178,13 @@ HEADS: tuple[Head, ...] = (),# Which reports flagged a real problem that then got fixed, by anyone and on any surface? Reads# only the status stream: a tracked PR merge, a hand-marked fix, or a dismissal as already- # fixed all count. 21 days because fixes marked by hand arrive about two weeks after birth.+ # fixed all count. Fixes marked by hand arrive about two weeks after birth and many land later,+ # so 30 days labels fewer late fixes as negatives than 21 did.Head(name="fixed",cohort=everyone,label=fixed,- horizon_days=21,+ horizon_days=30,min_holdout_positives=30,label_columns=("fixed_count",),status_labels=True,