: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): restore resolved expiry after monitoring (#120711)
Mikayla Thompson88626612c192
diff --git a/docs/internal/signals-pr-lifecycle.md b/docs/internal/signals-pr-lifecycle.mdindex 15a026ed3937..5e4b4b92a538 100644--- a/docs/internal/signals-pr-lifecycle.md+++ b/docs/internal/signals-pr-lifecycle.md@@ -74,6 +74,8 @@ Each completed attempt appends a protected `check_observation` log entry with itWith Monitoring disabled, observations disappear from the artefact API and counts. The existing Resolved executor uses the stored full-window query, comparison, and minimum soak. Observation values require the same query permissions as terminal check results. The inbox follows all artefact pages within the current project before deriving task runs, reviewers, and activity so observations cannot displace older report state. Polling waits for an in-flight paginated load to finish. With the Monitoring flag enabled, scouts see metric checks with an explicit definition as scheduled or due inside their Monitoring window; agent checks and metric checks without a definition remain paused until resolution. The soak deadline bounds interim execution; no final verdict, reopening, or follow-up report is added here.+Disabling Monitoring restores the legacy expiry for armed Monitoring metric checks from their existing measurement start and remaining schedule. The check saves this fallback deadline so further flag changes cannot shorten it after runs have been consumed or extend it after retries. Repair batches remember checks whose legacy expiry is also 90 days, allowing later checks to progress. Re-enabling restores the original horizon for active checks and leaves terminal checks unchanged. Archive and restore preserve the saved fallback deadline; reopening implementation clears it for the next period.+With `signals-report-metrics` enabled, research gathers short-window baselines before verification and prefers metric-based follow-up checks. It aims for practical 70-80% confidence in improvement, without claiming a calculated confidence score. Observed volume, recurrence, ingestion delay, and deployment timing justify the shortest useful query and wait. Frequent or high-volume checks can use 4-8 hours, allowing for several hours of deployment delay before the fix reaches users. Around 24 hours or several days require the corresponding activity or rollout evidence. Agent checks remain available when interpretation or unsupported measurements prevent a useful metric check. Missing activity is not success. These prompt preferences do not change execution, schema defaults, or final outcomes.The server refuses new Monitoring definitions when `signals-report-monitoring` is disabled or unavailable and omits the definition from check responses. Stored definitions remain intact. Research carries its definition-visibility decision into reconciliation, so flag recovery during a run does not replace an unchanged check or reset its approval and schedule. Existing definitions, charts, check schedules, and Resolved outcomes otherwise follow their current behavior.diff --git a/products/signals/backend/migrations/0190_monitoring_fallback_expiry.py b/products/signals/backend/migrations/0190_monitoring_fallback_expiry.pynew file mode 100644index 000000000000..46c782f79579--- /dev/null+++ b/products/signals/backend/migrations/0190_monitoring_fallback_expiry.py@@ -0,0 +1,17 @@+# Generated by Django 5.2.18 on 2026-10-20 22:25++from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("signals", "0189_first_report_notification"),+ ]++ operations = [+ migrations.AddField(+ model_name="signalreportcheck",+ name="monitoring_fallback_expires_at",+ field=models.DateTimeField(blank=True, null=True),+ ),+ ]diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txtindex c18661923fb2..cb61b9ee3e41 100644--- a/products/signals/backend/migrations/max_migration.txt+++ b/products/signals/backend/migrations/max_migration.txt@@ -1 +1 @@-0189_first_report_notification+0190_monitoring_fallback_expirydiff --git a/products/signals/backend/models.py b/products/signals/backend/models.pyindex 9ec3bbaf32d2..5a8648701834 100644--- a/products/signals/backend/models.py+++ b/products/signals/backend/models.py@@ -2481,6 +2481,7 @@ class SignalReportCheck(UUIDModel):run_interval_minutes = models.PositiveIntegerField(null=True, blank=True)runs_remaining = models.PositiveIntegerField(default=1)expires_at = models.DateTimeField()+ monitoring_fallback_expires_at = models.DateTimeField(null=True, blank=True)status = models.CharField(max_length=20, choices=Status, default=Status.ACTIVE)consecutive_errors = models.PositiveIntegerField(default=0)diff --git a/products/signals/backend/report_check_execution.py b/products/signals/backend/report_check_execution.pyindex 905f1edbd732..47b8b6e04270 100644--- a/products/signals/backend/report_check_execution.py+++ b/products/signals/backend/report_check_execution.py@@ -452,6 +452,92 @@ def _monitoring_metric_filter(disabled_organizations: frozenset[UUID], *, starte)+def _completed_check_runs(check: SignalReportCheck, start: datetime) -> int:+ completed = 0+ results = (+ SignalReportArtefact.objects.using("default")+ .filter(+ team_id=check.team_id,+ report_id=check.report_id,+ type=SignalReportArtefact.ArtefactType.CHECK_RESULT,+ created_at__gte=start,+ )+ .values_list("content", flat=True)+ )+ for content in results.iterator(chunk_size=100):+ try:+ result = CheckResult.model_validate_json(content)+ except ValueError:+ continue+ if result.check_id == str(check.id) and result.outcome == "passed":+ completed += 1+ return completed+++def _resolved_monitoring_expiry(check: SignalReportCheck) -> datetime:+ start = check.report.monitoring_started_at+ if (+ check.kind != SignalReportCheck.Kind.METRIC_THRESHOLD+ or not check.config.get("monitoring")+ or start is None+ or check.measurement_start_at != start+ or check.expires_at != start + MAX_CHECK_HORIZON+ ):+ return check.expires_at+ if check.monitoring_fallback_expires_at is not None:+ return check.monitoring_fallback_expires_at+ ready_at = start + timedelta(minutes=check.soak_minutes or 0)+ try:+ config = cast(MetricThresholdConfig, parse_check_config(check.kind, check.config))+ query = resolve_check_query(config, check.report)+ ready_at = max(ready_at, metric_check_ready_at(query, check.report.team, start))+ except (CheckConfigValidationError, ValueError):+ pass+ runs = check.runs_remaining+ if check.run_interval_minutes and check.last_outcome is not None:+ runs += _completed_check_runs(check, start)+ return check_schedule_expires_at(+ next_run_at=ready_at,+ run_interval_minutes=check.run_interval_minutes,+ runs_remaining=runs,+ start_at=start,+ )+++def _restore_resolved_monitoring_expiries(now: datetime, disabled_organizations: frozenset[UUID]) -> None:+ if not disabled_organizations:+ return+ candidates = (+ SignalReportCheck.all_teams.filter(+ _monitoring_metric_filter(frozenset()),+ report__team__organization_id__in=disabled_organizations,+ status=SignalReportCheck.Status.ACTIVE,+ measurement_start_at=F("report__monitoring_started_at"),+ expires_at=ExpressionWrapper(+ F("report__monitoring_started_at") + Value(MAX_CHECK_HORIZON), output_field=DateTimeField()+ ),+ )+ .filter(Q(monitoring_fallback_expires_at__isnull=True) | ~Q(monitoring_fallback_expires_at=F("expires_at")))+ .select_related("report__team")+ .order_by("expires_at", "id")[:MAX_CHECK_PARKS_PER_TICK]+ )+ for check in candidates:+ expires_at = _resolved_monitoring_expiry(check)+ period = SignalReport.objects.filter(+ id=OuterRef("report_id"),+ team_id=OuterRef("team_id"),+ status=SignalReport.Status.MONITORING,+ monitoring_started_at=check.report.monitoring_started_at,+ )+ SignalReportCheck.objects.for_team(check.team_id).filter(+ Exists(period),+ id=check.id,+ status=SignalReportCheck.Status.ACTIVE,+ updated_at=check.updated_at,+ expires_at=check.expires_at,+ ).update(expires_at=expires_at, monitoring_fallback_expires_at=expires_at, updated_at=now)++def expire_overdue_checks(now: datetime, *, disabled_monitoring_organization_ids: frozenset[UUID] | None = None) -> int:"""Retire open checks whose horizon passed without a run. Returns how many were retired.@@ -579,6 +665,9 @@ def _park_checks(active: Iterable[SignalReportCheck], now: datetime, *, resolvedmeasurement_start_at=None,next_run_at=now + timedelta(minutes=soak_minutes),expires_at=now + MAX_CHECK_HORIZON,+ monitoring_fallback_expires_at=F("monitoring_fallback_expires_at")+ if check.report.monitoring_started_at is not None+ else None,consecutive_errors=F("consecutive_errors") if preserve_monitoring_errors else 0,consecutive_inconclusive=0,dispatched_at=None,@@ -589,6 +678,13 @@ def _park_checks(active: Iterable[SignalReportCheck], now: datetime, *, resolveddef park_report_checks_on_reopen(*, team_id: int, report_id: str, now: datetime) -> int:+ new_period = SignalReport.objects.filter(id=report_id, team_id=team_id, monitoring_started_at__isnull=True)+ SignalReportCheck.objects.for_team(team_id).filter(+ Exists(new_period),+ report_id=report_id,+ status=SignalReportCheck.Status.PENDING,+ monitoring_fallback_expires_at__isnull=False,+ ).update(monitoring_fallback_expires_at=None, updated_at=now)return _park_checks(SignalReportCheck.objects.for_team(team_id).filter(report_id=report_id, status=SignalReportCheck.Status.ACTIVE)@@ -714,6 +810,13 @@ def _prepare_monitoring_metrics(now: datetime, disabled_organizations: frozensetnext_run_at=check._monitoring_next_run_at,measurement_start_at=start,expires_at=check._monitoring_expires_at,+ monitoring_fallback_expires_at=check.expires_at+ if (+ check.monitoring_fallback_expires_at is None+ and check.measurement_start_at == start+ and check.expires_at < start + MAX_CHECK_HORIZON+ )+ else check.monitoring_fallback_expires_at,updated_at=now,)@@ -766,6 +869,12 @@ def collect_due_checks(per_team: dict[int, int] = {}due: list[SignalReportCheck] = []for check in candidates:+ if (+ check.report.status == SignalReport.Status.MONITORING+ and check.team.organization_id in disabled_monitoring_organization_ids+ and _resolved_monitoring_expiry(check) <= now+ ):+ continuetaken = per_team.get(check.team_id, 0)if taken >= MAX_CHECK_RUNS_PER_TEAM_PER_TICK:continue@@ -820,6 +929,7 @@ def run_due_report_checks(*, now: datetime | None = None, limit: int = MAX_CHECK)disabled_organizations = check_monitoring_disabled_organizations(candidate_checks)_prepare_monitoring_metrics(now, disabled_organizations)+ _restore_resolved_monitoring_expiries(now, disabled_organizations)expired = expire_overdue_checks(now, disabled_monitoring_organization_ids=disabled_organizations)_arm_monitoring_checks(now, disabled_monitoring_organization_ids=disabled_organizations)park_checks_on_unresolved_reports(now, disabled_monitoring_organization_ids=disabled_organizations)@@ -854,6 +964,13 @@ def run_due_report_checks(*, now: datetime | None = None, limit: int = MAX_CHECK"signals.report_check.monitoring_step_failed", check_id=str(check.id), team_id=check.team_id)continue+ if (+ check.report.status == SignalReport.Status.MONITORING+ and check.team.organization_id in disabled_organizations+ and _resolved_monitoring_expiry(check) != check.expires_at+ ):+ counts["deferred"] += 1+ continueif check.kind == SignalReportCheck.Kind.AGENT:# Deferred: the agent lane reaches the scout harness and the Temporal client, and this# module is imported by the REST route load, which never dispatches anything.diff --git a/products/signals/backend/test/test_report_check_concurrency.py b/products/signals/backend/test/test_report_check_concurrency.pyindex bad60dff8fc2..f01da9f3d991 100644--- a/products/signals/backend/test/test_report_check_concurrency.py+++ b/products/signals/backend/test/test_report_check_concurrency.py@@ -104,8 +104,8 @@ class TestReportCheckConcurrency(NonAtomicBaseTest):team_id=self.team.id, report=self.report, type=SignalReportArtefact.ArtefactType.CHECK_EXPIRED).exists()- @patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=True)- def test_schedule_repair_preserves_a_concurrent_observation(self, _flag: object) -> None:+ @parameterized.expand([("enabled", True), ("disabled", False)])+ def test_schedule_repair_preserves_a_concurrent_observation(self, _name: str, flag: bool) -> None:now = timezone.now()start = now - timedelta(days=1)self.report.status = SignalReport.Status.MONITORING@@ -124,17 +124,22 @@ class TestReportCheckConcurrency(NonAtomicBaseTest):error="The metric query failed.",explanation="The metric query failed.",)- with ThreadPoolExecutor(max_workers=1) as executor:+ with (+ patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=flag),+ ThreadPoolExecutor(max_workers=1) as executor,+ ):with transaction.atomic():SignalReportCheck.objects.for_team(self.team.id).select_for_update().get(id=self.check.id)future = self._start_write(executor, lambda: run_due_report_checks(now=now, limit=0))self._assert_write_waits(future)- assert record_monitoring_observation(self.check, observation)+ with patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=True):+ assert record_monitoring_observation(self.check, observation)future.result(timeout=10)self.check.refresh_from_db()assert self.check.last_run_at == nowassert self.check.next_run_at == now + MONITORING_ERROR_RETRY_AFTERassert self.check.consecutive_errors == 1+ assert self.check.expires_at == start + MAX_CHECK_HORIZONassert (SignalReportArtefact.objects.filter(team_id=self.team.id, report=self.report, type=SignalReportArtefact.ArtefactType.CHECK_OBSERVATIONdiff --git a/products/signals/backend/test/test_report_checks.py b/products/signals/backend/test/test_report_checks.pyindex 0e4dc1e9c66b..56a01360cd52 100644--- a/products/signals/backend/test/test_report_checks.py+++ b/products/signals/backend/test/test_report_checks.py@@ -840,10 +840,16 @@ class TestReportCheckExecution(APIBaseTest):assert listed.run_state == expectedassert {row.id for row in collect_due_checks(now)} == ({check.id} if expected == "due" else set())- def test_flag_off_restores_the_legacy_soak_and_whole_window(self) -> None:+ @parameterized.expand(+ [("disabled", False, 14, 14 * 24), ("unavailable", None, 14, 14 * 24), ("query_window", False, 2, 7 * 24 + 12)]+ )+ def test_flag_off_restores_the_legacy_soak_and_whole_window(+ self, _name: str, flag: bool | None, soak_days: int, ready_hours: int+ ) -> None:start = datetime(2026, 10, 1, 12, tzinfo=UTC)+ ready_at = start + timedelta(hours=ready_hours)with time_machine.travel(start, tick=False):- check = self._monitoring_check(start=start)+ check = self._monitoring_check(start=start, soak_minutes=soak_days * 1440)with (patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=True),patch(@@ -853,19 +859,198 @@ class TestReportCheckExecution(APIBaseTest):):run_due_report_checks(now=start + timedelta(days=1))with (- patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=False),+ patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=flag),patch(_MEASURE, return_value=MetricMeasurement(value=2, measured_at=start, series=None)) as measure,):run_due_report_checks(now=start + timedelta(days=2))measure.assert_not_called()check.refresh_from_db()- assert check.next_run_at == start + timedelta(days=14)- with time_machine.travel(start + timedelta(days=14), tick=False):+ assert check.next_run_at == ready_at+ assert check.expires_at == ready_at + DEFAULT_CHECK_EXPIRY_AFTER_LAST_RUN+ with time_machine.travel(ready_at, tick=False):run_due_report_checks()check.refresh_from_db()assert check.status == SignalReportCheck.Status.PASSEDassert check.runs_remaining == 0+ @parameterized.expand([("repaired", 500, 45), ("overdue_backlog", 0, 45), ("future_backlog", 0, 20)])+ @time_machine.travel("2026-10-01T12:00:00Z", tick=False)+ def test_flag_off_defers_unrepaired_checks_and_expires_overdue_checks(+ self, _name: str, repair_limit: int, age_days: int+ ) -> None:+ start = timezone.now() - timedelta(days=age_days)+ check = self._monitoring_check(start=start)+ with (+ patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=False),+ patch("products.signals.backend.report_check_execution.MAX_CHECK_PARKS_PER_TICK", repair_limit),+ patch(_MEASURE) as measure,+ ):+ assert collect_due_checks(timezone.now()) == ([] if age_days > 44 else [check])+ summary = run_due_report_checks()+ measure.assert_not_called()+ assert summary.deferred == (1 if age_days < 44 else 0)+ check.refresh_from_db()+ assert check.status == (SignalReportCheck.Status.EXPIRED if repair_limit else SignalReportCheck.Status.ACTIVE)+ assert self._results() == []+ if repair_limit:+ with patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=True):+ run_due_report_checks(limit=0)+ check.refresh_from_db()+ assert check.status == SignalReportCheck.Status.EXPIRED++ def test_expiry_restoration_only_changes_disabled_monitoring_checks(self) -> None:+ now = timezone.now()+ check = self._monitoring_check(start=now)+ resolved = SignalReport.objects.create(team=self.team, status=SignalReport.Status.RESOLVED)+ legacy = self._check(report=resolved)+ other_team = Team.objects.create(organization=Organization.objects.create(name="Another organization"))+ other_report = SignalReport.objects.create(+ team=other_team, status=SignalReport.Status.MONITORING, monitoring_started_at=now+ )+ enabled = self._check(+ team=other_team,+ report=other_report,+ config=check.config,+ measurement_start_at=now,+ expires_at=now + MAX_CHECK_HORIZON,+ )+ with patch(+ "products.signals.backend.report_content_gates.feature_enabled_or_false",+ side_effect=lambda _flag, organization_id, **kwargs: organization_id == str(other_team.organization_id),+ ):+ run_due_report_checks(now=now, limit=0)+ for row, expected_expiry in (+ (check, now + timedelta(days=44)),+ (legacy, legacy.expires_at),+ (enabled, enabled.expires_at),+ ):+ row.refresh_from_db()+ assert row.expires_at == expected_expiry++ @parameterized.expand([("passed", False), ("errored", True)])+ def test_flag_cycles_preserve_the_fallback_expiry_after_a_verdict(self, _name: str, query_error: bool) -> None:+ start = datetime(2026, 10, 1, 12, tzinfo=UTC)+ expected_expiry = start + timedelta(days=65)+ with time_machine.travel(start + timedelta(days=13), tick=False):+ check = self._monitoring_check(start=start, run_interval_minutes=7 * 1440, runs_remaining=4)+ with patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=False):+ run_due_report_checks(limit=0)+ with (+ time_machine.travel(start + timedelta(days=14), tick=False),+ patch(+ _MEASURE,+ side_effect=RuntimeError("Query unavailable") if query_error else None,+ return_value=MetricMeasurement(value=2, measured_at=timezone.now(), series=None),+ ),+ ):+ run_due_report_checks()+ check.refresh_from_db()+ assert check.runs_remaining == (4 if query_error else 3)+ assert check.expires_at == expected_expiry+ with patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=True):+ run_due_report_checks(now=start + timedelta(days=15), limit=0)+ check.refresh_from_db()+ assert check.expires_at == start + MAX_CHECK_HORIZON+ with patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=False):+ run_due_report_checks(now=start + timedelta(days=16), limit=0)+ check.refresh_from_db()+ assert check.expires_at == expected_expiry++ with (+ time_machine.travel(start + timedelta(days=16), tick=False),+ patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=True),+ ):+ self.report.refresh_from_db()+ with self.captureOnCommitCallbacks(execute=True):+ self.report.save(update_fields=self.report.transition_to(SignalReport.Status.SUPPRESSED))+ self.report.save(update_fields=self.report.transition_to(self.report.restore_target_status()))+ check.refresh_from_db()+ assert check.monitoring_fallback_expires_at == expected_expiry+ self.report.save(update_fields=self.report.transition_to(SignalReport.Status.READY))+ check.refresh_from_db()+ self.assertIsNone(check.monitoring_fallback_expires_at)++ def test_expiry_repair_advances_past_checks_whose_legacy_horizon_is_also_ninety_days(self) -> None:+ now = timezone.now()+ start = now - timedelta(days=2)+ long_check = self._monitoring_check(start=start, run_interval_minutes=8 * 1440, runs_remaining=7)+ later_start = now - timedelta(days=1)+ later_report = SignalReport.objects.create(+ team=self.team, status=SignalReport.Status.MONITORING, monitoring_started_at=later_start+ )+ later_check = self._check(+ report=later_report,+ config=long_check.config,+ measurement_start_at=later_start,+ soak_minutes=14 * 1440,+ next_run_at=later_start + timedelta(days=14),+ expires_at=later_start + MAX_CHECK_HORIZON,+ )+ with (+ patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=False),+ patch("products.signals.backend.report_check_execution.MAX_CHECK_PARKS_PER_TICK", 1),+ ):+ run_due_report_checks(now=now, limit=0)+ run_due_report_checks(now=now, limit=0)+ long_check.refresh_from_db()+ later_check.refresh_from_db()+ assert long_check.expires_at == start + MAX_CHECK_HORIZON+ assert later_check.expires_at == later_start + timedelta(days=44)++ @parameterized.expand([("capped", 13, 5, 90), ("uncapped", 7, 3, 58)])+ def test_legacy_flag_recovery_preserves_elapsed_recurring_runs(+ self, _name: str, interval_days: int, runs: int, expiry_days: int+ ) -> None:+ start = datetime(2026, 10, 1, 12, tzinfo=UTC)+ with time_machine.travel(start, tick=False):+ check = self._monitoring_check(start=start, run_interval_minutes=interval_days * 1440, runs_remaining=runs)+ for check_id, result_at in (+ ("00000000-0000-0000-0000-000000000001", start),+ (str(check.id), start - timedelta(days=1)),+ ):+ result = SignalReportArtefact.add_log(+ team_id=self.team.id,+ report_id=str(self.report.id),+ content=CheckResult(+ check_id=check_id,+ kind=check.kind,+ title="Earlier result",+ outcome="passed",+ explanation="The goal held.",+ ),+ attribution=ArtefactAttribution.system(),+ )+ SignalReportArtefact.objects.filter(id=result.id, team_id=self.team.id).update(created_at=result_at)+ for run in range(runs - 1):+ run_at = start + timedelta(days=14 + interval_days * run)+ with (+ time_machine.travel(run_at, tick=False),+ patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=False),+ patch(_MEASURE, return_value=MetricMeasurement(value=2, measured_at=run_at, series=None)),+ ):+ run_due_report_checks()+ with time_machine.travel(run_at + timedelta(days=1), tick=False):+ with patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=True):+ run_due_report_checks(limit=0)+ SignalReportCheck.objects.for_team(self.team.id).filter(id=check.id).update(+ monitoring_fallback_expires_at=None+ )+ with patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=False):+ run_due_report_checks(limit=0)+ check.refresh_from_db()+ assert check.runs_remaining == 1+ assert check.expires_at == start + timedelta(days=expiry_days)+ final_run_at = start + timedelta(days=14 + interval_days * (runs - 1))+ with (+ time_machine.travel(final_run_at, tick=False),+ patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=False),+ patch(_MEASURE, return_value=MetricMeasurement(value=2, measured_at=final_run_at, series=None)),+ ):+ run_due_report_checks()+ check.refresh_from_db()+ assert check.status == SignalReportCheck.Status.PASSED+ assert check.runs_remaining == 0+@parameterized.expand([("success", False), ("query_error", True)])def test_flag_recovery_restores_the_latest_monitoring_attempt_schedule(self, _name: str, query_error: bool) -> None:start = datetime(2026, 10, 1, 12, tzinfo=UTC)@@ -886,6 +1071,7 @@ class TestReportCheckExecution(APIBaseTest):run_due_report_checks(now=sample_at + interval)check.refresh_from_db()assert check.next_run_at == start + timedelta(days=14)+ assert check.expires_at == start + timedelta(days=44)with (patch("products.signals.backend.report_content_gates.feature_enabled_or_false", return_value=True),patch(@@ -897,6 +1083,7 @@ class TestReportCheckExecution(APIBaseTest):measure.assert_not_called()check.refresh_from_db()assert check.next_run_at == sample_at + interval+ assert check.expires_at == start + MAX_CHECK_HORIZONrun_due_report_checks(now=sample_at + interval)measure.assert_called_once()assert self.report.artefacts.filter(type="check_observation").count() == 2@@ -2901,6 +3088,8 @@ class TestPendingChecks(APIBaseTest):run_due_report_checks()check.refresh_from_db()assert check.consecutive_errors == MAX_CONSECUTIVE_CHECK_ERRORS - 1+ check.monitoring_fallback_expires_at = old_start + timedelta(days=44)+ check.save(update_fields=["monitoring_fallback_expires_at"])with self.captureOnCommitCallbacks(execute=False) as old_callbacks:self.report.save(update_fields=self.report.transition_to(SignalReport.Status.SUPPRESSED))self.report.save(update_fields=self.report.transition_to(self.report.restore_target_status()))@@ -2916,6 +3105,7 @@ class TestPendingChecks(APIBaseTest):check.refresh_from_db()assert check.status == SignalReportCheck.Status.PENDINGassert check.measurement_start_at is None+ self.assertIsNone(check.monitoring_fallback_expires_at)for callback in new_callbacks:callback()check.refresh_from_db()