: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
fix(signals): keep ranking training metadata out of the artefact list (#117791)
posthog[bot]d21b08a1b068
diff --git a/products/signals/backend/serializers.py b/products/signals/backend/serializers.pyindex 9bb737c57b9a..6d52f1c28048 100644--- a/products/signals/backend/serializers.py+++ b/products/signals/backend/serializers.py@@ -2419,6 +2419,35 @@ class SignalReportCheckWriteSerializer(serializers.Serializer):return attrs+# The head fields a reader needs to show a score: readability and the base rate behind each lift.+_COMPACT_RANKING_HEAD_FIELDS = ("head", "readable", "refit_classification_threshold")+++def compact_ranking_score_content(content: dict) -> dict:+ """Drop the copied model metadata from a `ranking_score` row, except the head fields that read a score.++ The metadata holds training and holdout data that is tens of KB per model, so a work log with a+ few scores is mostly metadata. The single-artefact read keeps the full row.+ """+ results = content.get("results")+ if not isinstance(results, dict):+ return content+ compact_results = {}+ for key, result in results.items():+ if not isinstance(result, dict):+ compact_results[key] = result+ continue+ metadata = result.get("metadata")+ heads = metadata.get("heads") if isinstance(metadata, dict) else None+ compact_heads = [+ {field: entry[field] for field in _COMPACT_RANKING_HEAD_FIELDS if field in entry}+ for entry in (heads if isinstance(heads, list) else [])+ if isinstance(entry, dict)+ ]+ compact_results[key] = {**result, "metadata": {"heads": compact_heads}}+ return {**content, "results": compact_results}++class SignalReportArtefactSerializer(serializers.ModelSerializer):claim_id = serializers.UUIDField(read_only=True, allow_null=True, help_text="Work claim that produced this artefact."@@ -2501,6 +2530,13 @@ class SignalReportArtefactSerializer(serializers.ModelSerializer):if obj.type == SignalReportArtefact.ArtefactType.CHECK_RESULT and isinstance(parsed, dict):return self._redact_check_result(obj, parsed)+ if (+ obj.type == SignalReportArtefact.ArtefactType.RANKING_SCORE+ and isinstance(parsed, dict)+ and self.context.get("signals_compact_ranking_scores")+ ):+ return compact_ranking_score_content(parsed)+if obj.type == SignalReportArtefact.ArtefactType.IMPACT_MEASUREMENT_PLAN and isinstance(parsed, dict):policy = report_metric_access_policy(self.context)if not policy.may_read_query(parsed) or (diff --git a/products/signals/backend/test/test_signal_report_api.py b/products/signals/backend/test/test_signal_report_api.pyindex 5584c6e1a4a8..b9d850d969a2 100644--- a/products/signals/backend/test/test_signal_report_api.py+++ b/products/signals/backend/test/test_signal_report_api.py@@ -957,15 +957,34 @@ class TestSignalReportListAPI(APIBaseTest):self.user.is_staff = is_staffself.user.save()report = self._create_report()- artefact = self._ranking_score_artefact(report)+ full_heads = [+ {"head": "open", "readable": True, "refit_classification_threshold": 0.25, "holdout": {"auc": 0.7}},+ {"head": "merged", "readable": False},+ ]+ artefact = self._ranking_score_artefact(report, heads=full_heads)+ SignalReportArtefact.objects.create(+ team=self.team, report=report, type=SignalReportArtefact.ArtefactType.NOTE, content=json.dumps({})+ )url = f"/api/projects/{self.team.id}/signals/reports/{report.id}/artefacts/"response = self.client.get(url)assert response.status_code == status.HTTP_200_OK- assert [row["type"] for row in response.json()["results"]] == expected_types+ rows = response.json()["results"]+ assert [row["type"] for row in rows] == ["note", *expected_types]detail = self.client.get(f"{url}{artefact.id}/")assert detail.status_code == (status.HTTP_200_OK if is_staff else status.HTTP_404_NOT_FOUND)+ if is_staff:+ served_key = "report_embeddings@2026-09-01"+ listed = rows[1]["content"]["results"][served_key]+ assert listed["scores"] == {"open": 0.5, "merged": 0.2}+ assert listed["metadata"] == {+ "heads": [+ {"head": "open", "readable": True, "refit_classification_threshold": 0.25},+ {"head": "merged", "readable": False},+ ]+ }+ assert detail.json()["content"]["results"][served_key]["metadata"] == {"heads": full_heads}def test_filter_by_channel_id_narrows_to_that_space(self):channel = Channel.objects.create(team=self.team, name="Reports")diff --git a/products/signals/backend/views.py b/products/signals/backend/views.pyindex f5fdc191876e..4a4bf3d23105 100644--- a/products/signals/backend/views.py+++ b/products/signals/backend/views.py@@ -5378,7 +5378,9 @@ class SignalReportCheckViewSet("behind the report), status judgments (safety / actionability / priority, repo ""selection, suggested reviewers — the newest row of each status type is canonical), ""and log entries (code references, commits, task runs, notes). "- "`suggested_reviewers` content is enriched with PostHog user info at read time."+ "`suggested_reviewers` content is enriched with PostHog user info at read time. "+ "`ranking_score` content keeps only the head fields of each model's metadata; get the "+ "artefact by id for the full metadata."),parameters=[_REPORT_ID_PARAMETER],responses={200: SignalReportArtefactSerializer(many=True)},@@ -5386,7 +5388,10 @@ class SignalReportCheckViewSet(),retrieve=extend_schema(summary="Get a single artefact",- description="Get one artefact by id, content parsed (and reviewers enriched) the same way as the list.",+ description=(+ "Get one artefact by id, content parsed (and reviewers enriched) the same way as the list. "+ "A `ranking_score` keeps its full model metadata."+ ),parameters=[_REPORT_ID_PARAMETER],responses={200: SignalReportArtefactSerializer},operation_id="signals_report_artefacts_retrieve",@@ -5516,6 +5521,7 @@ class SignalReportArtefactViewSet("signals_github_login_to_user_map": login_map,"signals_reviewer_user_uuid_map": uuid_map,"signals_scout_display_names": scout_display_names,+ "signals_compact_ranking_scores": True,"signals_reviewer_history": [artefactfor artefact in real_artefactsdiff --git a/products/signals/frontend/generated/api.ts b/products/signals/frontend/generated/api.tsindex f3d47dd51980..200507e9b330 100644--- a/products/signals/frontend/generated/api.ts+++ b/products/signals/frontend/generated/api.ts@@ -930,7 +930,7 @@ export const getSignalsReportArtefactsListUrl = (}/**- * List every artefact on a report — the full work log: signal findings (the evidence behind the report), status judgments (safety / actionability / priority, repo selection, suggested reviewers — the newest row of each status type is canonical), and log entries (code references, commits, task runs, notes). `suggested_reviewers` content is enriched with PostHog user info at read time.+ * List every artefact on a report — the full work log: signal findings (the evidence behind the report), status judgments (safety / actionability / priority, repo selection, suggested reviewers — the newest row of each status type is canonical), and log entries (code references, commits, task runs, notes). `suggested_reviewers` content is enriched with PostHog user info at read time. `ranking_score` content keeps only the head fields of each model's metadata; get the artefact by id for the full metadata.* @summary List a report's artefacts*/export const signalsReportArtefactsList = async (@@ -975,7 +975,7 @@ export const getSignalsReportArtefactsRetrieveUrl = (projectId: string, reportId}/**- * Get one artefact by id, content parsed (and reviewers enriched) the same way as the list.+ * Get one artefact by id, content parsed (and reviewers enriched) the same way as the list. A `ranking_score` keeps its full model metadata.* @summary Get a single artefact*/export const signalsReportArtefactsRetrieve = async (diff --git a/products/signals/mcp/tools.yaml b/products/signals/mcp/tools.yamlindex fccf97865d56..b7257cdb3e66 100644--- a/products/signals/mcp/tools.yaml+++ b/products/signals/mcp/tools.yaml@@ -69,7 +69,8 @@ tools:`signal_finding` entries (the evidence behind the report), status judgments (safety / actionability /priority, repo_selection, suggested_reviewers — the newest row of each status type is the canonical status),and work-log entries (code references, commits, task runs, notes). Read this before re-judging a status or- adding to the log.+ adding to the log. `ranking_score` entries are compact: each model keeps its scores, lifts, and head+ readability, but not its training metadata. Use inbox-report-artefacts-retrieve to read one in full.agent_note: >Find the newest applicable `## Verification plan`. Treat it as guidance, not evidence. Confirm the currentstate before work and the outcome after the chosen resolution. Missing or inconclusive evidence does not@@ -88,7 +89,8 @@ tools:title: Get a single artefactdescription: >Get one artefact by id. Content is parsed (and suggested_reviewers enriched with PostHog user info) the same- way as inbox-report-artefacts-list.+ way as inbox-report-artefacts-list. A `ranking_score` keeps its full model metadata, including training and+ evaluation data.inbox-report-artefacts-update:operation: signals_report_artefacts_partial_updateenabled: truediff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 5247dc8ab972..6d9806aa9bd0 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -6978,7 +6978,7 @@}},"inbox-report-artefacts-list": {- "description": "List every artefact on a signal report — the full picture of why it exists and what has been done about it: `signal_finding` entries (the evidence behind the report), status judgments (safety / actionability / priority, repo_selection, suggested_reviewers — the newest row of each status type is the canonical status), and work-log entries (code references, commits, task runs, notes). Read this before re-judging a status or adding to the log.",+ "description": "List every artefact on a signal report — the full picture of why it exists and what has been done about it: `signal_finding` entries (the evidence behind the report), status judgments (safety / actionability / priority, repo_selection, suggested_reviewers — the newest row of each status type is the canonical status), and work-log entries (code references, commits, task runs, notes). Read this before re-judging a status or adding to the log. `ranking_score` entries are compact: each model keeps its scores, lifts, and head readability, but not its training metadata. Use inbox-report-artefacts-retrieve to read one in full.","category": "Signals","feature": "signals","summary": "List a report's artefacts",@@ -6992,7 +6992,7 @@}},"inbox-report-artefacts-retrieve": {- "description": "Get one artefact by id. Content is parsed (and suggested_reviewers enriched with PostHog user info) the same way as inbox-report-artefacts-list.",+ "description": "Get one artefact by id. Content is parsed (and suggested_reviewers enriched with PostHog user info) the same way as inbox-report-artefacts-list. A `ranking_score` keeps its full model metadata, including training and evaluation data.","category": "Signals","feature": "signals","summary": "Get a single artefact",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 579ac9aaea81..5b84a9a6f971 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -7175,7 +7175,7 @@}},"inbox-report-artefacts-list": {- "description": "List every artefact on a signal report — the full picture of why it exists and what has been done about it: `signal_finding` entries (the evidence behind the report), status judgments (safety / actionability / priority, repo_selection, suggested_reviewers — the newest row of each status type is the canonical status), and work-log entries (code references, commits, task runs, notes). Read this before re-judging a status or adding to the log.",+ "description": "List every artefact on a signal report — the full picture of why it exists and what has been done about it: `signal_finding` entries (the evidence behind the report), status judgments (safety / actionability / priority, repo_selection, suggested_reviewers — the newest row of each status type is the canonical status), and work-log entries (code references, commits, task runs, notes). Read this before re-judging a status or adding to the log. `ranking_score` entries are compact: each model keeps its scores, lifts, and head readability, but not its training metadata. Use inbox-report-artefacts-retrieve to read one in full.","category": "Signals","feature": "signals","summary": "List a report's artefacts",@@ -7189,7 +7189,7 @@}},"inbox-report-artefacts-retrieve": {- "description": "Get one artefact by id. Content is parsed (and suggested_reviewers enriched with PostHog user info) the same way as inbox-report-artefacts-list.",+ "description": "Get one artefact by id. Content is parsed (and suggested_reviewers enriched with PostHog user info) the same way as inbox-report-artefacts-list. A `ranking_score` keeps its full model metadata, including training and evaluation data.","category": "Signals","feature": "signals","summary": "Get a single artefact",diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.tsindex 8aedcf93cda8..a02cb7c9daea 100644--- a/services/mcp/src/generated/signals/api.ts+++ b/services/mcp/src/generated/signals/api.ts@@ -517,7 +517,7 @@ export const SignalsReportsStateCreateBody = () => zod.object({})/**- * List every artefact on a report — the full work log: signal findings (the evidence behind the report), status judgments (safety / actionability / priority, repo selection, suggested reviewers — the newest row of each status type is canonical), and log entries (code references, commits, task runs, notes). `suggested_reviewers` content is enriched with PostHog user info at read time.+ * List every artefact on a report — the full work log: signal findings (the evidence behind the report), status judgments (safety / actionability / priority, repo selection, suggested reviewers — the newest row of each status type is canonical), and log entries (code references, commits, task runs, notes). `suggested_reviewers` content is enriched with PostHog user info at read time. `ranking_score` content keeps only the head fields of each model's metadata; get the artefact by id for the full metadata.* @summary List a report's artefacts*/export const SignalsReportArtefactsListParams = () => zod.object({@@ -586,7 +586,7 @@ export const SignalsReportArtefactsCreateBody = () => zod)/**- * Get one artefact by id, content parsed (and reviewers enriched) the same way as the list.+ * Get one artefact by id, content parsed (and reviewers enriched) the same way as the list. A `ranking_score` keeps its full model metadata.* @summary Get a single artefact*/export const SignalsReportArtefactsRetrieveParams = () => zod.object({