: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): retire the tabular_xgb inbox ranking family (#112393)
posthog[bot]c2c6162ca5d2
diff --git a/docs/internal/inbox-ranking-training.md b/docs/internal/inbox-ranking-training.mdindex 7ee67f420d7e..49aadda68de6 100644--- a/docs/internal/inbox-ranking-training.md+++ b/docs/internal/inbox-ranking-training.md@@ -1,6 +1,6 @@# Inbox ranking training examples-The tabular, report-embedding and title-embedding ranking families use one example per report per head, from the report's birth-day snapshot.+The report-embedding and title-embedding ranking families use one example per report per head, from the report's birth-day snapshot.This prevents long-lived reports from receiving more weight in training because they appear in more daily snapshots.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.@@ -46,7 +46,7 @@ Each head in `metadata.json` records `cohort` (`everyone`) and `horizon_days`.## Row budgetA feature set can limit the rows one head keeps (`max_examples_per_head`).-The embedding families set it to 100,000; the tabular family has no budget.+The embedding families set it to 100,000.The budget limits history, not the rows inside a day:- The head's examples are grouped by report-creation day, newest first.diff --git a/products/signals/backend/ranking/features.py b/products/signals/backend/ranking/features.pyindex 64ab87529b1c..cd89f32ab8e4 100644--- a/products/signals/backend/ranking/features.py+++ b/products/signals/backend/ranking/features.py@@ -6,66 +6,23 @@ matrix. A model records the set it was fit on in its `metadata.json`, so a run csets at once: the examples Parquet, the training matrix and the scoring matrix are all built perset, and a model whose declared set this build cannot produce is left unscored.-The tabular set is the first one. Training (`products/signals/dags/inbox_ranking/training/`) and-serving (the scoring sweep in this package) must build features through the same code, so the-booster's `feature_names` match the serving matrix by construction. The sweep reads the tabular-contract directly as FEATURE_NAMES / `feature_vector` / FEATURE_SCHEMA_VERSION.--The tabular set is: the report-state columns the dataset dag snapshots from Postgres plus the-report's age at the scoring moment. No report embedding and no impression-derived columns-(`source_products`), so the sweep needs nothing beyond the SignalReport row and its latest-judgment artefacts. The two embedding sets are the report's combined-text vector and its title-only-vector, one rendering each, and the sweep serves neither: they are offline candidates graded on the-unseen read, and serving one needs its vector at scoring time (skill issue 14).+The two sets are the report's combined-text embedding vector and its title-only vector, one+rendering each. They are the served contract: training (`products/signals/dags/inbox_ranking/training/`)+and serving (the scoring sweep in this package) build features through the same `build_matrix`, so+the booster's `feature_names` match the serving matrix by construction. The sweep reads each+vector at scoring time and needs nothing else from the report."""import abc-import mathimport datetimefrom collections.abc import Mappingfrom types import MappingProxyType-from typing import Anyimport numpy as npimport pandas as pd-FEATURE_SCHEMA_VERSION = 1--PRIORITY_VALUES = ("P0", "P1", "P2", "P3", "P4")-ACTIONABILITY_VALUES = ("immediately_actionable", "requires_human_input", "not_actionable")--NUMERIC_FEATURES = (- "signal_count",- "total_weight",- "run_count",- "title_chars",- "summary_chars",- "age_hours",-)--FEATURE_NAMES: tuple[str, ...] = (- *NUMERIC_FEATURES,- "priority_known",- *(f"priority_{value}" for value in PRIORITY_VALUES),- "actionability_known",- *(f"actionability_{value}" for value in ACTIONABILITY_VALUES),-)--# The report-state columns `feature_frame` reads. `age_hours` is not one of them: it is the-# report's age at the scoring moment, derived from the snapshot's own clock, and the caller adds-# it to the rows of every set.-TABULAR_STATE_COLUMNS: tuple[str, ...] = (- "signal_count",- "total_weight",- "run_count",- "title_chars",- "summary_chars",- "priority",- "actionability",-)-# Side inputs a set may read next to the report-state rows, keyed by name and indexed by-# report_id. The tabular set needs none.+# report_id.Extras = Mapping[str, pd.DataFrame]NO_EXTRAS: Extras = MappingProxyType({})@@ -93,56 +50,6 @@ SCORING_MOMENT_GRAIN = "scoring_moment"REPORT_GRAIN = "report"-def _number(value: Any) -> float:- if value is None:- return math.nan- try:- number = float(value)- except (TypeError, ValueError):- return math.nan- return number if math.isfinite(number) else math.nan---def feature_vector(row: Mapping[str, Any]) -> list[float]:- """The feature vector for one scoring moment, in FEATURE_NAMES order.-- `row` carries the report-state columns (`signal_count`, `total_weight`, `run_count`,- `title_chars`, `summary_chars`, `priority`, `actionability`) and `age_hours`, the report's age- at the moment being scored. Missing numerics become NaN (XGBoost learns a default direction);- missing categoricals set the `*_known` flag to 0 with every one-hot at 0.- """- values = [_number(row.get(name)) for name in NUMERIC_FEATURES]- priority = row.get("priority")- values.append(1.0 if priority in PRIORITY_VALUES else 0.0)- values.extend(1.0 if priority == value else 0.0 for value in PRIORITY_VALUES)- actionability = row.get("actionability")- values.append(1.0 if actionability in ACTIONABILITY_VALUES else 0.0)- values.extend(1.0 if actionability == value else 0.0 for value in ACTIONABILITY_VALUES)- return values---def feature_frame(rows: pd.DataFrame) -> pd.DataFrame:- """Vectorized `feature_vector` over a frame of report-state rows, columns in FEATURE_NAMES order.-- Must agree with `feature_vector` row for row (a test pins it): training builds matrices here,- the sweep scores one report at a time through `feature_vector`.- """- out = pd.DataFrame(index=rows.index)- for name in NUMERIC_FEATURES:- out[name] = pd.to_numeric(rows[name], errors="coerce").astype(float) if name in rows else math.nan- priority = rows["priority"] if "priority" in rows else pd.Series(None, index=rows.index, dtype=object)- out["priority_known"] = priority.isin(PRIORITY_VALUES).astype(float)- for value in PRIORITY_VALUES:- out[f"priority_{value}"] = (priority == value).astype(float)- actionability = (- rows["actionability"] if "actionability" in rows else pd.Series(None, index=rows.index, dtype=object)- )- out["actionability_known"] = actionability.isin(ACTIONABILITY_VALUES).astype(float)- for value in ACTIONABILITY_VALUES:- out[f"actionability_{value}"] = (actionability == value).astype(float)- return out[list(FEATURE_NAMES)]--class FeatureSet(abc.ABC):"""One feature universe a model can be fit on and scored with.@@ -191,24 +98,6 @@ class FeatureSet(abc.ABC):return tuple(key for key in self.extras_keys if key not in extras)-class TabularFeatureSet(FeatureSet):- """The v0 set: the report-state counters, the title and summary lengths, the report's age, and- the one-hot priority and actionability. This is the set `feature_vector` serves."""-- name = "tabular"- schema_version = FEATURE_SCHEMA_VERSION- feature_names = FEATURE_NAMES- state_columns = TABULAR_STATE_COLUMNS-- def build_matrix(- self, rows: pd.DataFrame, extras: Extras = NO_EXTRAS, *, as_of: datetime.datetime | None = None- ) -> pd.DataFrame:- return feature_frame(rows)---TABULAR_FEATURE_SET = TabularFeatureSet()--class ReportEmbeddingsFeatureSet(FeatureSet):"""One text rendering's embedding vector, and nothing else, at one example per report.@@ -229,7 +118,7 @@ class ReportEmbeddingsFeatureSet(FeatureSet):times 1536 floats, is gigabytes of Parquet per partition and more than the training pod holds,which is what rules the moment grain out at this width. The default birth grain gives that.`max_examples_per_head` bounds what is left by dropping the oldest report-creation days; the- lookback stays the tabular set's, so positives accrue over the whole window until the budget binds.+ lookback stays the training job's, so positives accrue over the whole window until the budget binds.Vectors arrive through `extras`, from the rendering's own dt=D snapshot, which holds thelatest vector per report. A report is re-embedded whenever its text changes, and the@@ -314,17 +203,12 @@ TITLE_EMBEDDINGS_FEATURE_SET = ReportEmbeddingsFeatureSet(name="title_embeddings# scored, the same way a model whose feature names have moved on cannot.FEATURE_SETS: Mapping[str, FeatureSet] = MappingProxyType({- TABULAR_FEATURE_SET.name: TABULAR_FEATURE_SET,REPORT_EMBEDDINGS_FEATURE_SET.name: REPORT_EMBEDDINGS_FEATURE_SET,TITLE_EMBEDDINGS_FEATURE_SET.name: TITLE_EMBEDDINGS_FEATURE_SET,})-# What a model written before `feature_set` was recorded was fit on: every one of those is tabular.-DEFAULT_FEATURE_SET = TABULAR_FEATURE_SET-def feature_set_by_name(name: str | None) -> FeatureSet | None:- """The named set, the tabular default when the name is absent, or None when this build cannot- produce it."""- return DEFAULT_FEATURE_SET if name is None else FEATURE_SETS.get(name)+ """The named set, or None when the name is absent or this build cannot produce it."""+ return None if name is None else FEATURE_SETS.get(name)diff --git a/products/signals/backend/ranking/model_contract.py b/products/signals/backend/ranking/model_contract.pyindex a7807d591667..28520ad380e7 100644--- a/products/signals/backend/ranking/model_contract.py+++ b/products/signals/backend/ranking/model_contract.py@@ -14,7 +14,7 @@ from products.signals.backend.ranking.features import FeatureSet, feature_set_bydef model_feature_set(metadata: Mapping[str, Any]) -> FeatureSet | None:"""The feature set the model declares, or None when this build cannot produce it. Metadata- written before the field existed declares nothing and reads as the tabular set."""+ that declares no set is left unscored."""return feature_set_by_name(metadata.get("feature_set"))@@ -22,7 +22,7 @@ def model_mismatch(metadata: Mapping[str, Any]) -> str | None:"""Why the model cannot be scored, or None when it can.A model is checked against its own declared set rather than one global contract, so a family- on a richer set is not rejected for disagreeing with the tabular one.+ on one set is not rejected for disagreeing with another set."""feature_set = model_feature_set(metadata)if feature_set is None:diff --git a/products/signals/backend/test/test_ranking_scoring.py b/products/signals/backend/test/test_ranking_scoring.pyindex 7d3d6d913a11..08eb24bed1bd 100644--- a/products/signals/backend/test/test_ranking_scoring.py+++ b/products/signals/backend/test/test_ranking_scoring.py@@ -24,7 +24,6 @@ from products.signals.backend.ranking.features import (EMBEDDING_DIMENSIONS,REPORT_EMBEDDINGS_EXTRA,REPORT_EMBEDDINGS_FEATURE_SET,- TABULAR_FEATURE_SET,TITLE_EMBEDDINGS_FEATURE_SET,FeatureSet,)@@ -175,7 +174,7 @@ class TestModelStore(_StoreTestMixin, SimpleTestCase):@parameterized.expand([- ("booster_on_other_features", {"booster_feature_names": TABULAR_FEATURE_SET.feature_names}, "booster"),+ ("booster_on_other_features", {"booster_feature_names": ("age_hours",)}, "booster"),("missing_head_file", {"missing_heads": ["thumbs_up"]}, "thumbs_up.ubj"),("unknown_model_kind", {"model_kind": "torch"}, "torch"),]@@ -187,7 +186,7 @@ class TestModelStore(_StoreTestMixin, SimpleTestCase):@parameterized.expand([- ("booster_on_other_features", {"booster_feature_names": TABULAR_FEATURE_SET.feature_names}, "booster"),+ ("booster_on_other_features", {"booster_feature_names": ("age_hours",)}, "booster"),("missing_head_file", {"missing_heads": ["thumbs_up"]}, "thumbs_up.ubj"),("unknown_model_kind", {"model_kind": "torch"}, "torch"),]@@ -387,11 +386,10 @@ class TestScorer(_ScorerTestMixin, SimpleTestCase):assert sorted(fake_vectors.calls) == sorted([EMBEDDING_RENDERING_TITLE_SUMMARY, EMBEDDING_RENDERING_TITLE])- def test_challengers_without_a_vector_or_a_served_feature_set_are_skipped_results(self) -> None:+ def test_a_challenger_without_a_vector_is_a_skipped_result(self) -> None:served = self._served(thresholds={"open": 0.25})title = self._challenger("title_embeddings", TITLE_EMBEDDINGS_FEATURE_SET)- tabular = self._challenger("tabular_xgb", TABULAR_FEATURE_SET)- manifest = self.store.publish_manifest([served, title, tabular])+ manifest = self.store.publish_manifest([served, title])(outcome,), _, captured = self._score(["r1"],@@ -406,10 +404,6 @@ class TestScorer(_ScorerTestMixin, SimpleTestCase):assert results[served.key].lifts == {"open": results[served.key].scores["open"] / 0.25}assert results[title.key].lifts == {}assert (results[title.key].status, results[title.key].skip_reason) == ("skipped", NO_VECTOR)- assert (results[tabular.key].status, results[tabular.key].skip_reason) == (- "skipped",- "feature set tabular is not served yet",- )assert outcome.score.served_key == manifest.served.keyassert outcome.score.embedding_inserted_at == LANDEDassert captured.events == []diff --git a/products/signals/dags/inbox_ranking/AGENTS.md b/products/signals/dags/inbox_ranking/AGENTS.mdindex 2c167cf3bdf1..56570cf61955 100644--- a/products/signals/dags/inbox_ranking/AGENTS.md+++ b/products/signals/dags/inbox_ranking/AGENTS.md@@ -10,13 +10,13 @@ Read `README.md` first for what the dataset is and how partitions behave. This f## Training dag specifics-- `products/signals/backend/ranking/features.py` holds a `FeatureSet` per feature universe (it lives in the backend so the scoring sweep owns it and the dag imports it). The tabular set is also the serving contract the sweep reads as `FEATURE_NAMES` / `feature_vector`, and the sweep refuses a booster whose `feature_names` or `feature_schema_version` disagree. Adding a tabular feature means bumping `FEATURE_SCHEMA_VERSION`, and the sweep must be able to compute it from the `SignalReport` row at scoring time — nothing impression-derived, nothing that needs the label streams.+- `products/signals/backend/ranking/features.py` holds a `FeatureSet` per feature universe (it lives in the backend so the scoring sweep owns it and the dag imports it). The embedding sets are also the serving contract: the sweep builds each model's matrix through the set's own `build_matrix`, and refuses a booster whose `feature_names` or `feature_schema_version` disagree with its set. A change to a set's features means bumping that set's `schema_version`, and the sweep must be able to compute it at scoring time — nothing impression-derived, nothing that needs the label streams.- A model declares its feature set in `metadata.json` and is checked against that set, not against one global contract. Adding a set means an entry in `FEATURE_SETS`; the examples asset then writes its Parquet under `inbox_ranking_training_examples/v1/<feature_set>/dt=D/`, and the unseen scorer builds one matrix per set and shares it across the families that read it. Do not reintroduce a module-global feature list into the training path: three sets live side by side. A partition whose examples were written before the per-set layout has nothing under `<feature_set>/`, so re-run the examples asset for that day before re-running the candidate or the unseen scores on it.- A set that reads a side input declares it in `extras_keys`, and reports per-row availability through `buildable`. The example builder drops the rows `buildable` returns False for. The scorer deliberately does not drop rows: every family scores the whole newborn pool, or the AUCs stop being paired and the uplift read the families exist for is unmeasurable. Watch `<set>_pool_coverage` on the scores asset instead.- The two embedding sets are one `ReportEmbeddingsFeatureSet` parameterized by the `extras` key it reads, one rendering each. A set reads its own key only: never add a fallback to the other rendering's vector, and keep width, grain, row budget and booster params identical across the pair, or the paired AUC difference stops measuring the text choice. `embeddings_extras` loads one set's inputs at a time and the scores asset narrows each snapshot to the newborn pool, because a snapshot carries a vector per live report; keep both, so a further embedding family costs runtime rather than peak memory.- A **missing** side-input object leaves its key out, so only the sets reading it are skipped and their partitions stay as they are. An **empty** object keeps its key and takes the ordinary thin-input path. Do not collapse the two: the first must not write over a partition, and the second is a day the family really has nothing to fit.- Both `buildable` and `build_matrix` take the moment being built as `as_of`, and a side input that changes over a report's life must honor it. The report vector does: reports are re-embedded when their text changes, so the snapshot's latest vector often postdates the moment, and taking it would train on text that did not exist yet. Never widen a set's side input to the latest value for convenience.-- `example_grain` and `max_examples_per_head` are per set, because the examples object is. Every set defaults to the birth grain so the families target the same scoring moment; side-input availability and row budgets can still change their training populations. Keep the tabular set with no budget: `report_embeddings` is the reason the budget exists (1536 columns per row), and a budget on the tabular set would thin the family the other lines are measured against. A budget limits history and never samples inside a day: `cap_examples` keeps whole report-creation days, newest first, so the kept label rate stays the population rate and the scores stay calibrated. Never reintroduce a positive-keeping sample: it raises the base rate the booster fits, and a holdout cut from the same sample hides it.+- `example_grain` and `max_examples_per_head` are per set, because the examples object is. Every set defaults to the birth grain so the families target the same scoring moment; side-input availability and row budgets can still change their training populations. `report_embeddings` is the reason the budget exists (1536 columns per row). Keep the two embedding sets on one budget, so their grades measure the text choice and not the row count. A budget limits history and never samples inside a day: `cap_examples` keeps whole report-creation days, newest first, so the kept label rate stays the population rate and the scores stay calibrated. Never reintroduce a positive-keeping sample: it raises the base rate the booster fits, and a holdout cut from the same sample hides it.- `feature_vector` (one row, serving) and `feature_frame` (vectorized, training) must agree row for row; a test pins it. Change both together.- Examples are one row per report, on the snapshot of the day it was created, labeled from the snapshot `horizon_days` later. The scoring-moment and report grains stay selectable for re-scoring families, so keep the holdout cut by report: a row-level split leaks near-duplicate snapshots of the same report the moment a set asks for one of them. The moments are chosen before the features are built, so a set under a row budget never builds columns for rows it then drops; keep that order.- `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.diff --git a/products/signals/dags/inbox_ranking/README.md b/products/signals/dags/inbox_ranking/README.mdindex 720841bdc375..022e3d260ed3 100644--- a/products/signals/dags/inbox_ranking/README.md+++ b/products/signals/dags/inbox_ranking/README.md@@ -30,7 +30,7 @@ Registered via `posthog/dags/locations/signals.py` (US only) and loaded locally```texts3://<bucket>/<prefix>/-├── inbox_report_state/v1/dt=YYYY-MM-DD/ # Postgres spine + report state + tabular features+├── inbox_report_state/v1/dt=YYYY-MM-DD/ # Postgres spine + report-state columns├── inbox_report_embeddings/v1/dt=YYYY-MM-DD/ # report_id -> small-1536 vector as of snapshot end├── inbox_report_labels/v1/dt=YYYY-MM-DD/ # cumulative label columns from dogfood telemetry├── inbox_report_model_data/v1/@@ -81,13 +81,13 @@ s3://<bucket>/<prefix>/└── inbox_ranking_unseen_scores/v1/dt=YYYY-MM-DD/ # the day's models on the reports born that day```-- **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.+- **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. `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 second family is a second candidate graded on the same unseen 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.- **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.-- **`tabular` is the serving set** (the state counters, title/summary length, age, one-hot priority/actionability). No embedding, no impression-derived columns, so the scoring sweep needs only the `SignalReport` row and its judgment artefacts. The sweep must build features through the same module; the booster's `feature_names` are checked against it at load.+- **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.- **`title_embeddings` is the same set over the title-only vector**, read from the dt=D `inbox_report_title_embeddings` snapshot, a separate leaf partition with its own `embedding_inserted_at`. One `ReportEmbeddingsFeatureSet` class parameterized by the input it reads, so the two renderings share this width, this grain, this row budget and the trainer's booster params by construction: the pair measures the text choice, and a recipe that drifted on one side would read as a text effect. A set reads its own input only and never falls back to the other rendering's vector, so a report present in one snapshot and absent from the other is an example for one family and not the other. The inbox title is what a person reads before opening a report and the summary is read after, which is the question the pair answers: whether the summary carries `open` signal or only post-open signal.- **A moment only takes a vector that already existed for it.** The snapshot holds the latest vector per report, and a report is re-embedded whenever its text changes (the summary workflow and every re-research run rewrite it), so the latest vector often postdates an earlier moment. Each row carries `embedding_inserted_at`, and a moment keeps the vector only when it landed at or before that snapshot's end; at the birth grain a report whose birth-day snapshot holds only a later vector is no example, and at the report grain it moves to the first snapshot where the vector was already its own. Without that check the family would train on text that did not exist when the report was supposedly scored. A report the snapshot has no vector for at all is not an example either, because the source table's TTL runs from report creation and a long-lived report loses its vector while still live. The scores asset records each set's coverage of the newborn pool, so a thin side input is visible rather than silent.@@ -110,7 +110,7 @@ The manifest holds one entry per model with its `roles`: `served` for the champiA region that does not train serves the same models through a mirror. When `INBOX_RANKING_SERVING_MIRROR_BUCKET` is set, the asset repeats the publish into that bucket after the primary publish succeeds, in the same order and with the same skip of versions already there. A mirror failure does not fail the asset: it logs, and the `inbox_ranking_serving_manifest_published` event carries `mirror_published=false`. The property is absent when no mirror is set.-The reader is `score_reports` in `products/signals/backend/ranking/scorer.py`. It loads every model the manifest names through `model_store.py`, reads each report's latest vector once per rendering, builds each model's matrix with its own `FeatureSet.build_matrix`, and writes one `ranking_score` artefact per report plus one `inbox_ranking_report_scored` event per report and model. The dag and the reader decide whether a model can be scored with the same functions, in `products/signals/backend/ranking/model_contract.py`. A served model that cannot load stops the pass. Any other model that cannot load, or has no vector for a report, is a `skipped` result. The embedding families are the only ones served, so a tabular entry is a `skipped` result too. No scheduled caller runs the reader yet.+The reader is `score_reports` in `products/signals/backend/ranking/scorer.py`. It loads every model the manifest names through `model_store.py`, reads each report's latest vector once per rendering, builds each model's matrix with its own `FeatureSet.build_matrix`, and writes one `ranking_score` artefact per report plus one `inbox_ranking_report_scored` event per report and model. The dag and the reader decide whether a model can be scored with the same functions, in `products/signals/backend/ranking/model_contract.py`. A served model that cannot load stops the pass. Any other model that cannot load, or has no vector for a report, is a `skipped` result. No scheduled caller runs the reader yet.### Overrides@@ -144,7 +144,7 @@ Every key is optional, but no key applies without `expires_at`:The worst result of a bad payload is a warning, never a stopped pass or an unpublished manifest:-- A `served` key that is not in the manifest, that did not load (missing files, a feature contract mismatch, an untrained head), that has fewer heads than the manifest's served model, or that the sweep cannot serve (a tabular model) is rejected. The sweep logs `inbox_ranking_override_rejected` and scores with the manifest's served model. The override only moves the `served` role among models the pods already load, so it never adds memory.+- A `served` key that is not in the manifest, that did not load (missing files, a feature contract mismatch, an untrained head), that has fewer heads than the manifest's served model is rejected. The sweep logs `inbox_ranking_override_rejected` and scores with the manifest's served model. The override only moves the `served` role among models the pods already load, so it never adds memory.- A pinned key whose `metadata.json` or boosters are missing in the dataset bucket, or that fails `model_mismatch`, is dropped before composition. The manifest still publishes, and the asset metadata lists `pinned_keys` and `dropped_pins` with reasons.During a `served` override, the override model carries the roles `served` and `served_override`, and the manifest's served model carries `manifest_served` in place of `served`. The sweep compares the served key on the latest `ranking_score` with the effective one, so setting or removing an override rescores every report in the window. The `inbox_ranking_sweep_finished` log and each `inbox_ranking_report_scored` event carry `override_served` and `override_expires_at`. The `inbox_ranking_promotion_decided` event carries `override` (`frozen`, `forced`, `skipped_gates` or null) and `override_skipped_gates`, next to the `reason` the rule gave, so a forced promotion still records why the rule refused it.@@ -192,7 +192,7 @@ See [training example semantics](../../../../docs/internal/inbox-ranking-traininThe 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, an offline batch proxy for performance on reports the model never saw.-- **`inbox_ranking_unseen_scores` (dt=D)** takes the dt=D state rows of the reports **created on D**, the pool the events 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: leakage-freedom is structural, not a property of what the example builder did that day. The set difference against the examples Parquet stays as a runtime guard — a non-empty overlap fails the asset instead of publishing the number. Every newborn is scored, not a sample, with the day's candidate and, when the pointer names a different version, the champion. Every head the candidate fit is scored, readable or not, because the pooled grade over many days is the only read a rare head can ever get; each scored row carries `head_readable`, the readability of that head on the model that wrote it, so the grade can keep the two populations apart. A model whose feature contract has moved on is logged and left out. Every family scores the whole pool, including reports whose side input has no row for them, because grades are only comparable on paired rows; the `<set>_pool_coverage` metadata says how much of the pool each set could build a real vector for. One Parquet row per (report, model, 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; an older pool's rows are still dropped on it, and so are a status-label head's rows in every pool, because no scores column carries the scoring-day `label_provenance_ok` that the example builder checks), `model_name`, and `pool`, the pool definition that produced the row. A re-run that scores nothing is refused when the partition already holds rows, so a day with no loadable model cannot erase the scores a later grade reads; one object holds every family, so a re-run that scored fewer families than the object already holds is refused too, and names them. A scores object written before `model_name` existed reads as `tabular_xgb`, the same way one written before `pool` existed keeps the old pool name.+- **`inbox_ranking_unseen_scores` (dt=D)** takes the dt=D state rows of the reports **created on D**, the pool the events 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: leakage-freedom is structural, not a property of what the example builder did that day. The set difference against the examples Parquet stays as a runtime guard — a non-empty overlap fails the asset instead of publishing the number. Every newborn is scored, not a sample, with the day's candidate and, when the pointer names a different version, the champion. Every head the candidate fit is scored, readable or not, because the pooled grade over many days is the only read a rare head can ever get; each scored row carries `head_readable`, the readability of that head on the model that wrote it, so the grade can keep the two populations apart. A model whose feature contract has moved on is logged and left out. Every family scores the whole pool, including reports whose side input has no row for them, because grades are only comparable on paired rows; the `<set>_pool_coverage` metadata says how much of the pool each set could build a real vector for. One Parquet row per (report, model, 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; an older pool's rows are still dropped on it, and so are a status-label head's rows in every pool, because no scores column carries the scoring-day `label_provenance_ok` that the example builder checks), `model_name`, and `pool`, the pool definition that produced the row. A re-run that scores nothing is refused when the partition already holds rows, so a day with no loadable model cannot erase the scores a later grade reads; one object holds every family, so a re-run that scored fewer families than the object already holds is refused too, and names them. Rows of a retired family (`RETIRED_MODEL_NAMES`) are dropped on read, and so are the rows of a scores object written before `model_name` existed, which all belong to one. The grader logs how many it drops, the shadow read does not grade them, and the rewrite guard does not require them, because no re-run can produce 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, 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. That read spans the whole pool, the reports whose side input has no row for them included, and the examples drop those rows, so on a thin `<set>_pool_coverage` day the unseen error carries a population the holdout error cannot: read the two per family.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.@@ -206,11 +206,11 @@ The `title_embeddings` and `report_embeddings` families are trained and graded t- **Pair the rows, then take the difference.** Both families score every newborn, so for one head and one day they are graded on the same reports. Break the unseen grade down by `model_name` and difference the two AUCs on the rows both grades had. An unpaired difference of two full-population AUCs is not this comparison: keep each family's full-population number, and the matched one, as separate figures.- **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.** `<set>_pool_coverage` on the scores asset says how much of the pool a rendering had a vector for, 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.** `tabular_xgb` and `recency_auc` are reported on the same grade, so the reading is title against combined against tabular against newest-first, not against numbers from another day.+- **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.- **This is not an online test.** Every row is a birth-day snapshot 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 offline 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 loads the tabular family's pointer, 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.+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.### Running the training job locally@@ -238,11 +238,11 @@ The training job is S3-only, so it can run on a laptop against copies of the proThe schedule is stopped outside prod US, so nothing runs unasked. If the run sits in `QUEUED`, check the daemon log for `Maximum is 10, won't launch more`: runs from a killed `dagster dev` stay `STARTED` forever and count against the local queue. Terminate them from the Runs page (force termination).-4. Read the result from `s3://posthog/inbox_ranking/inbox_ranking_models/v1/tabular_xgb/dt=<day>/metadata.json` (per-head AUCs, readability); the examples are at `s3://posthog/inbox_ranking/inbox_ranking_training_examples/v1/tabular/dt=<day>/part-00000.parquet`:+4. Read the result from `s3://posthog/inbox_ranking/inbox_ranking_models/v1/report_embeddings/dt=<day>/metadata.json` (per-head AUCs, readability); the examples are at `s3://posthog/inbox_ranking/inbox_ranking_training_examples/v1/report_embeddings/dt=<day>/part-00000.parquet`:```bashAWS_ACCESS_KEY_ID=object_storage_root_user AWS_SECRET_ACCESS_KEY=object_storage_root_password \- aws --endpoint-url http://localhost:19000 s3 cp s3://posthog/inbox_ranking/inbox_ranking_models/v1/tabular_xgb/dt=2026-08-25/metadata.json -+ aws --endpoint-url http://localhost:19000 s3 cp s3://posthog/inbox_ranking/inbox_ranking_models/v1/report_embeddings/dt=2026-08-25/metadata.json -```Nothing here touches the prod bucket: the reader credential is read-only and the dag writes only to the local bucket.diff --git a/products/signals/dags/inbox_ranking/dataset/dag.py b/products/signals/dags/inbox_ranking/dataset/dag.pyindex cc0bb0ac5f4f..1eca4970fb0b 100644--- a/products/signals/dags/inbox_ranking/dataset/dag.py+++ b/products/signals/dags/inbox_ranking/dataset/dag.py@@ -2,7 +2,7 @@Six assets on one daily partition, each writing Parquet under the configured S3 prefix:- inbox_report_state/v1/dt=D/ Postgres spine + report state + tabular features+ inbox_report_state/v1/dt=D/ Postgres spine + report-state columnsinbox_report_embeddings/v1/dt=D/ report_id -> small-1536 vector as of snapshot endinbox_report_labels/v1/dt=D/ cumulative label columns from the dogfood project's eventsinbox_report_model_data/v1/dt=D/ materialized join of the three, plus a rewritten latest/diff --git a/products/signals/dags/inbox_ranking/shadow/dag.py b/products/signals/dags/inbox_ranking/shadow/dag.pyindex 518fa36b1ee7..81b9c94eae1b 100644--- a/products/signals/dags/inbox_ranking/shadow/dag.py+++ b/products/signals/dags/inbox_ranking/shadow/dag.py@@ -163,7 +163,7 @@ def load_scores(client, bucket: str, prefix: str, dates: list[datetime.date]) ->for date in dates:key = date.isoformat()# Read whole rather than by column list: an object written before `model_name` existed- # has no such column, and `with_model_names` is what fills it in.+ # has no such column, and `with_model_names` drops its rows.try:response = client.get_object(Bucket=bucket, Key=partition_object_key(prefix, UNSEEN_SCORES_TABLE, key))except ClientError as error:diff --git a/products/signals/dags/inbox_ranking/tests/test_shadow.py b/products/signals/dags/inbox_ranking/tests/test_shadow.pyindex 1880a24291fb..6681cc818a2f 100644--- a/products/signals/dags/inbox_ranking/tests/test_shadow.py+++ b/products/signals/dags/inbox_ranking/tests/test_shadow.py@@ -93,7 +93,7 @@ def _scores(report_ids: list[str], scores: list[float], *, snapshot_date: dateti{"report_id": report_ids,"snapshot_date": snapshot_date,- "model_name": "tabular_xgb",+ "model_name": "report_embeddings","model_version": snapshot_date.isoformat(),"model_role": "champion","head": head,@@ -256,7 +256,7 @@ def test_the_model_order_is_graded_against_the_served_order_and_chance():served = _lists(_served("first", [UUID_A, UUID_B, UUID_B + "-c", UUID_B + "-d"])).assign(outcome_open=[False, False, False, True], outcome_action=False)- joined = _joined(served, model_name="tabular_xgb", model_version="2026-09-09", score=[0.1, 0.2, 0.3, 0.9])+ joined = _joined(served, model_name="report_embeddings", model_version="2026-09-09", score=[0.1, 0.2, 0.3, 0.9])grades = _by_order(grade_lists(joined, served=served))ndcg_5 = {order: grade.ndcg_5 or 0.0 for order, grade in grades.items()}@@ -281,7 +281,7 @@ def test_a_grade_carries_its_own_score_coverage_not_the_run_s():served = _lists(_served("first", [UUID_A, UUID_B, UUID_B + "-c", UUID_B + "-d"])).assign(outcome_open=[True, False, False, False], outcome_action=[True, False, False, False])- scored = {"model_name": "tabular_xgb", "model_version": "2026-09-09", "score": 0.5}+ scored = {"model_name": "report_embeddings", "model_version": "2026-09-09", "score": 0.5}joined = pd.concat([_joined(served, head="open", **scored), _joined(served.head(2), head="action", **scored)],ignore_index=True,@@ -302,7 +302,7 @@ def test_the_chance_line_does_not_move_when_the_rows_arrive_in_another_order():served = _lists(_served("first", [UUID_A, UUID_B, UUID_B + "-c", UUID_B + "-d"])).assign(outcome_open=[False, True, False, True], outcome_action=False)- joined = _joined(served, model_name="tabular_xgb", model_version="2026-09-09", score=[0.1, 0.2, 0.3, 0.9])+ joined = _joined(served, model_name="report_embeddings", model_version="2026-09-09", score=[0.1, 0.2, 0.3, 0.9])def chance(frame: pd.DataFrame) -> tuple:grade = _by_order(grade_lists(frame, served=served))[RANDOM_ORDER]@@ -387,7 +387,7 @@ def test_a_grade_carries_the_versions_that_scored_the_day():)joined = _joined(served,- model_name="tabular_xgb",+ model_name="report_embeddings",model_version=["2026-09-01", "2026-09-02", "2026-09-01", "2026-09-02"],score=0.5,)@@ -518,9 +518,9 @@ def test_the_score_window_reaches_the_partition_day_a_birth_day_score_lands_in()assert len(dates) == len(set(dates)) == settings.INBOX_RANKING_SHADOW_SCORE_LOOKBACK_DAYS + 1-def test_load_scores_reads_the_window_and_names_the_family_of_older_objects():+def test_load_scores_reads_the_window_and_drops_rows_that_name_no_family():old_day, new_day = DAY - datetime.timedelta(days=2), DAY - datetime.timedelta(days=1)- # An object written before `model_name` existed holds tabular rows and must not read as null.+ # An object written before `model_name` existed holds a retired family's rows, which must not read as null.legacy = _scores([UUID_A], [0.3], snapshot_date=old_day).drop(columns=["model_name", "available_at"])recent = pd.concat([@@ -538,10 +538,10 @@ def test_load_scores_reads_the_window_and_names_the_family_of_older_objects():scores = load_scores(client, "bucket", "inbox_ranking", [old_day, new_day, DAY])- assert scores["model_name"].tolist() == ["tabular_xgb", "tabular_xgb"]+ assert scores["model_name"].tolist() == ["report_embeddings"]# Only the heads this read grades, and each one stamped with when it became servable.- assert scores["head"].tolist() == ["open", "open"]- assert scores["available_at"].tolist() == [SERVED_AT + datetime.timedelta(hours=1)] * 2+ assert scores["head"].tolist() == ["open"]+ assert scores["available_at"].tolist() == [SERVED_AT + datetime.timedelta(hours=1)]joined = join_scores(_lists(_served("first", [UUID_A, UUID_B])), scores)assert joined["score"].isna().all()@@ -575,7 +575,7 @@ def test_a_day_that_graded_nothing_still_reports_a_run():# A day whose lists had no score available at impression time grades nothing, and without a# run event that is byte-identical to a run that crashed before capturing anything.served = _lists(_served("first", [UUID_A, UUID_B])).assign(outcome_open=[True, False], outcome_action=False)- joined = _joined(served, model_name="tabular_xgb", model_version="2026-09-09", score=[0.9, 0.1])+ joined = _joined(served, model_name="report_embeddings", model_version="2026-09-09", score=[0.9, 0.1])empty = shadow_grade_events(run_id="run-1", served_rows=12, served_lists=3, run_score_coverage=0.0, grades=[])graded = shadow_grade_events(@@ -614,7 +614,7 @@ def test_grade_rows_match_the_parquet_schema_exactly():# pa.Table.from_pylist drops keys the schema does not name, so a grade field added without a# column would vanish from the object without failing anything.served = _lists(_served("first", [UUID_A, UUID_B])).assign(outcome_open=[True, False], outcome_action=False)- joined = _joined(served, model_name="tabular_xgb", model_version="2026-09-09", score=[0.9, 0.1])+ joined = _joined(served, model_name="report_embeddings", model_version="2026-09-09", score=[0.9, 0.1])graded = grade_rows(grade_lists(joined, served=served),partition_key=DAY.isoformat(),diff --git a/products/signals/dags/inbox_ranking/tests/test_training.py b/products/signals/dags/inbox_ranking/tests/test_training.pyindex 1e41467376b2..1478b9228243 100644--- a/products/signals/dags/inbox_ranking/tests/test_training.py+++ b/products/signals/dags/inbox_ranking/tests/test_training.py@@ -1,7 +1,6 @@import ioimport copyimport json-import mathimport datetimefrom typing import Any@@ -25,21 +24,17 @@ from products.signals.backend.ranking.features import (EMBEDDING_COLUMN,EMBEDDING_DIMENSIONS,EMBEDDING_INSERTED_AT_COLUMN,- FEATURE_NAMES,- FEATURE_SCHEMA_VERSION,+ FEATURE_SETS,NO_EXTRAS,REPORT_EMBEDDINGS_EXTRA,REPORT_EMBEDDINGS_FEATURE_SET,REPORT_GRAIN,SCORING_MOMENT_GRAIN,- TABULAR_FEATURE_SET,TITLE_EMBEDDINGS_EXTRA,TITLE_EMBEDDINGS_FEATURE_SET,Extras,FeatureSet,- feature_frame,feature_set_by_name,- feature_vector,)from products.signals.backend.ranking.model_contract import (classification_thresholds,@@ -158,7 +153,6 @@ from products.signals.dags.inbox_ranking.training.unseen import (REPORT_EMBEDDINGS_MODEL_NAME,SCORE_COLUMNS,SERVED_SCORES_TABLE,- TABULAR_MODEL_NAME,TITLE_EMBEDDINGS_MODEL_NAME,UNSEEN_SCORES_TABLE,ModelFamily,@@ -183,6 +177,33 @@ EMBEDDINGS_MODEL_NAME = REPORT_EMBEDDINGS_MODEL_NAME# The two renderings' sets. Every rule about a vector holds for both, because they are one class# parameterized by the input it reads, so the embedding tests below run over the pair.EMBEDDING_FEATURE_SETS = (REPORT_EMBEDDINGS_FEATURE_SET, TITLE_EMBEDDINGS_FEATURE_SET)+++class _StateFeatureSet(FeatureSet):+ name = "state"+ schema_version = 1+ feature_names = ("signal_count", "total_weight", "age_hours")+ state_columns = ("signal_count", "total_weight")++ def build_matrix(+ self, rows: pd.DataFrame, extras: Extras = NO_EXTRAS, *, as_of: datetime.datetime | None = None+ ) -> pd.DataFrame:+ return rows.reindex(columns=list(self.feature_names)).apply(pd.to_numeric, errors="coerce").astype(float)+++# A cheap set with no side input, for the label, grain, consent and cap logic every set shares.+STATE_FEATURE_SET = _StateFeatureSet()+STATE_MODEL_NAME = "state_xgb"+++def register_state_set(monkeypatch):+ monkeypatch.setattr(+ "products.signals.backend.ranking.features.FEATURE_SETS",+ {**FEATURE_SETS, STATE_FEATURE_SET.name: STATE_FEATURE_SET},+ )++EMBEDDING_SET_IDS = [feature_set.name for feature_set in EMBEDDING_FEATURE_SETS]_EMBEDDING_EXTRA_KEYS = (REPORT_EMBEDDINGS_EXTRA, TITLE_EMBEDDINGS_EXTRA)@@ -247,42 +268,6 @@ def _daily_snapshots(return snapshots- "row",- [- {- "signal_count": 3,- "total_weight": 1.5,- "run_count": 1,- "title_chars": 40,- "summary_chars": 400,- "priority": "P1",- "actionability": "not_actionable",- "age_hours": 5.0,- },- {- "signal_count": None,- "total_weight": float("nan"),- "run_count": 2,- "title_chars": 0,- "summary_chars": 0,- "priority": None,- "actionability": "bogus",- "age_hours": 100.0,- },- {},- ],-)-def test_feature_vector_matches_feature_frame(row):- # The sweep scores one report at a time through feature_vector; training builds matrices- # through feature_frame. They must agree or the booster sees a different universe at serve time.- vector = feature_vector(row)- frame = feature_frame(pd.DataFrame([row]) if row else pd.DataFrame([{}]))- assert len(vector) == len(FEATURE_NAMES) == frame.shape[1]- for name, value, column_value in zip(FEATURE_NAMES, vector, frame.iloc[0].tolist(), strict=True):- assert (math.isnan(value) and math.isnan(column_value)) or value == column_value, name--def test_build_examples_is_a_scoring_moment_with_a_future_label():# The grain a re-scoring family would ask for: a row per snapshot, censored once the outcome is# visible. Every report here is older than D0, so no birth-day exemption applies.@@ -307,8 +292,8 @@ def test_build_examples_is_a_scoring_moment_with_a_future_label():# A snapshot with no horizon partner contributes nothing.later + datetime.timedelta(days=1): Snapshot(date=later, state=state, labels=_labels(ids)),}- examples = build_examples(snapshots, open_head, _at_grain(TABULAR_FEATURE_SET, SCORING_MOMENT_GRAIN))- assert list(examples.columns) == list(example_columns(TABULAR_FEATURE_SET))+ examples = build_examples(snapshots, open_head, _at_grain(STATE_FEATURE_SET, SCORING_MOMENT_GRAIN))+ assert list(examples.columns) == list(example_columns(STATE_FEATURE_SET))assert examples.set_index("report_id")["label"].to_dict() == {"a": 1, "c": 0, "d": 1}assert (examples["snapshot_date"] == D0).all()assert (examples["age_hours"] == 12.0).all()@@ -351,11 +336,11 @@ def test_assemble_snapshot_makes_never_labeled_reports_negatives_and_drops_untruassert 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, TABULAR_FEATURE_SET).set_index("report_id")["label"].to_dict()+ 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, TABULAR_FEATURE_SET).set_index("report_id")["label"].to_dict()+ wrong = build_examples(snapshots, wrong_head, STATE_FEATURE_SET).set_index("report_id")["label"].to_dict()assert wrong == {"b": 0, "c": 1}@@ -369,7 +354,7 @@ def test_build_examples_drops_state_rows_read_long_after_their_snapshot():D0: Snapshot(date=D0, state=state, labels=_labels(["a", "b"])),later: Snapshot(date=later, state=state, labels=_labels(["a", "b"])),}- assert build_examples(snapshots, head, TABULAR_FEATURE_SET)["report_id"].tolist() == ["a"]+ assert build_examples(snapshots, head, STATE_FEATURE_SET)["report_id"].tolist() == ["a"]@pytest.mark.parametrize(@@ -533,7 +518,7 @@ def test_new_head_label_columns_survive_the_load_snapshots_projection(head_name,objects[partition_object_key("inbox_ranking", STATE_TABLE, key)] = _parquet(_state(["a"]))objects[partition_object_key("inbox_ranking", LABELS_TABLE, key)] = _parquet(labels)snapshots = load_snapshots(_ParquetS3(objects), "bucket", "inbox_ranking", [D0, later])- examples = build_examples(snapshots, head, TABULAR_FEATURE_SET)+ examples = build_examples(snapshots, head, STATE_FEATURE_SET)assert examples.set_index("report_id")["label"].to_dict() == {"a": 1}@@ -548,7 +533,7 @@ def test_build_examples_skips_refund_pairs_when_the_scoring_snapshot_lacks_the_cD0: Snapshot(date=D0, state=_state(["a"]), labels=_labels(["a"])),later: Snapshot(date=later, state=_state(["a"]), labels=_labels(["a"], refund_count=[1])),}- assert build_examples(snapshots, head, TABULAR_FEATURE_SET).empty+ assert build_examples(snapshots, head, STATE_FEATURE_SET).emptydef test_build_examples_skips_label_only_rows():@@ -559,7 +544,7 @@ def test_build_examples_skips_label_only_rows():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])),}- assert build_examples(snapshots, head, TABULAR_FEATURE_SET)["report_id"].tolist() == ["a"]+ assert build_examples(snapshots, head, STATE_FEATURE_SET)["report_id"].tolist() == ["a"]def test_build_examples_drops_reports_without_training_consent_at_training_time():@@ -576,7 +561,7 @@ def test_build_examples_drops_reports_without_training_consent_at_training_time(kept, excluded = drop_without_training_consent(snapshots, frozenset({1}))- assert build_examples(kept, head, TABULAR_FEATURE_SET)["report_id"].tolist() == ["consenting"]+ assert build_examples(kept, head, STATE_FEATURE_SET)["report_id"].tolist() == ["consenting"]assert (excluded.reports, excluded.teams) == (2, 1)assert kept[later].labels.index.tolist() == ["consenting", "eu"]@@ -609,14 +594,14 @@ def test_train_head_learns_a_separable_signal_and_names_its_features():"age_hours": 12.0,})- examples = feature_frame(rows)+ examples = STATE_FEATURE_SET.build_matrix(rows)examples.insert(0, "head", head.name)examples.insert(1, "report_id", [f"r{i}" for i in range(n)])examples.insert(2, "snapshot_date", D0)examples.insert(3, "report_created_at", created)examples["label"] = (signal_count > 25).astype(int)- trained = train_head(examples, head, feature_names=FEATURE_NAMES, holdout_days=7)+ trained = train_head(examples, head, feature_names=STATE_FEATURE_SET.feature_names, holdout_days=7)assert trained is not Noneassert trained.metrics.readableassert trained.metrics.holdout_auc is not None and trained.metrics.holdout_auc > 0.9@@ -644,12 +629,12 @@ def test_train_head_learns_a_separable_signal_and_names_its_features():}booster = xgb.Booster()booster.load_model(bytearray(trained.booster_ubj))- assert booster.feature_names == list(FEATURE_NAMES)+ assert booster.feature_names == list(STATE_FEATURE_SET.feature_names)# The saved holdout fit graded on the same rows must reproduce the stored metric: this is the# path the champion gate uses to compare two models on one holdout.assert trained.holdout_booster_ubj is not Nonepaired = booster_holdout_grade(- trained.holdout_booster_ubj, examples, head, feature_names=FEATURE_NAMES, holdout_days=7+ trained.holdout_booster_ubj, examples, head, feature_names=STATE_FEATURE_SET.feature_names, holdout_days=7)assert paired is not Noneassert paired.auc == pytest.approx(trained.metrics.holdout_auc, abs=1e-6)@@ -658,15 +643,15 @@ def test_train_head_learns_a_separable_signal_and_names_its_features():)# The metadata that ships says what the probability is conditioned on and how much history it saw.window = {"example_window_start": "2026-08-01", "example_cap_bound": False}- table = examples_table(examples, TABULAR_FEATURE_SET, {head.name: window})+ table = examples_table(examples, STATE_FEATURE_SET, {head.name: window})buffer = io.BytesIO()pq.write_table(table, buffer)windows = example_windows(pq.read_table(pa.BufferReader(buffer.getvalue())))candidate_head = candidate_metadata("2026-08-19",[trained],- model_name=TABULAR_MODEL_NAME,- feature_set=TABULAR_FEATURE_SET,+ model_name=STATE_MODEL_NAME,+ feature_set=STATE_FEATURE_SET,skipped=[],trained_at=NOW,run_id="run-1",@@ -679,7 +664,10 @@ def test_train_head_learns_a_separable_signal_and_names_its_features():# back to the stored AUC instead of failing the champion asset every day.other_schema = xgb.XGBClassifier(n_estimators=2).fit(pd.DataFrame({"not_a_feature": [0, 1, 0, 1]}), [0, 1, 0, 1])other_ubj = bytes(other_schema.get_booster().save_raw("ubj"))- assert booster_holdout_grade(other_ubj, examples, head, feature_names=FEATURE_NAMES, holdout_days=7) is None+ assert (+ booster_holdout_grade(other_ubj, examples, head, feature_names=STATE_FEATURE_SET.feature_names, holdout_days=7)+ is None+ )def test_train_head_keeps_logloss_on_a_single_class_holdout():@@ -702,7 +690,7 @@ def test_train_head_keeps_logloss_on_a_single_class_holdout():"age_hours": 12.0,})- examples = feature_frame(rows)+ examples = STATE_FEATURE_SET.build_matrix(rows)examples.insert(0, "head", head.name)examples.insert(1, "report_id", [f"r{i}" for i in range(n)])examples.insert(2, "snapshot_date", D0)@@ -710,7 +698,7 @@ def test_train_head_keeps_logloss_on_a_single_class_holdout():in_holdout = holdout_mask(examples, 7).to_numpy()examples["label"] = ((signal_count > 25) & ~in_holdout).astype(int)- trained = train_head(examples, head, feature_names=FEATURE_NAMES, holdout_days=7)+ trained = train_head(examples, head, feature_names=STATE_FEATURE_SET.feature_names, holdout_days=7)assert trained is not Noneassert trained.metrics.holdout_positives == 0assert trained.metrics.holdout_auc is None@@ -738,9 +726,9 @@ def test_train_head_returns_none_without_both_classes():"label": [0, 0, 0],})- for name in FEATURE_NAMES:+ for name in STATE_FEATURE_SET.feature_names:examples[name] = 1.0- assert train_head(examples, head, feature_names=FEATURE_NAMES, holdout_days=7) is None+ assert train_head(examples, head, feature_names=STATE_FEATURE_SET.feature_names, holdout_days=7) is Noneclass _FakeClient:@@ -779,7 +767,7 @@ def _scores(report_ids: list[str], **overrides) -> pd.DataFrame:"report_created_at": [pd.Timestamp("2026-08-10T09:00:00Z")] * n,"snapshot_date": [D0] * n,"pool": [POOL_NAME] * n,- "model_name": [TABULAR_MODEL_NAME] * n,+ "model_name": [STATE_MODEL_NAME] * n,"model_version": ["2026-08-10"] * n,"model_role": [CANDIDATE_ROLE] * n,"feature_schema_version": [1] * n,@@ -827,11 +815,11 @@ def test_build_examples_never_covers_a_report_born_on_the_partition_day(grain):_labels(["old", "newborn"], open_count=[1, 1]),),}- examples = build_examples(snapshots, head, _at_grain(TABULAR_FEATURE_SET, grain))+ examples = build_examples(snapshots, head, _at_grain(STATE_FEATURE_SET, grain))assert set(examples["report_id"]) == {"old"}[email protected]("feature_set", [TABULAR_FEATURE_SET, *EMBEDDING_FEATURE_SETS])[email protected]("feature_set", [STATE_FEATURE_SET, *EMBEDDING_FEATURE_SETS])def test_birth_grain_keeps_one_row_per_report_on_the_day_it_was_created(feature_set):head = HEADS_BY_NAME["open"]ids = ["newborn", "older", "utc_start", "utc_end"]@@ -844,7 +832,7 @@ def test_birth_grain_keeps_one_row_per_report_on_the_day_it_was_created(feature_snapshots = _daily_snapshots(ids, head, created, days=3)snapshots[D0 + datetime.timedelta(days=head.horizon_days)].labels.loc[:, "open_count"] = 0# Both renderings' inputs, so the parameter that varies is the set under test and not what it- # was handed. The tabular set reads neither.+ # was handed. The state set reads neither.extras = {key: _vector_frame({report_id: _embedding() for report_id in ids}) for key in _EMBEDDING_EXTRA_KEYS}examples = build_examples(snapshots, head, feature_set, extras)@@ -876,7 +864,7 @@ def test_pr_merged_is_a_merge_from_birth_rather_than_a_merge_given_a_pr():},}- examples = build_examples(snapshots, head, TABULAR_FEATURE_SET)+ examples = build_examples(snapshots, head, STATE_FEATURE_SET)assert examples.set_index("report_id")["label"].to_dict() == {"merged": 1, "unmerged": 0, "nothing": 0}@@ -902,7 +890,7 @@ def test_reports_missing_birth_snapshot_counts_only_the_ones_a_partition_gap_cosassert reports_missing_birth_snapshot(snapshots, dates) == 2assert reports_missing_birth_snapshot({}, dates) == 0- examples = build_examples(snapshots, HEADS_BY_NAME["open"], TABULAR_FEATURE_SET)+ examples = build_examples(snapshots, HEADS_BY_NAME["open"], STATE_FEATURE_SET)assert examples["report_id"].tolist() == ["utc_end"]module = "products.signals.dags.inbox_ranking.training.dag"@@ -929,7 +917,7 @@ def test_build_examples_keeps_an_outcome_that_landed_on_the_reports_birth_day():date: assemble_snapshot(date, _state(ids, report_created_at=created), _labels(ids, pr_created_count=[1, 1]))for date in (D0, later)}- examples = build_examples(snapshots, head, TABULAR_FEATURE_SET)+ 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.assert examples.set_index("report_id")["label"].to_dict() == {"newborn": 1}assert birth_day_positives(examples) == 1@@ -1013,9 +1001,9 @@ def test_head_grades_report_counts_and_an_undefined_auc_on_a_single_class():# Counts are ints and the undefined AUC is dropped: the graded asset writes these as Dagster# metadata. The family is in the key, so a second family cannot overwrite the first's entries.metadata = grade_metadata([grade])- assert metadata["open_tabular_xgb_candidate_rows"] == dagster.MetadataValue.int(2)- assert metadata["open_tabular_xgb_candidate_auc"] == dagster.MetadataValue.float(1.0)- assert "open_tabular_xgb_candidate_auc" not in grade_metadata([single_class])+ assert metadata["open_state_xgb_candidate_rows"] == dagster.MetadataValue.int(2)+ assert metadata["open_state_xgb_candidate_auc"] == dagster.MetadataValue.float(1.0)+ assert "open_state_xgb_candidate_auc" not in grade_metadata([single_class])@pytest.mark.parametrize(@@ -1027,7 +1015,7 @@ def test_unseen_daily_evaluations_keep_baked_events_at_each_heads_horizon():ids = ["fast", "slow", "pending"]head_names = ["open", "pr_created", "pr_merged"]- families = [TABULAR_MODEL_NAME, EMBEDDINGS_MODEL_NAME]+ families = [STATE_MODEL_NAME, EMBEDDINGS_MODEL_NAME]scores = pd.concat([_scores(ids, head=[head] * 3, model_name=[family] * 3, score=[0.9, 0.1, 0.5])@@ -1227,7 +1215,7 @@ def test_head_grades_report_the_score_gap_a_perfect_auc_hides():assert sum(bucket.rows for bucket in grade.calibration) == grade.rowsassert {"head": "open",- "model_name": TABULAR_MODEL_NAME,+ "model_name": STATE_MODEL_NAME,"model_role": CANDIDATE_ROLE,"pool": POOL_NAME,"bucket": 2,@@ -1253,15 +1241,16 @@ def test_scored_pool_names_the_definition_a_scores_object_was_written_under(scor@pytest.mark.parametrize("scores,expected",[- (_scores(["a"]), TABULAR_MODEL_NAME),- (_scores(["a"], model_name=[EMBEDDINGS_MODEL_NAME]), EMBEDDINGS_MODEL_NAME),- # A pre-column object is still in the grader's 14-day window, and a null name splits the series.- (_scores(["a"]).drop(columns=["model_name"]), TABULAR_MODEL_NAME),- (_scores(["a"], model_name=[None]), TABULAR_MODEL_NAME),+ (_scores(["a"]), [STATE_MODEL_NAME]),+ # Rows that name no family belong to a retired one, and grading them under a null name splits the series.+ (_scores(["a"]).drop(columns=["model_name"]), []),+ (_scores(["a", "b"], model_name=[None, EMBEDDINGS_MODEL_NAME]), [EMBEDDINGS_MODEL_NAME]),+ # Named rows of a retired family are dropped too, or its grades outlive the family.+ (_scores(["a", "b"], model_name=["tabular_xgb", EMBEDDINGS_MODEL_NAME]), [EMBEDDINGS_MODEL_NAME]),],)-def test_scores_written_before_the_family_dimension_read_as_the_tabular_family(scores, expected):- assert with_model_names(scores)["model_name"].tolist() == [expected]+def test_with_model_names_drops_rows_that_name_no_family(scores, expected):+ assert with_model_names(scores)["model_name"].tolist() == expecteddef test_head_grades_keep_every_family_apart_on_the_same_rows():@@ -1271,11 +1260,11 @@ def test_head_grades_keep_every_family_apart_on_the_same_rows():head = HEADS_BY_NAME["open"]labels = _labels(["a", "e"], open_count=[1, 0])per_family = {- TABULAR_MODEL_NAME: [0.9, 0.1],+ STATE_MODEL_NAME: [0.9, 0.1],EMBEDDINGS_MODEL_NAME: [0.1, 0.9],TITLE_EMBEDDINGS_MODEL_NAME: [0.8, 0.2],}- thresholds = {TABULAR_MODEL_NAME: 0.5, EMBEDDINGS_MODEL_NAME: 0.05, TITLE_EMBEDDINGS_MODEL_NAME: 0.95}+ thresholds = {STATE_MODEL_NAME: 0.5, EMBEDDINGS_MODEL_NAME: 0.05, TITLE_EMBEDDINGS_MODEL_NAME: 0.95}graded = pd.concat([graded_rows(@@ -1296,7 +1285,7 @@ def test_head_grades_keep_every_family_apart_on_the_same_rows():grades = head_grades(graded, head, pool=POOL_NAME, scoring_partition="2026-08-10")assert [(grade.model_name, grade.rows, grade.auc) for grade in grades] == [(EMBEDDINGS_MODEL_NAME, 2, 0.0),- (TABULAR_MODEL_NAME, 2, 1.0),+ (STATE_MODEL_NAME, 2, 1.0),(TITLE_EMBEDDINGS_MODEL_NAME, 2, 1.0),]# Each model keeps the cut it saved, and never borrows another model's.@@ -1351,19 +1340,24 @@ def test_an_empty_scores_write_is_refused_over_a_partition_that_holds_rows(exist"existing,scored,expected",[(- [TABULAR_MODEL_NAME, EMBEDDINGS_MODEL_NAME, TITLE_EMBEDDINGS_MODEL_NAME],- [TABULAR_MODEL_NAME, EMBEDDINGS_MODEL_NAME],+ [STATE_MODEL_NAME, EMBEDDINGS_MODEL_NAME, TITLE_EMBEDDINGS_MODEL_NAME],+ [STATE_MODEL_NAME, EMBEDDINGS_MODEL_NAME],[TITLE_EMBEDDINGS_MODEL_NAME],),(- [TABULAR_MODEL_NAME, EMBEDDINGS_MODEL_NAME],- [TABULAR_MODEL_NAME, EMBEDDINGS_MODEL_NAME],+ [STATE_MODEL_NAME, EMBEDDINGS_MODEL_NAME],+ [STATE_MODEL_NAME, EMBEDDINGS_MODEL_NAME],+ [],+ ),+ ([STATE_MODEL_NAME], [], [STATE_MODEL_NAME]),+ ([], [STATE_MODEL_NAME], []),+ (+ ["tabular_xgb", EMBEDDINGS_MODEL_NAME, TITLE_EMBEDDINGS_MODEL_NAME],+ [EMBEDDINGS_MODEL_NAME, TITLE_EMBEDDINGS_MODEL_NAME],[],),- ([TABULAR_MODEL_NAME], [], [TABULAR_MODEL_NAME]),- ([], [TABULAR_MODEL_NAME], []),],- ids=["one_family_skipped", "every_family_scored", "nothing_scored", "first_write"],+ ids=["one_family_skipped", "every_family_scored", "nothing_scored", "first_write", "retired_family_held"],)def test_a_rewrite_that_drops_a_family_names_the_rows_it_would_delete(existing, scored, expected):# One object holds every family, so a re-run in a state where a family is not loadable would@@ -1376,12 +1370,12 @@ def test_a_rewrite_that_drops_a_family_names_the_rows_it_would_delete(existing,)-def test_a_rewrite_reads_a_pre_family_scores_object_as_the_tabular_family():- # A partition written before `model_name` existed holds tabular rows. Reading it as a family of- # its own would refuse every re-run of those days, which is the opposite of the guard's point.+def test_a_rewrite_does_not_count_a_pre_family_scores_object_as_a_family():+ # A partition written before `model_name` existed holds rows of a retired family. Reading it as a+ # family of its own would refuse every re-run of those days, which is the opposite of the guard's point.existing = pd.DataFrame({"report_id": ["a"], "score": [0.5]})- assert families_lost_by_rewrite(existing, pd.DataFrame({"model_name": [TABULAR_MODEL_NAME]})) == []+ assert families_lost_by_rewrite(existing, pd.DataFrame({"model_name": [STATE_MODEL_NAME]})) == []class _ModelStoreS3:@@ -1415,37 +1409,37 @@ class _DeniedPrefixS3(_ModelStoreS3):return super().get_object(Bucket=Bucket, Key=Key)-def test_load_unseen_models_skips_a_family_with_nothing_to_score_that_day(monkeypatch):+def test_load_unseen_models_skips_a_family_with_nothing_to_score_that_day(monkeypatch, register_state_set):# A family registered before its first trainer run, or one whose candidate failed, must cost only its own line.partition_key = "2026-08-19"metadata = {- "model_name": TABULAR_MODEL_NAME,+ "model_name": STATE_MODEL_NAME,"model_version": partition_key,- "feature_set": TABULAR_FEATURE_SET.name,- "feature_schema_version": FEATURE_SCHEMA_VERSION,- "feature_names": list(FEATURE_NAMES),+ "feature_set": STATE_FEATURE_SET.name,+ "feature_schema_version": STATE_FEATURE_SET.schema_version,+ "feature_names": list(STATE_FEATURE_SET.feature_names),"heads": [{"head": "open", "readable": True, "file": "open.ubj", "refit_classification_threshold": 0.12},],}client = _ModelStoreS3({- model_object_key("inbox_ranking", TABULAR_MODEL_NAME, partition_key, METADATA_FILE): json.dumps(+ model_object_key("inbox_ranking", STATE_MODEL_NAME, partition_key, METADATA_FILE): json.dumps(metadata).encode(),- model_object_key("inbox_ranking", TABULAR_MODEL_NAME, partition_key, "open.ubj"): b"booster",+ model_object_key("inbox_ranking", STATE_MODEL_NAME, partition_key, "open.ubj"): b"booster",})monkeypatch.setattr("products.signals.dags.inbox_ranking.training.dag.MODEL_FAMILIES",(ModelFamily(name=EMBEDDINGS_MODEL_NAME, feature_set=REPORT_EMBEDDINGS_FEATURE_SET),- ModelFamily(name=TABULAR_MODEL_NAME, feature_set=TABULAR_FEATURE_SET),+ ModelFamily(name=STATE_MODEL_NAME, feature_set=STATE_FEATURE_SET),),)models = load_unseen_models(dagster.build_asset_context(), client, "bucket", "inbox_ranking", partition_key)assert [(model.model_name, model.model_role, sorted(model.boosters)) for model in models] == [- (TABULAR_MODEL_NAME, CANDIDATE_ROLE, ["open"])+ (STATE_MODEL_NAME, CANDIDATE_ROLE, ["open"])]assert models[0].classification_thresholds == {"open": 0.12}@@ -1490,7 +1484,7 @@ def test_training_events_carry_the_dashboard_contract(monkeypatch):# The per-head events are what the project-2 insights break down on; dropping the head# property, the partition-day timestamp, or the person-profile opt-out breaks every chart.metadata = {- "model_name": TABULAR_MODEL_NAME,+ "model_name": STATE_MODEL_NAME,"model_version": "2026-08-25","run_id": "run-1","dataset_version": "v1",@@ -1520,7 +1514,7 @@ def test_training_events_carry_the_dashboard_contract(monkeypatch):*examples_events(partition_key="2026-08-25",run_id="run-1",- feature_set=TABULAR_FEATURE_SET.name,+ feature_set=STATE_FEATURE_SET.name,snapshots=20,backfilled_rows=0,excluded=ConsentExclusion(reports=4, teams=2),@@ -1538,7 +1532,7 @@ def test_training_events_carry_the_dashboard_contract(monkeypatch):promotion_event(partition_key="2026-08-25",run_id="run-1",- model_name=TABULAR_MODEL_NAME,+ model_name=STATE_MODEL_NAME,decision=PromotionDecision(promote=True, reason="no champion yet", skipped_heads=("discuss",)),outcome=PromotionOutcome(promote=True, override=None),promoted=False,@@ -1553,7 +1547,7 @@ def test_training_events_carry_the_dashboard_contract(monkeypatch):*holdout_calibration_events(partition_key="2026-08-25",run_id="run-1",- model_name=TABULAR_MODEL_NAME,+ model_name=STATE_MODEL_NAME,rows=[{"head": "open",@@ -1591,7 +1585,7 @@ def test_training_events_carry_the_dashboard_contract(monkeypatch):"inbox_ranking_holdout_calibration","inbox_ranking_unseen_report_graded",):- assert all(call["properties"]["model_name"] == TABULAR_MODEL_NAME for call in by_event[event_name])+ assert all(call["properties"]["model_name"] == STATE_MODEL_NAME for call in by_event[event_name])candidates = by_event["inbox_ranking_candidate_trained"]assert [c["properties"]["head"] for c in candidates] == ["open", "action", "dismiss_wrong"]assert candidates[0]["properties"]["holdout_auc"] == 0.67@@ -1612,7 +1606,7 @@ def test_training_events_carry_the_dashboard_contract(monkeypatch):"birth_day_positives": 1,"example_window_start": "2026-07-01","example_cap_bound": True,- "feature_set": TABULAR_FEATURE_SET.name,+ "feature_set": STATE_FEATURE_SET.name,"excluded_no_training_consent_reports": 4,"excluded_no_training_consent_teams": 2,}.items() <= examples_props.items()@@ -1993,8 +1987,8 @@ class _FakeS3:def test_rerun_removes_stale_head_files_but_keeps_what_it_just_wrote():- folder = model_object_key("inbox_ranking", TABULAR_MODEL_NAME, "2026-08-19", "")- champion = champion_object_key("inbox_ranking", TABULAR_MODEL_NAME)+ folder = model_object_key("inbox_ranking", STATE_MODEL_NAME, "2026-08-19", "")+ champion = champion_object_key("inbox_ranking", STATE_MODEL_NAME)written = {folder + "open.ubj", folder + "open.holdout.ubj", folder + "metadata.json"}client = _FakeS3([*written, folder + "action.ubj", champion])assert _delete_other_objects(client, "bucket", folder, written) == [folder + "action.ubj"]@@ -2025,12 +2019,12 @@ def test_examples_depend_on_the_whole_lookback_window():def test_model_key_layout_is_stable():# The scoring sweep resolves these keys, and a prefix per family stops two families colliding.assert (- model_object_key("inbox_ranking", TABULAR_MODEL_NAME, "2026-08-19", "open.ubj")- == "inbox_ranking/inbox_ranking_models/v1/tabular_xgb/dt=2026-08-19/open.ubj"+ model_object_key("inbox_ranking", STATE_MODEL_NAME, "2026-08-19", "open.ubj")+ == "inbox_ranking/inbox_ranking_models/v1/state_xgb/dt=2026-08-19/open.ubj")assert (- champion_object_key("inbox_ranking", TABULAR_MODEL_NAME)- == "inbox_ranking/inbox_ranking_models/v1/tabular_xgb/champion.json"+ champion_object_key("inbox_ranking", STATE_MODEL_NAME)+ == "inbox_ranking/inbox_ranking_models/v1/state_xgb/champion.json")assert (model_object_key("inbox_ranking", EMBEDDINGS_MODEL_NAME, "2026-08-19", "open.ubj")@@ -2108,12 +2102,12 @@ def test_an_unreadable_trained_head_is_still_scored_and_graded():assert trained_head_files(metadata, HEADS_BY_NAME) == {"open": "open.ubj", "thumbs_up": "thumbs_up.ubj"}assert readable_head_names(metadata) == frozenset({"open"})- booster = _booster_ubj(tuple(TABULAR_FEATURE_SET.feature_names))+ booster = _booster_ubj(tuple(STATE_FEATURE_SET.feature_names))model = UnseenModel(- model_name=TABULAR_MODEL_NAME,+ model_name=STATE_MODEL_NAME,model_version="2026-08-10",model_role=CANDIDATE_ROLE,- feature_set=TABULAR_FEATURE_SET,+ feature_set=STATE_FEATURE_SET,boosters={"open": booster, "thumbs_up": booster},readable_heads=readable_head_names(metadata),classification_thresholds={"thumbs_up": 0.0},@@ -2155,20 +2149,20 @@ def test_a_scores_object_written_before_the_readable_column_grades_as_readable()def test_score_pool_builds_one_matrix_per_feature_set_and_shares_it():# Two models on one set must reuse its matrix, and a model on another set must get its own.# Scoring every model against a single matrix would feed the second set the wrong columns.- tabular = _CountingFeatureSet(TABULAR_FEATURE_SET)+ state = _CountingFeatureSet(STATE_FEATURE_SET)age_only = _CountingFeatureSet(_AgeOnlyFeatureSet())models = [- _unseen_model(TABULAR_MODEL_NAME, tabular),- _unseen_model(TABULAR_MODEL_NAME, tabular, role=CHAMPION_ROLE),+ _unseen_model(STATE_MODEL_NAME, state),+ _unseen_model(STATE_MODEL_NAME, state, role=CHAMPION_ROLE),_unseen_model(EMBEDDINGS_MODEL_NAME, age_only),]scores = score_pool(_state(["a", "b"]), _labels(["a", "b"]), models, snapshot_date=D0)- assert (tabular.builds, age_only.builds) == (1, 1)+ assert (state.builds, age_only.builds) == (1, 1)assert list(scores.columns) == list(SCORE_COLUMNS)assert scores.groupby(["model_name", "model_role"]).size().to_dict() == {- (TABULAR_MODEL_NAME, CANDIDATE_ROLE): 2,- (TABULAR_MODEL_NAME, CHAMPION_ROLE): 2,+ (STATE_MODEL_NAME, CANDIDATE_ROLE): 2,+ (STATE_MODEL_NAME, CHAMPION_ROLE): 2,(EMBEDDINGS_MODEL_NAME, CANDIDATE_ROLE): 2,}# Each row carries the schema version of the set its model was fit on, not one global version.@@ -2179,9 +2173,9 @@ def test_score_pool_builds_one_matrix_per_feature_set_and_shares_it():def _model_metadata(**overrides) -> dict[str, Any]:base = {- "feature_set": TABULAR_FEATURE_SET.name,- "feature_schema_version": FEATURE_SCHEMA_VERSION,- "feature_names": list(FEATURE_NAMES),+ "feature_set": REPORT_EMBEDDINGS_FEATURE_SET.name,+ "feature_schema_version": REPORT_EMBEDDINGS_FEATURE_SET.schema_version,+ "feature_names": list(REPORT_EMBEDDINGS_FEATURE_SET.feature_names),}base.update(overrides)return base@@ -2191,13 +2185,13 @@ def _model_metadata(**overrides) -> dict[str, Any]:"metadata,expected",[(_model_metadata(), None),- # Written before the field existed: every one of those models is tabular.- ({key: value for key, value in _model_metadata().items() if key != "feature_set"}, None),+ # No declared set is left unscored rather than read as a default.+ ({key: value for key, value in _model_metadata().items() if key != "feature_set"}, "this build can produce"),(_model_metadata(- feature_set=REPORT_EMBEDDINGS_FEATURE_SET.name,- feature_schema_version=REPORT_EMBEDDINGS_FEATURE_SET.schema_version,- feature_names=list(REPORT_EMBEDDINGS_FEATURE_SET.feature_names),+ feature_set=TITLE_EMBEDDINGS_FEATURE_SET.name,+ feature_schema_version=TITLE_EMBEDDINGS_FEATURE_SET.schema_version,+ feature_names=list(TITLE_EMBEDDINGS_FEATURE_SET.feature_names),),None,),@@ -2208,7 +2202,7 @@ def _model_metadata(**overrides) -> dict[str, Any]:],)def test_model_mismatch_checks_a_model_against_its_own_feature_set(metadata, expected):- # A family on a richer set must not be rejected for disagreeing with the tabular contract, and+ # A family on one set must not be rejected for disagreeing with another set's contract, and# a set this build cannot produce must not be scored on whatever matrix happens to be at hand.mismatch = model_mismatch(metadata)assert expected is None and mismatch is None or (mismatch is not None and expected in mismatch)@@ -2249,8 +2243,8 @@ def test_build_examples_carries_the_columns_of_the_set_it_is_given():def test_examples_key_layout_is_per_feature_set():# Two sets carry different feature columns, so they cannot share a partition's object.assert (- examples_object_key("inbox_ranking", TABULAR_FEATURE_SET.name, "2026-08-19")- == "inbox_ranking/inbox_ranking_training_examples/v1/tabular/dt=2026-08-19/part-00000.parquet"+ examples_object_key("inbox_ranking", STATE_FEATURE_SET.name, "2026-08-19")+ == "inbox_ranking/inbox_ranking_training_examples/v1/state/dt=2026-08-19/part-00000.parquet")assert (examples_object_key("inbox_ranking", REPORT_EMBEDDINGS_FEATURE_SET.name, "2026-08-19")@@ -2267,7 +2261,7 @@ def test_examples_key_layout_is_per_feature_set():)[email protected]("feature_set", [TABULAR_FEATURE_SET, *EMBEDDING_FEATURE_SETS])[email protected]("feature_set", EMBEDDING_FEATURE_SETS)def test_every_registered_set_is_reachable_by_the_name_a_model_records(feature_set):# A model names its set in `metadata.json`, and a name this build cannot resolve is left# unscored, so registering the set is what makes the family's boosters loadable at all.@@ -2451,7 +2445,7 @@ def test_only_the_set_whose_snapshot_is_missing_is_skipped(monkeypatch):inbox_ranking_training_examples(context)metadata = context.get_output_metadata("result")- assert written == [TABULAR_FEATURE_SET.name, REPORT_EMBEDDINGS_FEATURE_SET.name]+ assert written == [REPORT_EMBEDDINGS_FEATURE_SET.name]assert metadata[f"{TITLE_EMBEDDINGS_FEATURE_SET.name}_skipped"].value is True@@ -2497,7 +2491,7 @@ def test_report_grain_keeps_one_example_per_report_and_needs_a_vector(feature_seassert examples["snapshot_date"].tolist() == [D0]assert examples["emb_0"].tolist() == [0.0]# The same snapshots at the moment grain: both reports, both days.- moments = build_examples(snapshots, head, _at_grain(TABULAR_FEATURE_SET, SCORING_MOMENT_GRAIN))+ moments = build_examples(snapshots, head, _at_grain(STATE_FEATURE_SET, SCORING_MOMENT_GRAIN))assert moments["report_id"].tolist() == ["a", "b", "a", "b"]@@ -2608,7 +2602,7 @@ def test_reading_a_moment_needs_the_vectors_landing_time(feature_set):@pytest.mark.parametrize("feature_set,extras,expected",[- (TABULAR_FEATURE_SET, NO_EXTRAS, ()),+ (STATE_FEATURE_SET, NO_EXTRAS, ()),(REPORT_EMBEDDINGS_FEATURE_SET, _report_vectors({"a": _embedding()}), ()),(REPORT_EMBEDDINGS_FEATURE_SET, NO_EXTRAS, (REPORT_EMBEDDINGS_EXTRA,)),# Each rendering answers for its own input: the other one being present is not its input.@@ -2643,12 +2637,12 @@ def test_a_family_without_examples_keeps_the_partition_it_already_has():def test_a_model_is_not_scored_without_the_side_input_its_set_reads():# Scoring every report off the booster's missing branch would put a line on the chart that says# nothing about the model, and the day's grade would read as the family's performance.- tabular = _unseen_model(TABULAR_MODEL_NAME, TABULAR_FEATURE_SET)+ state = _unseen_model(STATE_MODEL_NAME, STATE_FEATURE_SET)embeddings = _unseen_model(EMBEDDINGS_MODEL_NAME, REPORT_EMBEDDINGS_FEATURE_SET)- kept = models_with_extras(dagster.build_asset_context(), [tabular, embeddings], NO_EXTRAS)+ kept = models_with_extras(dagster.build_asset_context(), [state, embeddings], NO_EXTRAS)- assert [model.model_name for model in kept] == [TABULAR_MODEL_NAME]+ assert [model.model_name for model in kept] == [STATE_MODEL_NAME]def _serving_metadata(model_name: str, version: str, *, heads=("open", "action"), readable=True, **overrides):@@ -2680,23 +2674,23 @@ def _manifest_entry(model_name: str, version: str, *, roles, heads=("open",)):# expression ambiguous, empty or unresolvable at scoring time instead of at write time.([- _manifest_entry(TABULAR_MODEL_NAME, "2026-08-19", roles=[SERVED_ROLE]),+ _manifest_entry(STATE_MODEL_NAME, "2026-08-19", roles=[SERVED_ROLE]),_manifest_entry(EMBEDDINGS_MODEL_NAME, "2026-08-19", roles=[SERVED_ROLE]),],"exactly one model",),- ([_manifest_entry(TABULAR_MODEL_NAME, "2026-08-19", roles=[CROSS_FAMILY_ROLE])], "exactly one model"),+ ([_manifest_entry(STATE_MODEL_NAME, "2026-08-19", roles=[CROSS_FAMILY_ROLE])], "exactly one model"),([- _manifest_entry(TABULAR_MODEL_NAME, "2026-08-19", roles=[SERVED_ROLE]),- _manifest_entry(TABULAR_MODEL_NAME, "2026-08-19", roles=[CROSS_FAMILY_ROLE]),+ _manifest_entry(STATE_MODEL_NAME, "2026-08-19", roles=[SERVED_ROLE]),+ _manifest_entry(STATE_MODEL_NAME, "2026-08-19", roles=[CROSS_FAMILY_ROLE]),],"must be unique",),([], "at least 1 item"),([- _manifest_entry(TABULAR_MODEL_NAME, "2026-08-19", roles=[SERVED_ROLE]),+ _manifest_entry(STATE_MODEL_NAME, "2026-08-19", roles=[SERVED_ROLE]),*(_manifest_entry(EMBEDDINGS_MODEL_NAME, f"2026-08-{day:02d}", roles=[CROSS_FAMILY_ROLE])for day in range(1, MAX_RANKING_MODEL_RESULTS + 1)@@ -2716,12 +2710,12 @@ def test_a_manifest_entry_key_must_match_its_model():# names a different version sends the sweep to the wrong prefix and stores the wrong identity.with pytest.raises(ValidationError, match="does not match its model"):ServingManifestEntry(- key="tabular_xgb@2026-08-18",- model_name=TABULAR_MODEL_NAME,+ key="state_xgb@2026-08-18",+ model_name=STATE_MODEL_NAME,model_version="2026-08-19",model_kind=DEFAULT_MODEL_KIND,roles=[SERVED_ROLE],- prefix="inbox_ranking/serving/models/tabular_xgb@2026-08-19",+ prefix="inbox_ranking/serving/models/state_xgb@2026-08-19",heads=["open"],)@@ -2796,7 +2790,7 @@ def test_a_family_with_no_readable_head_is_left_out():champion=_serving_metadata(EMBEDDINGS_MODEL_NAME, "2026-08-15"),),FamilyModels(- name=TABULAR_MODEL_NAME, candidate=None, champion=_serving_metadata(TABULAR_MODEL_NAME, "2026-08-10")+ name=STATE_MODEL_NAME, candidate=None, champion=_serving_metadata(STATE_MODEL_NAME, "2026-08-10")),FamilyModels(name=TITLE_EMBEDDINGS_MODEL_NAME,@@ -2806,7 +2800,7 @@ def test_a_family_with_no_readable_head_is_left_out():])assert decision.manifest is not None- assert [entry.model_name for entry in decision.manifest.models] == [EMBEDDINGS_MODEL_NAME, TABULAR_MODEL_NAME]+ assert [entry.model_name for entry in decision.manifest.models] == [EMBEDDINGS_MODEL_NAME, STATE_MODEL_NAME]def test_the_cap_drops_cross_family_entries_before_the_paired_read():@@ -2841,9 +2835,7 @@ def test_a_pinned_model_is_kept_and_capped_before_the_paired_read():candidate=_serving_metadata(EMBEDDINGS_MODEL_NAME, "2026-08-19"),champion=_serving_metadata(EMBEDDINGS_MODEL_NAME, "2026-08-15"),),- FamilyModels(- name=TABULAR_MODEL_NAME, candidate=None, champion=_serving_metadata(TABULAR_MODEL_NAME, "2026-08-10")- ),+ FamilyModels(name=STATE_MODEL_NAME, candidate=None, champion=_serving_metadata(STATE_MODEL_NAME, "2026-08-10")),]pinned = [_serving_metadata(EMBEDDINGS_MODEL_NAME, f"2026-08-0{day}", readable=False) for day in range(1, 5)]# A pin of a model the manifest already names gains no second entry.@@ -3061,10 +3053,16 @@ def test_a_missing_pin_is_dropped_and_the_manifest_still_publishes(monkeypatch):client.objects[model_object_key(prefix, EMBEDDINGS_MODEL_NAME, pin_version, METADATA_FILE)] = json.dumps(pin_metadata).encode()+ # A retired family's model is still in the bucket with every booster, but no set here can build its matrix.+ retired_key = model_key("tabular_xgb", pin_version)+ client.objects[model_object_key(prefix, "tabular_xgb", pin_version, METADATA_FILE)] = json.dumps(+ _serving_metadata("tabular_xgb", pin_version, heads=("open",), feature_set="tabular")+ ).encode()+ client.objects[model_object_key(prefix, "tabular_xgb", pin_version, "open.ubj")] = b"booster"missing_key = model_key(EMBEDDINGS_MODEL_NAME, pin_version)absent_key = model_key(EMBEDDINGS_MODEL_NAME, "2026-07-01")denied_key = model_key(EMBEDDINGS_MODEL_NAME, "2026-06-01")- pins = (missing_key, absent_key, denied_key)+ pins = (missing_key, absent_key, denied_key, retired_key)monkeypatch.setattr("products.signals.dags.inbox_ranking.training.dag.read_ranking_overrides",lambda now: RankingOverrides(pin=pins),@@ -3084,6 +3082,7 @@ def test_a_missing_pin_is_dropped_and_the_manifest_still_publishes(monkeypatch):assert "missing boosters" in dropped[missing_key]assert METADATA_FILE in dropped[absent_key]assert "AccessDenied" in dropped[denied_key]+ assert "this build can produce" in dropped[retired_key]def test_the_serving_prefix_layout_is_stable():diff --git a/products/signals/dags/inbox_ranking/training/dag.py b/products/signals/dags/inbox_ranking/training/dag.pyindex d1970b7cfbc0..a4e78ec6f6a0 100644--- a/products/signals/dags/inbox_ranking/training/dag.py+++ b/products/signals/dags/inbox_ranking/training/dag.py@@ -25,7 +25,7 @@ was promoted from so a loader can tell a re-run apart from the version it pinnedgraded on the candidate's holdout through its `<head>.holdout.ubj` (the train-only fit), so thepromotion rule compares both models on one set of reports. Every model object sits under itsfamily's `model_name`, and promotion stays inside a family: a richer family is a second candidate-graded on the same rows, not a competitor for the tabular family's pointer.+graded on the same rows, not a competitor for another family's pointer.Both the candidate and the champion asset walk `MODEL_FAMILIES`, so each family trains on theexamples of the feature set it declares and decides against its own pointer. A family whose@@ -151,6 +151,7 @@ from products.signals.dags.inbox_ranking.training.train import (from products.signals.dags.inbox_ranking.training.unseen import (CANDIDATE_ROLE,CHAMPION_ROLE,+ FEATURE_INPUT_COLUMNS,MODEL_FAMILIES,SERVED_SCORES_TABLE,UNSEEN_SCORES_TABLE,@@ -197,12 +198,13 @@ _LABEL_COLUMNS = (*PROVENANCE_LABEL_COLUMNS,)# Every registered feature set's columns in one read: the state snapshot is loaded once and every-# set builds its examples from it.+# set builds its examples from it. The scored events copy the report-state inputs, so they are read too._STATE_READ_COLUMNS = tuple(dict.fromkeys((*BASE_STATE_COLUMNS,*(column for feature_set in FEATURE_SETS.values() for column in feature_set.state_columns),+ *FEATURE_INPUT_COLUMNS,*PROVENANCE_STATE_COLUMNS,"features_observed_at",)@@ -1392,6 +1394,11 @@ def inbox_ranking_unseen_graded(context: dagster.AssetExecutionContext) -> None:skipped[f"{skip_prefix}{scoring_partition}"] = f"no {kind} scores"continuescores = with_model_names(table.to_pandas())+ if len(scores) < table.num_rows:+ context.log.warning(+ f"dropped {table.num_rows - len(scores)} {kind} score rows of {scoring_partition} with no model_name "+ "or a retired one"+ )pool = scored_pool(scores)graded_by_head: dict[str, pd.DataFrame] = {}for head in heads:diff --git a/products/signals/dags/inbox_ranking/training/unseen.py b/products/signals/dags/inbox_ranking/training/unseen.pyindex 90a9facf8499..701aaa055e2d 100644--- a/products/signals/dags/inbox_ranking/training/unseen.py+++ b/products/signals/dags/inbox_ranking/training/unseen.py@@ -27,7 +27,6 @@ from posthog.dataclasses import frozenfrom products.signals.backend.ranking.features import (NO_EXTRAS,REPORT_EMBEDDINGS_FEATURE_SET,- TABULAR_FEATURE_SET,TITLE_EMBEDDINGS_FEATURE_SET,Extras,FeatureSet,@@ -63,9 +62,12 @@ CHAMPION_ROLE = "champion"# The model family: which features and which learner, as against `model_version`, the partition day# it was fit on. Both are in the identity, so two families trained on one day stay apart.-TABULAR_MODEL_NAME = "tabular_xgb"REPORT_EMBEDDINGS_MODEL_NAME = "report_embeddings"TITLE_EMBEDDINGS_MODEL_NAME = "title_embeddings"+# Families this build no longer trains. Saved scores objects still hold their rows, so every reader+# drops them through `with_model_names`: the grades stop with the family, and the rewrite guard does+# not require rows that no re-run can produce.+RETIRED_MODEL_NAMES = frozenset({"tabular_xgb"})# A shuffle plus one AUC rather than a refit, so this sits far above the trainer's NULL_PERMUTATIONS.NULL_PERMUTATIONS = 25@@ -146,7 +148,6 @@ class ModelFamily:# settings match by construction. Keep it that way: the pair is a measurement of the text choice,# and a recipe that differed between them would answer a question nobody asked.MODEL_FAMILIES: tuple[ModelFamily, ...] = (- ModelFamily(name=TABULAR_MODEL_NAME, feature_set=TABULAR_FEATURE_SET),ModelFamily(name=REPORT_EMBEDDINGS_MODEL_NAME, feature_set=REPORT_EMBEDDINGS_FEATURE_SET),ModelFamily(name=TITLE_EMBEDDINGS_MODEL_NAME, feature_set=TITLE_EMBEDDINGS_FEATURE_SET),)@@ -325,15 +326,16 @@ def empty_scores_write_allowed(existing_row_count: int | None) -> bool:def with_model_names(scores: pd.DataFrame) -> pd.DataFrame:- """`scores` with a `model_name` column, filling the tabular family where it is absent.+ """`scores` without the rows that name no model family or a retired one.- The grader reads scores objects up to 14 days old, so it still meets objects written before the- column existed. Every one of those holds tabular XGBoost rows, and grading them under a null- name would split the AUC series on the day the column arrived.+ A scores object written before the `model_name` column existed holds only rows of a retired+ family, and a later object can still hold named rows of one. No family this build trains can+ grade them, and grading them would keep a retired series alive, or put the unnamed rows in a+ series of their own, so they are dropped. The caller compares lengths to count them."""if "model_name" not in scores:- return scores.assign(model_name=TABULAR_MODEL_NAME)- return scores.assign(model_name=scores["model_name"].fillna(TABULAR_MODEL_NAME))+ return scores.iloc[0:0].assign(model_name=pd.Series(dtype=object))+ return scores[scores["model_name"].notna() & ~scores["model_name"].isin(RETIRED_MODEL_NAMES)]def families_lost_by_rewrite(existing: pd.DataFrame, scores: pd.DataFrame) -> list[str]:@@ -344,7 +346,8 @@ def families_lost_by_rewrite(existing: pd.DataFrame, scores: pd.DataFrame) -> li`empty_scores_write_allowed` refuses for a run that scored nothing, and a family is skippedwhenever its models or its set's side input are missing for the partition, so the partial caseis as ordinary as the empty one. Reading the object settles what it holds, which the row-count- stamp alone cannot.+ stamp alone cannot. A retired family's rows do not count: no re-run can produce them, so+ counting them would refuse every re-run of the days that hold them."""return sorted(set(with_model_names(existing)["model_name"].unique()) - set(scores["model_name"].unique()))