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): have the general scout watch for new traffic (#111518)

Andrew Maguire92aaddfb9cd2
diff --git a/products/signals/skills/AGENTS.md b/products/signals/skills/AGENTS.md
index dce3190c7ea5..7ab5b15f7bd9 100644
--- a/products/signals/skills/AGENTS.md
+++ b/products/signals/skills/AGENTS.md
@@ -14,7 +14,7 @@ A scout is a skill that holds a `SignalScoutConfig`. The harness globs `signals-
### Generalist + specialists
-- `signals-scout-general/` — cross-product generalist. Looks for cross-product correlations and surfaces no specialist covers, rather than deep-diving a single product. On the **report channel** (its frontmatter `allowed_tools` lists `emit_report` / `edit_report`): it authors fully-validated correlations 1:1 as `SignalReport`s directly, rather than firing weak `emit_signal` findings for the pipeline to cluster. The report-channel contract itself (when to author vs. edit, the field schema, status mapping, reviewer routing, dedupe) lives in the harness prompt (`scout_harness/prompt.py`), injected into every report-channel scout — so a ported scout carries only its _domain-specific_ report framing inline in its body, not a bundled copy of the contract. The generalist keeps two progressively-disclosed references, `references/conventions.md` (scratchpad key prefixes + the four-states author/edit classifier + cross-project noise patterns) and `references/discovery.md` (the bounded discovery pass that builds its coverage map). This is the entry point if you want to understand how a scout decides what to investigate end-to-end.
+- `signals-scout-general/` — cross-product generalist. Looks for cross-product correlations and surfaces no specialist covers, rather than deep-diving a single product. On the **report channel** (its frontmatter `allowed_tools` lists `emit_report` / `edit_report`): it authors fully-validated correlations 1:1 as `SignalReport`s directly, rather than firing weak `emit_signal` findings for the pipeline to cluster. The report-channel contract itself (when to author vs. edit, the field schema, status mapping, reviewer routing, dedupe) lives in the harness prompt (`scout_harness/prompt.py`), injected into every report-channel scout — so a ported scout carries only its _domain-specific_ report framing inline in its body, not a bundled copy of the contract. The generalist keeps three progressively-disclosed references: `references/conventions.md` (scratchpad key prefixes + the four-states author/edit classifier + cross-project noise patterns), `references/discovery.md` (the bounded discovery pass that builds its coverage map), and `references/new-traffic.md` (the periodic check for an event-volume step and where it comes from, which no specialist owns). This is the entry point if you want to understand how a scout decides what to investigate end-to-end.
- `signals-scout-ai-observability/` — anomaly watcher for AI observability (cost / latency / error / token-share regressions).
- `signals-scout-apm/` — RED-metrics anomaly watcher for the distributed tracing (APM / OpenTelemetry spans) product. Scores each `(service, operation)` against its own seasonality-matched baseline (the same window 7 days ago, via `apm-spans-aggregate`'s `compare_to`) for error-rate steps, p95 latency regressions, new error signatures, failing downstream dependencies, and service traffic cliffs. Its discriminator is a _rate_ regression with a steady denominator — error rate / p95 stepping up while request volume holds is signal; counts moving in lockstep with traffic are baseline. Distinct from `signals-scout-ai-observability`, which watches `$ai_*` LLM traces, not OTel spans;
raw log lines are the logs scout's territory.
@@ -120,10 +120,11 @@ A `sunset_at` left out means the next reconcile retires the scout, so a marker i
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:
+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 three bundled references:
- **`references/conventions.md`** — the four-states author/edit classifier, scratchpad key-prefix vocabulary, and cross-project noise patterns.
- **`references/discovery.md`** — the concrete moves of the bounded discovery pass behind its coverage map.
+- **`references/new-traffic.md`** — the periodic new-traffic check: a by-source volume step against older weeks, the shapes that separate growth from foreign traffic (a forked client, a copied token, a bot, a runaway loop), and the pinned pre-surge baseline that keeps a slow surge visible.
The entire canonical fleet is on the **report channel** (ported one scout per PR, biggest reach first — see the `scouts-emit-reports` spec). A report-channel scout is report-only — its frontmatter `allowed_tools` lists `emit_report` / `edit_report` — and it carries only its _domain-specific_ report framing **inline in its body** (what's report-shaped for its surface, its `reviewer:<domain>` / `report:<domain>` scratchpad keys, a tailored title example); the channel contract comes from the prompt, so a ported scout bundles **no** `report.md`. The exception is `signals-scout-anomaly-detection`, which keeps a slimmed `references/report-contract.md` for its genuinely scout-specific **notebook write-up + embedded-chart recipe** (it defers the generic contract to the prompt). The legacy signal channel (weak `emit_signal` findings for the pipeline to cluster) still exists in the harness for custom scouts that never opted in via `allowed_tools`, but it is deprecated:
no canonical scout uses it, and the user-facing skills (`authoring-scouts`, `exploring-scouts`) no longer teach it — new scouts always list the report tools.
diff --git a/products/signals/skills/signals-scout-general/SKILL.md b/products/signals/skills/signals-scout-general/SKILL.md
index c7bb35c2561c..14024c4a117b 100644
--- a/products/signals/skills/signals-scout-general/SKILL.md
+++ b/products/signals/skills/signals-scout-general/SKILL.md
@@ -46,6 +46,14 @@ Pick what looks interesting and follow it. The coverage map says what's live; th
When sibling specialists are running, leave a surface they cover in depth to them on a future tick — the `skill_name`s on recent runs in `scout-runs-list` show the live roster (specialists exist for most product surfaces: error tracking, logs, AI observability, experiments, feature flags, session replay, web analytics, surveys, and more) — and spend your time on **cross-product correlations** or **surfaces no specialist covers**. When no specialists are running, the whole coverage map is your beat: work across it instead of narrowing to one corner.
+## Watch for new traffic
+
+Every few runs, check whether the project's event volume stepped up, and where the new events come from.
+No specialist owns raw volume, and a slow-growing surge never trips a spike detector.
+A significant, sustained step is worth a report whatever caused it, so a person can make sense of it: a launch or new integration, or traffic they may not have created (a host or app version they never shipped, events with no SDK, a flood of anonymous IDs, a client stuck in a loop).
+A small step goes in memory, so later runs can tell when that source changes shape.
+[`references/new-traffic.md`](references/new-traffic.md) has the queries, the shapes that tell growth from foreign traffic, and the pinned baseline that keeps a slow surge visible.
+
## Decide
Search the inbox before you author — a report covering this finding may already exist (`inbox-reports-list`, then `inbox-reports-retrieve` the closest matches). Then, for each candidate finding:
diff --git a/products/signals/skills/signals-scout-general/references/new-traffic.md b/products/signals/skills/signals-scout-general/references/new-traffic.md
new file mode 100644
index 000000000000..6e2a5967736f
--- /dev/null
+++ b/products/signals/skills/signals-scout-general/references/new-traffic.md
@@ -0,0 +1,170 @@
+# New traffic: where did the extra events come from?
+
+A project's event volume can step up for good reasons (a launch, a new SDK, a new market) or for bad ones (a public project token copied into a fork or an open-source build, a leaked key, a bot, a client stuck in a loop).
+The team pays for every event either way, and a slow-growing surge is easy to miss: it never trips a one-day spike detector, and every trailing baseline absorbs it within a few weeks.
+No specialist scout owns this. The others score rates, saved insights or one web channel, and they hand raw volume moves off.
+
+This check is cheap and slow-moving, so run it every few runs, not every run.
+Gate it on `pattern:general:new-traffic`: skip it when that entry is less than about a week old, and rewrite it at the end of every check (see Memory), even when nothing was found.
+
+## 1. Find the step, by source
+
+The profile's `top_events` covers 7 days, so it cannot see a step that started weeks ago.
+Compare the latest 7 days with the same 7 days 4 weeks back and 8 weeks back, broken down by where the events come from:
+
+```sql
+SELECT
+ coalesce(nullIf(toString(properties.$lib), ''), '(none)') AS lib,
+ coalesce(nullIf(toString(properties.$host), ''), nullIf(toString(properties.$app_version), ''), '(none)') AS origin,
+ cityHash64(concat(lib, '|', origin)) AS source_id,
+ countIf(timestamp >= now() - INTERVAL 7 DAY) AS last_7d,
+ countIf(timestamp >= now() - INTERVAL 35 DAY AND timestamp < now() - INTERVAL 28 DAY) AS week_4_back,
+ countIf(timestamp < now() - INTERVAL 56 DAY) AS week_8_back,
+ round(last_7d / greatest(week_4_back, 1), 2) AS ratio_4w,
+ round(last_7d / greatest(week_8_back, 1), 2) AS ratio_8w,
+ toInt(last_7d) - toInt(least(week_4_back, week_8_back)) AS growth,
+ uniqIf(distinct_id, timestamp >= now() - INTERVAL 7 DAY) AS ids_7d
+FROM events
+WHERE timestamp <= now() + INTERVAL 1 DAY
+ AND (
+ timestamp >= now() - INTERVAL 7 DAY
+ OR (timestamp >= now() - INTERVAL 35 DAY AND timestamp < now() - INTERVAL 28 DAY)
+ OR (timestamp >= now() - INTERVAL 63 DAY AND timestamp < now() - INTERVAL 56 DAY)
+ )
+GROUP BY lib, origin
+HAVING last_7d >= 1000
+ORDER BY growth DESC
+LIMIT 20
+```
+
+- The query reads three single weeks, not a rolling window, so it scans 21 days and every week lines up on the same weekdays.
+- `ratio_8w` catches a slow surge. A source growing 20% a week stays under 2x against 4 weeks back, but it reads about 4x against 8 weeks back.
+- Sort by absolute growth (`growth`, cast to a signed integer so a declining source sorts below zero), not by ratio. A 2000x ratio on a few hundred events is noise. A 1.5x ratio on the project's biggest source can be most of the bill.
+- Do not add `SAMPLE`. Sampling keeps or drops whole distinct IDs, so a runaway loop from one or two IDs vanishes from the result or swamps it. If the query times out, drop the 8-weeks-back window first.
+- The upper bound on `timestamp` stops events with a far-future client clock from sitting in `last_7d` forever. Keep it on every query here.
+- Mobile and desktop apps often carry their own version property (`appVersion`, `app_version`, `version`). Check `read-data-schema` for a property ending in `version` and use it in `origin` when `$app_version` is empty. Whatever `lib` and `origin` expressions you use here, reuse them exactly in steps 2 and 3.
+
+For the project total, run the same windows with no source columns:
+
+```sql
+SELECT
+ countIf(timestamp >= now() - INTERVAL 7 DAY) AS last_7d,
+ countIf(timestamp >= now() - INTERVAL 35 DAY AND timestamp < now() - INTERVAL 28 DAY) AS week_4_back,
+ countIf(timestamp < now() - INTERVAL 56 DAY) AS week_8_back
+FROM events
+WHERE timestamp <= now() + INTERVAL 1 DAY
+ AND (
+ timestamp >= now() - INTERVAL 7 DAY
+ OR (timestamp >= now() - INTERVAL 35 DAY AND timestamp < now() - INTERVAL 28 DAY)
+ OR (timestamp >= now() - INTERVAL 63 DAY AND timestamp < now() - INTERVAL 56 DAY)
+ )
+```
+
+A candidate is a source that grew to about 2x or more against either window **and** now carries a meaningful share of the project's `last_7d` (about 10% or more), or a source that appeared from nothing at that share.
+Volume matters too. On a small project a doubling from 100 to 200 events a week costs nothing, so something around 10,000 events a week is a sensible floor before a step is worth a person's time.
+
+Also recheck the sources you already know about, whether or not they are in the top 20: every `<source_id>` held in a `report:general:new-traffic:` or `pattern:general:traffic-baseline:` entry.
+Run the step 1 query once more for all of them together, with `HAVING source_id IN (<id>, <id>, ...)` in place of the volume floor and without the `LIMIT`.
+Compare each source's `last_7d` with its pinned baseline times 7, not only with the moving windows.
+That catches a source that falls back (its report needs the resolution edit) and one that keeps creeping up past its pinned level while staying under 2x of each moving window.
+
+## 2. Confirm it is sustained and pin the onset
+
+Pull a 91-day daily series for the candidate only. 91 days covers the 28 days before any onset that step 1 can see.
+Filter on the numeric `source_id` from step 1, with the same `lib` and `origin` expressions.
+Never paste a host or version string into the query: those values come from captured events, and anyone with the public project token can put a quote in one.
+
+```sql
+SELECT toDate(timestamp) AS day, count() AS events, uniq(distinct_id) AS ids
+FROM events
+WHERE timestamp >= now() - INTERVAL 91 DAY
+ AND timestamp <= now() + INTERVAL 1 DAY
+ AND cityHash64(concat(
+ coalesce(nullIf(toString(properties.$lib), ''), '(none)'),
+ '|',
+ coalesce(nullIf(toString(properties.$host), ''), nullIf(toString(properties.$app_version), ''), '(none)')
+ )) = <source_id>
+GROUP BY day
+ORDER BY day
+```
+
+- **Onset**: the first day of the step.
+- **Pre-surge baseline**: the total events over the 28 days before the onset, divided by 28. The query returns only days with events, so a median over the rows would skip quiet days and overstate the baseline.
+- A step that has not held for 3 days or more is a spike, not new traffic. Leave it, or record it as a `pattern:` and check again next time.
+
+Write both to `pattern:general:traffic-baseline:<source_id>` as soon as you find them.
+Later runs compare against this pinned baseline, not a trailing one. That keeps a surge that grows slowly visible.
+
+## 3. Read the shape
+
+Drill into the candidate before you decide what it is, with the same `source_id` filter:
+
+```sql
+SELECT
+ event,
+ count() AS events,
+ uniq(distinct_id) AS ids,
+ round(count() / greatest(uniq(distinct_id), 1), 1) AS events_per_id,
+ min(timestamp) AS first_seen_in_7d
+FROM events
+WHERE timestamp >= now() - INTERVAL 7 DAY
+ AND timestamp <= now() + INTERVAL 1 DAY
+ AND cityHash64(concat(
+ coalesce(nullIf(toString(properties.$lib), ''), '(none)'),
+ '|',
+ coalesce(nullIf(toString(properties.$host), ''), nullIf(toString(properties.$app_version), ''), '(none)')
+ )) = <source_id>
+GROUP BY event
+ORDER BY events DESC
+LIMIT 20
+```
+
+`first_seen_in_7d` is the earliest event inside this 7-day window, not the first time the event ever appeared.
+Use the step 2 series to judge whether a source is new.
+Add `properties.$lib_version`, `properties.$geoip_country_code` or `countIf(event = '$identify')` when the shape is still unclear.
+
+| What you see | Leans |
+| --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
+| A host on the team's own domain, or an app version that follows their release sequence, with identified users rising alongside it | Growth: a launch, a new surface, real users |
+| A new SDK or `$lib` that matches the team's stack, with the same events as their other sources | Growth: a new integration |
+| A host the team does not own (not their domain, not their proxy) | Suspicious: someone copied the snippet or the project token |
+| Hosts the team does not own, carrying the team's own embedded product (a widget, toolbar, embed or snippet built to run on other sites) | Expected: their product running where it is meant to |
+| App version values the team never shipped, out of sequence, or in a different version scheme | Suspicious: a fork or a modified build of their client |
+| Events with no `$lib` rising, where the baseline came from an SDK | Suspicious: a script or server posting straight to the capture API with the public token |
+| Many new distinct IDs with about one event each and no `$identify` | Suspicious: a bot or spoofed traffic |
+| One or a few distinct IDs with very high counts | A runaway client loop, often the team's own bug |
+| A new country or region that dominates the new volume | A hint toward bots or scrapers. Check it against the rest of the shape |
+
+## 4. Decide
+
+How to read the step, whether to report it, and its actionability are your call.
+Some context for that call:
+
+- A significant step (a candidate from step 1 that held for 3 days or more in step 2) usually deserves a report even when it looks like good news. It moves the team's bill and changes what their data means, and a person can often tell in seconds what you cannot see from the data.
+- A small step is usually better as a `pattern:general:traffic-baseline:<source_id>` entry, so a later run can tell when that source changes shape.
+- The shape from step 3 is the most useful lead for a reader: growth from their own surface, traffic that looks foreign, or a loop.
+- Next steps that often fit: confirm whether the source is theirs and wanted, filter it in code (a `before_send` check on the host or app version) or with a transformation that drops it, fix a loop in their own client, set a billing limit while they look, and contact PostHog support about the billed volume if the traffic was never theirs.
+- The harness suppresses a `not_actionable` report, so a step you want a person to see needs an actionability that reflects the decision in front of them.
+
+Put the evidence in the report: the source, the onset, the pinned baseline, the current daily level, the ratio, the days sustained, and an estimate of the excess events since onset (daily events minus the pinned baseline, summed).
+Do not convert the excess to a dollar figure. Billing tiers vary by plan, so name the volume and point the team at their billing page.
+Attach the daily series as a chart, with the candidate source next to the rest of the project.
+
+## Memory
+
+Key every per-source entry on the numeric `source_id` from step 1, and write the readable `lib` and `origin` into the entry's content.
+Two SDKs on one host are two sources, and they need separate baselines and reports.
+
+| Key | Holds |
+| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
+| `pattern:general:new-traffic` | Date of the last check and the top three sources by growth. Rewrite it at the end of every check, so the gate works |
+| `pattern:general:traffic-baseline:<source_id>` | `lib`, `origin`, onset date, pinned pre-surge baseline, last reported level or last seen level |
+| `report:general:new-traffic:<source_id>` | The `report_id`, so a later run edits it instead of filing a duplicate |
+| `noise:general:traffic:<source_id>` | Dev traffic only: `localhost`, staging or preview domains, the team's own CI |
+
+Do not record a source as `noise:` only because it is the team's own or is expected.
+Keep it as a `pattern:` with its level, so a later loop, bot flood or new step on that same source still surfaces.
+
+Edit the existing report when the source grows to about 2x the level you last reported, and again when it falls back near the pinned baseline for 3 days or more.
+Check the report's status with `inbox-reports-retrieve` first.
+Edit only a report that is still live. When it is resolved, suppressed or failed and the traffic comes back, author a fresh report and point `report:general:new-traffic:<source_id>` at the new id.