: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): broaden catalog-first steering to operational measures (#79821)
Thiago Salvatoreae0f559858ea
diff --git a/products/signals/backend/scout_harness/prompt.py b/products/signals/backend/scout_harness/prompt.pyindex c96fd5c4b991..e6b5a9fdb2b8 100644--- a/products/signals/backend/scout_harness/prompt.py+++ b/products/signals/backend/scout_harness/prompt.py@@ -120,7 +120,7 @@ _HOW_A_RUN_WORKS_HEAD = """# How a run works# Rendered into the head's investigate step only when the team's data catalog is enabled, because# `system.information_schema.metrics` and `data-catalog-metric-run` don't exist for flag-off teams# and unconditioned steering would burn those runs' budget on failing queries.-_METRICS_CATALOG_RULE = """ When a hypothesis rests on a business measure (revenue, MRR, churn, activation), check the governed metrics catalog first – `SELECT name, description, status, is_drifted FROM system.information_schema.metrics` via `execute-sql` – and run an approved, non-drifted match with `data-catalog-metric-run` rather than hand-deriving it, even when your skill body ships its own SQL for that measure: a governed definition outranks a playbook query, and a number derived outside it must be labeled noncanonical. Schema, availability, and freshness checks stay schema-first; no catalog detour for those."""+_METRICS_CATALOG_RULE = """ When a hypothesis rests on a named, reusable measure, business (revenue, MRR, churn, activation) or operational telemetry computed to monitor or report (cost per run, failure or error rates, latency, throughput), check the governed metrics catalog first – `SELECT name, description, status, is_drifted FROM system.information_schema.metrics` via `execute-sql` – and run an approved, non-drifted match with `data-catalog-metric-run` rather than hand-deriving it, even when your skill body ships its own SQL for that measure: a governed definition outranks a playbook query, and a number derived outside it must be labeled noncanonical. Cache the lookup outcome in your scratchpad (`catalog:<scope>:<measure>`, match or no-match plus date) and reuse a fresh entry instead of re-querying every run; re-verify an entry roughly a day old, and immediately when a canonical run reports drift or a status change. Schema, availability, and freshness checks stay schema-first; no catalog detour for those."""def _how_a_run_works_head(*, data_catalog_enabled: bool) -> str:diff --git a/products/signals/skills/authoring-scouts/SKILL.md b/products/signals/skills/authoring-scouts/SKILL.mdindex 6e456318ddcc..eba5fac33340 100644--- a/products/signals/skills/authoring-scouts/SKILL.md+++ b/products/signals/skills/authoring-scouts/SKILL.md@@ -99,7 +99,7 @@ For error tracking it's the `count` vs `distinct_users` ratio; for CSP it's reacYour new scout needs its own.Name it explicitly near the top of the body so every run anchors on it.-A second design rule binds any **metric-shaped scout** — one that scores, ranks, or reports a business measure (MRR, churn risk, usage revenue, activation).+A second design rule binds any **metric-shaped scout** — one that scores, ranks, or reports a named, reusable measure, whether a business measure (MRR, churn risk, usage revenue, activation) or operational telemetry it computes every run to monitor or report (cost per run, failure or error rates, latency, throughput).When the project's metrics catalog is enabled, it may hold a governed definition of that measure in `system.information_schema.metrics`, and the harness tells every run to prefer it — so write the body to cooperate rather than compete: have the run check the catalog for an approved, non-drifted metric before its own derivation, and run a match through `data-catalog-metric-run`.Where a governed metric exists, reference it by name in any `references/queries.md` you ship, and label every hand-written derivation there a noncanonical fallback — an unlabeled "validated query" outranks the harness's catalog-first rule at run time, which is exactly how a scout ends up re-deriving a number the team already governs.Freshness, availability, and schema checks are exempt: they stay schema-first, with no catalog detour.diff --git a/services/mcp/src/templates/sections/metric-discovery-compact.md b/services/mcp/src/templates/sections/metric-discovery-compact.mdindex 01c8ae3b7ebc..98ea44898511 100644--- a/services/mcp/src/templates/sections/metric-discovery-compact.md+++ b/services/mcp/src/templates/sections/metric-discovery-compact.md@@ -1 +1 @@-**Metrics & SQL trust**: for any metric/KPI question, and before writing SQL or joins, run `learn analytics` — the catalog defines governed metrics (`system.information_schema.metrics`), certified tables/views, and verified joins. Check it before insights or raw SQL.+**Metrics & SQL trust**: for any metric question (business KPI or recurring operational measure), and before writing SQL or joins, run `learn analytics` — the catalog defines governed metrics (`system.information_schema.metrics`), certified tables/views, and verified joins. Check it before insights or raw SQL.diff --git a/services/mcp/src/templates/sections/metric-discovery.md b/services/mcp/src/templates/sections/metric-discovery.mdindex 518c78f19ab2..23efa266e4a3 100644--- a/services/mcp/src/templates/sections/metric-discovery.md+++ b/services/mcp/src/templates/sections/metric-discovery.md@@ -1,8 +1,8 @@#### Metric discovery (semantic layer)-Catalog-first for any named business measure or KPI (revenue-, growth-, engagement-, conversion-shaped numbers, e.g. MRR, activation, retention), including rankings/breakdowns/comparisons. Synonyms and derived forms (e.g. an annualized variant of a stored metric) still route here; label derivations noncanonical. Raw event/property exploration stays schema-first.+Catalog-first for any named, reusable measure, business or operational: KPIs (MRR, activation, retention) and monitored telemetry (cost per run, failure or error rate, latency), including rankings/breakdowns/comparisons. Synonyms and derived forms (e.g. an annualized variant of a stored metric) still route here; label derivations noncanonical. One-off exploration and debugging aggregates stay schema-first.-This takes precedence over 'Retrieving data' below: for metric/KPI questions, check the catalog before any `query-*` or `execute-sql` call, even when the question maps to a supported insight type.+This takes precedence over 'Retrieving data' below: for metric questions, check the catalog before any `query-*` or `execute-sql` call, even when the question maps to a supported insight type.Before data calls, search `name`, `display_name`, and `description` with terms/synonyms. `exec search` finds tools, not catalog rows.