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.

fix(signals): verify central report impact measurements (#116221)

Georgiy Tarasov111bd6781593
diff --git a/docs/internal/signals-pr-lifecycle.md b/docs/internal/signals-pr-lifecycle.md
index 5c4303911902..8197518bd27c 100644
--- a/docs/internal/signals-pr-lifecycle.md
+++ b/docs/internal/signals-pr-lifecycle.md
@@ -27,6 +27,12 @@ It also skips a plan that carries its own open, draft, or unknown PR, because th
## Follow-up checks
+Scout and research guidance asks for a verified live observation metric when a central quantitative claim comes from events.
+A count can justify a metric without a chart or a change over time.
+The metric must match the finding's filters, population, exclusions, window, and aggregation.
+When no useful supported metric can measure that claim, the summary states the specific limitation in one short sentence.
+Qualitative findings can omit metrics.
+
Research writes measurable outcome goals as `metric_threshold` report checks and investigative goals as `agent` checks. A metric check stores a bounded live query, baseline, comparison, and soak window; the query and display format are copied from its report metric when it names one. The check waits for the report to resolve, then the coordinator runs it and records a verdict. Metric checks keep the configured soak separate from their query window and wait until that full window contains only post-resolution data. Each run pins absolute query bounds to avoid reusing a pre-resolution cached result. Reopening clears the measurement start; the next resolution starts it again. Existing active metric checks without a recorded start begin their window at the first coordinator tick. New metric checks validate count, rate, duration, baseline, and threshold values using the same rules as report metrics; existing configurations remain readable. A later research pass reviews every open check, preserves unchanged checks and their approvals, replaces changed checks, and retires omitted checks. A failed verification turn leaves existing checks alone. Verification can revise only Expected impact; other summary sections and their chart links must remain intact. The full replacement schedule, including its soak and measurement window, must finish before the 90-day horizon. The Follow-up checks sidebar shows schedules and results for both kinds. The Expected impact section uses the same metric checks to show goals and charts, behind the person-level `signals-expected-impact` display flag. A person can mark those measurements "Looks good" as a quality signal; approval does not control scheduling or execution. The "Suggest different metrics" action starts a discussion that can atomically replace relevant open metric checks while preserving unrelated checks. A failed replacement leaves the original running, and a successful replacement starts unapproved. Report observation metrics remain separate from these forward-looking checks.
Reports awaiting human input also retain their generated checks, pending resolution. Pending sidebar rows show the minimum wait after resolution. Metric replacements require access to the query they schedule and preserve the remaining recurring runs and soak duration, including zero minutes. Replacement cannot override the soak. Creation and replacement share full schedule validation against the 90-day horizon. A replacement rejects a check moved by a concurrent report merge; reload the report and retry on the survivor. Units cannot contain null characters or unpaired Unicode surrogates. The Expected impact section shows finished verdicts and refreshes after agent tasks change checks.
diff --git a/products/signals/backend/report_generation/research.py b/products/signals/backend/report_generation/research.py
index 14fde9072b75..d27a8255b79d 100644
--- a/products/signals/backend/report_generation/research.py
+++ b/products/signals/backend/report_generation/research.py
@@ -841,6 +841,9 @@ _REPORT_METRICS_GUIDANCE = f"""## Measuring impact
Put reproducible report-level measurements under `metrics`. A metric tells the reader how many people, sessions, occurrences, conversions, errors, milliseconds, or dollars the observation affects. Use at most one `primary` metric for the key observation and `supporting` metrics for the compact impact facts around it. Every metric needs a bounded live query; its saved snapshot is only an optional cached fallback.
+- Attach a verified `primary` metric for the main quantitative claim from events, including a single count. A chart is not required. For SQL evidence, run an equivalent supported Trends query before attaching it.
+- Match the claim's filters, population, exclusions, window, and aggregation. Do not use project totals for one issue, event ratios for user funnels, or exposure as confirmed harm.
+- If no useful supported metric can measure the claim, explain why in one short summary sentence. Keep the useful report. Qualitative findings can omit metrics.
- **Choose the kind by what the reader will ask.**
- `affected_users` for anything a person experiences: a captured exception with person context, a dead click, a rage click, a failed request on a surface, or a pageview matching a broken URL. One series, `math: "dau"`.
- `affected_sessions` when the source establishes sessions but not people. Use exactly one event or action series with `math: "unique_session"`. Do not use a formula or group math.
diff --git a/products/signals/backend/scout_harness/prompt.py b/products/signals/backend/scout_harness/prompt.py
index b8c4d79f7b7b..0add4b9a7283 100644
--- a/products/signals/backend/scout_harness/prompt.py
+++ b/products/signals/backend/scout_harness/prompt.py
@@ -631,6 +631,9 @@ _REPORT_METRICS = f"""# Measuring report impact
`metrics` on the report tools carries the small set of typed measurements that tell a reader what the observation changes and how many people it affects. Use one `primary` metric for the key observation and the rest as `supporting` facts. Every metric needs a bounded live query; its saved snapshot is only an optional cached fallback. Omit a metric you cannot measure honestly rather than guessing. A weak number is worse than none: a single support ticket, a one-off migration crash, a rate over a handful of attempts, or a count with no person context tells the reader nothing, so a report with no metric beats a report with a weak metric.
+- Attach a verified `primary` metric for the main quantitative claim from events, including a single count. A chart is not required. For SQL evidence, run an equivalent supported Trends query before attaching it.
+- Match the claim's filters, population, exclusions, window, and aggregation. Do not use project totals for one issue, event ratios for user funnels, or exposure as confirmed harm.
+- If no useful supported metric can measure the claim, explain why in one short summary sentence. Keep the useful report. Qualitative findings can omit metrics.
- **Choose the kind by what the reader will ask.**
- `affected_users` for anything a person experiences: a captured exception with person context, a dead click, a rage click, a failed request on a surface, or a pageview matching a broken URL. One series, `math: "dau"`.
- `affected_sessions` when the source establishes sessions but not people. Use exactly one event or action series with `math: "unique_session"`. Do not use a formula or group math.