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): prepare monitoring report status (#114660)

Mikayla Thompson6fa441533d01
diff --git a/docs/internal/signals-pr-lifecycle.md b/docs/internal/signals-pr-lifecycle.md
index 5265a0735d46..1168aa42e347 100644
--- a/docs/internal/signals-pr-lifecycle.md
+++ b/docs/internal/signals-pr-lifecycle.md
@@ -3,6 +3,8 @@
A report completes after all linked implementation PRs are closed or merged.
At least one merged PR resolves the report; otherwise all closed PRs suppress it.
+The schema reserves `monitoring` and a nullable `monitoring_started_at`, but current report transitions do not enter that state. The organization-level `signals-report-monitoring` gate requires explicit enablement, including in local development, and treats evaluation failures as disabled.
+
Attaching a new open, draft, or unknown PR to a resolved report returns it to ready.
The shared PR-linking service applies this rule to task outputs and agent attachments.
An existing attachment retry does not reopen a report, and importing legacy assignments preserves its status.
diff --git a/products/signals/backend/admin.py b/products/signals/backend/admin.py
index 786aa84141c6..c5d4c6144781 100644
--- a/products/signals/backend/admin.py
+++ b/products/signals/backend/admin.py
@@ -1,7 +1,11 @@
+from __future__ import annotations
+
import re
from django import forms
from django.contrib import admin
+from django.db.models import QuerySet
+from django.http import HttpRequest
from django.urls import reverse
from django.utils.html import format_html
@@ -31,6 +35,23 @@ class SignalReportArtefactInline(admin.TabularInline):
return (obj.content[:200] + "...") if len(obj.content) > 200 else obj.content
+class SignalReportStatusFilter(admin.SimpleListFilter):
+ title = "status"
+ parameter_name = "status__exact"
+
+ # nosemgrep: tuple-return-prefer-dataclass -- Django requires (value, label) lookup pairs.
+ def lookups(self, request: HttpRequest, model_admin: admin.ModelAdmin) -> list[tuple[str, str]]:
+ return [
+ (value, str(label))
+ for value, label in SignalReport.Status.choices
+ if value != SignalReport.Status.MONITORING
+ ]
+
+ def queryset(self, request: HttpRequest, queryset: QuerySet[SignalReport]) -> QuerySet[SignalReport]:
+ value = self.value()
+ return queryset.filter(status=value) if value else queryset
+
+
@admin.register(SignalReport)
class SignalReportAdmin(admin.ModelAdmin):
list_display = (
@@ -44,7 +65,7 @@ class SignalReportAdmin(admin.ModelAdmin):
"promoted_at",
)
list_display_links = ("id",)
- list_filter = ("status",)
+ list_filter = (SignalReportStatusFilter,)
search_fields = ("id", "team__name", "team__organization__name", "title", "summary")
ordering = ("-created_at",)
show_full_result_count = False
diff --git a/products/signals/backend/migrations/0164_report_monitoring_foundation.py b/products/signals/backend/migrations/0164_report_monitoring_foundation.py
new file mode 100644
index 000000000000..40834c073bdc
--- /dev/null
+++ b/products/signals/backend/migrations/0164_report_monitoring_foundation.py
@@ -0,0 +1,58 @@
+# Generated by Django 5.2.18 on 2026-10-09 14:59
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("signals", "0163_signalscoutrun_trial_state"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="signalreport",
+ name="monitoring_started_at",
+ field=models.DateTimeField(blank=True, null=True),
+ ),
+ migrations.AlterField(
+ model_name="signalreport",
+ name="status",
+ field=models.CharField(
+ choices=[
+ ("potential", "Potential"),
+ ("candidate", "Candidate"),
+ ("in_progress", "In Progress"),
+ ("pending_input", "Pending Input"),
+ ("ready", "Ready"),
+ ("monitoring", "Monitoring"),
+ ("resolved", "Resolved"),
+ ("failed", "Failed"),
+ ("deleted", "Deleted"),
+ ("suppressed", "Suppressed"),
+ ],
+ default="potential",
+ max_length=20,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="signalreport",
+ name="status_before_suppression",
+ field=models.CharField(
+ blank=True,
+ choices=[
+ ("potential", "Potential"),
+ ("candidate", "Candidate"),
+ ("in_progress", "In Progress"),
+ ("pending_input", "Pending Input"),
+ ("ready", "Ready"),
+ ("monitoring", "Monitoring"),
+ ("resolved", "Resolved"),
+ ("failed", "Failed"),
+ ("deleted", "Deleted"),
+ ("suppressed", "Suppressed"),
+ ],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ]
diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txt
index bca2cd14ca12..2dec3a487f33 100644
--- a/products/signals/backend/migrations/max_migration.txt
+++ b/products/signals/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0163_signalscoutrun_trial_state
+0164_report_monitoring_foundation
diff --git a/products/signals/backend/models.py b/products/signals/backend/models.py
index 80adbbfe6e75..01337114823a 100644
--- a/products/signals/backend/models.py
+++ b/products/signals/backend/models.py
@@ -299,6 +299,7 @@ class SignalReport(UUIDModel):
IN_PROGRESS = "in_progress"
PENDING_INPUT = "pending_input"
READY = "ready"
+ MONITORING = "monitoring"
RESOLVED = "resolved"
FAILED = "failed"
DELETED = "deleted"
@@ -384,6 +385,7 @@ class SignalReport(UUIDModel):
updated_at = models.DateTimeField(auto_now=True)
promoted_at = models.DateTimeField(null=True, blank=True)
last_run_at = models.DateTimeField(null=True, blank=True)
+ monitoring_started_at = models.DateTimeField(null=True, blank=True)
# When the report first became user-visible (entered READY, PENDING_INPUT, or FAILED, the statuses the
# inbox lists). Set once and never cleared, so re-research and suppress/restore cycles don't
# recount it against SignalTeamConfig.max_reports_per_day. Null for reports that predate the
diff --git a/products/signals/backend/report_content_gates.py b/products/signals/backend/report_content_gates.py
index 4c66c73a9b8d..5019a53ae908 100644
--- a/products/signals/backend/report_content_gates.py
+++ b/products/signals/backend/report_content_gates.py
@@ -1,4 +1,4 @@
-"""Organization-level rollout gates for agent-authored report content.
+"""Organization-level rollout gates for report content and lifecycle.
The checks live in their own module because they need `Team` and the flag client.
Report models and Temporal payloads import `report_metrics.py` during process setup,
@@ -20,16 +20,17 @@ from posthog.ph_client import feature_enabled_or_false
logger = structlog.get_logger(__name__)
REPORT_METRICS_FLAG = "signals-report-metrics"
+REPORT_MONITORING_FLAG = "signals-report-monitoring"
-def _organization_flag_enabled(flag: str, organization_id: UUID) -> bool:
+def _organization_flag_enabled(flag: str, organization_id: UUID, *, enable_in_debug: bool = True) -> bool:
"""Read one organization-keyed rollout flag.
- The flag is evaluated for every call so a flip takes effect immediately, and is on in DEBUG for
- local coverage. It fails closed, because a flag-service error must not add content to the reports
- of an organization that is not opted in.
+ The flag is evaluated for every call so a flip takes effect immediately. Content flags are on
+ in DEBUG for local coverage; lifecycle flags can require explicit enablement. It fails closed,
+ because a flag-service error must not add content to reports of an organization that is not opted in.
"""
- if settings.DEBUG:
+ if settings.DEBUG and enable_in_debug:
return True
try:
return feature_enabled_or_false(
@@ -46,10 +47,10 @@ def _organization_flag_enabled(flag: str, organization_id: UUID) -> bool:
return False
-def _team_flag_enabled(flag: str, team_id: int) -> bool:
+def _team_flag_enabled(flag: str, team_id: int, *, enable_in_debug: bool = True) -> bool:
"""The `team_id` adapter for callers that hold an id instead of a `Team`, such as a Temporal
activity input. Fails closed, so a team that cannot be read gets no report content."""
- if settings.DEBUG:
+ if settings.DEBUG and enable_in_debug:
return True
try:
organization_id = Team.objects.values_list("organization_id", flat=True).get(id=team_id)
@@ -58,7 +59,7 @@ def _team_flag_enabled(flag: str, team_id: int) -> bool:
"signals report content flag check could not resolve the team", flag=flag, team_id=team_id, exc_info=True
)
return False
- return _organization_flag_enabled(flag, organization_id)
+ return _organization_flag_enabled(flag, organization_id, enable_in_debug=enable_in_debug)
def organization_report_metrics_enabled(organization_id: UUID) -> bool:
@@ -67,3 +68,7 @@ def organization_report_metrics_enabled(organization_id: UUID) -> bool:
def team_report_metrics_enabled(team_id: int) -> bool:
return _team_flag_enabled(REPORT_METRICS_FLAG, team_id)
+
+
+def team_report_monitoring_enabled(team_id: int) -> bool:
+ return _team_flag_enabled(REPORT_MONITORING_FLAG, team_id, enable_in_debug=False)
diff --git a/products/signals/backend/test/test_report_admin.py b/products/signals/backend/test/test_report_admin.py
new file mode 100644
index 000000000000..f9c39a2a18d8
--- /dev/null
+++ b/products/signals/backend/test/test_report_admin.py
@@ -0,0 +1,20 @@
+from unittest.mock import Mock
+
+from django.contrib import admin
+from django.test import RequestFactory, SimpleTestCase
+
+from products.signals.backend.admin import SignalReportAdmin, SignalReportStatusFilter
+from products.signals.backend.models import SignalReport
+
+
+class TestReportAdmin(SimpleTestCase):
+ def test_status_filter_keeps_monitoring_hidden_and_existing_links_working(self) -> None:
+ request = RequestFactory().get("/", {"status__exact": "resolved"})
+ model_admin = SignalReportAdmin(SignalReport, admin.site)
+ filter_type = model_admin.get_list_filter(request)[0]
+ assert isinstance(filter_type, type) and issubclass(filter_type, SignalReportStatusFilter)
+ status_filter = filter_type(request, request.GET.copy(), SignalReport, model_admin)
+
+ choices = list(status_filter.choices(Mock(add_facets=False)))
+ assert "Monitoring" not in [choice["display"] for choice in choices]
+ assert next(choice for choice in choices if choice["display"] == "Resolved")["selected"]
diff --git a/products/signals/backend/test/test_report_content_gates.py b/products/signals/backend/test/test_report_content_gates.py
new file mode 100644
index 000000000000..445121e12184
--- /dev/null
+++ b/products/signals/backend/test/test_report_content_gates.py
@@ -0,0 +1,69 @@
+from uuid import UUID
+
+from unittest.mock import patch
+
+from django.test import SimpleTestCase, override_settings
+
+from parameterized import parameterized
+
+from products.signals.backend.models import InvalidStatusTransition, SignalReport
+from products.signals.backend.report_content_gates import team_report_metrics_enabled, team_report_monitoring_enabled
+
+_TEAM_LOOKUP = "products.signals.backend.report_content_gates.Team.objects.values_list"
+_FLAG_EVALUATION = "products.signals.backend.report_content_gates.feature_enabled_or_false"
+
+
+class TestReportContentGates(SimpleTestCase):
+ @parameterized.expand(
+ [(f"{debug}_{enabled}", debug, enabled) for debug in [False, True] for enabled in [False, True]]
+ )
+ def test_monitoring_requires_the_organization_flag(self, _name: str, debug: bool, enabled: bool) -> None:
+ organization_id = UUID("00000000-0000-0000-0000-000000000001")
+ with (
+ override_settings(DEBUG=debug),
+ patch(_TEAM_LOOKUP) as team_lookup,
+ patch(_FLAG_EVALUATION, return_value=enabled) as evaluate,
+ ):
+ team_lookup.return_value.get.return_value = organization_id
+
+ assert team_report_monitoring_enabled(7) is enabled
+
+ team_lookup.return_value.get.assert_called_once_with(id=7)
+ evaluate.assert_called_once_with(
+ "signals-report-monitoring",
+ str(organization_id),
+ groups={"organization": str(organization_id)},
+ group_properties={"organization": {"id": str(organization_id)}},
+ send_feature_flag_events=False,
+ )
+
+ @override_settings(DEBUG=True)
+ def test_monitoring_fails_closed_when_flag_evaluation_fails(self) -> None:
+ with patch(_TEAM_LOOKUP) as team_lookup, patch(_FLAG_EVALUATION, side_effect=RuntimeError("unavailable")):
+ team_lookup.return_value.get.return_value = UUID("00000000-0000-0000-0000-000000000001")
+
+ assert not team_report_monitoring_enabled(7)
+
+ @override_settings(DEBUG=True)
+ def test_monitoring_fails_closed_when_the_team_cannot_be_read(self) -> None:
+ with (
+ patch(_TEAM_LOOKUP, side_effect=RuntimeError("unavailable")),
+ patch(_FLAG_EVALUATION) as evaluate,
+ ):
+ assert not team_report_monitoring_enabled(7)
+
+ evaluate.assert_not_called()
+
+ @override_settings(DEBUG=True)
+ def test_metrics_keep_the_existing_debug_override(self) -> None:
+ with patch(_TEAM_LOOKUP) as team_lookup, patch(_FLAG_EVALUATION) as evaluate:
+ assert team_report_metrics_enabled(7)
+
+ team_lookup.assert_not_called()
+ evaluate.assert_not_called()
+
+ def test_the_monitoring_status_has_no_transition_yet(self) -> None:
+ report = SignalReport(team_id=7, status=SignalReport.Status.READY)
+
+ with self.assertRaises(InvalidStatusTransition):
+ report.transition_to(SignalReport.Status.MONITORING)
diff --git a/products/signals/backend/test/test_signal_report_api.py b/products/signals/backend/test/test_signal_report_api.py
index 8062968ca355..7c1b7b6e0c1e 100644
--- a/products/signals/backend/test/test_signal_report_api.py
+++ b/products/signals/backend/test/test_signal_report_api.py
@@ -1084,6 +1084,7 @@ class TestSignalReportListAPI(APIBaseTest):
@parameterized.expand(
[
+ ("monitoring", "monitoring"),
("garbage", "bogus_status"),
("mixed_valid_and_invalid", "ready,bogus_status"),
("deleted_not_filterable", "deleted"),
diff --git a/products/signals/backend/views.py b/products/signals/backend/views.py
index e618506eb610..47952c090e0b 100644
--- a/products/signals/backend/views.py
+++ b/products/signals/backend/views.py
@@ -1275,7 +1275,11 @@ class SignalReportViewSet(
# Deleted reports are terminal, so `deleted` never reaches any endpoint (detail, list,
# actions) and is never a valid filter target either.
- _FILTERABLE_STATUSES = frozenset(SignalReport.Status.values) - {SignalReport.Status.DELETED}
+ # Monitoring has no supported lifecycle yet, so it is excluded from reads too.
+ _FILTERABLE_STATUSES = frozenset(SignalReport.Status.values) - {
+ SignalReport.Status.DELETED,
+ SignalReport.Status.MONITORING,
+ }
_DEFAULT_STATUSES = _FILTERABLE_STATUSES - {SignalReport.Status.SUPPRESSED}
# Actions that work on many reports at once, so per-row annotations are wasted work there.
diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.ts
index 2cda6017d529..5a72c28a9842 100644
--- a/products/signals/frontend/generated/api.schemas.ts
+++ b/products/signals/frontend/generated/api.schemas.ts
@@ -122,6 +122,7 @@ export interface PauseResponseApi {
* * `in_progress` - In Progress
* * `pending_input` - Pending Input
* * `ready` - Ready
+ * * `monitoring` - Monitoring
* * `resolved` - Resolved
* * `failed` - Failed
* * `deleted` - Deleted
@@ -135,6 +136,7 @@ export const SignalReportStatusEnumApi = {
InProgress: 'in_progress',
PendingInput: 'pending_input',
Ready: 'ready',
+ Monitoring: 'monitoring',
Resolved: 'resolved',
Failed: 'failed',
Deleted: 'deleted',
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 960acd308cfb..686a42553758 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -71906,6 +71906,7 @@ export namespace Schemas {
* * `in_progress` - In Progress
* * `pending_input` - Pending Input
* * `ready` - Ready
+ * * `monitoring` - Monitoring
* * `resolved` - Resolved
* * `failed` - Failed
* * `deleted` - Deleted
@@ -71920,6 +71921,7 @@ export namespace Schemas {
InProgress: 'in_progress',
PendingInput: 'pending_input',
Ready: 'ready',
+ Monitoring: 'monitoring',
Resolved: 'resolved',
Failed: 'failed',
Deleted: 'deleted',