Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(autoresearch): add training trend, likely count and first check date (#115141)

posthog[bot]7234c2c186eb
diff --git a/products/autoresearch/backend/evaluation/AGENTS.md b/products/autoresearch/backend/evaluation/AGENTS.md
index 2e4f9df7b39f..b85bde745321 100644
--- a/products/autoresearch/backend/evaluation/AGENTS.md
+++ b/products/autoresearch/backend/evaluation/AGENTS.md
@@ -27,6 +27,9 @@ It is the only honest number in the product. A holdout AUC of 0.93 says the mode
Results land on `AutoresearchModel.realized_score` / `.calibration_error` / `.metrics["realized"]` via `_update_model_realized_metrics()`, and each validated date records an `AutoresearchRun` whose `metrics["per_model"]` keeps the emitted role next to the current one.
The model row keeps only the newest date. The history is on the runs: `latest_validation_runs()` in `history.py` reads them, for `online_performance()` in `../facade/api.py` (the pipeline's `online_performance` action and the `autoresearch-online-performance-retrieve` MCP tool) reads the newest completed run per (date, horizon) and returns one row per model per date, so an archived former champion keeps its evidence after a promotion. The training brief reads the same history (`../training/realized_context.py`).
+- `maturity.py`
+ `OUTCOME_INGESTION_GRACE` and `matures_at()`, the first instant a prediction date can be checked. `find_pending_validation_dates()` uses it, and the pipeline's `first_check_expected_at` applies it to the champion's earliest scored date, so the two cannot disagree. It imports nothing heavy, so the facade reads it without loading this package's sandbox code.
+
- `segment_thresholds.py`
The cut points between the Likely, Possible and Unlikely segments. Possible starts at the base rate, and Likely starts at `LIKELY_LIFT` times it, capped halfway between the base rate and 1. The base rate pools the emitted champion's `n_positive` / `n_scored` over the newest `BASE_RATE_DATES` checked dates. Until those dates hold `MIN_BASE_RATE_POSITIVES`, the fixed pair applies. `online_performance()` returns the current pair, which every frontend surface reads, and `champion_score_calibration()` flags a champion whose mean score is far from the realized rate. Class weighting or resampling in `train.py` leaves scores that are not probabilities, and nothing at scoring time corrects it.
A saved cohort, flag or workflow stores the absolute cut point, so it does not follow a later change in the base rate.
diff --git a/products/autoresearch/backend/evaluation/maturity.py b/products/autoresearch/backend/evaluation/maturity.py
new file mode 100644
index 000000000000..1b027953b47f
--- /dev/null
+++ b/products/autoresearch/backend/evaluation/maturity.py
@@ -0,0 +1,15 @@
+"""When a prediction date's outcome window has closed and its last outcome events have landed."""
+
+from datetime import UTC, date, datetime, timedelta
+
+# An outcome event timestamped just before the window closes can still be in the ingestion
+# queue when the window closes. Maturity waits this long past the window end so it lands
+# first; a completed date is never revisited, so a positive that arrives later than this
+# reads as a negative.
+OUTCOME_INGESTION_GRACE = timedelta(hours=1)
+
+
+def matures_at(prediction_date: date, horizon_days: int) -> datetime:
+ """The first instant online validation can check a prediction date scored under ``horizon_days``."""
+ window_start = datetime(prediction_date.year, prediction_date.month, prediction_date.day, tzinfo=UTC)
+ return window_start + timedelta(days=horizon_days) + OUTCOME_INGESTION_GRACE
diff --git a/products/autoresearch/backend/evaluation/online_validation.py b/products/autoresearch/backend/evaluation/online_validation.py
index 1865541981c8..d2470c58d358 100644
--- a/products/autoresearch/backend/evaluation/online_validation.py
+++ b/products/autoresearch/backend/evaluation/online_validation.py
@@ -43,6 +43,7 @@ from products.autoresearch.backend.dataset.labeling import (
build_target_condition,
)
from products.autoresearch.backend.evaluation.history import latest_validation_runs
+from products.autoresearch.backend.evaluation.maturity import matures_at
from products.autoresearch.backend.evaluation.segment_thresholds import BASE_RATE_DATES, segment_thresholds
from products.autoresearch.backend.inference.sandbox import SandboxInferenceError, _resolve_acting_user
from products.autoresearch.backend.models import AutoresearchModel, AutoresearchPipeline, AutoresearchRun
@@ -55,12 +56,6 @@ logger = structlog.get_logger(__name__)
# died mid-run and the exception handler never ran. Neither kind may hold a date forever.
STALE_RUN_AFTER = timedelta(hours=6)
-# An outcome event timestamped just before the window closes can still be in the ingestion
-# queue when the window closes. Maturity waits this long past the window end so it lands
-# first; a completed date is never revisited, so a positive that arrives later than this
-# reads as a negative.
-OUTCOME_INGESTION_GRACE = timedelta(hours=1)
-
# A live run stamps its events at emission time, which can cross midnight UTC before the
# batch goes out; a backfill stamps noon UTC of the date. Both fall within this many days
# of the start of the prediction date, so the fetch can bound `timestamp` for pruning.
@@ -203,7 +198,9 @@ def find_pending_validation_dates(pipeline: AutoresearchPipeline) -> list[Pendin
return [
item
for item in _scored_groups(pipeline)
- if item.key not in scoring and not _is_blocked(item, state) and item.window_end + OUTCOME_INGESTION_GRACE <= now
+ if item.key not in scoring
+ and not _is_blocked(item, state)
+ and matures_at(item.prediction_date, item.horizon_days) <= now
]
diff --git a/products/autoresearch/backend/evaluation/test_online_validation.py b/products/autoresearch/backend/evaluation/test_online_validation.py
index c71aa5c8ec78..c2a4f8e18e76 100644
--- a/products/autoresearch/backend/evaluation/test_online_validation.py
+++ b/products/autoresearch/backend/evaluation/test_online_validation.py
@@ -14,8 +14,8 @@ from posthog.models.user import User
from products.autoresearch.backend.dataset.labeling import PREDICTION_EVENT_NAME, SHADOW_MODEL_ROLE
from products.autoresearch.backend.evaluation import online_validation
+from products.autoresearch.backend.evaluation.maturity import OUTCOME_INGESTION_GRACE
from products.autoresearch.backend.evaluation.online_validation import (
- OUTCOME_INGESTION_GRACE,
STALE_RUN_AFTER,
OnlineValidationError,
_auc_confidence_interval,
diff --git a/products/autoresearch/backend/facade/api.py b/products/autoresearch/backend/facade/api.py
index 335ad2275bfb..757fd9d288fe 100644
--- a/products/autoresearch/backend/facade/api.py
+++ b/products/autoresearch/backend/facade/api.py
@@ -13,7 +13,7 @@ import json
import base64
import asyncio
import hashlib
-from datetime import date, timedelta
+from datetime import date, datetime, timedelta
from typing import Any
from uuid import UUID, uuid4
@@ -40,6 +40,7 @@ from ..dataset.validation import (
validate_pipeline_definition as _validate_pipeline_definition,
)
from ..evaluation.history import latest_validation_runs, realized_auc_trends
+from ..evaluation.maturity import matures_at
from ..evaluation.segment_thresholds import (
BASE_RATE_DATES,
FIXED_LIKELY_THRESHOLD,
@@ -100,6 +101,7 @@ from .contracts import (
TrainingRunHistory,
TrainingRunHistoryEntry,
TrainingRunNotFound,
+ TrainingTrendPoint,
ValidationWarning,
)
@@ -166,7 +168,11 @@ def _coverage_contract(coverage: Any) -> PredictionCoverage | None:
@frozen
class _PipelineActivity:
champion_realized_auc_trend: list[RealizedAucPoint]
+ champion_training_trend: list[TrainingTrendPoint]
people_scored: int | None
+ likely_count: int | None
+ likely_threshold: float | None
+ first_check_expected_at: datetime | None
coverage: PredictionCoverage | None
training_run_count: int
experiment_count: int
@@ -201,6 +207,74 @@ def _newest_completed_inference(team_id: int, pipeline_ids: list[UUID], field: s
)
+def _champion_training_trends(
+ team_id: int, champions: dict[UUID, AutoresearchModel]
+) -> dict[UUID, list[TrainingTrendPoint]]:
+ """Best-so-far holdout score per iteration of the run that trained each champion, oldest first."""
+ pipeline_by_run = {c.source_training_run_id: p for p, c in champions.items() if c.source_training_run_id}
+ trends: dict[UUID, list[TrainingTrendPoint]] = {}
+ best: dict[UUID, float] = {}
+ for training_run_id, iteration_number, holdout_score in (
+ AutoresearchIteration.objects.for_team(team_id)
+ .filter(training_run_id__in=list(pipeline_by_run))
+ .order_by("training_run_id", "iteration_number")
+ .values_list("training_run_id", "iteration_number", "holdout_score")
+ ):
+ if holdout_score is not None and holdout_score > best.get(training_run_id, -1.0):
+ best[training_run_id] = holdout_score
+ if training_run_id in best:
+ trends.setdefault(pipeline_by_run[training_run_id], []).append(
+ TrainingTrendPoint(iteration_number=iteration_number, best_holdout_score=best[training_run_id])
+ )
+ return trends
+
+
+def _champion_likely_counts(team_id: int, champions: dict[UUID, AutoresearchModel]) -> dict[UUID, tuple[int, float]]:
+ """Likely count and cut point of each champion's newest completed live run that recorded them."""
+ return {
+ pipeline_id: (count, threshold)
+ for pipeline_id, count, threshold in AutoresearchRun.objects.for_team(team_id)
+ .filter(
+ model_id__in=[c.id for c in champions.values()],
+ run_type=AutoresearchRun.RunType.INFERENCE,
+ status=AutoresearchRun.Status.COMPLETED,
+ metrics__has_key="likely_count",
+ )
+ .order_by("pipeline_id", F("completed_at").desc(nulls_last=True), "-created_at")
+ .distinct("pipeline_id")
+ .values_list("pipeline_id", "metrics__likely_count", "metrics__likely_threshold")
+ }
+
+
+def _first_checks_expected(team_id: int, champions: dict[UUID, AutoresearchModel]) -> dict[UUID, datetime]:
+ """
+ When online validation can first check each champion that no validation has checked yet.
+
+ Validation checks every completed run a model emitted, shadow runs and backfills included,
+ so the earliest of them sets the date.
+ """
+ pipeline_by_model = {c.id: p for p, c in champions.items() if not (c.metrics or {}).get("realized")}
+ first_checks: dict[UUID, datetime] = {}
+ for model_id, prediction_date, horizon_days in (
+ AutoresearchRun.objects.for_team(team_id)
+ .filter(
+ model_id__in=list(pipeline_by_model),
+ run_type=AutoresearchRun.RunType.INFERENCE,
+ status=AutoresearchRun.Status.COMPLETED,
+ rows_scored__gt=0,
+ metrics__has_key="prediction_date",
+ )
+ .values_list("model_id", "metrics__prediction_date", "metrics__horizon_days")
+ ):
+ if not isinstance(horizon_days, int):
+ continue
+ check_at = matures_at(date.fromisoformat(prediction_date), horizon_days)
+ pipeline_id = pipeline_by_model[model_id]
+ if pipeline_id not in first_checks or check_at < first_checks[pipeline_id]:
+ first_checks[pipeline_id] = check_at
+ return first_checks
+
+
def _pipeline_activity(
team_id: int, pipeline_ids: list[UUID], champions: dict[UUID, AutoresearchModel]
) -> dict[UUID, _PipelineActivity]:
@@ -246,12 +320,19 @@ def _pipeline_activity(
{pipeline_id: champion.id for pipeline_id, champion in champions.items()},
dates=REALIZED_AUC_TREND_DATES,
)
+ training_trends = _champion_training_trends(team_id, champions)
+ likely_counts = _champion_likely_counts(team_id, champions)
+ first_checks = _first_checks_expected(team_id, champions)
return {
pipeline_id: _PipelineActivity(
champion_realized_auc_trend=[
RealizedAucPoint(prediction_date=d, realized_auc=auc) for d, auc in trends.get(pipeline_id, [])
],
+ champion_training_trend=training_trends.get(pipeline_id, []),
people_scored=people_scored.get(pipeline_id),
+ likely_count=likely_counts[pipeline_id][0] if pipeline_id in likely_counts else None,
+ likely_threshold=likely_counts[pipeline_id][1] if pipeline_id in likely_counts else None,
+ first_check_expected_at=first_checks.get(pipeline_id),
coverage=_coverage_contract(coverage.get(pipeline_id)),
training_run_count=training_run_counts.get(pipeline_id, 0),
experiment_count=experiment_counts.get(pipeline_id, 0),
@@ -301,7 +382,11 @@ def _pipeline_to_contract(
champion_lift_at_10=_champion_lift_at_10(champion),
champion_is_preliminary=champion.is_preliminary if champion else None,
champion_realized_auc_trend=activity.champion_realized_auc_trend,
+ champion_training_trend=activity.champion_training_trend,
people_scored=activity.people_scored,
+ likely_count=activity.likely_count,
+ likely_threshold=activity.likely_threshold,
+ first_check_expected_at=activity.first_check_expected_at,
coverage=activity.coverage,
training_run_count=activity.training_run_count,
experiment_count=activity.experiment_count,
diff --git a/products/autoresearch/backend/facade/contracts.py b/products/autoresearch/backend/facade/contracts.py
index 982574b2ab03..705c7a5288c2 100644
--- a/products/autoresearch/backend/facade/contracts.py
+++ b/products/autoresearch/backend/facade/contracts.py
@@ -102,6 +102,12 @@ class RealizedAucPoint:
realized_auc: float
+@dataclass(frozen=True)
+class TrainingTrendPoint:
+ iteration_number: int
+ best_holdout_score: float
+
+
@dataclass(frozen=True, config={"arbitrary_types_allowed": True})
class Pipeline:
"""One prediction pipeline: a target, a population, and a horizon.
@@ -136,7 +142,11 @@ class Pipeline:
champion_lift_at_10: float | None
champion_is_preliminary: bool | None
champion_realized_auc_trend: list[RealizedAucPoint]
+ champion_training_trend: list[TrainingTrendPoint]
people_scored: int | None
+ likely_count: int | None
+ likely_threshold: float | None
+ first_check_expected_at: datetime | None
coverage: PredictionCoverage | None
training_run_count: int
experiment_count: int
diff --git a/products/autoresearch/backend/inference/AGENTS.md b/products/autoresearch/backend/inference/AGENTS.md
index 20777a459a2d..9919cad07084 100644
--- a/products/autoresearch/backend/inference/AGENTS.md
+++ b/products/autoresearch/backend/inference/AGENTS.md
@@ -31,6 +31,7 @@ The cardinal rule: **inference never refits a persisted model.** A bundle is fit
Inference rows are checked against the anchor count on both paths (`count_inference_anchors()`), and training rows against the labeled anchor count (`count_training_anchors()`, at the negative sample rate the rows were drawn at), because feature SQL that inner joins or filters a joined table in `WHERE` drops people without any row looking wrong.
Scoring above the cap is rolling. Every path (bundle, agent recipe, stub) counts the whole inference population first. When the count reaches `MATERIALIZE_ROW_LIMIT`, `rolling_selection()` returns a `RollingSelection` of `ROLLING_SCORE_LIMIT` persons, and the feature query takes that many anchors, ranked by `build_inference_anchors_sql()`: never scored by this pipeline, then the oldest last score, then the most recent activity. The row check then expects exactly that many rows. The run records the whole count as `metrics["rows_eligible"]` next to `rows_scored`, so a run that scored part of its population completes, and consecutive runs cover everyone in `ceil(eligible / scored)` runs, which is that many times `cadence_days` in days. Below the cap the selection is unchanged. The stub path's population and ranking bind the run's cutoff at every size, so a retry selects the same people, though its feature SQL still reads at `now()`. The truncation check stays as the backstop for a query that misbehaves.
A completed live run also records `metrics["coverage"]`: the population, how many people have a non-shadow score, how many have none, and the age of the newest score per person (avg, p50, p90, max, in days before the cutoff). `build_prediction_coverage_sql()` reads the same last-score subquery as the ranking, over the same `scored_lookback_days()` window, so `never_scored` is the set the ranking puts first. The query runs under `BATCH_QUERY`. A failed coverage query only logs, and backfill and shadow runs do not record coverage.
+ A completed live run also records `metrics["likely_count"]`, the people it scored at or above the current Likely cut point from `../evaluation/segment_thresholds.py`, and that cut point as `metrics["likely_threshold"]`. The score distribution keeps only quantiles, so the model list reads the count from here instead of querying the prediction events. Backfill and shadow runs do not record it.
`_resolve_distinct_ids()` maps the `person_id` everything is keyed on back to one current `distinct_id` through personhog (`get_persons_by_uuids`), never from event history, because an id read off old events can belong to someone else after a merge or split.
## Query budget
diff --git a/products/autoresearch/backend/inference/scoring.py b/products/autoresearch/backend/inference/scoring.py
index abc1bfd528cb..5815ff9529d2 100644
--- a/products/autoresearch/backend/inference/scoring.py
+++ b/products/autoresearch/backend/inference/scoring.py
@@ -67,6 +67,8 @@ from products.autoresearch.backend.dataset.labeling import (
build_training_features_sql,
rolling_selection,
)
+from products.autoresearch.backend.evaluation.history import latest_validation_runs
+from products.autoresearch.backend.evaluation.segment_thresholds import BASE_RATE_DATES, segment_thresholds
from products.autoresearch.backend.inference.failures import classify_failure
from products.autoresearch.backend.inference.sandbox import (
_FOLD_COL,
@@ -334,6 +336,8 @@ def run_inference_for_pipeline(
"rows_eligible": scored.rows_eligible,
}
)
+ if not window.is_backfill:
+ run.metrics.update(_likely_segment(team_id=team.pk, pipeline=pipeline, scored=scored))
run.completed_at = django_timezone.now()
run.save(update_fields=["status", "rows_scored", "negative_sample_rate", "metrics", "completed_at"])
@@ -384,6 +388,20 @@ def run_inference_for_pipeline(
return run
+def _likely_segment(*, team_id: int, pipeline: AutoresearchPipeline, scored: ScoredPopulation) -> dict[str, Any]:
+ """
+ The people a live champion run scored at or above the current Likely cut point, and that cut point.
+
+ The run keeps the count because its score distribution stores only quantiles, and the model
+ list must not query the prediction events for every pipeline.
+ """
+ threshold = segment_thresholds(latest_validation_runs(team_id, pipeline, limit=BASE_RATE_DATES)).likely
+ return {
+ "likely_count": sum(1 for row in scored.rows if row["p_y"] >= threshold),
+ "likely_threshold": threshold,
+ }
+
+
def _record_coverage(
*,
team: Team,
diff --git a/products/autoresearch/backend/inference/test_inference.py b/products/autoresearch/backend/inference/test_inference.py
index 0a49ae3518de..10fa51cb93df 100644
--- a/products/autoresearch/backend/inference/test_inference.py
+++ b/products/autoresearch/backend/inference/test_inference.py
@@ -214,6 +214,52 @@ class TestRunInferencePipeline(TeamScopedTestMixin, BaseTest):
run.refresh_from_db()
assert run.negative_sample_rate == 0.25
+ @parameterized.expand(
+ [
+ ("fixed_cut_point", 0, 0, {"likely_count": 2, "likely_threshold": 0.6}),
+ ("base_rate_cut_point", 10, 0, {"likely_count": 3, "likely_threshold": 0.3}),
+ ("backfill_records_nothing", 0, 30, {}),
+ ]
+ )
+ def test_a_live_run_records_its_likely_count(self, _name, checked_positives, days_back, expected):
+ pipeline, model = self._make_pipeline_and_model()
+ model.artifact_prefix = "tasks/autoresearch/team_1/pipeline_x/run_y"
+ model.save(update_fields=["artifact_prefix"])
+ if checked_positives:
+ AutoresearchRun.objects.create(
+ pipeline=pipeline,
+ run_type=AutoresearchRun.RunType.VALIDATION,
+ status=AutoresearchRun.Status.COMPLETED,
+ metrics={
+ "prediction_date": "2026-09-01",
+ "horizon_days": 7,
+ "per_model": {
+ str(model.pk): {"emitted_role": "champion", "n_scored": 100, "n_positive": checked_positives}
+ },
+ },
+ )
+ sandbox_result = SandboxScoreResult(
+ scored_rows=[{"distinct_id": f"user-{p_y}", "p_y": p_y} for p_y in (0.7, 0.6, 0.3, 0.1)],
+ holdout_auc=0.7,
+ n_train=10,
+ n_features=1,
+ rows_eligible=4,
+ )
+ with (
+ patch.object(scoring, "score_via_sandbox", return_value=sandbox_result),
+ patch.object(scoring, "_resolve_distinct_ids", return_value={}),
+ patch.object(scoring, "capture_batch_internal", _capture_accepting_everything()),
+ patch.object(scoring, "measure_prediction_coverage", return_value={}),
+ ):
+ run = run_inference_for_pipeline(
+ pipeline=pipeline,
+ model=model,
+ prediction_date=date.today() - timedelta(days=days_back) if days_back else None,
+ )
+
+ assert run.status == AutoresearchRun.Status.COMPLETED
+ assert {k: run.metrics[k] for k in ("likely_count", "likely_threshold") if k in run.metrics} == expected
+
def test_a_rolling_run_records_the_eligible_total_next_to_the_rows_scored(self):
pipeline, model = self._make_pipeline_and_model()
diff --git a/products/autoresearch/backend/presentation/views/serializers.py b/products/autoresearch/backend/presentation/views/serializers.py
index 91f0c32c1b00..d4ac13448fe7 100644
--- a/products/autoresearch/backend/presentation/views/serializers.py
+++ b/products/autoresearch/backend/presentation/views/serializers.py
@@ -27,6 +27,7 @@ from products.autoresearch.backend.facade.contracts import (
Run,
Suggestion,
TrainingRun,
+ TrainingTrendPoint,
)
POPULATION_KINDS = api.POPULATION_KINDS
@@ -567,6 +568,18 @@ class RealizedAucPointSerializer(DataclassSerializer):
fields = ["prediction_date", "realized_auc"]
+@extend_schema_serializer(component_name="AutoresearchTrainingTrendPoint")
+class TrainingTrendPointSerializer(DataclassSerializer):
+ iteration_number = serializers.IntegerField(read_only=True, help_text="Iteration number inside the training run.")
+ best_holdout_score = serializers.FloatField(
+ read_only=True, help_text="Best holdout AUC of the run up to and including this iteration."
+ )
+
+ class Meta:
+ dataclass = TrainingTrendPoint
+ fields = ["iteration_number", "best_holdout_score"]
+
+
@extend_schema_serializer(component_name="AutoresearchPipeline")
# Read representation of a pipeline. Every field is declared explicitly so the generated
# AutoresearchPipeline component keeps the shape it had when this was a ModelSerializer.
@@ -666,11 +679,44 @@ class AutoresearchPipelineSerializer(DataclassSerializer):
read_only=True,
help_text="Realized AUC of the current champion on its newest 14 validated prediction dates, oldest first.",
)
+ champion_training_trend = TrainingTrendPointSerializer(
+ many=True,
+ read_only=True,
+ help_text=(
+ "Best-so-far holdout AUC per iteration of the training run that produced the current champion, "
+ "oldest first. Iterations before the first holdout score are left out. Empty when the pipeline has no champion."
+ ),
+ )
people_scored = serializers.IntegerField(
read_only=True,
allow_null=True,
help_text="People scored by the most recent completed inference run. Null before the first scoring run.",
)
+ likely_count = serializers.IntegerField(
+ read_only=True,
+ allow_null=True,
+ help_text=(
+ "People the newest completed live run of the current champion scored at or above likely_threshold. "
+ "Null before such a run, and for runs that did not record it."
+ ),
+ )
+ likely_threshold = serializers.FloatField(
+ read_only=True,
+ allow_null=True,
+ help_text=(
+ "The Likely cut point that likely_count used, as it was when that run scored. It is the fixed "
+ "cut point until enough predictions are checked. Null when likely_count is null."
+ ),
+ )
+ first_check_expected_at = serializers.DateTimeField(
+ read_only=True,
+ allow_null=True,
+ help_text=(
+ "When online validation can first check the current champion against real outcomes: its earliest "
+ "prediction date plus the horizon plus the ingestion grace. Null before the champion's first scoring "
+ "run, and once a validation has checked it."
+ ),
+ )
coverage = PredictionCoverageSerializer(
read_only=True,
allow_null=True,
@@ -714,7 +760,11 @@ class AutoresearchPipelineSerializer(DataclassSerializer):
"champion_lift_at_10",
"champion_is_preliminary",
"champion_realized_auc_trend",
+ "champion_training_trend",
"people_scored",
+ "likely_count",
+ "likely_threshold",
+ "first_check_expected_at",
"coverage",
"training_run_count",
"experiment_count",
diff --git a/products/autoresearch/backend/tests/test_api.py b/products/autoresearch/backend/tests/test_api.py
index f929c238bf4e..1b5db2315a16 100644
--- a/products/autoresearch/backend/tests/test_api.py
+++ b/products/autoresearch/backend/tests/test_api.py
@@ -215,15 +215,52 @@ class TestAutoresearchPipelineAPI(TeamScopedTestMixin, APIBaseTest):
self._make_pipeline(name="Untrained")
champion = AutoresearchModel.objects.get(pipeline=validated, role=AutoresearchModel.Role.CHAMPION)
finished = AutoresearchTrainingRun.objects.create(pipeline=validated, status="completed", iteration_budget=5)
- AutoresearchIteration.objects.create(
- pipeline=validated,
- training_run=finished,
- iteration_number=0,
- recipe_hash="a",
- recipe_snapshot={},
- status="kept",
- )
+ for number, holdout in [(0, None), (1, 0.7), (2, 0.65), (3, 0.8)]:
+ AutoresearchIteration.objects.create(
+ pipeline=validated,
+ training_run=finished,
+ iteration_number=number,
+ recipe_hash=f"a{number}",
+ recipe_snapshot={},
+ holdout_score=holdout,
+ status="kept",
+ )
+ champion.source_training_run = finished
+ champion.save(update_fields=["source_training_run"])
+ archived = AutoresearchModel.objects.get(pipeline=validated, role=AutoresearchModel.Role.ARCHIVED)
+ preliminary_champion = AutoresearchModel.objects.get(pipeline=preliminary)
now = django_timezone.now()
+ # The newest run with a Likely count belongs to the archived model, so the champion keeps its own.
+ for model, minutes_ago, count in [(champion, 90, 10), (champion, 70, 12), (archived, 65, 99)]:
+ AutoresearchRun.objects.create(
+ pipeline=validated,
+ model=model,
+ run_type=AutoresearchRun.RunType.INFERENCE,
+ status="completed",
+ rows_scored=100,
+ completed_at=now - timedelta(minutes=minutes_ago),
+ metrics={
+ "prediction_date": "2026-01-01",
+ "horizon_days": 7,
+ "likely_count": count,
+ "likely_threshold": 0.6,
+ },
+ )
+ # The earliest date that emitted rows sets the first check, whatever order the runs completed in.
+ for prediction_date, horizon_days, rows_scored, minutes_ago in [
+ ("2026-01-05", 7, 40, 30),
+ ("2026-01-03", 7, 30, 20),
+ ("2026-01-01", 7, 0, 10),
+ ]:
+ AutoresearchRun.objects.create(
+ pipeline=preliminary,
+ model=preliminary_champion,
+ run_type=AutoresearchRun.RunType.INFERENCE,
+ status="completed",
+ rows_scored=rows_scored,
+ completed_at=now - timedelta(minutes=minutes_ago),
+ metrics={"prediction_date": prediction_date, "horizon_days": horizon_days},
+ )
coverage = {
"population": 400,
"with_score": 300,
@@ -288,7 +325,7 @@ class TestAutoresearchPipelineAPI(TeamScopedTestMixin, APIBaseTest):
"Validated": (
250,
1,
- 1,
+ 4,
[
{"prediction_date": "2026-01-01", "realized_auc": 0.6},
{"prediction_date": "2026-01-02", "realized_auc": 0.75},
@@ -296,7 +333,7 @@ class TestAutoresearchPipelineAPI(TeamScopedTestMixin, APIBaseTest):
None,
),
"Preliminary": (
- None,
+ 0,
1,
2,
[],
@@ -347,6 +384,31 @@ class TestAutoresearchPipelineAPI(TeamScopedTestMixin, APIBaseTest):
"Untrained": (None, None, None, None),
}
+ assert {
+ name: (
+ row["champion_training_trend"],
+ row["likely_count"],
+ row["likely_threshold"],
+ row["first_check_expected_at"],
+ )
+ for name, row in by_name.items()
+ } == {
+ "Validated": (
+ [
+ {"iteration_number": 1, "best_holdout_score": 0.7},
+ {"iteration_number": 2, "best_holdout_score": 0.7},
+ {"iteration_number": 3, "best_holdout_score": 0.8},
+ ],
+ 12,
+ 0.6,
+ None,
+ ),
+ "Preliminary": ([], None, None, "2026-01-10T01:00:00Z"),
+ "No positives": ([], None, None, None),
+ "Zero lift": ([], None, None, None),
+ "Untrained": ([], None, None, None),
+ }
+
def test_archived_pipelines_excluded_from_list(self):
self._make_pipeline(name="Active")
self._make_pipeline(name="Archived", status=AutoresearchPipeline.Status.ARCHIVED)
diff --git a/products/autoresearch/frontend/generated/api.schemas.ts b/products/autoresearch/frontend/generated/api.schemas.ts
index d7eef482b131..43168d448af8 100644
--- a/products/autoresearch/frontend/generated/api.schemas.ts
+++ b/products/autoresearch/frontend/generated/api.schemas.ts
@@ -91,6 +91,13 @@ export interface AutoresearchRealizedAucPointApi {
readonly realized_auc: number
}
+export interface AutoresearchTrainingTrendPointApi {
+ /** Iteration number inside the training run. */
+ readonly iteration_number: number
+ /** Best holdout AUC of the run up to and including this iteration. */
+ readonly best_holdout_score: number
+}
+
export interface AutoresearchPredictionCoverageApi {
/** People in the inference population at the run's cutoff. */
readonly population: number
@@ -266,11 +273,28 @@ export interface AutoresearchPipelineApi {
readonly champion_is_preliminary: boolean | null
/** Realized AUC of the current champion on its newest 14 validated prediction dates, oldest first. */
readonly champion_realized_auc_trend: readonly AutoresearchRealizedAucPointApi[]
+ /** Best-so-far holdout AUC per iteration of the training run that produced the current champion, oldest first. Iterations before the first holdout score are left out. Empty when the pipeline has no champion. */
+ readonly champion_training_trend: readonly AutoresearchTrainingTrendPointApi[]
/**
* People scored by the most recent completed inference run. Null before the first scoring run.
* @nullable
*/
readonly people_scored: number | null
+ /**
+ * People the newest completed live run of the current champion scored at or above likely_threshold. Null before such a run, and for runs that did not record it.
+ * @nullable
+ */
+ readonly likely_count: number | null
+ /**
+ * The Likely cut point that likely_count used, as it was when that run scored. It is the fixed cut point until enough predictions are checked. Null when likely_count is null.
+ * @nullable
+ */
+ readonly likely_threshold: number | null
+ /**
+ * When online validation can first check the current champion against real outcomes: its earliest prediction date plus the horizon plus the ingestion grace. Null before the champion's first scoring run, and once a validation has checked it.
+ * @nullable
+ */
+ readonly first_check_expected_at: string | null
/** Score coverage and score age from the newest live champion run that measured them. Null before the first such run. */
readonly coverage: AutoresearchPredictionCoverageApi | null
/** Training runs started for this pipeline. */
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index e594c9bc0c5b..787e19530118 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -13934,6 +13934,13 @@ export namespace Schemas {
readonly realized_auc: number;
}
+ export interface AutoresearchTrainingTrendPoint {
+ /** Iteration number inside the training run. */
+ readonly iteration_number: number;
+ /** Best holdout AUC of the run up to and including this iteration. */
+ readonly best_holdout_score: number;
+ }
+
export interface AutoresearchPredictionCoverage {
/** People in the inference population at the run's cutoff. */
readonly population: number;
@@ -14067,11 +14074,28 @@ export namespace Schemas {
readonly champion_is_preliminary: boolean | null;
/** Realized AUC of the current champion on its newest 14 validated prediction dates, oldest first. */
readonly champion_realized_auc_trend: readonly AutoresearchRealizedAucPoint[];
+ /** Best-so-far holdout AUC per iteration of the training run that produced the current champion, oldest first. Iterations before the first holdout score are left out. Empty when the pipeline has no champion. */
+ readonly champion_training_trend: readonly AutoresearchTrainingTrendPoint[];
/**
* People scored by the most recent completed inference run. Null before the first scoring run.
* @nullable
*/
readonly people_scored: number | null;
+ /**
+ * People the newest completed live run of the current champion scored at or above likely_threshold. Null before such a run, and for runs that did not record it.
+ * @nullable
+ */
+ readonly likely_count: number | null;
+ /**
+ * The Likely cut point that likely_count used, as it was when that run scored. It is the fixed cut point until enough predictions are checked. Null when likely_count is null.
+ * @nullable
+ */
+ readonly likely_threshold: number | null;
+ /**
+ * When online validation can first check the current champion against real outcomes: its earliest prediction date plus the horizon plus the ingestion grace. Null before the champion's first scoring run, and once a validation has checked it.
+ * @nullable
+ */
+ readonly first_check_expected_at: string | null;
/** Score coverage and score age from the newest live champion run that measured them. Null before the first such run. */
readonly coverage: AutoresearchPredictionCoverage | null;
/** Training runs started for this pipeline. */