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): train only the open, action and fixed ranking heads (#118616)

posthog[bot]a39c9cb2e26a
diff --git a/docs/internal/inbox-ranking-training.md b/docs/internal/inbox-ranking-training.md
index 0aec94e5f6fe..0578ee7e0958 100644
--- a/docs/internal/inbox-ranking-training.md
+++ b/docs/internal/inbox-ranking-training.md
@@ -11,9 +11,8 @@ This prevents long-lived reports from receiving more weight in training because
Birth days use the UTC interval returned by `snapshot_bounds`, including the start and excluding the end.
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 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 families train only the heads the inbox reads: `open`, `action` and `fixed`.
+The dataset still snapshots the label columns of other outcomes, so a head can come back without a labels backfill.
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.
@@ -33,19 +32,11 @@ 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 | 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 | 30d |
-| `refund` | P(refund) over every report | 14d |
-| `dismiss_lowvalue` | P(dismissed as real but not worth fixing) over every report | 21d |
+| Head | Probability | Horizon |
+| -------- | ----------------------------- | ------- |
+| `open` | P(opened) over every report | 7d |
+| `action` | P(acted on) over every report | 14d |
+| `fixed` | P(fixed) over every report | 30d |
Each head in `metadata.json` records `cohort` (`everyone`) and `horizon_days`.
diff --git a/products/signals/dags/inbox_ranking/AGENTS.md b/products/signals/dags/inbox_ranking/AGENTS.md
index fc00b06d4caa..6540c4cdc923 100644
--- a/products/signals/dags/inbox_ranking/AGENTS.md
+++ b/products/signals/dags/inbox_ranking/AGENTS.md
@@ -24,7 +24,7 @@ Read `README.md` first for what the dataset is and how partitions behave. This f
- `inbox_ranking_models/v1/<model_name>/dt=D/` is history like the dataset partitions: the only mutation is a re-run of the same partition, which replaces the prefix in full (stale head files are deleted). `<model_name>/champion.json` is the only object written outside its partition, and only the champion asset (or a human, deliberately) writes it; it carries the candidate's `run_id`, so a loader can detect a re-run behind a pinned version.
- The model is read in three layers: **training** (train metrics), **test** (the random-by-report holdout, which drives promotion) and **online** (`inbox_ranking_served_scores`, the scoring sweep's live scores of each day's newborns, graded by `inbox_ranking_unseen_graded` at each head's horizon). Do not add an offline rescoring of the newborn pool beside the online layer: the sweep already scores it with every model key the manifest names.
- `served_score_rows` keeps the earliest scored event per (report, model key) and takes `model_role` from the event's roles. Grades stay per `(model_name, model_version, model_role)` and are never pooled across versions. 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 holds, because the newborn state snapshot behind those rows ages out and the dt=D+horizon grade reads them.
-- Every scored row carries `head_readable`, and an unreadable head is still graded: a rare head (`thumbs_up`, `reviewer_fix`) never clears `min_holdout_positives` on one day's holdout, so the pooled online grade is the only read that can give it a number. Keep the promotion gate reading `readable` from the candidate metadata: an unreadable head must not decide a promotion.
+- Every scored row carries `head_readable`, and an unreadable head is still graded: a head that misses `min_holdout_positives` on one day's holdout still gets a number from the pooled online grade. Keep the promotion gate reading `readable` from the candidate metadata: an unreadable head must not decide a promotion.
- `model_name` is the model family, and every model object, scored row, grade and event carries it. A family is an entry in `MODEL_FAMILIES` (`training/unseen.py`) naming the feature set it is fit on, its `learner` and the `location` that trains it; each location's candidate and champion assets walk `families_trained_in(<location>)`, and the grader and the events need no change to gain a family. Promotion stays inside a family, so a family never takes another family's `champion.json`. Do not fold the family into `model_version`, which the dashboard filters as a date.
- A family whose `metadata.json`, examples object or side input is missing for a partition is logged and skipped, so one family does not cost every family's series. The champion asset raises only when no family has a candidate at all.
- Skipping is not the same as rebuilding from nothing, and the difference is destructive. An empty examples object produces an empty candidate, and the candidate's prefix cleanup then deletes the boosters that partition already holds, which a `champion.json` can be pointing at. So when a side input is unavailable, leave the partition's objects alone rather than writing empty ones over them.
@@ -35,6 +35,7 @@ Read `README.md` first for what the dataset is and how partitions behave. This f
- The manifest schema and the object keys live in `products/signals/backend/ranking/serving_manifest.py`, next to the feature contract, because the dag writes them and the sweep reads them. Its validators run at write time, so the dag refuses a manifest the sweep could not act on; the entry cap is the `ranking_score` artefact's, so a manifest can never produce a row the artefact refuses.
- Publishing order is load-bearing. Every model copy finishes before `manifest.json` is written, so a failed copy leaves the previous manifest and the previous models serving. A model version is immutable, so a version whose `metadata.json` is already at the target is not copied again. A run with nothing to publish, and no champion for the served family is the case today, writes nothing rather than an empty manifest.
- When a manifest entry has `reads_project_vectors`, the dt=D `inbox_project_vectors` day is copied to `serving/project_vectors/<D>/` before `manifest.json`, and the manifest names it in `project_vectors`. A missing day fails the publish, like a missing model file. Never copy project vectors to the mirror: they are per-team data of this deployment, so the mirror's manifest names none. Training and serving build the `project` and `has_history` inputs through the one `project_inputs` in `features.py`; keep `PROJECT_VECTOR_KINDS` and `MIN_PROJECT_HISTORY_REPORTS` there.
+- `HEADS` holds only the heads the inbox reads (`HeadRanker` in `backend/ranking/inbox_sort.py`). Add a head there only together with a surface that reads it. The promotion gate skips a champion head that is not in `HEADS`, so a trim does not block promotion.
- `nn` is trained by the `signals_ml` location (`nn/dag.py`), never by the main one. torch is imported only inside the candidate asset's body (through `nn/train.py` and `multihead/network.py`). `signals_ml` must import without torch, and `test_multihead_network.py` pins that. Its champion goes through `decide_family_champion`, the same rule and gate as the boosters, graded through the incumbent's `model.holdout.onnx`. Keep `signals_ml` commented out in `.dagster_home/workspace.yaml`, and keep its schedule (04:30 UTC) running by default on prod US only.
## Invariants — do not break
diff --git a/products/signals/dags/inbox_ranking/README.md b/products/signals/dags/inbox_ranking/README.md
index 6b0b4df21664..8283a3141e35 100644
--- a/products/signals/dags/inbox_ranking/README.md
+++ b/products/signals/dags/inbox_ranking/README.md
@@ -148,9 +148,9 @@ 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 (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.
+- **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, 14 for action, 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 (`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.
- **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.
+- **Every head asks whether the outcome happened within N days of the scoring moment.**
- **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.
- **The embedding sets are the serving contract.** Each reads one rendering's vector and nothing else, so the scoring sweep needs only the report's latest vector for that rendering. The sweep must build features through the same module; the booster's `feature_names` are checked against it at load. A model whose metadata names no set is left unscored.
- **`report_embeddings` is the report's own vector and nothing else**, read from the dt=D `inbox_report_embeddings` snapshot as a side input. Age is deliberately left out: it is the whole signal of the `recency_auc` line the unseen read already reports, so a gap to that line is content rather than recency. The scoring sweep does not serve this set: it is an offline candidate, and serving it needs the report vector at scoring time.
@@ -231,19 +231,15 @@ Both regions read the same flag, so one override applies everywhere, if the regi
### Outcome heads
-| Head | Cohort at the horizon | Horizon (days) |
-| ------------------ | --------------------- | -------------- |
-| `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 | 30 |
-| `discuss` | Every report | 7 |
-| `refund` | Every report | 14 |
-| `thumbs_up` | Every report | 7 |
-| `reviewer_fix` | Every report | 14 |
-| `dismiss_lowvalue` | Every report | 21 |
+| Head | Cohort at the horizon | Horizon (days) |
+| -------- | --------------------- | -------------- |
+| `open` | Every report | 7 |
+| `action` | Every report | 14 |
+| `fixed` | Every report | 30 |
+
+The families train only these three heads, because the inbox reads only these three.
+The dataset still snapshots the label columns of other outcomes, so a head can come back without a labels backfill.
+The promotion gate compares only the heads in `HEADS`, so a champion that carries a retired head does not block a candidate without it.
`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.
@@ -261,10 +257,6 @@ Filter on `surface` where a metric must stay Inbox-only.
Today sets a verdict first and sends its optional reason in a second state call, which does not change the status.
For that call the server emits `signal_report_status_changed` with `previous_status` equal to `status` and `reason_added: true`, so the reason reaches the status-stream heads.
-`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, 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.
Before and after holdout numbers are not comparable because the example population changes.
See [training example semantics](../../../../docs/internal/inbox-ranking-training.md) for gap handling and snapshot boundaries.
diff --git a/products/signals/dags/inbox_ranking/tests/test_training.py b/products/signals/dags/inbox_ranking/tests/test_training.py
index ba555ea73176..828b915e8c0a 100644
--- a/products/signals/dags/inbox_ranking/tests/test_training.py
+++ b/products/signals/dags/inbox_ranking/tests/test_training.py
@@ -102,12 +102,7 @@ from products.signals.dags.inbox_ranking.training.examples import (
holdout_mask,
reports_missing_birth_snapshot,
)
-from products.signals.dags.inbox_ranking.training.heads import (
- ACTION_LABEL_COLUMNS,
- HEADS_BY_NAME,
- Head,
- dismissed_as_wrong,
-)
+from products.signals.dags.inbox_ranking.training.heads import ACTION_LABEL_COLUMNS, HEADS_BY_NAME, Head
from products.signals.dags.inbox_ranking.training.promotion import (
AUC_TOLERANCE,
ECE_TOLERANCE,
@@ -287,13 +282,13 @@ 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 == 21
+ head = HEADS_BY_NAME["open"]
+ fixed_head = HEADS_BY_NAME["fixed"]
+ assert fixed_head.horizon_days == 30
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;
- # c: trusted, dismissed as wrong by the horizon; gone: hard-deleted before the horizon, so the
+ # c: trusted, fixed by the horizon; gone: hard-deleted before the horizon, so the
# later snapshot has its label row but no state row.
state = _state(
ids,
@@ -301,38 +296,39 @@ def test_assemble_snapshot_makes_never_labeled_reports_negatives_and_drops_untru
status=["ready"] * 4,
pg_updated_at=[pd.Timestamp("2026-08-09T12:00:00Z")] * 4,
)
- labels_now = _labels(["a", "c"], latest_status_event=["suppressed", None], status_event_team_id=[99, None])
+ labels_now = _labels(
+ ["a", "c"], latest_status_event=["suppressed", None], status_event_team_id=[99, None], fixed_count=[0, 0]
+ )
labels_later = _labels(
["a", "c", "gone"],
latest_status_event=["suppressed", "suppressed", None],
status_event_team_id=[99, 1, None],
- wrong_dismissal_count=[1, 1, 0],
- pr_created_count=[0, 1, 1],
+ fixed_count=[1, 1, 0],
+ open_count=[0, 1, 1],
)
state_later = state.drop("gone").assign(status=["ready", "ready", "suppressed"])
snapshots = {
D0: assemble_snapshot(D0, state, labels_now),
later: assemble_snapshot(later, state_later, labels_later),
# The two heads read different horizons off the same day.
- D0 + datetime.timedelta(days=wrong_head.horizon_days): assemble_snapshot(
- D0 + datetime.timedelta(days=wrong_head.horizon_days), state_later, labels_later
+ D0 + datetime.timedelta(days=fixed_head.horizon_days): assemble_snapshot(
+ D0 + datetime.timedelta(days=fixed_head.horizon_days), state_later, labels_later
),
}
assert snapshots[D0].labels.loc["b", "impression_unit_count"] == 0
assert snapshots[D0].labels["label_provenance_ok"].to_dict() == {"a": False, "b": True, "c": True, "gone": True}
assert snapshots[later].labels["label_provenance_ok"].to_dict() == {"a": False, "b": True, "c": True, "gone": False}
- # pr_created reads the tasks webhook, so a's untrusted status telemetry does not exclude it there.
- pr = build_examples(snapshots, head, STATE_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 but is a negative,
- # c is a positive.
- wrong = build_examples(snapshots, wrong_head, STATE_FEATURE_SET).set_index("report_id")["label"].to_dict()
- assert wrong == {"b": 0, "c": 1}
+ # open reads the open events, so a's untrusted status telemetry does not exclude it there.
+ opened = build_examples(snapshots, head, STATE_FEATURE_SET).set_index("report_id")["label"].to_dict()
+ assert opened == {"a": 0, "b": 0, "c": 1, "gone": 1}
+ # fixed reads the status stream: a is dropped, b has no label row but is a negative, c is a positive.
+ fixed = build_examples(snapshots, fixed_head, STATE_FEATURE_SET).set_index("report_id")["label"].to_dict()
+ assert fixed == {"b": 0, "c": 1}
def test_build_examples_drops_state_rows_read_long_after_their_snapshot():
- head = HEADS_BY_NAME["pr_created"]
+ head = HEADS_BY_NAME["open"]
later = D0 + datetime.timedelta(days=head.horizon_days)
forward_run = pd.Timestamp(D0 + datetime.timedelta(days=1), tz="UTC") + pd.Timedelta(hours=3)
backfill = pd.Timestamp(D0 + datetime.timedelta(days=1), tz="UTC") + STATE_LAG_LIMIT + pd.Timedelta(hours=1)
@@ -344,33 +340,9 @@ def test_build_examples_drops_state_rows_read_long_after_their_snapshot():
assert build_examples(snapshots, head, STATE_FEATURE_SET)["report_id"].tolist() == ["a"]
- "frame,expected",
- [
- # The cumulative count wins: a wrong dismissal later overwritten by already_fixed stays positive.
- (
- pd.DataFrame({"wrong_dismissal_count": [1, 0], "dismissal_reason": ["already_fixed", "analysis_wrong"]}),
- [True, False],
- ),
- # Partitions written before the count existed fall back to the latest-wins reason.
- (pd.DataFrame({"dismissal_reason": ["already_fixed", "analysis_wrong"]}), [False, True]),
- ],
-)
-def test_dismissed_as_wrong_prefers_the_cumulative_count(frame, expected):
- assert dismissed_as_wrong(frame).tolist() == expected
-
-
@pytest.mark.parametrize(
"head_name,frame,expected_cohort,expected_label",
[
- # pr_merged: cohort is everyone, label is the merge within the horizon, whether or not the
- # report already had a PR at the scoring moment.
- (
- "pr_merged",
- pd.DataFrame({"pr_created_count": [1, 1, 0], "pr_merged_count": [1, 0, 1]}),
- [True, True, True],
- [True, False, True],
- ),
# action: cohort is everyone, so a never-impressed report an agent claimed is a positive.
# A server-side action and a UI action are the same label.
(
@@ -393,56 +365,9 @@ def test_dismissed_as_wrong_prefers_the_cumulative_count(frame, expected):
[True, True, True],
[True, False, False],
),
- # 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, 1]}),
- [True, True, True],
- [True, False, True],
- ),
- # refund: cohort is everyone, label is a refund event.
- (
- "refund",
- pd.DataFrame({"refund_count": [1, 0, 0]}),
- [True, True, True],
- [True, False, False],
- ),
- # 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, True],
- [True, False, False],
- ),
- # 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, 1],
- "reviewer_remove_count": [0, 2, 0, 0],
- }
- ),
- [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):
+def test_heads_read_the_right_cohort_and_label_columns(head_name, frame, expected_cohort, expected_label):
head = HEADS_BY_NAME[head_name]
assert head.cohort(frame).tolist() == expected_cohort
assert head.label(frame).tolist() == expected_label
@@ -469,16 +394,11 @@ class _ParquetS3:
@pytest.mark.parametrize(
"head_name,positive_column",
[
- ("pr_merged", "pr_merged_count"),
("fixed", "fixed_count"),
- ("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),
],
)
-def test_new_head_label_columns_survive_the_load_snapshots_projection(monkeypatch, head_name, positive_column):
+def test_head_label_columns_survive_the_load_snapshots_projection(monkeypatch, head_name, positive_column):
# load_snapshots projects the labels parquet down to _LABEL_COLUMNS before any head sees it, so a
# head whose label column is missing from that list trains on all-zero labels. The cohort/label
# unit test hand-builds frames that already carry the columns, so it never crosses the projection.
@@ -490,18 +410,7 @@ def test_new_head_label_columns_survive_the_load_snapshots_projection(monkeypatc
)
head = HEADS_BY_NAME[head_name]
later = D0 + datetime.timedelta(days=head.horizon_days)
- zeros = {
- column: [0]
- for column in (
- "pr_merged_count",
- "fixed_count",
- "refund_count",
- "feedback_positive_count",
- "reviewer_add_count",
- "lowvalue_dismissal_count",
- *ACTION_LABEL_COLUMNS,
- )
- }
+ zeros = {column: [0] for column in ("fixed_count", *ACTION_LABEL_COLUMNS)}
labels_now = _labels(["a"], open_count=[1], **zeros)
labels_later = _labels(["a"], open_count=[1], **{**zeros, positive_column: [1]})
objects: dict[str, bytes] = {}
@@ -514,33 +423,33 @@ def test_new_head_label_columns_survive_the_load_snapshots_projection(monkeypatc
assert examples.set_index("report_id")["label"].to_dict() == {"a": 1}
-def test_build_examples_skips_refund_pairs_when_the_scoring_snapshot_lacks_the_column():
- # refund_count entered the labels schema after the epoch, so a partition written before it has no
- # such column. Without the guard _count reads the gap as zero, so the "not refunded yet" filter
- # passes for a report already refunded before D0, and its cumulative refund in the later snapshot
- # mints a stale future positive. The whole pair must be skipped, not scored.
- head = HEADS_BY_NAME["refund"]
+def test_build_examples_skips_pairs_when_the_scoring_snapshot_lacks_a_label_column():
+ # A partition written before a label column existed has no such column. Without the guard _count
+ # reads the gap as zero, so the "not fixed yet" filter passes for a report already fixed before
+ # D0, and its cumulative count in the later snapshot mints a stale future positive. The whole
+ # pair must be skipped, not scored.
+ head = HEADS_BY_NAME["fixed"]
later = D0 + datetime.timedelta(days=head.horizon_days)
snapshots = {
D0: Snapshot(date=D0, state=_state(["a"]), labels=_labels(["a"])),
- later: Snapshot(date=later, state=_state(["a"]), labels=_labels(["a"], refund_count=[1])),
+ later: Snapshot(date=later, state=_state(["a"]), labels=_labels(["a"], fixed_count=[1])),
}
assert build_examples(snapshots, head, STATE_FEATURE_SET).empty
def test_build_examples_skips_label_only_rows():
- head = HEADS_BY_NAME["pr_created"]
+ head = HEADS_BY_NAME["open"]
later = D0 + datetime.timedelta(days=head.horizon_days)
state = _state(["a", "eu"], signal_count=[3, None])
snapshots = {
D0: Snapshot(date=D0, state=state, labels=_labels(["a", "eu"])),
- later: Snapshot(date=later, state=state, labels=_labels(["a", "eu"], pr_created_count=[1, 1])),
+ later: Snapshot(date=later, state=state, labels=_labels(["a", "eu"], open_count=[1, 1])),
}
assert build_examples(snapshots, head, STATE_FEATURE_SET)["report_id"].tolist() == ["a"]
def test_build_examples_drops_reports_without_training_consent_at_training_time():
- head = HEADS_BY_NAME["pr_created"]
+ head = HEADS_BY_NAME["open"]
later = D0 + datetime.timedelta(days=head.horizon_days)
# opted_out: its organization opted out after these snapshots were written; no_team: a state row
# with no readable team; eu: a label-only row with no state.
@@ -548,7 +457,7 @@ def test_build_examples_drops_reports_without_training_consent_at_training_time(
state = _state(ids, report_team_id=[1, 2, None, None], signal_count=[3, 3, 3, None])
snapshots = {
D0: Snapshot(date=D0, state=state, labels=_labels(ids)),
- later: Snapshot(date=later, state=state, labels=_labels(ids, pr_created_count=[1, 1, 1, 1])),
+ later: Snapshot(date=later, state=state, labels=_labels(ids, open_count=[1, 1, 1, 1])),
}
kept, excluded = drop_without_training_consent(snapshots, frozenset({1}))
@@ -844,27 +753,6 @@ def test_birth_grain_keeps_one_row_per_report_on_the_day_it_was_created(feature_
assert moments[moments["report_id"] == "newborn"]["label"].tolist() == [0, 1, 1]
-def test_pr_merged_is_a_merge_from_birth_rather_than_a_merge_given_a_pr():
- head = HEADS_BY_NAME["pr_merged"]
- assert head.horizon_days == 14
- later = D0 + datetime.timedelta(days=14)
- merged_day = D0 + datetime.timedelta(days=10)
- ids = ["merged", "unmerged", "nothing"]
- snapshots = {
- D0: assemble_snapshot(D0, _state(ids), _labels(ids, pr_created_count=[0, 1, 0], pr_merged_count=[0, 0, 0])),
- **{
- date: assemble_snapshot(
- date, _state(ids), _labels(ids, pr_created_count=[1, 1, 0], pr_merged_count=[1, 0, 0])
- )
- for date in (merged_day, later)
- },
- }
-
- examples = build_examples(snapshots, head, STATE_FEATURE_SET)
-
- assert examples.set_index("report_id")["label"].to_dict() == {"merged": 1, "unmerged": 0, "nothing": 0}
-
-
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(3 + HEADS_BY_NAME["open"].horizon_days)]
@@ -903,18 +791,18 @@ def test_reports_missing_birth_snapshot_counts_only_the_ones_a_partition_gap_cos
def test_build_examples_keeps_an_outcome_that_landed_on_the_reports_birth_day():
- # Most PRs land the day the report is born. Censoring on the labels of the birth day would
+ # Many outcomes land the day the report is born. Censoring on the labels of the birth day would
# drop those positives from the head that predicts them.
- head = HEADS_BY_NAME["pr_created"]
+ head = HEADS_BY_NAME["open"]
later = D0 + datetime.timedelta(days=head.horizon_days)
ids = ["newborn", "old"]
created = [pd.Timestamp("2026-08-10T09:00:00Z"), pd.Timestamp("2026-07-01T00:00:00Z")]
snapshots = {
- date: assemble_snapshot(date, _state(ids, report_created_at=created), _labels(ids, pr_created_count=[1, 1]))
+ date: assemble_snapshot(date, _state(ids, report_created_at=created), _labels(ids, open_count=[1, 1]))
for date in (D0, later)
}
examples = build_examples(snapshots, head, STATE_FEATURE_SET)
- # The old report's PR predates D0, so it belongs to a moment before D0 and stays censored.
+ # The old report's open predates D0, so it belongs to a moment before D0 and stays censored.
assert examples.set_index("report_id")["label"].to_dict() == {"newborn": 1}
assert birth_day_positives(examples) == 1
@@ -953,11 +841,11 @@ def test_grading_an_older_pool_still_drops_an_outcome_that_predates_the_score():
def test_grading_a_status_label_head_drops_a_newborn_outcome_from_the_scoring_day():
# build_examples reads label_provenance_ok on the scoring snapshot too, and no scores column
# carries that verdict, so grading the row would accept a label the builder can still refuse.
- head = HEADS_BY_NAME["dismiss_wrong"]
+ head = HEADS_BY_NAME["fixed"]
scores = _scores(["a", "b"], label_at_scoring=[False, True])
labels = _labels(
["a", "b"],
- wrong_dismissal_count=[1, 1],
+ fixed_count=[1, 1],
impression_unit_count=[1, 1],
label_provenance_ok=[True, True],
)
@@ -1047,14 +935,14 @@ def test_head_grades_report_counts_and_an_undefined_auc_on_a_single_class():
@pytest.mark.parametrize(
- "observed_days,missing_merge_column",
- [(0, False), (1, False), (2, False), (3, False), (7, False), (14, False), (15, False), (0, True), (14, True)],
+ "observed_days,missing_fixed_column",
+ [(0, False), (1, False), (2, False), (3, False), (7, False), (30, False), (31, False), (0, True), (30, True)],
)
def test_unseen_daily_evaluations_keep_baked_events_at_each_heads_horizon(
- monkeypatch, observed_days, missing_merge_column
+ monkeypatch, observed_days, missing_fixed_column
):
ids = ["fast", "slow", "pending"]
- head_names = ["open", "pr_created", "pr_merged"]
+ head_names = ["open", "fixed"]
families = [STATE_MODEL_NAME, EMBEDDINGS_MODEL_NAME]
scores = pd.concat(
[
@@ -1067,10 +955,10 @@ def test_unseen_daily_evaluations_keep_baked_events_at_each_heads_horizon(
day = D0 + datetime.timedelta(days=observed_days)
partition = day.isoformat()
outcomes = [1, int(observed_days >= 2), 0]
- labels = _labels(ids, open_count=outcomes, pr_created_count=outcomes, pr_merged_count=outcomes)
- if missing_merge_column:
- labels = labels.drop(columns=["pr_merged_count"])
- head_names.remove("pr_merged")
+ labels = _labels(ids, open_count=outcomes, fixed_count=outcomes)
+ if missing_fixed_column:
+ labels = labels.drop(columns=["fixed_count"])
+ head_names.remove("fixed")
prefix = settings.INBOX_RANKING_DATASET_S3_PREFIX
storage = _ParquetS3(
{
@@ -1131,7 +1019,7 @@ def test_unseen_daily_evaluations_keep_baked_events_at_each_heads_horizon(
@pytest.mark.parametrize("labeled", [0, 1])
def test_daily_evaluation_keeps_empty_and_single_class_cohorts_explicit(labeled):
- head = HEADS_BY_NAME["discuss"]
+ head = HEADS_BY_NAME["open"]
# 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]),
@@ -1720,6 +1608,13 @@ def _metadata(version: str, **aucs: float | None) -> dict:
False,
"action readable on champion but not on candidate",
),
+ # A head retired from HEADS is never trained again, so it must not block the champion's successor.
+ (
+ _metadata("d2", open=0.65),
+ {**_metadata("d1", open=0.64, dismiss_wrong=0.7), "promoted_at": "2026-08-10T00:00:00+00:00"},
+ True,
+ "at or above",
+ ),
# A backfilled older candidate, even a much better one, must not roll the champion backwards.
(
_metadata("2026-08-11", open=0.90),
@@ -1781,28 +1676,28 @@ def _head(name: str, auc: float, *, readable: bool) -> dict:
@pytest.mark.parametrize(
- "candidate_heads,discuss_grade,expected_promote,reason_fragment,expected_skipped",
+ "candidate_heads,fixed_grade,expected_promote,reason_fragment,expected_skipped",
[
- # The shared holdout is too thin to read discuss on either model: no evidence, not a regression.
+ # The shared holdout is too thin to read fixed on either model: no evidence, not a regression.
(
- [_head("open", 0.70, readable=True), _head("discuss", 0.77, readable=False)],
+ [_head("open", 0.70, readable=True), _head("fixed", 0.77, readable=False)],
_grade(auc=0.70, positives=26),
True,
- "skipped: discuss",
- ("discuss",),
+ "skipped: fixed",
+ ("fixed",),
),
# A thin holdout must not hide a head the candidate lost.
- ([_head("open", 0.70, readable=True)], _grade(auc=0.70, positives=0), False, "discuss not trained", ()),
+ ([_head("open", 0.70, readable=True)], _grade(auc=0.70, positives=0), False, "fixed not trained", ()),
# Enough positives, the candidate sits inside its null and well under the champion: its numbers fail it.
(
- [_head("open", 0.70, readable=True), _head("discuss", 0.55, readable=False)],
+ [_head("open", 0.70, readable=True), _head("fixed", 0.55, readable=False)],
_grade(auc=0.70, positives=40),
False,
- "discuss regressed",
+ "fixed regressed",
(),
),
(
- [_head("open", 0.70, readable=True), _head("discuss", 0.71, readable=True)],
+ [_head("open", 0.70, readable=True), _head("fixed", 0.71, readable=True)],
_grade(auc=0.70, positives=40),
True,
"every readable head",
@@ -1812,18 +1707,18 @@ def _head(name: str, auc: float, *, readable: bool) -> dict:
ids=["thin_holdout_skipped", "head_not_trained", "unreadable_regressed", "both_readable"],
)
def test_decide_promotion_skips_heads_the_shared_holdout_cannot_read(
- candidate_heads, discuss_grade, expected_promote, reason_fragment, expected_skipped
+ candidate_heads, fixed_grade, expected_promote, reason_fragment, expected_skipped
):
candidate = {"model_version": "d2", "heads": candidate_heads}
- champion = {**_metadata("d1", open=0.70, discuss=0.70), "promoted_at": "2026-08-10T00:00:00+00:00"}
+ champion = {**_metadata("d1", open=0.70, fixed=0.70), "promoted_at": "2026-08-10T00:00:00+00:00"}
decision = decide_promotion(
candidate,
champion,
now=NOW,
min_days_between=3,
- champion_grades={"open": _grade(auc=0.70, positives=60), "discuss": discuss_grade},
- min_holdout_positives={"open": 50, "discuss": 30},
+ champion_grades={"open": _grade(auc=0.70, positives=60), "fixed": fixed_grade},
+ min_holdout_positives={"open": 50, "fixed": 30},
)
assert decision.promote is expected_promote
@@ -1877,12 +1772,12 @@ _RECENT_CHAMPION = {**_metadata("d1", open=0.70), "promoted_at": "2026-08-19T00:
"model_version": "d2",
"heads": [
_head("open", 0.70, readable=True),
- {**_head("discuss", 0.60, readable=False), "holdout_positives": 4},
+ {**_head("fixed", 0.60, readable=False), "holdout_positives": 4},
],
},
- {**_metadata("d1", open=0.70, discuss=0.70), "promoted_at": "2026-08-10T00:00:00+00:00"},
+ {**_metadata("d1", open=0.70, fixed=0.70), "promoted_at": "2026-08-10T00:00:00+00:00"},
{},
- "discuss readable on champion but not on candidate",
+ "fixed readable on champion but not on candidate",
),
],
)
@@ -1891,7 +1786,7 @@ def test_a_skipped_gate_waives_only_that_check(gate, candidate, champion, grades
"now": NOW,
"min_days_between": 3,
"champion_grades": grades,
- "min_holdout_positives": {"open": 50, "discuss": 30},
+ "min_holdout_positives": {"open": 50, "fixed": 30},
}
refused = decide_promotion(candidate, champion, **kwargs)
assert not refused.promote and expected_reason in refused.reason
@@ -2092,10 +1987,9 @@ def _booster_ubj(feature_names: tuple[str, ...]) -> bytes:
def test_an_unreadable_scored_head_is_still_graded():
- # A rare head never clears min_holdout_positives on one day's holdout, so the pooled newborn
- # grade is the only read that can ever give it a number. The grade carries the flag instead, so
- # the two populations stay apart.
- head = HEADS_BY_NAME["thumbs_up"]
+ # A head can miss min_holdout_positives on one day's holdout, and the pooled newborn grade
+ # still gives it a number. The grade carries the flag instead, so the two populations stay apart.
+ head = HEADS_BY_NAME["fixed"]
scores = _scores(
["a", "b"],
head=[head.name] * 2,
@@ -2103,7 +1997,7 @@ def test_an_unreadable_scored_head_is_still_graded():
head_readable=[False] * 2,
classification_threshold=[0.0] * 2,
)
- labels = _labels(["a", "b"], open_count=[1, 1], feedback_positive_count=[1, 0])
+ labels = _labels(["a", "b"], open_count=[1, 1], fixed_count=[1, 0])
graded = graded_rows(scores, labels, head, pool=POOL_NAME)
(grade,) = head_grades(graded, head, pool=POOL_NAME, scoring_partition="2026-08-10")
assert (grade.rows, grade.positives, grade.readable) == (2, 1, False)
diff --git a/products/signals/dags/inbox_ranking/training/heads.py b/products/signals/dags/inbox_ranking/training/heads.py
index 6fd1da39039b..0d1df719f217 100644
--- a/products/signals/dags/inbox_ranking/training/heads.py
+++ b/products/signals/dags/inbox_ranking/training/heads.py
@@ -17,10 +17,9 @@ The dataset keeps them for position bias.
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.
-Mirrors the workspace `heads.py` (random-dev-internal, `inbox-ranking/`). Nine heads are dense
-enough 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 than
-for a holdout AUC. The rest stay workspace-only.
+Only the heads the inbox reads are trained: `open`, `action` and `fixed` (`HeadRanker` in
+`products/signals/backend/ranking/inbox_sort.py`). The dataset dag still snapshots the label columns
+of other outcomes, so a head can come back without a labels backfill.
"""
from collections.abc import Callable
@@ -29,8 +28,6 @@ import pandas as pd
from posthog.dataclasses import frozen
-from products.signals.dags.inbox_ranking.common import WRONG_DISMISSAL_REASONS
-
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)
@@ -75,48 +72,10 @@ def acted(frame: pd.DataFrame) -> pd.Series:
return any_action
-def dismissed_as_wrong(frame: pd.DataFrame) -> pd.Series:
- if "wrong_dismissal_count" in frame:
- return _count(frame, "wrong_dismissal_count") > 0
- # Partitions written before the cumulative count existed carry only the latest-wins reason,
- # which a later restore or re-dismissal can overwrite.
- if "dismissal_reason" not in frame:
- return pd.Series(False, index=frame.index)
- return frame["dismissal_reason"].isin(WRONG_DISMISSAL_REASONS)
-
-
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
-
-
-def pr_merged(frame: pd.DataFrame) -> pd.Series:
- return _count(frame, "pr_merged_count") > 0
-
-
-def discussed(frame: pd.DataFrame) -> pd.Series:
- return _count(frame, "discuss_count") > 0
-
-
-def refunded(frame: pd.DataFrame) -> pd.Series:
- return _count(frame, "refund_count") > 0
-
-
-def thumbed_up(frame: pd.DataFrame) -> pd.Series:
- return _count(frame, "feedback_positive_count") > 0
-
-
-def reviewer_fixed(frame: pd.DataFrame) -> pd.Series:
- return (_count(frame, "reviewer_add_count") + _count(frame, "reviewer_remove_count")) > 0
-
-
@frozen
class Head:
name: str
@@ -127,7 +86,7 @@ class Head:
min_holdout_positives: int
# Cumulative count columns the label reads. A scoring pair whose snapshot is missing one of these
# cannot tell "outcome not yet observed" from "column absent", so the example builder skips it.
- # Empty when the label tolerates a missing column on its own (dismiss_wrong falls back to a reason).
+ # Empty when the label tolerates a missing column on its own.
label_columns: tuple[str, ...] = ()
# The label comes from the status-change stream, whose tenant provenance the dataset dag
# cross-checks; rows that fail that check are unusable for this head.
@@ -152,30 +111,6 @@ HEADS: tuple[Head, ...] = (
label_columns=ACTION_LABEL_COLUMNS,
status_labels=True,
),
- # 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=everyone,
- label=dismissed_as_wrong,
- horizon_days=21,
- min_holdout_positives=30,
- status_labels=True,
- ),
- # Which reports get a PR at all? Cohort is every report the sweep would score.
- Head(name="pr_created", cohort=everyone, label=pr_created, horizon_days=7, min_holdout_positives=30),
- # Which reports end up with a merged PR? The cohort is everyone, so the label carries the whole
- # report-to-merge path rather than conditioning on a PR that does not exist yet at birth.
- Head(
- name="pr_merged",
- cohort=everyone,
- label=pr_merged,
- horizon_days=14,
- min_holdout_positives=30,
- label_columns=("pr_merged_count",),
- ),
# 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. A one-click resolve counts after its grace window (`STATUS_SQL`). Fixes marked
@@ -190,66 +125,6 @@ HEADS: tuple[Head, ...] = (
label_columns=("fixed_count",),
status_labels=True,
),
- # 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=everyone,
- label=discussed,
- horizon_days=7,
- min_holdout_positives=30,
- label_columns=("discuss_count",),
- ),
- # Which reports led to a refund? Cohort is everyone, not pr_created: a minority of refunded reports
- # carry no pr_created event, since the refund stream is minted server-side on its own event.
- # refund_count entered the labels schema after the epoch, so pre-existing partitions lack it; the
- # label_columns guard keeps its cumulative count from leaking stale refunds as future positives.
- Head(
- name="refund",
- cohort=everyone,
- label=refunded,
- horizon_days=14,
- min_holdout_positives=20,
- label_columns=("refund_count",),
- ),
- # 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=everyone,
- label=thumbed_up,
- horizon_days=7,
- min_holdout_positives=10,
- label_columns=("feedback_positive_count",),
- ),
- # 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=everyone,
- label=reviewer_fixed,
- horizon_days=14,
- 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}
diff --git a/products/signals/dags/inbox_ranking/training/promotion.py b/products/signals/dags/inbox_ranking/training/promotion.py
index 0bb25720a1c7..ddcf986dabd8 100644
--- a/products/signals/dags/inbox_ranking/training/promotion.py
+++ b/products/signals/dags/inbox_ranking/training/promotion.py
@@ -17,7 +17,8 @@ rate, so a head without a paired error skips this check.
A paired grade also says how many positives the shared holdout holds. Below the head's
`min_holdout_positives` neither model can be read on it, so the head is skipped, not counted as a
regression. A head the candidate did not train still blocks: a candidate must not replace a champion
-by losing a head the champion serves.
+by losing a head the champion serves. A champion head that is no longer in `HEADS` is not compared:
+it was retired, so no candidate trains it.
An owner can change one family's outcome through the `promotion` override (see
`products/signals/backend/ranking/overrides.py`). `skip_gates` waives named checks inside the rule,
@@ -31,6 +32,7 @@ from typing import Any
from posthog.dataclasses import frozen
from products.signals.backend.ranking.overrides import PromotionOverride
+from products.signals.dags.inbox_ranking.training.heads import HEADS_BY_NAME
from products.signals.dags.inbox_ranking.training.train import HoldoutGrade
# A candidate may be this much worse than the champion on a readable head and still promote: at
@@ -122,6 +124,8 @@ def _compare_to_champion(
candidate_heads = {head["head"]: head for head in candidate.get("heads", [])}
skipped: list[str] = []
for head, stored_auc in _readable_aucs(champion).items():
+ if head not in HEADS_BY_NAME:
+ continue
candidate_positives = candidate_heads.get(head, {}).get("holdout_positives")
if (
"min_holdout_positives" in skip_gates
diff --git a/products/signals/frontend/inbox/filterOptions.tsx b/products/signals/frontend/inbox/filterOptions.tsx
index 4845a4d7fccc..6ddff1141cc7 100644
--- a/products/signals/frontend/inbox/filterOptions.tsx
+++ b/products/signals/frontend/inbox/filterOptions.tsx
@@ -114,7 +114,7 @@ export const INBOX_RANKING_SCORES: InboxRankingScore[] = [
name: 'Open',
sortLabel: 'Most likely to be opened',
tagLabel: 'open',
- description: 'A person opens the report within 3 days.',
+ description: 'A person opens the report within 7 days.',
},
{
field: 'ranking_action',
@@ -122,7 +122,7 @@ export const INBOX_RANKING_SCORES: InboxRankingScore[] = [
name: 'Engage',
sortLabel: 'Most likely to be acted on',
tagLabel: 'engage',
- description: 'A person acts on the report within 7 days.',
+ description: 'A person acts on the report within 14 days.',
},
{
field: 'ranking_fixed',
@@ -130,7 +130,7 @@ export const INBOX_RANKING_SCORES: InboxRankingScore[] = [
name: 'Fix',
sortLabel: 'Most likely to be fixed',
tagLabel: 'fix',
- description: 'Someone fixes the problem within 21 days.',
+ description: 'Someone fixes the problem within 30 days.',
},
]