: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(capture): add CAPTURE_AI_LANE_PREDICATE toggle and misrouted_event warning (#103267)
Eli Reisman9d3abcdca47e
diff --git a/rust/capture/OUTPUTS_REFACTOR_PLAN.md b/rust/capture/OUTPUTS_REFACTOR_PLAN.mdindex 3d0df100350e..b67aef5a64f1 100644--- a/rust/capture/OUTPUTS_REFACTOR_PLAN.md+++ b/rust/capture/OUTPUTS_REFACTOR_PLAN.md@@ -203,7 +203,7 @@ Goal: v1 endpoints publish through `dyn Outputs` like every other ingress, so fa### AI pipeline and Import mode-- **AI pipeline membership is a name allowlist, resolved once into a stamp.** `AI_EVENT_NAMES` lists the event names on the lane; `DataType::from_event_name` resolves a name against it and stamps `DataType::AiEvents`, on every capture mode, mirroring v1's `Destination::AiEvents`. Everything downstream reads the stamp — `Pipeline::from_metadata` maps it, and the multipart and OTEL AI ingress stamp the same lane at the handler. The allowlist is deliberately not an `$ai_` prefix match: the Node AI pipeline DLQs anything it receives off its own `AI_EVENT_TYPES` list, so a prefixed-but-unlisted name like `$ai_call` must stay on the analytics lane. (The quota predicate `is_llm_event` is separate and *is* prefix-based.) There is no per-batch routing config and no per-deployment divert switch — the rollout-era `AiRouting` mode/allowlist/percentage machinery is retired, and so is the capture-mode predicate that replaced it. A deployment that wants AI traffic on a given topic points `CAPTURE_ANALYTICS_AI_EVENTS_TOPIC` at it.+- **AI pipeline membership is one predicate, resolved once into a stamp.** `AiLanePredicate` (`CAPTURE_AI_LANE_PREDICATE`: `allowlist` = exact membership in `AI_EVENT_NAMES`, `prefix` = any `$ai_*` name) decides which names are on the lane; `DataType::from_event_name` resolves a name against it and stamps `DataType::AiEvents`, on every capture mode, mirroring v1's `Destination::AiEvents`. Everything downstream reads the stamp — `Pipeline::from_metadata` maps it, and the multipart and OTEL AI ingress stamp the same lane at the handler. A deployment may only run `prefix` once its AI ingestion pipeline admits by prefix too, otherwise a prefixed-but-unlisted name like `$ai_call` is diverted and then DLQed. (The quota predicate `is_llm_event` is separate and always prefix-based.) There is no per-batch routing config and no per-deployment divert switch — the rollout-era `AiRouting` mode/allowlist/percentage machinery is retired, and so is the capture-mode predicate that replaced it. A deployment that wants AI traffic on a given topic points `CAPTURE_ANALYTICS_AI_EVENTS_TOPIC` at it.- **The AI lanes own dedicated topics.** `TopicTable` grows an `ai_events` row (`CAPTURE_ANALYTICS_AI_EVENTS_TOPIC`, required with default `events_plugin_ingestion_ai`) and an optional `ai_events_overflow` row (`..._OVERFLOW_TOPIC`); there is no `AiLane::Historical` — the divert decision wins over historical, matching v1. The AI overflow valve (overflow topic set) rides `PrepSpec` into `resolve`, so an unarmed deployment never routes the AI lane to overflow, force_overflow included.- **Import mode** is an analytics-family deployment on `router::router`; it mounts `/i/v0/ai/batch` (gated batch handler) but not the ai/otel handlers, and shares the Events topic requirements.diff --git a/rust/capture/docs/ai-endpoint-parity.md b/rust/capture/docs/ai-endpoint-parity.mdindex 76b2f11461b3..d61b01990c6c 100644--- a/rust/capture/docs/ai-endpoint-parity.md+++ b/rust/capture/docs/ai-endpoint-parity.md@@ -29,7 +29,7 @@ This document compares the `/i/v0/ai` endpoint with the `/i/v0/e` (events) endpo|---------|-------------|-------|| Multipart form-data parsing | Parse and validate multipart requests with an event part and an optional properties part | AI-specific || Authorization header requirement | Require `Bearer <token>` in Authorization header | AI-specific |-| AI event type validation | Validate against 6 allowed AI event types: `$ai_generation`, `$ai_trace`, `$ai_span`, `$ai_embedding`, `$ai_metric`, `$ai_feedback` | AI-specific |+| AI event name validation | `CAPTURE_AI_LANE_PREDICATE=allowlist`: 6 allowed names (`$ai_generation`, `$ai_trace`, `$ai_span`, `$ai_embedding`, `$ai_metric`, `$ai_feedback`); `prefix`: any `$ai_*` name | AI-specific || `$ai_model` property validation | Ensure `$ai_model` is present and non-empty | AI-specific || Strict size limits per part type | 32KB event, 960KB properties + event | AI-specific |@@ -103,6 +103,6 @@ flag.- The AI endpoint's unique features (multipart parsing, AI event validation, etc.) are intentional and should be preserved- Some differences are by design rather than gaps:- - **Event type filtering**: `/e` uses denylist (blocks `$performance_event`), AI uses allowlist (only accepts 6 `$ai_*` events)+ - **Event type filtering**: `/e` uses denylist (blocks `$performance_event`), AI accepts only AI-lane names (6-name allowlist or the `$ai_` prefix, per `CAPTURE_AI_LANE_PREDICATE`)- **Single event vs batch**: AI processes single events, `/e` supports batches- Focus parity efforts on security, billing, and abuse prevention featuresdiff --git a/rust/capture/docs/llma-capture-overview.md b/rust/capture/docs/llma-capture-overview.mdindex 54cc2d6bf855..835a8db85142 100644--- a/rust/capture/docs/llma-capture-overview.md+++ b/rust/capture/docs/llma-capture-overview.md@@ -13,8 +13,10 @@ This document covers only the single-event multipart endpoint.## Supported events-The endpoint accepts exactly six event names (`ALLOWED_AI_EVENTS` in `ai_rejection.rs`):+Which event names the endpoint accepts depends on the deployment's `CAPTURE_AI_LANE_PREDICATE`.+Under `allowlist` (the default) it accepts exactly six names (`ALLOWED_AI_EVENTS` in `ai_rejection.rs`):`$ai_generation`, `$ai_trace`, `$ai_span`, `$ai_embedding`, `$ai_metric`, and `$ai_feedback`.+Under `prefix` it accepts any name that starts with `$ai_`.Every event must carry a non-empty string `$ai_model` property, a `distinct_id`, and a client-supplied `uuid`.## Request formatdiff --git a/rust/capture/src/ai_endpoint.rs b/rust/capture/src/ai_endpoint.rsindex dd897232453e..9db9319a25ec 100644--- a/rust/capture/src/ai_endpoint.rs+++ b/rust/capture/src/ai_endpoint.rs@@ -34,7 +34,7 @@ use crate::router::State as AppState;use crate::timestamp;use crate::token::validate_token;use crate::v0_request::{- exceeds_max_ai_event_bytes, DataType, ProcessedEvent, ProcessedEventMetadata,+ exceeds_max_ai_event_bytes, AiLanePredicate, DataType, ProcessedEvent, ProcessedEventMetadata,};use crate::v1::gateway_provenance as gp;@@ -310,7 +310,7 @@ async fn ai_handler_inner(retrieve_multipart_parts(&mut multipart, event_metadata, state.ai_max_event_bytes).await?;// Step 6: Parse the parts- let mut parsed = parse_multipart_data(parts)?;+ let mut parsed = parse_multipart_data(parts, state.ai_lane_predicate)?;// AI-gateway provenance: stamp the trusted marker (overwriting client values) on a// verified event, else strip the whole $ai_gateway* namespace so a forged marker@@ -783,6 +783,7 @@ async fn retrieve_multipart_parts(/// Parse retrieved multipart parts and validate event structure.fn parse_multipart_data(parts: RetrievedMultipartParts,+ ai_lane_predicate: AiLanePredicate,) -> Result<ParsedMultipartData, AiRejection> {// Merge properties into the eventlet mut event = parts.event_json;@@ -793,7 +794,7 @@ fn parse_multipart_data(}// Now validate the complete event structure- validate_event_structure(&event)?;+ validate_event_structure(&event, ai_lane_predicate)?;// Extract event_name, distinct_id, uuid, and timestamp for later uselet event_name = event@@ -845,7 +846,10 @@ fn parse_multipart_data(}/// Validate the structure and content of an AI event-fn validate_event_structure(event: &Value) -> Result<(), AiRejection> {+fn validate_event_structure(+ event: &Value,+ ai_lane_predicate: AiLanePredicate,+) -> Result<(), AiRejection> {// Check if event is an objectlet event_obj = event.as_object().ok_or(AiRejection::EventNotObject)?;@@ -859,8 +863,16 @@ fn validate_event_structure(event: &Value) -> Result<(), AiRejection> {return Err(AiRejection::EventNameEmpty);}- if !ALLOWED_AI_EVENTS.contains(&event_name) {- return Err(AiRejection::EventNameNotAllowed(event_name.to_string()));+ // The rejection names the rule the deployment applied, so the client's 400+ // body (and the warning details) say what a valid name looks like here.+ match ai_lane_predicate {+ AiLanePredicate::Allowlist if !ALLOWED_AI_EVENTS.contains(&event_name) => {+ return Err(AiRejection::EventNameNotAllowed(event_name.to_string()));+ }+ AiLanePredicate::Prefix if !ai_lane_predicate.is_ai_event(event_name) => {+ return Err(AiRejection::EventNameNotAiPrefixed(event_name.to_string()));+ }+ _ => {}}// Validate distinct_iddiff --git a/rust/capture/src/ai_rejection.rs b/rust/capture/src/ai_rejection.rsindex 36f022e45507..4f4789c9acd6 100644--- a/rust/capture/src/ai_rejection.rs+++ b/rust/capture/src/ai_rejection.rs@@ -16,9 +16,11 @@use std::fmt;use crate::api::CaptureError;+use crate::v0_request::AI_LANE_NAME_PREFIX;-/// Event names the endpoint accepts. Anything else is a client sending ordinary-/// analytics to the AI path.+/// Event names the endpoint accepts under `AiLanePredicate::Allowlist`; under+/// `Prefix` any `$ai_*` name is accepted. Anything else is ordinary analytics+/// sent to the AI path.pub const ALLOWED_AI_EVENTS: [&str; 6] = ["$ai_generation","$ai_trace",@@ -81,8 +83,10 @@ pub enum AiRejection {EventUuidRequired,EventUuidInvalid(String),- // AI-specific validation+ // AI-specific validation. The name rejection follows the deployment's+ // `AiLanePredicate`: `EventNameNotAllowed` or `EventNameNotAiPrefixed`.EventNameNotAllowed(String),+ EventNameNotAiPrefixed(String),AiModelMissing,AiModelNotString,AiModelEmpty,@@ -141,6 +145,9 @@ impl AiRejection {ALLOWED_AI_EVENTS.join(", "),event_name),+ Self::EventNameNotAiPrefixed(event_name) => format!(+ "Event name must start with '{AI_LANE_NAME_PREFIX}', got '{event_name}'"+ ),Self::AiModelMissing => "Event properties must contain '$ai_model'".to_string(),Self::AiModelNotString => "$ai_model must be a string".to_string(),Self::AiModelEmpty => "$ai_model cannot be empty".to_string(),@@ -179,6 +186,7 @@ impl AiRejection {| Self::EventUuidRequired| Self::EventUuidInvalid(_)| Self::EventNameNotAllowed(_)+ | Self::EventNameNotAiPrefixed(_)| Self::AiModelMissing| Self::AiModelNotString| Self::AiModelEmpty => ErrorKind::Parsing,@@ -294,6 +302,10 @@ pub(crate) fn all_variants_with_messages() -> Vec<(AiRejection, &'static str)> {AiRejection::EventNameNotAllowed("$pageview".to_string()),"Event name must be one of: $ai_generation, $ai_trace, $ai_span, $ai_embedding, $ai_metric, $ai_feedback, got '$pageview'",),+ (+ AiRejection::EventNameNotAiPrefixed("$pageview".to_string()),+ "Event name must start with '$ai_', got '$pageview'",+ ),(AiRejection::AiModelMissing,"Event properties must contain '$ai_model'",@@ -395,7 +407,7 @@ mod tests {);assert_eq!(listed.len(),- 29,+ 30,"variant count changed — add the new variant to all_variants_with_messages \and update this expected count");diff --git a/rust/capture/src/config.rs b/rust/capture/src/config.rsindex 71821afd6634..e395f48dae1a 100644--- a/rust/capture/src/config.rs+++ b/rust/capture/src/config.rs@@ -4,6 +4,8 @@ use common_continuous_profiling::ContinuousProfilingConfig;use envconfig::Envconfig;use tracing::Level;+use crate::v0_request::AiLanePredicate;+#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]pub enum CaptureMode {Events,@@ -359,6 +361,12 @@ pub struct Config {#[envconfig(default = "8388608")] // 8MiBpub ai_max_event_bytes: u64,+ /// AI lane membership: `allowlist` (exact `AI_EVENT_NAMES`) or `prefix` (any `$ai_*`).+ /// Set `prefix` only once the environment's AI ingestion pipeline admits by prefix,+ /// or it DLQs every unlisted `$ai_*` name capture diverts.+ #[envconfig(from = "CAPTURE_AI_LANE_PREDICATE", default = "allowlist")]+ pub ai_lane_predicate: AiLanePredicate,+// HMAC-SHA256 key shared with the AI gateway. When set, $ai_generation events// carrying a valid PostHog-Ai-Gateway-* signature are stamped verified and// exempted from the llm_events quota limiter. Unset disables verification@@ -621,6 +629,7 @@ pub struct KafkaConfig {#[cfg(test)]mod tests {use super::{CaptureMode, Config};+ use crate::v0_request::AiLanePredicate;use std::collections::HashMap;use std::str::FromStr;@@ -659,6 +668,26 @@ mod tests {assert_eq!(config.kafka.capture_analytics_ai_events_topic, "ai_events");}+ #[test]+ fn ai_lane_predicate_binds_to_its_env_var_and_defaults_to_allowlist() {+ // Unset must mean `allowlist` so the toggle is a no-op until an env opts in.+ let config: Config =+ envconfig::Envconfig::init_from_hashmap(&required_config_env()).unwrap();+ assert_eq!(config.ai_lane_predicate, AiLanePredicate::Allowlist);++ let mut env = required_config_env();+ env.insert("CAPTURE_AI_LANE_PREDICATE".into(), "prefix".into());+ let config: Config = envconfig::Envconfig::init_from_hashmap(&env).unwrap();+ assert_eq!(config.ai_lane_predicate, AiLanePredicate::Prefix);++ env.insert("CAPTURE_AI_LANE_PREDICATE".into(), "everything".into());+ let bad: Result<Config, _> = envconfig::Envconfig::init_from_hashmap(&env);+ assert!(+ bad.is_err(),+ "an unknown predicate must fail startup, not silently fall back"+ );+ }+#[test]fn capture_mode_from_str_and_tag_roundtrip() {// Locks the CAPTURE_MODE env contract, including the new `import` modediff --git a/rust/capture/src/event_restrictions/types.rs b/rust/capture/src/event_restrictions/types.rsindex e2ffe68e24b7..765fee87f18f 100644--- a/rust/capture/src/event_restrictions/types.rs+++ b/rust/capture/src/event_restrictions/types.rs@@ -45,7 +45,7 @@ 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`- /// (names on the `AI_EVENT_NAMES` allowlist), so its restriction service+ /// (names the deployment's `AiLanePredicate` accepts), 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.///@@ -416,7 +416,7 @@ mod tests {vec![Pipeline::SessionRecordings]);// Ai serves only the AI lane: its routes are AI-only and its batch path- // rejects anything off the allowlist, so every event it processes+ // rejects anything off the AI lane, so every event it processes// resolves to Pipeline::Ai. Widening this would load slices nothing// looks up; narrowing it below is only safe while both of those hold.assert_eq!(diff --git a/rust/capture/src/events/ai_byte_limit.rs b/rust/capture/src/events/ai_byte_limit.rsindex 91eab37a7a20..8a72982f6dd5 100644--- a/rust/capture/src/events/ai_byte_limit.rs+++ b/rust/capture/src/events/ai_byte_limit.rs@@ -1,6 +1,6 @@//! The AI lane's per-project byte budget. The lane is the whole gate: every-//! event on the `AI_EVENT_NAMES` allowlist is bound for the AI Kafka topic on-//! every deployment, stamped `DataType::AiEvents` in v0 and+//! event the deployment's `AiLanePredicate` accepts is bound for the AI Kafka+//! topic on every deployment, stamped `DataType::AiEvents` in v0 and//! `Destination::AiEvents` in v1. Import deployments are exempt — backfills//! are never throttled, matching the other limiters — which setup enforces by//! not building the limiter at all in import mode.diff --git a/rust/capture/src/events/analytics.rs b/rust/capture/src/events/analytics.rsindex fb9a4ff0e4a4..1931c6d4c1a5 100644--- a/rust/capture/src/events/analytics.rs+++ b/rust/capture/src/events/analytics.rs@@ -130,7 +130,11 @@ pub fn process_single_event(Span::current().record("is_mirror_deploy", context.is_mirror_deploy);Span::current().record("request_id", &context.request_id);- let data_type = DataType::from_event_name(&event.event, context.historical_migration);+ let data_type = DataType::from_event_name(+ &event.event,+ context.historical_migration,+ context.ai_lane_predicate,+ );// Redact the IP address of internally-generated events when tagged as suchlet resolved_ip = if event.properties.contains_key("capture_internal") {@@ -375,9 +379,8 @@ async fn process_events_inner(// abort path emits an `invalid_ai_event` ingestion warning alongside the// 400, so the project owner sees it too.//- // Lane membership is the `AI_EVENT_NAMES` allowlist, not an `$ai_` prefix,- // so a prefixed-but-unlisted name is rejected here too — the Node AI- // pipeline would DLQ it anyway.+ // Lane membership follows the deployment's `AiLanePredicate`, the same+ // answer `DataType::from_event_name` stamped on each event above.if context.capture_mode == crate::config::CaptureMode::Ai {if let Some(offender) = events.iter()@@ -660,7 +663,7 @@ mod tests {use super::*;use crate::ingestion_warnings::SdkAttribution;use crate::utils::uuid_v7_from_datetime;- use crate::v0_request::{OverflowReason, ProcessingContext};+ use crate::v0_request::{AiLanePredicate, OverflowReason, ProcessingContext};use chrono::{DateTime, TimeZone, Utc};use common_ingestion_warnings::test_support::CollectingEmitter;use common_ingestion_warnings::WarningType;@@ -687,6 +690,7 @@ mod tests {chatty_debug_enabled: false,capture_mode: crate::config::CaptureMode::Events,ai_max_event_bytes: 0,+ ai_lane_predicate: AiLanePredicate::Allowlist,sdk_attribution: crate::ingestion_warnings::SdkAttribution::default(),}}@@ -1663,27 +1667,41 @@ mod tests {/// second event is the one under test.struct AiLaneGateCase {second_event: &'static str,+ predicate: AiLanePredicate,rejected: bool,}#[rstest]#[case::analytics_event_is_rejected(AiLaneGateCase {second_event: "$pageview",+ predicate: AiLanePredicate::Allowlist,+ rejected: true,+ })]+ #[case::analytics_event_is_rejected_under_prefix(AiLaneGateCase {+ second_event: "$pageview",+ predicate: AiLanePredicate::Prefix,rejected: true,})]- // Lane membership is the AI_EVENT_NAMES allowlist, not an `$ai_` prefix.- // A prefixed-but-unlisted name resolves to AnalyticsMain, so it must be- // rejected too -- the Node AI pipeline would DLQ it downstream anyway.+ // Under `Allowlist` a prefixed-but-unlisted name resolves to AnalyticsMain,+ // so it is rejected too; under `Prefix` the same name is on the lane.#[case::prefixed_but_unlisted_name_is_rejected(AiLaneGateCase {second_event: "$ai_call",+ predicate: AiLanePredicate::Allowlist,rejected: true,})]+ #[case::prefixed_but_unlisted_name_passes_under_prefix(AiLaneGateCase {+ second_event: "$ai_call",+ predicate: AiLanePredicate::Prefix,+ rejected: false,+ })]#[case::exception_is_rejected(AiLaneGateCase {second_event: "$exception",+ predicate: AiLanePredicate::Allowlist,rejected: true,})]#[case::second_allowlisted_event_passes(AiLaneGateCase {second_event: "$ai_span",+ predicate: AiLanePredicate::Allowlist,rejected: false,})]#[tokio::test]@@ -1695,6 +1713,7 @@ mod tests {.with_timezone(&Utc);let mut context = create_test_context(now, None);context.capture_mode = crate::config::CaptureMode::Ai;+ context.ai_lane_predicate = case.predicate;let events = vec![create_test_event_with_name("$ai_generation", None, None, None),diff --git a/rust/capture/src/events/recordings.rs b/rust/capture/src/events/recordings.rsindex 2cb566938616..303e0c7cfe75 100644--- a/rust/capture/src/events/recordings.rs+++ b/rust/capture/src/events/recordings.rs@@ -865,6 +865,7 @@ mod tests {path: "/s/".to_string(),capture_mode: crate::config::CaptureMode::Recordings,ai_max_event_bytes: 0,+ ai_lane_predicate: crate::v0_request::AiLanePredicate::Allowlist,sdk_attribution: crate::ingestion_warnings::SdkAttribution::default(),}}diff --git a/rust/capture/src/ingestion_warnings/ai.rs b/rust/capture/src/ingestion_warnings/ai.rsindex a58cf64ede45..1b9cb126af05 100644--- a/rust/capture/src/ingestion_warnings/ai.rs+++ b/rust/capture/src/ingestion_warnings/ai.rs@@ -34,6 +34,7 @@ pub fn warning_for_ai_rejection(rejection: &AiRejection) -> Option<WarningType>// Sending ordinary analytics to the AI path, or omitting the one// property every AI event needs.AiRejection::EventNameNotAllowed(_)+ | AiRejection::EventNameNotAiPrefixed(_)| AiRejection::AiModelMissing| AiRejection::AiModelNotString| AiRejection::AiModelEmpty => Some(WarningType::InvalidAiEvent),@@ -145,6 +146,13 @@ fn details_for(rejection: &AiRejection) -> Map<String, serde_json::Value> {json!(crate::ai_rejection::ALLOWED_AI_EVENTS),);}+ AiRejection::EventNameNotAiPrefixed(event_name) => {+ details.insert("eventName".to_string(), json!(bounded_detail(event_name)));+ details.insert(+ "requiredPrefix".to_string(),+ json!(crate::v0_request::AI_LANE_NAME_PREFIX),+ );+ }AiRejection::FirstPartNotEvent(field) | AiRejection::UnknownField(field) => {details.insert("part".to_string(), json!(bounded_detail(field)));}@@ -178,6 +186,10 @@ mod tests {AiRejection::EventNameNotAllowed("$pageview".to_string()),Some(WarningType::InvalidAiEvent))]+ #[case::wrong_event_name_under_prefix(+ AiRejection::EventNameNotAiPrefixed("$pageview".to_string()),+ Some(WarningType::InvalidAiEvent)+ )]#[case::no_model(AiRejection::AiModelMissing, Some(WarningType::InvalidAiEvent))]#[case::no_event_name(AiRejection::EventNameRequired, Some(WarningType::MissingEventName))]#[case::no_distinct_id(AiRejection::DistinctIdEmpty, Some(WarningType::MissingDistinctId))]diff --git a/rust/capture/src/ingestion_warnings/legacy.rs b/rust/capture/src/ingestion_warnings/legacy.rsindex 79dc0d97c685..2baace9440d3 100644--- a/rust/capture/src/ingestion_warnings/legacy.rs+++ b/rust/capture/src/ingestion_warnings/legacy.rs@@ -171,6 +171,7 @@ mod tests {chatty_debug_enabled: false,capture_mode: crate::config::CaptureMode::Events,ai_max_event_bytes: 0,+ ai_lane_predicate: crate::v0_request::AiLanePredicate::Allowlist,sdk_attribution: attribution,}}diff --git a/rust/capture/src/ingestion_warnings/replay.rs b/rust/capture/src/ingestion_warnings/replay.rsindex 8868754d615d..c99d6405d8ce 100644--- a/rust/capture/src/ingestion_warnings/replay.rs+++ b/rust/capture/src/ingestion_warnings/replay.rs@@ -273,6 +273,7 @@ mod tests {chatty_debug_enabled: false,capture_mode: CaptureMode::Recordings,ai_max_event_bytes: 0,+ ai_lane_predicate: crate::v0_request::AiLanePredicate::Allowlist,sdk_attribution: attribution,}}diff --git a/rust/capture/src/overflow_parity.rs b/rust/capture/src/overflow_parity.rsindex 675c0f64e3f0..f15bf410f855 100644--- a/rust/capture/src/overflow_parity.rs+++ b/rust/capture/src/overflow_parity.rs@@ -115,6 +115,7 @@ fn v0_context(now: DateTime<Utc>) -> ProcessingContext {chatty_debug_enabled: false,capture_mode: crate::config::CaptureMode::Events,ai_max_event_bytes: 0,+ ai_lane_predicate: crate::v0_request::AiLanePredicate::Allowlist,sdk_attribution: crate::ingestion_warnings::SdkAttribution::default(),}}diff --git a/rust/capture/src/payload/analytics.rs b/rust/capture/src/payload/analytics.rsindex d5c91bc4475e..99a9ddaff083 100644--- a/rust/capture/src/payload/analytics.rs+++ b/rust/capture/src/payload/analytics.rs@@ -134,6 +134,7 @@ pub async fn handle_event_payload(chatty_debug_enabled,capture_mode: state.capture_mode,ai_max_event_bytes: state.ai_max_event_bytes,+ ai_lane_predicate: state.ai_lane_predicate,sdk_attribution,};debug_or_info!(chatty_debug_enabled, context=?context, event_count=?events.len(), "processing complete");diff --git a/rust/capture/src/payload/recordings.rs b/rust/capture/src/payload/recordings.rsindex 1423f8365aad..45f1a0c52079 100644--- a/rust/capture/src/payload/recordings.rs+++ b/rust/capture/src/payload/recordings.rs@@ -136,6 +136,7 @@ pub async fn handle_recording_payload(chatty_debug_enabled,capture_mode: state.capture_mode,ai_max_event_bytes: 0,+ ai_lane_predicate: crate::v0_request::AiLanePredicate::Allowlist,sdk_attribution: attribution_from_event(&events[0], metadata.user_agent),};diff --git a/rust/capture/src/router.rs b/rust/capture/src/router.rsindex 8fbb86b03bdb..e8c48e8ea018 100644--- a/rust/capture/src/router.rs+++ b/rust/capture/src/router.rs@@ -20,7 +20,7 @@ use crate::global_rate_limiter::GlobalRateLimiter;use crate::otel;use crate::outputs::OutputRegistry;use crate::test_endpoint;-use crate::v0_request::DataType;+use crate::v0_request::{AiLanePredicate, DataType};use crate::{ai_endpoint, time::TimeSource, v0_endpoint};use common_ingestion_warnings::WarningEmitter;use common_redis::Client;@@ -70,6 +70,9 @@ pub struct State {/// Largest AI-lane event this deployment accepts (`AI_MAX_EVENT_BYTES`)./// `0` disables the ceiling.pub ai_max_event_bytes: u64,+ /// How this deployment decides an event name is on the AI lane+ /// (`CAPTURE_AI_LANE_PREDICATE`).+ pub ai_lane_predicate: AiLanePredicate,pub body_chunk_read_timeout: Option<Duration>,pub body_read_chunk_size_kb: usize,pub capture_v1_max_compressed_body_bytes: usize,@@ -186,6 +189,7 @@ pub fn router<TZ: TimeSource + Send + Sync + 'static, R: Client + Send + Sync +verbose_sample_percent: f32,ai_max_sum_of_parts_bytes: usize,ai_max_event_bytes: u64,+ ai_lane_predicate: AiLanePredicate,body_chunk_read_timeout_ms: Option<u64>,body_read_chunk_size_kb: usize,capture_v1_max_compressed_body_bytes: usize,@@ -217,6 +221,7 @@ pub fn router<TZ: TimeSource + Send + Sync + 'static, R: Client + Send + Sync +verbose_sample_percent,ai_max_sum_of_parts_bytes,ai_max_event_bytes,+ ai_lane_predicate,body_chunk_read_timeout: body_chunk_read_timeout_ms.map(Duration::from_millis),body_read_chunk_size_kb,capture_v1_max_compressed_body_bytes,diff --git a/rust/capture/src/setup.rs b/rust/capture/src/setup.rsindex def4a2ba3c65..20f78a8cc175 100644--- a/rust/capture/src/setup.rs+++ b/rust/capture/src/setup.rs@@ -399,6 +399,7 @@ pub async fn build_components(config.verbose_sample_percent,config.ai_max_sum_of_parts_bytes,config.ai_max_event_bytes,+ config.ai_lane_predicate,config.body_chunk_read_timeout_ms,config.body_read_chunk_size_kb,config.capture_v1_max_compressed_body_bytes,@@ -418,6 +419,10 @@ pub async fn build_components("config: is_mirror_deploy == {:?} ; log_level == {:?}",config.is_mirror_deploy, config.log_level);+ info!(+ ai_lane_predicate = config.ai_lane_predicate.as_tag(),+ "AI lane membership predicate"+ );CaptureComponents {app,diff --git a/rust/capture/src/v0_request.rs b/rust/capture/src/v0_request.rsindex 50da7baf5eac..50baa35ca257 100644--- a/rust/capture/src/v0_request.rs+++ b/rust/capture/src/v0_request.rs@@ -153,6 +153,9 @@ pub struct ProcessingContext {/// `AI_MAX_EVENT_BYTES`. `0` disables the ceiling. See/// [`exceeds_max_ai_event_bytes`].pub ai_max_event_bytes: u64,+ /// How this deployment decides an event name is on the AI lane, from+ /// `CAPTURE_AI_LANE_PREDICATE`. See [`AiLanePredicate`].+ pub ai_lane_predicate: AiLanePredicate,/// SDK identity snapshotted from the batch's first event, for ingestion/// warning attribution. Captured at batch construction because the events/// are typed there; downstream stages hold serialized payloads and would@@ -188,12 +191,12 @@ pub enum DataType {AiEvents,}-/// Event names diverted to the dedicated AI lane. Must stay in sync with the-/// AI lane's allowlist (`AI_EVENT_TYPES` in-/// `nodejs/src/ingestion/common/ai-event-types.ts`), which DLQs-/// anything it receives that isn't on the list. Matching on the `$ai_` prefix-/// instead would divert prefixed-but-unlisted names (e.g. `$ai_call`) into the-/// AI topic only for the ingestion pipeline to DLQ them.+/// AI lane membership under [`AiLanePredicate::Prefix`]. The ingestion AI pipeline+/// admits by the same prefix (`isAiEventName` in `nodejs/src/ingestion/common/ai-event-types.ts`).+pub const AI_LANE_NAME_PREFIX: &str = "$ai_";++/// AI lane membership under [`AiLanePredicate::Allowlist`]. Remove once every+/// environment runs [`AiLanePredicate::Prefix`].pub const AI_EVENT_NAMES: &[&str] = &["$ai_generation","$ai_embedding",@@ -208,10 +211,46 @@ pub const AI_EVENT_NAMES: &[&str] = &["$ai_evaluation_report",];-/// Whether an event name is diverted to the dedicated AI lane. See-/// [`AI_EVENT_NAMES`].-pub fn is_ai_event(name: &str) -> bool {- AI_EVENT_NAMES.contains(&name)+/// How a deployment decides an event name is on the AI lane (`CAPTURE_AI_LANE_PREDICATE`).+/// Every "is this an AI event" check goes through [`AiLanePredicate::is_ai_event`] so+/// one deployment never mixes the two answers.+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Default)]+pub enum AiLanePredicate {+ /// Exact membership in [`AI_EVENT_NAMES`].+ #[default]+ Allowlist,+ /// Any name starting with [`AI_LANE_NAME_PREFIX`].+ Prefix,+}++impl AiLanePredicate {+ pub fn is_ai_event(self, name: &str) -> bool {+ match self {+ Self::Allowlist => AI_EVENT_NAMES.contains(&name),+ Self::Prefix => name.starts_with(AI_LANE_NAME_PREFIX),+ }+ }++ pub fn as_tag(self) -> &'static str {+ match self {+ Self::Allowlist => "allowlist",+ Self::Prefix => "prefix",+ }+ }+}++impl std::str::FromStr for AiLanePredicate {+ type Err = String;++ fn from_str(s: &str) -> Result<Self, Self::Err> {+ match s.trim().to_lowercase().as_ref() {+ "allowlist" => Ok(Self::Allowlist),+ "prefix" => Ok(Self::Prefix),+ _ => Err(format!(+ "Unknown AI lane predicate: {s} (expected `allowlist` or `prefix`)"+ )),+ }+ }}/// Whether an AI-lane event's body exceeds the deployment's per-event ceiling.@@ -237,19 +276,23 @@ impl DataType {/// `apply_restrictions` so the analytics → exception → heatmap →/// ingestion-warning split stays in one place.///- /// AI events (per [`is_ai_event`]) divert to `AiEvents` on every- /// deployment, winning over historical (in v1 the historical reroute only- /// applies to the analytics-main destination). Mirrors v1's+ /// AI events (per [`AiLanePredicate::is_ai_event`]) divert to `AiEvents`+ /// on every deployment, winning over historical (in v1 the historical+ /// reroute only applies to the analytics-main destination). Mirrors v1's/// `destination_for_event_name`.////// `SnapshotMain` is not produced here — replay events arrive on a/// separate endpoint and never flow through analytics processing.- pub fn from_event_name(event_name: &str, historical_migration: bool) -> Self {+ pub fn from_event_name(+ event_name: &str,+ historical_migration: bool,+ ai_lane_predicate: AiLanePredicate,+ ) -> Self {match event_name {"$$client_ingestion_warning" => Self::ClientIngestionWarning,"$exception" => Self::ExceptionErrorTracking,"$$heatmap" => Self::HeatmapMain,- _ if is_ai_event(event_name) => Self::AiEvents,+ _ if ai_lane_predicate.is_ai_event(event_name) => Self::AiEvents,_ if historical_migration => Self::AnalyticsHistorical,_ => Self::AnalyticsMain,}@@ -369,47 +412,129 @@ mod tests {use serde::Deserialize;use serde_json::json;- use super::{CaptureError, Compression, DataType, RawRequest};+ use super::{AiLanePredicate, CaptureError, Compression, DataType, RawRequest};/// Mirrors v1's `destination_for_event_name` mapping tests: the- /// dedicated-name lanes always win, an allowlisted AI name diverts on every deployment+ /// dedicated-name lanes always win, an AI name diverts on every deployment/// (beating historical), and everything else falls through to- /// main/historical per the batch flag.+ /// main/historical per the batch flag. The AI lane membership differs by+ /// predicate only for `$ai_`-prefixed names outside the allowlist.#[rstest::rstest]- // Dedicated-name lanes are unaffected by the historical flag.- #[case("$exception", false, DataType::ExceptionErrorTracking)]- #[case("$exception", true, DataType::ExceptionErrorTracking)]- #[case("$$heatmap", false, DataType::HeatmapMain)]- #[case("$$heatmap", true, DataType::HeatmapMain)]- #[case("$$client_ingestion_warning", false, DataType::ClientIngestionWarning)]- #[case("$$client_ingestion_warning", true, DataType::ClientIngestionWarning)]+ // Dedicated-name lanes are unaffected by the historical flag or predicate.+ #[case(+ "$exception",+ false,+ DataType::ExceptionErrorTracking,+ DataType::ExceptionErrorTracking+ )]+ #[case(+ "$exception",+ true,+ DataType::ExceptionErrorTracking,+ DataType::ExceptionErrorTracking+ )]+ #[case("$$heatmap", false, DataType::HeatmapMain, DataType::HeatmapMain)]+ #[case("$$heatmap", true, DataType::HeatmapMain, DataType::HeatmapMain)]+ #[case(+ "$$client_ingestion_warning",+ false,+ DataType::ClientIngestionWarning,+ DataType::ClientIngestionWarning+ )]+ #[case(+ "$$client_ingestion_warning",+ true,+ DataType::ClientIngestionWarning,+ DataType::ClientIngestionWarning+ )]// Non-AI events keep the main/historical split.- #[case("$pageview", false, DataType::AnalyticsMain)]- #[case("custom_event", false, DataType::AnalyticsMain)]- #[case("$pageview", true, DataType::AnalyticsHistorical)]- // Allowlisted AI events divert, and win over historical.- #[case("$ai_generation", false, DataType::AiEvents)]- #[case("$ai_span", false, DataType::AiEvents)]- #[case("$ai_trace", false, DataType::AiEvents)]- #[case("$ai_generation_summary", false, DataType::AiEvents)]- #[case("$ai_generation", true, DataType::AiEvents)]- // Names matching the $ai_ prefix but absent from the allowlist do NOT divert:- // the ingestion AI pipeline would DLQ them, so they stay on the main lane.- #[case("$ai_call", false, DataType::AnalyticsMain)]- #[case("$ai_generation_enriched", false, DataType::AnalyticsMain)]- #[case("$ai_model_failover", false, DataType::AnalyticsMain)]- #[case("$ai_model_failover", true, DataType::AnalyticsHistorical)]+ #[case("$pageview", false, DataType::AnalyticsMain, DataType::AnalyticsMain)]+ #[case(+ "custom_event",+ false,+ DataType::AnalyticsMain,+ DataType::AnalyticsMain+ )]+ #[case(+ "$pageview",+ true,+ DataType::AnalyticsHistorical,+ DataType::AnalyticsHistorical+ )]+ // Names that only look like the prefix never divert.+ #[case(+ "ai_generation",+ false,+ DataType::AnalyticsMain,+ DataType::AnalyticsMain+ )]+ #[case(+ "$AI_generation",+ false,+ DataType::AnalyticsMain,+ DataType::AnalyticsMain+ )]+ #[case("$ai", false, DataType::AnalyticsMain, DataType::AnalyticsMain)]+ // Allowlisted AI events divert under both predicates, and win over historical.+ #[case("$ai_generation", false, DataType::AiEvents, DataType::AiEvents)]+ #[case("$ai_span", false, DataType::AiEvents, DataType::AiEvents)]+ #[case("$ai_trace", false, DataType::AiEvents, DataType::AiEvents)]+ #[case(+ "$ai_generation_summary",+ false,+ DataType::AiEvents,+ DataType::AiEvents+ )]+ #[case("$ai_generation", true, DataType::AiEvents, DataType::AiEvents)]+ // Prefixed-but-unlisted names divert only under the prefix predicate.+ #[case("$ai_call", false, DataType::AnalyticsMain, DataType::AiEvents)]+ #[case(+ "$ai_generation_enriched",+ false,+ DataType::AnalyticsMain,+ DataType::AiEvents+ )]+ #[case(+ "$ai_model_failover",+ false,+ DataType::AnalyticsMain,+ DataType::AiEvents+ )]+ #[case(+ "$ai_model_failover",+ true,+ DataType::AnalyticsHistorical,+ DataType::AiEvents+ )]+ #[case("$ai_", false, DataType::AnalyticsMain, DataType::AiEvents)]fn from_event_name_mapping(#[case] event_name: &str,#[case] historical_migration: bool,- #[case] expected: DataType,+ #[case] expected_allowlist: DataType,+ #[case] expected_prefix: DataType,) {assert_eq!(- DataType::from_event_name(event_name, historical_migration),- expected+ DataType::from_event_name(event_name, historical_migration, AiLanePredicate::Allowlist),+ expected_allowlist+ );+ assert_eq!(+ DataType::from_event_name(event_name, historical_migration, AiLanePredicate::Prefix),+ expected_prefix);}+ #[rstest::rstest]+ #[case("allowlist", Ok(AiLanePredicate::Allowlist))]+ #[case(" Prefix ", Ok(AiLanePredicate::Prefix))]+ #[case("regex", Err(()))]+ #[case("", Err(()))]+ fn ai_lane_predicate_from_str(+ #[case] raw: &str,+ #[case] expected: Result<AiLanePredicate, ()>,+ ) {+ assert_eq!(raw.parse::<AiLanePredicate>().map_err(|_| ()), expected);+ }+#[test]fn decode_compression_param() {#[derive(Deserialize, Debug)]diff --git a/rust/capture/src/v1/analytics/constants.rs b/rust/capture/src/v1/analytics/constants.rsindex 12593951218e..fc39b3768712 100644--- a/rust/capture/src/v1/analytics/constants.rs+++ b/rust/capture/src/v1/analytics/constants.rs@@ -71,8 +71,8 @@ pub(super) const DETAIL_EVENT_RESTRICTION_DROP: &str = "event_restriction_drop";pub(super) const DETAIL_NON_HISTORICAL_DROP: &str = "non_historical_import_drop";/// Detail tag for events dropped by an AI-mode deployment because they are not-/// on the AI lane.-pub(super) const DETAIL_NON_AI_EVENT: &str = "non_ai_event";+/// on the AI lane. Same tag as the `misrouted_event` ingestion warning it emits.+pub(super) const DETAIL_MISROUTED_EVENT: &str = "misrouted_event";/// Detail tag for events dropped due to uncoercible options fields.pub(super) const DETAIL_INVALID_OPTIONS: &str = "invalid_options";diff --git a/rust/capture/src/v1/analytics/process.rs b/rust/capture/src/v1/analytics/process.rsindex 16df3a279cf6..6ff1c34708f1 100644--- a/rust/capture/src/v1/analytics/process.rs+++ b/rust/capture/src/v1/analytics/process.rs@@ -12,7 +12,7 @@ use super::constants::{CAPTURE_V1_EVENT_ADJUSTMENTS_APPLIED, CAPTURE_V1_MAX_EVENT_NAME_LENGTH,CAPTURE_V1_OVERFLOW_ROUTED, CAPTURE_V1_PARSED_EVENTS, CAPTURE_V1_PROCESSING_DURATION_SECONDS,CAPTURE_V1_RATE_LIMITER, DETAIL_AI_BYTE_RATE_LIMITED, DETAIL_AI_EVENT_TOO_BIG,- DETAIL_EVENT_RESTRICTION_DROP, DETAIL_INVALID_OPTIONS, DETAIL_NON_AI_EVENT,+ DETAIL_EVENT_RESTRICTION_DROP, DETAIL_INVALID_OPTIONS, DETAIL_MISROUTED_EVENT,DETAIL_NON_HISTORICAL_DROP, DETAIL_PERSON_PROCESSING_DISABLED, FUTURE_EVENT_HOURS_CUTOFF_MS,ILLEGAL_DISTINCT_IDS,};@@ -21,7 +21,7 @@ use super::types::{Batch, Event, EventResult, Options, WrappedEvent};use crate::event_restrictions::{EventContext, EventRestrictionService};use crate::events::ai_byte_limit::charge_ai_bytes;use crate::global_rate_limiter::{GlobalRateLimitKey, GlobalRateLimiter};-use crate::v0_request::{exceeds_max_ai_event_bytes, is_ai_event};+use crate::v0_request::{exceeds_max_ai_event_bytes, AiLanePredicate};use limiters::overflow::{OverflowLimiter, OverflowLimiterResult};use tracing::Level;@@ -46,14 +46,14 @@ use common_ingestion_warnings::{/// (extractHeatmapDataStep) handles extraction when `skip_heatmap_processing` is unset/// in Kafka headers — removing that fallback would break scroll-depth heatmaps for v1.///-/// AI events (per [`is_ai_event`]) are diverted to `Destination::AiEvents` on-/// every deployment.-fn destination_for_event_name(name: &str) -> Destination {+/// AI events (per the deployment's [`AiLanePredicate`]) are diverted to+/// `Destination::AiEvents` on every deployment.+fn destination_for_event_name(name: &str, ai_lane_predicate: AiLanePredicate) -> Destination {match name {"$exception" => Destination::ExceptionErrorTracking,"$$heatmap" => Destination::HeatmapMain,"$$client_ingestion_warning" => Destination::ClientIngestionWarning,- _ if is_ai_event(name) => Destination::AiEvents,+ _ if ai_lane_predicate.is_ai_event(name) => Destination::AiEvents,_ => Destination::AnalyticsMain,}}@@ -91,7 +91,7 @@ async fn run_pipeline(}context.set_batch_metadata(&batch);- let mut events = match validate_events(context, batch) {+ let mut events = match validate_events(context, state.ai_lane_predicate, batch) {Ok(events) => events,Err(err) => {emit_batch_abort_warning(state, context, &err, batch_len);@@ -150,10 +150,20 @@ async fn run_pipeline(.await;}- apply_ai_event_size_limit(state.ai_max_event_bytes, &mut events);+ apply_ai_event_size_limit(+ state.ai_max_event_bytes,+ state.ai_lane_predicate,+ &mut events,+ );if let Some(ref limiter) = state.ai_byte_rate_limiter {- apply_ai_byte_limits(limiter, &context.api_token, &mut events).await;+ apply_ai_byte_limits(+ limiter,+ &context.api_token,+ state.ai_lane_predicate,+ &mut events,+ )+ .await;}apply_historical_rerouting(&state.historical_cfg, context, &mut events);@@ -487,7 +497,11 @@ fn validate_batch(batch: &Batch) -> Result<(), Error> {Ok(())}-fn validate_events(context: &RequestContext, batch: Batch) -> Result<Vec<WrappedEvent>, Error> {+fn validate_events(+ context: &RequestContext,+ ai_lane_predicate: AiLanePredicate,+ batch: Batch,+) -> Result<Vec<WrappedEvent>, Error> {let batch_len = batch.batch.len();let mut events: Vec<WrappedEvent> = Vec::with_capacity(batch_len);let mut seen: HashSet<Uuid> = HashSet::with_capacity(batch_len);@@ -507,7 +521,7 @@ fn validate_events(context: &RequestContext, batch: Batch) -> Result<Vec<Wrapped));}- let destination = destination_for_event_name(&event.event);+ let destination = destination_for_event_name(&event.event, ai_lane_predicate);match validate_event(&event) {Ok(raw_ts) => {@@ -872,12 +886,12 @@ fn drop_non_ai_events(state: &router::State, context: &Context, events: &mut [Wr// cannot ride an analytics lane out of an AI deployment. Neither case// is reachable at this point today; both make the gate correct on its// own terms rather than on its position in the pipeline.- if !event.should_publish() || on_ai_lane(event) {+ if !event.should_publish() || on_ai_lane(event, state.ai_lane_predicate) {continue;}event.result = EventResult::Drop;event.destination = Destination::Drop;- event.details = Some(DETAIL_NON_AI_EVENT);+ event.details = Some(DETAIL_MISROUTED_EVENT);dropped += 1;single_offender = match dropped {1 => Some((event.event.event.clone(), event.uuid)),@@ -889,12 +903,10 @@ fn drop_non_ai_events(state: &router::State, context: &Context, events: &mut [Wrreturn;}- metrics::counter!(CAPTURE_V1_EVENTS_DROPPED, "reason" => "non_ai_event").increment(dropped);+ metrics::counter!(CAPTURE_V1_EVENTS_DROPPED, "reason" => "misrouted_event").increment(dropped);// DEBUG, not WARN: a client sending the wrong event name is not an operator- // problem, and the SDKs route on the `$ai_` prefix while this gate is the- // narrower name allowlist, so it is expected to fire at client volume. The- // counter above carries the alerting signal and the warning below tells the- // project owner.+ // problem and fires at client volume. The counter above carries the alerting+ // signal and the warning below tells the project owner.crate::ctx_log!(Level::DEBUG,context,@@ -902,9 +914,9 @@ fn drop_non_ai_events(state: &router::State, context: &Context, events: &mut [Wr"dropped non-AI events sent to the AI lane");- // The same `invalid_ai_event` type the v0 AI endpoint emits for an event- // name off the allowlist: identical mistake, so a reader of the v2 warnings- // table doesn't have to learn a second vocabulary for it.+ // `misrouted_event`, not `invalid_ai_event`: the v0 endpoint's warning also+ // covers a missing `$ai_model`, so a reader could not tell "wrong endpoint"+ // from "malformed AI event" without this distinct type.let mut details = serde_json::Map::new();if let Some((event_name, uuid)) = single_offender {details.insert(@@ -917,7 +929,7 @@ fn drop_non_ai_events(state: &router::State, context: &Context, events: &mut [Wrstate.ingestion_warning_emitter.as_deref(),&context.warning_context(),CAPTURE_V1_ANALYTICS,- WarningType::InvalidAiEvent,+ WarningType::MisroutedEvent,details,dropped,);@@ -930,10 +942,10 @@ fn drop_non_ai_events(state: &router::State, context: &Context, events: &mut [Wr/// operator redirected: `force_overflow` retargets an AI event to/// `AiEventsOverflow`, which is still the AI lane, and a `redirect_to_topic`/// or DLQ restriction moves it off `AiEvents` without taking it off the wire.-/// The allowlist is the same source v0 stamps `DataType::AiEvents` from, so-/// both pipelines charge and measure the same set.-fn on_ai_lane(event: &WrappedEvent) -> bool {- is_ai_event(&event.event.event)+/// The predicate is the same one v0 stamps `DataType::AiEvents` from, so both+/// pipelines charge and measure the same set.+fn on_ai_lane(event: &WrappedEvent, ai_lane_predicate: AiLanePredicate) -> bool {+ ai_lane_predicate.is_ai_event(&event.event.event)}/// Drop AI-lane events past the deployment's per-event size ceiling.@@ -946,7 +958,11 @@ fn on_ai_lane(event: &WrappedEvent) -> bool {////// Charged bytes are the event's properties, which dominate an AI event's wire/// size; the serialized envelope is not built until the sink.-fn apply_ai_event_size_limit(max_event_bytes: u64, events: &mut [WrappedEvent]) {+fn apply_ai_event_size_limit(+ max_event_bytes: u64,+ ai_lane_predicate: AiLanePredicate,+ events: &mut [WrappedEvent],+) {if max_event_bytes == 0 {return;}@@ -954,7 +970,7 @@ fn apply_ai_event_size_limit(max_event_bytes: u64, events: &mut [WrappedEvent])let mut dropped: u64 = 0;for event in events.iter_mut() {- if event.result != EventResult::Ok || !on_ai_lane(event) {+ if event.result != EventResult::Ok || !on_ai_lane(event, ai_lane_predicate) {continue;}if exceeds_max_ai_event_bytes(event.event.properties.get().len(), max_event_bytes) {@@ -976,7 +992,7 @@ fn apply_ai_event_size_limit(max_event_bytes: u64, events: &mut [WrappedEvent])/// (`events::ai_byte_limit`), so a token's bytes count once no matter which/// pipeline carries them.///-/// Membership comes from the event-name allowlist, not the current+/// Membership comes from the deployment's lane predicate, not the current/// destination: a restriction that retargets an AI event still spends the/// project's bytes, and `force_overflow` keeps it on the AI lane outright. The/// `EventResult::Ok` guard keeps every upstream drop — validation, quota, a@@ -988,12 +1004,13 @@ fn apply_ai_event_size_limit(max_event_bytes: u64, events: &mut [WrappedEvent])async fn apply_ai_byte_limits(limiter: &GlobalRateLimiter,token: &str,+ ai_lane_predicate: AiLanePredicate,events: &mut [WrappedEvent],) {let mut dropped: u64 = 0;for event in events.iter_mut() {- if event.result != EventResult::Ok || !on_ai_lane(event) {+ if event.result != EventResult::Ok || !on_ai_lane(event, ai_lane_predicate) {continue;}if charge_ai_bytes(limiter, token, event.event.properties.get().len()).await {@@ -1456,7 +1473,7 @@ mod tests {let normal = valid_event();let normal_uuid = Uuid::parse_str(&normal.uuid).unwrap();let batch = valid_batch(vec![perf, normal]);- let events = validate_events(&ctx, batch).unwrap();+ let events = validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap();assert_eq!(events.len(), 2);// Vec preserves input order: perf first, normal second.let p = &events[0];@@ -1480,7 +1497,7 @@ mod tests {..valid_event()};let batch = valid_batch(vec![p1, p2]);- let events = validate_events(&ctx, batch).unwrap();+ let events = validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap();assert_eq!(events.len(), 2);for ev in &events {assert_eq!(ev.result, EventResult::Drop);@@ -1496,7 +1513,7 @@ mod tests {illegal_event.distinct_id = id.to_string();let legal_event = valid_event();let batch = valid_batch(vec![illegal_event, legal_event]);- let events = validate_events(&ctx, batch).unwrap();+ let events = validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap();assert_eq!(events.len(), 2, "id={id:?}");let flagged = &events[0];@@ -1521,7 +1538,7 @@ mod tests {let ctx = test_utils::test_context();let event = deserialized_event(&Uuid::new_v4().to_string(), " NULL ");let batch = valid_batch(vec![event]);- let events = validate_events(&ctx, batch).unwrap();+ let events = validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap();assert_eq!(events[0].result, EventResult::Ok);assert!(events[0].force_disable_person_processing);assert_eq!(events[0].details, Some(DETAIL_PERSON_PROCESSING_DISABLED));@@ -1534,7 +1551,7 @@ mod tests {let mut illegal_event = valid_event();illegal_event.distinct_id = id.to_string();let batch = valid_batch(vec![illegal_event]);- let events = validate_events(&ctx, batch).unwrap();+ let events = validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap();assert_eq!(events.len(), 1, "id={id:?}");assert!(events[0].should_publish(), "id={id:?}");}@@ -1561,7 +1578,7 @@ mod tests {},],};- let err = validate_events(&ctx, batch).unwrap_err();+ let err = validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap_err();assert!(matches!(err, Error::DuplicateEventUuid(_)));}@@ -1577,7 +1594,7 @@ mod tests {..valid_event()}],};- let err = validate_events(&ctx, batch).unwrap_err();+ let err = validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap_err();assert!(matches!(err, Error::InvalidEventUuid(_)));}@@ -1593,7 +1610,7 @@ mod tests {..valid_event()}],};- let err = validate_events(&ctx, batch).unwrap_err();+ let err = validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap_err();assert!(matches!(err, Error::MissingEventUuid));}@@ -1625,7 +1642,7 @@ mod tests {let count = dropped_count("duplicate_event_uuid", "validation_abort", || {assert!(matches!(- validate_events(&ctx, batch).unwrap_err(),+ validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap_err(),Error::DuplicateEventUuid(_)));});@@ -1647,7 +1664,7 @@ mod tests {let count = dropped_count("invalid_event_uuid", "validation_abort", || {assert!(matches!(- validate_events(&ctx, batch).unwrap_err(),+ validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap_err(),Error::InvalidEventUuid(_)));});@@ -1667,7 +1684,7 @@ mod tests {let count = dropped_count("missing_event_uuid", "validation_abort", || {assert!(matches!(- validate_events(&ctx, batch).unwrap_err(),+ validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap_err(),Error::MissingEventUuid));});@@ -1715,7 +1732,7 @@ mod tests {let event = deserialized_event(&padded_uuid, "user-42");assert_eq!(event.uuid, inner_uuid.to_string());let batch = valid_batch(vec![event]);- let events = validate_events(&ctx, batch).unwrap();+ let events = validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap();assert_eq!(events.len(), 1);assert_eq!(events[0].uuid, inner_uuid);}@@ -1734,7 +1751,7 @@ mod tests {capture_internal: None,batch: vec![bad_event],};- let events = validate_events(&ctx, batch).unwrap();+ let events = validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap();assert_eq!(events.len(), 1);let event = &events[0];assert_eq!(event.uuid, uuid);@@ -1760,7 +1777,7 @@ mod tests {capture_internal: None,batch: vec![good, bad],};- let events = validate_events(&ctx, batch).unwrap();+ let events = validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap();assert_eq!(events.len(), 2);assert_eq!(events[0].result, EventResult::Ok);@@ -1789,7 +1806,7 @@ mod tests {capture_internal: None,batch: vec![ev1, ev2],};- let result = validate_events(&ctx, batch);+ let result = validate_events(&ctx, AiLanePredicate::Allowlist, batch);assert!(result.is_ok());let events = result.unwrap();assert_eq!(events[0].result, EventResult::Drop);@@ -1811,7 +1828,7 @@ mod tests {capture_internal: None,batch: vec![ev],};- let events = validate_events(&ctx, batch).unwrap();+ let events = validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap();assert_eq!(events[0].result, EventResult::Ok);assert_eq!(events[0].options.disable_skew_correction, Some(true));}@@ -1835,7 +1852,7 @@ mod tests {capture_internal: None,batch: vec![ev],};- let events = validate_events(&ctx, batch).unwrap();+ let events = validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap();assert_eq!(events[0].result, EventResult::Drop);assert_eq!(events[0].details, Some("missing_event_name"));}@@ -2106,7 +2123,7 @@ mod tests {let mut events = vec![oversized, small];- apply_ai_event_size_limit(700, &mut events);+ apply_ai_event_size_limit(700, AiLanePredicate::Allowlist, &mut events);let big = find_by_did(&events, "user-big");assert_eq!(big.result, EventResult::Drop);@@ -2131,7 +2148,7 @@ mod tests {test_utils::raw_obj(&format!(r#"{{"$ai_input":"{}"}}"#, "x".repeat(800)));let mut events = vec![oversized];- apply_ai_event_size_limit(0, &mut events);+ apply_ai_event_size_limit(0, AiLanePredicate::Allowlist, &mut events);assert_eq!(events[0].result, EventResult::Ok);assert_eq!(events[0].destination, Destination::AiEvents);@@ -2148,7 +2165,7 @@ mod tests {oversized.destination = Destination::AiEventsOverflow;let mut events = vec![oversized];- apply_ai_event_size_limit(700, &mut events);+ apply_ai_event_size_limit(700, AiLanePredicate::Allowlist, &mut events);assert_eq!(events[0].result, EventResult::Drop);assert_eq!(events[0].destination, Destination::Drop);@@ -2178,7 +2195,13 @@ mod tests {event.destination = destination.clone();}- apply_ai_byte_limits(&limiter, "phc_token", &mut events).await;+ apply_ai_byte_limits(+ &limiter,+ "phc_token",+ AiLanePredicate::Allowlist,+ &mut events,+ )+ .await;assert_eq!(events[0].result, EventResult::Ok);assert_eq!(events[0].destination, destination);@@ -2197,7 +2220,13 @@ mod tests {wrapped_event("$pageview", "user-2"),];- apply_ai_byte_limits(&limiter, "phc_token", &mut events).await;+ apply_ai_byte_limits(+ &limiter,+ "phc_token",+ AiLanePredicate::Allowlist,+ &mut events,+ )+ .await;for event in &events {assert_eq!(event.result, EventResult::Ok);@@ -2223,7 +2252,13 @@ mod tests {let mut events = vec![already_dropped, publishable];- apply_ai_byte_limits(&limiter, "phc_token", &mut events).await;+ apply_ai_byte_limits(+ &limiter,+ "phc_token",+ AiLanePredicate::Allowlist,+ &mut events,+ )+ .await;let ev = find_by_did(&events, "user-1");assert_eq!(@@ -2362,25 +2397,68 @@ mod tests {// --- destination_for_event_name ---+ /// Every non-AI row is identical in both modes; only `$ai_`-prefixed names+ /// off the allowlist move, and only under `Prefix`.#[rstest::rstest]- #[case("$exception", Destination::ExceptionErrorTracking)]- #[case("$$heatmap", Destination::HeatmapMain)]- #[case("$$client_ingestion_warning", Destination::ClientIngestionWarning)]- #[case("$pageview", Destination::AnalyticsMain)]- #[case("custom_event", Destination::AnalyticsMain)]- #[case("$autocapture", Destination::AnalyticsMain)]- // Allowlisted AI events divert on every deployment.- #[case("$ai_generation", Destination::AiEvents)]- #[case("$ai_span", Destination::AiEvents)]- #[case("$ai_trace", Destination::AiEvents)]- #[case("$ai_generation_summary", Destination::AiEvents)]- // $ai_ prefixed names absent from the allowlist stay on Main so the- // ingestion AI pipeline doesn't DLQ them.- #[case("$ai_call", Destination::AnalyticsMain)]- #[case("$ai_generation_enriched", Destination::AnalyticsMain)]- #[case("$ai_model_failover", Destination::AnalyticsMain)]- fn destination_for_event_name_mapping(#[case] event_name: &str, #[case] expected: Destination) {- assert_eq!(destination_for_event_name(event_name), expected);+ #[case(+ "$exception",+ Destination::ExceptionErrorTracking,+ Destination::ExceptionErrorTracking+ )]+ #[case("$$heatmap", Destination::HeatmapMain, Destination::HeatmapMain)]+ #[case(+ "$$client_ingestion_warning",+ Destination::ClientIngestionWarning,+ Destination::ClientIngestionWarning+ )]+ #[case("$pageview", Destination::AnalyticsMain, Destination::AnalyticsMain)]+ #[case("custom_event", Destination::AnalyticsMain, Destination::AnalyticsMain)]+ #[case("$autocapture", Destination::AnalyticsMain, Destination::AnalyticsMain)]+ // Allowlisted AI events divert on every deployment in both modes.+ #[case("$ai_generation", Destination::AiEvents, Destination::AiEvents)]+ #[case("$ai_span", Destination::AiEvents, Destination::AiEvents)]+ #[case("$ai_trace", Destination::AiEvents, Destination::AiEvents)]+ #[case("$ai_generation_summary", Destination::AiEvents, Destination::AiEvents)]+ // `$ai_`-prefixed names absent from the allowlist: Main under `Allowlist`+ // (the AI pipeline of that era would DLQ them), AI lane under `Prefix`.+ #[case("$ai_call", Destination::AnalyticsMain, Destination::AiEvents)]+ #[case(+ "$ai_generation_enriched",+ Destination::AnalyticsMain,+ Destination::AiEvents+ )]+ #[case(+ "$ai_model_failover",+ Destination::AnalyticsMain,+ Destination::AiEvents+ )]+ // Prefix means `$ai_`, not `$ai`: a name without the underscore never diverts.+ #[case("$ai", Destination::AnalyticsMain, Destination::AnalyticsMain)]+ #[case(+ "$aigeneration",+ Destination::AnalyticsMain,+ Destination::AnalyticsMain+ )]+ #[case(+ "ai_generation",+ Destination::AnalyticsMain,+ Destination::AnalyticsMain+ )]+ fn destination_for_event_name_mapping(+ #[case] event_name: &str,+ #[case] under_allowlist: Destination,+ #[case] under_prefix: Destination,+ ) {+ assert_eq!(+ destination_for_event_name(event_name, AiLanePredicate::Allowlist),+ under_allowlist,+ "allowlist: {event_name}"+ );+ assert_eq!(+ destination_for_event_name(event_name, AiLanePredicate::Prefix),+ under_prefix,+ "prefix: {event_name}"+ );}// --- restrictions bypass pipeline-less events ---@@ -3241,7 +3319,7 @@ mod tests {};let batch = valid_batch(vec![normal_a, perf, normal_b, normal_c]);- let events = validate_events(&ctx, batch).unwrap();+ let events = validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap();assert_eq!(distinct_id_sequence(&events),@@ -3255,7 +3333,7 @@ mod tests {let ctx = test_utils::test_context();let (first, second) = test_utils::realistic_dup_uuid_pair();let batch = valid_batch(vec![first, second]);- let err = validate_events(&ctx, batch).unwrap_err();+ let err = validate_events(&ctx, AiLanePredicate::Allowlist, batch).unwrap_err();assert!(matches!(err, Error::DuplicateEventUuid(_)));}@@ -4476,7 +4554,7 @@ mod tests {assert_eq!(entry.result, EventResult::Ok);} else {assert_eq!(entry.result, EventResult::Drop);- assert_eq!(entry.details, Some(DETAIL_NON_AI_EVENT));+ assert_eq!(entry.details, Some(DETAIL_MISROUTED_EVENT));}}assert!(!resp.has_retry, "a gated batch must not signal retry");@@ -4487,33 +4565,43 @@ mod tests {});}- /// Lane membership is the `AI_EVENT_NAMES` allowlist, so an `$ai_`-prefixed- /// name that is not on it is dropped like any other non-AI event; the Node- /// AI pipeline would DLQ it anyway.+ /// Under `Allowlist` an unlisted `$ai_*` name drops like any non-AI event; under+ /// `Prefix` it is admitted. Non-AI names drop in both modes.#[rstest::rstest]- #[case::allowlisted("$ai_generation", EventResult::Ok)]- #[case::allowlisted_span("$ai_span", EventResult::Ok)]- #[case::prefixed_but_unlisted("$ai_not_a_real_event", EventResult::Drop)]- #[case::analytics("$pageview", EventResult::Drop)]- #[case::exception("$exception", EventResult::Drop)]- #[case::heatmap("$$heatmap", EventResult::Drop)]+ #[case::allowlisted("$ai_generation", EventResult::Ok, EventResult::Ok)]+ #[case::allowlisted_span("$ai_span", EventResult::Ok, EventResult::Ok)]+ #[case::prefixed_but_unlisted("$ai_not_a_real_event", EventResult::Drop, EventResult::Ok)]+ #[case::analytics("$pageview", EventResult::Drop, EventResult::Drop)]+ #[case::exception("$exception", EventResult::Drop, EventResult::Drop)]+ #[case::heatmap("$$heatmap", EventResult::Drop, EventResult::Drop)]+ #[case::prefix_needs_underscore("$aigeneration", EventResult::Drop, EventResult::Drop)]#[tokio::test]- async fn ai_mode_gates_on_the_ai_event_allowlist(+ async fn ai_mode_gates_on_the_ai_lane_predicate(#[case] event_name: &str,- #[case] expected: EventResult,+ #[case] under_allowlist: EventResult,+ #[case] under_prefix: EventResult,) {- let ts = TestStateBuilder::new()- .with_capture_mode(CaptureMode::Ai)- .build();- let mut ctx = test_utils::test_analytics_context();- let batch = valid_batch(vec![named_event(event_name)]);-- let resp = process_batch(&ts.state, &mut ctx, batch).await.unwrap();-- let (_, entry) = &resp.entries()[0];- assert_eq!(entry.result, expected, "event={event_name}");- if expected == EventResult::Drop {- assert_eq!(entry.details, Some(DETAIL_NON_AI_EVENT));+ for (predicate, expected) in [+ (AiLanePredicate::Allowlist, under_allowlist),+ (AiLanePredicate::Prefix, under_prefix),+ ] {+ let ts = TestStateBuilder::new()+ .with_capture_mode(CaptureMode::Ai)+ .with_ai_lane_predicate(predicate)+ .build();+ let mut ctx = test_utils::test_analytics_context();+ let batch = valid_batch(vec![named_event(event_name)]);++ let resp = process_batch(&ts.state, &mut ctx, batch).await.unwrap();++ let (_, entry) = &resp.entries()[0];+ assert_eq!(+ entry.result, expected,+ "event={event_name} predicate={predicate:?}"+ );+ if expected == EventResult::Drop {+ assert_eq!(entry.details, Some(DETAIL_MISROUTED_EVENT));+ }}}@@ -4562,7 +4650,7 @@ mod tests {assert_eq!(entries.len(), 3, "every event still gets a verdict");for (_, entry) in entries {assert_eq!(entry.result, EventResult::Drop);- assert_eq!(entry.details, Some(DETAIL_NON_AI_EVENT));+ assert_eq!(entry.details, Some(DETAIL_MISROUTED_EVENT));}assert!(!resp.has_retry, "a fully gated batch must not signal retry");ts.mock_producer@@ -4620,11 +4708,11 @@ mod tests {assert_eq!(events[0].result, EventResult::Drop);assert_eq!(events[0].destination, Destination::Drop);- assert_eq!(events[0].details, Some(DETAIL_NON_AI_EVENT));+ assert_eq!(events[0].details, Some(DETAIL_MISROUTED_EVENT));}#[tokio::test]- async fn ai_mode_non_ai_drop_emits_the_invalid_ai_event_warning() {+ async fn ai_mode_non_ai_drop_emits_the_misrouted_event_warning() {let collector = Arc::new(CollectingEmitter::new());let ts = TestStateBuilder::new().with_capture_mode(CaptureMode::Ai)@@ -4639,7 +4727,7 @@ mod tests {let emitted = collector.emitted();assert_eq!(emitted.len(), 1);- assert_eq!(emitted[0].warning, WarningType::InvalidAiEvent);+ assert_eq!(emitted[0].warning, WarningType::MisroutedEvent);assert_eq!(emitted[0].count, 1);assert_eq!(emitted[0].extra_details.get("eventName"),@@ -4752,7 +4840,7 @@ mod tests {let emitted = collector.emitted();assert_eq!(emitted.len(), 1);- assert_eq!(emitted[0].warning, WarningType::InvalidAiEvent);+ assert_eq!(emitted[0].warning, WarningType::MisroutedEvent);assert_eq!(emitted[0].count, 2);assert!(!emitted[0].extra_details.contains_key("eventName"));assert!(!emitted[0].extra_details.contains_key("eventUuid"));diff --git a/rust/capture/src/v1/quota_limiter_shim.rs b/rust/capture/src/v1/quota_limiter_shim.rsindex ce4f1250a2aa..31215d78f11a 100644--- a/rust/capture/src/v1/quota_limiter_shim.rs+++ b/rust/capture/src/v1/quota_limiter_shim.rs@@ -243,6 +243,7 @@ mod tests {s3_fallback_prefix: String::new(),ai_max_sum_of_parts_bytes: 26_214_400,ai_max_event_bytes: 8_388_608,+ ai_lane_predicate: crate::v0_request::AiLanePredicate::Allowlist,ai_gateway_signing_secret: None,http1_header_read_timeout_ms: Some(5000),body_chunk_read_timeout_ms: None,diff --git a/rust/capture/src/v1/test_utils.rs b/rust/capture/src/v1/test_utils.rsindex 4b52413552c9..af76b9beef5c 100644--- a/rust/capture/src/v1/test_utils.rs+++ b/rust/capture/src/v1/test_utils.rs@@ -678,6 +678,7 @@ use crate::global_rate_limiter::GlobalRateLimiter;use crate::quota_limiters::CaptureQuotaLimiter;use crate::router::{self, HistoricalConfig};use crate::time::TimeSource;+use crate::v0_request::AiLanePredicate;use crate::v1::sinks::kafka::mock::MockProducer;use crate::v1::sinks::kafka::sink::KafkaSink;use crate::v1::sinks::sink::Sink;@@ -706,6 +707,7 @@ pub struct TestStateBuilder {ingestion_warning_emitter: Option<Arc<dyn common_ingestion_warnings::WarningEmitter>>,capture_mode: CaptureMode,ai_max_event_bytes: u64,+ ai_lane_predicate: AiLanePredicate,}impl Default for TestStateBuilder {@@ -731,6 +733,7 @@ impl TestStateBuilder {ingestion_warning_emitter: None,capture_mode: CaptureMode::Events,ai_max_event_bytes: 0,+ ai_lane_predicate: AiLanePredicate::Allowlist,}}@@ -831,6 +834,11 @@ impl TestStateBuilder {self}+ pub fn with_ai_lane_predicate(mut self, predicate: AiLanePredicate) -> Self {+ self.ai_lane_predicate = predicate;+ self+ }+pub fn build(self) -> TestState {let mut manager = lifecycle::Manager::builder("test_state").with_trap_signals(false)@@ -942,6 +950,7 @@ impl TestStateBuilder {verbose_sample_percent: 0.0,ai_max_sum_of_parts_bytes: 100 * 1024 * 1024,ai_max_event_bytes: self.ai_max_event_bytes,+ ai_lane_predicate: self.ai_lane_predicate,body_chunk_read_timeout: None,body_read_chunk_size_kb: 64,capture_v1_max_compressed_body_bytes: 2 * 1024 * 1024,diff --git a/rust/capture/tests/common/integration_utils.rs b/rust/capture/tests/common/integration_utils.rsindex 229aff1e1712..de058a6e89df 100644--- a/rust/capture/tests/common/integration_utils.rs+++ b/rust/capture/tests/common/integration_utils.rs@@ -12,7 +12,7 @@ use capture::{quota_limiters::CaptureQuotaLimiter,router::router,time::TimeSource,- v0_request::{DataType, ProcessedEvent},+ v0_request::{AiLanePredicate, DataType, ProcessedEvent},v1::test_utils::TestStateBuilder,};use chrono::{DateTime, Utc};@@ -1121,8 +1121,9 @@ fn build_router_for_mode_at(historical_rerouting_threshold_days,is_mirror_deploy,verbose_sample_percent,- 26_214_400, // 25MB default for AI endpoint- 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ 26_214_400, // 25MB default for AI endpoint+ 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None, // body_chunk_read_timeout_ms256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytesdiff --git a/rust/capture/tests/common/utils.rs b/rust/capture/tests/common/utils.rsindex 84e1427910f0..067e984d4cac 100644--- a/rust/capture/tests/common/utils.rs+++ b/rust/capture/tests/common/utils.rs@@ -161,6 +161,7 @@ pub static DEFAULT_CONFIG: Lazy<Config> = Lazy::new(|| Config {s3_fallback_prefix: String::new(),ai_max_sum_of_parts_bytes: 26_214_400, // 25MB defaultai_max_event_bytes: 8_388_608, // 8MiB default+ ai_lane_predicate: capture::v0_request::AiLanePredicate::Allowlist,ai_gateway_signing_secret: None,http1_header_read_timeout_ms: Some(5000), // 5 seconds defaultbody_chunk_read_timeout_ms: None, // disabled by default in testsdiff --git a/rust/capture/tests/integration_ai_endpoint.rs b/rust/capture/tests/integration_ai_endpoint.rsindex 6a5727d9f08c..09fe2caa3540 100644--- a/rust/capture/tests/integration_ai_endpoint.rs+++ b/rust/capture/tests/integration_ai_endpoint.rs@@ -12,7 +12,7 @@ use capture::outputs::{OutputRegistry, PublishEvents};use capture::quota_limiters::CaptureQuotaLimiter;use capture::router::router;use capture::time::TimeSource;-use capture::v0_request::{OverflowReason, ProcessedEvent};+use capture::v0_request::{AiLanePredicate, OverflowReason, ProcessedEvent};use chrono::{DateTime, TimeZone, Utc};use common_ingestion_warnings::test_support::CollectingEmitter;use common_ingestion_warnings::{WarningEmitter, WarningType, CAPTURE_AI_EVENTS};@@ -133,6 +133,10 @@ fn create_ai_event_form(event_name: &str, distinct_id: &str, properties: Value)// Helper to setup test routerfn setup_ai_test_router() -> Router {+ setup_ai_test_router_with_predicate(AiLanePredicate::Allowlist)+}++fn setup_ai_test_router_with_predicate(ai_lane_predicate: AiLanePredicate) -> Router {let (readiness, liveness, _monitor) = test_lifecycle_handlers();let sink = TestSink;@@ -167,8 +171,9 @@ fn setup_ai_test_router() -> Router {1_i64,false,0.0_f32,- 26_214_400, // 25MB default for AI endpoint- 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ 26_214_400, // 25MB default for AI endpoint+ 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ ai_lane_predicate,None, // body_chunk_read_timeout_ms256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytes@@ -226,6 +231,7 @@ fn setup_ai_router_collecting_warnings() -> (Router, Arc<CollectingEmitter>) {0.0_f32,26_214_400,983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None,256,10 * 1024 * 1024,@@ -685,6 +691,41 @@ async fn test_invalid_ai_event_type_returns_400() {}}+/// Under `CAPTURE_AI_LANE_PREDICATE=prefix` the endpoint accepts any `$ai_*`+/// name and refuses the rest with a message naming the prefix rule, not the+/// allowlist. `$ai_model` is still required either way.+#[tokio::test]+async fn prefix_predicate_accepts_any_ai_prefixed_name_on_the_ai_endpoint() {+ let router = setup_ai_test_router_with_predicate(AiLanePredicate::Prefix);+ let test_client = TestClient::new(router);+ let token = Some("phc_VXRzc3poSG9GZm1JenRianJ6TTJFZGh4OWY2QXzx9f3");++ for event_name in ["$ai_generation", "$ai_unknown", "$ai_custom"] {+ let form = create_ai_event_form(event_name, "test_user", json!({"$ai_model": "m"}));+ let response = send_multipart_request(&test_client, form, token).await;+ assert_eq!(+ response.status(),+ StatusCode::OK,+ "Event type {event_name} should be accepted under prefix"+ );+ }++ for event_name in ["$pageview", "ai_generation", "$aigeneration"] {+ let form = create_ai_event_form(event_name, "test_user", json!({"$ai_model": "m"}));+ let response = send_multipart_request(&test_client, form, token).await;+ assert_eq!(+ response.status(),+ StatusCode::BAD_REQUEST,+ "Event type {event_name} should be rejected under prefix"+ );+ let body = response.text().await;+ assert!(+ body.contains("must start with '$ai_'"),+ "rejection must name the prefix rule, got: {body}"+ );+ }+}+#[tokio::test]async fn test_missing_required_ai_properties_returns_400() {let router = setup_ai_test_router();@@ -1294,8 +1335,9 @@ fn setup_ai_test_router_with_capturing_sink() -> (Router, CapturingSink) {1_i64,false,0.0_f32,- 26_214_400, // 25MB default for AI endpoint- 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ 26_214_400, // 25MB default for AI endpoint+ 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None, // body_chunk_read_timeout_ms256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytes@@ -1966,6 +2008,7 @@ fn setup_ai_test_router_with_token_dropper(token_dropper: TokenDropper) -> (Rout0.0, // verbose_sample_percent26_214_400, // ai_max_sum_of_parts_bytes983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None, // body_chunk_read_timeout_ms256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytes@@ -2033,6 +2076,7 @@ fn setup_ai_test_router_with_byte_limiter() -> (Router, CapturingSink) {0.0, // verbose_sample_percent26_214_400, // ai_max_sum_of_parts_bytes983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None, // body_chunk_read_timeout_ms256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytes@@ -2295,7 +2339,8 @@ fn setup_ai_test_router_with_llm_quota_limited(token: &str) -> (Router, Capturinfalse,0.0_f32,26_214_400,- 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None, // body_chunk_read_timeout_ms256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytes@@ -2455,6 +2500,7 @@ fn setup_ai_test_router_with_overflow_limiter(0.0_f32,26_214_400,983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None,256,10 * 1024 * 1024, // capture_v1_max_compressed_body_bytes@@ -2597,6 +2643,7 @@ fn ai_router(0.0_f32,26_214_400,983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None,256,10 * 1024 * 1024,diff --git a/rust/capture/tests/integration_ai_restrictions.rs b/rust/capture/tests/integration_ai_restrictions.rsindex 30f7b8e4a8bb..42a48d01a7f0 100644--- a/rust/capture/tests/integration_ai_restrictions.rs+++ b/rust/capture/tests/integration_ai_restrictions.rs@@ -15,7 +15,7 @@ use capture::outputs::{OutputRegistry, PublishEvents};use capture::quota_limiters::CaptureQuotaLimiter;use capture::router::router;use capture::time::TimeSource;-use capture::v0_request::{DataType, OverflowReason, ProcessedEvent};+use capture::v0_request::{AiLanePredicate, DataType, OverflowReason, ProcessedEvent};use chrono::{DateTime, Utc};use common_redis::MockRedisClient;use futures::StreamExt;@@ -169,6 +169,7 @@ async fn setup_ai_router_with_restriction(0.0_f32,26_214_400,983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None,256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytes@@ -491,6 +492,7 @@ async fn setup_ai_router_with_redirect_to_topic(0.0_f32,26_214_400,983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None,256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytes@@ -571,6 +573,7 @@ async fn setup_ai_router_with_force_overflow_and_limiter(0.0_f32,26_214_400,983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None,256,10 * 1024 * 1024, // capture_v1_max_compressed_body_bytesdiff --git a/rust/capture/tests/integration_analytics_ai_routing.rs b/rust/capture/tests/integration_analytics_ai_routing.rsindex 7edc844a0244..10f73d7ef8ed 100644--- a/rust/capture/tests/integration_analytics_ai_routing.rs+++ b/rust/capture/tests/integration_analytics_ai_routing.rs@@ -18,7 +18,7 @@ use capture::outputs::{OutputRegistry, PublishEvents};use capture::quota_limiters::CaptureQuotaLimiter;use capture::router::router;use capture::time::TimeSource;-use capture::v0_request::{DataType, OverflowReason, ProcessedEvent};+use capture::v0_request::{AiLanePredicate, DataType, OverflowReason, ProcessedEvent};use chrono::{DateTime, Utc};use common_redis::MockRedisClient;use integration_utils::{test_lifecycle_handlers, DEFAULT_CONFIG, DEFAULT_TEST_TIME};@@ -75,6 +75,7 @@ fn setup_analytics_router() -> (Router, CapturingSink) {setup_router_for_mode(CaptureMode::Events,+ AiLanePredicate::Allowlist,ai_events_overflow_enabled,overflow_limiter,ai_events_overflow_limiter,@@ -83,6 +84,7 @@ fn setup_analytics_router(fn setup_router_for_mode(capture_mode: CaptureMode,+ ai_lane_predicate: AiLanePredicate,ai_events_overflow_enabled: bool,overflow_limiter: Option<Arc<OverflowLimiter>>,ai_events_overflow_limiter: Option<Arc<OverflowLimiter>>,@@ -124,6 +126,7 @@ fn setup_router_for_mode(0.0_f32,26_214_400,983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ ai_lane_predicate,None,256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytes@@ -304,7 +307,13 @@ async fn mixed_batch_diverts_only_ai_events(#[case] ai_events_overflow_enabled:/// half of the old version of this test now lives below.#[tokio::test]async fn ai_mode_diverts_ai_events_like_every_other_mode() {- let (router, sink) = setup_router_for_mode(CaptureMode::Ai, false, None, None);+ let (router, sink) = setup_router_for_mode(+ CaptureMode::Ai,+ AiLanePredicate::Allowlist,+ false,+ None,+ None,+ );let client = TestClient::new(router);let response = client@@ -326,12 +335,58 @@ async fn ai_mode_diverts_ai_events_like_every_other_mode() {);}+/// `CAPTURE_AI_LANE_PREDICATE` decides where an `$ai_`-prefixed name off the+/// allowlist lands, end to end through `/batch`: analytics lane under+/// `allowlist`, AI lane under `prefix`. The listed name diverts either way.+#[rstest]+#[case::allowlist(AiLanePredicate::Allowlist, DataType::AnalyticsMain)]+#[case::prefix(AiLanePredicate::Prefix, DataType::AiEvents)]+#[tokio::test]+async fn unlisted_ai_prefixed_name_follows_the_configured_predicate(+ #[case] predicate: AiLanePredicate,+ #[case] expected_unlisted_lane: DataType,+) {+ let (router, sink) = setup_router_for_mode(CaptureMode::Events, predicate, false, None, None);+ let client = TestClient::new(router);++ let payload = json!({+ "api_key": TOKEN,+ "batch": [+ {"event": "$ai_generation", "distinct_id": DISTINCT_ID, "properties": {"$ai_model": "gpt-4"}},+ {"event": "$ai_custom_step", "distinct_id": DISTINCT_ID, "properties": {}},+ {"event": "$pageview", "distinct_id": DISTINCT_ID, "properties": {}}+ ]+ })+ .to_string();+ post_batch(&client, payload).await;++ let events = sink.get_events().await;+ assert_eq!(events.len(), 3);+ let lane_of = |name: &str| {+ events+ .iter()+ .find(|e| e.metadata.event_name == name)+ .unwrap_or_else(|| panic!("{name} must reach the sink"))+ .metadata+ .data_type+ };+ assert_eq!(lane_of("$ai_generation"), DataType::AiEvents);+ assert_eq!(lane_of("$ai_custom_step"), expected_unlisted_lane);+ assert_eq!(lane_of("$pageview"), DataType::AnalyticsMain);+}+/// The endpoint-level half of the AI-lane gate. The unit tests in/// `events::analytics` call `process_events` directly, so only this proves the/// rejection is reachable through the router and surfaces as a 400.#[tokio::test]async fn ai_mode_rejects_a_mixed_batch_through_the_endpoint() {- let (router, sink) = setup_router_for_mode(CaptureMode::Ai, false, None, None);+ let (router, sink) = setup_router_for_mode(+ CaptureMode::Ai,+ AiLanePredicate::Allowlist,+ false,+ None,+ None,+ );let client = TestClient::new(router);let response = client@@ -461,6 +516,7 @@ async fn ai_lane_overflow_isolated_from_analytics_limiter() {async fn import_mode_historical_batch_never_overflows() {let (router, sink) = setup_router_for_mode(CaptureMode::Import,+ AiLanePredicate::Allowlist,false,Some(force_keyed_limiter()),None,diff --git a/rust/capture/tests/integration_analytics_restrictions.rs b/rust/capture/tests/integration_analytics_restrictions.rsindex 9d4f881e267e..5892ad5ab6f0 100644--- a/rust/capture/tests/integration_analytics_restrictions.rs+++ b/rust/capture/tests/integration_analytics_restrictions.rs@@ -15,7 +15,7 @@ use capture::outputs::{OutputRegistry, PublishEvents};use capture::quota_limiters::CaptureQuotaLimiter;use capture::router::router;use capture::time::TimeSource;-use capture::v0_request::{DataType, ProcessedEvent};+use capture::v0_request::{AiLanePredicate, DataType, ProcessedEvent};use chrono::{DateTime, Utc};use common_redis::MockRedisClient;use integration_utils::{test_lifecycle_handlers, DEFAULT_CONFIG, DEFAULT_TEST_TIME};@@ -119,6 +119,7 @@ async fn setup_analytics_router_with_restriction(0.0_f32,26_214_400,983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None,256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytes@@ -546,6 +547,7 @@ async fn setup_analytics_router_with_redirect_to_topic(0.0_f32,26_214_400,983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None,256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytesdiff --git a/rust/capture/tests/integration_otel_endpoint.rs b/rust/capture/tests/integration_otel_endpoint.rsindex d221647cc673..e025ec8fdfd2 100644--- a/rust/capture/tests/integration_otel_endpoint.rs+++ b/rust/capture/tests/integration_otel_endpoint.rs@@ -14,7 +14,7 @@ use capture::outputs::{OutputRegistry, PublishEvents};use capture::quota_limiters::{is_llm_event, CaptureQuotaLimiter, EventInfo};use capture::router::router;use capture::time::TimeSource;-use capture::v0_request::{DataType, OverflowReason, ProcessedEvent};+use capture::v0_request::{AiLanePredicate, DataType, OverflowReason, ProcessedEvent};use chrono::{DateTime, Utc};use common_ingestion_warnings::test_support::CollectingEmitter;use common_ingestion_warnings::{WarningEmitter, WarningType, CAPTURE_AI_OTEL};@@ -188,6 +188,7 @@ fn make_test_client_with_options(sink: &CapturingSink, options: TestClientOption0.0_f32, // verbose_sample_percent26_214_400, // ai_max_sum_of_parts_bytesoptions.ai_max_event_bytes.unwrap_or(983_040), // ai_max_event_bytes+ AiLanePredicate::Allowlist, // ai_lane_predicateNone, // body_chunk_read_timeout_ms256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytesdiff --git a/rust/capture/tests/integration_person_processing_matrix.rs b/rust/capture/tests/integration_person_processing_matrix.rsindex 178161b72e75..6ebc1f664fbf 100644--- a/rust/capture/tests/integration_person_processing_matrix.rs+++ b/rust/capture/tests/integration_person_processing_matrix.rs@@ -48,6 +48,7 @@ use capture::sinks::kafka::KafkaSinkBase;use capture::sinks::producer::MockKafkaProducer;use capture::sinks::registry::TopicTable;use capture::time::TimeSource;+use capture::v0_request::AiLanePredicate;use capture::v1::router::{router as v1_router, RouterConfig as V1RouterConfig};use capture::v1::test_utils::TestStateBuilder;use chrono::{DateTime, Utc};@@ -255,6 +256,7 @@ async fn run_v0(inputs: Inputs, distinct_ids: &[&str]) -> Batch {0.0_f32,26_214_400,983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None,256,10 * 1024 * 1024,diff --git a/rust/capture/tests/integration_replay_restrictions.rs b/rust/capture/tests/integration_replay_restrictions.rsindex 1d4963416fe7..e1305440a482 100644--- a/rust/capture/tests/integration_replay_restrictions.rs+++ b/rust/capture/tests/integration_replay_restrictions.rs@@ -15,7 +15,7 @@ use capture::outputs::{OutputRegistry, PublishEvents};use capture::quota_limiters::CaptureQuotaLimiter;use capture::router::router;use capture::time::TimeSource;-use capture::v0_request::{DataType, ProcessedEvent};+use capture::v0_request::{AiLanePredicate, DataType, ProcessedEvent};use chrono::{DateTime, Utc};use common_redis::MockRedisClient;use integration_utils::{test_lifecycle_handlers, DEFAULT_CONFIG, DEFAULT_TEST_TIME};@@ -116,6 +116,7 @@ async fn setup_recordings_router_with_restriction(0.0_f32,26_214_400,983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None,256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytes@@ -489,6 +490,7 @@ async fn setup_recordings_router_with_redirect_to_topic(0.0_f32,26_214_400,983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None,256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytesdiff --git a/rust/capture/tests/integration_wire_body_limits.rs b/rust/capture/tests/integration_wire_body_limits.rsindex 7f934a76eec8..3655216f4f49 100644--- a/rust/capture/tests/integration_wire_body_limits.rs+++ b/rust/capture/tests/integration_wire_body_limits.rs@@ -10,6 +10,7 @@ use capture::outputs::{OutputRegistry, PublishEvents};use capture::quota_limiters::CaptureQuotaLimiter;use capture::router::{router, BATCH_BODY_SIZE};use capture::time::TimeSource;+use capture::v0_request::AiLanePredicate;use capture::v0_request::ProcessedEvent;use chrono::{DateTime, Utc};use common_redis::MockRedisClient;@@ -92,6 +93,7 @@ fn make_test_client(mode: CaptureMode) -> (TestClient, CapturingSink) {// Far above any body this file sends: the AI-lane event ceiling must not// be what produces a 413 here, or the wire cap would go untested.BATCH_BODY_SIZE as u64 * 5, // ai_max_event_bytes+ AiLanePredicate::Allowlist,None,256,10 * 1024 * 1024,diff --git a/rust/capture/tests/quota_limiters.rs b/rust/capture/tests/quota_limiters.rsindex 01e3dfd45936..20d1eca636e5 100644--- a/rust/capture/tests/quota_limiters.rs+++ b/rust/capture/tests/quota_limiters.rs@@ -22,6 +22,7 @@ use capture::quota_limiters::{};use capture::router::router;use capture::time::TimeSource;+use capture::v0_request::AiLanePredicate;use capture::v0_request::ProcessedEvent;use chrono::{DateTime, Utc};@@ -130,14 +131,15 @@ async fn setup_router_with_limits(None, // event_restriction_serviceNone, // recorder_handleCaptureMode::Events,- None, // concurrency_limit- 1024 * 1024, // event_payload_size_limit- false, // enable_historical_rerouting- 1, // historical_rerouting_threshold_days- false, // is_mirror_deploy- 0.0, // verbose_sample_percent- 26_214_400, // ai_max_sum_of_parts_bytes (25MB)- 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ None, // concurrency_limit+ 1024 * 1024, // event_payload_size_limit+ false, // enable_historical_rerouting+ 1, // historical_rerouting_threshold_days+ false, // is_mirror_deploy+ 0.0, // verbose_sample_percent+ 26_214_400, // ai_max_sum_of_parts_bytes (25MB)+ 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None, // body_chunk_read_timeout_ms256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytes@@ -1192,7 +1194,8 @@ async fn test_survey_quota_cross_batch_first_submission_allowed() {false,0.0,26_214_400,- 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None, // body_chunk_read_timeout_ms256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytes@@ -1285,7 +1288,8 @@ async fn test_survey_quota_cross_batch_duplicate_submission_dropped() {false,0.0,26_214_400,- 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None, // body_chunk_read_timeout_ms256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytes@@ -1382,7 +1386,8 @@ async fn test_survey_quota_cross_batch_redis_error_fail_open() {false,0.0,26_214_400,- 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None, // body_chunk_read_timeout_ms256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytes@@ -1816,7 +1821,8 @@ async fn test_ai_quota_cross_batch_redis_error_fail_open() {false,0.0,26_214_400,- 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ 983_040, // ai_max_event_bytes (960KB, the previous hardcoded limit)+ AiLanePredicate::Allowlist,None, // body_chunk_read_timeout_ms256, // body_read_chunk_size_kb10 * 1024 * 1024, // capture_v1_max_compressed_body_bytes