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): show a headline metric for each model card state (#115142)

posthog[bot]9665c36c5d4f
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 00b3dbbd50fb..137fbb11a55c 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6562,6 +6562,34 @@ snapshots:
hash: v1.k794b7964.ec5636bb061b046741a42c6ce3faa30704b2b4203947e956c5d7966bada33fd5.pMIwCFfVjMdfrr_RckXkoewH1hbCy3Veditgtv4hx_k
products-autoresearch-lifecycle-strip--validated-champion--light:
hash: v1.k794b7964.131ecc736b38defef5b8ba34fa9836f1d2d5132e1d109e4b995b9591a5d9255c.759giT71A_8sdMCqx-FasPgdZzZWHgRvaoUmqVtYYKw
+ products-autoresearch-model-card--awaiting-check--dark:
+ hash: v1.k794b7964.d0c4b837aed2340580cd64fcaea327145813c7059755c0d1ecb8ac37db523c9c.EDQGSSHmD19QsqrAXbeRBy2xQ_ncxQ0uEi1Vurn2GTM
+ products-autoresearch-model-card--awaiting-check--light:
+ hash: v1.k794b7964.5bf4a652830591e22ba932b205c1b9fc971ccca7cc8998e3b5b12e80789dc644.x3Zss-7B1weoMuvViz6vQDL5zzT5tCVeBhm6__eX4Pk
+ products-autoresearch-model-card--awaiting-check-long-horizon--dark:
+ hash: v1.k794b7964.f5f88b6745f7bfacf9bfd3ef83dbf938d92be62492f0ab4ed576c92aef541d7b.xUxsBctJvFgDLdGVYEW5u93I4hsqF9jeoZU5_SUBs6g
+ products-autoresearch-model-card--awaiting-check-long-horizon--light:
+ hash: v1.k794b7964.6cfc41c038fff8f43911ff67989e922de4519d80b7dce505e88274cf9fb14dff.VCMAfDPJBS14sTWlxUMPTg00ZvnbQ1cvOvi75YHy7vU
+ products-autoresearch-model-card--awaiting-check-without-likely-count--dark:
+ hash: v1.k794b7964.fa9128a2c665e012372016fe6de76e472ce39693299398e521787df9145c01a2.Tzva3cwDscvroRQDNmGTaNZFuKh1Xk3IpLVKp40Akm8
+ products-autoresearch-model-card--awaiting-check-without-likely-count--light:
+ hash: v1.k794b7964.facd8b0a9f18a67b5201de155edaa7a2c525f761ccc76f7487412884985bcd60.kq612Xhu2k_A_Q9gQpUqqsDbfytVIe_QcHHRmdxZIVc
+ products-autoresearch-model-card--confirmed--dark:
+ hash: v1.k794b7964.c8a65abbd3ce09b8b0f00d978c43bd083e2fc4a2a4bbd04841d16297d286b7ec.95EPpNIJb_jAY8Q5-gKw9f8deLfpD36ZjkCocJoYw60
+ products-autoresearch-model-card--confirmed--light:
+ hash: v1.k794b7964.933313db18507b0065864ec7ff98f7b2cff1692348b155e93adfcea14f72ed7f.11puCCTL4IP0fCXV_oOb3z5SIOeMBf0GbVvS_W5vhtw
+ products-autoresearch-model-card--confirmed-retraining--dark:
+ hash: v1.k794b7964.5021416edf991c93cc0e91bd0718a9d4ad90d01423d2ff1c4e74c5677fb81bb3.Po7UU9vxVppgHMgZU9EaahuM1ZLgC7ueUA8CnK3gYus
+ products-autoresearch-model-card--confirmed-retraining--light:
+ hash: v1.k794b7964.571893710d8f09efe512dbe906d1265f33f7cf7e537807dd2b3d5f0dc2faed91.4CbLaR4dEKjeP4Lc8cHqGHssgQlGo-LlDQYRgvFezbs
+ products-autoresearch-model-card--draft--dark:
+ hash: v1.k794b7964.c5cd95350db692fbff81d2f5049547a5a2a06bbbc8c7445654e5c0f1a3c4ca8e.AObIoQAoS70zxfPfmLnNY0kZPAUiygI5TwRnYKpkMlw
+ products-autoresearch-model-card--draft--light:
+ hash: v1.k794b7964.5fe35a8ac4491a88eb83b822301eff24e6f0bd6da0db81d0e7a8c0760f1468d3.IYNg7FBpccTnNYl04nGAnBGnKOmhgMbB4X4l0c3YvC4
+ products-autoresearch-model-card--training--dark:
+ hash: v1.k794b7964.88f39e3d0fbb43768a2cc61642017cb712ba6dbda2c40e1d99be11dbd87d198e.iAXGkjxlkUg5I1g5gl5H-XTbduzQFWYZfAvgZG60FzA
+ products-autoresearch-model-card--training--light:
+ hash: v1.k794b7964.8e81700643972d08ca45a0abc5e0b82b9b0a88566cc308b48c219301d42d8e5f.VhTJ3bXOU3KzsyClYUCH41SjpCm4bgfA4pAnCC5DMvI
products-autoresearch-model-detail-scene--accuracy--narrow--dark:
hash: v1.k794b7964.0131fa2a83a07edaa2c861515efb408fe43304690fc5d5d38aa3816a3dd49a23.J9awvFmY6Pn1s-oWPqAnejGDIAwddfAHgY8xbNcFyJk
products-autoresearch-model-detail-scene--accuracy--narrow--light:
diff --git a/products/autoresearch/frontend/AGENTS.md b/products/autoresearch/frontend/AGENTS.md
index 15e8cfea5fba..03b03bfc7548 100644
--- a/products/autoresearch/frontend/AGENTS.md
+++ b/products/autoresearch/frontend/AGENTS.md
@@ -9,7 +9,7 @@ The product is mostly a backend, and the UI is deliberately thin — it reads st
| File | Scene / role |
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `AutoresearchScene.tsx` | `/autoresearch` — the model list: a container-query grid of model cards and the "New model" entry point. |
-| `AutoresearchModelCard.tsx` | One model card: the question as title, a state body (scored, training, draft), and counts. `ModelCardMenu.tsx` holds pause, resume, delete. |
+| `AutoresearchModelCard.tsx` | One model card: the question, a headline metric per state (draft, training, awaiting check, confirmed). `ModelCardMenu.tsx` holds actions. |
| `pipelineQuestion.ts` | The model's question in plain words ("Who will do X in the next N days?"), shared by the list cards and the detail header. |
| `AutoresearchNewScene.tsx` | `/autoresearch/new` — the create form. Its parts live in `newModel/`. |
| `AutoresearchPipelineScene.tsx` | `/autoresearch/:id` — the detail shell: the question header, the lifecycle strip, and four tabs. Each tab lives in `pipeline/`. |
diff --git a/products/autoresearch/frontend/AutoresearchModelCard.stories.tsx b/products/autoresearch/frontend/AutoresearchModelCard.stories.tsx
new file mode 100644
index 000000000000..2c5e2ae24b33
--- /dev/null
+++ b/products/autoresearch/frontend/AutoresearchModelCard.stories.tsx
@@ -0,0 +1,125 @@
+import { Meta, StoryObj } from '@storybook/react'
+
+import { AutoresearchModelCard } from './AutoresearchModelCard'
+import type { AutoresearchPipelineApi } from './generated/api.schemas'
+
+const meta: Meta<typeof AutoresearchModelCard> = {
+ title: 'Products/Autoresearch/Model card',
+ component: AutoresearchModelCard,
+ parameters: { mockDate: '2026-03-01T12:00:00Z' },
+ decorators: [
+ (Story) => (
+ <div className="w-80">
+ <Story />
+ </div>
+ ),
+ ],
+}
+export default meta
+type Story = StoryObj<typeof AutoresearchModelCard>
+
+const BASE = {
+ id: '0190c3f2-0000-7000-8000-000000000001',
+ name: 'File sharers',
+ target_event: 'file_shared',
+ horizon_days: 7,
+ cadence_days: 1,
+ iteration_budget: 8,
+ success_auc: null,
+ status: 'running',
+ created_at: '2026-02-01T09:00:00Z',
+ last_scored_at: '2026-03-01T03:00:00Z',
+ champion_holdout_auc: 0.83,
+ champion_realized_auc: null,
+ champion_lift_at_10: null,
+ champion_is_preliminary: null,
+ champion_realized_auc_trend: [],
+ champion_training_trend: [0.68, 0.71, 0.71, 0.76, 0.79, 0.79, 0.83, 0.83].map((best_holdout_score, i) => ({
+ iteration_number: i,
+ best_holdout_score,
+ })),
+ people_scored: 48210,
+ likely_count: 1240,
+ likely_threshold: 0.6,
+ first_check_expected_at: '2026-03-04T01:00:00Z',
+ coverage: null,
+ training_run_count: 1,
+ experiment_count: 8,
+ live_training_run: null,
+} as unknown as AutoresearchPipelineApi
+
+const LIVE_RUN: AutoresearchPipelineApi['live_training_run'] = {
+ id: 'training-2',
+ iteration_budget: 8,
+ experiment_count: 3,
+ best_holdout_score: 0.81,
+ latest_agent_description: 'Add the ratio of shares in the last 7 days to the last 30 days.',
+ latest_summary: null,
+}
+
+const CONFIRMED = {
+ ...BASE,
+ champion_realized_auc: 0.84,
+ champion_lift_at_10: 2.3,
+ champion_is_preliminary: false,
+ champion_realized_auc_trend: [0.79, 0.81, 0.8, 0.82, 0.84, 0.83, 0.84].map((realized_auc, i) => ({
+ prediction_date: `2026-02-${String(18 + i).padStart(2, '0')}`,
+ realized_auc,
+ })),
+ likely_threshold: 0.09,
+ first_check_expected_at: null,
+ training_run_count: 2,
+} as AutoresearchPipelineApi
+
+export const Draft: Story = {
+ args: {
+ pipeline: {
+ ...BASE,
+ status: 'draft',
+ champion_holdout_auc: null,
+ champion_training_trend: [],
+ people_scored: null,
+ likely_count: null,
+ likely_threshold: null,
+ first_check_expected_at: null,
+ last_scored_at: null,
+ training_run_count: 0,
+ experiment_count: 0,
+ },
+ },
+}
+
+export const Training: Story = {
+ args: {
+ pipeline: {
+ ...Draft.args!.pipeline!,
+ status: 'bootstrapping',
+ training_run_count: 1,
+ experiment_count: 3,
+ live_training_run: LIVE_RUN,
+ },
+ },
+}
+
+export const AwaitingCheck: Story = { args: { pipeline: BASE } }
+
+export const AwaitingCheckLongHorizon: Story = {
+ args: {
+ pipeline: {
+ ...BASE,
+ name: 'Upgraders',
+ target_event: 'plan_upgraded',
+ horizon_days: 30,
+ likely_count: 312,
+ first_check_expected_at: '2026-03-28T01:00:00Z',
+ },
+ },
+}
+
+export const AwaitingCheckWithoutLikelyCount: Story = {
+ args: { pipeline: { ...BASE, likely_count: null, likely_threshold: null, first_check_expected_at: null } },
+}
+
+export const Confirmed: Story = { args: { pipeline: CONFIRMED } }
+
+export const ConfirmedRetraining: Story = { args: { pipeline: { ...CONFIRMED, live_training_run: LIVE_RUN } } }
diff --git a/products/autoresearch/frontend/AutoresearchModelCard.tsx b/products/autoresearch/frontend/AutoresearchModelCard.tsx
index 5e4a9181e098..25dc65400951 100644
--- a/products/autoresearch/frontend/AutoresearchModelCard.tsx
+++ b/products/autoresearch/frontend/AutoresearchModelCard.tsx
@@ -11,14 +11,55 @@ import { urls } from 'scenes/urls'
import { autoresearchLogic } from './autoresearchLogic'
import { AutoresearchLiveTrainingRunApi, AutoresearchPipelineApi } from './generated/api.schemas'
import { ModelCardMenu } from './ModelCardMenu'
-import { modelCardState } from './modelCardState'
+import { firstCheckCountdown, modelCardState } from './modelCardState'
import { modelQuality } from './modelQuality'
import { ModelQualityTag } from './ModelQualityTag'
import { MetricSparkline } from './pipeline/MetricSparkline'
import { pipelineQuestion } from './pipelineQuestion'
import { PipelineStatusTag } from './PipelineStatusTag'
+import { formatProbability } from './predictionSegments'
-function ScoredBody({ pipeline }: { pipeline: AutoresearchPipelineApi }): JSX.Element {
+const TEST_DATA_COLOR = 'var(--color-text-secondary)'
+const REAL_OUTCOME_COLOR = 'var(--success)'
+
+function Headline({ value, label }: { value: string; label: string }): JSX.Element {
+ return (
+ <div className="flex flex-col min-w-0">
+ <span className="text-xl font-semibold leading-tight">{value}</span>
+ <span className="text-xs text-secondary break-words">{label}</span>
+ </div>
+ )
+}
+
+function TrendChart({
+ points,
+ color,
+ title,
+}: {
+ points: { date: string; value: number }[]
+ color: string
+ title: string
+}): JSX.Element | null {
+ if (points.length < 2) {
+ return null
+ }
+ return (
+ <Tooltip title={title}>
+ <span className="shrink-0">
+ <MetricSparkline points={points} color={color} width={96} height={32} />
+ </span>
+ </Tooltip>
+ )
+}
+
+/** Until enough predictions are checked, Likely uses the fixed cut point, so the tooltip says so. */
+function likelyTooltip(threshold: number, confirmed: boolean): string {
+ return confirmed
+ ? `Likely means a score of ${formatProbability(threshold)} or more when the model last scored.`
+ : `Likely means a score of ${formatProbability(threshold)} or more until enough predictions are checked.`
+}
+
+function AwaitingCheckBody({ pipeline }: { pipeline: AutoresearchPipelineApi }): JSX.Element {
const quality = modelQuality({
holdoutAuc: pipeline.champion_holdout_auc,
realizedAuc: pipeline.champion_realized_auc,
@@ -29,30 +70,123 @@ function ScoredBody({ pipeline }: { pipeline: AutoresearchPipelineApi }): JSX.El
if (!quality) {
return <span className="text-secondary">No quality measured yet</span>
}
+ const countdown =
+ pipeline.first_check_expected_at && pipeline.horizon_days
+ ? firstCheckCountdown(pipeline.first_check_expected_at, pipeline.horizon_days)
+ : null
+ const trend = pipeline.champion_training_trend.map((point) => ({
+ date: String(point.iteration_number),
+ value: point.best_holdout_score,
+ }))
+ return (
+ <div className="flex flex-col gap-2">
+ <div className="flex items-center justify-between gap-2">
+ {pipeline.likely_count != null && pipeline.likely_threshold != null ? (
+ <Tooltip title={likelyTooltip(pipeline.likely_threshold, false)}>
+ <span className="min-w-0">
+ <Headline
+ value={humanFriendlyNumber(pipeline.likely_count)}
+ label={
+ pipeline.horizon_days
+ ? `people likely to do ${pipeline.target_event} in the next ${pluralize(pipeline.horizon_days, 'day')}`
+ : `people likely to do ${pipeline.target_event}`
+ }
+ />
+ </span>
+ </Tooltip>
+ ) : (
+ <span className="text-xs text-secondary break-words">{quality.sentence}</span>
+ )}
+ <TrendChart
+ points={trend}
+ color={TEST_DATA_COLOR}
+ title="Best test AUC per experiment of the run that trained this model"
+ />
+ </div>
+ <div className="flex items-center gap-1">
+ <ModelQualityTag
+ quality={quality}
+ holdoutAuc={pipeline.champion_holdout_auc}
+ realizedAuc={pipeline.champion_realized_auc}
+ />
+ <span className="text-xs text-secondary">{`on test data · AUC ${quality.auc.toFixed(2)}`}</span>
+ </div>
+ {countdown && (
+ <div className="flex flex-col gap-1">
+ <span className="text-xs text-secondary">{countdown.label}</span>
+ <LemonProgress percent={countdown.percent} strokeColor={TEST_DATA_COLOR} />
+ </div>
+ )}
+ </div>
+ )
+}
+
+function ConfirmedBody({ pipeline }: { pipeline: AutoresearchPipelineApi }): JSX.Element | null {
+ const quality = modelQuality({
+ holdoutAuc: pipeline.champion_holdout_auc,
+ realizedAuc: pipeline.champion_realized_auc,
+ liftAt10: pipeline.champion_lift_at_10,
+ isPreliminary: pipeline.champion_is_preliminary,
+ target: pipeline.target_event,
+ })
+ if (!quality) {
+ return null
+ }
const trend = pipeline.champion_realized_auc_trend.map((point) => ({
date: point.prediction_date,
value: point.realized_auc,
}))
return (
- <div className="flex items-center justify-between gap-2">
- <div className="flex flex-col gap-1 min-w-0">
- <div className="flex items-center gap-1">
+ <div className="flex flex-col gap-2">
+ <div className="flex items-center justify-between gap-2">
+ {pipeline.champion_lift_at_10 != null ? (
+ <Headline value={`${pipeline.champion_lift_at_10.toFixed(1)}× lift`} label={quality.sentence} />
+ ) : (
+ <span className="text-xs text-secondary break-words">{quality.sentence}</span>
+ )}
+ <TrendChart points={trend} color={REAL_OUTCOME_COLOR} title="Realized AUC on recent checked dates" />
+ </div>
+ <div className="flex flex-wrap items-center gap-x-2 gap-y-1">
+ <span className="flex items-center gap-1">
<ModelQualityTag
quality={quality}
holdoutAuc={pipeline.champion_holdout_auc}
realizedAuc={pipeline.champion_realized_auc}
/>
- <span className="text-xs text-secondary">{quality.basis}</span>
- </div>
- <span className="text-xs text-secondary break-words">{quality.sentence}</span>
+ <span className="text-xs text-secondary">{`confirmed · real AUC ${quality.auc.toFixed(2)}`}</span>
+ </span>
+ {pipeline.likely_count != null && pipeline.likely_threshold != null && (
+ <Tooltip title={likelyTooltip(pipeline.likely_threshold, true)}>
+ <span className="text-xs text-secondary">
+ {`${humanFriendlyNumber(pipeline.likely_count)} people likely`}
+ </span>
+ </Tooltip>
+ )}
</div>
- {trend.length > 1 && (
- <Tooltip title="Realized AUC on recent checked dates">
- <span className="shrink-0">
- <MetricSparkline points={trend} width={96} height={32} />
- </span>
- </Tooltip>
- )}
+ </div>
+ )
+}
+
+function RetrainingStrip({
+ liveRun,
+ liveAuc,
+}: {
+ liveRun: AutoresearchLiveTrainingRunApi
+ liveAuc: number | null
+}): JSX.Element {
+ const details = [
+ `experiment ${liveRun.experiment_count} of ${liveRun.iteration_budget}`,
+ liveRun.best_holdout_score != null
+ ? `best test AUC ${liveRun.best_holdout_score.toFixed(2)}${liveAuc != null ? ` vs live ${liveAuc.toFixed(2)}` : ''}`
+ : null,
+ ]
+ return (
+ <div className="rounded border px-2 py-1 text-xs text-secondary">
+ <span className="font-semibold text-primary">Retraining</span>
+ {details
+ .filter(Boolean)
+ .map((detail) => ` · ${detail}`)
+ .join('')}
</div>
)
}
@@ -63,14 +197,10 @@ function TrainingBody({ liveRun }: { liveRun: AutoresearchLiveTrainingRunApi | n
}
return (
<div className="flex flex-col gap-1">
- <div className="flex items-center justify-between gap-2 text-xs">
- <span className="font-semibold">
- {`Experiment ${liveRun.experiment_count} of ${liveRun.iteration_budget}`}
- </span>
- {liveRun.best_holdout_score != null && (
- <span className="text-secondary">{`Best AUC so far ${liveRun.best_holdout_score.toFixed(2)}`}</span>
- )}
- </div>
+ <Headline
+ value={liveRun.best_holdout_score != null ? liveRun.best_holdout_score.toFixed(2) : 'No score yet'}
+ label={`Best test AUC so far · experiment ${liveRun.experiment_count} of ${liveRun.iteration_budget}`}
+ />
<LemonProgress percent={(liveRun.experiment_count / liveRun.iteration_budget) * 100} />
{liveRun.latest_agent_description && (
<span className="text-xs text-secondary truncate" title={liveRun.latest_agent_description}>
@@ -133,13 +263,20 @@ export function AutoresearchModelCard({ pipeline }: { pipeline: AutoresearchPipe
{pipeline.name} · {pipeline.target_event}
</span>
</div>
- <div className="rounded border bg-surface-secondary p-3">
- {state === 'training' ? (
- <TrainingBody liveRun={pipeline.live_training_run} />
- ) : state === 'draft' ? (
- <DraftBody pipeline={pipeline} />
- ) : (
- <ScoredBody pipeline={pipeline} />
+ <div className="flex flex-col gap-1">
+ <div className="rounded border bg-surface-secondary p-3">
+ {state === 'training' ? (
+ <TrainingBody liveRun={pipeline.live_training_run} />
+ ) : state === 'draft' ? (
+ <DraftBody pipeline={pipeline} />
+ ) : state === 'awaiting_check' ? (
+ <AwaitingCheckBody pipeline={pipeline} />
+ ) : (
+ <ConfirmedBody pipeline={pipeline} />
+ )}
+ </div>
+ {state !== 'training' && pipeline.live_training_run && (
+ <RetrainingStrip liveRun={pipeline.live_training_run} liveAuc={pipeline.champion_holdout_auc} />
)}
</div>
<div className="flex flex-wrap items-center justify-between gap-x-3 gap-y-1 text-xs text-secondary mt-auto">
diff --git a/products/autoresearch/frontend/modelCardState.test.ts b/products/autoresearch/frontend/modelCardState.test.ts
index a5d1ebdbb7d5..451cefafd21a 100644
--- a/products/autoresearch/frontend/modelCardState.test.ts
+++ b/products/autoresearch/frontend/modelCardState.test.ts
@@ -1,5 +1,7 @@
+import { dayjs } from 'lib/dayjs'
+
import { AutoresearchPipelineApi } from './generated/api.schemas'
-import { modelCardState } from './modelCardState'
+import { firstCheckCountdown, modelCardState } from './modelCardState'
describe('modelCardState', () => {
const liveRun: AutoresearchPipelineApi['live_training_run'] = {
@@ -10,15 +12,92 @@ describe('modelCardState', () => {
latest_agent_description: 'baseline',
latest_summary: null,
}
+ const noChampion = { champion_holdout_auc: null, champion_realized_auc: null, champion_is_preliminary: null }
+ const awaiting = { champion_holdout_auc: 0.81, champion_realized_auc: null, champion_is_preliminary: null }
+ const confirmed = { champion_holdout_auc: 0.81, champion_realized_auc: 0.78, champion_is_preliminary: false }
+
+ test.each([
+ { name: 'draft', status: 'draft' as const, live: false, champion: noChampion, expected: 'draft' },
+ {
+ name: 'draft with a live run',
+ status: 'draft' as const,
+ live: true,
+ champion: noChampion,
+ expected: 'training',
+ },
+ {
+ name: 'first training run',
+ status: 'bootstrapping' as const,
+ live: false,
+ champion: noChampion,
+ expected: 'training',
+ },
+ {
+ name: 'no realized AUC',
+ status: 'running' as const,
+ live: false,
+ champion: awaiting,
+ expected: 'awaiting_check',
+ },
+ {
+ name: 'preliminary realized AUC',
+ status: 'running' as const,
+ live: false,
+ champion: { ...confirmed, champion_is_preliminary: true },
+ expected: 'awaiting_check',
+ },
+ { name: 'realized AUC', status: 'paused' as const, live: false, champion: confirmed, expected: 'confirmed' },
+ {
+ name: 'retrain of a confirmed model',
+ status: 'running' as const,
+ live: true,
+ champion: confirmed,
+ expected: 'confirmed',
+ },
+ {
+ name: 'retrain before the first check',
+ status: 'running' as const,
+ live: true,
+ champion: awaiting,
+ expected: 'awaiting_check',
+ },
+ ])('$name is $expected', ({ status, live, champion, expected }) => {
+ expect(modelCardState({ status, live_training_run: live ? liveRun : null, ...champion })).toEqual(expected)
+ })
+})
+
+describe('firstCheckCountdown', () => {
+ const now = dayjs('2026-03-10T12:00:00Z')
+
+ test.each([
+ {
+ name: 'short horizon counts days',
+ checkAt: '2026-03-13T01:00:00Z',
+ horizon: 7,
+ label: 'First real check in 3\u00a0days',
+ },
+ {
+ name: 'part of a day rounds up',
+ checkAt: '2026-03-10T13:00:00Z',
+ horizon: 7,
+ label: 'First real check in 1\u00a0day',
+ },
+ {
+ name: 'long horizon shows the date',
+ checkAt: '2026-03-30T01:00:00Z',
+ horizon: 30,
+ label: 'First real check on Mar 30',
+ },
+ { name: 'a past date is due', checkAt: '2026-03-09T01:00:00Z', horizon: 7, label: 'First real check is due' },
+ ])('$name', ({ checkAt, horizon, label }) => {
+ expect(firstCheckCountdown(checkAt, horizon, now).label).toEqual(label)
+ })
test.each([
- { status: 'draft' as const, live: false, expected: 'draft' },
- { status: 'draft' as const, live: true, expected: 'training' },
- { status: 'bootstrapping' as const, live: false, expected: 'training' },
- { status: 'running' as const, live: true, expected: 'training' },
- { status: 'running' as const, live: false, expected: 'scored' },
- { status: 'paused' as const, live: false, expected: 'scored' },
- ])('$status with a live run: $live is $expected', ({ status, live, expected }) => {
- expect(modelCardState({ status, live_training_run: live ? liveRun : null })).toEqual(expected)
+ { checkAt: '2026-03-17T12:00:00Z', horizon: 7, percent: 0 },
+ { checkAt: '2026-03-14T00:00:00Z', horizon: 7, percent: 50 },
+ { checkAt: '2026-03-01T00:00:00Z', horizon: 7, percent: 100 },
+ ])('percent of the window passed is $percent', ({ checkAt, horizon, percent }) => {
+ expect(firstCheckCountdown(checkAt, horizon, now).percent).toBeCloseTo(percent)
})
})
diff --git a/products/autoresearch/frontend/modelCardState.ts b/products/autoresearch/frontend/modelCardState.ts
index 5c364ed1a9b9..98d2c0faee04 100644
--- a/products/autoresearch/frontend/modelCardState.ts
+++ b/products/autoresearch/frontend/modelCardState.ts
@@ -1,14 +1,61 @@
+import { Dayjs, dayjs } from 'lib/dayjs'
+import { pluralize } from 'lib/utils/strings'
+
import { AutoresearchPipelineApi } from './generated/api.schemas'
-export type ModelCardState = 'training' | 'draft' | 'scored'
+export type ModelCardState = 'draft' | 'training' | 'awaiting_check' | 'confirmed'
-/** A live training run wins over the status, so a retrain of a live model shows its progress. */
+/**
+ * A live training run shows its progress only while the model has no champion. A retrain of a
+ * model with a champion keeps the champion's body, and the card adds a retraining strip.
+ */
export function modelCardState({
status,
live_training_run,
-}: Pick<AutoresearchPipelineApi, 'status' | 'live_training_run'>): ModelCardState {
- if (live_training_run || status === 'bootstrapping') {
+ champion_holdout_auc,
+ champion_realized_auc,
+ champion_is_preliminary,
+}: Pick<
+ AutoresearchPipelineApi,
+ 'status' | 'live_training_run' | 'champion_holdout_auc' | 'champion_realized_auc' | 'champion_is_preliminary'
+>): ModelCardState {
+ const hasChampion = champion_holdout_auc != null || champion_realized_auc != null
+ if (!hasChampion && (live_training_run || status === 'bootstrapping')) {
return 'training'
}
- return status === 'draft' ? 'draft' : 'scored'
+ if (status === 'draft') {
+ return 'draft'
+ }
+ // The same rule as the `confirmed` basis in modelQuality: a preliminary realized AUC is not a confirmation.
+ return champion_realized_auc != null && !champion_is_preliminary ? 'confirmed' : 'awaiting_check'
+}
+
+/** Horizons up to this many days count down in days. Longer horizons show the date. */
+const COUNTDOWN_MAX_DAYS = 14
+
+export interface FirstCheckCountdown {
+ label: string
+ /** How much of the outcome window has passed, from 0 to 100. */
+ percent: number
+}
+
+export function firstCheckCountdown(
+ firstCheckExpectedAt: string,
+ horizonDays: number,
+ now: Dayjs = dayjs()
+): FirstCheckCountdown {
+ const checkAt = dayjs(firstCheckExpectedAt)
+ const hoursLeft = checkAt.diff(now, 'hour', true)
+ const percent = Math.min(100, Math.max(0, 100 * (1 - hoursLeft / (horizonDays * 24))))
+ if (hoursLeft <= 0) {
+ return { label: 'First real check is due', percent }
+ }
+ const daysLeft = Math.ceil(hoursLeft / 24)
+ return {
+ label:
+ horizonDays <= COUNTDOWN_MAX_DAYS
+ ? `First real check in ${pluralize(daysLeft, 'day')}`
+ : `First real check on ${checkAt.format('MMM D')}`,
+ percent,
+ }
}
diff --git a/products/autoresearch/frontend/modelQuality.ts b/products/autoresearch/frontend/modelQuality.ts
index 58d4953c874e..00b559a5e90b 100644
--- a/products/autoresearch/frontend/modelQuality.ts
+++ b/products/autoresearch/frontend/modelQuality.ts
@@ -40,6 +40,7 @@ function modelQualityVerdict(auc: number): ModelQualityVerdict {
function liftSentence(liftAt10: number | null | undefined, target: string, confirmed: boolean): string {
if (liftAt10 == null) {
// A confirmed model has realized metrics, so the API leaves lift null only when no one did the target that day.
+ // An unconfirmed model card shows its Likely count instead, so this line is the fallback for a card without one.
return confirmed ? `No one did ${target} in the latest check` : 'Not checked against real outcomes yet'
}
return `Top 10% are ${liftAt10.toFixed(1)}× more likely to do ${target}`