: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): tag the canonical AI observability scout for the self-driving tab (#82079)
Radu Raiceab38c59ba4af4
diff --git a/products/signals/backend/scout_harness/AGENTS.md b/products/signals/backend/scout_harness/AGENTS.mdindex b4b7909e0c9b..55030a6e5d4b 100644--- a/products/signals/backend/scout_harness/AGENTS.md+++ b/products/signals/backend/scout_harness/AGENTS.md@@ -21,7 +21,7 @@ In production it is driven by `SignalsScoutCoordinatorWorkflow` (periodic tick e- `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.- `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).+ `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.- `slack_delivery.py` / `slack_delivery_queue.py`Best-effort direct Slack delivery for configured scout outputs. Finding emissions and surfaced report emits/edits snapshot the run config's destination after their database write commits, then enqueue the shared retrying Celery worker. Integrations are project-scoped, so a workspace connected from any environment in the project can receive the canonical parent team's scout output.- `tools/`diff --git a/products/signals/backend/scout_harness/config_registry.py b/products/signals/backend/scout_harness/config_registry.pyindex 4daf9d14c14f..27a60c7c9eaf 100644--- a/products/signals/backend/scout_harness/config_registry.py+++ b/products/signals/backend/scout_harness/config_registry.py@@ -15,6 +15,7 @@ from products.signals.backend.models import SignalScoutConfigfrom products.signals.backend.scout_harness.lazy_seed import (HARNESS_SEEDED_BY,SCOUT_SKILL_CATEGORY,+ canonical_config_tags_for,canonical_skill_names,)from products.signals.backend.scout_harness.limits import MAX_ENABLED_SCOUTS_PER_TEAM@@ -152,6 +153,9 @@ def register_missing_configs(scout isn't silently muted. With no allowlist, every scout enables at the model-defaultschedule. Either way, a scout disabled at seed stays visible and tunable but adds no spend.+ A canonical scout's `scout-tags` frontmatter is stamped on the row it creates, so a scout+ ships already labelled for the product surface it watches.+Posture only shapes rows at creation (forward-only) — existing configs are never re-stamped,so flipping the flag later doesn't disturb teams already seeded, and a user enabling a scoutwon't be reverted on the next tick.@@ -209,6 +213,12 @@ def register_missing_configs(seed_enabled = in_allowlist and not at_capdefaults: dict = {} if seed_enabled else {"enabled": False}+ # A canonical scout can claim a product surface's tag in its SKILL.md frontmatter+ # (`scout-tags`) — that's what lands it in that product's own scout list. Seeded at+ # creation like the rest of the posture, so a person who later removes the tag keeps it+ # removed. Only canonical names read from disk: a team's scout sharing the name is its own.+ if name in canonical_names and (canonical_tags := canonical_config_tags_for(name)):+ defaults["tags"] = list(canonical_tags)# The launch cadence is stamped on every canonical (gated) scout — whether it seeds# enabled now or stays disabled for the user to switch on later — so a specialist a user# toggles on runs at the flag's launch cadence rather than the model default (daily).diff --git a/products/signals/backend/scout_harness/lazy_seed.py b/products/signals/backend/scout_harness/lazy_seed.pyindex 8308320d94fe..b2cd1f95cf2c 100644--- a/products/signals/backend/scout_harness/lazy_seed.py+++ b/products/signals/backend/scout_harness/lazy_seed.py@@ -16,7 +16,9 @@ import yamlfrom posthog.models.team.team import Team+from products.signals.backend.models import SignalScoutConfigfrom products.signals.backend.scout_harness.skill_loader import SIGNALS_SCOUT_SKILL_PREFIX+from products.signals.backend.scout_harness.tags import slugify_tagfrom products.skills.backend.models.skills import LLMSkill, LLMSkillFilelogger = logging.getLogger(__name__)@@ -87,7 +89,8 @@ class CanonicalSkill:frontmatter. `allowed_tools` is optional in frontmatter — defaults to empty (no narrowing).The agentskills.io spec uses `allowed-tools` (hyphen); we accept both, preferring thespec form. `files` is the recursive content of the `_ALLOWED_BUNDLE_SUBDIRS` directories- alongside SKILL.md.+ alongside SKILL.md. `config_tags` is the optional `scout-tags` frontmatter list, seeded onto+ the scout's `SignalScoutConfig` when that row is first created."""name: str@@ -96,6 +99,7 @@ class CanonicalSkill:allowed_tools: tuple[str, ...]files: tuple[CanonicalSkillFile, ...]source_path: Path+ config_tags: tuple[str, ...] = ()@dataclass(frozen=True)@@ -141,6 +145,47 @@ class CanonicalSkillParseError(ValueError):"""A canonical SKILL.md on disk is malformed (missing frontmatter, bad YAML, etc.)."""+def _parse_config_tags(frontmatter: dict, skill_file: Path, *, is_scout: bool) -> tuple[str, ...]:+ """Read the optional `scout-tags` frontmatter list — the tags seeded onto the scout's config.++ This is how a canonical scout claims a product surface's tag (e.g. `ai-observability`, which+ is what puts a scout in AI observability's self-driving tab) without that product hardcoding+ a skill name. Normalized through the same `slugify_tag` the config API uses, so a tag written+ here means what a person typing it in the tag box would get, and bounded by the same caps —+ a malformed value fails the parse rather than seeding a tag nobody can reproduce by hand.++ Only scouts have a config to tag, so the key is rejected on a companion skill.+ """+ if "scout-tags" not in frontmatter:+ return ()+ if not is_scout:+ raise CanonicalSkillParseError(f"Only a signals-scout-* skill may declare 'scout-tags': {skill_file}")+ raw_tags = frontmatter["scout-tags"]+ if not isinstance(raw_tags, list) or not all(isinstance(t, str) for t in raw_tags):+ raise CanonicalSkillParseError(f"SKILL.md frontmatter 'scout-tags' must be a list of strings: {skill_file}")+ tags: set[str] = set()+ for raw in raw_tags:+ tag = slugify_tag(raw)+ if not tag:+ raise CanonicalSkillParseError(+ f"SKILL.md frontmatter tag {raw!r} is empty once normalized to a lowercase slug: {skill_file}"+ )+ if len(tag) > SignalScoutConfig.MAX_TAG_LENGTH:+ raise CanonicalSkillParseError(+ f"SKILL.md frontmatter tag {raw!r} is {len(tag)} characters once normalized, over the "+ f"{SignalScoutConfig.MAX_TAG_LENGTH} limit: {skill_file}"+ )+ tags.add(tag)+ # Counted after normalization, like the length cap above is measured on the slug: the cap is+ # about what lands on the config, so spellings that collapse to one tag cost one tag.+ if len(tags) > SignalScoutConfig.MAX_TAGS:+ raise CanonicalSkillParseError(+ f"SKILL.md frontmatter 'scout-tags' has {len(tags)} tags once normalized, over the "+ f"{SignalScoutConfig.MAX_TAGS} limit: {skill_file}"+ )+ return tuple(sorted(tags))++def _parse_canonical_skill(skill_dir: Path, *, is_scout: bool = True) -> CanonicalSkill:skill_file = skill_dir / "SKILL.md"raw = skill_file.read_text(encoding="utf-8")@@ -203,6 +248,8 @@ def _parse_canonical_skill(skill_dir: Path, *, is_scout: bool = True) -> Canonicf"SKILL.md frontmatter 'allowed-tools'/'allowed_tools' must be a list of strings: {skill_file}")+ config_tags = _parse_config_tags(frontmatter, skill_file, is_scout=is_scout)+body = raw[match.end() :]# Enforce the same per-skill limits the REST API uses (skill_services.py). The seed# bypasses `create_skill_file` (no service-layer "create from scratch with files"@@ -246,6 +293,7 @@ def _parse_canonical_skill(skill_dir: Path, *, is_scout: bool = True) -> Canonicallowed_tools=tuple(raw_allowed),files=tuple(files),source_path=skill_dir,+ config_tags=config_tags,)@@ -304,6 +352,31 @@ def canonical_skill_names() -> frozenset[str]:return frozenset()+@lru_cache(maxsize=1)+def _canonical_config_tags() -> dict[str, tuple[str, ...]]:+ """`scout-tags` per canonical scout name, for the scouts that declare any.++ Cached for the process like `canonical_skill_names` — the shipped fleet only changes on+ deploy — and degrades to empty on a malformed canonical rather than failing config+ registration, which the harness's own sync path already fails loud on.+ """+ try:+ return {skill.name: skill.config_tags for skill in discover_canonical_skills() if skill.config_tags}+ except CanonicalSkillParseError:+ logger.warning("canonical_config_tags: malformed canonical skill on disk; seeding no tags")+ return {}+++def canonical_config_tags_for(skill_name: str) -> tuple[str, ...]:+ """Tags the canonical scout of this name declares, to stamp on its config at creation.++ Empty for a custom scout, and for a canonical scout that claims no product surface. 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.+ """+ return _canonical_config_tags().get(skill_name, ())++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.@@ -336,6 +409,10 @@ def _compute_canonical_hash(canonical: CanonicalSkill) -> str:SHA-256 is overkill cryptographically but content-addressable hashes are cheap and we wantno false positives.++ Deliberately excludes `config_tags`: the hash is compared against `_compute_row_hash` over the+ team's `LLMSkill` row, which stores no tags (they live on the config), so folding them in here+ would make every seeded row read as diverged forever."""payload = {"description": canonical.description,diff --git a/products/signals/backend/test/test_scout_harness_lazy_seed.py b/products/signals/backend/test/test_scout_harness_lazy_seed.pyindex 01415701046f..0bceab4e865f 100644--- a/products/signals/backend/test/test_scout_harness_lazy_seed.py+++ b/products/signals/backend/test/test_scout_harness_lazy_seed.py@@ -51,6 +51,7 @@ def _make_canonical(body: str = "# Body\n",allowed_tools: tuple[str, ...] = (),files: tuple[CanonicalSkillFile, ...] = (),+ config_tags: tuple[str, ...] = (),) -> CanonicalSkill:"""Build a CanonicalSkill for a unit test without going through disk + frontmatter."""return CanonicalSkill(@@ -60,6 +61,7 @@ def _make_canonical(allowed_tools=allowed_tools,files=files,source_path=Path("/tmp/fake"),+ config_tags=config_tags,)@@ -235,6 +237,81 @@ class TestDiscoverCanonicalSkills:with pytest.raises(CanonicalSkillParseError, match="must be a list of strings"):discover_canonical_skills(tmp_path)+ def test_parses_and_normalizes_scout_tags(self, tmp_path: Path) -> None:+ # `scout-tags` is what lands a canonical scout in a product's own scout list, so a+ # dropped or unnormalized value silently empties that list.+ _write_canonical_skill(+ tmp_path,+ dir_name="signals-scout-bar",+ frontmatter="""+ ---+ name: signals-scout-bar+ description: bar skill+ scout-tags:+ - AI Observability+ - ai_observability+ - on-call+ ---+ """,+ body="# Bar\n",+ )+ skills = discover_canonical_skills(tmp_path)+ assert skills[0].config_tags == ("ai-observability", "on-call")++ def test_defaults_to_no_scout_tags(self, tmp_path: Path) -> None:+ _write_canonical_skill(+ tmp_path,+ dir_name="signals-scout-bar",+ frontmatter="""+ ---+ name: signals-scout-bar+ description: bar skill+ ---+ """,+ body="# Bar\n",+ )+ assert discover_canonical_skills(tmp_path)[0].config_tags == ()++ @pytest.mark.parametrize(+ "scout_tags_yaml,expected_error",+ [+ ("scout-tags: ai-observability", "must be a list of strings"),+ ("scout-tags:", "must be a list of strings"),+ ("scout-tags:\n - '!!!'", "empty once normalized"),+ (f"scout-tags:\n - {'a' * 51}", "over the 50 limit"),+ ("scout-tags:\n" + "".join(f" - tag-{i}\n" for i in range(11)), "over the 10 limit"),+ ],+ )+ def test_rejects_malformed_scout_tags(self, tmp_path: Path, scout_tags_yaml: str, expected_error: str) -> None:+ # A tag that doesn't survive validation must fail the parse: seeding a silently-different+ # tag (or none) is a scout missing from the product surface that claims it.+ _write_canonical_skill(+ tmp_path,+ dir_name="signals-scout-bar",+ frontmatter=f"---\nname: signals-scout-bar\ndescription: bar skill\n{scout_tags_yaml}\n---\n",+ body="# Bar\n",+ )+ with pytest.raises(CanonicalSkillParseError, match=expected_error):+ discover_canonical_skills(tmp_path)++ def test_rejects_scout_tags_on_companion_skill(self, tmp_path: Path) -> None:+ # A companion skill never gets a config, so there is nothing for its tags to land on.+ _write_canonical_skill(+ tmp_path,+ dir_name="authoring-scouts",+ frontmatter="""+ ---+ name: authoring-scouts+ description: companion authoring guide+ scout-tags:+ - ai-observability+ ---+ """,+ body="# Authoring\n",+ )+ with pytest.raises(CanonicalSkillParseError, match="Only a signals-scout-\\* skill may declare 'scout-tags'"):+ discover_canonical_skills(tmp_path)+def test_parses_bundled_files_under_allowed_subdirs(self, tmp_path: Path) -> None:# `_ALLOWED_BUNDLE_SUBDIRS` is kept in lockstep with `hogli build:skills` —# `references/` and `scripts/` only. `assets/` and any other subdir are intentionally@@ -434,6 +511,13 @@ class TestComputeCanonicalHash:b = _make_canonical("signals-scout-foo", files=f2)assert _compute_canonical_hash(a) != _compute_canonical_hash(b)+ def test_scout_tags_do_not_change_hash(self) -> None:+ # Tags live on the config, not the skill row, so folding them in would leave every+ # seeded row permanently diverged from its stored hash and freeze content updates.+ a = _make_canonical("signals-scout-foo", body="x")+ b = _make_canonical("signals-scout-foo", body="x", config_tags=("ai-observability",))+ assert _compute_canonical_hash(a) == _compute_canonical_hash(b)+def test_canonical_and_row_hashes_agree_when_content_matches(self) -> None:"""When a row's content matches the canonical exactly, the two hashing helpersproduce the same digest. This is the round-trip the sync function depends on."""@@ -900,3 +984,15 @@ class TestSeedCanonicalSkillsAlias(BaseTest):assert loaded.name == "signals-scout-general"assert loaded.version == 1assert "Signals scout" in loaded.body++ def test_real_fleet_scout_tags_land_on_the_seeded_config(self) -> None:+ # The whole path a product surface depends on: `scout-tags` in the in-repo SKILL.md →+ # the tag column the AI observability tab filters its scout list on. No mocking, so+ # dropping the frontmatter key or the seed fails here rather than in the UI.+ seed_canonical_skills(self.team)+ register_missing_configs(self.team.id)++ tagged = SignalScoutConfig.all_teams.get(team=self.team, skill_name="signals-scout-ai-observability")+ assert tagged.tag_list == ["ai-observability"]+ untagged = SignalScoutConfig.all_teams.get(team=self.team, skill_name="signals-scout-general")+ assert untagged.tag_list == []diff --git a/products/signals/skills/AGENTS.md b/products/signals/skills/AGENTS.mdindex 82c2fea4a2ca..d1571b308823 100644--- a/products/signals/skills/AGENTS.md+++ b/products/signals/skills/AGENTS.md@@ -83,6 +83,11 @@ No coordinator-side code change is needed. Use `signals-scout-general` as the teEach scout's body is an instruction set the harness loads verbatim into the system prompt. References (siblings of `SKILL.md`) are progressively disclosed via `Skill.read_file()` from inside the run. Keep the body lean — every line is a recurring token cost on every run — and push detail into references that are only read when needed. Do not hard-wrap scout `SKILL.md` prose at a column width — use semantic line breaks (sentence per line); the body is a prompt, not display text, and column wrapping only adds diff noise.+Frontmatter also carries the optional **`scout-tags`** list — the config tags `register_missing_configs` stamps on the `SignalScoutConfig` it creates for the scout, normalized and capped like a tag typed into the config API.+It is how a canonical scout claims a product surface: AI observability's self-driving tab lists the scouts tagged `ai-observability`, so that tab needs no hardcoded skill name and a scout can change surfaces by editing its frontmatter.+Tags are seeded at creation only — a person who removes one keeps it removed — so adding the key to a scout teams already run leaves their existing configs untagged until someone tags them through the config API.+They sit outside the canonical content hash, since they belong to the config rather than the skill row.+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 one bundled reference:- **`references/conventions.md`** — the four-states author/edit classifier, scratchpad key-prefix vocabulary, and cross-project noise patterns.diff --git a/products/signals/skills/signals-scout-ai-observability/SKILL.md b/products/signals/skills/signals-scout-ai-observability/SKILL.mdindex 92278e423d49..bde4f5a5940b 100644--- a/products/signals/skills/signals-scout-ai-observability/SKILL.md+++ b/products/signals/skills/signals-scout-ai-observability/SKILL.md@@ -14,6 +14,8 @@ compatibility: >allowed_tools:- emit_report- edit_report+scout-tags:+ - ai-observabilitymetadata:owner_team: signalsscope: llm_analytics