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(signals): add sort=personal to the inbox report list (#129978)

posthog[bot]d185384fb73a
diff --git a/products/signals/backend/personal_ranking/list_sort.py b/products/signals/backend/personal_ranking/list_sort.py
new file mode 100644
index 000000000000..3645656ce289
--- /dev/null
+++ b/products/signals/backend/personal_ranking/list_sort.py
@@ -0,0 +1,65 @@
+"""Read one person's stored list for `sort=personal` on the report list. The read never builds.
+
+It reads one `PersonalInboxRanking` row and nothing else: no candidate pools, no queued build, no model call. So a
+page load can use it. The order puts the ranked reports first by stored rank, then the folded reports, and the view
+orders every other report in the person's `recommended` order. With no usable row there is no order, and the list is
+the plain `recommended` order.
+"""
+
+import uuid
+from collections.abc import Mapping
+
+from posthog.dataclasses import frozen
+from posthog.models import Team, User
+
+from products.signals.backend.models import PersonalInboxRanking
+from products.signals.backend.personal_ranking.config import read_config
+
+
+@frozen
+class PersonalRowNote:
+ tier: str
+ reason: str
+
+
+@frozen
+class PersonalListOrder:
+ ranking_id: str
+ # The ranked reports by stored rank, then the folded reports.
+ report_ids: tuple[uuid.UUID, ...]
+ # Only the reports the language model ranked, by report id.
+ notes: Mapping[str, PersonalRowNote]
+
+
+def _parse_id(value: object) -> uuid.UUID | None:
+ try:
+ return uuid.UUID(str(value))
+ except ValueError:
+ return None
+
+
+def personal_list_order(team: Team, user: User, ranking_id: str | None = None) -> PersonalListOrder | None:
+ """The order of the row `ranking_id` names, else of the latest personalized row. None when nothing is ranked."""
+ if not read_config().enabled:
+ return None
+ rows = PersonalInboxRanking.objects.for_team(team.id).filter(user_id=user.id, personalized=True)
+ # A later page names the row of the first page, so a rebuild between pages does not reshuffle them.
+ row = rows.filter(id=ranking_id).first() if ranking_id else None
+ if row is None:
+ row = rows.order_by("-created_at", "-id").first()
+ if row is None:
+ return None
+ result = row.result or {}
+ ranked = sorted(result.get("ranked") or (), key=lambda entry: entry["rank"])
+ report_ids: dict[uuid.UUID, None] = {}
+ notes: dict[str, PersonalRowNote] = {}
+ for entry in [*ranked, *(result.get("folded") or ())]:
+ report_id = _parse_id(entry.get("report_id"))
+ if report_id is None:
+ continue
+ report_ids.setdefault(report_id)
+ if entry.get("ranked_by") == "llm":
+ notes[str(report_id)] = PersonalRowNote(tier=entry["tier"], reason=entry["reason"])
+ if not report_ids:
+ return None
+ return PersonalListOrder(ranking_id=str(row.id), report_ids=tuple(report_ids), notes=notes)
diff --git a/products/signals/backend/scout_report/trial_inbox.py b/products/signals/backend/scout_report/trial_inbox.py
index ef99138b886f..94676e583fbe 100644
--- a/products/signals/backend/scout_report/trial_inbox.py
+++ b/products/signals/backend/scout_report/trial_inbox.py
@@ -44,6 +44,7 @@ class TrialInboxReads:
"count_only",
"ordering",
"sort",
+ "ranking_id",
"limit",
"offset",
"format",
@@ -296,6 +297,8 @@ class TrialInboxReads:
include_source_metadata=include_source_metadata,
)
document["inbox_merge_key"] = None
+ document["personal_tier"] = None
+ document["personal_reason"] = None
if document.get("status") not in statuses:
continue
if search and not any(search in str(document.get(field, "")).casefold() for field in ("title", "summary")):
diff --git a/products/signals/backend/serializers.py b/products/signals/backend/serializers.py
index 4ba21cca92b2..a40d6bcf60e8 100644
--- a/products/signals/backend/serializers.py
+++ b/products/signals/backend/serializers.py
@@ -124,6 +124,7 @@ from .models import (
SignalTeamConfig,
SignalUserAutonomyConfig,
)
+from .personal_ranking.list_sort import PersonalListOrder, PersonalRowNote
from .pull_request_label import DEFAULT_PULL_REQUEST_LABEL
from .ranking.inbox_sort import inbox_merge_key
from .ranking.public_outcomes import RankingOutcome
@@ -2647,16 +2648,30 @@ class SignalReportListSerializer(SignalReportSerializer):
)
inbox_merge_key = serializers.SerializerMethodField(
help_text=(
- "Sort key from the ranker named by the list response's ranker field, for sort=recommended only. "
- "Lower keys rank first, so rows from several requests merge in the order of one request. "
- "For an outcome ranker (open, action or fix), a scored report gets 1 minus its score, from 0 to 1, "
- "and a report without a usable score gets 2 plus its priority rank. The priority ranker uses the "
- "priority rank only, from 0 (P0) to 5 (no priority). Null for every other sort."
+ "Sort key from the ranker named by the list response's ranker field, for sort=recommended and "
+ "sort=personal only. Lower keys rank first, so rows from several requests merge in the order of one "
+ "request. For an outcome ranker (open, action or fix), a scored report gets 1 minus its score, from "
+ "0 to 1, and a report without a usable score gets 2 plus its priority rank. The priority ranker uses "
+ "the priority rank only, from 0 (P0) to 5 (no priority). For the personal ranker, a report in the "
+ "stored personal ranking gets its position in that ranking from 0, and every other report gets the "
+ "number of those positions plus its key from the recommended ranker. Null for every other sort."
+ ),
+ )
+ personal_tier = serializers.SerializerMethodField(
+ help_text=(
+ "The tier your personal ranking gave this report, for sort=personal. Null when the language model "
+ "did not rank the report, and for every other sort."
+ ),
+ )
+ personal_reason = serializers.SerializerMethodField(
+ help_text=(
+ "Why your personal ranking put this report where it is, for sort=personal. Null when the language "
+ "model did not rank the report, and for every other sort."
),
)
class Meta(SignalReportSerializer.Meta):
- fields = [*SignalReportSerializer.Meta.fields, "inbox_merge_key"]
+ fields = [*SignalReportSerializer.Meta.fields, "inbox_merge_key", "personal_tier", "personal_reason"]
read_only_fields = fields
def get_inbox_merge_key(self, obj: SignalReport) -> float | None:
@@ -2664,7 +2679,26 @@ class SignalReportListSerializer(SignalReportSerializer):
if ranker is None:
return None
score = None if ranker == "priority" else getattr(obj, f"ranking_{ranker}_score", None)
- return inbox_merge_key(ranker, score, getattr(obj, "priority_sort_rank", None))
+ key = inbox_merge_key(ranker, score, getattr(obj, "priority_sort_rank", None))
+ personal_order: PersonalListOrder | None = self.context.get("personal_order")
+ if personal_order is None:
+ return key
+ personal_rank = getattr(obj, "personal_rank", None)
+ if personal_rank is not None:
+ return float(personal_rank - 1)
+ return len(personal_order.report_ids) + key
+
+ def _personal_note(self, obj: SignalReport) -> PersonalRowNote | None:
+ personal_order: PersonalListOrder | None = self.context.get("personal_order")
+ return personal_order.notes.get(str(obj.id)) if personal_order is not None else None
+
+ def get_personal_tier(self, obj: SignalReport) -> str | None:
+ note = self._personal_note(obj)
+ return note.tier if note is not None else None
+
+ def get_personal_reason(self, obj: SignalReport) -> str | None:
+ note = self._personal_note(obj)
+ return note.reason if note is not None else None
class SignalReportSectionCountsSerializer(serializers.Serializer):
@@ -2695,6 +2729,13 @@ class SignalReportFilterQuerySerializer(serializers.Serializer):
class SignalReportListQuerySerializer(SignalReportFilterQuerySerializer):
+ ranking_id = serializers.UUIDField(
+ required=False,
+ help_text=(
+ "For sort=personal: the ranking_id of the first page. Pass it on later pages, so a new personal "
+ "ranking does not reorder them. When that ranking no longer exists, the latest one applies."
+ ),
+ )
count_only = serializers.BooleanField(
required=False,
default=False,
diff --git a/products/signals/backend/test/test_personal_ranking.py b/products/signals/backend/test/test_personal_ranking.py
index f02f5e2bd5c4..5050e1beed0d 100644
--- a/products/signals/backend/test/test_personal_ranking.py
+++ b/products/signals/backend/test/test_personal_ranking.py
@@ -1173,3 +1173,144 @@ class TestForMeEndpoint(APIBaseTest):
else:
assert response.status_code == 404
assert (self._rows(), self.queued) == (0, [])
+
+
+class TestPersonalListSort(APIBaseTest):
+ def setUp(self) -> None:
+ super().setUp()
+ self.payload: dict[str, Any] = {}
+ self.flag_enabled = True
+ self.analytics = MagicMock()
+ self.analytics.get_feature_flag.return_value = "control"
+ self.gather = MagicMock()
+ self.delay = MagicMock()
+ for target, value in (
+ (
+ "products.signals.backend.personal_ranking.config.read_flag_payload",
+ MagicMock(side_effect=lambda *_: self.payload),
+ ),
+ (
+ "products.signals.backend.ranking.access.feature_enabled_or_false",
+ MagicMock(side_effect=lambda *_args, **_kwargs: self.flag_enabled),
+ ),
+ ("products.signals.backend.ranking.inbox_sort.posthoganalytics", self.analytics),
+ ("products.signals.backend.personal_ranking.serve.gather_candidates", self.gather),
+ ("products.signals.backend.personal_ranking.serve.build_personal_inbox_ranking.delay", self.delay),
+ ):
+ patcher = patch(target, value)
+ patcher.start()
+ self.addCleanup(patcher.stop)
+ self.reports = [
+ SignalReport.objects.create(
+ team=self.team, title=f"R{index}", summary="s", signal_count=1, total_weight=1.0, status="ready"
+ )
+ for index in range(5)
+ ]
+
+ def _ranking(self, ranked: list[SignalReport], folded: list[SignalReport], **kwargs: Any) -> PersonalInboxRanking:
+ defaults: dict[str, Any] = {
+ "personalized": True,
+ "result": {
+ "ranked": [
+ {
+ "report_id": str(report.id),
+ "rank": rank,
+ "tier": "top" if rank == 1 else "later",
+ "reason": f"reason {report.title}",
+ "ranked_by": "llm" if rank == 1 else "model",
+ }
+ # Stored out of rank order, so the read must sort by rank.
+ for rank, report in reversed(list(enumerate(ranked, start=1)))
+ ],
+ "folded": [
+ {"report_id": str(report.id), "into_report_id": str(ranked[0].id), "reason": "same"}
+ for report in folded
+ ],
+ },
+ }
+ return PersonalInboxRanking.objects.create(
+ team=self.team,
+ user=self.user,
+ input_hash="h",
+ model="m",
+ prompt_version=1,
+ status="ok",
+ **{**defaults, **kwargs},
+ )
+
+ def _list(self, **params: Any) -> dict[str, Any]:
+ query = "&".join(f"{key}={value}" for key, value in {"status": "ready", **params}.items())
+ response = self.client.get(f"/api/projects/{self.team.id}/signals/reports/?{query}")
+ assert response.status_code == 200, response.json()
+ return response.json()
+
+ def _ids(self, body: dict[str, Any]) -> list[str]:
+ return [row["id"] for row in body["results"]]
+
+ def test_puts_ranked_then_folded_reports_first_without_a_build_or_an_exposure(self) -> None:
+ r0, r1, r2, r3, r4 = self.reports
+ row = self._ranking([r2, r0], [r1])
+ base = self._ids(self._list(sort="recommended"))
+ self.analytics.reset_mock()
+
+ body = self._list(sort="personal")
+
+ rest = [report_id for report_id in base if report_id not in {str(r2.id), str(r0.id), str(r1.id)}]
+ assert self._ids(body) == [str(r2.id), str(r0.id), str(r1.id), *rest]
+ assert (body["ranker"], body["ranking_id"], body["ranking_pill"]) == ("personal", str(row.id), False)
+ assert [row["inbox_merge_key"] for row in body["results"]] == [0, 1, 2, 3 + 5, 3 + 5]
+ assert [(row["personal_tier"], row["personal_reason"]) for row in body["results"][:3]] == [
+ ("top", "reason R2"),
+ (None, None),
+ (None, None),
+ ]
+ assert self.analytics.get_feature_flag.call_args.kwargs["send_feature_flag_events"] is False
+ assert (self.gather.call_count, self.delay.call_count) == (0, 0)
+ assert PersonalInboxRanking.objects.for_team(self.team.id).count() == 1
+
+ @parameterized.expand(
+ [
+ ("no_row", None, True, True),
+ ("empty_row", {"ranked": [], "folded": []}, True, True),
+ ("not_personalized", "not_personalized", True, True),
+ ("flag_off", "ranked", False, True),
+ ("disabled", "ranked", True, False),
+ ]
+ )
+ def test_falls_back_to_the_recommended_order(
+ self, _name: str, row: Any, flag_enabled: bool, config_enabled: bool
+ ) -> None:
+ r0, r1, *_ = self.reports
+ if row == "not_personalized":
+ self._ranking([r0], [r1], personalized=False)
+ elif row == "ranked":
+ self._ranking([r0], [r1])
+ elif row is not None:
+ self._ranking([], [], result=row)
+ base = self._list(sort="recommended")
+ self.flag_enabled = flag_enabled
+ self.payload = {} if config_enabled else {"enabled": False}
+
+ body = self._list(sort="personal")
+
+ assert self._ids(body) == self._ids(base)
+ assert (body["ranker"], body["ranking_id"]) == ("priority", None)
+ assert [row["inbox_merge_key"] for row in body["results"]] == [
+ row["inbox_merge_key"] for row in base["results"]
+ ]
+ assert all(row["personal_reason"] is None for row in body["results"])
+ assert (self.gather.call_count, self.delay.call_count) == (0, 0)
+
+ def test_later_pages_keep_the_order_of_the_first_page_after_a_rebuild(self) -> None:
+ r0, r1, r2, r3, r4 = self.reports
+ old = self._ranking([r0, r1, r2, r3], [])
+ first = self._list(sort="personal", limit=2)
+ assert (self._ids(first), first["ranking_id"]) == ([str(r0.id), str(r1.id)], str(old.id))
+ self._ranking([r3, r2, r1, r0], [])
+
+ second = self._list(sort="personal", limit=2, offset=2, ranking_id=first["ranking_id"])
+ assert (self._ids(second), second["ranking_id"]) == ([str(r2.id), str(r3.id)], str(old.id))
+
+ old.delete()
+ latest = self._list(sort="personal", limit=2, offset=2, ranking_id=first["ranking_id"])
+ assert self._ids(latest) == [str(r1.id), str(r0.id)]
diff --git a/products/signals/backend/views.py b/products/signals/backend/views.py
index 0ed841baa6ab..63ce8cfe200d 100644
--- a/products/signals/backend/views.py
+++ b/products/signals/backend/views.py
@@ -10,6 +10,7 @@ from functools import cached_property, partial
from typing import Any, Literal, cast
from django.conf import settings
+from django.contrib.postgres.fields import ArrayField
from django.core.cache import cache
from django.db import IntegrityError, models, transaction
from django.db.models import (
@@ -18,12 +19,14 @@ from django.db.models import (
Count,
Exists,
F,
+ Func,
IntegerField,
OuterRef,
Prefetch,
Q,
Subquery,
Sum,
+ UUIDField,
Value,
When,
)
@@ -156,6 +159,7 @@ from products.signals.backend.models import (
SignalUserAutonomyConfig,
)
from products.signals.backend.personal_ranking.config import PERSONAL_INBOX_RANKING_FLAG
+from products.signals.backend.personal_ranking.list_sort import PersonalListOrder, personal_list_order
from products.signals.backend.personal_ranking.serve import serve_personal_ranking
from products.signals.backend.pr_ci_status import pr_ci_statuses_for_references, rollup_ci_status
from products.signals.backend.presentation.scout_permissions import ScoutCanonicalTeamAccessPermission
@@ -1397,11 +1401,22 @@ class SignalReportListPagination(FacadeLimitOffsetPagination):
"type": "string",
"nullable": True,
"description": (
- "The ranker that ordered the page when sort=recommended: priority, or open, action or fix "
- "for that outcome of the served ranking model. Null for every other sort. Each row's "
+ "The ranker that ordered the page when sort=recommended or sort=personal: priority, or open, "
+ "action or fix for that outcome of the served ranking model. For sort=personal it is personal "
+ "when your stored personal ranking ordered the page. Null for every other sort. Each row's "
"inbox_merge_key belongs to this ranker."
),
}
+ paginated["properties"]["ranking_id"] = {
+ "type": "string",
+ "format": "uuid",
+ "nullable": True,
+ "description": (
+ "The stored personal ranking that ordered the page when sort=personal. Pass it back as "
+ "ranking_id on later pages, so a new ranking does not reorder them. Null when no personal "
+ "ranking applied, and for every other sort."
+ ),
+ }
paginated["properties"]["count_is_capped"] = {
"type": "boolean",
"description": (
@@ -1413,8 +1428,8 @@ class SignalReportListPagination(FacadeLimitOffsetPagination):
"type": "boolean",
"nullable": True,
"description": (
- "Whether the client shows a ranking score pill on each card, when sort=recommended. "
- "The same flag arm sets this and the ranker. Null for every other sort."
+ "Whether the client shows a ranking score pill on each card, when sort=recommended or "
+ "sort=personal. The same flag arm sets this and the ranker. Null for every other sort."
),
}
return paginated
@@ -1605,11 +1620,14 @@ _REPORT_LIST_PARAMETERS = [
location=OpenApiParameter.QUERY,
required=False,
description=(
- "Inbox sort preset: priority, recommended, last_updated, newest, or oldest. Ignored when "
- "ordering is supplied. recommended resolves per user to a ranker: the priority order, or "
+ "Inbox sort preset: priority, recommended, personal, last_updated, newest, or oldest. Ignored "
+ "when ordering is supplied. recommended resolves per user to a ranker: the priority order, or "
"the open, action or fix outcome of the served ranking model, highest score first, with "
"unscored and stale reports in priority order after the scored ones. The response's ranker "
- "field names the one used, and its ranking_pill field says whether to show score pills."
+ "field names the one used, and its ranking_pill field says whether to show score pills. "
+ "personal puts the reports of your stored personal ranking first, by rank, then the reports it "
+ "folded, then every other report in your recommended order. It only reads the stored ranking "
+ "and never starts a build. With no stored personal ranking, it is the recommended order."
),
),
OpenApiParameter(
@@ -1756,6 +1774,8 @@ class SignalReportViewSet(
"priority": PRIORITY_ORDERING,
# A feature flag resolves this preset per user. See `_recommended_arm`.
"recommended": PRIORITY_ORDERING,
+ # `_personal_order` puts the stored ranking before the recommended arm's order.
+ "personal": PRIORITY_ORDERING,
"last_updated": "-updated_at,status",
"newest": "-created_at,status,-updated_at",
"oldest": "created_at,status,-updated_at",
@@ -2765,14 +2785,36 @@ class SignalReportViewSet(
@cached_property
def _recommended_arm(self) -> RecommendedArm | None:
params = self.request.query_params
- if params.get("ordering") is not None or params.get("sort") != "recommended":
+ inbox_sort = params.get("sort")
+ if params.get("ordering") is not None or inbox_sort not in ("recommended", "personal"):
+ return None
+ # The personal sort only borrows the arm's order, so it records no exposure for the experiment.
+ return resolve_recommended_arm(
+ self.team, cast(User, self.request.user), send_feature_flag_events=inbox_sort == "recommended"
+ )
+
+ @cached_property
+ def _personal_order(self) -> PersonalListOrder | None:
+ request = self.request
+ user = request.user
+ if (
+ self._recommended_arm is None
+ or request.query_params.get("sort") != "personal"
+ or is_service_auth(request)
+ or not isinstance(user, User)
+ or not user_flag_enabled(PERSONAL_INBOX_RANKING_FLAG, user, self.team)
+ ):
return None
- return resolve_recommended_arm(self.team, cast(User, self.request.user))
+ return personal_list_order(self.team, user, request.query_params.get("ranking_id"))
@property
- def _inbox_ranker(self) -> InboxRanker | None:
+ def _base_inbox_ranker(self) -> InboxRanker | None:
return self._recommended_arm.ranker if self._recommended_arm is not None else None
+ @property
+ def _inbox_ranker(self) -> str | None:
+ return "personal" if self._personal_order is not None else self._base_inbox_ranker
+
def _parse_signal_report_ordering(self) -> list[str]:
arm = self._recommended_arm
if arm is not None:
@@ -2800,6 +2842,17 @@ class SignalReportViewSet(
clauses = [*clauses, "id"]
ranking_annotations = {self._SIGNAL_REPORT_ORDERING_FIELDS[field] for field in self._RANKING_ORDERING_HEADS}
order_by: list[str | OrderBy] = []
+ personal_order = self._personal_order
+ if personal_order is not None:
+ queryset = queryset.annotate(
+ personal_rank=Func(
+ Value(list(personal_order.report_ids), output_field=ArrayField(UUIDField())),
+ F("id"),
+ function="array_position",
+ output_field=IntegerField(),
+ )
+ )
+ order_by.append(F("personal_rank").asc(nulls_last=True))
for clause in clauses:
name = clause.lstrip("-")
if name in ranking_annotations:
@@ -3136,11 +3189,13 @@ class SignalReportViewSet(
if count_only:
# A count orders nothing, so it must not record a flag exposure for the ranker.
self._recommended_arm = None
+ self._personal_order = None
with trial_state_errors():
store = trial_store_for_request(request, self.team_id)
if store is not None:
# Private trial reads compare against the priority order, never a flag arm.
self._recommended_arm = None
+ self._personal_order = None
return TrialInboxReads(self, store).list(
count_only=count_only, include_source_metadata=include_source_metadata
)
@@ -3209,6 +3264,7 @@ class SignalReportViewSet(
response.data["ranking_pill"] = (
self._recommended_arm.ranking_pill if self._recommended_arm is not None else None
)
+ response.data["ranking_id"] = self._personal_order.ranking_id if self._personal_order is not None else None
return response
return Response(data)
@@ -3313,7 +3369,8 @@ class SignalReportViewSet(
"scout_names_map": {rid: meta.scout_name for rid, meta in signal_meta_map.items() if meta.scout_name},
**self._claim_and_pull_request_context(report_ids, pull_requests_map, claims),
"first_billable_pr_run_at_map": first_billable_pr_run_at_map,
- "inbox_ranker": self._inbox_ranker,
+ "inbox_ranker": self._base_inbox_ranker,
+ "personal_order": self._personal_order,
"source_issues_map": source_issues_by_report(team_id=self.team_id, report_ids=report_ids),
}
serializer = self.get_serializer(reports, many=True, context=context)
diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.ts
index 4a8846681e9f..f112d4f44d17 100644
--- a/products/signals/frontend/generated/api.schemas.ts
+++ b/products/signals/frontend/generated/api.schemas.ts
@@ -2524,10 +2524,20 @@ export interface SignalReportListApi {
/** The plan this report leads or is a step of, with every step in it. A report that other reports link to with `part_of` is a plan. Null when the report is in no plan, and always null in list responses, because finding a plan's steps costs several queries per report. */
readonly plan: ReportPlanApi | null
/**
- * Sort key from the ranker named by the list response's ranker field, for sort=recommended only. Lower keys rank first, so rows from several requests merge in the order of one request. For an outcome ranker (open, action or fix), a scored report gets 1 minus its score, from 0 to 1, and a report without a usable score gets 2 plus its priority rank. The priority ranker uses the priority rank only, from 0 (P0) to 5 (no priority). Null for every other sort.
+ * Sort key from the ranker named by the list response's ranker field, for sort=recommended and sort=personal only. Lower keys rank first, so rows from several requests merge in the order of one request. For an outcome ranker (open, action or fix), a scored report gets 1 minus its score, from 0 to 1, and a report without a usable score gets 2 plus its priority rank. The priority ranker uses the priority rank only, from 0 (P0) to 5 (no priority). For the personal ranker, a report in the stored personal ranking gets its position in that ranking from 0, and every other report gets the number of those positions plus its key from the recommended ranker. Null for every other sort.
* @nullable
*/
readonly inbox_merge_key: number | null
+ /**
+ * The tier your personal ranking gave this report, for sort=personal. Null when the language model did not rank the report, and for every other sort.
+ * @nullable
+ */
+ readonly personal_tier: string | null
+ /**
+ * Why your personal ranking put this report where it is, for sort=personal. Null when the language model did not rank the report, and for every other sort.
+ * @nullable
+ */
+ readonly personal_reason: string | null
}
export interface PaginatedSignalReportListListApi {
@@ -2538,14 +2548,19 @@ export interface PaginatedSignalReportListListApi {
previous?: string | null
results: SignalReportListApi[]
/**
- * The ranker that ordered the page when sort=recommended: priority, or open, action or fix for that outcome of the served ranking model. Null for every other sort. Each row's inbox_merge_key belongs to this ranker.
+ * The ranker that ordered the page when sort=recommended or sort=personal: priority, or open, action or fix for that outcome of the served ranking model. For sort=personal it is personal when your stored personal ranking ordered the page. Null for every other sort. Each row's inbox_merge_key belongs to this ranker.
* @nullable
*/
ranker?: string | null
+ /**
+ * The stored personal ranking that ordered the page when sort=personal. Pass it back as ranking_id on later pages, so a new ranking does not reorder them. Null when no personal ranking applied, and for every other sort.
+ * @nullable
+ */
+ ranking_id?: string | null
/** True when `count` stopped at a cap, so it is a lower bound and `next` keeps paging past it. Only a search with a full page can cap the count. */
count_is_capped?: boolean
/**
- * Whether the client shows a ranking score pill on each card, when sort=recommended. The same flag arm sets this and the ranker. Null for every other sort.
+ * Whether the client shows a ranking score pill on each card, when sort=recommended or sort=personal. The same flag arm sets this and the ranker. Null for every other sort.
* @nullable
*/
ranking_pill?: boolean | null
@@ -11277,6 +11292,10 @@ export type SignalsReportsListParams = {
* Comma-separated list of priorities to include. Valid values: P0, P1, P2, P3, P4. Reports without a priority assignment are excluded when this filter is set.
*/
priority?: string
+ /**
+ * For sort=personal: the ranking_id of the first page. Pass it on later pages, so a new personal ranking does not reorder them. When that ranking no longer exists, the latest one applies.
+ */
+ ranking_id?: string
/**
* Comma-separated <outcome>:<lift> pairs, e.g. fix:2,open:1.5. Keeps reports whose served ranking lift is at least the value for every named outcome. Outcomes: open, action, fix. Read inbox-ranking-outcomes-list for what each outcome means. Unscored and stale reports never match. Needs staff or the inbox model sort rollout: other users get a 400.
*/
@@ -11302,7 +11321,7 @@ export type SignalsReportsListParams = {
*/
search?: string
/**
- * Inbox sort preset: priority, recommended, last_updated, newest, or oldest. Ignored when ordering is supplied. recommended resolves per user to a ranker: the priority order, or the open, action or fix outcome of the served ranking model, highest score first, with unscored and stale reports in priority order after the scored ones. The response's ranker field names the one used, and its ranking_pill field says whether to show score pills.
+ * Inbox sort preset: priority, recommended, personal, last_updated, newest, or oldest. Ignored when ordering is supplied. recommended resolves per user to a ranker: the priority order, or the open, action or fix outcome of the served ranking model, highest score first, with unscored and stale reports in priority order after the scored ones. The response's ranker field names the one used, and its ranking_pill field says whether to show score pills. personal puts the reports of your stored personal ranking first, by rank, then the reports it folded, then every other report in your recommended order. It only reads the stored ranking and never starts a build. With no stored personal ranking, it is the recommended order.
*/
sort?: string
/**
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index b082f80083e1..acdeed5ad65c 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -75054,10 +75054,20 @@ export namespace Schemas {
/** The plan this report leads or is a step of, with every step in it. A report that other reports link to with `part_of` is a plan. Null when the report is in no plan, and always null in list responses, because finding a plan's steps costs several queries per report. */
readonly plan: ReportPlan | null;
/**
- * Sort key from the ranker named by the list response's ranker field, for sort=recommended only. Lower keys rank first, so rows from several requests merge in the order of one request. For an outcome ranker (open, action or fix), a scored report gets 1 minus its score, from 0 to 1, and a report without a usable score gets 2 plus its priority rank. The priority ranker uses the priority rank only, from 0 (P0) to 5 (no priority). Null for every other sort.
+ * Sort key from the ranker named by the list response's ranker field, for sort=recommended and sort=personal only. Lower keys rank first, so rows from several requests merge in the order of one request. For an outcome ranker (open, action or fix), a scored report gets 1 minus its score, from 0 to 1, and a report without a usable score gets 2 plus its priority rank. The priority ranker uses the priority rank only, from 0 (P0) to 5 (no priority). For the personal ranker, a report in the stored personal ranking gets its position in that ranking from 0, and every other report gets the number of those positions plus its key from the recommended ranker. Null for every other sort.
* @nullable
*/
readonly inbox_merge_key: number | null;
+ /**
+ * The tier your personal ranking gave this report, for sort=personal. Null when the language model did not rank the report, and for every other sort.
+ * @nullable
+ */
+ readonly personal_tier: string | null;
+ /**
+ * Why your personal ranking put this report where it is, for sort=personal. Null when the language model did not rank the report, and for every other sort.
+ * @nullable
+ */
+ readonly personal_reason: string | null;
}
export interface PaginatedSignalReportListList {
@@ -75068,14 +75078,19 @@ export namespace Schemas {
previous?: string | null;
results: SignalReportList[];
/**
- * The ranker that ordered the page when sort=recommended: priority, or open, action or fix for that outcome of the served ranking model. Null for every other sort. Each row's inbox_merge_key belongs to this ranker.
+ * The ranker that ordered the page when sort=recommended or sort=personal: priority, or open, action or fix for that outcome of the served ranking model. For sort=personal it is personal when your stored personal ranking ordered the page. Null for every other sort. Each row's inbox_merge_key belongs to this ranker.
* @nullable
*/
ranker?: string | null;
+ /**
+ * The stored personal ranking that ordered the page when sort=personal. Pass it back as ranking_id on later pages, so a new ranking does not reorder them. Null when no personal ranking applied, and for every other sort.
+ * @nullable
+ */
+ ranking_id?: string | null;
/** True when `count` stopped at a cap, so it is a lower bound and `next` keeps paging past it. Only a search with a full page can cap the count. */
count_is_capped?: boolean;
/**
- * Whether the client shows a ranking score pill on each card, when sort=recommended. The same flag arm sets this and the ranker. Null for every other sort.
+ * Whether the client shows a ranking score pill on each card, when sort=recommended or sort=personal. The same flag arm sets this and the ranker. Null for every other sort.
* @nullable
*/
ranking_pill?: boolean | null;
@@ -133435,6 +133450,10 @@ export namespace Schemas {
* Comma-separated list of priorities to include. Valid values: P0, P1, P2, P3, P4. Reports without a priority assignment are excluded when this filter is set.
*/
priority?: string;
+ /**
+ * For sort=personal: the ranking_id of the first page. Pass it on later pages, so a new personal ranking does not reorder them. When that ranking no longer exists, the latest one applies.
+ */
+ ranking_id?: string;
/**
* Comma-separated <outcome>:<lift> pairs, e.g. fix:2,open:1.5. Keeps reports whose served ranking lift is at least the value for every named outcome. Outcomes: open, action, fix. Read inbox-ranking-outcomes-list for what each outcome means. Unscored and stale reports never match. Needs staff or the inbox model sort rollout: other users get a 400.
*/
@@ -133460,7 +133479,7 @@ export namespace Schemas {
*/
search?: string;
/**
- * Inbox sort preset: priority, recommended, last_updated, newest, or oldest. Ignored when ordering is supplied. recommended resolves per user to a ranker: the priority order, or the open, action or fix outcome of the served ranking model, highest score first, with unscored and stale reports in priority order after the scored ones. The response's ranker field names the one used, and its ranking_pill field says whether to show score pills.
+ * Inbox sort preset: priority, recommended, personal, last_updated, newest, or oldest. Ignored when ordering is supplied. recommended resolves per user to a ranker: the priority order, or the open, action or fix outcome of the served ranking model, highest score first, with unscored and stale reports in priority order after the scored ones. The response's ranker field names the one used, and its ranking_pill field says whether to show score pills. personal puts the reports of your stored personal ranking first, by rank, then the reports it folded, then every other report in your recommended order. It only reads the stored ranking and never starts a build. With no stored personal ranking, it is the recommended order.
*/
sort?: string;
/**
diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.ts
index 7ec151340cd0..6c6bd78845a6 100644
--- a/services/mcp/src/generated/signals/api.ts
+++ b/services/mcp/src/generated/signals/api.ts
@@ -492,6 +492,12 @@ export const SignalsReportsListQueryParams = () => zod.object({
.describe(
'Comma-separated list of priorities to include. Valid values: P0, P1, P2, P3, P4. Reports without a priority assignment are excluded when this filter is set.'
),
+ ranking_id: zod
+ .string()
+ .optional()
+ .describe(
+ 'For sort=personal: the ranking_id of the first page. Pass it on later pages, so a new personal ranking does not reorder them. When that ranking no longer exists, the latest one applies.'
+ ),
ranking_min_lift: zod
.string()
.optional()
@@ -525,7 +531,7 @@ export const SignalsReportsListQueryParams = () => zod.object({
.string()
.optional()
.describe(
- "Inbox sort preset: priority, recommended, last_updated, newest, or oldest. Ignored when ordering is supplied. recommended resolves per user to a ranker: the priority order, or the open, action or fix outcome of the served ranking model, highest score first, with unscored and stale reports in priority order after the scored ones. The response's ranker field names the one used, and its ranking_pill field says whether to show score pills."
+ "Inbox sort preset: priority, recommended, personal, last_updated, newest, or oldest. Ignored when ordering is supplied. recommended resolves per user to a ranker: the priority order, or the open, action or fix outcome of the served ranking model, highest score first, with unscored and stale reports in priority order after the scored ones. The response's ranker field names the one used, and its ranking_pill field says whether to show score pills. personal puts the reports of your stored personal ranking first, by rank, then the reports it folded, then every other report in your recommended order. It only reads the stored ranking and never starts a build. With no stored personal ranking, it is the recommended order."
),
source_id: zod
.string()
diff --git a/services/mcp/src/tools/generated/signals.ts b/services/mcp/src/tools/generated/signals.ts
index 47b17534c203..2973cbcc36be 100644
--- a/services/mcp/src/tools/generated/signals.ts
+++ b/services/mcp/src/tools/generated/signals.ts
@@ -825,6 +825,7 @@ const inboxReportsList = (): ToolBase<
offset: params.offset,
ordering: params.ordering,
priority: params.priority,
+ ranking_id: params.ranking_id,
ranking_min_lift: params.ranking_min_lift,
ranking_min_probability: params.ranking_min_probability,
scope: params.scope,
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.json
index c2083aea22d4..06693024951b 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
@@ -72,6 +72,10 @@
"description": "Comma-separated list of priorities to include. Valid values: P0, P1, P2, P3, P4. Reports without a priority assignment are excluded when this filter is set.",
"type": "string"
},
+ "ranking_id": {
+ "description": "For sort=personal: the ranking_id of the first page. Pass it on later pages, so a new personal ranking does not reorder them. When that ranking no longer exists, the latest one applies.",
+ "type": "string"
+ },
"ranking_min_lift": {
"description": "Comma-separated <outcome>:<lift> pairs, e.g. fix:2,open:1.5. Keeps reports whose served ranking lift is at least the value for every named outcome. Outcomes: open, action, fix. Read inbox-ranking-outcomes-list for what each outcome means. Unscored and stale reports never match. Needs staff or the inbox model sort rollout: other users get a 400.",
"type": "string"
@@ -97,7 +101,7 @@
"type": "string"
},
"sort": {
- "description": "Inbox sort preset: priority, recommended, last_updated, newest, or oldest. Ignored when ordering is supplied. recommended resolves per user to a ranker: the priority order, or the open, action or fix outcome of the served ranking model, highest score first, with unscored and stale reports in priority order after the scored ones. The response's ranker field names the one used, and its ranking_pill field says whether to show score pills.",
+ "description": "Inbox sort preset: priority, recommended, personal, last_updated, newest, or oldest. Ignored when ordering is supplied. recommended resolves per user to a ranker: the priority order, or the open, action or fix outcome of the served ranking model, highest score first, with unscored and stale reports in priority order after the scored ones. The response's ranker field names the one used, and its ranking_pill field says whether to show score pills. personal puts the reports of your stored personal ranking first, by rank, then the reports it folded, then every other report in your recommended order. It only reads the stored ranking and never starts a build. With no stored personal ranking, it is the recommended order.",
"type": "string"
},
"source_id": {