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(capture): enforce heatmaps and client warnings restrictions (#115303)

Paweł Ledwońd25920fd6981
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index f61452a6e2a3..829647b85700 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -2277,6 +2277,7 @@ dependencies = [
"serde_json",
"serde_urlencoded",
"sha2 0.10.9",
+ "strum 0.28.0",
"thiserror 2.0.18",
"time",
"tokio",
diff --git a/rust/capture/Cargo.toml b/rust/capture/Cargo.toml
index c1bc6e870c64..4fca901e8260 100644
--- a/rust/capture/Cargo.toml
+++ b/rust/capture/Cargo.toml
@@ -82,6 +82,7 @@ metrics-util = { workspace = true }
once_cell = { workspace = true }
rand = { workspace = true }
rstest = "0.26"
+strum = { version = "0.28", features = ["derive"] }
rdkafka = { workspace = true }
reqwest = { workspace = true, features = ["multipart"] }
redis = { workspace = true }
diff --git a/rust/capture/OUTPUTS_REFACTOR_PLAN.md b/rust/capture/OUTPUTS_REFACTOR_PLAN.md
index 36fb64d2788e..1ed362dc403d 100644
--- a/rust/capture/OUTPUTS_REFACTOR_PLAN.md
+++ b/rust/capture/OUTPUTS_REFACTOR_PLAN.md
@@ -2,15 +2,15 @@
Working contract for implementation agents. Steps 1–13 have shipped. Each remaining step is one commit in its own PR.
-This doc is deleted when it schedules nothing. Step 18 closes objective 1; objectives 2 and 3 are then scheduled in order. Before deletion, the parts still needed — the vocabulary rules, the ordering-vs-person-processing contract, the repartitioning note — move into module docs, and unscheduled work becomes issues.
+This doc is deleted when it schedules nothing. Step 19 closes objective 1; objectives 2 and 3 are then scheduled in order. Before deletion, the parts still needed — the vocabulary rules, the ordering-vs-person-processing contract, the repartitioning note — move into module docs, and unscheduled work becomes issues.
## Objectives
Capture has two produce stacks. The v0 endpoints (`/e`, `/batch`, `/i/v0/*`, replay, OTEL) stay forever. The v1 stack is live beside them: capture-analytics and capture-import serve `/i/v1/analytics/events` through it, and capture-ai serves `/i/v1/ai/events`. Both stacks produce through the outputs layer, and v0's internals move toward v1's shape.
-1. **Manual fallback for all capture traffic.** If MSK degrades, capture-analytics can produce to another cluster, with its own brokers, TLS, and topic names. One environment variable and a pod roll arm it, for v0 and v1 traffic alike. Boot-time checks prove the configuration is sound before any traffic moves. Steps 9–18.
-2. **One set of internals for v0 and v1.** v0 builds prepared events before the outputs layer like v1, and both use one prepared-event builder and one lane-decision model. The two stacks already share one producer and its settings (Step 12). The v0 endpoints do not change. Steps 20–22.
-3. **Automated fallback, capture side.** A separate circuit-breaker service decides when to switch. Capture sends producer health, receives switch signals, and applies them at runtime without a redeploy. Consumers are out of scope. Steps 23–25.
+1. **Manual fallback for all capture traffic.** If MSK degrades, capture-analytics can produce to another cluster, with its own brokers, TLS, and topic names. One environment variable and a pod roll arm it, for v0 and v1 traffic alike. Boot-time checks prove the configuration is sound before any traffic moves. Steps 9–19.
+2. **One set of internals for v0 and v1.** v0 builds prepared events before the outputs layer like v1, and both use one prepared-event builder and one lane-decision model. The two stacks already share one producer and its settings (Step 12). The v0 endpoints do not change. Steps 21–23.
+3. **Automated fallback, capture side.** A separate circuit-breaker service decides when to switch. Capture sends producer health, receives switch signals, and applies them at runtime without a redeploy. Consumers are out of scope. Steps 24–26.
Objective 2 goes before 3 because it deletes v0's event-level route into the outputs layer; the runtime switch is then built once, on the one remaining route. Neither depends on the other otherwise, and objective 3 also waits on the breaker service existing.
@@ -22,7 +22,7 @@ All three use one mechanism:
- Every output a deployment can reach must be fully configured.
- Each output's topics are checked against its producer's broker at boot.
-A fallback is then a configuration of an output's targets, not a new code path. The policy tree already composes two outputs (Step 7). It needs targets that can be configured independently, a policy that picks the live target at boot (Step 17), and for objective 3, a way to change that pick at runtime.
+A fallback is then a configuration of an output's targets, not a new code path. The policy tree already composes two outputs (Step 7). It needs targets that can be configured independently, a policy that picks the live target at boot (Step 18), and for objective 3, a way to change that pick at runtime.
Today this is not possible. One deployment-wide `KafkaConfig` holds ten topic names, each with a compiled-in default, so a boot check cannot tell a configured topic from a missing one. The existing completeness flag demands all ten on every pod. It fails any deployment that deliberately blanks a topic it never produces to, and where it can be enabled it still misses a missing variable, because the default fills it in.
@@ -41,7 +41,7 @@ outputs → Address → output = 1..n targets + selection policy
(single | select | split | dual-write);
target = own topics + a named producer
sinks → transport encoding (Kafka: topic, key, headers, optional lz4 envelope;
- S3 until Step 18: JSON lines), enqueue, ack
+ S3 until Step 19: JSON lines), enqueue, ack
producers → named connections (brokers, TLS, tuning), instantiated once,
shared by every output that names them
```
@@ -64,12 +64,12 @@ producers → named connections (brokers, TLS, tuning), instantiated onc
### Invariants
-- Metric names and labels stay stable: `capture_events_rerouted_*`, `capture_event_batch_size`, and until Step 18, `capture_primary_sink_health` and `capture_fallback_sink_failovers_total`. Steps that retire a metric list it as an accepted difference.
+- Metric names and labels stay stable: `capture_events_rerouted_*`, `capture_event_batch_size`, and until Step 19, `capture_primary_sink_health` and `capture_fallback_sink_failovers_total`. Steps that retire a metric list it as an accepted difference.
- Wire parity: the Step-1 goldens and existing endpoint and integration tests pass **unmodified**, unless a step says otherwise.
- Never mix a mechanical move with a behavior change in one commit.
- Every step ships green (`cargo test -p capture`, clippy `-D warnings`, fmt).
- v0 call sites keep the whole-request `CaptureError`. v1 keeps its per-event response.
-- No new sink code reads `ProcessedEventMetadata`. The Kafka sink's v0 prep path is the one remaining reader; Step 20 removes it.
+- No new sink code reads `ProcessedEventMetadata`. The Kafka sink's v0 prep path is the one remaining reader; Step 21 removes it.
## Starting point
@@ -81,25 +81,25 @@ Steps 1–11 shipped the structure:
- **4** — `serialization`: `Format` (JSON only) × `Envelope` (none or lz4) → `Serializer`, used in Kafka prep.
- **6** — the `PublishPayloads` trait takes `PreparedPayload`s and returns per-event `SinkResult`s. Kafka's `prepare_batch` is an inherent method.
- **7** — `outputs.rs`: `Output` is a sink or a `failover` over two outputs. `FallbackSink` is deleted. Accepted metric change: `capture_event_batch_size` now records on the S3 fallback path and on print/noop single sends.
-- **8** — every v0 call site publishes through `OutputRegistry::publish`. `State.outputs` is a concrete `Arc<OutputRegistry>`. The v0 `Event` trait is deleted. `kafka_send` stays on the one-event path: removing it adds a task spawn per event and drops the `ack_wait_one` span, so Step 20 takes it.
+- **8** — every v0 call site publishes through `OutputRegistry::publish`. `State.outputs` is a concrete `Arc<OutputRegistry>`. The v0 `Event` trait is deleted. `kafka_send` stays on the one-event path: removing it adds a task spawn per event and drops the `ack_wait_one` span, so Step 21 takes it.
- **9** — named producers (`producers.rs`): each slot reads `KAFKA_<SLOT>_PRODUCER_<RDKAFKA_KEY>` and is instantiated once. `INGESTION` is the one slot. ([#105335](https://github.com/PostHog/posthog/pull/105335))
- **10** — each v0 `Destination` is an output with a topic and a producer, read from `CAPTURE_OUTPUT_<OUTPUT>_TOPIC` and `CAPTURE_OUTPUT_<OUTPUT>_PRODUCER` as in Node.js ingestion. `OutputTable` replaces `TopicTable`. `PreparedPayload` carries the `Destination`. Setup maps each target's producer name to its handle once and hands the Kafka sink the resolved table; at enqueue the sink publishes through the target's own producer. Custom redirects publish through `CAPTURE_OUTPUT_CUSTOM_PRODUCER`. The resolved table is the Kafka sink's address-to-target lookup for both routes until Step 14's registries replace it.
- **11** — outputs take prepared events: `OutputRegistry::publish_prepared(Vec<PreparedEvent>) -> Vec<SinkResult>`, one result per event, in input order. `PreparedEvent` carries an `Address` and a `Bytes` payload. Every sink implements `PublishPrepared` beside `PublishEvents`; the `Sink` bound makes both required. The Kafka sink maps the address to its `Destination` and publishes through that target's topic and producer, enqueueing serially in input order; an enqueue or ack failure fails only its event. The S3 sink writes each payload as one line. Failover moves only the events with a retriable primary failure to the fallback. Test sinks that serve only v0 endpoints mark the prepared route `unreachable!`. Deviation from the original step text: the address-to-topic lookup is the Step-10 resolved `OutputTable` held by the Kafka sink, not a separate per-producer sink type; Step 14's registries replace the lookup.
-- **12** — v1 publishes through the outputs layer. `Destination::address` maps each v1 destination to an `Address`, `serialize_batch` builds the outputs layer's `PreparedEvent`s, and `process_batch` calls `state.outputs.publish_prepared` on the registry v0 uses. v0 and v1 are different HTTP endpoints, not different pipelines, so they share the `INGESTION` producer and its settings; per-pipeline tuning stays per deployment. v1's `Router`, `Sink`, `KafkaSink`, producer, per-sink config, `SinkName` and the `topic_ai` injection are deleted, and so is v1's produce timeout, which v0 never had. The capture mode alone decides which v1 endpoints a deployment serves, so `CAPTURE_V1_SINKS` and every `CAPTURE_V1_SINK_*` variable go. Accepted differences: the `capture_v1_kafka_*` metrics give way to the shared Kafka sink's; v1's per-error cause tags collapse into `CaptureError` kinds, so response details read `not_persisted`, `event_too_big` or `rejected`; `InvalidMessage` and `InvalidMessageSize`, which v1 classed as fatal, are now retriable, as in v0; the batch-wide `is_ready` reject and the per-sink lifecycle handles are gone, and producer liveness is the `INGESTION` slot's; v1 traffic takes the deployment's output policy, including S3 failover where it is on. It supersedes Step 19.
+- **12** — v1 publishes through the outputs layer. `Destination::address` maps each v1 destination to an `Address`, `serialize_batch` builds the outputs layer's `PreparedEvent`s, and `process_batch` calls `state.outputs.publish_prepared` on the registry v0 uses. v0 and v1 are different HTTP endpoints, not different pipelines, so they share the `INGESTION` producer and its settings; per-pipeline tuning stays per deployment. v1's `Router`, `Sink`, `KafkaSink`, producer, per-sink config, `SinkName` and the `topic_ai` injection are deleted, and so is v1's produce timeout, which v0 never had. The capture mode alone decides which v1 endpoints a deployment serves, so `CAPTURE_V1_SINKS` and every `CAPTURE_V1_SINK_*` variable go. Accepted differences: the `capture_v1_kafka_*` metrics give way to the shared Kafka sink's; v1's per-error cause tags collapse into `CaptureError` kinds, so response details read `not_persisted`, `event_too_big` or `rejected`; `InvalidMessage` and `InvalidMessageSize`, which v1 classed as fatal, are now retriable, as in v0; the batch-wide `is_ready` reject and the per-sink lifecycle handles are gone, and producer liveness is the `INGESTION` slot's; v1 traffic takes the deployment's output policy, including S3 failover where it is on. It supersedes Step 20.
- **13** — lanes are typed per pipeline: `Address::Lane(PipelineLane)`, where `PipelineLane` is `Analytics(AnalyticsLane)`, `Ai(AiLane)`, `Heatmaps`/`Warnings`/`ErrorTracking(BasicLane)` or `Replay(SessionReplayLane)`, and the standalone `Pipeline` enum folds into it. There is no `AiLane::Historical`. The lane → output map is total, so v0 prep loses its dlq fallback for an unbacked pair and the prepared route loses its `NonRetryableSinkError` for one. Goldens unmodified; `resolve` tests retyped with the same assertions.
Today the registry holds one deployment-wide `Output`: a Kafka sink, or Kafka→S3 failover. v0 publishes events through it and v1 publishes prepared events through it.
## Objective 1 — manual fallback for all capture traffic
-Step 14 makes the set of reachable outputs a type. Steps 15–16 are the checks that type allows. Step 17 is the fallback. Step 18 deletes the S3 fallback it replaces.
+Step 14 makes the set of reachable outputs a type. Steps 15–16 are the checks that type allows. Step 17 gives each pipeline its own dlq output. Step 18 is the fallback. Step 19 deletes the S3 fallback it replaces.
### Step 14 · Per-mode output registries
- **Goal.** One registry type per capture mode, with required fields: `AnalyticsFamilyOutputs` (analytics, ai, heatmaps, warnings, error tracking) for Events and Import pods, `AiOutputs` for Ai pods, and `SessionReplayOutputs` for Recordings pods. Rows naming the same producer share its one instance.
- **Each type holds exactly what its mode can reach.** The set comes from the routes the mode mounts: Ai pods serve only the AI batch, AI, OTEL, and v1 AI routes (`router.rs`), so `AiOutputs` does not demand heatmaps, warnings, or error-tracking topics. The exact rows for each mode, Import included, are derived from its routes when this step is scheduled.
- **Why.** Step 15 demands configuration per mode. Without these types, that demand is a hand-written mode → outputs map. With them, the type is the list.
-- **Out of scope.** Binding handlers to capability traits over a generic `State<T>` (Step 29).
+- **Out of scope.** Binding handlers to capability traits over a generic `State<T>` (Step 30).
- **Parity proof.** Goldens and integration suites unmodified; per-mode construction tests.
- **Size.** L.
@@ -121,7 +121,16 @@ Example of what this catches: until [charts#14941](https://github.com/PostHog/ch
- **Enabled per deployment.**
- **Size.** M.
-### Step 17 · capture-analytics emergency fallback
+### Step 17 · A dlq lane per pipeline
+
+- **Goal.** A dlq redirect publishes to its pipeline's dlq topic, the one Node.js ingestion uses for that pipeline, such as `ingestion-heatmaps-main-dlq`. `Address::Dlq` goes. Each pipeline lane type gains a dlq lane, so `resolve` returns a lane of the event's pipeline and the lane → output map stays total.
+- **Why.** Every pipeline shares one dlq output. A dlq restriction that capture applies to heatmaps, client warnings, error tracking, AI or replay lands in that shared topic, while the same restriction applied by Node.js lands in the pipeline's own dlq. A replay of one dlq misses the events in the other.
+- **Config.** Each dlq output is a row in its mode's Step-14 registry and reads `CAPTURE_OUTPUT_<PIPELINE>_DLQ_TOPIC` and `CAPTURE_OUTPUT_<PIPELINE>_DLQ_PRODUCER`. Step 15 requires them, and Step 16 checks their topics on the broker, so charts sets every value before the code lands.
+- **Before Step 18,** so every dlq output gets a secondary target like the other outputs.
+- **Accepted difference.** The goldens' dlq rows for non-analytics pipelines change topic. Analytics dlq rows stay unmodified.
+- **Size.** M.
+
+### Step 18 · capture-analytics emergency fallback
- **Shape.** Each capture-analytics output gets a secondary target beside its primary, as in Node.js ingestion's dual-write outputs: `CAPTURE_OUTPUT_<OUTPUT>_SECONDARY_TOPIC` and `CAPTURE_OUTPUT_<OUTPUT>_SECONDARY_PRODUCER`. The secondary producer has its own brokers and TLS, and its topics do not have to copy the primary's names. v0 and v1 traffic both publish through these outputs.
- **Arming.** One environment variable, matched exactly against a sentinel value. `"1"`, `"true"`, or `"yes"` does not arm it; any value other than the sentinel refuses to boot. Unset is normal operation.
@@ -138,13 +147,13 @@ Example of what this catches: until [charts#14941](https://github.com/PostHog/ch
- **Known gaps, for the runbook.** capture-import writes the same topics and must be stopped before any drain-to-zero check. The AI lane's bridges read MSK topic names.
- **Size.** M/L.
-### Step 18 · Delete the S3 fallback
+### Step 19 · Delete the S3 fallback
- **Goal.** Delete `S3Sink`, the `s3_fallback_*` config, the Kafka→S3 wiring in `setup`, and the health-gated `failover` policy, which serves only S3.
- **Why it is safe.** No production deployment enables it. The charts set `S3_FALLBACK_ENABLED: "false"` in six values files and `"true"` only in `apps/capture-analytics/values.dev.yaml`.
-- **Why Step 17 replaces it.** A second Kafka cluster keeps events flowing to consumers. S3 needs a replay path that has never run in production.
+- **Why Step 18 replaces it.** A second Kafka cluster keeps events flowing to consumers. S3 needs a replay path that has never run in production.
- **Accepted differences.** `capture_primary_sink_health` and `capture_fallback_sink_failovers_total` go with the policy that emits them.
-- **What is lost.** S3 failover is automatic; Step 17 is manual. No deployment uses the automatic path today, but the capability goes. Objective 3 brings it back through Step 23.
+- **What is lost.** S3 failover is automatic; Step 18 is manual. No deployment uses the automatic path today, but the capability goes. Objective 3 brings it back through Step 24.
- **Cross-repo.** The seven charts values entries, the `CaptureAnalyticsV0S3FallbackActive` alert spec and runbook, and the IAM role in cloud-infra.
- **Size.** M.
@@ -152,18 +161,18 @@ Example of what this catches: until [charts#14941](https://github.com/PostHog/ch
Scheduled when objective 1 closes. The v0 endpoints and their responses do not change.
-### Step 20 · v0 builds prepared events
+### Step 21 · v0 builds prepared events
v0 resolves the lane, builds the JSON body and header values, and hands prepared events to `publish_prepared`, as v1 does. The lz4 envelope moves into the Kafka sink as target config. `PublishEvents`, `kafka_send`, and v0's event route into the outputs layer are deleted, and with them v0's Kafka prep and the test sinks' `unreachable!` prepared impls. v0 call sites fold per-event results into the whole-request `CaptureError`.
- **Tests.** Capturing mocks see prepared events, not `ProcessedEvent`s, so about 60 metadata assertions become wire-level (topic, key, headers, payload). The `ExpectedEvent` checkers rebuild the expected record, so test bodies stay the same. This also pins that replay events redirected to dlq/custom partition on the event key, not the session id.
- **Accepted differences.** print/noop run the real prep path, so they can now fail prep (e.g. `MissingSessionId`). Prep histograms keep their `capture_kafka_*` names.
-### Step 21 · One prepared-event builder
+### Step 22 · One prepared-event builder
v0 and v1 build the JSON body and header values with the same code. Known differences are settled here: `sent_at` fractional-second formatting (parses equal; v1 adopts v0's), and the header differences pinned by `overflow_parity.rs`.
-### Step 22 · One lane-decision model
+### Step 23 · One lane-decision model
v0's lane decision moves to v1's model.
@@ -178,40 +187,40 @@ v0's lane decision moves to v1's model.
A separate circuit-breaker service decides; how it decides is out of scope. Capture sends producer health and receives switch signals. These steps are scheduled with parity proofs once objectives 1 and 2 close.
-### Step 23 · Target selection at runtime
+### Step 24 · Target selection at runtime
-The `select` policy's live target becomes swappable state with no lock on the request path. Each batch reads the live target once, and its acks and retries stay on that target, so a switch never splits a batch or sends it twice. Step 17's arming sets its boot value. A signal switches the target. No signal, or an unreachable control plane, keeps the current target: missing information must never move traffic. The Step-17 gauge reports the live target. With no service configured, behavior matches Step 17 exactly. As in Step 17, a switch moves only where capture writes. Repointing consumers happens outside capture and outside this plan, and must be coordinated with the switch before it is automated.
+The `select` policy's live target becomes swappable state with no lock on the request path. Each batch reads the live target once, and its acks and retries stay on that target, so a switch never splits a batch or sends it twice. Step 18's arming sets its boot value. A signal switches the target. No signal, or an unreachable control plane, keeps the current target: missing information must never move traffic. The Step-18 gauge reports the live target. With no service configured, behavior matches Step 18 exactly. As in Step 18, a switch moves only where capture writes. Repointing consumers happens outside capture and outside this plan, and must be coordinated with the switch before it is automated.
-### Step 24 · Producer health out
+### Step 25 · Producer health out
Each named producer reports delivery latency, error rate, and queue depth under its name, including the idle fallback producer. Transport and cadence are decided when scheduled. Reporting must never slow the produce path.
-### Step 25 · Switch signals in
+### Step 26 · Switch signals in
-Capture applies the service's switch signals through Step 23 and acknowledges them. The Step-17 variable stays the manual override and outranks the service; exact precedence is decided when scheduled. The breaker logic that an earlier plan put inside capture (`FailoverMode::Breaker`) belongs to the service.
+Capture applies the service's switch signals through Step 24 and acknowledges them. The Step-18 variable stays the manual override and outranks the service; exact precedence is decided when scheduled. The breaker logic that an earlier plan put inside capture (`FailoverMode::Breaker`) belongs to the service.
## Deferred work
Unscheduled. To revive a step, move it under an objective with its parity proof.
-### Step 29 · Handlers bound by publish capabilities
+### Step 30 · Handlers bound by publish capabilities
Handlers bind on sealed traits (`PublishesAnalyticsFamily`, `PublishesSessionReplay`). `State<T>` is generic over the Step-14 registry, and `setup` builds the router per mode. Mounting an ingress on a registry that cannot publish its pipeline becomes a compile error.
-### Steps 34–35 · Outputs as an open trait
+### Steps 35–36 · Outputs as an open trait
-`Outputs` becomes an open trait replacing the closed policy enum: `KafkaOutputs`, `PrintOutputs`/`NoopOutputs`, and `SelectOutputs`/`SplitOutputs` over `Arc<dyn Outputs>`. A test-only prototype (`outputs::dynamic`, Step 35) has `DynamicKafkaOutputs` take config pushes from an in-process `KafkaManagerService` and switch topics and brokers partition by partition.
+`Outputs` becomes an open trait replacing the closed policy enum: `KafkaOutputs`, `PrintOutputs`/`NoopOutputs`, and `SelectOutputs`/`SplitOutputs` over `Arc<dyn Outputs>`. A test-only prototype (`outputs::dynamic`, Step 36) has `DynamicKafkaOutputs` take config pushes from an in-process `KafkaManagerService` and switch topics and brokers partition by partition.
Split and dual-write policies are also unscheduled. Before either is scheduled, it must define how per-target results become one result per event, which failures it retries, and how it handles an event delivered to both targets.
-Steps 30 and 33 are listed in the tracker only. Steps 26, 28, 31, and 32 are superseded; the tracker says by what.
+Steps 31 and 34 are listed in the tracker only. Steps 27, 29, 32, and 33 are superseded; the tracker says by what.
## Repartitioning coordinator (design note)
Unscheduled. This records where a coordinator plugs in, so nothing already landed has to move. The goal: move a deployment between clusters one partition at a time, with a short hold per partition.
- **Shards decided above the sinks.** The coordinator owns `shard = hash(key) % N`, over the same key the sink hashes, with its own `N`. The prepared event gets `shard: Option<u32>`, so both targets of a pair see the same shard.
-- **A `ShardRouted` output policy** holds two child outputs (old, new) and a swappable `shard → Old | New` table (`ArcSwap`, updated like Step 23). A batch splits by assignment.
+- **A `ShardRouted` output policy** holds two child outputs (old, new) and a swappable `shard → Old | New` table (`ArcSwap`, updated like Step 24). A batch splits by assignment.
- **Partition pass-through.** `ProduceRecord` gets `partition: Option<i32>`; the Kafka sink maps shard to a partition of its topic. `None` keeps key hashing.
- **Fence per shard `s`, Old → New:**
1. Swap the entry for `s`; new `s` events are held.
@@ -264,22 +273,23 @@ One step = one commit, subject from the tracker. No `--no-verify`.
| 14 · Per-mode output registries | pending | `feat(capture): per-mode output registries with required rows` |
| 15 · A reachable output must be configured | pending | `feat(capture): require configuration for every reachable output` |
| 16 · Verify topics against the producer's broker | pending | `feat(capture): verify each output's topics against its producer's broker at boot` |
-| 17 · capture-analytics emergency fallback | pending | `feat(capture): select policy and emergency fallback for capture-analytics` |
-| 18 · Delete the S3 fallback | pending | `refactor(capture): delete the s3 fallback and the health-gated failover policy` |
-| 19 · One producer per cluster | superseded | — (Step 12 put v1 on v0's producer and settings) |
-| 20 · v0 builds prepared events | objective 2 | `refactor(capture): v0 publishes prepared events; PublishEvents retired` |
-| 21 · One prepared-event builder | objective 2 | `refactor(capture): v0 and v1 share one prepared-event builder` |
-| 22 · One lane-decision model | objective 2 | `refactor(capture): v0 lane decision moves to the v1 model` |
-| 23 · Target selection at runtime | objective 3 | `feat(capture): select policy target switchable at runtime` |
-| 24 · Producer health metrics out | objective 3 | `feat(capture): producers report health for the breaker service` |
-| 25 · Switch signals in | objective 3 | `feat(capture): apply breaker switch signals to the select policy` |
-| 26 · Prep hoist; `PublishEvents` retired | superseded | — (became Step 20) |
-| 27 · AI membership stamp; `AiRouting` retired | done | — (landed with the AI lane rollout, outside this plan's sequence) |
-| 28 · Sinks realize namespaces | superseded | — (targets map addresses to topics from Step 11) |
-| 29 · Handlers bound by publish capabilities | deferred | `feat(capture): handlers bound by publish capabilities over per-mode state` |
-| 30 · AI ingress family | deferred | `feat(capture): ai ingress is its own router family with its own capability` |
-| 31 · Topic tables injected into sinks | superseded | — (the Kafka sink resolves addresses through its table from Step 11; Step 14's registries replace it) |
-| 32 · Per-pipeline output overrides; boot topic verification | superseded | — (boot verification became Step 16; retargeting is configuration after Steps 10 and 14) |
-| 33 · Naming and import hygiene | deferred | `refactor(capture): replace remaining nested paths with imports` + `refactor(capture): name the session replay pipeline consistently` |
-| 34 · Outputs as an open trait | deferred | `refactor(capture): Outputs becomes an open trait` |
-| 35 · Dynamic outputs prototype | deferred | `feat(capture): prototype dynamic outputs with incremental switchover (test-only)` |
+| 17 · A dlq lane per pipeline | pending | `feat(capture): each pipeline publishes dlq redirects to its own dlq output` |
+| 18 · capture-analytics emergency fallback | pending | `feat(capture): select policy and emergency fallback for capture-analytics` |
+| 19 · Delete the S3 fallback | pending | `refactor(capture): delete the s3 fallback and the health-gated failover policy` |
+| 20 · One producer per cluster | superseded | — (Step 12 put v1 on v0's producer and settings) |
+| 21 · v0 builds prepared events | objective 2 | `refactor(capture): v0 publishes prepared events; PublishEvents retired` |
+| 22 · One prepared-event builder | objective 2 | `refactor(capture): v0 and v1 share one prepared-event builder` |
+| 23 · One lane-decision model | objective 2 | `refactor(capture): v0 lane decision moves to the v1 model` |
+| 24 · Target selection at runtime | objective 3 | `feat(capture): select policy target switchable at runtime` |
+| 25 · Producer health metrics out | objective 3 | `feat(capture): producers report health for the breaker service` |
+| 26 · Switch signals in | objective 3 | `feat(capture): apply breaker switch signals to the select policy` |
+| 27 · Prep hoist; `PublishEvents` retired | superseded | — (became Step 21) |
+| 28 · AI membership stamp; `AiRouting` retired | done | — (landed with the AI lane rollout, outside this plan's sequence) |
+| 29 · Sinks realize namespaces | superseded | — (targets map addresses to topics from Step 11) |
+| 30 · Handlers bound by publish capabilities | deferred | `feat(capture): handlers bound by publish capabilities over per-mode state` |
+| 31 · AI ingress family | deferred | `feat(capture): ai ingress is its own router family with its own capability` |
+| 32 · Topic tables injected into sinks | superseded | — (the Kafka sink resolves addresses through its table from Step 11; Step 14's registries replace it) |
+| 33 · Per-pipeline output overrides; boot topic verification | superseded | — (boot verification became Step 16; retargeting is configuration after Steps 10 and 14) |
+| 34 · Naming and import hygiene | deferred | `refactor(capture): replace remaining nested paths with imports` + `refactor(capture): name the session replay pipeline consistently` |
+| 35 · Outputs as an open trait | deferred | `refactor(capture): Outputs becomes an open trait` |
+| 36 · Dynamic outputs prototype | deferred | `feat(capture): prototype dynamic outputs with incremental switchover (test-only)` |
diff --git a/rust/capture/src/event_restrictions/manager.rs b/rust/capture/src/event_restrictions/manager.rs
index 5f38071ee61a..f3698fb0f825 100644
--- a/rust/capture/src/event_restrictions/manager.rs
+++ b/rust/capture/src/event_restrictions/manager.rs
@@ -394,10 +394,13 @@ impl EventRestrictionService {
#[cfg(test)]
mod tests {
use super::*;
+ use crate::config::CaptureMode;
use crate::event_restrictions::repository::testing::MockRestrictionsRepository;
use crate::event_restrictions::repository::RestrictionEntry;
use crate::event_restrictions::types::RestrictionScope;
+ use crate::v0_request::DataType;
use common_redis::CustomRedisError;
+ use strum::IntoEnumIterator;
use tokio_util::sync::CancellationToken;
fn test_lifecycle() -> (CancellationToken, lifecycle::Handle) {
@@ -588,6 +591,35 @@ mod tests {
.is_empty());
}
+ #[tokio::test]
+ async fn events_deployment_loads_restrictions_for_every_classified_pipeline() {
+ for data_type in DataType::iter() {
+ let Some(pipeline) = data_type.pipeline() else {
+ continue;
+ };
+ let repo = MockRestrictionsRepository::new();
+ repo.set_entries(
+ RestrictionType::DropEvent,
+ Some(vec![make_entry("token", vec![pipeline.as_str()])]),
+ )
+ .await;
+
+ let manager = RestrictionManager::from_repository(
+ &repo,
+ &Pipeline::for_capture_mode(CaptureMode::Events),
+ )
+ .await
+ .unwrap();
+
+ let restrictions =
+ manager.get_restrictions("token", &EventContext::default(), pipeline);
+ assert!(
+ restrictions.contains(RestrictionType::DropEvent),
+ "{data_type:?}"
+ );
+ }
+ }
+
#[tokio::test]
async fn test_manager_skips_old_version() {
let repo = MockRestrictionsRepository::new();
diff --git a/rust/capture/src/event_restrictions/types.rs b/rust/capture/src/event_restrictions/types.rs
index 0d320f097361..cd5e51957710 100644
--- a/rust/capture/src/event_restrictions/types.rs
+++ b/rust/capture/src/event_restrictions/types.rs
@@ -50,10 +50,10 @@ impl Pipeline {
impl Pipeline {
/// Pipelines a given capture deployment produces events to. The events
/// deployment writes to `analytics` (normal events), `errortracking`
- /// (`$exception` events split off in `process_single_event`), and `ai`
- /// (`$ai_` names), so its restriction service must serve restrictions for
- /// all three pipelines. `Import` is an events deployment restricted to
- /// backfills, so it serves the same three.
+ /// (`$exception`), `ai` (`$ai_` names), `heatmaps` (`$$heatmap`) and
+ /// `clientwarnings` (`$$client_ingestion_warning`), so its restriction
+ /// service must serve all five. `Import` is an events deployment
+ /// restricted to backfills, so it serves the same five.
///
/// `Ai` serves only `ai`. That deployment registers no analytics route,
/// and `process_events` rejects a batch carrying anything off the AI lane,
@@ -63,9 +63,13 @@ impl Pipeline {
/// `RestrictionSet` — silently unrestricted.
pub fn for_capture_mode(mode: CaptureMode) -> Vec<Pipeline> {
match mode {
- CaptureMode::Events | CaptureMode::Import => {
- vec![Self::Analytics, Self::ErrorTracking, Self::Ai]
- }
+ CaptureMode::Events | CaptureMode::Import => vec![
+ Self::Analytics,
+ Self::ErrorTracking,
+ Self::Ai,
+ Self::Heatmaps,
+ Self::ClientWarnings,
+ ],
CaptureMode::Recordings => vec![Self::SessionRecordings],
// capture-ai registers only the AI routes, and both pipelines
// refuse an event off the AI lane before restrictions are applied,
@@ -415,7 +419,13 @@ mod tests {
fn test_pipeline_for_capture_mode() {
assert_eq!(
Pipeline::for_capture_mode(CaptureMode::Events),
- vec![Pipeline::Analytics, Pipeline::ErrorTracking, Pipeline::Ai]
+ vec![
+ Pipeline::Analytics,
+ Pipeline::ErrorTracking,
+ Pipeline::Ai,
+ Pipeline::Heatmaps,
+ Pipeline::ClientWarnings,
+ ]
);
// Import is an events deployment restricted to backfills, so it must
// serve the identical pipeline set -- a backfill can carry $exception
diff --git a/rust/capture/src/v0_request.rs b/rust/capture/src/v0_request.rs
index 2799371a813b..9ce30e58b183 100644
--- a/rust/capture/src/v0_request.rs
+++ b/rust/capture/src/v0_request.rs
@@ -174,6 +174,7 @@ pub fn path_is_legacy_endpoint(path: &str) -> bool {
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
+#[cfg_attr(test, derive(strum::EnumIter))]
pub enum DataType {
AnalyticsMain,
AnalyticsHistorical,