:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(signals): expose all 11 ranking heads as model sorts (#114781)
posthog[bot]a4476763ee7e
diff --git a/products/signals/backend/test/test_signal_report_api.py b/products/signals/backend/test/test_signal_report_api.pyindex 0ac3cbc249ee..d83557954a51 100644--- a/products/signals/backend/test/test_signal_report_api.py+++ b/products/signals/backend/test/test_signal_report_api.py@@ -1208,21 +1208,28 @@ class TestSignalReportListAPI(APIBaseTest):ids = [r["id"] for r in response.json()["results"]]assert ids.index(str(high_candidate.id)) < ids.index(str(low_ready.id))- @parameterized.expand([("descending", "-ranking_pr_merged"), ("ascending", "ranking_pr_merged")])- def test_ranking_ordering_sorts_by_the_served_head_with_unscored_last(self, _name, ordering):+ @parameterized.expand(+ [+ (f"{field}_{direction}", f"{prefix}{field}", head)+ for field, head in SignalReportViewSet._RANKING_ORDERING_HEADS.items()+ for direction, prefix in (("descending", "-"), ("ascending", ""))+ ]+ )+ def test_ranking_ordering_sorts_by_the_served_head_with_unscored_last(self, _name, ordering, head):self.user.is_staff = Trueself.user.save()+ other_head = "action" if head == "open" else "open"low = self._create_report(title="Low")high = self._create_report(title="High")unscored = self._create_report(title="Unscored")no_head = self._create_report(title="No head")- self._ranking_score_artefact(low, scores={"pr_merged": 0.1, "open": 0.9})- self._ranking_score_artefact(high, scores={"pr_merged": 0.7, "open": 0.1})- self._ranking_score_artefact(no_head, scores={"open": 0.5})- stale = self._ranking_score_artefact(low, scores={"pr_merged": 0.99})+ self._ranking_score_artefact(low, scores={head: 0.1, other_head: 0.9})+ self._ranking_score_artefact(high, scores={head: 0.7, other_head: 0.1})+ self._ranking_score_artefact(no_head, scores={other_head: 0.5})+ stale = self._ranking_score_artefact(low, scores={head: 0.99})SignalReportArtefact.objects.filter(pk=stale.pk).update(created_at=timezone.now() - timedelta(days=1))impossible_time = self._create_report(title="Impossible time")- impossible_score = self._ranking_score_artefact(impossible_time, scores={"pr_merged": 0.4})+ impossible_score = self._ranking_score_artefact(impossible_time, scores={head: 0.4})SignalReportArtefact.objects.filter(pk=impossible_score.pk).update(content=impossible_score.content.replace("2026-09-20T12:00:00Z", "2026-02-31T12:00:00Z"))@@ -1233,7 +1240,7 @@ class TestSignalReportListAPI(APIBaseTest):content=json.dumps({"old_title": "Old", "new_title": "Impossible time"}),)bad_latest = self._create_report(title="Bad latest")- older_valid = self._ranking_score_artefact(bad_latest, scores={"pr_merged": 0.99})+ older_valid = self._ranking_score_artefact(bad_latest, scores={head: 0.99})SignalReportArtefact.objects.filter(pk=older_valid.pk).update(created_at=timezone.now() - timedelta(days=1))self._ranking_score_artefact(bad_latest, content="not json")diff --git a/products/signals/backend/views.py b/products/signals/backend/views.pyindex 0823b05acc7c..47ffba70d9f7 100644--- a/products/signals/backend/views.py+++ b/products/signals/backend/views.py@@ -1126,6 +1126,13 @@ class SignalReportViewSet("ranking_pr_created": "ranking_pr_created_score","ranking_action": "ranking_action_score","ranking_open": "ranking_open_score",+ "ranking_fixed": "ranking_fixed_score",+ "ranking_discuss": "ranking_discuss_score",+ "ranking_thumbs_up": "ranking_thumbs_up_score",+ "ranking_reviewer_fix": "ranking_reviewer_fix_score",+ "ranking_refund": "ranking_refund_score",+ "ranking_dismiss_wrong": "ranking_dismiss_wrong_score",+ "ranking_dismiss_lowvalue": "ranking_dismiss_lowvalue_score",}# Ordering field to the outcome head it reads from the served model of the latest ranking score._RANKING_ORDERING_HEADS: dict[str, str] = {@@ -1133,6 +1140,13 @@ class SignalReportViewSet("ranking_pr_created": "pr_created","ranking_action": "action","ranking_open": "open",+ "ranking_fixed": "fixed",+ "ranking_discuss": "discuss",+ "ranking_thumbs_up": "thumbs_up",+ "ranking_reviewer_fix": "reviewer_fix",+ "ranking_refund": "refund",+ "ranking_dismiss_wrong": "dismiss_wrong",+ "ranking_dismiss_lowvalue": "dismiss_lowvalue",}@extend_schema(request=ReportReadStateRequestSerializer, responses=ReportReadStateResponseSerializer)@@ -2314,7 +2328,8 @@ class SignalReportViewSet("Comma-separated ordering clauses. Each clause is a field name optionally prefixed with '-' ""for descending. Allowed fields: status, is_suggested_reviewer, signal_count, total_weight, ""priority, created_at, updated_at, id, ranking_pr_merged, ranking_pr_created, ranking_action, "- "ranking_open. Defaults to '-is_suggested_reviewer,status,-updated_at'. The ranking_* fields "+ "ranking_open, ranking_fixed, ranking_discuss, ranking_thumbs_up, ranking_reviewer_fix, "+ "ranking_refund, ranking_dismiss_wrong, ranking_dismiss_lowvalue. Defaults to '-is_suggested_reviewer,status,-updated_at'. The ranking_* fields ""sort by the served ranking model's probability for that outcome head, with unscored reports ""last in either direction. They are staff only: other users get a 400."),diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.tsindex 4d5ca9de9fcb..3f3c38f492b2 100644--- a/products/signals/frontend/generated/api.schemas.ts+++ b/products/signals/frontend/generated/api.schemas.ts@@ -7528,7 +7528,7 @@ export type SignalsReportsListParams = {*/offset?: number/**- * Comma-separated ordering clauses. Each clause is a field name optionally prefixed with '-' for descending. Allowed fields: status, is_suggested_reviewer, signal_count, total_weight, priority, created_at, updated_at, id, ranking_pr_merged, ranking_pr_created, ranking_action, ranking_open. Defaults to '-is_suggested_reviewer,status,-updated_at'. The ranking_* fields sort by the served ranking model's probability for that outcome head, with unscored reports last in either direction. They are staff only: other users get a 400.+ * Comma-separated ordering clauses. Each clause is a field name optionally prefixed with '-' for descending. Allowed fields: status, is_suggested_reviewer, signal_count, total_weight, priority, created_at, updated_at, id, ranking_pr_merged, ranking_pr_created, ranking_action, ranking_open, ranking_fixed, ranking_discuss, ranking_thumbs_up, ranking_reviewer_fix, ranking_refund, ranking_dismiss_wrong, ranking_dismiss_lowvalue. Defaults to '-is_suggested_reviewer,status,-updated_at'. The ranking_* fields sort by the served ranking model's probability for that outcome head, with unscored reports last in either direction. They are staff only: other users get a 400.*/ordering?: string/**diff --git a/products/signals/frontend/inbox/components/shell/InboxReportFilters.tsx b/products/signals/frontend/inbox/components/shell/InboxReportFilters.tsxindex 6e63816d2043..a1d63ff8da29 100644--- a/products/signals/frontend/inbox/components/shell/InboxReportFilters.tsx+++ b/products/signals/frontend/inbox/components/shell/InboxReportFilters.tsx@@ -5,6 +5,7 @@ import { LemonSelect } from '@posthog/lemon-ui'import {INBOX_CREATED_WINDOW_OPTIONS,INBOX_MODEL_SORT_OPTIONS,+ INBOX_MODEL_SORT_SECTIONS,INBOX_PRIORITY_OPTIONS,INBOX_SORT_OPTIONS,inboxPriorityFilterLabel,@@ -43,7 +44,7 @@ const toSortSelectOption = (option: InboxSortOption): { value: string; label: stconst SORT_SELECT_OPTIONS = INBOX_SORT_OPTIONS.map(toSortSelectOption)const SORT_SELECT_SECTIONS_WITH_MODEL = [{ options: SORT_SELECT_OPTIONS },- { title: 'Model', options: INBOX_MODEL_SORT_OPTIONS.map(toSortSelectOption) },+ ...INBOX_MODEL_SORT_SECTIONS.map(({ title, options }) => ({ title, options: options.map(toSortSelectOption) })),]const ALL_SORT_OPTIONS = [...INBOX_SORT_OPTIONS, ...INBOX_MODEL_SORT_OPTIONS]diff --git a/products/signals/frontend/inbox/filterOptions.tsx b/products/signals/frontend/inbox/filterOptions.tsxindex d4e0203d4d19..e2a943b55c67 100644--- a/products/signals/frontend/inbox/filterOptions.tsx+++ b/products/signals/frontend/inbox/filterOptions.tsx@@ -85,13 +85,52 @@ export const INBOX_SORT_OPTIONS: InboxSortOption[] = []/** Staff-only sorts by the ranking model's served probability for one outcome head. Descending only. */-export const INBOX_MODEL_SORT_OPTIONS: InboxSortOption[] = [- { label: 'Most likely to merge', field: 'ranking_pr_merged', direction: 'desc', icon: <IconBrain /> },- { label: 'Most likely to get a PR', field: 'ranking_pr_created', direction: 'desc', icon: <IconBrain /> },- { label: 'Most likely to need action', field: 'ranking_action', direction: 'desc', icon: <IconBrain /> },- { label: 'Most likely to be opened', field: 'ranking_open', direction: 'desc', icon: <IconBrain /> },+export const INBOX_MODEL_SORT_SECTIONS: { title: string; options: InboxSortOption[] }[] = [+ {+ title: 'Model: good outcomes',+ options: [+ { label: 'Most likely to merge', field: 'ranking_pr_merged', direction: 'desc', icon: <IconBrain /> },+ { label: 'Most likely to get a PR', field: 'ranking_pr_created', direction: 'desc', icon: <IconBrain /> },+ { label: 'Most likely to need action', field: 'ranking_action', direction: 'desc', icon: <IconBrain /> },+ { label: 'Most likely to be opened', field: 'ranking_open', direction: 'desc', icon: <IconBrain /> },+ { label: 'Most likely to be fixed', field: 'ranking_fixed', direction: 'desc', icon: <IconBrain /> },+ { label: 'Most likely to be discussed', field: 'ranking_discuss', direction: 'desc', icon: <IconBrain /> },+ {+ label: 'Most likely to get a thumbs up',+ field: 'ranking_thumbs_up',+ direction: 'desc',+ icon: <IconBrain />,+ },+ ],+ },+ {+ title: 'Model: bad outcomes',+ options: [+ {+ label: 'Most likely to need a reviewer fix',+ field: 'ranking_reviewer_fix',+ direction: 'desc',+ icon: <IconBrain />,+ },+ { label: 'Most likely to be refunded', field: 'ranking_refund', direction: 'desc', icon: <IconBrain /> },+ {+ label: 'Most likely to be dismissed as wrong',+ field: 'ranking_dismiss_wrong',+ direction: 'desc',+ icon: <IconBrain />,+ },+ {+ label: 'Most likely to be dismissed as low value',+ field: 'ranking_dismiss_lowvalue',+ direction: 'desc',+ icon: <IconBrain />,+ },+ ],+ },]+export const INBOX_MODEL_SORT_OPTIONS: InboxSortOption[] = INBOX_MODEL_SORT_SECTIONS.flatMap(({ options }) => options)+export function isRankingSortField(field: InboxSortField): field is InboxRankingSortField {return field.startsWith('ranking_')}@@ -102,6 +141,13 @@ export const RANKING_SORT_HEADS: Record<InboxRankingSortField, { head: string; tranking_pr_created: { head: 'pr_created', tagLabel: 'PR' },ranking_action: { head: 'action', tagLabel: 'action' },ranking_open: { head: 'open', tagLabel: 'open' },+ ranking_fixed: { head: 'fixed', tagLabel: 'fix' },+ ranking_discuss: { head: 'discuss', tagLabel: 'discuss' },+ ranking_thumbs_up: { head: 'thumbs_up', tagLabel: 'thumbs up' },+ ranking_reviewer_fix: { head: 'reviewer_fix', tagLabel: 'reviewer fix' },+ ranking_refund: { head: 'refund', tagLabel: 'refund' },+ ranking_dismiss_wrong: { head: 'dismiss_wrong', tagLabel: 'wrong' },+ ranking_dismiss_lowvalue: { head: 'dismiss_lowvalue', tagLabel: 'low value' },}/** Display names for the ranking heads in the probability tooltip. Unknown heads show their raw name. */@@ -110,11 +156,13 @@ export const RANKING_HEAD_LABELS: Record<string, string> = {pr_created: 'PR created',action: 'Needs action',open: 'Opened',+ fixed: 'Fixed',thumbs_up: 'Thumbs up',discuss: 'Discussed',dismiss_wrong: 'Dismissed as wrong',refund: 'Refunded',reviewer_fix: 'Reviewer fix',+ dismiss_lowvalue: 'Dismissed as low value',}export const INBOX_CREATED_WINDOW_OPTIONS: { value: InboxCreatedWindow; label: string; hours: number }[] = [diff --git a/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts b/products/signals/frontend/inbox/logics/inboxFiltersLogic.tsindex cb2d7fc9041a..a748827c4d80 100644--- a/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts+++ b/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts@@ -41,7 +41,18 @@ export interface InboxReviewerOption {email: string}-export type InboxRankingSortField = 'ranking_pr_merged' | 'ranking_pr_created' | 'ranking_action' | 'ranking_open'+export type InboxRankingSortField =+ | 'ranking_pr_merged'+ | 'ranking_pr_created'+ | 'ranking_action'+ | 'ranking_open'+ | 'ranking_fixed'+ | 'ranking_discuss'+ | 'ranking_thumbs_up'+ | 'ranking_reviewer_fix'+ | 'ranking_refund'+ | 'ranking_dismiss_wrong'+ | 'ranking_dismiss_lowvalue'export type InboxSortField = 'priority' | 'created_at' | 'updated_at' | InboxRankingSortFieldexport type InboxSortDirection = 'asc' | 'desc'/** Preset for the created-in window filter. Null means any time. */diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex cb1338bf8c8e..f82df5d238b6 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -126479,7 +126479,7 @@ export namespace Schemas {*/offset?: number;/**- * Comma-separated ordering clauses. Each clause is a field name optionally prefixed with '-' for descending. Allowed fields: status, is_suggested_reviewer, signal_count, total_weight, priority, created_at, updated_at, id, ranking_pr_merged, ranking_pr_created, ranking_action, ranking_open. Defaults to '-is_suggested_reviewer,status,-updated_at'. The ranking_* fields sort by the served ranking model's probability for that outcome head, with unscored reports last in either direction. They are staff only: other users get a 400.+ * Comma-separated ordering clauses. Each clause is a field name optionally prefixed with '-' for descending. Allowed fields: status, is_suggested_reviewer, signal_count, total_weight, priority, created_at, updated_at, id, ranking_pr_merged, ranking_pr_created, ranking_action, ranking_open, ranking_fixed, ranking_discuss, ranking_thumbs_up, ranking_reviewer_fix, ranking_refund, ranking_dismiss_wrong, ranking_dismiss_lowvalue. Defaults to '-is_suggested_reviewer,status,-updated_at'. The ranking_* fields sort by the served ranking model's probability for that outcome head, with unscored reports last in either direction. They are staff only: other users get a 400.*/ordering?: string;/**diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.tsindex 7f483430fb95..b00d72478165 100644--- a/services/mcp/src/generated/signals/api.ts+++ b/services/mcp/src/generated/signals/api.ts@@ -76,7 +76,7 @@ export const SignalsReportsListQueryParams = () => zod.object({.string().optional().describe(- "Comma-separated ordering clauses. Each clause is a field name optionally prefixed with '-' for descending. Allowed fields: status, is_suggested_reviewer, signal_count, total_weight, priority, created_at, updated_at, id, ranking_pr_merged, ranking_pr_created, ranking_action, ranking_open. Defaults to '-is_suggested_reviewer,status,-updated_at'. The ranking_\* fields sort by the served ranking model's probability for that outcome head, with unscored reports last in either direction. They are staff only: other users get a 400."+ "Comma-separated ordering clauses. Each clause is a field name optionally prefixed with '-' for descending. Allowed fields: status, is_suggested_reviewer, signal_count, total_weight, priority, created_at, updated_at, id, ranking_pr_merged, ranking_pr_created, ranking_action, ranking_open, ranking_fixed, ranking_discuss, ranking_thumbs_up, ranking_reviewer_fix, ranking_refund, ranking_dismiss_wrong, ranking_dismiss_lowvalue. Defaults to '-is_suggested_reviewer,status,-updated_at'. The ranking_\* fields sort by the served ranking model's probability for that outcome head, with unscored reports last in either direction. They are staff only: other users get a 400."),priority: zod.string()diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-list.jsonindex 9a77759e6c8c..7ac057294d4d 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-list.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-list.json@@ -51,7 +51,7 @@"type": "number"},"ordering": {- "description": "Comma-separated ordering clauses. Each clause is a field name optionally prefixed with '-' for descending. Allowed fields: status, is_suggested_reviewer, signal_count, total_weight, priority, created_at, updated_at, id, ranking_pr_merged, ranking_pr_created, ranking_action, ranking_open. Defaults to '-is_suggested_reviewer,status,-updated_at'. The ranking_* fields sort by the served ranking model's probability for that outcome head, with unscored reports last in either direction. They are staff only: other users get a 400.",+ "description": "Comma-separated ordering clauses. Each clause is a field name optionally prefixed with '-' for descending. Allowed fields: status, is_suggested_reviewer, signal_count, total_weight, priority, created_at, updated_at, id, ranking_pr_merged, ranking_pr_created, ranking_action, ranking_open, ranking_fixed, ranking_discuss, ranking_thumbs_up, ranking_reviewer_fix, ranking_refund, ranking_dismiss_wrong, ranking_dismiss_lowvalue. Defaults to '-is_suggested_reviewer,status,-updated_at'. The ranking_* fields sort by the served ranking model's probability for that outcome head, with unscored reports last in either direction. They are staff only: other users get a 400.","type": "string"},"priority": {