: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
feat(signals): gate scout auto-pause on report engagement, not emission (#76046)
Andrew Maguireac02ca02bc6a
diff --git a/frontend/src/scenes/inbox/components/config/scouts/ScoutBadges.tsx b/frontend/src/scenes/inbox/components/config/scouts/ScoutBadges.tsxindex 163982451936..8a01c0fb271e 100644--- a/frontend/src/scenes/inbox/components/config/scouts/ScoutBadges.tsx+++ b/frontend/src/scenes/inbox/components/config/scouts/ScoutBadges.tsx@@ -51,14 +51,17 @@ export function ScoutLifecycleBadge({ config }: { config: SignalScoutConfig }):return null}if (config.status === 'pending_pause') {- const why =- config.pause_reason === 'ignored'- ? "Nothing has come of this scout's recent reports, so it pauses in about a week unless that changes."- : "It hasn't surfaced anything in the last two weeks, so it pauses in about a week unless it finds something."+ // The two warnings say different things at a glance: `ignored` schedules a pause and can+ // apply to a scout that files plenty of reports, so labeling it "Quiet" would misread as+ // a benign watchdog.+ const ignored = config.pause_reason === 'ignored'+ const title = ignored+ ? "Nothing has come of this scout's recent reports, so it pauses in about a week unless that changes. Turn on 'Opt out of auto-pause' in its settings to leave it running."+ : "This scout hasn't surfaced anything in the last two weeks. It keeps running, but check that it's watching the right things. Turn on 'Opt out of auto-pause' in its settings if quiet is expected."return (- <Tooltip title={`${why} Turn on 'Keep running while quiet' in its settings to leave it running.`}>+ <Tooltip title={title}><LemonTag type="caution" size="small">- Quiet+ {ignored ? 'Pausing soon' : 'Quiet'}</LemonTag></Tooltip>)diff --git a/frontend/src/scenes/inbox/components/config/scouts/ScoutConfigControls.tsx b/frontend/src/scenes/inbox/components/config/scouts/ScoutConfigControls.tsxindex 71d7ace2a174..4081988771d2 100644--- a/frontend/src/scenes/inbox/components/config/scouts/ScoutConfigControls.tsx+++ b/frontend/src/scenes/inbox/components/config/scouts/ScoutConfigControls.tsx@@ -137,10 +137,10 @@ export function ScoutConfigForm({) : null}<div className="flex items-center justify-between gap-4"><div className="flex flex-col min-w-0">- <span className="text-xs text-default">Keep running while quiet</span>+ <span className="text-xs text-default">Opt out of auto-pause</span><span className="text-[11.5px] text-muted">- A scout that goes two weeks without surfacing anything anyone uses is paused. Turn this on for a- scout whose job is to stay quiet.+ A scout is paused when nobody acts on its reports for a few weeks, and flagged as quiet when it+ surfaces nothing. Turn this on to opt this scout out of both.</span></div><LemonSwitch@@ -148,7 +148,7 @@ export function ScoutConfigForm({checked={config.auto_pause_exempt}disabledReason={controlsDisabledReason}onChange={(checked) => onUpdate(config.id, { auto_pause_exempt: checked })}- aria-label={`${config.skill_name} keep running while quiet`}+ aria-label={`${config.skill_name} opt out of auto-pause`}/></div><ScoutSlackDestinationdiff --git a/products/signals/ARCHITECTURE.md b/products/signals/ARCHITECTURE.mdindex 0382a8cc26bc..b6b15038b6c0 100644--- a/products/signals/ARCHITECTURE.md+++ b/products/signals/ARCHITECTURE.md@@ -538,23 +538,23 @@ Per-team configuration for which signal sources are enabled.Per-scout binding for the headless **Signals agent**: one row per `(team, skill_name)`. The coordinator auto-creates a row when it discovers a `signals-scout-*` skill on a participating team. Changes are activity-logged (they drive spend); team-level participation is gated by the `signals-scout` flag at the coordinator, not here. See `backend/scout_harness/AGENTS.md` for the harness internals.-| Field | Type | Description |-| ---------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |-| `team` | FK → Team | Owning team (`related_name="signal_scout_configs"`). `unique_together(team, skill_name)`. |-| `skill_name` | CharField | The `signals-scout-*` skill this row controls. Auto-registered by the coordinator when it finds the skill on a participating team. |-| `enabled` | Boolean | Per-scout switch; defaults `True`. Derived from `status` (`enabled = status in (active, pending_pause)`) but kept as a real column for SQL filtering and the warehouse mirror; `save()` reconciles the pair for writers that set only one side. |-| `status` | Char (choices) | Lifecycle source of truth: `active` / `pending_pause` / `paused_by_system` / `paused_by_user`. Who paused is the state itself: the system may resume its own pauses but must never touch a human's. `pending_pause` still runs (a warning, not a pause) and is cleared by any human config edit. |-| `pause_reason` | Char (nullable) | Why the system paused or warned: `no_output` / `ignored` / `repeated_failures`. Also names the writer that owns the pause: a system writer may only clear or overwrite a pause carrying its own reason (`transition_status_by_system()`). Null outside `pending_pause` / `paused_by_system`. |-| `status_changed_at` | DateTime (nullable) | When `status` last changed. Anchors the cold-start grace window (`in_cold_start_grace()`): any move back to `active` re-anchors it, deliberately independent of the actor so the window survives account deletion. |-| `status_changed_by` | FK → User (nullable) | The human behind the last status change; null on system transitions, so a human re-enable and a system resume are distinguishable and a system pause never reads as a person's action. |-| `auto_pause_exempt` | Boolean | Opt-out from the daily inactivity sweep (`scout_harness/inactivity.py`, the `no_output` / `ignored` writer), for watchdog scouts whose whole job is staying quiet. Defaults `False`. Also set automatically when a human re-enables a scout the sweep paused, so the sweep never overrules a person twice. |-| `emit` | Boolean | Dry-run vs emit. Defaults `True`: a freshly authored scout is live from its first tick. Flip to `False` for dry-run — the scout runs and logs but `emit_finding` writes nothing — to validate it on a team before its findings reach the inbox. |-| `run_interval_minutes` | PositiveInteger | Minutes between runs. The coordinator dispatches rolling schedules when `last_run_at is None or now - last_run_at >= run_interval_minutes`. Default `1440` (daily). Validated `30 <= N <= 43200`. |-| `run_cron_schedule` | Char (nullable) | Optional five-field cron expression anchoring runs to wall-clock slots; takes precedence over `run_interval_minutes` when set. Interpreted in the project's timezone so daylight-saving changes are applied automatically. Occurrences must be ≥ 30 minutes apart. Null keeps the rolling interval behavior. |-| `schedule_changed_at` | DateTime (nullable) | Stamped by the config serializers only when a schedule field actually changes. Anchors the cron due-check (with `last_run_at` / `created_at`) instead of `updated_at`, so an unrelated emit/enabled save can never defer an overdue scheduled run. |-| `last_run_at` | DateTime (nullable) | Stamped after each dispatch; drives the due-check. Excluded from activity logging (written every run). |-| `created_by` | FK → User (nullable) | Audit pointer |-| `enabled_by` | FK → User (nullable) | Who last flipped `enabled` — tracked because enablement drives spend. |+| Field | Type | Description |+| ---------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| `team` | FK → Team | Owning team (`related_name="signal_scout_configs"`). `unique_together(team, skill_name)`. |+| `skill_name` | CharField | The `signals-scout-*` skill this row controls. Auto-registered by the coordinator when it finds the skill on a participating team. |+| `enabled` | Boolean | Per-scout switch; defaults `True`. Derived from `status` (`enabled = status in (active, pending_pause)`) but kept as a real column for SQL filtering and the warehouse mirror; `save()` reconciles the pair for writers that set only one side. |+| `status` | Char (choices) | Lifecycle source of truth: `active` / `pending_pause` / `paused_by_system` / `paused_by_user`. Who paused is the state itself: the system may resume its own pauses but must never touch a human's. `pending_pause` still runs (a warning, not a pause) and is cleared by any human config edit. |+| `pause_reason` | Char (nullable) | Why the system paused or warned: `no_output` (warn-only: silence flags a scout but never pauses it) / `ignored` (nobody acts on its reports: warns, then pauses) / `repeated_failures`. Also names the writer that owns the pause: a system writer may only move a pause carrying a reason it owns, and the inactivity sweep owns both of its reasons (`transition_status_by_system()`). Null outside `pending_pause` / `paused_by_system`. |+| `status_changed_at` | DateTime (nullable) | When `status` last changed. Anchors the cold-start grace window (`in_cold_start_grace()`): any move back to `active` re-anchors it, deliberately independent of the actor so the window survives account deletion. |+| `status_changed_by` | FK → User (nullable) | The human behind the last status change; null on system transitions, so a human re-enable and a system resume are distinguishable and a system pause never reads as a person's action. |+| `auto_pause_exempt` | Boolean | Opt-out from the daily inactivity sweep (`scout_harness/inactivity.py`, the `no_output` / `ignored` writer), for watchdog scouts whose whole job is staying quiet. Defaults `False`. Also set automatically when a human re-enables a scout the sweep paused, so the sweep never overrules a person twice. |+| `emit` | Boolean | Dry-run vs emit. Defaults `True`: a freshly authored scout is live from its first tick. Flip to `False` for dry-run — the scout runs and logs but `emit_finding` writes nothing — to validate it on a team before its findings reach the inbox. |+| `run_interval_minutes` | PositiveInteger | Minutes between runs. The coordinator dispatches rolling schedules when `last_run_at is None or now - last_run_at >= run_interval_minutes`. Default `1440` (daily). Validated `30 <= N <= 43200`. |+| `run_cron_schedule` | Char (nullable) | Optional five-field cron expression anchoring runs to wall-clock slots; takes precedence over `run_interval_minutes` when set. Interpreted in the project's timezone so daylight-saving changes are applied automatically. Occurrences must be ≥ 30 minutes apart. Null keeps the rolling interval behavior. |+| `schedule_changed_at` | DateTime (nullable) | Stamped by the config serializers only when a schedule field actually changes. Anchors the cron due-check (with `last_run_at` / `created_at`) instead of `updated_at`, so an unrelated emit/enabled save can never defer an overdue scheduled run. |+| `last_run_at` | DateTime (nullable) | Stamped after each dispatch; drives the due-check. Excluded from activity logging (written every run). |+| `created_by` | FK → User (nullable) | Audit pointer |+| `enabled_by` | FK → User (nullable) | Who last flipped `enabled` — tracked because enablement drives spend. |### `SignalScoutRun`diff --git a/products/signals/backend/models.py b/products/signals/backend/models.pyindex 25134d28f656..6a50c1f499fa 100644--- a/products/signals/backend/models.py+++ b/products/signals/backend/models.py@@ -1105,9 +1105,10 @@ class SignalScoutConfig(ModelActivityMixin, TeamScopedRootMixin, UUIDModel):"""ACTIVE = "active", "Active"- # Warned by a system writer: will be paused on a set date unless something changes.- # Still scheduled. A state rather than a notification so the sweep that sets it is- # idempotent and any human touch has something concrete to clear.+ # Warned by a system writer. Still scheduled; whether the warning later advances to a+ # pause depends on its reason (an `ignored` warning pauses after a grace period, a+ # `no_output` one only ever warns). A state rather than a notification so the sweep+ # that sets it is idempotent and any human touch has something concrete to clear.PENDING_PAUSE = "pending_pause", "Pending pause"PAUSED_BY_SYSTEM = "paused_by_system", "Paused by system"# A human switched the scout off. No system writer may resume or re-pause it.@@ -1333,6 +1334,16 @@ class SignalScoutConfig(ModelActivityMixin, TeamScopedRootMixin, UUIDModel):kwargs["update_fields"] = fields | touchedsuper().save(*args, **kwargs)+ @classmethod+ def _pause_reasons_share_writer(cls, current: str | None, incoming: "SignalScoutConfig.PauseReason") -> bool:+ """The ownership rule compares writers, not exact reasons: the inactivity sweep owns+ both `no_output` and `ignored`, and must be able to reclassify its own warning from+ one to the other without being refused as a foreign writer."""+ if current == incoming:+ return True+ inactivity: set[str] = set(cls.INACTIVITY_PAUSE_REASONS)+ return current in inactivity and incoming in inactivity+def transition_status_by_system(self,new_status: "SignalScoutConfig.Status",@@ -1342,11 +1353,11 @@ class SignalScoutConfig(ModelActivityMixin, TeamScopedRootMixin, UUIDModel):) -> bool:"""Apply a system-driven status transition under the reason-scoped ownership rule.- `pause_reason` names the calling writer (an inactivity sweep passes `no_output`, a- failure breaker `repeated_failures`) as well as the reason recorded on a pause. The- rule: a system writer may never touch `paused_by_user`, and may only move a scout- whose current pause carries its own reason, so independent pause mechanisms cannot- clear or overwrite each other's state. The checks run against a freshly locked row,+ `pause_reason` names the calling writer (an inactivity sweep passes `no_output` or+ `ignored`, a failure breaker `repeated_failures`) as well as the reason recorded on a+ pause. The rule: a system writer may never touch `paused_by_user`, and may only move a+ scout whose current pause carries a reason it owns (`_pause_reasons_share_writer`), so+ independent pause mechanisms cannot clear or overwrite each other's state. The checks run against a freshly locked row,not the caller's instance, so a human pause or another writer's claim that landedafter the caller read the row cannot be overwritten. Pass `evaluated_at` (when thecaller read the state its decision is based on) to also refuse the transition if the@@ -1371,7 +1382,9 @@ class SignalScoutConfig(ModelActivityMixin, TeamScopedRootMixin, UUIDModel):return Falseif locked.status == self.Status.PAUSED_BY_USER:return False- if locked.status != self.Status.ACTIVE and locked.pause_reason != pause_reason:+ if locked.status != self.Status.ACTIVE and not self._pause_reasons_share_writer(+ locked.pause_reason, pause_reason+ ):return False# A warning is weaker than a pause: a delayed or retried warn must not reopen a# scout its own writer already paused (pending_pause is runnable).diff --git a/products/signals/backend/scout_harness/AGENTS.md b/products/signals/backend/scout_harness/AGENTS.mdindex ca533b4c283a..d18170a5073e 100644--- a/products/signals/backend/scout_harness/AGENTS.md+++ b/products/signals/backend/scout_harness/AGENTS.md@@ -37,8 +37,9 @@ In production it is driven by `SignalsScoutCoordinatorWorkflow` (periodic tick ePer-entity sections are deliberately light (counts + 5 most-recent items with name, status, timestamp); deep drilldowns go via the per-entity MCP list tools.See the module docstring at `profile/builders.py` for the authoritative section list — when adding or renaming a section, bump `INVENTORY_SOURCE_VERSION` so the cache invalidates cleanly.- `inactivity.py`- The stop switch on the waste axis (the failure breaker below covers the failure axis). `sweep_inactive_scouts()` warns, then auto-pauses any scout that goes `INACTIVITY_WINDOW` without either producing output on **any** of the three emit channels (`emitted_finding_ids` / `emitted_report_ids` / `edited_report_ids` — the finding tally alone would read every report-channel scout as silent) or having a **person** engage with a report it wrote earlier (a log artefact attributed to a user, or the report reaching a user-driven status — pipeline writers append log artefacts of their own, so unattributed ones don't count).- It speaks the scout lifecycle vocabulary rather than keeping fields of its own: the warning is `status=pending_pause` (still scheduled), the pause is `status=paused_by_system` (syncing `enabled=False`), both through `transition_status_by_system` with a `pause_reason` the sweep owns — `no_output` for a scout that surfaces nothing, `ignored` for one whose reports nobody picks up, separated because the two want different fixes — and the helper's reason-scoped ownership rule keeps the sweep and the failure breaker off each other's pauses.+ The stop switch on the waste axis (the failure breaker below covers the failure axis). `sweep_inactive_scouts()` judges **consumption, not emission**: a scout counts as consumed only when a **person** acted on a report it wrote or edited in the `TOUCHED_REPORT_LOOKBACK` — a log artefact attributed to a user (pipeline writers append log artefacts of their own, so unattributed ones don't count), or the report recently reaching `resolved`/`deleted` (`resolved` deliberately includes the GitHub webhook's resolve-on-merge, so a PR merged on GitHub with no in-app action still counts; `suppressed` is deliberately excluded because the same webhook suppresses on close-unmerged with no human involved).+ The two `pause_reason`s behave differently: `ignored` (the scout holds at least one report older than `ESTABLISHED_REPORT_AGE` and none of its reports show consumption) warns and then pauses after `WARNING_GRACE`; `no_output` (silent, with no judgeable report evidence) only ever warns, because a watch scout's silence can be its job. A scout with output but nothing judgeable on the report side — findings-only, Slack-routed (consumption happens in Slack where no evidence flows back), or every report younger than `ESTABLISHED_REPORT_AGE` — is left alone.+ It speaks the scout lifecycle vocabulary rather than keeping fields of its own: the warning is `status=pending_pause` (still scheduled), the pause is `status=paused_by_system` (syncing `enabled=False`), both through `transition_status_by_system`. The helper's ownership rule is writer-scoped: the sweep owns both of its reasons (so it can reclassify its own warning in either direction — `no_output` becomes `ignored` when report evidence establishes, restarting the grace clock, and `ignored` downgrades to `no_output` when its evidence ages out of the lookback, so a pause never lands on stale grounds), and neither the sweep nor the failure breaker can touch the other's pauses.Driven by the daily `pause_inactive_signal_scouts` Celery task rather than the coordinator tick, which stays short-lived and bounded. A dry-run scout, one inside `in_cold_start_grace()`, one that has barely run (`MIN_RUNS_IN_WINDOW`), and one flagged `auto_pause_exempt` (watchdogs whose value is staying quiet) are all left alone; new warnings are capped per sweep (`MAX_WARNS_PER_SWEEP`), which also bounds later pauses, since a pause only ever follows a warning by `WARNING_GRACE`.Unlike the failure breaker there is no probe — an inactivity pause never runs again on its own. Re-enabling through the config API resumes the scout, re-anchors its grace window, and marks it `auto_pause_exempt` so the sweep never overrules a person twice; that resume also emits `signals_scout_auto_pause_reverted`, the sweep's false-positive metric (the warn and pause emit `signals_scout_auto_pause_warned` / `signals_scout_auto_paused`).- `limits.py`diff --git a/products/signals/backend/scout_harness/inactivity.py b/products/signals/backend/scout_harness/inactivity.pyindex f0e469836b96..a47bea932c15 100644--- a/products/signals/backend/scout_harness/inactivity.py+++ b/products/signals/backend/scout_harness/inactivity.py@@ -1,38 +1,60 @@"""Inactivity sweep: warn, then auto-pause scouts that produce nothing anyone uses.-`SignalScoutConfig.enabled` only ever moves by hand, so a scout that surfaces nothing keeps-spending sandbox runs on its cadence indefinitely. This module is the missing stop: once a day-(`tasks.pause_inactive_signal_scouts`, deliberately not the 30-minute coordinator tick, which is-kept short-lived and bounded) it decides whether each enabled scout is still earning its runs.--A scout counts as **productive** if either half holds over the window:--- *output* — any run in the window recorded something on any of the three emit channels- (`emitted_finding_ids`, `emitted_report_ids`, `edited_report_ids`). All three matter: a- report-channel scout writes through `emit_report` / `edit_report`, so judging on the finding- tally alone would read every one of them as silent.-- *engagement* — a person acted on a report the scout wrote or edited before the window: they left a- log artefact on it (a note, a dismissal, a code reference…) inside the window, or the report- reached a state only a human action produces. Reports the scout touched- *inside* the window are excluded from this half — they are already covered by the output half, and- including them would count the scout's own writes as engagement with itself. Client-side opens- aren't persisted server-side, so they can't count either way.--The sweep speaks the scout lifecycle vocabulary rather than keeping fields of its own: a warning is-`status=pending_pause` (still scheduled), the pause is `status=paused_by_system`, and both carry a-`pause_reason` the sweep owns — `no_output` (it surfaced nothing at all) or `ignored` (it surfaced-reports nobody picked up). Every write goes through `transition_status_by_system`, whose-reason-scoped ownership rule keeps this sweep and the failure breaker (`repeated_failures`) from-touching each other's pauses, and whose `evaluated_at` check makes a racing human edit win over a-sweep decision made on stale reads. There is no half-open probe on this axis: an inactivity pause-never runs again on its own — a human re-enable is the only exit, and the update serializer marks-that re-enable `auto_pause_exempt` so the sweep never overrules it.+`SignalScoutConfig.enabled` only ever moves by hand, so a scout nobody is getting value from+keeps spending sandbox runs on its cadence indefinitely. This module is the missing stop: once a+day (`tasks.pause_inactive_signal_scouts`, deliberately not the 30-minute coordinator tick, which+is kept short-lived and bounded) it decides whether each enabled scout is still earning its runs.++The sweep judges **consumption, not emission**. Emitting a report is not evidence anyone wanted+it; a scout that files report after report nobody acts on is the expensive failure mode (a full+sandbox run per interval, plus inbox noise, plus pipeline work per finding), while a scout that+is merely quiet may be a watchdog whose silence is the job. So the two reasons behave+differently:++- `ignored` — the scout's reports show no human consumption. This is the pausing verdict: warn+ (`pending_pause`, still scheduled), then pause (`paused_by_system`) once `WARNING_GRACE`+ elapses.+- `no_output` — the scout surfaced nothing at all and has no report evidence to judge. This+ only ever warns: the badge asks a human to look, but silence alone never pauses a scout.++A scout counts as **consumed** when a person acted on any report it wrote or edited inside the+`TOUCHED_REPORT_LOOKBACK`: they left a log artefact on it (a note, a dismissal, a code+reference…) inside the window, or the report recently reached a state only a deliberate action+produces (`_ENGAGED_REPORT_STATUSES`). `resolved` is deliberately in that set even though the+GitHub webhook sets it without an in-app action, because the webhook resolves on PR *merge*: a+human merging the report's PR on GitHub is real consumption that leaves no other server-side+trace. `suppressed` is deliberately NOT in the set, because the same webhook suppresses a report+when its PR closes unmerged, which a stale-bot can do with no human anywhere in the loop; a+human archiving a report leaves a `DISMISSAL` artefact and is counted there instead. Client-side+opens aren't persisted server-side, so a report someone read but never acted on still counts as+unconsumed; a rescue feed of richer evidence (frontend opens, indirect report attribution) is a+planned follow-up, and its absence fails toward this rule's plain evidence, never toward extra+pauses. Report status changes carry no actor today, so a status flipped by another agent can+still read as consumption; tightening that needs actor attribution on status transitions.++The `ignored` verdict only applies when there is fair evidence to judge: the scout must hold at+least one touched report older than `ESTABLISHED_REPORT_AGE` (a report nobody has seen yet is+not a report nobody wanted), and Slack-routed scouts are exempt from it entirely because their+output is consumed in Slack where no evidence flows back. A scout with output but no judgeable+report evidence (findings-only, Slack-routed, or all reports too fresh) is left alone.++The sweep speaks the scout lifecycle vocabulary rather than keeping fields of its own. Every+write goes through `transition_status_by_system`, whose writer-scoped ownership rule keeps this+sweep and the failure breaker (`repeated_failures`) from touching each other's pauses (the sweep+owns both of its reasons, so it may reclassify its own warning in either direction: a `no_output`+warning becomes `ignored` when report evidence establishes, and an `ignored` warning downgrades+to `no_output` when its evidence ages out, so a pause never lands on stale grounds), and+whose `evaluated_at` check makes a racing human edit win over a sweep decision made on stale+reads. There is no half-open probe on this axis: an inactivity pause never runs again on its+own; a human re-enable is the only exit, and the update serializer marks that re-enable+`auto_pause_exempt` so the sweep never overrules it."""from __future__ import annotationsfrom dataclasses import dataclass, fieldfrom datetime import datetime, timedelta+from uuid import UUIDfrom django.utils import timezone@@ -42,6 +64,7 @@ from posthog.models.activity_logging.activity_log import Triggerfrom posthog.models.activity_logging.model_activity import ActivityTriggerContextfrom products.signals.backend.models import SignalReport, SignalReportArtefact, SignalScoutConfig, SignalScoutRun+from products.signals.backend.scout_harness.slack_delivery import get_scout_slack_destinationlogger = structlog.get_logger(__name__)@@ -50,7 +73,7 @@ logger = structlog.get_logger(__name__)INACTIVITY_WINDOW = timedelta(days=14)# Breathing room between the warning and the pause: the team gets a full week's notice on the fleet-# page, and a scout that surfaces something in the meantime clears its own warning.+# page, and a scout someone engages with in the meantime clears its own warning.WARNING_GRACE = timedelta(days=7)# A scout is only judged once it has actually had a fair number of attempts in the window. Guards@@ -63,19 +86,22 @@ MIN_RUNS_IN_WINDOW = 5# rescue the scout that wrote it.TOUCHED_REPORT_LOOKBACK = timedelta(days=90)-# Blast-radius cap: new warnings issued per sweep. Most of the running fleet qualifies as inactive-# on this rule the day it ships, and a pause can only ever follow a warning by `WARNING_GRACE`, so-# capping warnings alone bounds the pauses each later sweep can land while keeping every warned-# scout's "pauses in a week" promise honest. Applied in iteration order (team id, then skill name) —-# deterministic, so the sweep works through the backlog rather than re-sampling it. Deferrals are-# counted and logged: a capped sweep must read as "more to do", never as a clean bill of health.+# A report younger than this hasn't been ignored, it just hasn't been seen yet, so it cannot count+# toward the `ignored` verdict. Engagement with a fresh report still counts in the scout's favor.+ESTABLISHED_REPORT_AGE = timedelta(days=7)++# Blast-radius cap: new warnings issued per sweep. Most of the running fleet qualifies as+# unconsumed on this rule the day it ships, and a pause can only ever follow a warning by+# `WARNING_GRACE`, so capping warnings alone bounds the pauses each later sweep can land while+# keeping every warned scout's "pauses in a week" promise honest. Applied in iteration order+# (team id, then skill name) — deterministic, so the sweep works through the backlog rather than+# re-sampling it. Deferrals are counted and logged: a capped sweep must read as "more to do",+# never as a clean bill of health.MAX_WARNS_PER_SWEEP = 200-# The two pause reasons this sweep owns, from the model (`INACTIVITY_PAUSE_REASONS`): `no_output`-# for a scout that surfaced nothing at all, `ignored` for one that surfaced reports nobody picked-# up. Separated because they call for different fixes — an ignored scout needs retuning, a silent-# one may be watching a surface this project doesn't have. The reason-scoped ownership rule means-# the sweep may only advance or recover a warning carrying one of these.+# The two pause reasons this sweep owns, from the model (`INACTIVITY_PAUSE_REASONS`). The+# writer-scoped ownership rule means the sweep may only advance or recover a warning carrying one+# of these.SWEEP_REASONS: frozenset[str] = frozenset(SignalScoutConfig.INACTIVITY_PAUSE_REASONS)# Artefact types that mean work was done on a report. Only ones attributed to a person count (see@@ -85,12 +111,13 @@ _ENGAGEMENT_ARTEFACT_TYPES: frozenset[str] = SignalReportArtefact.LOG_ARTEFACT_T{SignalReportArtefact.ArtefactType.DISMISSAL})-# Statuses no pipeline transition produces: archiving, resolving, and deleting a report are all-# user-driven, which is what makes "report is in this state, and moved recently" a durable-# engagement signal even when the action left no artefact behind.+# Statuses that mean a person deliberately consumed the report. `resolved` covers both an in-app+# resolve and the GitHub webhook's resolve-on-merge (a merged PR is consumption even when the+# merge never touched the app). `suppressed` is excluded: the same webhook suppresses a report+# whose PR closed unmerged, which needs no human, and a human archive leaves a `DISMISSAL`+# artefact that the artefact half already counts._ENGAGED_REPORT_STATUSES: frozenset[str] = frozenset({- SignalReport.Status.SUPPRESSED,SignalReport.Status.RESOLVED,SignalReport.Status.DELETED,}@@ -110,10 +137,27 @@ class SweepOutcome:# Scouts that qualified for a warning after the per-sweep cap was already spent. They stay# active and are re-derived by the next sweep — counted so a capped sweep is visibly partial.deferred: int = 0+ # Whether each warned/paused config had output inside the window, keyed by config pk. Rides+ # the analytics events so the read-back can split noisy-but-unconsumed from silent.+ had_output: dict[UUID, bool] = field(default_factory=dict)+++@dataclass(frozen=True, kw_only=True)+class TeamAssessment:+ """Per-skill verdict inputs for one team's scouts."""++ # Ran often enough in the window for a verdict to mean anything.+ judgeable: set[str]+ # A person acted on a report the scout touched (any report age; the action is recent).+ engaged: set[str]+ # Recorded output on any emit channel inside the window.+ emitted: set[str]+ # Holds at least one touched report old enough to judge, so the `ignored` verdict applies.+ judged_on_reports: set[str]def sweep_inactive_scouts(now: datetime | None = None) -> SweepOutcome:- """Warn or pause every enabled scout that produced nothing anyone engaged with.+ """Warn or pause every enabled scout whose output nobody consumes.Idempotent: re-running the same day re-derives the same verdict from the runs and reportsthemselves, a warning already in place is only advanced once `WARNING_GRACE` has actually@@ -149,66 +193,119 @@ def sweep_inactive_scouts(now: datetime | None = None) -> SweepOutcome:outcome.considered += len(configs)try:assessment = _assess_team(team_id, [c.skill_name for c in configs], now)- productive, judgeable, has_past_output = assessmentexcept Exception:# One team's data problem must not cost the rest of the fleet its sweep.logger.exception("signals_scout inactivity sweep: team assessment failed", team_id=team_id)continuefor config in configs:- sweep_warned = (- config.status == SignalScoutConfig.Status.PENDING_PAUSE and config.pause_reason in SWEEP_REASONS- )- if config.skill_name in productive:- # It surfaced something again — drop the pending warning so a productive scout is- # never one quiet fortnight away from a pause it already worked off.- if sweep_warned and _transition(- config, SignalScoutConfig.Status.ACTIVE, config.pause_reason, evaluated_at=now- ):- outcome.recovered += 1- continue- if config.skill_name not in judgeable:- continue- if config.status == SignalScoutConfig.Status.ACTIVE:- if len(outcome.warned) >= MAX_WARNS_PER_SWEEP:- outcome.deferred += 1- continue- # Two shapes of the same waste, separated because they call for different fixes:- # a scout whose reports nobody picks up needs retuning, one that finds nothing at- # all may be watching a surface this project doesn't have.- reason = (- SignalScoutConfig.PauseReason.IGNORED- if config.skill_name in has_past_output- else SignalScoutConfig.PauseReason.NO_OUTPUT- )- if _transition(config, SignalScoutConfig.Status.PENDING_PAUSE, reason, evaluated_at=now):- outcome.warned.append(config)- logger.info(- "signals_scout inactivity sweep: warned",- team_id=config.team_id,- skill_name=config.skill_name,- reason=config.pause_reason,- )- elif sweep_warned:- # The pause carries the warned reason rather than reclassifying: a scout that- # produced anything since the warning recovered above, so the classification can- # only have moved by leaving the sweep's jurisdiction entirely.- warned_at = config.status_changed_at- if warned_at is None or now - warned_at < WARNING_GRACE:- continue- if _transition(- config, SignalScoutConfig.Status.PAUSED_BY_SYSTEM, config.pause_reason, evaluated_at=now- ):- outcome.paused.append(config)- logger.info(- "signals_scout inactivity sweep: paused",- team_id=config.team_id,- skill_name=config.skill_name,- reason=config.pause_reason,- )+ _apply_verdict(config, assessment, outcome, now)return outcome+def _apply_verdict(config: SignalScoutConfig, assessment: TeamAssessment, outcome: SweepOutcome, now: datetime) -> None:+ name = config.skill_name+ sweep_warned = config.status == SignalScoutConfig.Status.PENDING_PAUSE and config.pause_reason in SWEEP_REASONS++ if name in assessment.engaged:+ # Someone is using this scout's output — drop any pending warning so a consumed scout is+ # never one quiet week away from a pause it already worked off.+ if sweep_warned and _transition(config, SignalScoutConfig.Status.ACTIVE, config.pause_reason, evaluated_at=now):+ outcome.recovered += 1+ return+ if name not in assessment.judgeable:+ return++ # A Slack-routed scout's output is consumed in Slack, where no evidence flows back, so the+ # `ignored` verdict cannot be trusted for it. Its silence still warns below.+ slack_routed = get_scout_slack_destination(config.output_destinations) is not None+ if name in assessment.judged_on_reports and not slack_routed:+ _apply_ignored_verdict(config, outcome, now, had_output=name in assessment.emitted, sweep_warned=sweep_warned)+ return++ if name in assessment.emitted:+ # Producing output, but nothing judgeable on the report side (findings-only,+ # Slack-routed, or every report still fresh). Nothing to hold against it; a warning it+ # picked up earlier under different evidence gets cleared.+ if sweep_warned and _transition(config, SignalScoutConfig.Status.ACTIVE, config.pause_reason, evaluated_at=now):+ outcome.recovered += 1+ return++ # Silent, with no report evidence either way. Warn so a human looks at it, but never pause:+ # a watch scout that only speaks when something is wrong looks exactly like this.+ if sweep_warned and config.pause_reason == SignalScoutConfig.PauseReason.IGNORED:+ # The evidence behind the scheduled pause is gone (the touching runs aged past the+ # lookback, or the scout was re-routed to Slack since the warning), so the pause must not+ # land on stale grounds. Downgrade to the badge-only warning. Deliberately not capped:+ # deferring a downgrade would leave the scout scheduled to pause. Appended to `warned` so+ # the analytics event re-fires with the corrected reason.+ if _transition(+ config, SignalScoutConfig.Status.PENDING_PAUSE, SignalScoutConfig.PauseReason.NO_OUTPUT, evaluated_at=now+ ):+ outcome.warned.append(config)+ outcome.had_output[config.pk] = False+ logger.info(+ "signals_scout inactivity sweep: warned",+ team_id=config.team_id,+ skill_name=config.skill_name,+ reason=config.pause_reason,+ )+ return+ if config.status == SignalScoutConfig.Status.ACTIVE:+ if len(outcome.warned) >= MAX_WARNS_PER_SWEEP:+ outcome.deferred += 1+ return+ if _transition(+ config, SignalScoutConfig.Status.PENDING_PAUSE, SignalScoutConfig.PauseReason.NO_OUTPUT, evaluated_at=now+ ):+ outcome.warned.append(config)+ outcome.had_output[config.pk] = False+ logger.info(+ "signals_scout inactivity sweep: warned",+ team_id=config.team_id,+ skill_name=config.skill_name,+ reason=config.pause_reason,+ )+++def _apply_ignored_verdict(+ config: SignalScoutConfig, outcome: SweepOutcome, now: datetime, *, had_output: bool, sweep_warned: bool+) -> None:+ """Warn, reclassify, or pause a scout whose established reports show no consumption."""+ already_ignored = sweep_warned and config.pause_reason == SignalScoutConfig.PauseReason.IGNORED+ if config.status == SignalScoutConfig.Status.ACTIVE or (sweep_warned and not already_ignored):+ # Reclassifying a `no_output` warning to `ignored` schedules a pause for the first time,+ # so it restarts the grace clock and spends a slot under the cap like any fresh warning.+ if len(outcome.warned) >= MAX_WARNS_PER_SWEEP:+ outcome.deferred += 1+ return+ if _transition(+ config, SignalScoutConfig.Status.PENDING_PAUSE, SignalScoutConfig.PauseReason.IGNORED, evaluated_at=now+ ):+ outcome.warned.append(config)+ outcome.had_output[config.pk] = had_output+ logger.info(+ "signals_scout inactivity sweep: warned",+ team_id=config.team_id,+ skill_name=config.skill_name,+ reason=config.pause_reason,+ )+ return+ if already_ignored:+ warned_at = config.status_changed_at+ if warned_at is None or now - warned_at < WARNING_GRACE:+ return+ if _transition(config, SignalScoutConfig.Status.PAUSED_BY_SYSTEM, config.pause_reason, evaluated_at=now):+ outcome.paused.append(config)+ outcome.had_output[config.pk] = had_output+ logger.info(+ "signals_scout inactivity sweep: paused",+ team_id=config.team_id,+ skill_name=config.skill_name,+ reason=config.pause_reason,+ )++def _transition(config: SignalScoutConfig,new_status: SignalScoutConfig.Status,@@ -236,14 +333,7 @@ def _transition()-def _assess_team(team_id: int, skill_names: list[str], now: datetime) -> tuple[set[str], set[str], set[str]]:- """Return `(productive, judgeable, has_past_output)` skill-name sets for one team.-- Judgeable means the scout ran often enough in the window for "it found nothing" to mean- anything; productive means it passed either half of the productivity test; has_past_output- means it wrote reports before the window, which is what separates an ignored scout from one- that never surfaces anything.- """+def _assess_team(team_id: int, skill_names: list[str], now: datetime) -> TeamAssessment:window_start = now - INACTIVITY_WINDOWruns = (SignalScoutRun.objects.for_team(team_id)@@ -255,29 +345,28 @@ def _assess_team(team_id: int, skill_names: list[str], now: datetime) -> tuple[s)runs_in_window: dict[str, int] = {}- productive: set[str] = set()- # Reports each scout touched *before* the window — the only ones the engagement half reads, so a- # scout's own in-window writes can't be mistaken for someone engaging with them.- touched_before_window: dict[str, set[str]] = {}+ emitted: set[str] = set()+ touched: dict[str, set[str]] = {}for skill_name, created_at, finding_ids, report_ids, edited_ids in runs:- emitted_anything = bool(finding_ids) or bool(report_ids) or bool(edited_ids)if created_at >= window_start:runs_in_window[skill_name] = runs_in_window.get(skill_name, 0) + 1- if emitted_anything:- productive.add(skill_name)- continue- touched = {str(report_id) for report_id in (report_ids or []) + (edited_ids or [])}- if touched:- touched_before_window.setdefault(skill_name, set()).update(touched)+ if bool(finding_ids) or bool(report_ids) or bool(edited_ids):+ emitted.add(skill_name)+ reports = {str(report_id) for report_id in (report_ids or []) + (edited_ids or [])}+ if reports:+ touched.setdefault(skill_name, set()).update(reports)judgeable = {name for name, count in runs_in_window.items() if count >= MIN_RUNS_IN_WINDOW}- pending = {- name: reports for name, reports in touched_before_window.items() if name in judgeable and name not in productive- }- if pending:- engaged = _engaged_report_ids(team_id, set().union(*pending.values()), window_start)- productive.update(name for name, reports in pending.items() if reports & engaged)- return productive, judgeable, set(touched_before_window)+ relevant = {name: reports for name, reports in touched.items() if name in judgeable}+ all_touched: set[str] = set().union(*relevant.values()) if relevant else set()+ engaged_ids = _engaged_report_ids(team_id, all_touched, window_start)+ established_ids = _established_report_ids(team_id, all_touched, now - ESTABLISHED_REPORT_AGE)+ return TeamAssessment(+ judgeable=judgeable,+ engaged={name for name, reports in relevant.items() if reports & engaged_ids},+ emitted=emitted,+ judged_on_reports={name for name, reports in relevant.items() if reports & established_ids},+ )def _engaged_report_ids(team_id: int, report_ids: set[str], window_start: datetime) -> set[str]:@@ -308,3 +397,17 @@ def _engaged_report_ids(team_id: int, report_ids: set[str], window_start: dateti).values_list("id", flat=True)}return engaged+++def _established_report_ids(team_id: int, report_ids: set[str], created_before: datetime) -> set[str]:+ """Of `report_ids`, the ones old enough that no consumption is meaningful, not just unseen."""+ if not report_ids:+ return set()+ return {+ str(report_id)+ for report_id in SignalReport.objects.filter(+ team_id=team_id,+ id__in=report_ids,+ created_at__lte=created_before,+ ).values_list("id", flat=True)+ }diff --git a/products/signals/backend/scout_harness/serializers.py b/products/signals/backend/scout_harness/serializers.pyindex 37bb60d4879a..6f758c3d8a5c 100644--- a/products/signals/backend/scout_harness/serializers.py+++ b/products/signals/backend/scout_harness/serializers.py@@ -1968,17 +1968,18 @@ class SignalScoutConfigSerializer(serializers.ModelSerializer):allow_null=True,help_text=("When `status` last changed. For `pending_pause` this is when the warning was issued "- "(the pause lands about a week later unless the scout surfaces something); for the "- "paused statuses it is when the scout was paused. Null if the status never changed."+ "(an `ignored` warning pauses about a week later unless someone acts on the scout's "+ "reports; a `no_output` warning only flags the scout); for the paused statuses it is "+ "when the scout was paused. Null if the status never changed."),)auto_pause_exempt = serializers.BooleanField(read_only=True,help_text=(- "Whether this scout is exempt from the inactivity pause. Set it on watchdog scouts whose "- "value is staying quiet, so silence is never read as waste. Also set automatically when "- "someone re-enables a scout the inactivity sweep paused, so the sweep never overrules a "- "person twice."+ "Whether this scout is exempt from the inactivity sweep, meaning both the `ignored` "+ "pause and the `no_output` quiet warning. Set it on watchdog scouts whose value is "+ "staying quiet. Also set automatically when someone re-enables a scout the inactivity "+ "sweep paused, so the sweep never overrules a person twice."),)@@ -2123,8 +2124,8 @@ class SignalScoutConfigUpdateSerializer(serializers.ModelSerializer):auto_pause_exempt = serializers.BooleanField(required=False,help_text=(- "Exempt this scout from the inactivity pause. Set it on watchdog scouts whose value is "- "staying quiet, so silence is never read as waste."+ "Exempt this scout from the inactivity sweep, meaning both the `ignored` pause and the "+ "`no_output` quiet warning. Set it on watchdog scouts whose value is staying quiet."),)diff --git a/products/signals/backend/tasks.py b/products/signals/backend/tasks.pyindex dd123e625a91..8d0636cd00c1 100644--- a/products/signals/backend/tasks.py+++ b/products/signals/backend/tasks.py@@ -551,6 +551,9 @@ def pause_inactive_signal_scouts() -> None:"skill_name": config.skill_name,"run_interval_minutes": config.run_interval_minutes,"pause_reason": config.pause_reason,+ # Splits noisy-but-unconsumed from silent in the read-back; the two+ # cohorts need different fixes (retune vs refocus).+ "had_output": outcome.had_output.get(config.pk),},groups=groups(organization=organization),)diff --git a/products/signals/backend/test/test_scout_inactivity.py b/products/signals/backend/test/test_scout_inactivity.pyindex 3b5d175c3de9..4748ec482812 100644--- a/products/signals/backend/test/test_scout_inactivity.py+++ b/products/signals/backend/test/test_scout_inactivity.py@@ -14,6 +14,7 @@ from posthog.models.activity_logging.activity_log import ActivityLogfrom products.signals.backend.models import SignalReport, SignalReportArtefact, SignalScoutConfig, SignalScoutRunfrom products.signals.backend.scout_harness.config_registry import register_missing_configsfrom products.signals.backend.scout_harness.inactivity import (+ ESTABLISHED_REPORT_AGE,INACTIVITY_WINDOW,MIN_RUNS_IN_WINDOW,WARNING_GRACE,@@ -65,8 +66,10 @@ class TestScoutInactivitySweep(BaseTest):runs.append(run)return runs- def _report(self) -> SignalReport:- return SignalReport.objects.create(team=self.team, title="A report", summary="Something")+ def _report(self, *, age: timedelta = ESTABLISHED_REPORT_AGE + timedelta(days=3)) -> SignalReport:+ report = SignalReport.objects.create(team=self.team, title="A report", summary="Something")+ SignalReport.objects.filter(pk=report.pk).update(created_at=self.now - age)+ return reportdef _silent_runs(self, config: SignalScoutConfig | None = None) -> None:# Recent enough that the runs stay inside the assessment window at the post-grace pause@@ -74,6 +77,10 @@ class TestScoutInactivitySweep(BaseTest):# the exact grace boundary — see `_pause_time`).self._runs(MIN_RUNS_IN_WINDOW, age=INACTIVITY_WINDOW / 4, config=config)+ def _emitting_runs(self, report: SignalReport, config: SignalScoutConfig | None = None) -> None:+ self._runs(MIN_RUNS_IN_WINDOW - 1, age=INACTIVITY_WINDOW / 4, config=config)+ self._runs(1, age=INACTIVITY_WINDOW / 4, config=config, emitted_report_ids=[str(report.id)])+@propertydef _pause_time(self) -> Any:return self.now + WARNING_GRACE + timedelta(hours=1)@@ -81,17 +88,20 @@ class TestScoutInactivitySweep(BaseTest):def _reload(self) -> SignalScoutConfig:return SignalScoutConfig.all_teams.get(pk=self.config.pk)- def test_silent_scout_is_warned_then_paused_after_the_grace_period(self) -> None:- self._silent_runs()+ def test_an_emitting_scout_nobody_acts_on_is_paused_as_ignored(self) -> None:+ # The headline rule: emission is not evidence of value, so a scout filing reports nobody+ # acts on must not read as productive just because it keeps filing.+ self._emitting_runs(self._report())outcome = sweep_inactive_scouts(now=self.now)warned = self._reload()assert [c.pk for c in outcome.warned] == [self.config.pk]+ assert outcome.had_output[self.config.pk] is Trueassert warned.enabled is Trueassert warned.status == SignalScoutConfig.Status.PENDING_PAUSE- assert warned.pause_reason == SignalScoutConfig.PauseReason.NO_OUTPUT+ assert warned.pause_reason == SignalScoutConfig.PauseReason.IGNORED- # Still silent a day later: warned, not yet due to pause.+ # Still unconsumed a day later: warned, not yet due to pause.assert not sweep_inactive_scouts(now=self.now + timedelta(days=1)).pausedoutcome = sweep_inactive_scouts(now=self._pause_time)@@ -99,11 +109,27 @@ class TestScoutInactivitySweep(BaseTest):assert [c.pk for c in outcome.paused] == [self.config.pk]assert paused.enabled is Falseassert paused.status == SignalScoutConfig.Status.PAUSED_BY_SYSTEM- assert paused.pause_reason == SignalScoutConfig.PauseReason.NO_OUTPUT+ assert paused.pause_reason == SignalScoutConfig.PauseReason.IGNORED++ def test_a_silent_scout_is_flagged_but_never_paused(self) -> None:+ # A watch scout that only speaks when something is wrong looks exactly like this, so+ # silence warns (the badge asks a human to look) but must never advance to a pause.+ self._silent_runs()++ outcome = sweep_inactive_scouts(now=self.now)+ warned = self._reload()+ assert [c.pk for c in outcome.warned] == [self.config.pk]+ assert outcome.had_output[self.config.pk] is False+ assert warned.status == SignalScoutConfig.Status.PENDING_PAUSE+ assert warned.pause_reason == SignalScoutConfig.PauseReason.NO_OUTPUT++ outcome = sweep_inactive_scouts(now=self._pause_time)+ still_warned = self._reload()+ assert outcome.paused == []+ assert still_warned.enabled is True+ assert still_warned.status == SignalScoutConfig.Status.PENDING_PAUSEdef test_a_scout_whose_older_reports_went_unread_is_paused_as_ignored(self) -> None:- # Separated from `no_output` because the two want different fixes: retune a scout whose- # reports nobody picks up, retire one that never finds anything.report = self._report()self._runs(1, age=INACTIVITY_WINDOW + timedelta(days=5), emitted_report_ids=[str(report.id)])self._silent_runs()@@ -116,53 +142,65 @@ class TestScoutInactivitySweep(BaseTest):assert paused.status == SignalScoutConfig.Status.PAUSED_BY_SYSTEMassert paused.pause_reason == SignalScoutConfig.PauseReason.IGNORED- def test_sweep_transitions_are_activity_logged_without_pinning_them_on_a_user(self) -> None:+ def test_a_legacy_no_output_warning_is_reclassified_with_a_fresh_grace(self) -> None:+ # Rows warned `no_output` under the pre-consumption rule (or by an earlier sweep, before+ # their reports established) get rescheduled as `ignored` rather than paused off the old+ # warning's clock, so the "pauses in a week" promise stays honest.+ SignalScoutConfig.all_teams.filter(pk=self.config.pk).update(+ status=SignalScoutConfig.Status.PENDING_PAUSE,+ pause_reason=SignalScoutConfig.PauseReason.NO_OUTPUT,+ status_changed_at=self.now - WARNING_GRACE - timedelta(days=1),+ )+ report = self._report()+ self._runs(1, age=INACTIVITY_WINDOW + timedelta(days=5), emitted_report_ids=[str(report.id)])self._silent_runs()- ActivityLog.objects.filter(scope="SignalScoutConfig").delete()- sweep_inactive_scouts(now=self.now)- sweep_inactive_scouts(now=self._pause_time)-- entries = list(ActivityLog.objects.filter(scope="SignalScoutConfig", item_id=str(self.config.id)))- assert len(entries) == 2- for entry in entries:- assert entry.user is None- detail = entry.detail or {}- assert detail.get("trigger", {}).get("job_type") == "signals_scout_inactivity_sweep"-- @parameterized.expand(- [- ("findings", {"emitted_finding_ids": ["finding-1"], "emitted_count": 1}),- ("reports", {"emitted_report_ids": ["a3f0a1de-0000-4000-8000-000000000001"]}),- ("edits", {"edited_report_ids": ["a3f0a1de-0000-4000-8000-000000000002"]}),- ]- )- def test_output_on_any_emit_channel_keeps_a_scout_running(self, _name: str, output: dict) -> None:- # `emitted_count` covers only `emit_finding`, so judging on it alone would read every- # report-channel scout as silent and pause it.- self._runs(MIN_RUNS_IN_WINDOW - 1, age=INACTIVITY_WINDOW / 2)- self._runs(1, age=INACTIVITY_WINDOW / 2, **output)+ outcome = sweep_inactive_scouts(now=self.now)+ reclassified = self._reload()+ assert [c.pk for c in outcome.warned] == [self.config.pk]+ assert outcome.paused == []+ assert reclassified.status == SignalScoutConfig.Status.PENDING_PAUSE+ assert reclassified.pause_reason == SignalScoutConfig.PauseReason.IGNORED++ # The old warning's elapsed time doesn't count toward the new reason's grace.+ assert sweep_inactive_scouts(now=self.now + timedelta(days=1)).paused == []+ assert [c.pk for c in sweep_inactive_scouts(now=self._pause_time).paused] == [self.config.pk]++ def test_an_ignored_warning_whose_evidence_aged_out_downgrades_instead_of_stranding(self) -> None:+ # Once warned `ignored`, the pause re-derives its evidence each sweep. If the touching+ # runs age past the lookback before the grace elapses, the scout must not pause off stale+ # grounds, and must not freeze in `pending_pause` forever either: it downgrades to the+ # badge-only `no_output` warning.+ SignalScoutConfig.all_teams.filter(pk=self.config.pk).update(+ status=SignalScoutConfig.Status.PENDING_PAUSE,+ pause_reason=SignalScoutConfig.PauseReason.IGNORED,+ status_changed_at=self.now - WARNING_GRACE - timedelta(days=1),+ )+ self._silent_runs()outcome = sweep_inactive_scouts(now=self.now)- assert outcome.warned == []- assert self._reload().status == SignalScoutConfig.Status.ACTIVE+ downgraded = self._reload()+ assert outcome.paused == []+ assert [c.pk for c in outcome.warned] == [self.config.pk]+ assert downgraded.status == SignalScoutConfig.Status.PENDING_PAUSE+ assert downgraded.pause_reason == SignalScoutConfig.PauseReason.NO_OUTPUT+ assert sweep_inactive_scouts(now=self._pause_time).paused == []@parameterized.expand([("log_artefact", SignalReportArtefact.ArtefactType.NOTE, None),("dismissal_artefact", SignalReportArtefact.ArtefactType.DISMISSAL, None),- ("user_driven_status", None, SignalReport.Status.SUPPRESSED),+ # `resolved` includes the GitHub webhook's resolve-on-merge, which is how a merged PR+ # counts as consumption even when the merge never touched the app.+ ("resolved_status", None, SignalReport.Status.RESOLVED),])- def test_engagement_with_an_older_report_keeps_a_silent_scout_running(+ def test_engagement_with_a_report_keeps_a_scout_running(self, _name: str, artefact_type: str | None, report_status: str | None) -> None:report = self._report()- # Authored before the window, so the run itself is no longer output — only what happened to- # the report since counts.- self._runs(1, age=INACTIVITY_WINDOW + timedelta(days=5), emitted_report_ids=[str(report.id)])- self._silent_runs()+ self._emitting_runs(report)if artefact_type is not None:SignalReportArtefact.objects.create(team=self.team, report=report, type=artefact_type, content="{}", created_by=self.user@@ -177,6 +215,21 @@ class TestScoutInactivitySweep(BaseTest):assert outcome.warned == []assert self._reload().status == SignalScoutConfig.Status.ACTIVE+ def test_a_webhook_suppressed_report_is_not_engagement(self) -> None:+ # The GitHub webhook suppresses a report whose PR closed unmerged, which a stale-bot can+ # do with no human in the loop; counting it would keep zombie scouts alive. A human+ # archive leaves a DISMISSAL artefact, covered above.+ report = self._report()+ self._emitting_runs(report)+ SignalReport.objects.filter(pk=report.pk).update(+ status=SignalReport.Status.SUPPRESSED, updated_at=self.now - timedelta(days=1)+ )++ outcome = sweep_inactive_scouts(now=self.now)++ assert [c.pk for c in outcome.warned] == [self.config.pk]+ assert self._reload().pause_reason == SignalScoutConfig.PauseReason.IGNORED+@parameterized.expand([# A pipeline assessment, never a person's work.@@ -188,8 +241,7 @@ class TestScoutInactivitySweep(BaseTest):)def test_pipeline_artefacts_are_not_engagement(self, _name: str, artefact_type: str) -> None:report = self._report()- self._runs(1, age=INACTIVITY_WINDOW + timedelta(days=5), emitted_report_ids=[str(report.id)])- self._silent_runs()+ self._emitting_runs(report)SignalReportArtefact.objects.create(team=self.team,report=report,@@ -199,6 +251,60 @@ class TestScoutInactivitySweep(BaseTest):assert [c.pk for c in sweep_inactive_scouts(now=self.now).warned] == [self.config.pk]+ def test_a_scout_whose_reports_are_all_fresh_is_not_judged(self) -> None:+ # A report younger than ESTABLISHED_REPORT_AGE hasn't been ignored, it just hasn't been+ # seen yet.+ self._emitting_runs(self._report(age=timedelta(days=2)))++ outcome = sweep_inactive_scouts(now=self.now)++ assert outcome.warned == []+ assert self._reload().status == SignalScoutConfig.Status.ACTIVE++ @parameterized.expand(+ [+ ("findings_only", {"emitted_finding_ids": ["finding-1"], "emitted_count": 1}),+ # A report id with no report row behind it (a deleted or foreign-team report) must not+ # crash the assessment or count against the scout.+ ("dangling_report_id", {"emitted_report_ids": ["a3f0a1de-0000-4000-8000-000000000001"]}),+ ]+ )+ def test_output_without_judgeable_reports_keeps_a_scout_running(self, _name: str, output: dict) -> None:+ self._runs(MIN_RUNS_IN_WINDOW - 1, age=INACTIVITY_WINDOW / 2)+ self._runs(1, age=INACTIVITY_WINDOW / 2, **output)++ outcome = sweep_inactive_scouts(now=self.now)++ assert outcome.warned == []+ assert self._reload().status == SignalScoutConfig.Status.ACTIVE++ def test_a_slack_routed_scout_is_not_judged_on_report_consumption(self) -> None:+ # Slack output is consumed in Slack, where no evidence flows back, so the unconsumed+ # verdict cannot be trusted for these scouts.+ SignalScoutConfig.all_teams.filter(pk=self.config.pk).update(+ output_destinations={"slack": {"integration_id": 1, "channel": "C123"}}+ )+ self._emitting_runs(self._report())++ outcome = sweep_inactive_scouts(now=self.now)++ assert outcome.warned == []+ assert self._reload().status == SignalScoutConfig.Status.ACTIVE++ def test_sweep_transitions_are_activity_logged_without_pinning_them_on_a_user(self) -> None:+ self._emitting_runs(self._report())+ ActivityLog.objects.filter(scope="SignalScoutConfig").delete()++ sweep_inactive_scouts(now=self.now)+ sweep_inactive_scouts(now=self._pause_time)++ entries = list(ActivityLog.objects.filter(scope="SignalScoutConfig", item_id=str(self.config.id)))+ assert len(entries) == 2+ for entry in entries:+ assert entry.user is None+ detail = entry.detail or {}+ assert detail.get("trigger", {}).get("job_type") == "signals_scout_inactivity_sweep"+def test_a_scout_that_recovers_loses_its_warning(self) -> None:self._silent_runs()sweep_inactive_scouts(now=self.now)@@ -212,6 +318,25 @@ class TestScoutInactivitySweep(BaseTest):assert recovered.pause_reason is Noneassert recovered.enabled is True+ def test_an_ignored_warning_is_cleared_by_engagement(self) -> None:+ report = self._report()+ self._emitting_runs(report)+ sweep_inactive_scouts(now=self.now)+ SignalReportArtefact.objects.create(+ team=self.team,+ report=report,+ type=SignalReportArtefact.ArtefactType.DISMISSAL,+ content="{}",+ created_by=self.user,+ )++ outcome = sweep_inactive_scouts(now=self.now + timedelta(days=1))++ recovered = self._reload()+ assert outcome.recovered == 1+ assert recovered.status == SignalScoutConfig.Status.ACTIVE+ assert recovered.pause_reason is None+@parameterized.expand([("exempt", {"auto_pause_exempt": True}),@@ -229,7 +354,7 @@ class TestScoutInactivitySweep(BaseTest):)def test_scouts_the_sweep_must_not_touch(self, _name: str, overrides: dict) -> None:SignalScoutConfig.all_teams.filter(pk=self.config.pk).update(**overrides)- self._silent_runs()+ self._emitting_runs(self._report())outcome = sweep_inactive_scouts(now=self.now)@@ -238,7 +363,7 @@ class TestScoutInactivitySweep(BaseTest):def test_a_cold_start_scout_is_left_alone(self) -> None:SignalScoutConfig.all_teams.filter(pk=self.config.pk).update(created_at=self.now - timedelta(days=1))- self._silent_runs()+ self._emitting_runs(self._report())assert sweep_inactive_scouts(now=self.now).warned == []@@ -251,8 +376,8 @@ class TestScoutInactivitySweep(BaseTest):def test_a_resumed_scout_gets_a_full_fresh_window(self) -> None:# A human re-enable re-anchors `in_cold_start_grace` via `status_changed_at`, so the sweep- # must not judge the resumed scout on the same silent runs that got it paused.- self._silent_runs()+ # must not judge the resumed scout on the same unconsumed reports that got it paused.+ self._emitting_runs(self._report())sweep_inactive_scouts(now=self.now)sweep_inactive_scouts(now=self._pause_time)resumed_at = timezone.now()@@ -285,7 +410,7 @@ class TestScoutInactivitySweep(BaseTest):# Configs are re-reconciled on every coordinator tick; a pause that gets quietly re-enabled# there would put the scout straight back on the schedule.LLMSkill.objects.create(team=self.team, name=SKILL, description="Quiet", body="Look around")- self._silent_runs()+ self._emitting_runs(self._report())sweep_inactive_scouts(now=self.now)sweep_inactive_scouts(now=self._pause_time)diff --git a/products/signals/backend/test/test_scout_status.py b/products/signals/backend/test/test_scout_status.pyindex 7bc379367ee3..fd0a660be7e4 100644--- a/products/signals/backend/test/test_scout_status.py+++ b/products/signals/backend/test/test_scout_status.py@@ -58,11 +58,29 @@ class TestScoutStatusTransitions(BaseTest):("other_writer_cannot_overwrite_pause",Status.PAUSED_BY_SYSTEM,- Reason.NO_OUTPUT,+ Reason.REPEATED_FAILURES,Status.PAUSED_BY_SYSTEM,Reason.IGNORED,False,),+ # The sweep owns both inactivity reasons, so reclassifying its own warning is not a+ # foreign write. Reclassification restarts the grace clock via `status_changed_at`.+ (+ "sweep_reclassifies_its_own_warning",+ Status.PENDING_PAUSE,+ Reason.NO_OUTPUT,+ Status.PENDING_PAUSE,+ Reason.IGNORED,+ True,+ ),+ (+ "sweep_resumes_either_of_its_own_reasons",+ Status.PENDING_PAUSE,+ Reason.IGNORED,+ Status.ACTIVE,+ Reason.NO_OUTPUT,+ True,+ ),("other_writer_cannot_resume",Status.PAUSED_BY_SYSTEM,diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.tsindex 08f06b061e0c..6c0aa205a5e9 100644--- a/products/signals/frontend/generated/api.schemas.ts+++ b/products/signals/frontend/generated/api.schemas.ts@@ -1955,11 +1955,11 @@ export interface SignalScoutConfigApi {/** How many of this scout's runs have failed in a row. Back to 0 after a successful run or any config edit. At the failure limit the scout pauses itself (`status` becomes `paused_by_system` with `pause_reason` `repeated_failures`) and retries about once a day; a successful retry resumes it, and so does setting `enabled=true`. */readonly consecutive_failure_count: number/**- * When `status` last changed. For `pending_pause` this is when the warning was issued (the pause lands about a week later unless the scout surfaces something); for the paused statuses it is when the scout was paused. Null if the status never changed.+ * When `status` last changed. For `pending_pause` this is when the warning was issued (an `ignored` warning pauses about a week later unless someone acts on the scout's reports; a `no_output` warning only flags the scout); for the paused statuses it is when the scout was paused. Null if the status never changed.* @nullable*/readonly status_changed_at: string | null- /** Whether this scout is exempt from the inactivity pause. Set it on watchdog scouts whose value is staying quiet, so silence is never read as waste. Also set automatically when someone re-enables a scout the inactivity sweep paused, so the sweep never overrules a person twice. */+ /** Whether this scout is exempt from the inactivity sweep, meaning both the `ignored` pause and the `no_output` quiet warning. Set it on watchdog scouts whose value is staying quiet. Also set automatically when someone re-enables a scout the inactivity sweep paused, so the sweep never overrules a person twice. */readonly auto_pause_exempt: booleanreadonly created_at: string}@@ -2027,7 +2027,7 @@ export interface PatchedSignalScoutConfigUpdateApi {run_cron_schedule?: string | null/** Destinations that receive each finding or report this scout emits. Pass an empty object to disable delivery. */output_destinations?: SignalScoutOutputDestinationsApi- /** Exempt this scout from the inactivity pause. Set it on watchdog scouts whose value is staying quiet, so silence is never read as waste. */+ /** Exempt this scout from the inactivity sweep, meaning both the `ignored` pause and the `no_output` quiet warning. Set it on watchdog scouts whose value is staying quiet. */auto_pause_exempt?: boolean}diff --git a/products/signals/frontend/generated/api.zod.ts b/products/signals/frontend/generated/api.zod.tsindex 6386ed2d52b5..59752b859f60 100644--- a/products/signals/frontend/generated/api.zod.ts+++ b/products/signals/frontend/generated/api.zod.ts@@ -571,7 +571,7 @@ export const SignalsScoutConfigUpdateBody = /* @__PURE__ */ zod.boolean().optional().describe(- 'Exempt this scout from the inactivity pause. Set it on watchdog scouts whose value is staying quiet, so silence is never read as waste.'+ 'Exempt this scout from the inactivity sweep, meaning both the `ignored` pause and the `no_output` quiet warning. Set it on watchdog scouts whose value is staying quiet.'),}).describe('Editable schedule, enablement, and emit posture for one scout config.')diff --git a/products/signals/skills/authoring-scouts/SKILL.md b/products/signals/skills/authoring-scouts/SKILL.mdindex ea8954f46248..3d977ad02910 100644--- a/products/signals/skills/authoring-scouts/SKILL.md+++ b/products/signals/skills/authoring-scouts/SKILL.md@@ -113,9 +113,9 @@ For an **existing scout**, tune with `posthog:scout-config-update` (find the `idSet **`emit=false` (dry-run)** only when you want to be extra careful: the scout still runs and logs its reasoning but writes nothing to the inbox.Reach for dry-run on a scout you expect to be chatty, expensive, or high-stakes; for most scouts, just writing and watching the inbox is the better loop.- `auto_pause_exempt` — defaults to `false`.- A scout that goes two weeks without surfacing anything, and whose earlier reports nobody has picked up since, is warned and then paused automatically — every run costs a sandbox agent, so a scout going nowhere shouldn't keep running forever.- `-config-list` shows the warning as `status=pending_pause` and the pause as `status=paused_by_system`, with `pause_reason` saying which shape of quiet it was (`no_output` vs `ignored`); setting `enabled=true` again resumes the scout, and marks it exempt so the sweep never overrules a person twice.- Set `auto_pause_exempt=true` up front for a watchdog scout whose whole job is to stay quiet, so its silence is never read as waste.+ A scout whose reports nobody acts on is warned and then paused automatically (`pause_reason=ignored`) — every run costs a sandbox agent, so a scout producing output no human consumes shouldn't keep running forever. A scout that is merely quiet is only flagged (`pause_reason=no_output`, a warning that never advances to a pause), since a watch scout's silence can be its job.+ `-config-list` shows the warning as `status=pending_pause` and the pause as `status=paused_by_system`; setting `enabled=true` again resumes the scout, and marks it exempt so the sweep never overrules a person twice.+ Set `auto_pause_exempt=true` up front for a watchdog scout whose whole job is to stay quiet, so it never even picks up the quiet flag.## Steering with notes (no authoring needed)diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 00ba16d5c834..aba7032fbc30 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -54568,7 +54568,7 @@ export namespace Schemas {run_cron_schedule?: string | null;/** Destinations that receive each finding or report this scout emits. Pass an empty object to disable delivery. */output_destinations?: SignalScoutOutputDestinations;- /** Exempt this scout from the inactivity pause. Set it on watchdog scouts whose value is staying quiet, so silence is never read as waste. */+ /** Exempt this scout from the inactivity sweep, meaning both the `ignored` pause and the `no_output` quiet warning. Set it on watchdog scouts whose value is staying quiet. */auto_pause_exempt?: boolean;}@@ -64387,11 +64387,11 @@ export namespace Schemas {/** How many of this scout's runs have failed in a row. Back to 0 after a successful run or any config edit. At the failure limit the scout pauses itself (`status` becomes `paused_by_system` with `pause_reason` `repeated_failures`) and retries about once a day; a successful retry resumes it, and so does setting `enabled=true`. */readonly consecutive_failure_count: number;/**- * When `status` last changed. For `pending_pause` this is when the warning was issued (the pause lands about a week later unless the scout surfaces something); for the paused statuses it is when the scout was paused. Null if the status never changed.+ * When `status` last changed. For `pending_pause` this is when the warning was issued (an `ignored` warning pauses about a week later unless someone acts on the scout's reports; a `no_output` warning only flags the scout); for the paused statuses it is when the scout was paused. Null if the status never changed.* @nullable*/readonly status_changed_at: string | null;- /** Whether this scout is exempt from the inactivity pause. Set it on watchdog scouts whose value is staying quiet, so silence is never read as waste. Also set automatically when someone re-enables a scout the inactivity sweep paused, so the sweep never overrules a person twice. */+ /** Whether this scout is exempt from the inactivity sweep, meaning both the `ignored` pause and the `no_output` quiet warning. Set it on watchdog scouts whose value is staying quiet. Also set automatically when someone re-enables a scout the inactivity sweep paused, so the sweep never overrules a person twice. */readonly auto_pause_exempt: boolean;readonly created_at: string;}diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.tsindex ef79837f9980..01e23fc886f7 100644--- a/services/mcp/src/generated/signals/api.ts+++ b/services/mcp/src/generated/signals/api.ts@@ -705,7 +705,7 @@ export const SignalsScoutConfigUpdateBody = /* @__PURE__ */ zod.boolean().optional().describe(- 'Exempt this scout from the inactivity pause. Set it on watchdog scouts whose value is staying quiet, so silence is never read as waste.'+ 'Exempt this scout from the inactivity sweep, meaning both the `ignored` pause and the `no_output` quiet warning. Set it on watchdog scouts whose value is staying quiet.'),}).describe('Editable schedule, enablement, and emit posture for one scout config.')diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-update.jsonindex bd62a8bf490d..6fc4ffafd9b6 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-update.json@@ -2,7 +2,7 @@"$schema": "https://json-schema.org/draft/2020-12/schema","properties": {"auto_pause_exempt": {- "description": "Exempt this scout from the inactivity pause. Set it on watchdog scouts whose value is staying quiet, so silence is never read as waste.",+ "description": "Exempt this scout from the inactivity sweep, meaning both the `ignored` pause and the `no_output` quiet warning. Set it on watchdog scouts whose value is staying quiet.","type": "boolean"},"emit": {diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-update.jsonindex bd62a8bf490d..6fc4ffafd9b6 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-update.json@@ -2,7 +2,7 @@"$schema": "https://json-schema.org/draft/2020-12/schema","properties": {"auto_pause_exempt": {- "description": "Exempt this scout from the inactivity pause. Set it on watchdog scouts whose value is staying quiet, so silence is never read as waste.",+ "description": "Exempt this scout from the inactivity sweep, meaning both the `ignored` pause and the `no_output` quiet warning. Set it on watchdog scouts whose value is staying quiet.","type": "boolean"},"emit": {