Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(signals): give canonical scouts a deprecation lifecycle (#104502)

posthog[bot]e3a9ab352bb1
diff --git a/products/replay_vision/frontend/generated/api.schemas.ts b/products/replay_vision/frontend/generated/api.schemas.ts
index a5d61c423a74..9e10b3fe2fb8 100644
--- a/products/replay_vision/frontend/generated/api.schemas.ts
+++ b/products/replay_vision/frontend/generated/api.schemas.ts
@@ -1948,6 +1948,38 @@ export const ScoutRoleEnumApi = {
Operational: 'operational',
} as const
+/**
+ * * `announced` - announced
+ * * `retired` - retired
+ */
+export type ScoutDeprecationPhaseEnumApi =
+ (typeof ScoutDeprecationPhaseEnumApi)[keyof typeof ScoutDeprecationPhaseEnumApi]
+
+export const ScoutDeprecationPhaseEnumApi = {
+ Announced: 'announced',
+ Retired: 'retired',
+} as const
+
+/**
+ * What PostHog has said about retiring this scout, for the chip and the banner to render.
+ */
+export interface ScoutDeprecationApi {
+ /** How far the retirement has got: `announced` while the scout still runs, `retired` once its sunset has passed. A retired scout is paused and does not run again.
+ *
+ * * `announced` - announced
+ * * `retired` - retired */
+ phase: ScoutDeprecationPhaseEnumApi
+ /** Why PostHog is retiring the scout, written to be shown to a person as-is. */
+ reason: string
+ /** Skill name of the scout that takes over, or blank when nothing replaces it. */
+ superseded_by: string
+ /**
+ * When the scout stops running. Null means the next fleet reconcile retires it.
+ * @nullable
+ */
+ sunset_at: string | null
+}
+
/**
* * `active` - Active
* * `pending_pause` - Pending pause
@@ -1968,6 +2000,7 @@ export const SignalScoutConfigStatusEnumApi = {
* * `no_output` - No output
* * `ignored` - Ignored
* * `repeated_failures` - Repeated failures
+ * * `retired` - Retired
*/
export type SignalScoutConfigPauseReasonEnumApi =
(typeof SignalScoutConfigPauseReasonEnumApi)[keyof typeof SignalScoutConfigPauseReasonEnumApi]
@@ -1976,6 +2009,7 @@ export const SignalScoutConfigPauseReasonEnumApi = {
NoOutput: 'no_output',
Ignored: 'ignored',
RepeatedFailures: 'repeated_failures',
+ Retired: 'retired',
} as const
/**
@@ -2005,6 +2039,8 @@ export interface SignalScoutConfigApi {
readonly scout_origin: ScoutOriginEnumApi
/** What this scout is to the harness: `specialist` for one that watches a product surface, or `operational` for one PostHog ships to watch the self-driving system itself. An operational scout is exempt from the inactivity sweep and from the enabled-scout cap, and is not a scout a project should delete. Always `specialist` for a custom scout. */
readonly scout_role: ScoutRoleEnumApi
+ /** Set when PostHog is retiring this scout, and null otherwise. Carries the phase, the reason to show, what replaces the scout, and when it stops running. Only a canonical scout the project has not edited is ever marked: a project's own copy keeps running and reads as null. */
+ readonly deprecation: ScoutDeprecationApi | null
/** Who answers for this scout, seed-creator first. Ownership is recorded on the scout's skill rather than on this config, so editing the skill or toggling the scout leaves it unchanged. Reports the scout files suggest these people as reviewers. Prefer this over `created_by`-style fields, which only say who last flipped a switch. Empty when nobody owns the scout, when the owners are no longer members with access to the project, or when the caller is a scout sandbox token: owners are member PII, and a scout reads them through the skill API instead. */
readonly owners: readonly UserBasicApi[]
/** Whether this scout runs on its schedule. Disabled scouts are skipped by the coordinator. Derived from `status`: true for `active` and `pending_pause`, false for the paused statuses. */
@@ -2020,7 +2056,8 @@ export interface SignalScoutConfigApi {
*
* * `no_output` - No output
* * `ignored` - Ignored
- * * `repeated_failures` - Repeated failures */
+ * * `repeated_failures` - Repeated failures
+ * * `retired` - Retired */
readonly pause_reason: SignalScoutConfigPauseReasonEnumApi | null
/** Whether the scout writes findings to the inbox. False = dry-run: it runs and logs but emits nothing. */
readonly emit: boolean
diff --git a/products/signals/backend/migrations/0151_scout_config_retired_pause_reason.py b/products/signals/backend/migrations/0151_scout_config_retired_pause_reason.py
new file mode 100644
index 000000000000..90895e4315fd
--- /dev/null
+++ b/products/signals/backend/migrations/0151_scout_config_retired_pause_reason.py
@@ -0,0 +1,27 @@
+# Generated by Django 5.2.17 on 2026-09-22 13:48
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("signals", "0150_signalreportsuggestedreviewer"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="signalscoutconfig",
+ name="pause_reason",
+ field=models.CharField(
+ blank=True,
+ choices=[
+ ("no_output", "No output"),
+ ("ignored", "Ignored"),
+ ("repeated_failures", "Repeated failures"),
+ ("retired", "Retired"),
+ ],
+ max_length=20,
+ null=True,
+ ),
+ ),
+ ]
diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txt
index 4884601e9875..ba5b91931485 100644
--- a/products/signals/backend/migrations/max_migration.txt
+++ b/products/signals/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0150_signalreportsuggestedreviewer
+0151_scout_config_retired_pause_reason
diff --git a/products/signals/backend/models.py b/products/signals/backend/models.py
index 185597fdd739..520c020702e6 100644
--- a/products/signals/backend/models.py
+++ b/products/signals/backend/models.py
@@ -2151,6 +2151,12 @@ class SignalScoutConfig(ModelActivityMixin, TeamScopedRootMixin, UUIDModel):
NO_OUTPUT = "no_output", "No output"
IGNORED = "ignored", "Ignored"
REPEATED_FAILURES = "repeated_failures", "Repeated failures"
+ # PostHog retired the scout this config runs: its canonical skill declared a sunset that
+ # has passed, or it left the fleet on disk altogether. Owned by the retirement pass
+ # (`scout_harness/deprecation.py`) alone, so no other system writer resumes a scout that
+ # no longer exists, and the roster has a state to render instead of a row that looks
+ # healthy and never runs.
+ RETIRED = "retired", "Retired"
class NetworkAccess(models.TextChoices):
"""What the scout's sandbox can reach over the network during a run.
diff --git a/products/signals/backend/report_check_agent.py b/products/signals/backend/report_check_agent.py
index ba74d7b4f9e0..d7501b6857be 100644
--- a/products/signals/backend/report_check_agent.py
+++ b/products/signals/backend/report_check_agent.py
@@ -78,8 +78,37 @@ class CheckDispatchRefusal:
retryable: bool
-def resolve_check_skill_name(config: AgentCheckConfig) -> str:
- return config.skill_name or FALLBACK_CHECK_SKILL_NAME
+def resolve_check_skill_name(config: AgentCheckConfig, canonical_team_id: int | None = None) -> str:
+ """Which scout answers this check: the lane its author named, or the fleet's fallback scout.
+
+ Pass `canonical_team_id` to also fall back when the named lane cannot run on that project at
+ all — the scout was retired, held back, or has no live skill row. Without it the check is
+ dispatched at a lane that no longer exists, refused as `skill_withheld` or `scout_missing`, and
+ lands on the report as an errored check result: a reader is told their follow-up failed when
+ what actually happened is that PostHog stopped shipping the scout. The fallback scout re-
+ measures resolved reports for a living, so it is the right lane for a question whose original
+ one is gone.
+
+ A pause is deliberately not one of those reasons. Somebody switched that scout off on purpose,
+ and reporting the refusal is more honest than quietly running the question somewhere else.
+ """
+ skill_name = config.skill_name or FALLBACK_CHECK_SKILL_NAME
+ if canonical_team_id is None or skill_name == FALLBACK_CHECK_SKILL_NAME:
+ return skill_name
+ return skill_name if _lane_still_exists(canonical_team_id, skill_name) else FALLBACK_CHECK_SKILL_NAME
+
+
+def _lane_still_exists(canonical_team_id: int, skill_name: str) -> bool:
+ """Whether this project still has a scout of this name that PostHog has not retired."""
+ if skill_name in withheld_skills_for_team(canonical_team_id):
+ return False
+ if not LLMSkill.objects.filter(team_id=canonical_team_id, name=skill_name, is_latest=True, deleted=False).exists():
+ return False
+ return not SignalScoutConfig.all_teams.filter(
+ team_id=canonical_team_id,
+ skill_name=skill_name,
+ pause_reason=SignalScoutConfig.PauseReason.RETIRED,
+ ).exists()
def _latest_resolution_note(report: SignalReport) -> str | None:
@@ -276,11 +305,11 @@ def run_agent_check(check: SignalReportCheck, *, now: datetime | None = None) ->
)
return "errored"
- skill_name = resolve_check_skill_name(config)
# The scout fleet is bound to the canonical project, while the check sits on its report's own
# environment team, so every gate and the dispatch itself resolve the parent.
report_team = check.report.team
canonical_team_id = report_team.parent_team_id or report_team.id
+ skill_name = resolve_check_skill_name(config, canonical_team_id)
try:
refusal = _refuse_dispatch(skill_name, canonical_team_id)
diff --git a/products/signals/backend/scout_harness/AGENTS.md b/products/signals/backend/scout_harness/AGENTS.md
index 9d085a777d4d..04a8bea78fe5 100644
--- a/products/signals/backend/scout_harness/AGENTS.md
+++ b/products/signals/backend/scout_harness/AGENTS.md
@@ -22,9 +22,14 @@ In production it is driven by `SignalsScoutCoordinatorWorkflow` (periodic tick e
`resolve_skill_owner_user_uuids` exposes the owner set (seed-creator first) to the report tools' reviewer provenance stamp (`is_skill_owner`). Author resolution is opt-in via `load_skill_for_run(..., include_authors=True)` — only the runner's prompt-building path pays for it; the report-authorization gate in `views.py` loads the skill per report write just to check `allowed_tools` and skips it.
- `lazy_seed.py`
Canonical skill sync. Reads `products/signals/skills/signals-scout-*/` from disk and reconciles them against the team's `LLMSkill` rows: creates missing rows, updates ones the team hasn't edited, leaves diverged / hand-authored rows alone, tombstones rows whose canonical skill was deleted. Only rows tagged `metadata.seeded_by="signals_scout_harness"` are ever updated. Called both lazily (coordinator tick, runner cold-start) and explicitly via the `sync_signals_scout_skills` management command.
- It also parses the three config-shaping frontmatter keys, none of which enters the content hash (all belong to the config, not the skill row): `scout-tags` (`canonical_config_tags_for`), `scout-role` (`is_operational_scout`), and `scout-display-name` (`canonical_display_name_for`). `scout-display-name` is the label the scout ships under, and every canonical scout states one, because the clients' fallback sentence-cases the slug and turns `signals-scout-apm` into "Apm". `scout-role: operational` marks a scout that watches the self-driving system itself rather than a product surface — the fleet's follow-up validation scout — and an unknown value fails the parse rather than falling back, since a silently downgraded operational scout is the silencing the role exists to prevent.
+ It also parses the retirement marker (`canonical_deprecation_for`, see `deprecation.py`) and the three config-shaping frontmatter keys, none of which enters the content hash (all belong to the config, not the skill row): `scout-tags` (`canonical_config_tags_for`), `scout-role` (`is_operational_scout`), and `scout-display-name` (`canonical_display_name_for`). `scout-display-name` is the label the scout ships under, and every canonical scout states one, because the clients' fallback sentence-cases the slug and turns `signals-scout-apm` into "Apm". `scout-role: operational` marks a scout that watches the self-driving system itself rather than a product surface — the fleet's follow-up validation scout — and an unknown value fails the parse rather than falling back, since a silently downgraded operational scout is the silencing the role exists to prevent.
+- `deprecation.py`
+ The retirement lifecycle of a canonical scout: the `scout-status` / `scout-deprecation` frontmatter marker (`parse_scout_deprecation`), the shape it is stored in on `LLMSkill.metadata` (`DEPRECATION_METADATA_KEY`), and `retire_scout_configs`, which moves a project's config to `status=paused_by_system`, `pause_reason=retired` through `transition_status_by_system`.
+ `retired` is its own writer, so nothing else resumes a retired scout, and the transition obeys the same ownership rule every system writer does: a pause a person made stands, and so does a tripped failure breaker's.
+ The pass runs from `sync_canonical_skills(prune=True)` on two triggers — a sunset that has passed, and a skill the prune just reaped — so a scout deleted from disk without an announcement leaves no config enabled behind a skill that is gone, which is the ghost row this exists to prevent.
+ Only a row the sync owns and the project never edited is ever marked or retired, so a fork keeps running.
- `fleet_sync.py`
- `materialize_scout_fleet(team, surface=...)` — the on-demand `configs/sync/` path, and the only place that records what a materialization did. Resolves the seed posture + holdback from one flag read, runs `sync_canonical_skills(prune=True)` and `register_missing_configs`, then captures `signals_scout_fleet_synced` with the per-bucket counts the `SyncResult` carries (created / updated / diverged / tombstoned / pruned), the configs it registered, the fleet it left behind, whether the project had one before (`was_empty` — the rescue metric), the `surface` the caller declared, and how long the pass took. Every sync captures, zero counts included: a no-op sync is the denominator for "how often does opening the tab find work to do". Best-effort, like every other scout event.
+ `materialize_scout_fleet(team, surface=...)` — the on-demand `configs/sync/` path, and the only place that records what a materialization did. Resolves the seed posture + holdback from one flag read, runs `sync_canonical_skills(prune=True)` and `register_missing_configs`, then captures `signals_scout_fleet_synced` with the per-bucket counts the `SyncResult` carries (created / updated / diverged / tombstoned / pruned / retired configs), the configs it registered, the fleet it left behind, whether the project had one before (`was_empty` — the rescue metric), the `surface` the caller declared, and how long the pass took. Every sync captures, zero counts included: a no-op sync is the denominator for "how often does opening the tab find work to do". Best-effort, like every other scout event.
It also carries the mass-prune tripwire. A reap that takes more than half the canonical fleet, and at least `MASS_PRUNE_FLOOR` scouts, is not a retirement — it means the sync read a fleet the deploy did not ship — so it stamps `unexpected_prune` on the event and captures `UnexpectedScoutFleetPrune` into error tracking. A detector, not a guard: by the time the count exists the rows are tombstoned.
- `config_registry.py`
`register_missing_configs(team_id)` — auto-creates an enabled, default-schedule `SignalScoutConfig` for any `signals-scout-*` skill lacking one ("author a skill, get a scout"). Called by the coordinator tick; the HTTP surface registers explicitly via the write-scoped config `create` endpoint instead (reads stay side-effect free). A canonical scout's `scout-tags` frontmatter (read through `lazy_seed.canonical_config_tags_for`) is stamped on the row it creates, which is how a product surface claims its scouts by tag instead of by hardcoded skill name — AI observability's self-driving tab lists the `ai-observability`-tagged configs. Forward-only like the rest of the seed posture: adding the key to an already-seeded scout leaves that team's existing config untagged until someone tags it through the config API.
diff --git a/products/signals/backend/scout_harness/config_registry.py b/products/signals/backend/scout_harness/config_registry.py
index 38a5e211da44..63471d5a82b5 100644
--- a/products/signals/backend/scout_harness/config_registry.py
+++ b/products/signals/backend/scout_harness/config_registry.py
@@ -30,6 +30,7 @@ from products.signals.backend.scout_harness.lazy_seed import (
HARNESS_SEEDED_BY,
SCOUT_SKILL_CATEGORY,
canonical_config_tags_for,
+ canonical_deprecation_for,
canonical_display_name_for,
canonical_skill_names,
is_operational_scout,
@@ -226,6 +227,10 @@ def register_missing_configs(
(count + create, no lock) — a race can briefly overshoot by one, which the coordinator's
per-tick caps still bound.
+ A canonical scout PostHog is retiring (`scout-deprecation` frontmatter) gets no new config
+ here, so the retirement stops intake before it stops runs. An existing config is untouched and
+ keeps its schedule until `sync_canonical_skills` retires it at the sunset.
+
A canonical scout declaring `scout-role: operational` (`lazy_seed.is_operational_scout`) is
outside all of that: it watches the self-driving system rather than a product surface, so it
seeds enabled, exempt from the inactivity sweep, past the allowlist and past the cap, and
@@ -263,9 +268,16 @@ def register_missing_configs(
# sharing an operational name must not inherit the posture that skips the harness's gates.
operational_names = {name for name in canonical_names if is_operational_scout(name)}
+ # A scout PostHog has announced the retirement of is no longer offered: no new project picks
+ # one up, and a project that never had it does not acquire a row it would only have to retire.
+ # Read off the canonical set like the role is, so a team's own scout sharing the name is
+ # unaffected. Dispatch is untouched — a project already running the scout keeps running it
+ # until the sunset, which is the whole point of announcing one.
+ deprecated_names = {name for name in canonical_names if canonical_deprecation_for(name) is not None}
+
configs = SignalScoutConfig.objects.for_team(team_id)
existing = set(configs.values_list("skill_name", flat=True))
- missing = sorted(skill_names - existing)
+ missing = sorted(skill_names - existing - deprecated_names)
enabled = enabled_scout_count(team_id) if missing else 0
for name in missing:
at_cap = enabled >= MAX_ENABLED_SCOUTS_PER_TEAM
diff --git a/products/signals/backend/scout_harness/deprecation.py b/products/signals/backend/scout_harness/deprecation.py
new file mode 100644
index 000000000000..b5d1cf593c73
--- /dev/null
+++ b/products/signals/backend/scout_harness/deprecation.py
@@ -0,0 +1,212 @@
+"""The retirement lifecycle of a canonical scout: the marker on disk, and the pause it drives.
+
+Retiring a `signals-scout-*` scout used to mean one of two things that were built for something
+else. The `withheld_skills` denylist hides an unreleased scout, so using it for a retirement makes
+a scout teams already run disappear with no reason shown. Deleting the skill directory tombstones
+the `LLMSkill` row and leaves the `SignalScoutConfig` enabled behind it, so the roster keeps a row
+that looks healthy and can never run.
+
+So a retirement is a state instead. A canonical SKILL.md declares `scout-status: deprecated` with
+a `scout-deprecation` block, the sync copies that marker into every team's skill row metadata, and
+once the sunset passes the team's config moves to a `retired` pause like any other system
+transition: activity-logged, visible in the roster, and owned by a reason no other writer can
+clear. `retire_scout_configs` is also what the prune pass calls, so a scout deleted from disk
+without a marker leaves no ghost either.
+"""
+
+from __future__ import annotations
+
+from collections.abc import Collection
+from dataclasses import dataclass
+from datetime import UTC, date, datetime
+from pathlib import Path
+
+from django.utils import timezone
+
+import structlog
+
+from posthog.models.activity_logging.activity_log import Trigger
+from posthog.models.activity_logging.model_activity import ActivityTriggerContext
+
+from products.signals.backend.models import SignalScoutConfig
+
+logger = structlog.get_logger(__name__)
+
+# Frontmatter keys a canonical scout declares its retirement with.
+SCOUT_STATUS_KEY = "scout-status"
+SCOUT_DEPRECATION_KEY = "scout-deprecation"
+
+SCOUT_STATUS_ACTIVE = "active"
+SCOUT_STATUS_DEPRECATED = "deprecated"
+
+# `LLMSkill.metadata` key the sync copies the marker into, so every per-team surface reads the
+# retirement without a disk read.
+DEPRECATION_METADATA_KEY = "deprecation"
+
+# Cap on the author-written sentence a banner shows. Generous enough for a reason plus what
+# replaces the scout, tight enough that the marker stays a marker rather than a document.
+MAX_DEPRECATION_REASON_LENGTH = 500
+
+_RETIREMENT_JOB_TYPE = "signals_scout_retirement"
+
+
+class ScoutDeprecationParseError(ValueError):
+ """A canonical SKILL.md declares a retirement the harness cannot act on."""
+
+
+@dataclass(frozen=True)
+class ScoutDeprecation:
+ """PostHog is retiring this canonical scout, and what a person should be told about it.
+
+ `reason` is the sentence every surface shows, so it is required: a retirement a person cannot
+ read the reason for is the failure this lifecycle exists to fix. `superseded_by` names the
+ scout that takes over, when one does. `sunset_at` is when the scout stops running; absent
+ means the next reconcile retires it, so a marker is never half-applied.
+ """
+
+ reason: str
+ superseded_by: str = ""
+ sunset_at: datetime | None = None
+
+ def is_past_sunset(self, now: datetime) -> bool:
+ return self.sunset_at is None or self.sunset_at <= now
+
+ def as_metadata(self) -> dict[str, str | None]:
+ """The marker as it is stored on `LLMSkill.metadata`, and read back by every surface."""
+ return {
+ "reason": self.reason,
+ "superseded_by": self.superseded_by,
+ "sunset_at": self.sunset_at.isoformat() if self.sunset_at else None,
+ }
+
+
+def _parse_sunset_at(raw: object, skill_file: Path) -> datetime | None:
+ """Read the sunset instant from frontmatter, accepting a bare date as midnight UTC.
+
+ YAML resolves `2026-10-01` to a `date` and `2026-10-01T00:00:00Z` to an aware `datetime`, and
+ an author writes whichever reads better. A naive datetime is read as UTC rather than rejected,
+ because a sunset is a fleet-wide moment and the fleet runs on UTC.
+ """
+ if raw is None:
+ return None
+ if isinstance(raw, datetime):
+ return raw if timezone.is_aware(raw) else raw.replace(tzinfo=UTC)
+ if isinstance(raw, date):
+ return datetime(raw.year, raw.month, raw.day, tzinfo=UTC)
+ if isinstance(raw, str):
+ try:
+ parsed = datetime.fromisoformat(raw)
+ except ValueError as error:
+ raise ScoutDeprecationParseError(
+ f"SKILL.md frontmatter '{SCOUT_DEPRECATION_KEY}.sunset_at' is not an ISO-8601 date: {skill_file}"
+ ) from error
+ return parsed if timezone.is_aware(parsed) else parsed.replace(tzinfo=UTC)
+ raise ScoutDeprecationParseError(
+ f"SKILL.md frontmatter '{SCOUT_DEPRECATION_KEY}.sunset_at' must be a date or datetime: {skill_file}"
+ )
+
+
+def parse_scout_deprecation(frontmatter: dict, skill_file: Path, *, is_scout: bool) -> ScoutDeprecation | None:
+ """Read the optional retirement marker, or None when the scout is not being retired.
+
+ The two keys are required to agree. A `scout-deprecation` block without
+ `scout-status: deprecated` is a marker nobody meant to apply yet, and `scout-status:
+ deprecated` without a block is a retirement with no reason to show — both fail the parse
+ rather than resolving to a half-state the fleet would act on.
+
+ Only a scout can be retired this way, so the keys are rejected on a companion skill.
+ """
+ raw_status = frontmatter.get(SCOUT_STATUS_KEY)
+ raw_deprecation = frontmatter.get(SCOUT_DEPRECATION_KEY)
+ if raw_status is None and raw_deprecation is None:
+ return None
+ if not is_scout:
+ raise ScoutDeprecationParseError(
+ f"Only a signals-scout-* skill may declare '{SCOUT_STATUS_KEY}' or '{SCOUT_DEPRECATION_KEY}': {skill_file}"
+ )
+ if raw_status is not None and raw_status not in (SCOUT_STATUS_ACTIVE, SCOUT_STATUS_DEPRECATED):
+ raise ScoutDeprecationParseError(
+ f"SKILL.md frontmatter '{SCOUT_STATUS_KEY}' must be '{SCOUT_STATUS_ACTIVE}' or "
+ f"'{SCOUT_STATUS_DEPRECATED}': got {raw_status!r} in {skill_file}"
+ )
+ if raw_status != SCOUT_STATUS_DEPRECATED:
+ if raw_deprecation is not None:
+ raise ScoutDeprecationParseError(
+ f"SKILL.md frontmatter has '{SCOUT_DEPRECATION_KEY}' without "
+ f"'{SCOUT_STATUS_KEY}: {SCOUT_STATUS_DEPRECATED}': {skill_file}"
+ )
+ return None
+ if not isinstance(raw_deprecation, dict):
+ raise ScoutDeprecationParseError(
+ f"A deprecated scout must declare a '{SCOUT_DEPRECATION_KEY}' mapping with a reason: {skill_file}"
+ )
+ unknown = set(raw_deprecation) - {"reason", "superseded_by", "sunset_at"}
+ if unknown:
+ raise ScoutDeprecationParseError(
+ f"SKILL.md frontmatter '{SCOUT_DEPRECATION_KEY}' has unknown keys {sorted(unknown)}: {skill_file}"
+ )
+ raw_reason = raw_deprecation.get("reason")
+ if not isinstance(raw_reason, str) or not (reason := raw_reason.strip()):
+ raise ScoutDeprecationParseError(
+ f"SKILL.md frontmatter '{SCOUT_DEPRECATION_KEY}.reason' must be a non-empty string: {skill_file}"
+ )
+ if len(reason) > MAX_DEPRECATION_REASON_LENGTH:
+ raise ScoutDeprecationParseError(
+ f"SKILL.md frontmatter '{SCOUT_DEPRECATION_KEY}.reason' exceeds the "
+ f"{MAX_DEPRECATION_REASON_LENGTH} character limit: {skill_file}"
+ )
+ raw_superseded_by = raw_deprecation.get("superseded_by")
+ if raw_superseded_by is not None and not isinstance(raw_superseded_by, str):
+ raise ScoutDeprecationParseError(
+ f"SKILL.md frontmatter '{SCOUT_DEPRECATION_KEY}.superseded_by' must be a string: {skill_file}"
+ )
+ return ScoutDeprecation(
+ reason=reason,
+ superseded_by=(raw_superseded_by or "").strip(),
+ sunset_at=_parse_sunset_at(raw_deprecation.get("sunset_at"), skill_file),
+ )
+
+
+def deprecation_metadata_of(metadata: dict | None) -> dict | None:
+ """The retirement marker stored on a team's skill row, if the sync ever wrote one."""
+ stored = (metadata or {}).get(DEPRECATION_METADATA_KEY)
+ return stored if isinstance(stored, dict) else None
+
+
+def retire_scout_configs(team_id: int, skill_names: Collection[str]) -> tuple[str, ...]:
+ """Move each still-running config for these scouts to a retired pause, and say which moved.
+
+ The transition goes through `transition_status_by_system` under `PauseReason.RETIRED`, so it
+ obeys the same ownership rule every system writer does: a pause a person made stands, and a
+ pause another writer owns (a tripped failure breaker) is left as it is — neither is a scout
+ that runs, so neither is the ghost this pass exists to prevent. Nothing but this writer can
+ clear a retired pause afterwards.
+
+ Idempotent: a config already retired is not runnable, so a later pass skips it.
+ """
+ names = list(set(skill_names))
+ if not names:
+ return ()
+ retired: list[str] = []
+ configs = SignalScoutConfig.objects.for_team(team_id).filter(
+ skill_name__in=names, status__in=SignalScoutConfig.RUNNABLE_STATUSES
+ )
+ for config in configs:
+ trigger = Trigger(
+ job_type=_RETIREMENT_JOB_TYPE,
+ job_id=str(config.id),
+ payload={"skill_name": config.skill_name},
+ )
+ with ActivityTriggerContext(trigger):
+ moved = config.transition_status_by_system(
+ SignalScoutConfig.Status.PAUSED_BY_SYSTEM,
+ pause_reason=SignalScoutConfig.PauseReason.RETIRED,
+ )
+ if moved:
+ retired.append(config.skill_name)
+ logger.info(
+ "signals_scout: retired a scout PostHog no longer ships",
+ team_id=team_id,
+ skill_name=config.skill_name,
+ )
+ return tuple(sorted(retired))
diff --git a/products/signals/backend/scout_harness/fleet_sync.py b/products/signals/backend/scout_harness/fleet_sync.py
index b200e0c6e489..9a99b533d417 100644
--- a/products/signals/backend/scout_harness/fleet_sync.py
+++ b/products/signals/backend/scout_harness/fleet_sync.py
@@ -64,8 +64,9 @@ def materialize_scout_fleet(team: Team, *, surface: str | None = None) -> set[st
`prune=True` puts this on the same terms as the coordinator tick: a scout retired from
`products/signals/skills/` is tombstoned on the team instead of lingering as a live row the
- fleet UI keeps listing. The reap only touches rows the harness seeded and the team never
- edited, so a hand-authored or forked scout of the same name survives it.
+ fleet UI keeps listing, and its config is retired with it rather than left enabled behind a
+ skill that is gone. The reap only touches rows the harness seeded and the team never edited,
+ so a hand-authored or forked scout of the same name survives it.
"""
# Timed from the first read, not from the reconcile: `duration_ms` is what a cold project
# waits with its roster under a skeleton, and the flag read is part of that wait.
@@ -135,6 +136,10 @@ def _capture_fleet_synced(
"diverged_count": len(result.diverged_skill_names),
"tombstoned_count": len(result.tombstoned_skill_names),
"pruned_count": pruned_count,
+ # Configs this pass moved to a retired pause. The measure of the ghost-row
+ # problem: before the lifecycle every prune left its config enabled with no
+ # skill behind it, so a non-zero prune with a zero retire count is a regression.
+ "retired_count": len(result.retired_config_skill_names),
"configs_registered_count": len(configs_after - configs_before),
"withheld_count": withheld_count,
"fleet_size": len(configs_after),
diff --git a/products/signals/backend/scout_harness/lazy_seed.py b/products/signals/backend/scout_harness/lazy_seed.py
index a21fe9ec9056..ec50400812e8 100644
--- a/products/signals/backend/scout_harness/lazy_seed.py
+++ b/products/signals/backend/scout_harness/lazy_seed.py
@@ -17,6 +17,14 @@ import yaml
from posthog.models.team.team import Team
from products.signals.backend.models import SignalScoutConfig
+from products.signals.backend.scout_harness.deprecation import (
+ DEPRECATION_METADATA_KEY,
+ ScoutDeprecation,
+ ScoutDeprecationParseError,
+ deprecation_metadata_of,
+ parse_scout_deprecation,
+ retire_scout_configs,
+)
from products.signals.backend.scout_harness.skill_loader import SIGNALS_SCOUT_SKILL_PREFIX
from products.signals.backend.scout_harness.tags import slugify_tag
from products.skills.backend.models.skills import LLMSkill, LLMSkillFile
@@ -110,7 +118,8 @@ class CanonicalSkill:
the scout's `SignalScoutConfig` when that row is first created. `role` is the optional
`scout-role` frontmatter value — what the harness is allowed to do to the scout.
`display_name` is the optional `scout-display-name` frontmatter value, the label the fleet
- ships the scout under.
+ ships the scout under. `deprecation` is the optional retirement marker from `scout-status` /
+ `scout-deprecation`, set only on a scout PostHog is retiring.
"""
name: str
@@ -122,6 +131,7 @@ class CanonicalSkill:
config_tags: tuple[str, ...] = ()
role: ScoutRole = SCOUT_ROLE_SPECIALIST
display_name: str = ""
+ deprecation: ScoutDeprecation | None = None
@dataclass(frozen=True)
@@ -147,6 +157,11 @@ class SyncResult:
A skill name appears in at most one tuple per call. `skipped_reason` is set when no per-skill
work was even attempted (e.g. the canonical dir is missing on disk in tests).
+
+ `retired_config_skill_names` is the one bucket that names configs rather than skill rows, and
+ a name may appear in it alongside `pruned_skill_names`: it lists the scouts whose
+ `SignalScoutConfig` this pass moved to a retired pause, so a scout that left the fleet leaves
+ no row that looks healthy and never runs.
"""
created_skill_names: tuple[str, ...] = ()
@@ -154,6 +169,7 @@ class SyncResult:
diverged_skill_names: tuple[str, ...] = ()
tombstoned_skill_names: tuple[str, ...] = ()
pruned_skill_names: tuple[str, ...] = ()
+ retired_config_skill_names: tuple[str, ...] = ()
skipped_reason: str | None = None
@@ -325,6 +341,12 @@ def _parse_canonical_skill(skill_dir: Path, *, is_scout: bool = True) -> Canonic
config_tags = _parse_config_tags(frontmatter, skill_file, is_scout=is_scout)
role = _parse_scout_role(frontmatter, skill_file, is_scout=is_scout)
display_name = _parse_display_name(frontmatter, skill_file, is_scout=is_scout)
+ # A malformed marker is raised as a parse error like every other frontmatter fault, so the
+ # callers that degrade to an empty fleet keep one failure mode rather than two.
+ try:
+ deprecation = parse_scout_deprecation(frontmatter, skill_file, is_scout=is_scout)
+ except ScoutDeprecationParseError as error:
+ raise CanonicalSkillParseError(str(error)) from error
body = raw[match.end() :]
if len(body.encode("utf-8")) > _MAX_SKILL_BODY_BYTES:
@@ -372,6 +394,7 @@ def _parse_canonical_skill(skill_dir: Path, *, is_scout: bool = True) -> Canonic
config_tags=config_tags,
role=role,
display_name=display_name,
+ deprecation=deprecation,
)
@@ -494,6 +517,31 @@ def canonical_display_name_for(skill_name: str) -> str:
return _canonical_display_names().get(skill_name, "")
+@lru_cache(maxsize=1)
+def _canonical_deprecations() -> dict[str, ScoutDeprecation]:
+ """The retirement marker per canonical scout name, for the scouts PostHog is retiring.
+
+ Cached for the process like `canonical_skill_names` — the shipped fleet only changes on
+ deploy — and degrades to empty on a malformed canonical, which leaves every scout reading as
+ active rather than failing config registration.
+ """
+ try:
+ return {skill.name: skill.deprecation for skill in discover_canonical_skills() if skill.deprecation}
+ except CanonicalSkillParseError:
+ logger.warning("canonical_deprecations: malformed canonical skill on disk; reading no retirements")
+ return {}
+
+
+def canonical_deprecation_for(skill_name: str) -> ScoutDeprecation | None:
+ """The retirement PostHog announced for the canonical scout of this name, if any.
+
+ None for a custom scout, and for a canonical scout still in the fleet. Callers must confirm
+ the name is canonical first — a team's own `signals-scout-*` skill can share a canonical name,
+ and it inherits nothing from disk, least of all a retirement of somebody else's scout.
+ """
+ return _canonical_deprecations().get(skill_name)
+
+
@lru_cache(maxsize=1)
def _canonical_operational_scouts() -> frozenset[str]:
"""Names of the canonical scouts that declare `scout-role: operational`.
@@ -519,6 +567,24 @@ def is_operational_scout(skill_name: str) -> bool:
return skill_name in _canonical_operational_scouts()
+def reset_canonical_caches() -> None:
+ """Drop every process cache over the canonical fleet on disk.
+
+ The caches assume the fleet only changes on deploy, which holds in production and not in a
+ test that writes a fleet to a temporary directory or patches `discover_canonical_skills`: one
+ such test leaves the next reading a fleet that is not there. Kept here rather than in the
+ tests so a new cache is added to the list in the same edit that adds the cache.
+ """
+ for cache in (
+ canonical_skill_names,
+ _canonical_config_tags,
+ _canonical_display_names,
+ _canonical_operational_scouts,
+ _canonical_deprecations,
+ ):
+ cache.cache_clear()
+
+
def scout_skill_origin(skill_name: str, metadata: dict | None) -> Literal["canonical", "custom"]:
"""Classify a scout skill row as `"canonical"` or `"custom"` by who owns it.
@@ -615,6 +681,44 @@ def scout_skill_row_is_proven_canonical(skill: LLMSkill) -> bool:
return scout_skill_row_origin(skill) == "canonical" and (skill.metadata or {}).get("canonical_hash") is not None
+def _seed_metadata(canonical: CanonicalSkill, canonical_hash: str) -> dict:
+ """The harness-owned `LLMSkill.metadata` keys, as this canonical revision defines them.
+
+ The retirement marker rides here rather than in the content hash on purpose: a hash change
+ would bump the skill version on every team and read as a content edit, when what changed is
+ what PostHog says about the scout. `_reconcile_deprecation_metadata` is what carries a
+ marker-only change to rows whose content is already current.
+ """
+ return {
+ "seeded_by": HARNESS_SEEDED_BY,
+ "source": "products/signals/skills",
+ "canonical_hash": canonical_hash,
+ DEPRECATION_METADATA_KEY: canonical.deprecation.as_metadata() if canonical.deprecation else None,
+ }
+
+
+def _reconcile_deprecation_metadata(live: LLMSkill, canonical: CanonicalSkill) -> bool:
+ """Carry a marker-only frontmatter change onto a live row, and say whether it wrote.
+
+ Deprecating a scout changes no skill content, so the content hashes match and the update path
+ never fires — without this pass the marker would reach a team only on the scout's next real
+ edit. Written through `update()` rather than a version bump, because announcing a retirement
+ is not an edit to the skill anybody made. `updated_at` still moves: the marketplace plugin
+ version is `Max(updated_at)` over the team's rows, so a cached repo would otherwise keep
+ serving the row without its marker.
+
+ Caller must already have established that the sync owns this row and the team has not edited
+ it, which is what keeps a fork's marker its own.
+ """
+ desired = canonical.deprecation.as_metadata() if canonical.deprecation else None
+ if deprecation_metadata_of(live.metadata) == desired:
+ return False
+ metadata = dict(live.metadata or {})
+ metadata[DEPRECATION_METADATA_KEY] = desired
+ LLMSkill.objects.filter(pk=live.pk).update(metadata=metadata, updated_at=timezone.now())
+ return True
+
+
def _create_skill_from_canonical(team: Team, canonical: CanonicalSkill, canonical_hash: str) -> None:
"""Insert a brand-new row for a (team, canonical.name) that has no prior history.
@@ -630,11 +734,7 @@ def _create_skill_from_canonical(team: Team, canonical: CanonicalSkill, canonica
description=canonical.description,
body=canonical.body,
allowed_tools=list(canonical.allowed_tools),
- metadata={
- "seeded_by": HARNESS_SEEDED_BY,
- "source": "products/signals/skills",
- "canonical_hash": canonical_hash,
- },
+ metadata=_seed_metadata(canonical, canonical_hash),
category=SCOUT_SKILL_CATEGORY,
version=1,
is_latest=True,
@@ -676,9 +776,7 @@ def _update_skill_from_canonical(
locked.save(update_fields=["is_latest", "updated_at"])
new_metadata = dict(locked.metadata or {})
- new_metadata["seeded_by"] = HARNESS_SEEDED_BY
- new_metadata["source"] = "products/signals/skills"
- new_metadata["canonical_hash"] = canonical_hash
+ new_metadata.update(_seed_metadata(canonical, canonical_hash))
new_skill = LLMSkill.objects.create(
team=team,
@@ -731,6 +829,12 @@ def sync_canonical_skills(
don't rewrite skill history on a flag flip. Withheld skills are still on disk, so the `prune`
pass never reaps them as orphans.
+ `prune` also drives the retirement half of the lifecycle, for the same reason: both are
+ reconciliations a deliberate caller asks for. A canonical scout whose `scout-deprecation`
+ sunset has passed has this team's config moved to a retired pause, and so does a scout the
+ prune just reaped, so a retirement that skipped the announcement leaves no ghost either. A row
+ the team edited is left out of both, so a fork keeps running.
+
Idempotent and safe to call on every coordinator tick — the only DB writes happen when
something actually needs to change, and IntegrityError on races is logged-and-swallowed.
"""
@@ -739,11 +843,16 @@ def sync_canonical_skills(
return SyncResult(skipped_reason="no canonical signals-scout-* skills on disk")
withheld = withheld_skill_names or frozenset()
+ now = timezone.now()
created: list[str] = []
updated: list[str] = []
diverged: list[str] = []
tombstoned: list[str] = []
pruned: list[str] = []
+ remarked: list[str] = []
+ # Scouts whose config this pass should retire: a sunset that has passed, plus whatever the
+ # prune reaps below. Collected rather than retired inline so one pass writes each config once.
+ retire_targets: set[str] = set()
for canonical in canonicals:
if canonical.name in withheld:
@@ -792,14 +901,23 @@ def sync_canonical_skills(
diverged.append(canonical.name)
continue
- if live_hash == canonical_hash:
- continue # already at the latest canonical content
-
- if live_hash != stored_hash:
+ at_latest = live_hash == canonical_hash
+ if not at_latest and live_hash != stored_hash:
# Team edited their copy since our last write → leave it alone.
diverged.append(canonical.name)
continue
+ # From here the row is ours and carries no team edit, so what disk says about the scout
+ # is this team's too. A fork never reaches this point, which is what keeps its copy
+ # running through a retirement.
+ if _reconcile_deprecation_metadata(live, canonical):
+ remarked.append(canonical.name)
+ if prune and canonical.deprecation is not None and canonical.deprecation.is_past_sunset(now):
+ retire_targets.add(canonical.name)
+
+ if at_latest:
+ continue # already at the latest canonical content
+
# Unedited since our last write but canonical changed → safe to overwrite.
try:
_update_skill_from_canonical(team, live, canonical, canonical_hash)
@@ -853,8 +971,14 @@ def sync_canonical_skills(
team=team, name=row.name, deleted=False, metadata__seeded_by=HARNESS_SEEDED_BY
).update(deleted=True, is_latest=False, updated_at=timezone.now())
pruned.append(row.name)
+ retire_targets.add(row.name)
+
+ # Finish the retirement the skill rows only started. A tombstoned skill leaves its config
+ # enabled behind it, and dispatch is gated on a live skill, so the scout silently stops while
+ # its roster row still reads as healthy — the ghost this pass exists to prevent.
+ retired_configs = retire_scout_configs(team.id, retire_targets)
- if created or updated or pruned:
+ if created or updated or pruned or remarked or retired_configs:
logger.info(
"signals_scout: synced canonical skills",
extra={
@@ -864,6 +988,8 @@ def sync_canonical_skills(
"diverged_skills": diverged,
"tombstoned_skills": tombstoned,
"pruned_skills": pruned,
+ "remarked_skills": remarked,
+ "retired_configs": list(retired_configs),
},
)
@@ -873,6 +999,7 @@ def sync_canonical_skills(
diverged_skill_names=tuple(diverged),
tombstoned_skill_names=tuple(tombstoned),
pruned_skill_names=tuple(pruned),
+ retired_config_skill_names=retired_configs,
)
diff --git a/products/signals/backend/scout_harness/serializers.py b/products/signals/backend/scout_harness/serializers.py
index 27e7f4694977..513b0b3ffd01 100644
--- a/products/signals/backend/scout_harness/serializers.py
+++ b/products/signals/backend/scout_harness/serializers.py
@@ -3141,6 +3141,34 @@ class ScoutRole(models.TextChoices):
OPERATIONAL = "operational", "operational"
+class ScoutDeprecationPhase(models.TextChoices):
+ ANNOUNCED = "announced", "announced"
+ RETIRED = "retired", "retired"
+
+
+class ScoutDeprecationSerializer(serializers.Serializer):
+ """What PostHog has said about retiring this scout, for the chip and the banner to render."""
+
+ phase = serializers.ChoiceField(
+ choices=ScoutDeprecationPhase.choices,
+ help_text=(
+ "How far the retirement has got: `announced` while the scout still runs, `retired` "
+ "once its sunset has passed. A retired scout is paused and does not run again."
+ ),
+ )
+ reason = serializers.CharField(
+ help_text="Why PostHog is retiring the scout, written to be shown to a person as-is."
+ )
+ superseded_by = serializers.CharField(
+ allow_blank=True,
+ help_text="Skill name of the scout that takes over, or blank when nothing replaces it.",
+ )
+ sunset_at = serializers.DateTimeField(
+ allow_null=True,
+ help_text="When the scout stops running. Null means the next fleet reconcile retires it.",
+ )
+
+
class SignalScoutConfigSerializer(serializers.ModelSerializer):
"""Read shape for a per-(team, skill) scout config.
@@ -3177,6 +3205,14 @@ class SignalScoutConfigSerializer(serializers.ModelSerializer):
"for a custom scout."
),
)
+ deprecation = serializers.SerializerMethodField(
+ help_text=(
+ "Set when PostHog is retiring this scout, and null otherwise. Carries the phase, the "
+ "reason to show, what replaces the scout, and when it stops running. Only a canonical "
+ "scout the project has not edited is ever marked: a project's own copy keeps running "
+ "and reads as null."
+ ),
+ )
owners = serializers.SerializerMethodField(
help_text=(
"Who answers for this scout, seed-creator first. Ownership is recorded on the scout's "
@@ -3357,6 +3393,14 @@ class SignalScoutConfigSerializer(serializers.ModelSerializer):
info = (self.context.get("skill_info") or {}).get(obj.skill_name)
return info.role if info else "specialist"
+ @extend_schema_field(ScoutDeprecationSerializer(allow_null=True))
+ def get_deprecation(self, obj: SignalScoutConfig) -> dict[str, Any] | None:
+ # Same single-query `skill_info` map as `get_description`. The marker is read off the
+ # project's own skill row rather than from disk, so a scout the project forked — whose row
+ # the sync stops writing — never reads as retiring.
+ info = (self.context.get("skill_info") or {}).get(obj.skill_name)
+ return info.deprecation if info else None
+
@extend_schema_field(UserBasicSerializer(allow_null=True))
def get_status_changed_by(self, obj: SignalScoutConfig) -> dict[str, Any] | None:
# Member PII, so it rides the same gate `owners` does: a scout sandbox token reads the
@@ -3384,6 +3428,7 @@ class SignalScoutConfigSerializer(serializers.ModelSerializer):
"display_name",
"scout_origin",
"scout_role",
+ "deprecation",
"owners",
"enabled",
"status",
diff --git a/products/signals/backend/scout_harness/tools/checks.py b/products/signals/backend/scout_harness/tools/checks.py
index 78ad242c465d..b0e4ff5d66c4 100644
--- a/products/signals/backend/scout_harness/tools/checks.py
+++ b/products/signals/backend/scout_harness/tools/checks.py
@@ -86,7 +86,9 @@ def _resolve_dispatched_check(team: Team, run: SignalScoutRun, check_id: str) ->
config = parse_check_config(check.kind, check.config)
assert isinstance(config, AgentCheckConfig)
- if resolve_check_skill_name(config) != run.skill_name:
+ # Resolved with the project, exactly as the dispatch resolved it, so a run correctly sent to
+ # the fallback lane because the named scout was retired can still record what it found.
+ if resolve_check_skill_name(config, canonical_team_id) != run.skill_name:
raise InvalidCheckResultError(f"check {check_id} runs on another scout")
return check
diff --git a/products/signals/backend/scout_harness/views.py b/products/signals/backend/scout_harness/views.py
index e8750d2aca10..890f1209e94a 100644
--- a/products/signals/backend/scout_harness/views.py
+++ b/products/signals/backend/scout_harness/views.py
@@ -23,11 +23,14 @@ import uuid
import dataclasses
from collections.abc import Mapping
from dataclasses import dataclass
+from datetime import datetime
from typing import Any, cast
from django.db import transaction
from django.db.models import Q, Value
from django.db.models.functions import Coalesce, Lower, NullIf
+from django.utils import timezone
+from django.utils.dateparse import parse_datetime
import structlog
from drf_spectacular.types import OpenApiTypes
@@ -70,6 +73,7 @@ from products.signals.backend.pipeline_identity import pipeline_writer_identity
from products.signals.backend.report_charts import ChartSize
from products.signals.backend.report_generation.resolve_reviewers import MAX_PROJECT_MEMBERS, list_project_members
from products.signals.backend.scout_harness.config_registry import enabled_scout_count, ensure_scout_category
+from products.signals.backend.scout_harness.deprecation import deprecation_metadata_of
from products.signals.backend.scout_harness.fleet_sync import materialize_scout_fleet
from products.signals.backend.scout_harness.lazy_seed import (
SCOUT_ROLE_OPERATIONAL,
@@ -2641,6 +2645,9 @@ class _ScoutSkillInfo:
description: str
origin: str # "canonical" | "custom" — see `lazy_seed.scout_skill_origin`.
role: str # "specialist" | "operational" — see `lazy_seed.is_operational_scout`.
+ # The retirement PostHog announced for this scout, as the sync stored it on the row, plus the
+ # phase computed against now. None when the scout is not being retired.
+ deprecation: dict | None
def _skill_info_for(team_id: int, skill_names: list[str]) -> dict[str, _ScoutSkillInfo]:
@@ -2657,6 +2664,7 @@ def _skill_info_for(team_id: int, skill_names: list[str]) -> dict[str, _ScoutSki
rows = LLMSkill.objects.filter(team_id=team_id, name__in=names, is_latest=True).values_list(
"name", "description", "metadata", "deleted"
)
+ now = timezone.now()
return {
name: _ScoutSkillInfo(
description="" if deleted else (description or ""),
@@ -2666,11 +2674,35 @@ def _skill_info_for(team_id: int, skill_names: list[str]) -> dict[str, _ScoutSki
role=SCOUT_ROLE_OPERATIONAL
if origin == ScoutOrigin.CANONICAL.value and is_operational_scout(name)
else SCOUT_ROLE_SPECIALIST,
+ deprecation=_deprecation_for_row(metadata, now),
)
for name, description, metadata, deleted in rows
}
+def _deprecation_for_row(metadata: dict | None, now: datetime) -> dict | None:
+ """The stored retirement marker plus the phase it is in, or None when there is none.
+
+ The phase is computed here rather than stored, because it turns over on a date with nothing
+ running: a row written while the retirement was announced would otherwise still read
+ `announced` after its sunset, and the chip would say a scout is retiring that already stopped.
+ A marker with no sunset reads `retired`, matching the reconcile that retires it on its next
+ pass, so a person is never shown a retirement date that does not exist.
+ """
+ stored = deprecation_metadata_of(metadata)
+ if stored is None:
+ return None
+ raw_sunset = stored.get("sunset_at")
+ sunset_at = parse_datetime(raw_sunset) if isinstance(raw_sunset, str) else None
+ phase = "announced" if sunset_at is not None and sunset_at > now else "retired"
+ return {
+ "phase": phase,
+ "reason": stored.get("reason") or "",
+ "superseded_by": stored.get("superseded_by") or "",
+ "sunset_at": sunset_at,
+ }
+
+
def _precheck_scout_repositories(request: Request, *, team: Team, config_id: uuid.UUID) -> bool:
"""Run the GitHub reachability check for a `repositories` PATCH before the row lock.
diff --git a/products/signals/backend/test/test_report_checks.py b/products/signals/backend/test/test_report_checks.py
index 22a277149810..b17356602930 100644
--- a/products/signals/backend/test/test_report_checks.py
+++ b/products/signals/backend/test/test_report_checks.py
@@ -917,6 +917,50 @@ class TestAgentCheckDispatch(APIBaseTest):
check.refresh_from_db()
assert check.consecutive_errors == 1
+ def test_a_check_on_a_retired_scout_runs_on_the_follow_up_scout(self) -> None:
+ # Retiring a scout must not turn every open check bound to it into an errored result on a
+ # report. The fallback scout re-measures resolved reports for a living, so it answers them.
+ LLMSkill.objects.create(team=self.team, name="signals-scout-health-checks", is_latest=True, deleted=False)
+ SignalScoutConfig.objects.create(
+ team=self.team,
+ skill_name="signals-scout-health-checks",
+ status=SignalScoutConfig.Status.PAUSED_BY_SYSTEM,
+ pause_reason=SignalScoutConfig.PauseReason.RETIRED,
+ enabled=False,
+ )
+ self._check(
+ config={
+ "instructions": "Re-read the issue and say whether it still fires.",
+ "skill_name": "signals-scout-health-checks",
+ }
+ )
+
+ with patch(_CONNECT), patch(_DISPATCH, return_value="wf-1") as dispatch:
+ summary = run_due_report_checks()
+
+ assert summary.dispatched == 1
+ assert dispatch.call_args.kwargs["skill_name"] == FALLBACK_CHECK_SKILL_NAME
+ assert self._results() == []
+
+ def test_a_check_on_a_scout_a_person_paused_still_reports_the_refusal(self) -> None:
+ # A pause is somebody's decision, so saying the check could not run is more honest than
+ # quietly answering the question on another scout.
+ LLMSkill.objects.create(team=self.team, name="signals-scout-health-checks", is_latest=True, deleted=False)
+ SignalScoutConfig.objects.create(team=self.team, skill_name="signals-scout-health-checks", enabled=False)
+ self._check(
+ config={
+ "instructions": "Re-read the issue and say whether it still fires.",
+ "skill_name": "signals-scout-health-checks",
+ }
+ )
+
+ with patch(_CONNECT), patch(_DISPATCH) as dispatch:
+ summary = run_due_report_checks()
+
+ assert summary.errored == 1
+ dispatch.assert_not_called()
+ assert "is paused" in self._results()[0].content
+
def test_an_unenrolled_project_records_an_errored_result(self) -> None:
self._enrol({"guaranteed_team_ids": []})
self._check()
@@ -1003,6 +1047,9 @@ class TestCheckResultTool(APIBaseTest):
skill_name=FALLBACK_CHECK_SKILL_NAME,
skill_version=1,
)
+ # A live lane for the other scout, so a check naming it is one another scout really
+ # owns rather than one the dispatch would have resolved onto the fallback anyway.
+ LLMSkill.objects.create(team=self.team, name=_OTHER_SKILL, is_latest=True, deleted=False)
def _check(self, **overrides) -> SignalReportCheck:
now = timezone.now()
diff --git a/products/signals/backend/test/test_scout_coordinator.py b/products/signals/backend/test/test_scout_coordinator.py
index f19c8deb6fea..3fabadf8dce5 100644
--- a/products/signals/backend/test/test_scout_coordinator.py
+++ b/products/signals/backend/test/test_scout_coordinator.py
@@ -1636,15 +1636,9 @@ def test_role_change_preserves_only_user_exemptions(tmp_path: Path, explicit_exe
skill_dir.mkdir()
skill_file = skill_dir / "SKILL.md"
frontmatter = f"---\nname: {_OPERATIONAL_SCOUT}\ndescription: test scout\nscout-role: {{role}}\n---\nBody\n"
- caches = (
- lazy_seed.canonical_skill_names,
- lazy_seed._canonical_config_tags,
- lazy_seed._canonical_operational_scouts,
- )
try:
with team_scope(team.id, canonical=True), patch.object(lazy_seed, "_SKILLS_DIR", tmp_path):
- for cache in caches:
- cache.cache_clear()
+ lazy_seed.reset_canonical_caches()
skill_file.write_text(frontmatter.format(role="operational"))
sync_canonical_skills(team)
register_missing_configs(team.id)
@@ -1659,8 +1653,7 @@ def test_role_change_preserves_only_user_exemptions(tmp_path: Path, explicit_exe
serializer.save()
skill_file.write_text(frontmatter.format(role="specialist"))
- for cache in caches:
- cache.cache_clear()
+ lazy_seed.reset_canonical_caches()
sync_canonical_skills(team)
register_missing_configs(team.id)
@@ -1668,8 +1661,7 @@ def test_role_change_preserves_only_user_exemptions(tmp_path: Path, explicit_exe
assert config.auto_pause_exempt is (explicit_exemption is True)
assert config.enabled is True
finally:
- for cache in caches:
- cache.cache_clear()
+ lazy_seed.reset_canonical_caches()
@pytest.mark.django_db
diff --git a/products/signals/backend/test/test_scout_harness_lazy_seed.py b/products/signals/backend/test/test_scout_harness_lazy_seed.py
index 5757b042213b..083cd3841892 100644
--- a/products/signals/backend/test/test_scout_harness_lazy_seed.py
+++ b/products/signals/backend/test/test_scout_harness_lazy_seed.py
@@ -1,14 +1,18 @@
from __future__ import annotations
import textwrap
+from datetime import UTC, datetime, timedelta
from pathlib import Path
import pytest
from posthog.test.base import BaseTest
from unittest.mock import patch
+from django.utils import timezone
+
from products.signals.backend.models import SignalScoutConfig
from products.signals.backend.scout_harness.config_registry import register_missing_configs
+from products.signals.backend.scout_harness.deprecation import ScoutDeprecation
from products.signals.backend.scout_harness.lazy_seed import (
_MAX_SKILL_FILE_COUNT,
CanonicalSkill,
@@ -19,6 +23,7 @@ from products.signals.backend.scout_harness.lazy_seed import (
_compute_canonical_hash,
_compute_row_hash,
discover_canonical_skills,
+ reset_canonical_caches,
seed_canonical_skills,
sync_canonical_skills,
)
@@ -26,6 +31,18 @@ from products.signals.backend.scout_harness.skill_loader import load_skill_for_r
from products.skills.backend.models.skills import LLMSkill, LLMSkillFile
[email protected](autouse=True)
+def _forget_the_canonical_fleet():
+ """Keep each test's idea of the shipped fleet out of the next one's.
+
+ Several tests here read the real fleet on disk and several patch it, and the lookups over it
+ are cached for the process, so without this the file passes or fails on test order alone.
+ """
+ reset_canonical_caches()
+ yield
+ reset_canonical_caches()
+
+
def _write_canonical_skill(
base: Path,
*,
@@ -54,6 +71,7 @@ def _make_canonical(
files: tuple[CanonicalSkillFile, ...] = (),
config_tags: tuple[str, ...] = (),
role: ScoutRole = "specialist",
+ deprecation: ScoutDeprecation | None = None,
) -> CanonicalSkill:
"""Build a CanonicalSkill for a unit test without going through disk + frontmatter."""
return CanonicalSkill(
@@ -65,9 +83,14 @@ def _make_canonical(
source_path=Path("/tmp/fake"),
config_tags=config_tags,
role=role,
+ deprecation=deprecation,
)
+def _config(team_id: int, skill_name: str) -> SignalScoutConfig:
+ return SignalScoutConfig.all_teams.get(team_id=team_id, skill_name=skill_name)
+
+
class TestDiscoverCanonicalSkills:
def test_returns_empty_for_missing_dir(self, tmp_path: Path) -> None:
assert discover_canonical_skills(tmp_path / "does-not-exist") == ()
@@ -588,6 +611,94 @@ class TestDiscoverCanonicalSkills:
discover_canonical_skills(tmp_path)
+class TestDeprecationFrontmatter:
+ """`scout-status` / `scout-deprecation`: the marker a retirement PR adds to a SKILL.md."""
+
+ def test_parses_the_retirement_marker(self, tmp_path: Path) -> None:
+ _write_canonical_skill(
+ tmp_path,
+ dir_name="signals-scout-alpha",
+ frontmatter="""
+ ---
+ name: signals-scout-alpha
+ description: alpha
+ scout-status: deprecated
+ scout-deprecation:
+ reason: Health checks now report to your inbox directly.
+ superseded_by: signals-scout-general
+ sunset_at: 2026-10-01
+ ---
+ """,
+ )
+ (skill,) = discover_canonical_skills(tmp_path)
+ assert skill.deprecation is not None
+ assert skill.deprecation.reason == "Health checks now report to your inbox directly."
+ assert skill.deprecation.superseded_by == "signals-scout-general"
+ # A bare date is read as midnight UTC, so the sunset is a fleet-wide instant.
+ assert skill.deprecation.sunset_at == datetime(2026, 10, 1, tzinfo=UTC)
+
+ def test_absent_keys_mean_the_scout_is_active(self, tmp_path: Path) -> None:
+ _write_canonical_skill(
+ tmp_path,
+ dir_name="signals-scout-alpha",
+ frontmatter="""
+ ---
+ name: signals-scout-alpha
+ description: alpha
+ ---
+ """,
+ )
+ (skill,) = discover_canonical_skills(tmp_path)
+ assert skill.deprecation is None
+
+ @pytest.mark.parametrize(
+ "extra_frontmatter",
+ [
+ # A block with no status is a marker nobody meant to apply yet.
+ "scout-deprecation:\n reason: gone",
+ # A status with no block is a retirement with no reason to show anyone.
+ "scout-status: deprecated",
+ # A reason is the one thing every surface renders, so it cannot be blank.
+ "scout-status: deprecated\n scout-deprecation:\n reason: ' '",
+ "scout-status: retired",
+ "scout-status: deprecated\n scout-deprecation:\n reason: gone\n sunset_at: soon",
+ "scout-status: deprecated\n scout-deprecation:\n reason: gone\n retired_by: me",
+ ],
+ )
+ def test_rejects_a_marker_the_fleet_could_not_act_on(self, tmp_path: Path, extra_frontmatter: str) -> None:
+ _write_canonical_skill(
+ tmp_path,
+ dir_name="signals-scout-alpha",
+ frontmatter=f"""
+ ---
+ name: signals-scout-alpha
+ description: alpha
+ {extra_frontmatter}
+ ---
+ """,
+ )
+ with pytest.raises(CanonicalSkillParseError):
+ discover_canonical_skills(tmp_path)
+
+ def test_rejects_the_marker_on_a_companion_skill(self, tmp_path: Path) -> None:
+ # A companion has no config to retire, so the keys would do nothing but mislead.
+ _write_canonical_skill(
+ tmp_path,
+ dir_name="authoring-scouts",
+ frontmatter="""
+ ---
+ name: authoring-scouts
+ description: guide
+ scout-status: deprecated
+ scout-deprecation:
+ reason: gone
+ ---
+ """,
+ )
+ with pytest.raises(CanonicalSkillParseError):
+ discover_canonical_skills(tmp_path)
+
+
class TestComputeCanonicalHash:
def test_same_input_yields_same_hash(self) -> None:
a = _make_canonical("signals-scout-foo", body="hello", allowed_tools=("a", "b"))
@@ -940,6 +1051,171 @@ class TestSyncCanonicalSkills(BaseTest):
team=self.team, name="signals-scout-beta", is_latest=True, deleted=False
).exists()
+ def test_marker_reaches_a_row_whose_content_did_not_change(self) -> None:
+ # Deprecating a scout edits only frontmatter, so the content hashes still match and the
+ # update path never fires. Without the marker reconcile the retirement would reach a
+ # project only on the scout's next real content edit — that is, possibly never.
+ alpha = _make_canonical("signals-scout-alpha", body="alpha body")
+ with self._patch_canonicals((alpha,)):
+ sync_canonical_skills(self.team)
+
+ sunset = timezone.now() + timedelta(days=30)
+ deprecated = _make_canonical(
+ "signals-scout-alpha",
+ body="alpha body",
+ deprecation=ScoutDeprecation(reason="Nothing to watch here now.", sunset_at=sunset),
+ )
+ with self._patch_canonicals((deprecated,)):
+ result = sync_canonical_skills(self.team, prune=True)
+
+ row = LLMSkill.objects.get(team=self.team, name="signals-scout-alpha", is_latest=True)
+ assert row.metadata["deprecation"] == {
+ "reason": "Nothing to watch here now.",
+ "superseded_by": "",
+ "sunset_at": sunset.isoformat(),
+ }
+ # A marker is not a content edit, so no new version and nobody's copy was rewritten.
+ assert row.version == 1
+ assert result.updated_skill_names == ()
+
+ def test_announced_scout_keeps_running_until_its_sunset(self) -> None:
+ deprecated = _make_canonical(
+ "signals-scout-alpha",
+ deprecation=ScoutDeprecation(reason="gone soon", sunset_at=timezone.now() + timedelta(days=7)),
+ )
+ with self._patch_canonicals((deprecated,)):
+ sync_canonical_skills(self.team, prune=True)
+ register_missing_configs(self.team.id)
+ SignalScoutConfig.objects.for_team(self.team.id).create(
+ team_id=self.team.id, skill_name="signals-scout-alpha"
+ )
+ result = sync_canonical_skills(self.team, prune=True)
+
+ assert result.retired_config_skill_names == ()
+ config = _config(self.team.id, "signals-scout-alpha")
+ assert config.status == SignalScoutConfig.Status.ACTIVE
+ assert config.enabled is True
+
+ def test_retires_the_config_once_the_sunset_has_passed(self) -> None:
+ alpha = _make_canonical("signals-scout-alpha")
+ with self._patch_canonicals((alpha,)):
+ sync_canonical_skills(self.team)
+ register_missing_configs(self.team.id)
+
+ deprecated = _make_canonical(
+ "signals-scout-alpha",
+ deprecation=ScoutDeprecation(reason="gone", sunset_at=timezone.now() - timedelta(minutes=1)),
+ )
+ with self._patch_canonicals((deprecated,)):
+ result = sync_canonical_skills(self.team, prune=True)
+ # A second pass has nothing left to move, so a daily tick does not re-log forever.
+ repeat = sync_canonical_skills(self.team, prune=True)
+
+ assert result.retired_config_skill_names == ("signals-scout-alpha",)
+ assert repeat.retired_config_skill_names == ()
+ config = _config(self.team.id, "signals-scout-alpha")
+ assert config.status == SignalScoutConfig.Status.PAUSED_BY_SYSTEM
+ assert config.pause_reason == SignalScoutConfig.PauseReason.RETIRED
+ # `enabled` is what dispatch filters on, so the pair has to agree or the scout keeps running.
+ assert config.enabled is False
+
+ def test_retires_the_config_of_a_scout_pruned_from_disk(self) -> None:
+ # The ghost row: the prune tombstones the skill, dispatch is gated on a live skill, so
+ # without this the scout silently stops while its roster row still reads as enabled.
+ alpha = _make_canonical("signals-scout-alpha")
+ beta = _make_canonical("signals-scout-beta")
+ with self._patch_canonicals((alpha, beta)):
+ sync_canonical_skills(self.team)
+ register_missing_configs(self.team.id)
+
+ with self._patch_canonicals((alpha,)):
+ result = sync_canonical_skills(self.team, prune=True)
+
+ assert result.pruned_skill_names == ("signals-scout-beta",)
+ assert result.retired_config_skill_names == ("signals-scout-beta",)
+ beta_config = _config(self.team.id, "signals-scout-beta")
+ assert beta_config.enabled is False
+ assert beta_config.pause_reason == SignalScoutConfig.PauseReason.RETIRED
+ assert _config(self.team.id, "signals-scout-alpha").enabled is True
+
+ def test_leaves_an_edited_fork_running_through_a_retirement(self) -> None:
+ alpha = _make_canonical("signals-scout-alpha", body="alpha body")
+ with self._patch_canonicals((alpha,)):
+ sync_canonical_skills(self.team)
+ register_missing_configs(self.team.id)
+
+ row = LLMSkill.objects.get(team=self.team, name="signals-scout-alpha", is_latest=True)
+ row.body = "the project's own version"
+ row.save(update_fields=["body"])
+
+ deprecated = _make_canonical(
+ "signals-scout-alpha",
+ body="alpha body",
+ deprecation=ScoutDeprecation(reason="gone", sunset_at=timezone.now() - timedelta(days=1)),
+ )
+ with self._patch_canonicals((deprecated,)):
+ result = sync_canonical_skills(self.team, prune=True)
+
+ assert result.retired_config_skill_names == ()
+ row.refresh_from_db()
+ assert (row.metadata or {})["deprecation"] is None
+ assert _config(self.team.id, "signals-scout-alpha").enabled is True
+
+ def test_does_not_overrule_a_pause_a_person_made(self) -> None:
+ alpha = _make_canonical("signals-scout-alpha")
+ with self._patch_canonicals((alpha,)):
+ sync_canonical_skills(self.team)
+ register_missing_configs(self.team.id)
+
+ config = _config(self.team.id, "signals-scout-alpha")
+ config.enabled = False
+ config.save(update_fields=["enabled"])
+
+ deprecated = _make_canonical(
+ "signals-scout-alpha",
+ deprecation=ScoutDeprecation(reason="gone", sunset_at=timezone.now() - timedelta(days=1)),
+ )
+ with self._patch_canonicals((deprecated,)):
+ result = sync_canonical_skills(self.team, prune=True)
+
+ assert result.retired_config_skill_names == ()
+ config.refresh_from_db()
+ assert config.status == SignalScoutConfig.Status.PAUSED_BY_USER
+
+ def test_retirement_needs_the_deliberate_prune_path(self) -> None:
+ # The runner's cold-start sync passes no `prune`, so one ad-hoc run must not reconcile
+ # the rest of the project's fleet — the same rule the reap already follows.
+ alpha = _make_canonical("signals-scout-alpha")
+ with self._patch_canonicals((alpha,)):
+ sync_canonical_skills(self.team)
+ register_missing_configs(self.team.id)
+
+ deprecated = _make_canonical(
+ "signals-scout-alpha",
+ deprecation=ScoutDeprecation(reason="gone", sunset_at=timezone.now() - timedelta(days=1)),
+ )
+ with self._patch_canonicals((deprecated,)):
+ result = sync_canonical_skills(self.team)
+
+ assert result.retired_config_skill_names == ()
+ assert _config(self.team.id, "signals-scout-alpha").enabled is True
+
+ def test_no_config_is_seeded_for_a_scout_being_retired(self) -> None:
+ # Phase one stops intake: a project that never ran the scout does not acquire a row it
+ # would only have to retire. A project that already has one keeps it (above).
+ deprecated = _make_canonical(
+ "signals-scout-alpha",
+ deprecation=ScoutDeprecation(reason="gone", sunset_at=timezone.now() + timedelta(days=7)),
+ )
+ beta = _make_canonical("signals-scout-beta")
+ with self._patch_canonicals((deprecated, beta)):
+ sync_canonical_skills(self.team, prune=True)
+ register_missing_configs(self.team.id)
+
+ assert set(SignalScoutConfig.all_teams.filter(team=self.team).values_list("skill_name", flat=True)) == {
+ "signals-scout-beta"
+ }
+
def test_leaves_pre_hash_harness_row_alone(self) -> None:
# A harness-seeded row missing `canonical_hash` (only reachable for rows seeded before
# hash tracking, e.g. an existing dogfood team). We can't tell whether the team edited
diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.ts
index cc2027b23a12..4f90e59f7d41 100644
--- a/products/signals/frontend/generated/api.schemas.ts
+++ b/products/signals/frontend/generated/api.schemas.ts
@@ -3173,6 +3173,38 @@ export const ScoutRoleEnumApi = {
Operational: 'operational',
} as const
+/**
+ * * `announced` - announced
+ * * `retired` - retired
+ */
+export type ScoutDeprecationPhaseEnumApi =
+ (typeof ScoutDeprecationPhaseEnumApi)[keyof typeof ScoutDeprecationPhaseEnumApi]
+
+export const ScoutDeprecationPhaseEnumApi = {
+ Announced: 'announced',
+ Retired: 'retired',
+} as const
+
+/**
+ * What PostHog has said about retiring this scout, for the chip and the banner to render.
+ */
+export interface ScoutDeprecationApi {
+ /** How far the retirement has got: `announced` while the scout still runs, `retired` once its sunset has passed. A retired scout is paused and does not run again.
+ *
+ * * `announced` - announced
+ * * `retired` - retired */
+ phase: ScoutDeprecationPhaseEnumApi
+ /** Why PostHog is retiring the scout, written to be shown to a person as-is. */
+ reason: string
+ /** Skill name of the scout that takes over, or blank when nothing replaces it. */
+ superseded_by: string
+ /**
+ * When the scout stops running. Null means the next fleet reconcile retires it.
+ * @nullable
+ */
+ sunset_at: string | null
+}
+
/**
* * `engineering` - Engineering
* * `data` - Data
@@ -3250,6 +3282,7 @@ export const SignalScoutConfigStatusEnumApi = {
* * `no_output` - No output
* * `ignored` - Ignored
* * `repeated_failures` - Repeated failures
+ * * `retired` - Retired
*/
export type SignalScoutConfigPauseReasonEnumApi =
(typeof SignalScoutConfigPauseReasonEnumApi)[keyof typeof SignalScoutConfigPauseReasonEnumApi]
@@ -3258,6 +3291,7 @@ export const SignalScoutConfigPauseReasonEnumApi = {
NoOutput: 'no_output',
Ignored: 'ignored',
RepeatedFailures: 'repeated_failures',
+ Retired: 'retired',
} as const
/**
@@ -3287,6 +3321,8 @@ export interface SignalScoutConfigApi {
readonly scout_origin: ScoutOriginEnumApi
/** What this scout is to the harness: `specialist` for one that watches a product surface, or `operational` for one PostHog ships to watch the self-driving system itself. An operational scout is exempt from the inactivity sweep and from the enabled-scout cap, and is not a scout a project should delete. Always `specialist` for a custom scout. */
readonly scout_role: ScoutRoleEnumApi
+ /** Set when PostHog is retiring this scout, and null otherwise. Carries the phase, the reason to show, what replaces the scout, and when it stops running. Only a canonical scout the project has not edited is ever marked: a project's own copy keeps running and reads as null. */
+ readonly deprecation: ScoutDeprecationApi | null
/** Who answers for this scout, seed-creator first. Ownership is recorded on the scout's skill rather than on this config, so editing the skill or toggling the scout leaves it unchanged. Reports the scout files suggest these people as reviewers. Prefer this over `created_by`-style fields, which only say who last flipped a switch. Empty when nobody owns the scout, when the owners are no longer members with access to the project, or when the caller is a scout sandbox token: owners are member PII, and a scout reads them through the skill API instead. */
readonly owners: readonly UserBasicApi[]
/** Whether this scout runs on its schedule. Disabled scouts are skipped by the coordinator. Derived from `status`: true for `active` and `pending_pause`, false for the paused statuses. */
@@ -3302,7 +3338,8 @@ export interface SignalScoutConfigApi {
*
* * `no_output` - No output
* * `ignored` - Ignored
- * * `repeated_failures` - Repeated failures */
+ * * `repeated_failures` - Repeated failures
+ * * `retired` - Retired */
readonly pause_reason: SignalScoutConfigPauseReasonEnumApi | null
/** Whether the scout writes findings to the inbox. False = dry-run: it runs and logs but emits nothing. */
readonly emit: boolean
diff --git a/products/signals/frontend/inbox/__mocks__/scoutConfigs.ts b/products/signals/frontend/inbox/__mocks__/scoutConfigs.ts
index d13d83a3e7dc..a6cae7c01a58 100644
--- a/products/signals/frontend/inbox/__mocks__/scoutConfigs.ts
+++ b/products/signals/frontend/inbox/__mocks__/scoutConfigs.ts
@@ -38,6 +38,7 @@ function makeMockScout(overrides: MockScoutOverrides): SignalScoutConfigApi {
enabled: true,
status: 'active',
pause_reason: null,
+ deprecation: null,
emit: true,
run_interval_minutes: 1440,
run_cron_schedule: null,
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutBadges.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutBadges.tsx
index 3d7f79365c5e..99b0eec6b154 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutBadges.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutBadges.tsx
@@ -3,12 +3,42 @@ import { LemonTag, Tooltip } from '@posthog/lemon-ui'
import { dayjs } from 'lib/dayjs'
import type {
+ ScoutDeprecationApi,
ScoutOriginEnumApi,
SignalScoutConfigApi as SignalScoutConfig,
} from 'products/signals/frontend/generated/api.schemas'
import { ScoutGroupKey } from '../../../utils/scoutGroups'
+/**
+ * What a retirement PostHog announced for this scout says, in one tag. A scout that is on its way
+ * out otherwise looks identical to a healthy one until the day it stops, and a retired one looks
+ * like a scout somebody switched off. Nothing renders for a scout PostHog still ships, or for a
+ * project's own edited copy of one, which keeps running.
+ */
+export function ScoutDeprecationBadge({ config }: { config: SignalScoutConfig }): JSX.Element | null {
+ const deprecation: ScoutDeprecationApi | null | undefined = config.deprecation
+ if (!deprecation) {
+ return null
+ }
+ const sunsetOn = deprecation.sunset_at ? dayjs(deprecation.sunset_at).format('MMMM D, YYYY') : null
+ // An announced retirement always carries a date, since a marker without one reads as retired.
+ const announced = deprecation.phase === 'announced' && sunsetOn
+ const label = announced ? `Retiring on ${sunsetOn}` : 'Retired'
+ const headline = announced
+ ? `PostHog is retiring this scout on ${sunsetOn}.`
+ : sunsetOn
+ ? `PostHog retired this scout on ${sunsetOn}.`
+ : 'PostHog retired this scout.'
+ return (
+ <Tooltip title={`${headline} ${deprecation.reason}`.trim()}>
+ <LemonTag type={announced ? 'caution' : 'danger'} size="small">
+ {label}
+ </LemonTag>
+ </Tooltip>
+ )
+}
+
/**
* Where the scout stands with the system writers that can pause it: the failure breaker
* (`repeated_failures`) or the inactivity sweep (`no_output` / `ignored`), plus the sweep's
@@ -16,6 +46,10 @@ import { ScoutGroupKey } from '../../../utils/scoutGroups'
* as one a person turned off. Nothing renders for a healthy scout or a user pause.
*/
export function ScoutLifecycleBadge({ config }: { config: SignalScoutConfig }): JSX.Element | null {
+ if (config.pause_reason === 'retired') {
+ // The retirement badge already says this, and with the reason.
+ return null
+ }
if (config.status === 'paused_by_system') {
if (config.pause_reason === 'repeated_failures') {
return (
@@ -130,6 +164,13 @@ export function ScoutTagBadge({ tag }: { tag: string }): JSX.Element {
/** Where a scout stands right now, in one tag. Used on the scout page header and its settings modal. */
export function ScoutStatusTag({ config }: { config: SignalScoutConfig }): JSX.Element {
+ if (config.pause_reason === 'retired') {
+ return (
+ <LemonTag type="danger" size="small">
+ Retired
+ </LemonTag>
+ )
+ }
if (config.status === 'paused_by_system') {
return (
<LemonTag type="danger" size="small">
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutCadenceLabel.test.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutCadenceLabel.test.tsx
index daa9adeeda4a..f6202a080109 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutCadenceLabel.test.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutCadenceLabel.test.tsx
@@ -19,6 +19,7 @@ const config: SignalScoutConfigApi = {
enabled: true,
status: 'active',
pause_reason: null,
+ deprecation: null,
emit: true,
run_interval_minutes: 1440,
run_cron_schedule: '0 9 * * *',
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutConfigControls.test.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutConfigControls.test.tsx
index a949f78c2b3b..11d5ba97a202 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutConfigControls.test.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutConfigControls.test.tsx
@@ -22,6 +22,7 @@ const config: SignalScoutConfigApi = {
enabled: true,
status: 'active',
pause_reason: null,
+ deprecation: null,
emit: true,
run_interval_minutes: 1440,
run_cron_schedule: '0 9 * * *',
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutNextRunLabel.test.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutNextRunLabel.test.tsx
index 630916292ffe..9dbb776f6b1c 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutNextRunLabel.test.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutNextRunLabel.test.tsx
@@ -21,6 +21,7 @@ const config: SignalScoutConfigApi = {
enabled: true,
status: 'active',
pause_reason: null,
+ deprecation: null,
emit: true,
run_interval_minutes: 30,
run_cron_schedule: null,
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutRosterCard.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutRosterCard.tsx
index 729979e83a01..4938d0a5a1d5 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutRosterCard.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutRosterCard.tsx
@@ -11,7 +11,7 @@ import { scoutFleetLogic } from '../../../logics/scoutFleetLogic'
import { nextRunAt, SCOUT_GROUP_LABEL, ScoutRosterRow, scoutSubtitle } from '../../../utils/scoutGroups'
import { runStripEmptyLabel, scoutDisplayName } from '../../../utils/scoutRunsWindow'
import { inboxCardRowClassName } from '../../cards/inboxCardRowClassName'
-import { ScoutExemptionBadge, ScoutLifecycleBadge } from './ScoutBadges'
+import { ScoutDeprecationBadge, ScoutExemptionBadge, ScoutLifecycleBadge } from './ScoutBadges'
import { ScoutCadenceLabel } from './ScoutCadenceLabel'
import { ScoutEnabledSwitch } from './ScoutConfigControls'
import { ScoutCostLine } from './ScoutCostLine'
@@ -78,6 +78,7 @@ export const ScoutRosterCard = memo(function ScoutRosterCard({ row }: { row: Sco
<ScoutWriteAccessTag writeScopes={config.write_scopes} emit={config.emit} />
<ScoutExemptionBadge config={config} group={group} />
<ScoutLifecycleBadge config={config} />
+ <ScoutDeprecationBadge config={config} />
</div>
{subtitle && (
<p className={cn('m-0 line-clamp-1 text-xs leading-snug', SUBTITLE_TONE_CLASS[subtitle.tone])}>
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutSummaryRow.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutSummaryRow.tsx
index 4b3761bea039..8bf4fb967fed 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutSummaryRow.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutSummaryRow.tsx
@@ -14,7 +14,7 @@ import type {
import { nextRunAt } from '../../../utils/scoutGroups'
import { scoutDisplayName } from '../../../utils/scoutRunsWindow'
-import { ScoutLifecycleBadge } from './ScoutBadges'
+import { ScoutDeprecationBadge, ScoutLifecycleBadge } from './ScoutBadges'
import { ScoutCadenceLabel } from './ScoutCadenceLabel'
import { ScoutEnabledSwitch } from './ScoutConfigControls'
import { ScoutNextRunLabel } from './ScoutNextRunLabel'
@@ -61,6 +61,7 @@ export function ScoutSummaryRow({
</LemonTag>
)}
<ScoutLifecycleBadge config={config} />
+ <ScoutDeprecationBadge config={config} />
</div>
<span className="text-[11px] text-muted">
<ScoutCadenceLabel config={config} />
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutTags.stories.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutTags.stories.tsx
index c90c531efc3f..f435e6da7cab 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutTags.stories.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutTags.stories.tsx
@@ -20,6 +20,7 @@ const config: SignalScoutConfigApi = {
enabled: true,
status: 'active',
pause_reason: null,
+ deprecation: null,
emit: true,
run_interval_minutes: 1440,
run_cron_schedule: null,
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutWriteAccessSection.test.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutWriteAccessSection.test.tsx
index 9fa088136b0d..bdb60c6e7758 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutWriteAccessSection.test.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutWriteAccessSection.test.tsx
@@ -18,6 +18,7 @@ const CONFIG: SignalScoutConfigApi = {
enabled: true,
status: 'active',
pause_reason: null,
+ deprecation: null,
emit: true,
run_interval_minutes: 1440,
run_cron_schedule: null,
diff --git a/products/signals/frontend/inbox/logics/scoutCreateModalLogic.test.ts b/products/signals/frontend/inbox/logics/scoutCreateModalLogic.test.ts
index 503a8d3d7d1e..3e9b3632c3b4 100644
--- a/products/signals/frontend/inbox/logics/scoutCreateModalLogic.test.ts
+++ b/products/signals/frontend/inbox/logics/scoutCreateModalLogic.test.ts
@@ -44,6 +44,7 @@ const CREATED_SCOUT: SignalScoutCreateResponseApi = {
enabled: false,
status: 'paused_by_user',
pause_reason: null,
+ deprecation: null,
emit: false,
run_interval_minutes: 60,
run_cron_schedule: null,
diff --git a/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts b/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts
index 104aa40be6c4..fd7fb57efa55 100644
--- a/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts
+++ b/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts
@@ -64,6 +64,7 @@ const BASE_CONFIG: SignalScoutConfigApi = {
enabled: true,
status: 'active',
pause_reason: null,
+ deprecation: null,
emit: true,
run_interval_minutes: 1440,
run_cron_schedule: null,
diff --git a/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.test.ts b/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.test.ts
index 8e396bad6d30..128986e2a3d4 100644
--- a/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.test.ts
+++ b/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.test.ts
@@ -101,6 +101,7 @@ const CONFIG: SignalScoutConfigApi = {
enabled: false,
status: 'active',
pause_reason: null,
+ deprecation: null,
emit: true,
run_interval_minutes: 1440,
run_cron_schedule: null,
diff --git a/products/signals/skills/AGENTS.md b/products/signals/skills/AGENTS.md
index d8160f00ae30..29465f763a69 100644
--- a/products/signals/skills/AGENTS.md
+++ b/products/signals/skills/AGENTS.md
@@ -101,6 +101,13 @@ A scout that watches the self-driving system rather than a product surface decla
Unlike tags, the role is reconciled onto rows seeded earlier on every coordinator tick, because a silenced operational scout is the failure the role exists to prevent — though a pause a person made is still left standing, and `withheld_skills` still gates the scout.
Use it only for a scout whose subject is the fleet itself: `signals-scout-inbox-validation`, which re-measures whether merged fixes held, is the one that ships with it.
+Frontmatter also carries the optional **`scout-status`** / **`scout-deprecation`** pair, which is how a canonical scout is retired.
+`scout-status: deprecated` plus a `scout-deprecation` block (`reason`, optional `superseded_by`, optional `sunset_at`) is the whole announcement: the sync copies it into every project's skill row metadata, the roster renders a "Retiring on {date}" chip from it, no new project is seeded the scout, and on the first reconcile past the sunset each project's config moves to a `retired` pause.
+The two keys must agree, and a block with no reason fails the parse, because the reason is what every surface shows a person.
+A `sunset_at` left out means the next reconcile retires the scout, so a marker is never half-applied.
+A project that edited its copy is untouched by all of it and keeps running the scout as its own.
+Retiring a scout is therefore a frontmatter PR, and `withheld_skills` on the `signals-scout` flag goes back to meaning "unreleased" only.
+
The generalist (`signals-scout-general`) is **report-only** — it authors `SignalReport`s directly and does not `emit_signal`. The **report-channel contract** (when to author a fresh report vs. edit an existing one, the field schema, the safety × actionability status mapping, reviewer routing via `scout-members-list`, and the non-idempotency + pipeline-rewrite caveats) lives in the **harness prompt** (`scout_harness/prompt.py`), which forks on the scout's channel and injects it into every report-channel scout — so it is **not** duplicated as a per-scout reference. The generalist keeps two bundled references:
- **`references/conventions.md`** — the four-states author/edit classifier, scratchpad key-prefix vocabulary, and cross-project noise patterns.
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index bc68e54c498a..1dc9da1343a6 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -86438,6 +86438,38 @@ export namespace Schemas {
Operational: 'operational',
} as const;
+ /**
+ * * `announced` - announced
+ * * `retired` - retired
+ */
+ export type ScoutDeprecationPhaseEnum = typeof ScoutDeprecationPhaseEnum[keyof typeof ScoutDeprecationPhaseEnum];
+
+
+ export const ScoutDeprecationPhaseEnum = {
+ Announced: 'announced',
+ Retired: 'retired',
+ } as const;
+
+ /**
+ * What PostHog has said about retiring this scout, for the chip and the banner to render.
+ */
+ export interface ScoutDeprecation {
+ /** How far the retirement has got: `announced` while the scout still runs, `retired` once its sunset has passed. A retired scout is paused and does not run again.
+ *
+ * * `announced` - announced
+ * * `retired` - retired */
+ phase: ScoutDeprecationPhaseEnum;
+ /** Why PostHog is retiring the scout, written to be shown to a person as-is. */
+ reason: string;
+ /** Skill name of the scout that takes over, or blank when nothing replaces it. */
+ superseded_by: string;
+ /**
+ * When the scout stops running. Null means the next fleet reconcile retires it.
+ * @nullable
+ */
+ sunset_at: string | null;
+ }
+
/**
* * `active` - Active
* * `pending_pause` - Pending pause
@@ -86458,6 +86490,7 @@ export namespace Schemas {
* * `no_output` - No output
* * `ignored` - Ignored
* * `repeated_failures` - Repeated failures
+ * * `retired` - Retired
*/
export type SignalScoutConfigPauseReasonEnum = typeof SignalScoutConfigPauseReasonEnum[keyof typeof SignalScoutConfigPauseReasonEnum];
@@ -86466,6 +86499,7 @@ export namespace Schemas {
NoOutput: 'no_output',
Ignored: 'ignored',
RepeatedFailures: 'repeated_failures',
+ Retired: 'retired',
} as const;
/**
@@ -86495,6 +86529,8 @@ export namespace Schemas {
readonly scout_origin: ScoutOriginEnum;
/** What this scout is to the harness: `specialist` for one that watches a product surface, or `operational` for one PostHog ships to watch the self-driving system itself. An operational scout is exempt from the inactivity sweep and from the enabled-scout cap, and is not a scout a project should delete. Always `specialist` for a custom scout. */
readonly scout_role: ScoutRoleEnum;
+ /** Set when PostHog is retiring this scout, and null otherwise. Carries the phase, the reason to show, what replaces the scout, and when it stops running. Only a canonical scout the project has not edited is ever marked: a project's own copy keeps running and reads as null. */
+ readonly deprecation: ScoutDeprecation | null;
/** Who answers for this scout, seed-creator first. Ownership is recorded on the scout's skill rather than on this config, so editing the skill or toggling the scout leaves it unchanged. Reports the scout files suggest these people as reviewers. Prefer this over `created_by`-style fields, which only say who last flipped a switch. Empty when nobody owns the scout, when the owners are no longer members with access to the project, or when the caller is a scout sandbox token: owners are member PII, and a scout reads them through the skill API instead. */
readonly owners: readonly UserBasic[];
/** Whether this scout runs on its schedule. Disabled scouts are skipped by the coordinator. Derived from `status`: true for `active` and `pending_pause`, false for the paused statuses. */
@@ -86510,7 +86546,8 @@ export namespace Schemas {
*
* * `no_output` - No output
* * `ignored` - Ignored
- * * `repeated_failures` - Repeated failures */
+ * * `repeated_failures` - Repeated failures
+ * * `retired` - Retired */
readonly pause_reason: SignalScoutConfigPauseReasonEnum | null;
/** Whether the scout writes findings to the inbox. False = dry-run: it runs and logs but emits nothing. */
readonly emit: boolean;