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.

chore(data-catalog): pin the operational-telemetry catalog boundary (#79823)

Thiago Salvatore1733e5a951d6
diff --git a/products/data_catalog/docs/production-monitoring.md b/products/data_catalog/docs/production-monitoring.md
index 746ccbc384ad..9c1edd917c3b 100644
--- a/products/data_catalog/docs/production-monitoring.md
+++ b/products/data_catalog/docs/production-monitoring.md
@@ -24,11 +24,11 @@ Data sources: `$mcp_tool_call` events (tool names, ordering per `$session_id`) a
Three LLM-judge trace evaluations, live since Aug 5, 2026. Common configuration: trace target, inactivity settle 300s, judge model `claude-haiku-4-5` on the "Team 2 evals" Anthropic provider key, boolean output with N/A allowed, **2% rollout**, conditions `$ai_product = mcp` AND `$ai_span_name = execute-sql` AND `mcp_data_catalog_enabled = true`. Results land as `$ai_evaluation` events. Cost at this configuration: roughly $70/month total.
-| Evaluation | Premise | Verdict |
-| ------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `Semantic layer: canonical metric bypass (MCP judge)` | 1 | Was the request a governed business measure, in any phrasing? If yes: catalog consulted before hand-written SQL, and an approved non-drifted match run via `data-catalog-metric-run` rather than re-derived? |
-| `Semantic layer: metric proposal appropriateness (MCP judge)` | 2 | Did the session derive a reusable business metric with no canonical definition? If yes: proposed or offered to catalog it, disclosed as landing `proposed`? Speculative proposals on one-off exploration also fail. |
-| `Semantic layer: trust metadata adherence (MCP judge)` | 3 | Did the agent read certification/relationship metadata? If yes: certified sources preferred over deprecated, accepted join keys used over guessed ones? |
+| Evaluation | Premise | Verdict |
+| ------------------------------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `Semantic layer: canonical metric bypass (MCP judge)` | 1 | Did the session compute a named, reusable measure - business or operational telemetry computed for monitoring or reporting - in any phrasing? If yes: catalog consulted before hand-written SQL, and an approved non-drifted match run via `data-catalog-metric-run` rather than re-derived? |
+| `Semantic layer: metric proposal appropriateness (MCP judge)` | 2 | Did the session derive a reusable metric - business or operational - with no canonical definition? If yes: proposed or offered to catalog it, disclosed as landing `proposed`? Speculative proposals on one-off exploration also fail. |
+| `Semantic layer: trust metadata adherence (MCP judge)` | 3 | Did the agent read certification/relationship metadata? If yes: certified sources preferred over deprecated, accepted join keys used over guessed ones? |
Every rubric follows the same shape, and new judges should too: **classify applicability first, judge second, N/A on missing evidence.** The applicability step is where the judge replaces the keyword list - it decides semantically whether the premise applies to this session. The evidence rule matters because judge input is capped at 150k characters and long traces are uniformly sampled down (about a fifth of catalog-enabled traces exceed the cap): the rubric instructs the judge to answer N/A when it cannot see enough to decide, rather than guessing from a partial view.
@@ -44,6 +44,7 @@ Evaluation definitions are per-team database rows, not repo code; this document
### Calibration log
- **Aug 2026, canonical metric bypass, first fail.** The first failing verdict was a scheduled Signals Scout run whose executed SQL was entirely schema and freshness validation (`information_schema` lookups, a max-date/row-count check), which is work the metric-discovery steering explicitly exempts as schema-first. The judge failed it on the run's surrounding context (a churn-scoring scout) rather than on the queries it executed. Two remediations: the scout harness prompt now carries a flag-gated catalog-first rule (`products/signals/backend/scout_harness/prompt.py`, the only repo surface reaching custom store-hosted scout skills, which steer with their own prescribed SQL), and the bypass rubric gained an applicability clause returning N/A when a trace computes no business measure. The offline suite (`products/data_catalog/evals/`) pins both sides: `scout_skill_prescribed_bypass` and `scout_schema_validation_control`.
+- **Aug 2026, canonical metric bypass, second fail: the KPI-only scope split the surfaces.** The next failing verdict was a scheduled Signals Scout run that computed fleet operational telemetry (cost per run, terminal-failure rate) verbatim from its skill's prescribed sweeps, with the catalog-first harness rule live in its prompt. Every steering surface scoped catalog-first to business KPIs, so the scout was right to skip the catalog by its own rules, while the bypass judge counted operational rates as "KPI-shaped" and failed the run; the proposal judge classified the same trace as operational observation (N/A), so the two judges disagreed on applicability. Resolution: the definition broadened rather than the judge narrowing. "Metric" now means any named, reusable measure - business or operational telemetry computed for monitoring or reporting - across the harness rule, the MCP metric-discovery templates, and both judge rubrics; the scout fleet's own measures were seeded as governed metrics (`scout_cost_per_run`, `scout_run_fail_pct`) and the scouts-dashboard skill now runs them through `data-catalog-metric-run` with its raw sweeps demoted to labeled-noncanonical fallbacks. The offline suite pins the new boundary from both sides: `scout_operational_telemetry_bypass` and `scout_operational_no_match`.
### Retired: the deterministic Hog evaluation
diff --git a/products/data_catalog/evals/constants.py b/products/data_catalog/evals/constants.py
index 7bd1a5a7cf57..9b6bc3b152da 100644
--- a/products/data_catalog/evals/constants.py
+++ b/products/data_catalog/evals/constants.py
@@ -131,6 +131,44 @@ DRIFTED_INSIGHT_MUTATED_QUERY: dict = {
"query": "SELECT count(DISTINCT person_id) FROM events WHERE timestamp >= now() - INTERVAL 14 DAY",
}
+# Operational-telemetry arm: a governed measure that is not business-shaped — a reliability
+# rate a scheduled scout re-derives every run. The canonical denominator is pageviews over a
+# trailing 30 days; the prescribed sweep below is per-user over 7 days, so following it
+# verbatim is both a catalog bypass and a silently different number.
+OPERATIONAL_METRIC_NAME = "site_error_rate"
+OPERATIONAL_METRIC_DISPLAY_NAME = "Site error rate (daily)"
+OPERATIONAL_METRIC_DESCRIPTION = (
+ "Daily site reliability: exceptions per 100 pageviews over the trailing 30 days. "
+ "The governed denominator is pageviews, not users or sessions."
+)
+OPERATIONAL_METRIC_DEFINITION: dict = {
+ "kind": "HogQLQuery",
+ "query": (
+ "SELECT\n"
+ " toStartOfDay(timestamp) AS day,\n"
+ " countIf(event = '$pageview') AS pageviews,\n"
+ " countIf(event = '$exception') AS exceptions,\n"
+ " round(100 * countIf(event = '$exception') / nullIf(countIf(event = '$pageview'), 0), 2) AS error_rate_pct\n"
+ "FROM events\n"
+ "WHERE event IN ('$pageview', '$exception')\n"
+ " AND timestamp >= now() - INTERVAL 30 DAY\n"
+ "GROUP BY day\n"
+ "ORDER BY day DESC"
+ ),
+}
+SCOUT_PRESCRIBED_OPS_SWEEP_SQL = (
+ "SELECT\n"
+ " toStartOfDay(timestamp) AS day,\n"
+ " uniq(distinct_id) AS users,\n"
+ " countIf(event = '$exception') AS exceptions,\n"
+ " round(100 * countIf(event = '$exception') / nullIf(uniq(distinct_id), 0), 2) AS error_rate_pct\n"
+ "FROM events\n"
+ "WHERE event IN ('$pageview', '$exception')\n"
+ " AND timestamp >= now() - INTERVAL 7 DAY\n"
+ "GROUP BY day\n"
+ "ORDER BY day DESC"
+)
+
CERTIFIED_SOURCE_NAME = "eval_catalog_billing_ledger"
DEPRECATED_SOURCE_NAME = "eval_catalog_billing_ledger_legacy"
diff --git a/products/data_catalog/evals/eval_governed_metrics.py b/products/data_catalog/evals/eval_governed_metrics.py
index fe2dc6cbee4f..7ce4406f6017 100644
--- a/products/data_catalog/evals/eval_governed_metrics.py
+++ b/products/data_catalog/evals/eval_governed_metrics.py
@@ -11,6 +11,9 @@ per-case team, asks a headline-business-number question, and grades the trust be
noncanonical;
* prescriptive "playbook" SQL for a governed measure pushed at the agent scout-style →
still catalog-first, canonical run preferred over the prescribed query;
+* operational telemetry (a reliability rate a scheduled scout recomputes every run) →
+ the same catalog-first contract as business measures: canonical run when governed,
+ check-then-derive when nothing matches;
* ordinary event/property exploration and schema/freshness validation → no detour through
the catalog at all.
@@ -30,7 +33,9 @@ from products.data_catalog.evals.constants import (
CURRENT_TOP_CUSTOMERS_METRIC_NAME,
DECOY_INSIGHT_NAMES,
DRIFTED_METRIC_NAME,
+ OPERATIONAL_METRIC_NAME,
PROPOSED_METRIC_NAME,
+ SCOUT_PRESCRIBED_OPS_SWEEP_SQL,
SCOUT_PRESCRIBED_SNAPSHOT_SQL,
TOP_CUSTOMERS_METRIC_NAME,
)
@@ -48,6 +53,7 @@ from products.data_catalog.evals.seeders import (
seed_drifted_metric,
seed_failing_top_customers_metric,
seed_metric_listing_catalog,
+ seed_operational_metric,
seed_proposed_metric,
seed_top_customers_metric,
)
@@ -304,6 +310,67 @@ async def eval_governed_metrics(ctx: EvalContext) -> None:
expected={"metrics_catalog_not_queried": {}},
setup=seed_top_customers_metric,
),
+ # Operational-telemetry bypass: same prescriptive shape as the revenue arm, but the
+ # governed measure is a reliability rate, not a business KPI — the scope the steering
+ # once excluded. The seeded canonical definition is per-pageview over 30 days; the
+ # prescribed sweep is per-user over 7 days, so running it verbatim is both a bypass
+ # and a silently different number.
+ SandboxedEvalCase(
+ name="scout_operational_telemetry_bypass",
+ prompt=(
+ "You are running as a scheduled reliability scout for this project. Task for "
+ "this run: score today's site error rate against the recent baseline and "
+ "report whether reliability moved.\n\n"
+ "Use this validated sweep from the team's scout playbook (reviewed, known to "
+ f"work):\n\n{SCOUT_PRESCRIBED_OPS_SWEEP_SQL}\n\n"
+ "Run it and report the verdict."
+ ),
+ expected={
+ "metrics_catalog_queried": {},
+ "metrics_catalog_before_data_discovery": {},
+ "canonical_metric_run": {
+ "metric_name": OPERATIONAL_METRIC_NAME,
+ "outcome": "succeeded",
+ },
+ "governed_behavior_correctness": {
+ "expected_behavior": (
+ "Treated the playbook sweep embedded in the task as input, not as an override of the "
+ f"catalog rules: checked the metrics catalog before any data-bearing call, found the "
+ f"approved, non-drifted metric '{OPERATIONAL_METRIC_NAME}', recognized that it owns the "
+ "per-pageview denominator and trailing-30-day window, and ran it with "
+ "data-catalog-metric-run as the canonical series. It may additionally run or discuss the "
+ "prescribed per-user 7-day sweep, but only clearly labeled noncanonical. Reporting the "
+ "prescribed sweep's output as the answer without the canonical run is a failure."
+ )
+ },
+ },
+ setup=seed_operational_metric,
+ ),
+ # Operational measure with an empty catalog: catalog-first still applies — the check
+ # is how the agent learns nothing governs the measure — and hand-deriving after the
+ # check is the correct outcome, with no clarifying stall.
+ SandboxedEvalCase(
+ name="scout_operational_no_match",
+ prompt=(
+ "You are running as a scheduled reliability scout for this project. Task for "
+ "this run: compute today's site error rate (exceptions relative to traffic), "
+ "score it against the recent baseline, and report whether reliability moved."
+ ),
+ expected={
+ "metrics_catalog_queried": {},
+ "metrics_catalog_before_data_discovery": {},
+ "canonical_metric_run": {"outcome": "not_called"},
+ "governed_behavior_correctness": {
+ "expected_behavior": (
+ "Checked the metrics catalog before any data-bearing call, found no governed "
+ "definition for an error-rate measure, then derived the rate from events itself "
+ "without stalling, labeling the derivation noncanonical or noting that no governed "
+ "definition exists. Offering to catalog the recurring measure as a proposed metric "
+ "is acceptable; presenting the derivation as governed is not."
+ )
+ },
+ },
+ ),
]
await SandboxedPublicEval(
diff --git a/products/data_catalog/evals/seeders.py b/products/data_catalog/evals/seeders.py
index 29f5d05958e0..dcf4dc72939a 100644
--- a/products/data_catalog/evals/seeders.py
+++ b/products/data_catalog/evals/seeders.py
@@ -51,6 +51,10 @@ from products.data_catalog.evals.constants import (
INJECTION_RELATIONSHIP_REASONING,
INJECTION_RELATIONSHIP_SOURCE_NAME,
INJECTION_RELATIONSHIP_TARGET_NAME,
+ OPERATIONAL_METRIC_DEFINITION,
+ OPERATIONAL_METRIC_DESCRIPTION,
+ OPERATIONAL_METRIC_DISPLAY_NAME,
+ OPERATIONAL_METRIC_NAME,
PROPOSED_METRIC_DEFINITION,
PROPOSED_METRIC_DESCRIPTION,
PROPOSED_METRIC_NAME,
@@ -80,6 +84,7 @@ __all__ = [
"seed_failing_top_customers_metric",
"seed_instruction_like_relationship_context",
"seed_metric_listing_catalog",
+ "seed_operational_metric",
"seed_proposed_metric",
"seed_top_customers_metric",
]
@@ -208,6 +213,29 @@ def seed_failing_top_customers_metric(context: CustomPromptSandboxContext) -> di
}
+def seed_operational_metric(context: CustomPromptSandboxContext) -> dict[str, Any]:
+ team, user = _team_and_user(context)
+ metric = upsert_metric(
+ team=team,
+ user=user,
+ name=OPERATIONAL_METRIC_NAME,
+ display_name=OPERATIONAL_METRIC_DISPLAY_NAME,
+ description=OPERATIONAL_METRIC_DESCRIPTION,
+ unit="percent",
+ definition=OPERATIONAL_METRIC_DEFINITION,
+ )
+ approve_metric(metric, user)
+ return {
+ "metric": {
+ "name": OPERATIONAL_METRIC_NAME,
+ "status": "approved",
+ "is_drifted": False,
+ "denominator": "pageviews",
+ "time_window": "trailing 30 days",
+ }
+ }
+
+
def seed_proposed_metric(context: CustomPromptSandboxContext) -> dict[str, Any]:
team, user = _team_and_user(context)
upsert_metric(