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): store slug tags on inbox reports (#120544)

posthog[bot]1dbc099399d5
diff --git a/products/signals/backend/migrations/0196_signalreport_tags.py b/products/signals/backend/migrations/0196_signalreport_tags.py
new file mode 100644
index 000000000000..8505f63edac8
--- /dev/null
+++ b/products/signals/backend/migrations/0196_signalreport_tags.py
@@ -0,0 +1,24 @@
+# Generated by Django 5.2.18 on 2026-10-20 16:45
+
+import django.contrib.postgres.fields
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("signals", "0195_signalemissionrecord_source_assignment"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="signalreport",
+ name="tags",
+ field=django.contrib.postgres.fields.ArrayField(
+ base_field=models.CharField(max_length=50),
+ blank=True,
+ db_default=[],
+ default=list,
+ size=None,
+ ),
+ ),
+ ]
diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txt
index 50a4464b8108..4d74765f45f3 100644
--- a/products/signals/backend/migrations/max_migration.txt
+++ b/products/signals/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0195_signalemissionrecord_source_assignment
+0196_signalreport_tags
diff --git a/products/signals/backend/models.py b/products/signals/backend/models.py
index dab01b405217..5a0ae0d34f19 100644
--- a/products/signals/backend/models.py
+++ b/products/signals/backend/models.py
@@ -365,6 +365,10 @@ class SignalReport(UUIDModel):
POSTHOG_ONBOARDING = "posthog_onboarding", "PostHog onboarding"
POSTHOG_SYSTEM = "posthog_system", "PostHog system"
+ # Bounds on `tags`, the same as scout finding and task tags.
+ MAX_TAGS = 10
+ MAX_TAG_LENGTH = 50
+
team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
triggering_signal_id = models.UUIDField(null=True, blank=True)
pending_triggering_signal_id = models.UUIDField(null=True, blank=True)
@@ -438,6 +442,10 @@ class SignalReport(UUIDModel):
# leaving a stale question beside fresh prose. The inbox offers them above the "Ask AI" box.
# `db_default` alongside `default` for the reason spelled out on `charts`.
suggested_prompts = models.JSONField(default=list, db_default=[], blank=True)
+ # Free-form slug tags (lowercase kebab-case) for grouping and filtering reports. Writers go
+ # through `report_tags.set_report_tags`, which normalizes and caps them; report_tags.py holds
+ # the lifecycle rules. `db_default` for the reason spelled out on `charts`.
+ tags = ArrayField(models.CharField(max_length=MAX_TAG_LENGTH), default=list, db_default=[], blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
diff --git a/products/signals/backend/report_merge.py b/products/signals/backend/report_merge.py
index 597d3b91acef..e42296570f75 100644
--- a/products/signals/backend/report_merge.py
+++ b/products/signals/backend/report_merge.py
@@ -10,7 +10,8 @@ The caller names the survivor and the sources. Nothing here guesses which report
nothing here rewrites content: titles, summaries, charts and metrics are left exactly as they
were, so the survivor's embeddings are untouched and the outcome of a merge is predictable
without reading an LLM's mind. A caller that wants a combined summary edits the survivor
-afterwards, where the safety judge runs.
+afterwards, where the safety judge runs. Tags are metadata, not content: the survivor takes the
+union of its own tags and the sources' tags.
"""
from __future__ import annotations
@@ -42,6 +43,7 @@ from products.signals.backend.models import (
SignalScoutRun,
)
from products.signals.backend.recurrence import latest_recurrence_report
+from products.signals.backend.report_tags import set_report_tags, union_report_tags
from products.signals.backend.signal_metadata import REASSIGN_SIGNAL_ROW_CAP
logger = structlog.get_logger(__name__)
@@ -442,6 +444,8 @@ def merge_reports(
# duplicate_of cycle is a merge the caller cannot have, not a server fault.
raise ReportMergeError(str(e))
+ set_report_tags(survivor, union_report_tags(survivor.tags, *(source.tags for source in sources)))
+
SignalReportArtefact.add_log(
team_id=team.id,
report_id=str(survivor.id),
diff --git a/products/signals/backend/report_tags.py b/products/signals/backend/report_tags.py
new file mode 100644
index 000000000000..797f7ac8cd03
--- /dev/null
+++ b/products/signals/backend/report_tags.py
@@ -0,0 +1,64 @@
+"""Slug tags on inbox reports, and the rules every writer follows.
+
+- A writer sends the whole set. A list replaces the stored set, and `None` (an omitted field)
+ keeps it. This is the task tags rule.
+- A merge gives the survivor the union of its own tags and the sources' tags (`union_report_tags`).
+- A stack plan layer starts with the plan's tags.
+- A report never takes tags from its signals' `extra.tags`.
+
+Tags live in the `SignalReport.tags` column, not in the shared `TaggedItem` system. Every reader
+filters one column with no join, `Tag` rows would show report tags in the tag picker for other
+objects, and a `TaggedItem` delete writes an activity log row on each replace.
+"""
+
+from collections.abc import Sequence
+
+from products.signals.backend.models import SignalReport
+from products.signals.backend.scout_harness.tags import slugify_tag
+
+
+def normalize_report_tags(tags: list[str]) -> list[str]:
+ """Deduped kebab-case slugs in first-seen order, by the same rules as scout finding tags.
+
+ Raises `ValueError` when there are more than `SignalReport.MAX_TAGS`, or when a tag is empty or
+ too long after normalization, so a writer learns that its tags did not stick.
+ """
+ if len(tags) > SignalReport.MAX_TAGS:
+ raise ValueError(f"tags has {len(tags)} entries, max is {SignalReport.MAX_TAGS}")
+ normalized: list[str] = []
+ for raw in tags:
+ slug = slugify_tag(raw)
+ if not slug:
+ raise ValueError(f"tag {raw!r} is empty after slug normalization")
+ if len(slug) > SignalReport.MAX_TAG_LENGTH:
+ raise ValueError(f"tag {raw!r} exceeds {SignalReport.MAX_TAG_LENGTH} chars after normalization")
+ if slug not in normalized:
+ normalized.append(slug)
+ return normalized
+
+
+def set_report_tags(report: SignalReport, tags: list[str] | None) -> bool:
+ """Replace the report's tags with `normalize_report_tags(tags)`.
+
+ Returns True when the stored set changed. Raises `ValueError` from `normalize_report_tags` and
+ leaves the stored set as it was.
+ """
+ if tags is None:
+ return False
+ normalized = normalize_report_tags(tags)
+ if normalized == report.tags:
+ return False
+ report.tags = normalized
+ # Only `tags`, so a retag does not bump `updated_at` and skips the status and document receivers.
+ report.save(update_fields=["tags"])
+ return True
+
+
+def union_report_tags(*tag_sets: Sequence[str]) -> list[str]:
+ """The union of already-normalized tag sets in first-seen order, capped at `SignalReport.MAX_TAGS`."""
+ merged: list[str] = []
+ for tags in tag_sets:
+ for tag in tags:
+ if tag not in merged:
+ merged.append(tag)
+ return merged[: SignalReport.MAX_TAGS]
diff --git a/products/signals/backend/serializers.py b/products/signals/backend/serializers.py
index 60f31fb59fa2..1e7cf27952c7 100644
--- a/products/signals/backend/serializers.py
+++ b/products/signals/backend/serializers.py
@@ -1360,6 +1360,14 @@ class SignalReportSerializer(serializers.ModelSerializer):
"above the `Ask AI` box; clicking one fills the box with it."
),
)
+ tags = serializers.ListField(
+ child=serializers.CharField(),
+ read_only=True,
+ help_text=(
+ "Free-form lowercase kebab-case slug tags for grouping and filtering reports, at most 10. "
+ "Empty when the report has no tags."
+ ),
+ )
refund_ineligibility_reason = serializers.SerializerMethodField(
help_text=(
"Why refunding this report's PR would be rejected right now, or null when a refund "
@@ -1512,6 +1520,7 @@ class SignalReportSerializer(serializers.ModelSerializer):
"charts",
"metrics",
"suggested_prompts",
+ "tags",
"source_suggestion",
"priority",
"actionability",
diff --git a/products/signals/backend/stack_plan.py b/products/signals/backend/stack_plan.py
index aee0514e2ddd..b79b22fb84eb 100644
--- a/products/signals/backend/stack_plan.py
+++ b/products/signals/backend/stack_plan.py
@@ -125,6 +125,7 @@ def create_layer_reports(
# and lifecycle monitoring expects that event from every promoted report.
first_visible_at=now,
billing_exempt_reason=billing_exempt_reason,
+ tags=list(parent.tags),
)
child_id = str(child.id)
for judgment in judgments:
diff --git a/products/signals/backend/test/test_report_tags.py b/products/signals/backend/test/test_report_tags.py
new file mode 100644
index 000000000000..e630ddee471f
--- /dev/null
+++ b/products/signals/backend/test/test_report_tags.py
@@ -0,0 +1,51 @@
+import pytest
+from posthog.test.base import BaseTest
+
+from django.test import SimpleTestCase
+
+from parameterized import parameterized
+
+from products.signals.backend.models import SignalReport
+from products.signals.backend.report_tags import set_report_tags, union_report_tags
+
+
+class TestSetReportTags(BaseTest):
+ def setUp(self):
+ super().setUp()
+ self.report = SignalReport.objects.create(team=self.team, tags=["billing", "api"])
+
+ @parameterized.expand(
+ [
+ ("omitted_keeps_the_set", None, False, ["billing", "api"]),
+ ("list_replaces_the_set", ["Cost Spike", "cost_spike", "web"], True, ["cost-spike", "web"]),
+ ("empty_list_clears_the_set", [], True, []),
+ ("same_set_writes_nothing", ["billing", "API"], False, ["billing", "api"]),
+ ]
+ )
+ def test_set_report_tags(self, _name: str, tags: list[str] | None, changed: bool, expected: list[str]):
+ assert set_report_tags(self.report, tags) is changed
+
+ self.report.refresh_from_db()
+ assert self.report.tags == expected
+
+ @parameterized.expand(
+ [
+ ("too_many", [f"tag-{i}" for i in range(SignalReport.MAX_TAGS + 1)]),
+ ("empty_after_normalization", ["!!!"]),
+ ("too_long", ["x" * (SignalReport.MAX_TAG_LENGTH + 1)]),
+ ]
+ )
+ def test_invalid_tags_are_rejected_and_keep_the_set(self, _name: str, tags: list[str]):
+ with pytest.raises(ValueError):
+ set_report_tags(self.report, tags)
+
+ self.report.refresh_from_db()
+ assert self.report.tags == ["billing", "api"]
+
+
+class TestUnionReportTags(SimpleTestCase):
+ def test_union_keeps_first_seen_order_and_caps_the_count(self):
+ survivor = [f"own-{i}" for i in range(8)]
+ source = ["own-0", "src-a", "src-b", "src-c"]
+
+ assert union_report_tags(survivor, source) == [*survivor, "src-a", "src-b"]
diff --git a/products/signals/backend/test/test_signal_report_api.py b/products/signals/backend/test/test_signal_report_api.py
index 823ff8f01af0..60a9dddb83e0 100644
--- a/products/signals/backend/test/test_signal_report_api.py
+++ b/products/signals/backend/test/test_signal_report_api.py
@@ -3702,8 +3702,10 @@ class TestSignalReportMergeAPI(APIBaseTest):
)
def test_merge_moves_the_work_log_and_archives_the_source(self):
- survivor = self._report(signal_count=3, total_weight=1.5, corroboration_count=1)
- source = self._report(signal_count=2, total_weight=0.5, title="The twin", corroboration_count=4)
+ survivor = self._report(signal_count=3, total_weight=1.5, corroboration_count=1, tags=["billing"])
+ source = self._report(
+ signal_count=2, total_weight=0.5, title="The twin", corroboration_count=4, tags=["api", "billing"]
+ )
SignalReportArtefact.add_log(
team_id=self.team.id,
report_id=str(source.id),
@@ -3726,6 +3728,7 @@ class TestSignalReportMergeAPI(APIBaseTest):
]
# The response renders the survivor as it stands after the merge, counters included.
assert (payload["report"]["id"], payload["report"]["signal_count"]) == (str(survivor.id), 5)
+ assert payload["report"]["tags"] == ["billing", "api"]
survivor.refresh_from_db()
source.refresh_from_db()
diff --git a/products/signals/backend/test/test_stack_plan.py b/products/signals/backend/test/test_stack_plan.py
index a51e949d59a2..7d927b5f2ef1 100644
--- a/products/signals/backend/test/test_stack_plan.py
+++ b/products/signals/backend/test/test_stack_plan.py
@@ -90,7 +90,11 @@ class TestStackPlan(BaseTest):
def setUp(self):
super().setUp()
self.parent = SignalReport.objects.create(
- team=self.team, status=SignalReport.Status.READY, title="feat(x): the plan", summary="plan"
+ team=self.team,
+ status=SignalReport.Status.READY,
+ title="feat(x): the plan",
+ summary="plan",
+ tags=["billing", "api"],
)
for content in (
SafetyJudgment(choice=True),
@@ -161,6 +165,7 @@ class TestStackPlan(BaseTest):
"feat(x): ui",
]
assert all(child.status == SignalReport.Status.READY for child in children.values())
+ assert all(child.tags == ["billing", "api"] for child in children.values())
# A promoted report is expected to emit `signal_report_started`, and a layer never runs research.
assert all(child.promoted_at is None for child in children.values())
for index, child_id in enumerate(child_ids):
diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.ts
index faddf9d00478..3202e8902cc2 100644
--- a/products/signals/frontend/generated/api.schemas.ts
+++ b/products/signals/frontend/generated/api.schemas.ts
@@ -1459,6 +1459,8 @@ export interface SignalReportListApi {
readonly metrics: readonly ReportMetricListApi[]
/** Follow-up prompts the report's author suggests sending about it (questions to ask, or next-step actions to request), in the order they were written. The inbox offers them above the `Ask AI` box; clicking one fills the box with it. */
readonly suggested_prompts: readonly string[]
+ /** Free-form lowercase kebab-case slug tags for grouping and filtering reports, at most 10. Empty when the report has no tags. */
+ readonly tags: readonly string[]
/** A product the team does not use that would have given this report better evidence, from the latest source suggestion artefact. Null when there is none, or when the team now uses the product. Always null in list responses, because its in-use check can query ClickHouse. */
readonly source_suggestion: ReportSourceSuggestionApi | null
/**
@@ -1705,6 +1707,8 @@ export interface SignalReportApi {
readonly metrics: readonly ReportMetricApi[]
/** Follow-up prompts the report's author suggests sending about it (questions to ask, or next-step actions to request), in the order they were written. The inbox offers them above the `Ask AI` box; clicking one fills the box with it. */
readonly suggested_prompts: readonly string[]
+ /** Free-form lowercase kebab-case slug tags for grouping and filtering reports, at most 10. Empty when the report has no tags. */
+ readonly tags: readonly string[]
/** A product the team does not use that would have given this report better evidence, from the latest source suggestion artefact. Null when there is none, or when the team now uses the product. Always null in list responses, because its in-use check can query ClickHouse. */
readonly source_suggestion: ReportSourceSuggestionApi | null
/**
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 953eda674e05..532a38b8d2fe 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -77301,6 +77301,8 @@ export namespace Schemas {
readonly metrics: readonly ReportMetricList[];
/** Follow-up prompts the report's author suggests sending about it (questions to ask, or next-step actions to request), in the order they were written. The inbox offers them above the `Ask AI` box; clicking one fills the box with it. */
readonly suggested_prompts: readonly string[];
+ /** Free-form lowercase kebab-case slug tags for grouping and filtering reports, at most 10. Empty when the report has no tags. */
+ readonly tags: readonly string[];
/** A product the team does not use that would have given this report better evidence, from the latest source suggestion artefact. Null when there is none, or when the team now uses the product. Always null in list responses, because its in-use check can query ClickHouse. */
readonly source_suggestion: ReportSourceSuggestion | null;
/**
@@ -99269,6 +99271,8 @@ export namespace Schemas {
readonly metrics: readonly ReportMetric[];
/** Follow-up prompts the report's author suggests sending about it (questions to ask, or next-step actions to request), in the order they were written. The inbox offers them above the `Ask AI` box; clicking one fills the box with it. */
readonly suggested_prompts: readonly string[];
+ /** Free-form lowercase kebab-case slug tags for grouping and filtering reports, at most 10. Empty when the report has no tags. */
+ readonly tags: readonly string[];
/** A product the team does not use that would have given this report better evidence, from the latest source suggestion artefact. Null when there is none, or when the team now uses the product. Always null in list responses, because its in-use check can query ClickHouse. */
readonly source_suggestion: ReportSourceSuggestion | null;
/**