: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(error-tracking): start issue workflows from cymbal (#72874)
Hugues Pouillot752122d457c3
diff --git a/rust/Cargo.lock b/rust/Cargo.lockindex d7d3c2d78154..96e6c5097cc8 100644--- a/rust/Cargo.lock+++ b/rust/Cargo.lock@@ -31,7 +31,7 @@ checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"dependencies = ["cfg-if","cipher",- "cpufeatures",+ "cpufeatures 0.2.17",][[package]]@@ -1468,6 +1468,15 @@ dependencies = ["generic-array",]+[[package]]+name = "block-padding"+version = "0.3.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93"+dependencies = [+ "generic-array",+]+[[package]]name = "block2"version = "0.6.2"@@ -1529,7 +1538,7 @@ dependencies = ["tokio","tokio-stream","tokio-util",- "tonic 0.14.5",+ "tonic 0.14.6","tower-service","url","winapi",@@ -1543,7 +1552,7 @@ checksum = "85a885520bf6249ab931a764ffdb87b0ceef48e6e7d807cfdb21b751e086e1ad"dependencies = ["prost 0.14.3","prost-types 0.14.3",- "tonic 0.14.5",+ "tonic 0.14.6","tonic-prost","ureq",]@@ -1942,6 +1951,15 @@ version = "0.3.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"+[[package]]+name = "cbc"+version = "0.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"+dependencies = [+ "cipher",+]+[[package]]name = "cc"version = "1.2.56"@@ -1994,6 +2012,17 @@ version = "0.2.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"+[[package]]+name = "chacha20"+version = "0.10.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81"+dependencies = [+ "cfg-if",+ "cpufeatures 0.3.0",+ "rand_core 0.10.1",+]+[[package]]name = "choice"version = "0.0.2"@@ -2565,6 +2594,22 @@ dependencies = ["tokio",]+[[package]]+name = "common-temporal"+version = "0.1.0"+dependencies = [+ "base64 0.22.1",+ "fernet",+ "hex",+ "prost 0.14.3",+ "serde",+ "serde_json",+ "temporalio-client",+ "temporalio-common",+ "thiserror 2.0.18",+ "url",+]+[[package]]name = "common-types"version = "0.1.0"@@ -2636,6 +2681,15 @@ version = "0.3.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6"+[[package]]+name = "convert_case"+version = "0.10.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9"+dependencies = [+ "unicode-segmentation",+]+[[package]]name = "core-foundation"version = "0.9.4"@@ -2691,6 +2745,15 @@ dependencies = ["libc",]+[[package]]+name = "cpufeatures"+version = "0.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201"+dependencies = [+ "libc",+]+[[package]]name = "crc"version = "3.4.0"@@ -2947,6 +3010,7 @@ dependencies = ["common-metrics","common-posthog","common-redis",+ "common-temporal","common-types","cymbal-proto","envconfig",@@ -3242,6 +3306,29 @@ dependencies = ["syn 2.0.117",]+[[package]]+name = "derive_more"+version = "2.1.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134"+dependencies = [+ "derive_more-impl",+]++[[package]]+name = "derive_more-impl"+version = "2.1.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb"+dependencies = [+ "convert_case",+ "proc-macro2",+ "quote",+ "rustc_version",+ "syn 2.0.117",+ "unicode-xid",+]+[[package]]name = "determinator"version = "0.12.0"@@ -3572,6 +3659,17 @@ version = "1.0.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"+[[package]]+name = "erased-serde"+version = "0.4.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d2add8a07dd6a8d93ff627029c51de145e12686fbc36ecb298ac22e74cf02dec"+dependencies = [+ "serde",+ "serde_core",+ "typeid",+]+[[package]]name = "errno"version = "0.3.14"@@ -3592,8 +3690,8 @@ dependencies = ["prost 0.14.3","tokio","tokio-stream",- "tonic 0.14.5",- "tonic-build 0.14.5",+ "tonic 0.14.6",+ "tonic-build 0.14.6","tonic-prost","tonic-prost-build","tower 0.5.3",@@ -3805,10 +3903,15 @@ version = "0.2.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "c66b725fe9483b9ee72ccaec072b15eb8ad95a3ae63a8c798d5748883b72fd33"dependencies = [+ "aes","base64 0.22.1","byteorder",+ "cbc","getrandom 0.2.17",+ "hmac","openssl",+ "sha2",+ "subtle","zeroize",]@@ -4217,6 +4320,17 @@ dependencies = ["syn 2.0.117",]+[[package]]+name = "futures-retry"+version = "0.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fde5a672a61f96552aa5ed9fd9c81c3fbdae4be9b1e205d6eaf17c83705adc0f"+dependencies = [+ "futures",+ "pin-project-lite",+ "tokio",+]+[[package]]name = "futures-sink"version = "0.3.32"@@ -4298,6 +4412,7 @@ dependencies = ["cfg-if","libc","r-efi",+ "rand_core 0.10.1","wasip2","wasip3",]@@ -5365,6 +5480,7 @@ version = "0.1.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"dependencies = [+ "block-padding","generic-array",]@@ -5401,6 +5517,15 @@ dependencies = ["cfg-if",]+[[package]]+name = "inventory"+version = "0.3.24"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a4f0c30c76f2f4ccee3fe55a2435f691ca00c0e4bd87abe4f4a851b1d4dac39b"+dependencies = [+ "rustversion",+]+[[package]]name = "io-uring"version = "0.7.11"@@ -7440,6 +7565,28 @@ dependencies = ["camino",]+[[package]]+name = "pbjson"+version = "0.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e8edd1efdd8ab23ba9cb9ace3d9987a72663d5d7c9f74fa00b51d6213645cf6c"+dependencies = [+ "base64 0.22.1",+ "serde",+]++[[package]]+name = "pbjson-build"+version = "0.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2ed4d5c6ae95e08ac768883c8401cf0e8deb4e6e1d6a4e1fd3d2ec4f0ec63200"+dependencies = [+ "heck",+ "itertools 0.14.0",+ "prost 0.14.3",+ "prost-types 0.14.3",+]+[[package]]name = "pbkdf2"version = "0.12.2"@@ -8464,6 +8611,52 @@ dependencies = ["prost 0.14.3",]+[[package]]+name = "prost-wkt"+version = "0.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cd3de5e9c9e84fcb5efa204b8e283d23e615a8bc8c777bf1d6622bb01dc61445"+dependencies = [+ "chrono",+ "inventory",+ "prost 0.14.3",+ "serde",+ "serde_derive",+ "serde_json",+ "typetag",+]++[[package]]+name = "prost-wkt-build"+version = "0.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fe500dc80e757a75e1e8fb7290e448d62dfba3105ece1d058579cb00b58151cd"+dependencies = [+ "heck",+ "prost 0.14.3",+ "prost-build 0.14.3",+ "prost-types 0.14.3",+ "quote",+]++[[package]]+name = "prost-wkt-types"+version = "0.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "13807eaa7e15833d06e899008371926201cdcd11d74b6d490f49130cdb3f415e"+dependencies = [+ "chrono",+ "prost 0.14.3",+ "prost-build 0.14.3",+ "prost-types 0.14.3",+ "prost-wkt",+ "prost-wkt-build",+ "regex",+ "serde",+ "serde_derive",+ "serde_json",+]+[[package]]name = "protobuf"version = "3.7.2"@@ -8857,6 +9050,17 @@ dependencies = ["rand_core 0.9.5",]+[[package]]+name = "rand"+version = "0.10.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80"+dependencies = [+ "chacha20",+ "getrandom 0.4.1",+ "rand_core 0.10.1",+]+[[package]]name = "rand_chacha"version = "0.3.1"@@ -8895,6 +9099,12 @@ dependencies = ["getrandom 0.3.4",]+[[package]]+name = "rand_core"+version = "0.10.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"+[[package]]name = "rand_xorshift"version = "0.4.0"@@ -10052,7 +10262,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"dependencies = ["cfg-if",- "cpufeatures",+ "cpufeatures 0.2.17","digest",]@@ -10069,7 +10279,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"dependencies = ["cfg-if",- "cpufeatures",+ "cpufeatures 0.2.17","digest",]@@ -10958,6 +11168,17 @@ dependencies = ["unicode-ident",]+[[package]]+name = "syn"+version = "3.0.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3"+dependencies = [+ "proc-macro2",+ "quote",+ "unicode-ident",+]+[[package]]name = "sync_wrapper"version = "0.1.2"@@ -11075,6 +11296,116 @@ dependencies = ["windows-sys 0.61.2",]+[[package]]+name = "temporalio-client"+version = "0.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "257e69cdc823bfd0707d4daac7470451d59d31aefe519c4eb60d4ceeb77c443e"+dependencies = [+ "anyhow",+ "async-trait",+ "backoff",+ "base64 0.22.1",+ "bon",+ "bytes",+ "derive_more",+ "dyn-clone",+ "futures-retry",+ "futures-util",+ "http 1.4.0",+ "http-body-util",+ "hyper 1.9.0",+ "hyper-util",+ "parking_lot",+ "rand 0.10.2",+ "temporalio-common",+ "thiserror 2.0.18",+ "tokio",+ "tokio-rustls 0.26.4",+ "tonic 0.14.6",+ "tower 0.5.3",+ "tracing",+ "url",+ "uuid",+]++[[package]]+name = "temporalio-common"+version = "0.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6988555678e6177c08553aece24312643b714d35983ad9bf383c9f9eb77ea6ec"+dependencies = [+ "anyhow",+ "async-trait",+ "bon",+ "crc32fast",+ "derive_more",+ "erased-serde",+ "futures",+ "parking_lot",+ "prost 0.14.3",+ "prost-types 0.14.3",+ "serde",+ "serde_json",+ "temporalio-common-wasm",+ "temporalio-protos",+ "thiserror 2.0.18",+ "tonic 0.14.6",+ "tracing",+ "tracing-core",+ "tracing-subscriber",+ "url",+ "uuid",+]++[[package]]+name = "temporalio-common-wasm"+version = "0.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5d5dba313ccb58da518e23f85557e7cb9d5a1298fd7d8935328521ca641a4b11"+dependencies = [+ "anyhow",+ "async-trait",+ "bon",+ "crc32fast",+ "derive_more",+ "erased-serde",+ "futures",+ "parking_lot",+ "prost 0.14.3",+ "serde",+ "serde_json",+ "temporalio-protos",+ "thiserror 2.0.18",+ "tracing",+ "tracing-core",+ "tracing-subscriber",+ "url",+]++[[package]]+name = "temporalio-protos"+version = "0.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bce29ee903d46edec16df756e78e5ab125e4d342957174d4ac8ee30290ef249a"+dependencies = [+ "anyhow",+ "base64 0.22.1",+ "derive_more",+ "http 1.4.0",+ "pbjson",+ "pbjson-build",+ "prost 0.14.3",+ "prost-types 0.14.3",+ "prost-wkt-types",+ "serde",+ "serde_json",+ "thiserror 2.0.18",+ "tonic 0.14.6",+ "tonic-prost",+ "tonic-prost-build",+]+[[package]]name = "term"version = "0.7.0"@@ -11563,14 +11894,15 @@ dependencies = [[[package]]name = "tonic"-version = "0.14.5"+version = "0.14.6"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "fec7c61a0695dc1887c1b53952990f3ad2e3a31453e1f49f10e75424943a93ec"+checksum = "ac2a5518c70fa84342385732db33fb3f44bc4cc748936eb5833d2df34d6445ef"dependencies = ["async-trait","axum 0.8.8","base64 0.22.1","bytes",+ "flate2","h2 0.4.13","http 1.4.0","http-body 1.0.1",@@ -11580,9 +11912,11 @@ dependencies = ["hyper-util","percent-encoding","pin-project",+ "rustls-native-certs 0.8.3","socket2 0.6.3","sync_wrapper 1.0.2","tokio",+ "tokio-rustls 0.26.4","tokio-stream","tower 0.5.3","tower-layer",@@ -11606,9 +11940,9 @@ dependencies = [[[package]]name = "tonic-build"-version = "0.14.5"+version = "0.14.6"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "1882ac3bf5ef12877d7ed57aad87e75154c11931c2ba7e6cde5e22d63522c734"+checksum = "c68f61875ac5293cf72e6c8cf0158086428c82c37229e98c840878f1706b0322"dependencies = ["prettyplease","proc-macro2",@@ -11618,20 +11952,20 @@ dependencies = [[[package]]name = "tonic-prost"-version = "0.14.5"+version = "0.14.6"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "a55376a0bbaa4975a3f10d009ad763d8f4108f067c7c2e74f3001fb49778d309"+checksum = "50849f68853be452acf590cde0b146665b8d507b3b8af17261df47e02c209ea0"dependencies = ["bytes","prost 0.14.3",- "tonic 0.14.5",+ "tonic 0.14.6",][[package]]name = "tonic-prost-build"-version = "0.14.5"+version = "0.14.6"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "f3144df636917574672e93d0f56d7edec49f90305749c668df5101751bb8f95a"+checksum = "654e5643eff75d7f8c99197ce1440ed19a3474eada74c12bbac488b2cafdae27"dependencies = ["prettyplease","proc-macro2",@@ -11640,7 +11974,7 @@ dependencies = ["quote","syn 2.0.117","tempfile",- "tonic-build 0.14.5",+ "tonic-build 0.14.6",][[package]]@@ -11836,6 +12170,7 @@ dependencies = ["matchers","nu-ansi-term","once_cell",+ "parking_lot","regex-automata","serde","serde_json",@@ -11879,12 +12214,42 @@ version = "0.12.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "8e28f89b80c87b8fb0cf04ab448d5dd0dd0ade2f8891bae878de66a75a28600e"+[[package]]+name = "typeid"+version = "1.0.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c"+[[package]]name = "typenum"version = "1.19.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb"+[[package]]+name = "typetag"+version = "0.2.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c90e86058a30d42a1a928dfb4b49bb33c98c3a2b4909492e6b0881cd94798ec2"+dependencies = [+ "erased-serde",+ "inventory",+ "once_cell",+ "serde",+ "typetag-impl",+]++[[package]]+name = "typetag-impl"+version = "0.2.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f153acc4e99a5f2a5aefa09fb078be54e26271b2813f6041200b224c098d8328"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.3",+]+[[package]]name = "ucd-trie"version = "0.1.7"@@ -11936,6 +12301,12 @@ version = "0.1.4"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d"+[[package]]+name = "unicode-segmentation"+version = "1.13.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"+[[package]]name = "unicode-width"version = "0.2.2"diff --git a/rust/Cargo.toml b/rust/Cargo.tomlindex fa0dc9d26568..1cc5b1f47105 100644--- a/rust/Cargo.toml+++ b/rust/Cargo.toml@@ -31,6 +31,7 @@ members = ["common/s3","common/serve_metrics","common/symbol_data",+ "common/temporal","common/types","common/compression","common/hypercache",diff --git a/rust/common/temporal/Cargo.toml b/rust/common/temporal/Cargo.tomlnew file mode 100644index 000000000000..5db4be012781--- /dev/null+++ b/rust/common/temporal/Cargo.toml@@ -0,0 +1,19 @@+[package]+name = "common-temporal"+version = "0.1.0"+edition = "2021"++[lints]+workspace = true++[dependencies]+base64 = { workspace = true }+fernet = { version = "0.2.2", default-features = false, features = ["rustcrypto"] }+hex = "0.4"+prost14 = { package = "prost", version = "0.14" }+serde = { workspace = true }+serde_json = { workspace = true }+temporalio-client = { version = "=0.5.0", default-features = false, features = ["tls-ring"] }+temporalio-common = { version = "=0.5.0", default-features = false }+thiserror = { workspace = true }+url = { workspace = true }diff --git a/rust/common/temporal/src/lib.rs b/rust/common/temporal/src/lib.rsnew file mode 100644index 000000000000..7ef1787cb5ef--- /dev/null+++ b/rust/common/temporal/src/lib.rs@@ -0,0 +1,389 @@+//! Shared client for starting PostHog Python workflows from Rust services.+//!+//! Temporal payload encryption is application-defined rather than provided by+//! the SDK. This crate emits the same Fernet-wrapped `binary/encrypted` payloads+//! as `posthog.temporal.common.codec.EncryptionCodec`.++use std::collections::HashMap;+use std::time::Duration;++use base64::{engine::general_purpose, Engine};+use fernet::Fernet;+use prost14::Message;+use serde::Serialize;+use temporalio_client::grpc::WorkflowService;+use temporalio_client::tonic::{Code, IntoRequest};+use temporalio_client::{+ Client, ClientOptions, ClientTlsOptions, Connection, ConnectionOptions, TlsOptions,+};+use temporalio_common::protos::temporal::api::common::v1::{Payload, Payloads, WorkflowType};+use temporalio_common::protos::temporal::api::enums::v1::TaskQueueKind;+pub use temporalio_common::protos::temporal::api::enums::v1::{+ WorkflowIdConflictPolicy, WorkflowIdReusePolicy,+};+use temporalio_common::protos::temporal::api::taskqueue::v1::TaskQueue;+use temporalio_common::protos::temporal::api::workflowservice::v1::StartWorkflowExecutionRequest;+use thiserror::Error;++/// Connection and encryption settings for a PostHog Temporal namespace.+#[derive(Clone, Debug)]+pub struct TemporalClientConfig {+ pub host: String,+ pub port: u16,+ pub namespace: String,+ pub client_cert: String,+ pub client_key: String,+ pub server_root_ca_cert: Option<String>,+ pub payload_encryption_key: String,+ pub identity: String,+}++/// Options that identify and route one workflow execution.+#[derive(Clone, Debug)]+pub struct StartWorkflowOptions {+ pub workflow_name: String,+ pub task_queue: String,+ pub workflow_id: String,+ pub request_id: String,+ pub id_reuse_policy: WorkflowIdReusePolicy,+ pub id_conflict_policy: WorkflowIdConflictPolicy,+ pub execution_timeout: Option<Duration>,+ pub run_timeout: Option<Duration>,+ pub task_timeout: Option<Duration>,+}++impl StartWorkflowOptions {+ /// Build options for an idempotent start. Active executions are reused and+ /// only failed closed executions may reuse the workflow ID.+ pub fn idempotent(+ workflow_name: impl Into<String>,+ task_queue: impl Into<String>,+ workflow_id: impl Into<String>,+ request_id: impl Into<String>,+ ) -> Self {+ Self {+ workflow_name: workflow_name.into(),+ task_queue: task_queue.into(),+ workflow_id: workflow_id.into(),+ request_id: request_id.into(),+ id_reuse_policy: WorkflowIdReusePolicy::AllowDuplicateFailedOnly,+ id_conflict_policy: WorkflowIdConflictPolicy::UseExisting,+ execution_timeout: None,+ run_timeout: None,+ task_timeout: None,+ }+ }+}++#[derive(Clone, Debug, PartialEq, Eq)]+pub enum StartWorkflowOutcome {+ Started { run_id: String },+ Existing { run_id: Option<String> },+}++#[derive(Debug, Error)]+pub enum TemporalClientError {+ #[error("missing Temporal client configuration: {0}")]+ MissingConfig(&'static str),+ #[error("invalid Temporal target: {0}")]+ InvalidTarget(#[from] url::ParseError),+ #[error("invalid Temporal payload encryption key: {0}")]+ InvalidEncryptionKey(String),+ #[error("failed to connect to Temporal: {0}")]+ Connect(#[from] temporalio_client::errors::ClientConnectError),+ #[error("failed to create Temporal client: {0}")]+ CreateClient(#[from] temporalio_client::errors::ClientNewError),+ #[error("failed to serialize workflow input: {0}")]+ Serialize(#[from] serde_json::Error),+ #[error("invalid workflow start options: {0}")]+ InvalidStartOptions(&'static str),+ #[error("failed to start workflow: {0}")]+ Start(temporalio_client::tonic::Status),+}++/// A cheap-to-clone, namespace-bound Temporal client that serializes Rust+/// inputs for Python workflows and encrypts them with PostHog's payload codec.+#[derive(Clone)]+pub struct TemporalWorkflowClient {+ client: Client,+ identity: String,+ encryption_key: Fernet,+}++impl TemporalWorkflowClient {+ pub async fn connect(config: TemporalClientConfig) -> Result<Self, TemporalClientError> {+ require_config("TEMPORAL_HOST", &config.host)?;+ require_config("TEMPORAL_NAMESPACE", &config.namespace)?;+ require_config("TEMPORAL_CLIENT_CERT", &config.client_cert)?;+ require_config("TEMPORAL_CLIENT_KEY", &config.client_key)?;+ require_config("TEMPORAL_SECRET_KEY", &config.payload_encryption_key)?;+ require_config("identity", &config.identity)?;++ let target = url::Url::parse(&format!("https://{}:{}", config.host, config.port))?;+ let tls_options = TlsOptions {+ server_root_ca_cert: config+ .server_root_ca_cert+ .as_ref()+ .filter(|value| !value.is_empty())+ .map(|value| value.as_bytes().to_vec()),+ domain: Some(config.host.clone()),+ client_tls_options: Some(ClientTlsOptions {+ client_cert: config.client_cert.as_bytes().to_vec(),+ client_private_key: config.client_key.as_bytes().to_vec(),+ }),+ server_cert_verifier: None,+ };+ let connection_options = ConnectionOptions::new(target)+ .identity(config.identity.clone())+ .tls_options(tls_options)+ .build();+ let connection = Connection::connect(connection_options).await?;+ let client = Client::new(connection, ClientOptions::new(config.namespace).build())?;++ Ok(Self {+ client,+ identity: config.identity,+ encryption_key: temporal_encryption_key(&config.payload_encryption_key)?,+ })+ }++ /// Start a workflow using Temporal's stable request and workflow ID+ /// deduplication. `AlreadyExists` is returned as a successful outcome.+ pub async fn start_workflow<T: Serialize>(+ &self,+ input: &T,+ options: &StartWorkflowOptions,+ ) -> Result<StartWorkflowOutcome, TemporalClientError> {+ validate_start_options(options)?;+ let request = build_start_request(+ input,+ &self.client.options().namespace,+ &self.identity,+ options,+ &self.encryption_key,+ )?;++ match self+ .client+ .clone()+ .start_workflow_execution(request.into_request())+ .await+ {+ Ok(response) => {+ let response = response.into_inner();+ if response.started {+ Ok(StartWorkflowOutcome::Started {+ run_id: response.run_id,+ })+ } else {+ Ok(StartWorkflowOutcome::Existing {+ run_id: Some(response.run_id),+ })+ }+ }+ Err(status) if status.code() == Code::AlreadyExists => {+ Ok(StartWorkflowOutcome::Existing { run_id: None })+ }+ Err(status) => Err(TemporalClientError::Start(status)),+ }+ }+}++fn build_start_request<T: Serialize>(+ input: &T,+ namespace: &str,+ identity: &str,+ options: &StartWorkflowOptions,+ encryption_key: &Fernet,+) -> Result<StartWorkflowExecutionRequest, TemporalClientError> {+ let payload = encrypted_json_payload(input, encryption_key)?;+ Ok(StartWorkflowExecutionRequest {+ namespace: namespace.to_string(),+ workflow_id: options.workflow_id.clone(),+ workflow_type: Some(WorkflowType {+ name: options.workflow_name.clone(),+ }),+ task_queue: Some(TaskQueue {+ name: options.task_queue.clone(),+ kind: TaskQueueKind::Unspecified as i32,+ normal_name: String::new(),+ }),+ input: Some(Payloads {+ payloads: vec![payload],+ }),+ request_id: options.request_id.clone(),+ workflow_id_reuse_policy: options.id_reuse_policy as i32,+ workflow_id_conflict_policy: options.id_conflict_policy as i32,+ workflow_execution_timeout: options+ .execution_timeout+ .and_then(|value| value.try_into().ok()),+ workflow_run_timeout: options.run_timeout.and_then(|value| value.try_into().ok()),+ workflow_task_timeout: options.task_timeout.and_then(|value| value.try_into().ok()),+ identity: identity.to_string(),+ ..Default::default()+ })+}++fn encrypted_json_payload<T: Serialize>(+ value: &T,+ key: &Fernet,+) -> Result<Payload, TemporalClientError> {+ let plain_payload = Payload {+ metadata: HashMap::from([("encoding".to_string(), b"json/plain".to_vec())]),+ data: serde_json::to_vec(value)?,+ ..Default::default()+ };+ let token = key.encrypt(&plain_payload.encode_to_vec());+ Ok(Payload {+ metadata: HashMap::from([("encoding".to_string(), b"binary/encrypted".to_vec())]),+ data: token.into_bytes(),+ ..Default::default()+ })+}++/// Mirrors `posthog.temporal.common.codec._load_as_bytes` and `_prepare_key`.+/// Legacy raw keys and truncation to 32 bytes are intentional compatibility+/// behavior: deriving a stricter key here would make Python workers unable to+/// decrypt Rust-produced payloads.+fn temporal_encryption_key(raw: &str) -> Result<Fernet, TemporalClientError> {+ let loaded = if let Some(value) = raw.strip_prefix("hex:") {+ hex::decode(value)+ .map_err(|error| TemporalClientError::InvalidEncryptionKey(error.to_string()))?+ } else if let Some(value) = raw.strip_prefix("base64-urlsafe:") {+ general_purpose::URL_SAFE+ .decode(value)+ .map_err(|error| TemporalClientError::InvalidEncryptionKey(error.to_string()))?+ } else if let Some(value) = raw.strip_prefix("base64:") {+ general_purpose::STANDARD+ .decode(value)+ .map_err(|error| TemporalClientError::InvalidEncryptionKey(error.to_string()))?+ } else {+ raw.as_bytes().to_vec()+ };+ if loaded.len() < 32 {+ return Err(TemporalClientError::InvalidEncryptionKey(format!(+ "expected at least 32 bytes, got {}",+ loaded.len()+ )));+ }++ let prepared = general_purpose::URL_SAFE.encode(&loaded[..32]);+ Fernet::new(&prepared).ok_or_else(|| {+ TemporalClientError::InvalidEncryptionKey("failed to prepare Fernet key".to_string())+ })+}++fn validate_start_options(options: &StartWorkflowOptions) -> Result<(), TemporalClientError> {+ if options.workflow_name.is_empty() {+ return Err(TemporalClientError::InvalidStartOptions(+ "workflow_name is empty",+ ));+ }+ if options.task_queue.is_empty() {+ return Err(TemporalClientError::InvalidStartOptions(+ "task_queue is empty",+ ));+ }+ if options.workflow_id.is_empty() {+ return Err(TemporalClientError::InvalidStartOptions(+ "workflow_id is empty",+ ));+ }+ if options.request_id.is_empty() {+ return Err(TemporalClientError::InvalidStartOptions(+ "request_id is empty",+ ));+ }+ Ok(())+}++fn require_config(name: &'static str, value: &str) -> Result<(), TemporalClientError> {+ if value.is_empty() {+ return Err(TemporalClientError::MissingConfig(name));+ }+ Ok(())+}++#[cfg(test)]+mod tests {+ use prost14::Message;+ use serde::Serialize;++ use super::*;++ #[derive(Serialize)]+ struct TestInput<'a> {+ team_id: i32,+ name: &'a str,+ }++ fn options() -> StartWorkflowOptions {+ StartWorkflowOptions::idempotent(+ "python-workflow",+ "python-task-queue",+ "workflow-id",+ "request-id",+ )+ }++ #[test]+ fn builds_encrypted_python_workflow_request() {+ let key = temporal_encryption_key(&"a".repeat(32)).unwrap();+ let request = build_start_request(+ &TestInput {+ team_id: 42,+ name: "test",+ },+ "posthog.prod",+ "rust-service",+ &options(),+ &key,+ )+ .unwrap();++ assert_eq!(request.namespace, "posthog.prod");+ assert_eq!(request.workflow_id, "workflow-id");+ assert_eq!(request.request_id, "request-id");+ assert_eq!(request.workflow_type.unwrap().name, "python-workflow");+ assert_eq!(request.task_queue.unwrap().name, "python-task-queue");+ assert_eq!(+ request.workflow_id_reuse_policy,+ WorkflowIdReusePolicy::AllowDuplicateFailedOnly as i32+ );+ assert_eq!(+ request.workflow_id_conflict_policy,+ WorkflowIdConflictPolicy::UseExisting as i32+ );++ let payload = &request.input.unwrap().payloads[0];+ let token = std::str::from_utf8(&payload.data).unwrap();+ let inner = Payload::decode(key.decrypt(token).unwrap().as_slice()).unwrap();+ let value: serde_json::Value = serde_json::from_slice(&inner.data).unwrap();+ assert_eq!(payload.metadata["encoding"], b"binary/encrypted");+ assert_eq!(inner.metadata["encoding"], b"json/plain");+ assert_eq!(value["team_id"], 42);+ assert_eq!(value["name"], "test");+ }++ #[test]+ fn legacy_long_keys_match_python_truncation() {+ let long_key = temporal_encryption_key(&"a".repeat(40)).unwrap();+ let truncated_key = temporal_encryption_key(&"a".repeat(32)).unwrap();+ let token = long_key.encrypt(b"payload");++ assert_eq!(truncated_key.decrypt(&token).unwrap(), b"payload");+ }++ #[test]+ fn rejects_empty_idempotency_fields() {+ let mut options = options();+ options.request_id.clear();++ assert!(matches!(+ validate_start_options(&options),+ Err(TemporalClientError::InvalidStartOptions(+ "request_id is empty"+ ))+ ));+ }+}diff --git a/rust/cymbal/Cargo.toml b/rust/cymbal/Cargo.tomlindex b90c8c317da7..01e9f8e47093 100644--- a/rust/cymbal/Cargo.toml+++ b/rust/cymbal/Cargo.toml@@ -55,6 +55,7 @@ tokio-stream = "0.1"personhog-common = { path = "../personhog-common" }async-stream = { workspace = true }subtle = "2.6"+common-temporal = { path = "../common/temporal" }[dev-dependencies]diff --git a/rust/cymbal/src/core/types/notification.rs b/rust/cymbal/src/core/types/notification.rsindex 1a0b9bb82133..5a9afff1b616 100644--- a/rust/cymbal/src/core/types/notification.rs+++ b/rust/cymbal/src/core/types/notification.rs@@ -3,7 +3,7 @@//! them.use chrono::{DateTime, Utc};-use serde::{Deserialize, Serialize};+use serde::{Deserialize, Deserializer, Serialize};use uuid::Uuid;use crate::types::ProcessedExceptionProperties;@@ -30,7 +30,7 @@ pub enum NotificationValidationError {/// internally-tagged JSON (`{"type": "issue_created", ...}`) so new variants can/// be added without breaking existing consumers — an unknown `type` simply fails/// to deserialize and is skipped as a poison pill.-#[derive(Debug, Clone, Serialize, Deserialize)]+#[derive(Debug, Clone, Serialize)]#[serde(tag = "type", rename_all = "snake_case")]pub enum IngestionNotification {/// A new issue was created during ingestion.@@ -41,6 +41,59 @@ pub enum IngestionNotification {IssueSpiking(IssueSpiking),}+#[derive(Deserialize)]+#[serde(tag = "type")]+enum IngestionNotificationWire {+ #[serde(rename = "issue_created")]+ Created(IssueCreated),+ #[serde(rename = "issue_reopened")]+ Reopened(IssueReopened),+ #[serde(rename = "issue_spiking")]+ Spiking(IssueSpiking),+}++impl<'de> Deserialize<'de> for IngestionNotification {+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>+ where+ D: Deserializer<'de>,+ {+ let wire = IngestionNotificationWire::deserialize(deserializer)?;+ let mut notification = match wire {+ IngestionNotificationWire::Created(value) => Self::IssueCreated(value),+ IngestionNotificationWire::Reopened(value) => Self::IssueReopened(value),+ IngestionNotificationWire::Spiking(value) => Self::IssueSpiking(value),+ };++ if notification.notification_id().is_nil() {+ let fallback_key = match ¬ification {+ Self::IssueCreated(value) => format!(+ "issue_created:{}:{}:{}",+ value.meta.team_id, value.issue.issue_id, value.event_uuid+ ),+ Self::IssueReopened(value) => format!(+ "issue_reopened:{}:{}:{}",+ value.meta.team_id, value.issue.issue_id, value.event_timestamp+ ),+ Self::IssueSpiking(value) => format!(+ "issue_spiking:{}:{}:{}:{}",+ value.meta.team_id,+ value.issue.issue_id,+ value.computed_baseline.to_bits(),+ value.current_bucket_value.to_bits()+ ),+ };+ let notification_id = Uuid::new_v5(&Uuid::NAMESPACE_OID, fallback_key.as_bytes());+ match &mut notification {+ Self::IssueCreated(value) => value.meta.notification_id = notification_id,+ Self::IssueReopened(value) => value.meta.notification_id = notification_id,+ Self::IssueSpiking(value) => value.meta.notification_id = notification_id,+ }+ }++ Ok(notification)+ }+}+impl IngestionNotification {pub fn notification_id(&self) -> Uuid {match self {@@ -110,7 +163,9 @@ impl IngestionNotification {#[derive(Debug, Clone, Serialize, Deserialize)]pub struct NotificationMeta {/// Stable id for retryable side effects produced from this notification.- #[serde(default = "Uuid::now_v7")]+ /// Missing IDs on notifications produced before this field was introduced are+ /// deterministically derived by [`IngestionNotification::deserialize`].+ #[serde(default)]pub notification_id: Uuid,pub team_id: i32,}@@ -182,9 +237,10 @@ mod tests {#[test]fn issue_created_round_trips_with_type_tag() {+ let notification_id = Uuid::now_v7();let notification = IngestionNotification::IssueCreated(IssueCreated {meta: NotificationMeta {- notification_id: Uuid::nil(),+ notification_id,team_id: 42,},issue: IssueNotificationContext {@@ -226,6 +282,18 @@ mod tests {let decoded: IngestionNotification = serde_json::from_value(json.clone()).unwrap();assert_eq!(serde_json::to_value(&decoded).unwrap(), json);+ let mut missing_notification_id = json.clone();+ missing_notification_id+ .as_object_mut()+ .unwrap()+ .remove("notification_id");+ let first: IngestionNotification =+ serde_json::from_value(missing_notification_id.clone()).unwrap();+ let second: IngestionNotification =+ serde_json::from_value(missing_notification_id).unwrap();+ assert!(!first.notification_id().is_nil());+ assert_eq!(first.notification_id(), second.notification_id());+let mut issue_mismatch = json.clone();issue_mismatch["issue_id"] = serde_json::json!(Uuid::now_v7());let decoded: IngestionNotification = serde_json::from_value(issue_mismatch).unwrap();diff --git a/rust/cymbal/src/modes/notifications/config.rs b/rust/cymbal/src/modes/notifications/config.rsindex 6d1e317c9473..717e03f545bb 100644--- a/rust/cymbal/src/modes/notifications/config.rs+++ b/rust/cymbal/src/modes/notifications/config.rs@@ -10,8 +10,8 @@ pub const DEFAULT_CONSUMER_TOPIC: &str = "error_tracking_ingestion_notifications/// `KAFKA_CONSUMER_GROUP`.pub const DEFAULT_CONSUMER_GROUP: &str = "error_tracking_ingestion_notifications";-/// Top-level config for notifications mode. Keep this narrow: only Kafka,-/// Postgres, signal emission, and the metrics server.+/// Top-level config for notifications mode. Includes the downstream clients+/// needed for legacy side effects and opt-in Temporal workflow starts.#[derive(Envconfig, Clone)]pub struct NotificationsConfig {#[envconfig(nested = true)]@@ -59,6 +59,46 @@ pub struct NotificationsConfig {#[envconfig(default = "https://us.i.posthog.com/capture")]pub posthog_endpoint: String,++ /// Direct Temporal starts are disabled by default. When enabled with an empty+ /// allowlist, every team is routed to the issue-created workflow.+ #[envconfig(+ from = "ERROR_TRACKING_ISSUE_CREATED_WORKFLOW_ENABLED",+ default = "false"+ )]+ pub issue_created_workflow_enabled: bool,++ /// Comma-separated rollout allowlist. An empty value means all teams when+ /// `ERROR_TRACKING_ISSUE_CREATED_WORKFLOW_ENABLED` is true.+ #[envconfig(from = "ERROR_TRACKING_ISSUE_CREATED_WORKFLOW_TEAM_IDS", default = "")]+ pub issue_created_workflow_team_ids: String,++ #[envconfig(from = "TEMPORAL_HOST", default = "")]+ pub temporal_host: String,++ #[envconfig(from = "TEMPORAL_PORT", default = "7233")]+ pub temporal_port: u16,++ #[envconfig(from = "TEMPORAL_NAMESPACE", default = "")]+ pub temporal_namespace: String,++ #[envconfig(from = "TEMPORAL_CLIENT_CERT", default = "")]+ pub temporal_client_cert: String,++ #[envconfig(from = "TEMPORAL_CLIENT_KEY", default = "")]+ pub temporal_client_key: String,++ #[envconfig(from = "TEMPORAL_CLIENT_ROOT_CA")]+ pub temporal_client_root_ca: Option<String>,++ #[envconfig(from = "TEMPORAL_SECRET_KEY", default = "")]+ pub temporal_secret_key: String,++ #[envconfig(+ from = "ERROR_TRACKING_LIFECYCLE_TASK_QUEUE",+ default = "error-tracking-lifecycle-task-queue"+ )]+ pub error_tracking_lifecycle_task_queue: String,}impl NotificationsConfig {diff --git a/rust/cymbal/src/modes/notifications/context.rs b/rust/cymbal/src/modes/notifications/context.rsindex e77f551d08be..6967e58c5678 100644--- a/rust/cymbal/src/modes/notifications/context.rs+++ b/rust/cymbal/src/modes/notifications/context.rs@@ -9,6 +9,7 @@ use crate::core::config::build_pg_pool;use crate::core::error::UnhandledError;use crate::modes::notifications::config::NotificationsConfig;use crate::modes::notifications::signals::{MaybeSignalClient, SignalClient};+use crate::modes::notifications::temporal::MaybeIssueCreatedWorkflowStarter;#[derive(Clone)]pub struct NotificationsContext {@@ -18,6 +19,7 @@ pub struct NotificationsContext {pub signal_client: MaybeSignalClient,pub embedding_worker_topic: String,pub internal_events_topic: String,+ pub issue_created_workflow_starter: MaybeIssueCreatedWorkflowStarter,}impl NotificationsContext {@@ -36,6 +38,8 @@ impl NotificationsContext {signal_client: build_signal_client(config),embedding_worker_topic: config.embedding_worker_topic.clone(),internal_events_topic: config.internal_events_topic.clone(),+ issue_created_workflow_starter: MaybeIssueCreatedWorkflowStarter::from_config(config)+ .await?,})}}diff --git a/rust/cymbal/src/modes/notifications/issue_handler.rs b/rust/cymbal/src/modes/notifications/issue_handler.rsindex 78203d71f422..ab80c55ea451 100644--- a/rust/cymbal/src/modes/notifications/issue_handler.rs+++ b/rust/cymbal/src/modes/notifications/issue_handler.rs@@ -20,6 +20,24 @@ pub async fn handle_issue_created(context: &NotificationsContext,notification: IssueCreated,) -> Result<(), UnhandledError> {+ if context+ .issue_created_workflow_starter+ .start_if_enabled(¬ification)+ .await?+ {+ let sentry_integration = notification+ .issue+ .event_properties+ .properties()+ .contains_key("$sentry_event_id");+ capture_issue_created(+ notification.meta.team_id,+ notification.issue.issue_id,+ sentry_integration,+ );+ return Ok(());+ }+let IssueCreated {meta,issue,diff --git a/rust/cymbal/src/modes/notifications/mod.rs b/rust/cymbal/src/modes/notifications/mod.rsindex 03390b607ae3..e2de9ad1c112 100644--- a/rust/cymbal/src/modes/notifications/mod.rs+++ b/rust/cymbal/src/modes/notifications/mod.rs@@ -25,6 +25,7 @@ mod issue_handler;pub mod side_effects;pub mod signals;pub mod stacktrace;+pub mod temporal;pub mod types;pub use config::NotificationsConfig;diff --git a/rust/cymbal/src/modes/notifications/temporal.rs b/rust/cymbal/src/modes/notifications/temporal.rsnew file mode 100644index 000000000000..663d0c4be7a8--- /dev/null+++ b/rust/cymbal/src/modes/notifications/temporal.rs@@ -0,0 +1,244 @@+use std::collections::HashSet;++use common_temporal::{+ StartWorkflowOptions, StartWorkflowOutcome, TemporalClientConfig, TemporalWorkflowClient,+};+use serde::Serialize;+use uuid::Uuid;++use crate::core::error::UnhandledError;+use crate::core::types::notification::{IssueCreated, IssueSnapshot};+use crate::modes::notifications::config::NotificationsConfig;++const WORKFLOW_NAME: &str = "error-tracking-issue-created";+const WORKFLOW_ID_PREFIX: &str = "error-tracking-issue-created";+const WORKFLOW_STARTS_TOTAL: &str = "cymbal_issue_created_workflow_starts_total";+const WORKFLOW_ROUTES_TOTAL: &str = "cymbal_issue_created_workflow_routes_total";++#[derive(Clone, Default)]+pub struct MaybeIssueCreatedWorkflowStarter(Option<IssueCreatedWorkflowStarter>);++impl MaybeIssueCreatedWorkflowStarter {+ pub async fn from_config(config: &NotificationsConfig) -> Result<Self, UnhandledError> {+ if !config.issue_created_workflow_enabled {+ return Ok(Self::default());+ }++ Ok(Self(Some(+ IssueCreatedWorkflowStarter::from_config(config).await?,+ )))+ }++ pub async fn start_if_enabled(+ &self,+ notification: &IssueCreated,+ ) -> Result<bool, UnhandledError> {+ let Some(starter) = &self.0 else {+ metrics::counter!(WORKFLOW_ROUTES_TOTAL, "route" => "legacy").increment(1);+ return Ok(false);+ };+ if !starter.is_enabled_for_team(notification.meta.team_id) {+ metrics::counter!(WORKFLOW_ROUTES_TOTAL, "route" => "legacy").increment(1);+ return Ok(false);+ }++ starter.start(notification).await?;+ metrics::counter!(WORKFLOW_ROUTES_TOTAL, "route" => "temporal").increment(1);+ Ok(true)+ }+}++#[derive(Clone)]+struct IssueCreatedWorkflowStarter {+ client: TemporalWorkflowClient,+ task_queue: String,+ enabled_team_ids: Option<HashSet<i32>>,+}++impl IssueCreatedWorkflowStarter {+ async fn from_config(config: &NotificationsConfig) -> Result<Self, UnhandledError> {+ let client = TemporalWorkflowClient::connect(TemporalClientConfig {+ host: config.temporal_host.clone(),+ port: config.temporal_port,+ namespace: config.temporal_namespace.clone(),+ client_cert: config.temporal_client_cert.clone(),+ client_key: config.temporal_client_key.clone(),+ server_root_ca_cert: config.temporal_client_root_ca.clone(),+ payload_encryption_key: config.temporal_secret_key.clone(),+ identity: "cymbal-notifications".to_string(),+ })+ .await+ .map_err(|error| UnhandledError::Other(error.to_string()))?;++ Ok(Self {+ client,+ task_queue: config.error_tracking_lifecycle_task_queue.clone(),+ enabled_team_ids: parse_team_ids(&config.issue_created_workflow_team_ids)?,+ })+ }++ fn is_enabled_for_team(&self, team_id: i32) -> bool {+ self.enabled_team_ids+ .as_ref()+ .is_none_or(|team_ids| team_ids.contains(&team_id))+ }++ async fn start(&self, notification: &IssueCreated) -> Result<(), UnhandledError> {+ let options = start_options(notification, &self.task_queue);+ match self+ .client+ .start_workflow(&IssueCreatedWorkflowInput::from(notification), &options)+ .await+ {+ Ok(StartWorkflowOutcome::Started { .. }) => {+ metrics::counter!(WORKFLOW_STARTS_TOTAL, "outcome" => "started").increment(1);+ Ok(())+ }+ Ok(StartWorkflowOutcome::Existing { .. }) => {+ metrics::counter!(WORKFLOW_STARTS_TOTAL, "outcome" => "already_started")+ .increment(1);+ Ok(())+ }+ Err(error) => {+ metrics::counter!(WORKFLOW_STARTS_TOTAL, "outcome" => "error").increment(1);+ Err(UnhandledError::Other(format!(+ "failed to start issue-created workflow: {error}"+ )))+ }+ }+ }+}++fn start_options(notification: &IssueCreated, task_queue: &str) -> StartWorkflowOptions {+ StartWorkflowOptions::idempotent(+ WORKFLOW_NAME,+ task_queue,+ format!("{WORKFLOW_ID_PREFIX}-{}", notification.meta.notification_id),+ notification.meta.notification_id.to_string(),+ )+}++#[derive(Serialize)]+struct IssueCreatedWorkflowInput<'a> {+ notification_id: Uuid,+ team_id: i32,+ issue_id: Uuid,+ issue: &'a IssueSnapshot,+ fingerprint: &'a str,+ event_uuid: Uuid,+ event_timestamp: &'a str,+ assignee: Option<&'a str>,+}++impl<'a> From<&'a IssueCreated> for IssueCreatedWorkflowInput<'a> {+ fn from(notification: &'a IssueCreated) -> Self {+ Self {+ notification_id: notification.meta.notification_id,+ team_id: notification.meta.team_id,+ issue_id: notification.issue.issue_id,+ issue: ¬ification.issue.issue,+ fingerprint: ¬ification.fingerprint,+ event_uuid: notification.event_uuid,+ event_timestamp: ¬ification.event_timestamp,+ assignee: notification.assignee.as_deref(),+ }+ }+}++fn parse_team_ids(raw: &str) -> Result<Option<HashSet<i32>>, UnhandledError> {+ if raw.trim().is_empty() {+ return Ok(None);+ }+ raw.split(',')+ .map(|value| {+ value.trim().parse::<i32>().map_err(|error| {+ UnhandledError::Other(format!(+ "invalid ERROR_TRACKING_ISSUE_CREATED_WORKFLOW_TEAM_IDS entry {value:?}: {error}"+ ))+ })+ })+ .collect::<Result<HashSet<_>, _>>()+ .map(Some)+}++#[cfg(test)]+mod tests {+ use chrono::Utc;++ use crate::core::types::notification::{IssueNotificationContext, NotificationMeta};+ use crate::types::ProcessedExceptionProperties;++ use super::*;++ fn notification_id() -> Uuid {+ Uuid::parse_str("018f3f58-7a7b-7c00-8000-000000000001").unwrap()+ }++ fn notification() -> IssueCreated {+ IssueCreated {+ meta: NotificationMeta {+ notification_id: notification_id(),+ team_id: 42,+ },+ issue: IssueNotificationContext {+ issue_id: Uuid::nil(),+ issue: IssueSnapshot {+ name: Some("TypeError".to_string()),+ description: Some("boom".to_string()),+ status: "active".to_string(),+ created_at: Utc::now(),+ },+ event_properties: serde_json::from_value::<ProcessedExceptionProperties>(+ serde_json::json!({+ "$exception_list": [{"type": "TypeError", "value": "boom"}],+ "$exception_fingerprint": "fingerprint",+ "$exception_fingerprint_record": [],+ "$exception_issue_id": Uuid::nil(),+ "$exception_handled": false,+ "$exception_types": ["TypeError"],+ "$exception_values": ["boom"],+ "$exception_sources": [],+ "$exception_functions": [],+ }),+ )+ .unwrap(),+ },+ fingerprint: "fingerprint".to_string(),+ event_uuid: Uuid::nil(),+ event_timestamp: "2026-07-21T12:00:00Z".to_string(),+ assignee: None,+ }+ }++ #[test]+ fn workflow_input_excludes_event_properties() {+ let value = serde_json::to_value(IssueCreatedWorkflowInput::from(¬ification())).unwrap();++ assert_eq!(value["team_id"], 42);+ assert_eq!(value["fingerprint"], "fingerprint");+ assert!(value.get("event_properties").is_none());+ }++ #[test]+ fn start_options_are_idempotent_and_target_the_lifecycle_queue() {+ let options = start_options(¬ification(), "error-tracking-lifecycle-task-queue");++ assert_eq!(options.workflow_name, "error-tracking-issue-created");+ assert_eq!(+ options.workflow_id,+ format!("error-tracking-issue-created-{}", notification_id())+ );+ assert_eq!(options.request_id, notification_id().to_string());+ assert_eq!(options.task_queue, "error-tracking-lifecycle-task-queue");+ }++ #[test]+ fn parses_rollout_team_allowlist() {+ assert_eq!(parse_team_ids("").unwrap(), None);+ assert_eq!(+ parse_team_ids("42, 43").unwrap(),+ Some(HashSet::from([42, 43]))+ );+ assert!(parse_team_ids("42,nope").is_err());+ }+}