: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(autoresearch): clarify accuracy stats, matrix and event names (#115290)
posthog[bot]4842e1c5b367
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 581573ae71bb..35b9216ae276 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6563,45 +6563,45 @@ snapshots:products-autoresearch-lifecycle-strip--validated-champion--light:hash: v1.k794b7964.131ecc736b38defef5b8ba34fa9836f1d2d5132e1d109e4b995b9591a5d9255c.759giT71A_8sdMCqx-FasPgdZzZWHgRvaoUmqVtYYKwproducts-autoresearch-model-card--awaiting-check--dark:- hash: v1.k794b7964.d0c4b837aed2340580cd64fcaea327145813c7059755c0d1ecb8ac37db523c9c.EDQGSSHmD19QsqrAXbeRBy2xQ_ncxQ0uEi1Vurn2GTM+ hash: v1.k794b7964.b056234a14274cf4dabf766f8ce5bbb4f30686b0f39c8986beabed6e61236ed9._tHJm3TIgLh-acm6BpsMoysLaVDUs5U0FZwk-XqwBkoproducts-autoresearch-model-card--awaiting-check--light:- hash: v1.k794b7964.5bf4a652830591e22ba932b205c1b9fc971ccca7cc8998e3b5b12e80789dc644.x3Zss-7B1weoMuvViz6vQDL5zzT5tCVeBhm6__eX4Pk+ hash: v1.k794b7964.c852c837d5257dce5666ec6728e35c7544e0b14b73776bf231de9f8445592a11.51hAYxuyZyU0bJvT_3bQWE99EUzNOr9wQo-C2VT1xqMproducts-autoresearch-model-card--awaiting-check-long-horizon--dark:- hash: v1.k794b7964.f5f88b6745f7bfacf9bfd3ef83dbf938d92be62492f0ab4ed576c92aef541d7b.xUxsBctJvFgDLdGVYEW5u93I4hsqF9jeoZU5_SUBs6g+ hash: v1.k794b7964.606a012055c68cbad2df4e046662f45708bae09b37cbfe6f64e58aec71741ef8.CK9KLfTE9WcBJtNB3B-zF762dzi72OGJn1qEH7Od2KQproducts-autoresearch-model-card--awaiting-check-long-horizon--light:- hash: v1.k794b7964.6cfc41c038fff8f43911ff67989e922de4519d80b7dce505e88274cf9fb14dff.VCMAfDPJBS14sTWlxUMPTg00ZvnbQ1cvOvi75YHy7vU+ hash: v1.k794b7964.714049ddba6315508cdf2df2241aa5baf175dc3d21794b618b92e3f90214d571.7LsPBceXRrm0dLjX67D7CZsboeq7hckum8Pg999nlqEproducts-autoresearch-model-card--awaiting-check-without-likely-count--dark:- hash: v1.k794b7964.fa9128a2c665e012372016fe6de76e472ce39693299398e521787df9145c01a2.Tzva3cwDscvroRQDNmGTaNZFuKh1Xk3IpLVKp40Akm8+ hash: v1.k794b7964.646b615f503e4be4549069326eac807423c333514299b9ae065dedf931fe1e8d.GbY7KQeTN8_acds_yPpyDkH2Nbj_dq0J4lkC_mvG_wkproducts-autoresearch-model-card--awaiting-check-without-likely-count--light:- hash: v1.k794b7964.facd8b0a9f18a67b5201de155edaa7a2c525f761ccc76f7487412884985bcd60.kq612Xhu2k_A_Q9gQpUqqsDbfytVIe_QcHHRmdxZIVc+ hash: v1.k794b7964.3480f2e3fb8aa02079388e69564f9e3502459cfa8352c3738e9225fd551910bb.AYd_ZcQ5d9O04MYtf3UgXk4Qhynk5zyf_CaVFvDQSOsproducts-autoresearch-model-card--confirmed--dark:- hash: v1.k794b7964.c8a65abbd3ce09b8b0f00d978c43bd083e2fc4a2a4bbd04841d16297d286b7ec.95EPpNIJb_jAY8Q5-gKw9f8deLfpD36ZjkCocJoYw60+ hash: v1.k794b7964.dfadd13d662b49ad27d39ae1e7a159525bf5bf87a90a2e2f74a1c175d49f37f9.0JelBithkipyfqp5Noco-3okH_tM1o3GytYrraRMEJAproducts-autoresearch-model-card--confirmed--light:- hash: v1.k794b7964.933313db18507b0065864ec7ff98f7b2cff1692348b155e93adfcea14f72ed7f.11puCCTL4IP0fCXV_oOb3z5SIOeMBf0GbVvS_W5vhtw+ hash: v1.k794b7964.cb7ad0a101a8c5706356935ad94508a872546d5960c36cdb9a28f4c9b0aa8dc0.3vtiJANttiBwfCBvGT_B8PUkOkDPVNZV572QPGmz88gproducts-autoresearch-model-card--confirmed-retraining--dark:- hash: v1.k794b7964.5021416edf991c93cc0e91bd0718a9d4ad90d01423d2ff1c4e74c5677fb81bb3.Po7UU9vxVppgHMgZU9EaahuM1ZLgC7ueUA8CnK3gYus+ hash: v1.k794b7964.b87054adc04b2471b7b58ff48e76794de93ba7175531c6a36c7951473b2e0757.FUTc4YewRDSKJgo_I1sAC-3PwTo-yobhcZoyUTpI5Tcproducts-autoresearch-model-card--confirmed-retraining--light:- hash: v1.k794b7964.571893710d8f09efe512dbe906d1265f33f7cf7e537807dd2b3d5f0dc2faed91.4CbLaR4dEKjeP4Lc8cHqGHssgQlGo-LlDQYRgvFezbs+ hash: v1.k794b7964.8578c4676a64f77057a8c2ee2633cafa9223cf10c282a01d569ddd5c91bf0559.ilI1fJkVPCKd0mbfWDxU-4em181mjyXaf6xrTeVew1Yproducts-autoresearch-model-card--draft--dark:- hash: v1.k794b7964.c5cd95350db692fbff81d2f5049547a5a2a06bbbc8c7445654e5c0f1a3c4ca8e.AObIoQAoS70zxfPfmLnNY0kZPAUiygI5TwRnYKpkMlw+ hash: v1.k794b7964.81145212eebad57ac432fdc9f02184c3b93e2beaf1ecd39c06b9b1ffd3dd5f9b.PQoAXy1Udjo0qlIxYtnS8lhl5fJXrkb-4X56nVio6nkproducts-autoresearch-model-card--draft--light:- hash: v1.k794b7964.5fe35a8ac4491a88eb83b822301eff24e6f0bd6da0db81d0e7a8c0760f1468d3.IYNg7FBpccTnNYl04nGAnBGnKOmhgMbB4X4l0c3YvC4+ hash: v1.k794b7964.3c616c7e36d5fd229e302e60922969677fe723890f2dbf6c329a705c3ce95669.jsCdOMXuKPoT0RhQQr-_lS4-vQ4JmXgEO5InlxlF5bAproducts-autoresearch-model-card--training--dark:- hash: v1.k794b7964.88f39e3d0fbb43768a2cc61642017cb712ba6dbda2c40e1d99be11dbd87d198e.iAXGkjxlkUg5I1g5gl5H-XTbduzQFWYZfAvgZG60FzA+ hash: v1.k794b7964.cd5afd235dacbb2740cdf95a929cdb88eef0fabac1cb10287f578d554e165b99.AxWi1MV4FRxmq-OCiPsM8ZOKC1QUhzqqN2uWiYwIsdsproducts-autoresearch-model-card--training--light:- hash: v1.k794b7964.8e81700643972d08ca45a0abc5e0b82b9b0a88566cc308b48c219301d42d8e5f.VhTJ3bXOU3KzsyClYUCH41SjpCm4bgfA4pAnCC5DMvI+ hash: v1.k794b7964.8549b3b132dd11b9f618b96e48d41048e478d3de09cb360f4d9367ced26f4131.YQv_5y5fFu_B1cvZPcxGL8TnnvzbEvoBJD5Y-oQvjaMproducts-autoresearch-model-detail-scene--accuracy--narrow--dark:- hash: v1.k794b7964.0131fa2a83a07edaa2c861515efb408fe43304690fc5d5d38aa3816a3dd49a23.J9awvFmY6Pn1s-oWPqAnejGDIAwddfAHgY8xbNcFyJk+ hash: v1.k794b7964.ab6cd49b1bd74e55cdfc33e06cbfaea05af40f5423c9a354f2f0206f0b757755.GrpIVBW2vJXjMK0cAm_bPc0wDJN0yjE_PZ5Sqemb9F8products-autoresearch-model-detail-scene--accuracy--narrow--light:- hash: v1.k794b7964.3a8de6d5fad0b1f3e307af7bca498dd33b6a59bc89ce31d429a4cf066cf7128b.r5aiv5W6zb2ru9_PycWf1I6lMRQAf1RpYgzjFgexwxI+ hash: v1.k794b7964.0d14631f0afdcd7aa5601ee60740636b06f5b8701b3b84659016f55dd50c5e36.Rff5tsMEhih7Q6jnXaojrhaq_dq8ShBZoW_sx4mJWe8products-autoresearch-model-detail-scene--accuracy--wide--dark:- hash: v1.k794b7964.22101685dac81aca3c1571f854015397be350c53305fb3869c7c26bf2b5a5917.3ig445ptf8q-cA0jvU0lo6sxJcgXMOpKnQzPrkjdmqw+ hash: v1.k794b7964.be30fc55698840326ecb7ad998616a24eadcd9b1ff10413cc14b7894c9930f8a.Ir0oYLj5Vk8seoGSVk4o-_jWDmevr-Nth5G082R7SzUproducts-autoresearch-model-detail-scene--accuracy--wide--light:- hash: v1.k794b7964.8a9cfef58f60664cbac82a55c0d1e95651ee0ff147ab0f207badd7d4cb11b546.pFG9Zq4rulyBRBLHksTFzWMpsIX_jRMTR-Lw-yVTCZ8+ hash: v1.k794b7964.0cf1ce7f42431db447f057023346cd63cc8cddb5e45e6f41a5c1fc9b40ea717e.6X-N8RqCuyLJCXCvQUeiBKvbcDFuUbkfYUd_ngR_O6Mproducts-autoresearch-model-detail-scene--accuracy-before-precision-recall--wide--dark:- hash: v1.k794b7964.72015c93da744ac165c241ba268d7d8217f61294e15b794a5a49a26dae1651a0.-WLIXPLFx1bqZ38wxHMYgTkpik4ujwXsHjGL3RUsGvA+ hash: v1.k794b7964.2200b8e78bd0b6233eb155370f90b744fdd4bbf8765144a4801f9e9d72f2bbd3.dNmkJFFXuPHe_L4ocSeLTIACMvFmnvxIZpdhv4UwVNwproducts-autoresearch-model-detail-scene--accuracy-before-precision-recall--wide--light:- hash: v1.k794b7964.a2cb6200ea532a239a92826eea1e652bf90631cff34f043b6d8a11b52e7e1e34.3Fmsd_-HZsxTxIyp-hJXbhJmfolQnhq8rB1UbuE118w+ hash: v1.k794b7964.b9002eda53b32c688750ed9a09909356359135c1d697cbe011d1f3af170e61e0.ZW7Kz4xxkZU06OMpIB8KsDIxouakUNKAbgWYoCvApwkproducts-autoresearch-model-detail-scene--agent-research-narrow--narrow--dark:hash: v1.k794b7964.30d2a61a4d85714b8aa85d7a3551956a34d963b3c08fdf8543bac8ff298e393d.JWWJ93sVqwsvhTlOfR5BbtFkHXWx_0vKG74yU5gFln0products-autoresearch-model-detail-scene--agent-research-narrow--narrow--light:@@ -6613,35 +6613,35 @@ snapshots:products-autoresearch-model-detail-scene--coverage-below-cap--narrow--dark:hash: v1.k794b7964.152ee821492c266c89b740640ef7a91a4f67257a384bc2c6d526cc84df685d14.Rw2tjHmhWsFwm2-n-i1sOVP227F8AkhWTS4Lt96rV8kproducts-autoresearch-model-detail-scene--coverage-below-cap--narrow--light:- hash: v1.k794b7964.8b85874a8510cc9ac620a6360f915ef9fad9ff9168381f153b4476edeb257305.7lEqS90V1PKLx7mI-kuNhYFrm7FvermoDgbRKCG-_tA+ hash: v1.k794b7964.49da15b6115df1ac9364011595574996e88cf019db42521523a5c2baa9f9b1ed.OViBJ-jKe1xbmR5VT9GEBzjaKGOlGfOmy3vt55yJzlwproducts-autoresearch-model-detail-scene--coverage-below-cap--wide--dark:- hash: v1.k794b7964.2a7460ae7c4eae10331edb2e54a10bf944932a01ad4b8d1eb408dede6d05ee03.vHL1FF5inDvRNfzNWYhL6HOINnyNZlH-lwP5f0mSiFE+ hash: v1.k794b7964.6a7b41bb0e7beedd0bb605cd56099c6e0b68e0763f05ea70466b0792b01bea65.rxmdkr5Hds-9epbgQHCU1jhMN6pjWxhse5uOkXxKcqYproducts-autoresearch-model-detail-scene--coverage-below-cap--wide--light:- hash: v1.k794b7964.714b9d38ec4d9a9951aa6a264ceccc95770029fbf21e67f0fe4fde230c9e1f2e.ZjOuLQQvIgd_YVEMe2FGnlm2YM_nOGrYNxSkcwiFRvM+ hash: v1.k794b7964.b7d2d5609f5244526f724f4bd1f985809ed173037c3f12d2186b6a84b33a2a40.KPa_6jMPIsFyDRBQ8x0OYBaQRabumSRljZF0V0Ppfbkproducts-autoresearch-model-detail-scene--coverage-rolling-mid-cycle--narrow--dark:hash: v1.k794b7964.0e9f6a634a0ce036704e1ae40a3a269e520bb35965107459543d845835129f58.8wO2TTB9MQvDYz419LZaHyj792zNN0nuSgWi9IOkcpIproducts-autoresearch-model-detail-scene--coverage-rolling-mid-cycle--narrow--light:hash: v1.k794b7964.600621aa236383eef70dc1f93a10227a8ce6dbdcd52647237d8c9bcb8cdbfe9e._-R_fAQOI97_1m_hsbtEMILj9l19VGbisuIuqd_69zoproducts-autoresearch-model-detail-scene--coverage-rolling-mid-cycle--wide--dark:- hash: v1.k794b7964.905ec0ac29c887b94f15d33abc76ca9f5e104755d4bfacdfb79fe4c446faf717.0xSOAyw0fVXIixI_a_XNfUJCqZotC9W9mgvMNILdwzA+ hash: v1.k794b7964.9de0a95c8650d81633b5a014306cc9dba9e2fa0fbf732a22c4b43a06e298a677.ShGdwT0g2nNVVdCP1R7qxV6Q0lVKhONgs9mNWTA1UnEproducts-autoresearch-model-detail-scene--coverage-rolling-mid-cycle--wide--light:- hash: v1.k794b7964.a972f40d1aee3ed43147f57b29cbdd13c2a4e4dd58dc9e763ef91573990e883c.u_XZhFTgtkJ9TQiWD-06D9JQD1zFKUpuLKT8KRKchsY+ hash: v1.k794b7964.25e07fb2d2107ed96de9d03d0428f51ae61eb16f841050869a581d723258c959.KRtSWvEhwEuncr2ol08z8iIu7V2xxsbgwSNt85R1R_Qproducts-autoresearch-model-detail-scene--coverage-with-failed-runs--narrow--dark:hash: v1.k794b7964.5c238af99fab1ef0a4bef33f7837051ff977331581e39db887102bd673d2b895.bOwR6Kx4sbqPEEBS0t_ZcOqavzfAZ6gDOuA6z333akQproducts-autoresearch-model-detail-scene--coverage-with-failed-runs--narrow--light:hash: v1.k794b7964.fcc55a250637ae170122988f33efb7fffb8bb56e5c35317adf7456eb1f84387c.9eZcjMzAx5TX821Zl8bvWDoL3QSkSw-fNCzb4xKClF4products-autoresearch-model-detail-scene--coverage-with-failed-runs--wide--dark:- hash: v1.k794b7964.d370442d7b2b91bbe29e09f1b1b184ac10568bc946ab58c013a14e6de3dbc5b2.YA1HzZ9gKlsmt3z8W_SPF36y32G75KrRlPjGDpxIn1w+ hash: v1.k794b7964.9dd89ae970aca27680b939c019f8059a5d663877792ef275e74d6168bdc9dde5.KZj-dscfV0eEI0FfEhY7MMHj0wlwrl9RlRAfmi2sHroproducts-autoresearch-model-detail-scene--coverage-with-failed-runs--wide--light:- hash: v1.k794b7964.7fb45eaa6040a6f20dd015543842635fc88d068203a295d299dbf302f418032b.56I2KWH6Azy_G23S1LLxllPyaNcvRh9Qdt62a1VgvqE+ hash: v1.k794b7964.f14c2b3b63be611e3cdeeed2245735275173023ebe329b5fc1c59db97eec06a7.4gkAnNzehTz5TnzTvL5ZRcGFFtBZuQHrqec9fivPXAAproducts-autoresearch-model-detail-scene--narrow--narrow--dark:- hash: v1.k794b7964.8c38dd469af3a3c2fa3003ce281be5d58987209adf0c8aace518f7880dca44a7.XiFUy5mYsM23iEy1LSGhGBbAbK-1ipKxZa4tEAhiGQs+ hash: v1.k794b7964.e2ce91abe916cc3d09981c402e94c5955916495ea349799a305f81701d29b614.8X3qhSGbaIwj_LXSOsSn_Z4ltPGVduDSZZWBzFM9Nmcproducts-autoresearch-model-detail-scene--narrow--narrow--light:- hash: v1.k794b7964.0cc69b5560f729652f3ba1734ba4b2eedcc50cc20a24c7396bf6aadf9c9ed0d0.rjxp-hLAgxYedXpksnvsbqnWC3pqDz_V9mc9aoyTW84+ hash: v1.k794b7964.34f873e1e7b38e50ef3d10247e46bc4b7ba1783d034edf72aa481272e6991cb1.xFlmMX2BFoLZvwPTTJTRCkc_jvPBk96TmD_dkIHv-ksproducts-autoresearch-model-detail-scene--wide--wide--dark:- hash: v1.k794b7964.0a93aadb03edbceced1fe280d5ee0914b6bb6b943027df848a0700f0a8e4584e.dFrYrbOfMUuIt7x-RUa8XWGWWhYkLphH7G6GCWPr7iI+ hash: v1.k794b7964.45c778a22654973af271374665ae90b360501f18f1120c1e6080d00bf3e6478a.yenXnAEGj_qMppblaiuW3r5phbVYzqT3J-nD4aPizRkproducts-autoresearch-model-detail-scene--wide--wide--light:- hash: v1.k794b7964.80ebf1b109236a53138a1337174cc37670ac9bc84bdc0c14845e78d1c75e172a.aG-YLj2Raw4ZMUX3ARP5Wn5VINR7WioYSrAw0R2WzS8+ hash: v1.k794b7964.0e0a17654d0069447e8fe931049ded5d55c96e6aa3c60a1b601282e396ce334d.JIJB_oDt2a3xzX9u0TS72b1GwQY-i1Xu9wWUaJ0jsRQproducts-autoresearch-probability-histogram--bimodal--dark:hash: v1.k794b7964.f95d3982e7c08f2e1b51655520f15e37293aa98e5ca87126a5653d2300bd776b.2G0LsuSx-SLqWn1Oxm_bUHSqfeDPFF6Pof0vDvhZEHMproducts-autoresearch-probability-histogram--bimodal--light:diff --git a/products/autoresearch/frontend/AGENTS.md b/products/autoresearch/frontend/AGENTS.mdindex 03b03bfc7548..eb48f477d074 100644--- a/products/autoresearch/frontend/AGENTS.md+++ b/products/autoresearch/frontend/AGENTS.md@@ -10,7 +10,7 @@ The product is mostly a backend, and the UI is deliberately thin — it reads st| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- || `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, 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. |+| `pipelineQuestion.ts` | The model's question in plain words ("Who will do “X” in the next N days?"), `eventName()` for event names in copy, and the header subtitle. || `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/`. || `autoresearchLogic.ts` | List logic — loads pipelines, lifecycle actions, and setup-status detection for the empty-state gate. |@@ -19,7 +19,7 @@ The product is mostly a backend, and the UI is deliberately thin — it reads st| `autoresearchPipelineLogic.ts` | Detail logic. Also maps the old `?tab=` keys to the four tabs, so saved links still open. || `pipelineLifecycle.ts` | The five lifecycle steps (question set to checked against reality) and which one is current. || `agentSearch.ts` | The agent's search across training runs: chart points, best score so far, AUC change per experiment, log groups and the latest agent notes. |-| `onlinePerformance.ts` | Accuracy tab helpers over the `online_performance` endpoint: the headline, the realized AUC series, predicted against actual by segment. |+| `onlinePerformance.ts` | Accuracy tab helpers over the `online_performance` endpoint: the stat tiles, the realized AUC series, predicted against actual by segment. || `predictionCoverage.ts` | Predictions tab coverage from the runs list: the measured summary and the coverage and score age per day. || `predictionSegments.ts` | The likelihood segments from the cut points the `online_performance` endpoint returns: lift over the base rate, or a fixed pair until then. || `PipelineStatusTag.tsx` | Status tag + tooltip shared by the list and detail scenes. |diff --git a/products/autoresearch/frontend/AutoresearchPipelineScene.tsx b/products/autoresearch/frontend/AutoresearchPipelineScene.tsxindex 782058e76f8a..c13d883f3a48 100644--- a/products/autoresearch/frontend/AutoresearchPipelineScene.tsx+++ b/products/autoresearch/frontend/AutoresearchPipelineScene.tsx@@ -22,7 +22,7 @@ import { PipelineSummary } from './pipeline/PipelineSummary'import { PredictionsTab } from './pipeline/PredictionsTab'import { ScoreNowButton } from './pipeline/ScoreNowButton'import { SetupTab } from './pipeline/SetupTab'-import { pipelineQuestion } from './pipelineQuestion'+import { pipelineQuestion, pipelineSubtitle } from './pipelineQuestion'export const scene: SceneExport = {component: AutoresearchPipelineScene,@@ -52,7 +52,7 @@ export function AutoresearchPipelineScene(): JSX.Element {<SceneContent><SceneTitleSectionname={heading}- description={pipeline?.name ?? null}+ description={pipeline ? pipelineSubtitle(pipeline) : null}resourceType={{ type: 'experiment' }}actions={<>diff --git a/products/autoresearch/frontend/modelQuality.test.ts b/products/autoresearch/frontend/modelQuality.test.tsindex 41dcf1a6726f..e828d9e8e2bf 100644--- a/products/autoresearch/frontend/modelQuality.test.ts+++ b/products/autoresearch/frontend/modelQuality.test.ts@@ -11,7 +11,7 @@ describe('modelQuality', () => {verdict: 'Weak',basis: 'confirmed',auc: 0.65,- sentence: 'Top 10% are 1.2× more likely to do signed_up',+ sentence: 'Top 10% are 1.2× more likely to do “signed_up”',},},{@@ -21,7 +21,7 @@ describe('modelQuality', () => {verdict: 'Strong',basis: 'confirmed',auc: 0.8,- sentence: 'Top 10% are 3.4× more likely to do signed_up',+ sentence: 'Top 10% are 3.4× more likely to do “signed_up”',},},{@@ -71,7 +71,7 @@ describe('modelQuality', () => {verdict: 'Fair',basis: 'confirmed',auc: 0.78,- sentence: 'No one did signed_up in the latest check',+ sentence: 'No one did “signed_up” in the latest check',},},{ name: 'no AUC gives no verdict', input: {}, expected: null },diff --git a/products/autoresearch/frontend/modelQuality.ts b/products/autoresearch/frontend/modelQuality.tsindex 00b559a5e90b..ba9617c169cc 100644--- a/products/autoresearch/frontend/modelQuality.ts+++ b/products/autoresearch/frontend/modelQuality.ts@@ -1,3 +1,5 @@+import { eventName } from './pipelineQuestion'+/*** AUC cutoffs for the quality verdict: Strong at or above `strong`, Fair at or above `fair`, Weak below.* They do not vary by base rate yet. Tune them here after dogfooding.@@ -41,9 +43,11 @@ function liftSentence(liftAt10: number | null | undefined, target: string, confiif (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 confirmed+ ? `No one did ${eventName(target)} in the latest check`+ : 'Not checked against real outcomes yet'}- return `Top 10% are ${liftAt10.toFixed(1)}× more likely to do ${target}`+ return `Top 10% are ${liftAt10.toFixed(1)}× more likely to do ${eventName(target)}`}/** Realized AUC measures real outcomes, so it wins over holdout AUC. Null when the model has no AUC at all. */diff --git a/products/autoresearch/frontend/onlinePerformance.test.ts b/products/autoresearch/frontend/onlinePerformance.test.tsindex 18366e2a5c01..e53153c31eb9 100644--- a/products/autoresearch/frontend/onlinePerformance.test.ts+++ b/products/autoresearch/frontend/onlinePerformance.test.ts@@ -1,5 +1,12 @@import { AutoresearchRunApi, ConfusionByCutoffApi, OnlinePerformanceRowApi } from './generated/api.schemas'-import { calibrationBySegment, pooledConfusion, realizedAucSeries, validatedPredictionDates } from './onlinePerformance'+import {+ accuracyStats,+ accuracySummary,+ calibrationBySegment,+ pooledConfusion,+ realizedAucSeries,+ validatedPredictionDates,+} from './onlinePerformance'function row(overrides: Partial<OnlinePerformanceRowApi>): OnlinePerformanceRowApi {return {@@ -77,9 +84,52 @@ describe('onlinePerformance', () => {datesWithoutCounts: 1,})expect(pooledConfusion(rows, 'likely')).toMatchObject({ flagged: 0, precision: null, recall: 0 })+ expect(accuracySummary(pooledConfusion(rows, 'top_10')!, 'top_10', 'File shared')).toEqual(+ 'For people scored from Feb 12 to Feb 13, 50.0% of the top 10% the model flagged did “File shared”, against 4.0% of everyone. They include 50.0% of everyone who did it.'+ )+ expect(accuracySummary(pooledConfusion(rows, 'likely')!, 'likely', 'File shared')).toBeNull()expect(pooledConfusion([row({ model_id: 'new', confusion: null })], 'top_10')).toBeNull()})+ test.each([+ {+ name: 'a checked date with outcomes',+ overrides: { lift_at_10: 3.44, mean_p_y: 0.033 },+ expected: [+ ['Strong', 'AUC 0.80, scored on Feb 10'],+ ['3.4×', 'Against everyone, scored on Feb 10'],+ ['3.0%', 'Predicted 3.3%, scored on Feb 10'],+ ['47,000', '1,410 did it, scored on Feb 10'],+ ],+ },+ {+ name: 'a checked date where no one did it',+ overrides: { realized_auc: null, lift_at_10: 0, mean_p_y: null, n_positive: 0, base_rate: 0 },+ expected: [+ ['—', 'No AUC, scored on Feb 10'],+ ['—', 'No one did it, scored on Feb 10'],+ ['0.0%', 'scored on Feb 10'],+ ['47,000', '0 did it, scored on Feb 10'],+ ],+ },+ {+ name: 'a checked date with outcomes but no lift',+ overrides: { lift_at_10: null, mean_p_y: 0.033 },+ expected: [+ ['Strong', 'AUC 0.80, scored on Feb 10'],+ ['—', 'Not measured, scored on Feb 10'],+ ['3.0%', 'Predicted 3.3%, scored on Feb 10'],+ ['47,000', '1,410 did it, scored on Feb 10'],+ ],+ },+ ])('accuracyStats names the scored date on every stat for $name', ({ overrides, expected }) => {+ const stats = accuracyStats(+ row({ n_scored: 47000, n_positive: 1410, base_rate: 0.03, ...overrides }),+ 'File shared'+ )+ expect(stats.map(({ value, detail }) => [value, detail])).toEqual(expected)+ })+test('validatedPredictionDates counts only completed validation runs that scored a model', () => {const scored = { per_model: { champion: { n_scored: 100 } } }const runs = [diff --git a/products/autoresearch/frontend/onlinePerformance.ts b/products/autoresearch/frontend/onlinePerformance.tsindex 25d29ddf5467..15b228515c69 100644--- a/products/autoresearch/frontend/onlinePerformance.ts+++ b/products/autoresearch/frontend/onlinePerformance.ts@@ -7,6 +7,7 @@ import {OnlinePerformanceRowApi,} from './generated/api.schemas'import { modelQuality } from './modelQuality'+import { eventName } from './pipelineQuestion'import {PredictionSegmentDefinition,PredictionSegmentThresholds,@@ -62,15 +63,20 @@ export function latestChampionRow(rows: OnlinePerformanceRowApi[]): OnlinePerforreturn rows.find((row) => row.emitted_role === 'champion') ?? null}-/** One sentence on what the model predicted for its newest matured date and what really happened. */-export function accuracyHeadline(row: OnlinePerformanceRowApi, target: string): string {- const date = dayjs(row.prediction_date).format('MMM D')- const outcome = `${row.n_positive.toLocaleString()} of ${row.n_scored.toLocaleString()} people scored on ${date} did ${target} (${percent(row.base_rate)})`- return row.mean_p_y != null ? `${outcome}. The model predicted ${percent(row.mean_p_y)}.` : `${outcome}.`+export interface AccuracyStat {+ key: 'ranking' | 'lift' | 'rate' | 'people'+ label: string+ value: string+ /** The supporting number and the date the stat covers. */+ detail: string+ tooltip: string}-/** How well the model ranked people on that date, in the same words as the model list. */-export function rankingSentence(row: OnlinePerformanceRowApi, target: string): string | null {+/** The four headline stats for the champion's newest checked date. Each stat names that date. */+export function accuracyStats(row: OnlinePerformanceRowApi, target: string): AccuracyStat[] {+ const date = `scored on ${dayjs(row.prediction_date).format('MMM D')}`+ // Lift has no meaning when no one did the target, and the backend reports 0 then.+ const lift = row.n_positive > 0 ? row.lift_at_10 : nullconst quality = modelQuality({holdoutAuc: null,realizedAuc: row.realized_auc,@@ -78,12 +84,41 @@ export function rankingSentence(row: OnlinePerformanceRowApi, target: string): sisPreliminary: false,target: '',})- if (!quality) {- return null- }- const lift =- row.lift_at_10 != null ? ` The top 10% were ${row.lift_at_10.toFixed(1)}× more likely to do ${target}.` : ''- return `Ranking quality is ${quality.verdict.toLowerCase()} (realized AUC ${quality.auc.toFixed(2)}).${lift}`+ return [+ {+ key: 'ranking',+ label: 'Ranking',+ value: quality?.verdict ?? '—',+ detail: quality ? `AUC ${quality.auc.toFixed(2)}, ${date}` : `No AUC, ${date}`,+ tooltip: `How well the model ranked people who did ${eventName(target)} above people who did not. Realized AUC 0.5 is a coin flip and 1 is a perfect ranking.`,+ },+ {+ key: 'lift',+ label: 'Top 10% lift',+ value: lift != null ? `${lift.toFixed(1)}×` : '—',+ detail:+ row.n_positive === 0+ ? `No one did it, ${date}`+ : lift != null+ ? `Against everyone, ${date}`+ : `Not measured, ${date}`,+ tooltip: `How many times more likely the top 10% were to do ${eventName(target)} than everyone the model scored.`,+ },+ {+ key: 'rate',+ label: 'Actual rate',+ value: percent(row.base_rate),+ detail: row.mean_p_y != null ? `Predicted ${percent(row.mean_p_y)}, ${date}` : date,+ tooltip: `The share of scored people who did ${eventName(target)}, against the average score the model gave them.`,+ },+ {+ key: 'people',+ label: 'People checked',+ value: row.n_scored.toLocaleString(),+ detail: `${row.n_positive.toLocaleString()} did it, ${date}`,+ tooltip: `The people the model scored on that date, and how many of them did ${eventName(target)} in the horizon.`,+ },+ ]}/** The champion's realized AUC per date, oldest first, for the trend chart. */@@ -167,7 +202,13 @@ export function pooledConfusion(rows: OnlinePerformanceRowApi[], cutoff: Accurac}}-/** The group of people a cutoff flags, in words that fit "Of {group}, ...". */+/** The dates the pooled counts cover, as "Feb 10 to Feb 14, 2026" or one date. */+export function confusionDateRange({ firstDate, lastDate }: Pick<PooledConfusion, 'firstDate' | 'lastDate'>): string {+ const last = dayjs(lastDate).format('MMM D, YYYY')+ return firstDate === lastDate ? last : `${dayjs(firstDate).format('MMM D')} to ${last}`+}++/** The group of people a cutoff flags, in words that fit "{share} of {group} did X". */function cutoffGroup(cutoff: AccuracyCutoff): string {switch (cutoff) {case 'top_10':@@ -179,19 +220,22 @@ function cutoffGroup(cutoff: AccuracyCutoff): string {}}-/** Precision and recall in plain words. Null when the cutoff flagged nobody. */-export function precisionRecallSentence(- confusion: PooledConfusion,- cutoff: AccuracyCutoff,- target: string-): string | null {+/** Hit rate against the overall rate, then coverage, over the pooled dates. Null when the cutoff flagged nobody. */+export function accuracySummary(confusion: PooledConfusion, cutoff: AccuracyCutoff, target: string): string | null {if (confusion.precision == null) {return null}- const precision = `Of ${cutoffGroup(cutoff)}, ${percent(confusion.precision)} did ${target}.`- return confusion.recall != null- ? `${precision} They include ${percent(confusion.recall)} of everyone who did.`- : `${precision} No one did ${target} in this period.`+ const { firstDate, lastDate } = confusion+ const period =+ firstDate === lastDate+ ? `For people scored on ${dayjs(lastDate).format('MMM D')}`+ : `For people scored from ${dayjs(firstDate).format('MMM D')} to ${dayjs(lastDate).format('MMM D')}`+ if (confusion.recall == null) {+ return `${period}, no one did ${eventName(target)}.`+ }+ const everyone = confusion.tp + confusion.fp + confusion.fn + confusion.tn+ const overall = (confusion.tp + confusion.fn) / everyone+ return `${period}, ${percent(confusion.precision)} of ${cutoffGroup(cutoff)} did ${eventName(target)}, against ${percent(overall)} of everyone. They include ${percent(confusion.recall)} of everyone who did it.`}/** When the first scored date matures: the earliest completed scoring run plus the horizon. */diff --git a/products/autoresearch/frontend/pipeline/ConfusionMatrixCard.tsx b/products/autoresearch/frontend/pipeline/ConfusionMatrixCard.tsxindex 4e7af29472fc..04025521c7f0 100644--- a/products/autoresearch/frontend/pipeline/ConfusionMatrixCard.tsx+++ b/products/autoresearch/frontend/pipeline/ConfusionMatrixCard.tsx@@ -1,25 +1,42 @@import { useActions, useValues } from 'kea'-import { LemonBanner, LemonSegmentedButton } from '@posthog/lemon-ui'+import { LemonBanner, LemonSegmentedButton, Tooltip } from '@posthog/lemon-ui'import { dayjs } from 'lib/dayjs'import { autoresearchPipelineLogic } from '../autoresearchPipelineLogic'-import { ACCURACY_CUTOFFS, PooledConfusion, percent } from '../onlinePerformance'-import { MetricCard } from './MetricCard'+import { ACCURACY_CUTOFFS, confusionDateRange, percent } from '../onlinePerformance'+import { eventName } from '../pipelineQuestion'import { SectionCard } from './SectionCard'-function dateRange({ firstDate, lastDate }: PooledConfusion): string {- const last = dayjs(lastDate).format('MMM D, YYYY')- return firstDate === lastDate ? last : `${dayjs(firstDate).format('MMM D')} to ${last}`+function Cell({ count, label, tint }: { count: number; label: string; tint: string }): JSX.Element {+ return (+ <div className={`rounded p-3 min-w-0 ${tint}`}>+ <div className="text-xl @xl:text-2xl font-semibold tabular-nums">{count.toLocaleString()}</div>+ <div className="text-xs text-secondary">{label}</div>+ </div>+ )}-function Cell({ count, label }: { count: number; label: string }): JSX.Element {+function Rate({+ label,+ value,+ detail,+ tooltip,+}: {+ label: string+ value: number | null+ detail: string+ tooltip: string+}): JSX.Element {return (- <td className="border p-2 text-right">- <div className="text-base font-semibold tabular-nums">{count.toLocaleString()}</div>- <div className="text-xs text-muted">{label}</div>- </td>+ <div className="min-w-0 max-w-32 self-center">+ <Tooltip title={tooltip}>+ <div className="text-xs font-semibold text-muted cursor-help">{label}</div>+ </Tooltip>+ <div className="text-lg font-bold tabular-nums">{value != null ? percent(value) : '—'}</div>+ <div className="text-xs text-secondary">{detail}</div>+ </div>)}@@ -27,11 +44,16 @@ function Cell({ count, label }: { count: number; label: string }): JSX.Element {export function ConfusionMatrixCard(): JSX.Element {const { pipeline, accuracyCutoff, championConfusion: confusion } = useValues(autoresearchPipelineLogic)const { setAccuracyCutoff } = useActions(autoresearchPipelineLogic)- const target = pipeline?.target_event ?? 'the target event'+ const target = pipeline ? eventName(pipeline.target_event) : 'the target event'return (<SectionCard- title={`Who the model flagged${confusion ? `, ${dateRange(confusion)}` : ''}`}+ title="Who the model flagged"+ description={+ confusion+ ? `People scored ${confusion.firstDate === confusion.lastDate ? 'on' : 'from'} ${confusionDateRange(confusion)}`+ : undefined+ }actions={<LemonSegmentedButtonsize="small"@@ -60,37 +82,33 @@ export function ConfusionMatrixCard(): JSX.Element {scores did.</LemonBanner>) : (- <div className="flex flex-wrap items-start gap-4">- <table className="text-sm border-collapse">- <thead>- <tr>- <th />- <th className="p-2 text-right font-semibold">Did {target}</th>- <th className="p-2 text-right font-semibold">Didn't</th>- </tr>- </thead>- <tbody>- <tr>- <th className="p-2 text-left font-semibold">Flagged</th>- <Cell count={confusion.tp} label="Correct" />- <Cell count={confusion.fp} label="False alarm" />- </tr>- <tr>- <th className="p-2 text-left font-semibold">Not flagged</th>- <Cell count={confusion.fn} label="Missed" />- <Cell count={confusion.tn} label="Correct" />- </tr>- </tbody>- </table>- <div className="grid grid-cols-2 gap-2 min-w-60">- <MetricCard+ <div className="@container">+ <div className="grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] gap-2 items-stretch">+ <div />+ <div className="text-sm font-semibold">Did it</div>+ <div className="text-sm font-semibold">Didn't</div>+ <div />++ <div className="text-sm font-semibold self-center">Flagged</div>+ <Cell count={confusion.tp} label="Caught" tint="bg-success-highlight" />+ <Cell count={confusion.fp} label="False alarm" tint="bg-warning-highlight" />+ <Ratelabel="Hit rate"- value={confusion.precision != null ? percent(confusion.precision) : '—'}+ value={confusion.precision}+ detail={`${confusion.tp.toLocaleString()} of ${confusion.flagged.toLocaleString()} flagged`}tooltip={`Precision: the share of flagged people who did ${target}.`}/>- <MetricCard++ <div className="text-sm font-semibold self-center">Not flagged</div>+ <Cell count={confusion.fn} label="Missed" tint="bg-danger-highlight" />+ <Cell count={confusion.tn} label="Correctly ignored" tint="bg-surface-secondary" />+ <div />++ <div />+ <Ratelabel="Coverage"- value={confusion.recall != null ? percent(confusion.recall) : '—'}+ value={confusion.recall}+ detail={`${confusion.tp.toLocaleString()} of ${(confusion.tp + confusion.fn).toLocaleString()} who did it`}tooltip={`Recall: the share of everyone who did ${target} that the model flagged.`}/></div>diff --git a/products/autoresearch/frontend/pipeline/MetricCard.tsx b/products/autoresearch/frontend/pipeline/MetricCard.tsxindex 32dd7cbefa23..5b8117225e32 100644--- a/products/autoresearch/frontend/pipeline/MetricCard.tsx+++ b/products/autoresearch/frontend/pipeline/MetricCard.tsx@@ -1,6 +1,16 @@import { Tooltip } from '@posthog/lemon-ui'-export function MetricCard({ label, value, tooltip }: { label: string; value: string; tooltip?: string }): JSX.Element {+export function MetricCard({+ label,+ value,+ detail,+ tooltip,+}: {+ label: string+ value: string+ detail?: string+ tooltip?: string+}): JSX.Element {const labelElement = (<div className={`text-xs font-semibold text-muted uppercase tracking-wide${tooltip ? ' cursor-help' : ''}`}>{label}@@ -10,6 +20,7 @@ export function MetricCard({ label, value, tooltip }: { label: string; value: st<div className="rounded bg-surface-secondary p-3 space-y-1">{tooltip ? <Tooltip title={tooltip}>{labelElement}</Tooltip> : labelElement}<div className="text-lg font-bold truncate">{value}</div>+ {detail && <div className="text-xs text-secondary">{detail}</div>}</div>)}diff --git a/products/autoresearch/frontend/pipeline/OnlinePerformanceTab.tsx b/products/autoresearch/frontend/pipeline/OnlinePerformanceTab.tsxindex b950c43b2b49..88f135724584 100644--- a/products/autoresearch/frontend/pipeline/OnlinePerformanceTab.tsx+++ b/products/autoresearch/frontend/pipeline/OnlinePerformanceTab.tsx@@ -7,9 +7,11 @@ import { dayjs } from 'lib/dayjs'import { pluralize } from 'lib/utils/strings'import { autoresearchPipelineLogic } from '../autoresearchPipelineLogic'-import { accuracyHeadline, percent, precisionRecallSentence, rankingSentence } from '../onlinePerformance'+import { accuracyStats, accuracySummary, percent } from '../onlinePerformance'+import { eventName } from '../pipelineQuestion'import { ConfusionMatrixCard } from './ConfusionMatrixCard'import { EmptyTab } from './EmptyTab'+import { MetricCard } from './MetricCard'import { RealizedAucChart } from './RealizedAucChart'import { ScoreNowButton } from './ScoreNowButton'import { SectionCard } from './SectionCard'@@ -82,22 +84,21 @@ export function OnlinePerformanceTab(): JSX.Element {return <NotCheckedYet />}- const ranking = rankingSentence(latestChampionPerformance, pipeline.target_event)- const precisionRecall = championConfusion- ? precisionRecallSentence(championConfusion, accuracyCutoff, pipeline.target_event)- : null+ const target = eventName(pipeline.target_event)+ const summary = championConfusion ? accuracySummary(championConfusion, accuracyCutoff, pipeline.target_event) : nullconst latestDate = dayjs(latestChampionPerformance.prediction_date).format('MMM D')return (<div className="space-y-6"><SectionCard>- <div className="space-y-1">- <p className="text-base font-semibold mb-0">- {accuracyHeadline(latestChampionPerformance, pipeline.target_event)}- </p>- {ranking && <p className="text-sm text-muted mb-0">{ranking}</p>}- {precisionRecall && <p className="text-sm text-muted mb-0">{precisionRecall}</p>}+ <div className="@container">+ <div className="grid grid-cols-1 @sm:grid-cols-2 @3xl:grid-cols-4 gap-2">+ {accuracyStats(latestChampionPerformance, pipeline.target_event).map(({ key, ...stat }) => (+ <MetricCard key={key} {...stat} />+ ))}+ </div></div>+ {summary && <p className="text-sm mb-0">{summary}</p>}</SectionCard><ConfusionMatrixCard />@@ -113,9 +114,9 @@ export function OnlinePerformanceTab(): JSX.Element {title="Realized AUC over time"description={<>- Realized AUC measures how well the model ranked people who did {pipeline.target_event} above- people who did not. 0.5 is a coin flip and 1 is a perfect ranking. The holdout line is the- score the model got in training.+ Realized AUC measures how well the model ranked people who did {target} above people who did+ not. 0.5 is a coin flip and 1 is a perfect ranking. The holdout line is the score the model+ got in training.</>}>@@ -176,10 +177,9 @@ export function OnlinePerformanceTab(): JSX.Element {Realized AUC: higher is better. Brier score and calibration error (ECE): lower isbetter. ECE measures how far predicted probabilities drift from observed rates. Liftat k%: ratio of positives in the top k% vs a random sample, so 2× means twice as- many conversions as random. Precision at 10%: share of the top 10% who did{' '}- {pipeline.target_event}. Recall at 10%: share of everyone who did it that the top- 10% includes. Average precision: precision averaged over every cutoff, higher is- better.+ many conversions as random. Precision at 10%: share of the top 10% who did {target}.+ Recall at 10%: share of everyone who did it that the top 10% includes. Average+ precision: precision averaged over every cutoff, higher is better.</p></div>),diff --git a/products/autoresearch/frontend/pipeline/PredictionSegmentCards.tsx b/products/autoresearch/frontend/pipeline/PredictionSegmentCards.tsxindex 7d267ec94996..899f47d2447c 100644--- a/products/autoresearch/frontend/pipeline/PredictionSegmentCards.tsx+++ b/products/autoresearch/frontend/pipeline/PredictionSegmentCards.tsx@@ -5,6 +5,7 @@ import { LemonBanner, LemonButton, LemonSkeleton, Tooltip } from '@posthog/lemonimport { humanFriendlyNumber } from 'lib/utils/numbers'import { autoresearchPipelineLogic } from '../autoresearchPipelineLogic'+import { eventName } from '../pipelineQuestion'import { PredictionSegmentDefinition, formatProbability, predictionSegmentPeopleUrl } from '../predictionSegments'function SegmentCard({ segment }: { segment: PredictionSegmentDefinition }): JSX.Element {@@ -88,7 +89,7 @@ function SegmentCutPoints(): JSX.Element | null {if (!thresholds) {return null}- const target = pipeline?.target_event ?? 'the target event'+ const target = pipeline ? eventName(pipeline.target_event) : 'the target event'return (<><p className="text-sm text-secondary mb-0">diff --git a/products/autoresearch/frontend/pipelineQuestion.test.ts b/products/autoresearch/frontend/pipelineQuestion.test.tsindex ae3ac487873f..01d2d1ba9d42 100644--- a/products/autoresearch/frontend/pipelineQuestion.test.ts+++ b/products/autoresearch/frontend/pipelineQuestion.test.ts@@ -1,11 +1,23 @@-import { pipelineQuestion } from './pipelineQuestion'+import { pipelineQuestion, pipelineSubtitle } from './pipelineQuestion'describe('pipelineQuestion', () => {test.each([- { horizon_days: 30, expected: 'Who will do file_shared in the next 30 days?' },- { horizon_days: 1, expected: 'Who will do file_shared in the next day?' },- { horizon_days: undefined, expected: 'Who will do file_shared?' },+ { horizon_days: 30, expected: 'Who will do “file_shared” in the next 30 days?' },+ { horizon_days: 1, expected: 'Who will do “file_shared” in the next day?' },+ { horizon_days: undefined, expected: 'Who will do “file_shared”?' },])('horizon $horizon_days', ({ horizon_days, expected }) => {expect(pipelineQuestion({ target_event: 'file_shared', horizon_days })).toEqual(expected)})++ test.each([+ { name: 'File sharers', expected: 'File sharers' },+ { name: 'Feature adoption: File shared', expected: 'Feature adoption: File shared' },+ { name: 'Who will do File shared in the next 7 days', expected: null },+ { name: 'file shared', expected: null },+ { name: 'File', expected: null },+ { name: 'Files', expected: 'Files' },+ { name: ' ', expected: null },+ ])('subtitle for name "$name"', ({ name, expected }) => {+ expect(pipelineSubtitle({ name, target_event: 'File shared', horizon_days: 7 })).toEqual(expected)+ })})diff --git a/products/autoresearch/frontend/pipelineQuestion.ts b/products/autoresearch/frontend/pipelineQuestion.tsindex ff92ee564e8d..17626777f0ea 100644--- a/products/autoresearch/frontend/pipelineQuestion.ts+++ b/products/autoresearch/frontend/pipelineQuestion.ts@@ -1,14 +1,41 @@import { AutoresearchPipelineApi } from './generated/api.schemas'+/**+ * The target event as a name inside a sentence. Event names are nouns or past-tense phrases+ * ("File downloaded"), so quotes keep "did File downloaded" from reading as a broken verb.+ */+export function eventName(targetEvent: string): string {+ return `“${targetEvent}”`+}+/** The question a model answers, in plain words. The model list cards and the detail header both show it. */export function pipelineQuestion({target_event,horizon_days,}: Pick<AutoresearchPipelineApi, 'target_event' | 'horizon_days'>): string {+ const target = eventName(target_event)if (!horizon_days) {- return `Who will do ${target_event}?`+ return `Who will do ${target}?`}return horizon_days === 1- ? `Who will do ${target_event} in the next day?`- : `Who will do ${target_event} in the next ${horizon_days} days?`+ ? `Who will do ${target} in the next day?`+ : `Who will do ${target} in the next ${horizon_days} days?`+}++function words(text: string): string {+ return text+ .toLowerCase()+ .replace(/[^\p{L}\p{N}]+/gu, ' ')+ .trim()+}++/** The model name under the question in the detail header. Null when the name only repeats part of the question. */+export function pipelineSubtitle(+ pipeline: Pick<AutoresearchPipelineApi, 'name' | 'target_event' | 'horizon_days'>+): string | null {+ const name = words(pipeline.name ?? '')+ if (!name) {+ return null+ }+ return ` ${words(pipelineQuestion(pipeline))} `.includes(` ${name} `) ? null : pipeline.name}