From ac318f9922cb9d83f183076e23a0dd36f7f2354a Mon Sep 17 00:00:00 2001 From: Simon Scatton Date: Fri, 20 Nov 2026 10:32:12 +0100 Subject: [PATCH 1/5] refactor(drivers): stop passing the telemetry toggle into sandboxes The Docker, Kubernetes, Podman and VM drivers copied the gateway's OPENSHELL_TELEMETRY_ENABLED value into every sandbox environment, but the sandbox supervisor never read it. Drop the injection, the sandbox_env constant, the core helper that computed the value, and the tests that pinned the propagation. Signed-off-by: Simon Scatton --- Cargo.lock | 2 - crates/openshell-core/src/sandbox_env.rs | 3 - crates/openshell-core/src/telemetry.rs | 30 ---------- .../src/image_update.rs | 10 +--- .../src/image_update/tests.rs | 1 - crates/openshell-driver-docker/src/lib.rs | 22 ++----- crates/openshell-driver-docker/src/tests.rs | 11 +--- crates/openshell-driver-kubernetes/Cargo.toml | 1 - .../openshell-driver-kubernetes/src/driver.rs | 39 ------------- .../src/sandbox_runtime.rs | 4 -- crates/openshell-driver-podman/Cargo.toml | 1 - .../openshell-driver-podman/src/container.rs | 42 -------------- crates/openshell-driver-vm/src/driver.rs | 57 ------------------- 13 files changed, 10 insertions(+), 213 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9260c5bc89..857ef6b72d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4686,7 +4686,6 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.9", - "temp-env", "thiserror 2.0.20", "tokio", "tokio-rustls", @@ -4769,7 +4768,6 @@ dependencies = [ "serde_json", "sha2 0.10.9", "tar", - "temp-env", "tempfile", "thiserror 2.0.20", "tokio", diff --git a/crates/openshell-core/src/sandbox_env.rs b/crates/openshell-core/src/sandbox_env.rs index c691642904..965bb0dd10 100644 --- a/crates/openshell-core/src/sandbox_env.rs +++ b/crates/openshell-core/src/sandbox_env.rs @@ -373,9 +373,6 @@ impl MainProcessConfig { } } -/// Deployment-controlled telemetry toggle propagated to the sandbox supervisor. -pub const TELEMETRY_ENABLED: &str = "OPENSHELL_TELEMETRY_ENABLED"; - /// Supervisor pod/runtime topology. Kubernetes sidecar mode sets this to /// `"sidecar"`; the default combined supervisor path omits it. pub const SUPERVISOR_TOPOLOGY: &str = "OPENSHELL_SUPERVISOR_TOPOLOGY"; diff --git a/crates/openshell-core/src/telemetry.rs b/crates/openshell-core/src/telemetry.rs index 2aca36f92b..7de98b22b7 100644 --- a/crates/openshell-core/src/telemetry.rs +++ b/crates/openshell-core/src/telemetry.rs @@ -304,27 +304,6 @@ pub fn enabled() -> bool { false } -#[cfg(feature = "telemetry")] -pub fn enabled_env_value() -> &'static str { - enabled_env_value_from(std::env::var("OPENSHELL_TELEMETRY_ENABLED").ok().as_deref()) -} - -/// Telemetry support is compiled out: report disabled so sandbox supervisors -/// inherit the disabled state and skip activity collection. -#[cfg(not(feature = "telemetry"))] -pub fn enabled_env_value() -> &'static str { - "false" -} - -#[cfg(feature = "telemetry")] -fn enabled_env_value_from(value: Option<&str>) -> &'static str { - if telemetry_enabled_from(value) { - "true" - } else { - "false" - } -} - #[cfg(feature = "telemetry")] fn telemetry_enabled_from(value: Option<&str>) -> bool { let value = value.unwrap_or("true"); @@ -627,14 +606,6 @@ mod tests { assert!(telemetry_enabled_from(Some("yes"))); } - #[test] - fn telemetry_enabled_env_value_is_normalized() { - assert_eq!(enabled_env_value_from(Some("false")), "false"); - assert_eq!(enabled_env_value_from(Some("0")), "false"); - assert_eq!(enabled_env_value_from(None), "true"); - assert_eq!(enabled_env_value_from(Some("yes")), "true"); - } - #[test] fn telemetry_endpoint_empty_disables_publish() { assert_eq!(telemetry_endpoint_from(Some(" ")), None); @@ -749,7 +720,6 @@ mod disabled_tests { #[test] fn telemetry_reports_disabled_when_compiled_out() { assert!(!enabled()); - assert_eq!(enabled_env_value(), "false"); } #[test] diff --git a/crates/openshell-driver-docker/src/image_update.rs b/crates/openshell-driver-docker/src/image_update.rs index 4c5070f2c9..98ef7a1f6b 100644 --- a/crates/openshell-driver-docker/src/image_update.rs +++ b/crates/openshell-driver-docker/src/image_update.rs @@ -628,13 +628,9 @@ impl DockerComputeDriver { .unwrap_or_default() .iter() .filter(|entry| { - entry.split_once('=').is_some_and(|(name, _)| { - matches!( - name, - openshell_core::sandbox_env::LOG_LEVEL - | openshell_core::sandbox_env::TELEMETRY_ENABLED - ) - }) + entry + .split_once('=') + .is_some_and(|(name, _)| name == openshell_core::sandbox_env::LOG_LEVEL) }) .cloned() .collect(), diff --git a/crates/openshell-driver-docker/src/image_update/tests.rs b/crates/openshell-driver-docker/src/image_update/tests.rs index 3ba13f7e21..a22b532383 100644 --- a/crates/openshell-driver-docker/src/image_update/tests.rs +++ b/crates/openshell-driver-docker/src/image_update/tests.rs @@ -55,7 +55,6 @@ impl Fixture { ]); original_config.env = Some(vec![ format!("{}=debug", openshell_core::sandbox_env::LOG_LEVEL), - format!("{}=false", openshell_core::sandbox_env::TELEMETRY_ENABLED), "PATH=/original-image/path".into(), ]); source.host_config = Some(serde_json::from_value(serde_json::json!({ diff --git a/crates/openshell-driver-docker/src/lib.rs b/crates/openshell-driver-docker/src/lib.rs index 8bb5f9bbee..9bf8d244c9 100644 --- a/crates/openshell-driver-docker/src/lib.rs +++ b/crates/openshell-driver-docker/src/lib.rs @@ -5623,11 +5623,6 @@ async fn spawn_docker_control_process( openshell_core::sandbox_env::LOG_LEVEL, openshell_core::driver_utils::sandbox_log_level(sandbox, &config.log_level) ), - format!( - "{}={}", - openshell_core::sandbox_env::TELEMETRY_ENABLED, - openshell_core::telemetry::enabled_env_value() - ), ]; environment.extend(image_environment); environment.extend(supervisor_otlp_environment(config)); @@ -6215,18 +6210,11 @@ fn build_boundary_environment( sandbox: &DriverSandbox, config: &DockerDriverRuntimeConfig, ) -> Vec { - vec![ - format!( - "{}={}", - openshell_core::sandbox_env::LOG_LEVEL, - openshell_core::driver_utils::sandbox_log_level(sandbox, &config.log_level) - ), - format!( - "{}={}", - openshell_core::sandbox_env::TELEMETRY_ENABLED, - openshell_core::telemetry::enabled_env_value() - ), - ] + vec![format!( + "{}={}", + openshell_core::sandbox_env::LOG_LEVEL, + openshell_core::driver_utils::sandbox_log_level(sandbox, &config.log_level) + )] } fn docker_cdi_gpu_inventory(info: &SystemInfo) -> CdiGpuInventory { diff --git a/crates/openshell-driver-docker/src/tests.rs b/crates/openshell-driver-docker/src/tests.rs index 40972a0c79..48a4b61e0d 100644 --- a/crates/openshell-driver-docker/src/tests.rs +++ b/crates/openshell-driver-docker/src/tests.rs @@ -1609,15 +1609,8 @@ fn supervisor_otlp_environment_carries_only_configured_signals() { fn boundary_environment_contains_only_driver_owned_values() { let env = build_boundary_environment(&test_sandbox(), &runtime_config()); - assert_eq!(env.len(), 2); - assert!( - env.iter() - .any(|entry| entry.starts_with("OPENSHELL_LOG_LEVEL=")) - ); - assert!(env.iter().any(|entry| entry.starts_with(&format!( - "{}=", - openshell_core::sandbox_env::TELEMETRY_ENABLED - )))); + assert_eq!(env.len(), 1); + assert!(env[0].starts_with("OPENSHELL_LOG_LEVEL=")); } #[test] diff --git a/crates/openshell-driver-kubernetes/Cargo.toml b/crates/openshell-driver-kubernetes/Cargo.toml index 4b7659ffdd..35d971db6e 100644 --- a/crates/openshell-driver-kubernetes/Cargo.toml +++ b/crates/openshell-driver-kubernetes/Cargo.toml @@ -56,7 +56,6 @@ tokio-rustls = { workspace = true } [dev-dependencies] openshell-otel-test-support = { path = "../openshell-otel-test-support" } opentelemetry_sdk = { workspace = true, features = ["testing"] } -temp-env = "0.3" tokio = { workspace = true, features = ["test-util"] } toml = { workspace = true } diff --git a/crates/openshell-driver-kubernetes/src/driver.rs b/crates/openshell-driver-kubernetes/src/driver.rs index f7eaf4bd6b..2321c67842 100644 --- a/crates/openshell-driver-kubernetes/src/driver.rs +++ b/crates/openshell-driver-kubernetes/src/driver.rs @@ -8338,11 +8338,6 @@ fn build_sandbox_env( upsert_env(&mut env, name, value); } } - upsert_env( - &mut env, - openshell_core::sandbox_env::TELEMETRY_ENABLED, - openshell_core::telemetry::enabled_env_value(), - ); env } @@ -9570,9 +9565,6 @@ mod tests { assert!(err.contains("Secret"), "{err}"); } - static ENV_LOCK: std::sync::LazyLock> = - std::sync::LazyLock::new(|| std::sync::Mutex::new(())); - fn kube_test_response( status: http::StatusCode, body: serde_json::Value, @@ -12934,37 +12926,6 @@ mod tests { assert!(cr["spec"].get("logLevel").is_none()); } - #[test] - fn telemetry_toggle_propagates_from_driver_env_to_sandbox_pod() { - let _guard = ENV_LOCK.lock().unwrap(); - temp_env::with_vars( - [( - openshell_core::sandbox_env::TELEMETRY_ENABLED, - Some("false"), - )], - || { - let spec = SandboxSpec { - environment: std::collections::HashMap::from([( - openshell_core::sandbox_env::TELEMETRY_ENABLED.to_string(), - "true".to_string(), - )]), - ..SandboxSpec::default() - }; - let cr = sandbox_to_k8s_spec_for_test(Some(&spec), &SandboxPodParams::default()); - let env = cr["spec"]["podTemplate"]["spec"]["containers"][0]["env"] - .as_array() - .unwrap(); - let telemetry_entries = env - .iter() - .filter(|entry| entry["name"] == openshell_core::sandbox_env::TELEMETRY_ENABLED) - .collect::>(); - - assert_eq!(telemetry_entries.len(), 1); - assert_eq!(telemetry_entries[0]["value"], serde_json::json!("false")); - }, - ); - } - #[test] fn sandbox_pod_drops_legacy_network_capability_environment() { let spec = SandboxSpec { diff --git a/crates/openshell-driver-kubernetes/src/sandbox_runtime.rs b/crates/openshell-driver-kubernetes/src/sandbox_runtime.rs index 9ed4ce71e9..1dda469cfc 100644 --- a/crates/openshell-driver-kubernetes/src/sandbox_runtime.rs +++ b/crates/openshell-driver-kubernetes/src/sandbox_runtime.rs @@ -391,10 +391,6 @@ pub fn supervisor_pod( PROXY_CA_PRIVATE_KEY_PATH, ), env_var("OPENSHELL_LOG_LEVEL", log_level), - env_var( - openshell_core::sandbox_env::TELEMETRY_ENABLED, - openshell_core::telemetry::enabled_env_value(), - ), env_var( openshell_core::sandbox_env::NETWORK_RUNTIME_CAPABILITIES, "", diff --git a/crates/openshell-driver-podman/Cargo.toml b/crates/openshell-driver-podman/Cargo.toml index 3fb3c51b5d..1cc04e3a85 100644 --- a/crates/openshell-driver-podman/Cargo.toml +++ b/crates/openshell-driver-podman/Cargo.toml @@ -54,7 +54,6 @@ openshell-otel-test-support = { path = "../openshell-otel-test-support" } opentelemetry_sdk = { workspace = true, features = ["testing"] } prost-types = { workspace = true } rcgen = { workspace = true } -temp-env = "0.3" tokio = { workspace = true, features = ["test-util"] } [lints] diff --git a/crates/openshell-driver-podman/src/container.rs b/crates/openshell-driver-podman/src/container.rs index 9943d7a0b6..7a05c1aaf6 100644 --- a/crates/openshell-driver-podman/src/container.rs +++ b/crates/openshell-driver-podman/src/container.rs @@ -734,10 +734,6 @@ fn build_env( openshell_core::sandbox_env::MAIN_PROCESS_SPEC.into(), main_process, ); - env.insert( - openshell_core::sandbox_env::TELEMETRY_ENABLED.into(), - openshell_core::telemetry::enabled_env_value().into(), - ); env.extend( config .supervisor_otlp @@ -1933,9 +1929,6 @@ mod tests { use crate::client::ImageConfig; use openshell_core::proto::compute::v1::{GpuResourceRequirements, ResourceRequirements}; - static ENV_LOCK: std::sync::LazyLock> = - std::sync::LazyLock::new(|| std::sync::Mutex::new(())); - fn resolved_image( requested_image: &str, id: &str, @@ -3012,41 +3005,6 @@ mod tests { ); } - #[test] - fn container_spec_telemetry_toggle_comes_from_driver_env() { - use openshell_core::proto::compute::v1::{DriverSandboxSpec, DriverSandboxTemplate}; - - let _guard = ENV_LOCK.lock().unwrap(); - temp_env::with_vars( - [( - openshell_core::sandbox_env::TELEMETRY_ENABLED, - Some("false"), - )], - || { - let mut sandbox = test_sandbox("test-id", "legit-name"); - sandbox.spec = Some(DriverSandboxSpec { - environment: std::collections::HashMap::from([( - openshell_core::sandbox_env::TELEMETRY_ENABLED.to_string(), - "true".to_string(), - )]), - template: Some(DriverSandboxTemplate::default()), - ..Default::default() - }); - - let spec = build_container_spec(&sandbox, &test_config()); - let env_map = spec["env"].as_object().expect("env should be an object"); - - assert_eq!( - env_map - .get(openshell_core::sandbox_env::TELEMETRY_ENABLED) - .and_then(|v| v.as_str()), - Some("false"), - "telemetry toggle must come from the deployment environment" - ); - }, - ); - } - #[test] fn container_spec_keeps_network_capabilities_driver_controlled() { use openshell_core::proto::compute::v1::{DriverSandboxSpec, DriverSandboxTemplate}; diff --git a/crates/openshell-driver-vm/src/driver.rs b/crates/openshell-driver-vm/src/driver.rs index 528c786b60..27b4a51256 100644 --- a/crates/openshell-driver-vm/src/driver.rs +++ b/crates/openshell-driver-vm/src/driver.rs @@ -1475,10 +1475,6 @@ impl VmDriver { .env( openshell_core::sandbox_env::LOG_LEVEL, openshell_core::driver_utils::sandbox_log_level(sandbox, &self.config.log_level), - ) - .env( - openshell_core::sandbox_env::TELEMETRY_ENABLED, - openshell_core::telemetry::enabled_env_value(), ); command.envs(supervisor_otlp_environment(&self.config)); if let Some(server_name) = gateway_tls_server_name { @@ -6752,10 +6748,6 @@ fn build_guest_environment(sandbox: &Sandbox, config: &VmDriverConfig) -> Vec>(); pairs.sort_by(|left, right| left.0.cmp(&right.0)); pairs @@ -8346,9 +8338,6 @@ mod tests { (dir, Arc::new(fd)) } - static ENV_LOCK: std::sync::LazyLock> = - std::sync::LazyLock::new(|| std::sync::Mutex::new(())); - #[test] fn vm_console_diagnostic_is_bounded_to_the_tail() { let directory = tempfile::tempdir().unwrap(); @@ -11981,52 +11970,6 @@ mod tests { ); } - #[test] - fn build_guest_environment_uses_deployment_telemetry_toggle() { - let _guard = ENV_LOCK.lock().unwrap(); - temp_env::with_vars( - [( - openshell_core::sandbox_env::TELEMETRY_ENABLED, - Some("false"), - )], - || { - let config = VmDriverConfig { - grpc_endpoint: "http://127.0.0.1:8080".to_string(), - ..Default::default() - }; - let sandbox = Sandbox { - id: "sandbox-123".to_string(), - name: "sandbox-123".to_string(), - spec: Some(SandboxSpec { - environment: HashMap::from([( - openshell_core::sandbox_env::TELEMETRY_ENABLED.to_string(), - "true".to_string(), - )]), - ..Default::default() - }), - ..Default::default() - }; - - let env = build_guest_environment(&sandbox, &config); - let telemetry_entries = env - .iter() - .filter(|entry| { - entry.starts_with(&format!( - "{}=", - openshell_core::sandbox_env::TELEMETRY_ENABLED - )) - }) - .collect::>(); - - assert_eq!(telemetry_entries.len(), 1); - assert_eq!( - telemetry_entries[0], - &format!("{}=false", openshell_core::sandbox_env::TELEMETRY_ENABLED) - ); - }, - ); - } - #[test] fn image_reference_registry_host_defaults_to_docker_hub() { assert_eq!(image_reference_registry_host("ubuntu:24.04"), "docker.io"); From b25f140af8f343bc1caf6375a5d2e6938810b6ff Mon Sep 17 00:00:00 2001 From: Kris Hicks Date: Mon, 23 Nov 2026 07:46:30 -0800 Subject: [PATCH 2/5] docs(telemetry): stop describing sandbox propagation of the telemetry toggle The gateway no longer passes OPENSHELL_TELEMETRY_ENABLED into sandbox environments, but the telemetry, Kubernetes setup and Helm docs, the VM driver feature comment and the cluster debug skill still said it did. Describe the setting as gateway-only. Signed-off-by: Kris Hicks --- crates/openshell-driver-vm/Cargo.toml | 3 +-- deploy/helm/openshell/README.md | 2 +- deploy/helm/openshell/values.yaml | 3 +-- docs/kubernetes/setup.mdx | 2 +- docs/observability/telemetry.mdx | 4 ++-- skills/debug-openshell-cluster/SKILL.md | 2 +- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/crates/openshell-driver-vm/Cargo.toml b/crates/openshell-driver-vm/Cargo.toml index 57921d4b9a..0a67b2436e 100644 --- a/crates/openshell-driver-vm/Cargo.toml +++ b/crates/openshell-driver-vm/Cargo.toml @@ -102,8 +102,7 @@ compute-driver = [ "dep:zstd", ] ## Compile in telemetry support (forwards to openshell-core/telemetry). On by -## default; build with `--no-default-features` for a telemetry-free VM driver -## that reports telemetry disabled to the sandboxes it launches. +## default; build with `--no-default-features` for a telemetry-free VM driver. telemetry = ["openshell-core/telemetry"] ## Convenience alias: every default feature except `telemetry`. Build a ## telemetry-free VM driver with diff --git a/deploy/helm/openshell/README.md b/deploy/helm/openshell/README.md index 92fc803b1d..deed9fc708 100644 --- a/deploy/helm/openshell/README.md +++ b/deploy/helm/openshell/README.md @@ -793,7 +793,7 @@ for peer identity policies, multi-node registrations, and authorization. | server.sandboxNamespace | string | `""` | Namespace where sandbox pods are created. Defaults to the Helm release namespace (.Release.Namespace) when left empty. | | server.sandboxUid | string | `""` | UID for sandbox pods (`sandbox_uid`). Empty (default) = use the OpenShift SCC namespace annotation if present, otherwise the driver default. Must be an integer between 1 and 4294967294. | | server.serviceHostnameFormat | string | `""` | Hostname format for exposed sandbox services. Empty or "readable" keeps readable `--[--]` hostnames; "hashed" mints opaque one-label hostnames discriminated by the gateway installation name (server.name, defaulting to the release name). The name must be unique among all gateways sharing the service base domain, and renaming the installation changes every minted hostname. | -| server.telemetryEnabled | bool | `true` | Enable anonymous OpenShell telemetry from the gateway and the sandbox supervisors it launches. | +| server.telemetryEnabled | bool | `true` | Enable anonymous OpenShell telemetry from the gateway. | | server.tls.certSecretName | string | `"openshell-server-tls"` | K8s secret (type kubernetes.io/tls) with tls.crt and tls.key for the server. | | server.tls.clientCaSecretName | string | `"openshell-server-client-ca"` | K8s secret with ca.crt for client certificate verification (mTLS). Only used when enableMtls is true. Set to "" to disable client certificate verification for HTTPS-only mode. | | server.tls.clientTlsSecretName | string | `"openshell-client-tls"` | K8s secret mounted into sandbox pods for mTLS to the server. | diff --git a/deploy/helm/openshell/values.yaml b/deploy/helm/openshell/values.yaml index 5cfd50f99e..3825068f29 100644 --- a/deploy/helm/openshell/values.yaml +++ b/deploy/helm/openshell/values.yaml @@ -487,8 +487,7 @@ server: # -- Additional environment variables for the gateway container, such as # OTEL_* exporter settings. Entries can read from a Secret with valueFrom. extraEnv: [] - # -- Enable anonymous OpenShell telemetry from the gateway and the sandbox - # supervisors it launches. + # -- Enable anonymous OpenShell telemetry from the gateway. telemetryEnabled: true # -- Namespace where sandbox pods are created. Defaults to the Helm release # namespace (.Release.Namespace) when left empty. diff --git a/docs/kubernetes/setup.mdx b/docs/kubernetes/setup.mdx index c9f936818e..703bbdbaf0 100644 --- a/docs/kubernetes/setup.mdx +++ b/docs/kubernetes/setup.mdx @@ -310,7 +310,7 @@ The most commonly changed values are: | `server.externalDbSecret` | Secret containing a PostgreSQL connection URI in the `uri` key. Use when the database is managed outside the chart. | | `server.dataStorageSize` | Storage request for the gateway data PVC under `workload.kind=statefulset`. Defaults to `1Gi`. Requires an explicit unit, such as `20Gi`. | | `server.dataStorageClass` | `StorageClass` for the gateway data PVC under `workload.kind=statefulset`. Empty (default) omits `storageClassName` and uses the cluster's default `StorageClass`. Use a block-backed class, not NFS. | -| `server.telemetryEnabled` | Enable anonymous OpenShell telemetry from the gateway and its sandbox supervisors. Set to `false` to opt out. | +| `server.telemetryEnabled` | Enable anonymous OpenShell telemetry from the gateway. Set to `false` to opt out. | | `sandbox.image.repository` / `sandbox.image.tag` / `sandbox.image.digest` | Default sandbox image used when a sandbox does not specify one. | | `sandboxRuntime.image.registry` / `sandboxRuntime.image.repository` / `sandboxRuntime.image.tag` / `sandboxRuntime.image.digest` | Trusted workload-side image that provides the `openshell-sandbox` binary. A digest takes precedence over the tag. | | `supervisor.image.registry` / `supervisor.image.repository` / `supervisor.image.tag` / `supervisor.image.digest` | Trusted control-side supervisor image. | diff --git a/docs/observability/telemetry.mdx b/docs/observability/telemetry.mdx index 0793fefd0d..7bc99faa02 100644 --- a/docs/observability/telemetry.mdx +++ b/docs/observability/telemetry.mdx @@ -19,7 +19,7 @@ Opting out applies only to telemetry emitted by OpenShell. Third-party services, ## Disable Telemetry at Runtime -Set `OPENSHELL_TELEMETRY_ENABLED=false` on the gateway deployment. For Helm installs, set `server.telemetryEnabled=false`. OpenShell propagates this setting into sandbox supervisor environments, so sandbox-side telemetry collection is disabled as well. +Set `OPENSHELL_TELEMETRY_ENABLED=false` on the gateway deployment. For Helm installs, set `server.telemetryEnabled=false`. ## Compile Telemetry Out @@ -31,7 +31,7 @@ cargo build --release -p openshell-sandbox --no-default-features --features defa cargo build --release -p openshell-driver-vm --no-default-features --features defaults-without-telemetry ``` -The resulting binaries contain no telemetry endpoint, no telemetry HTTP client, and no emission code. With telemetry compiled out, the gateway emits nothing and reports telemetry disabled to the sandboxes it launches. +The resulting binaries contain no telemetry endpoint, no telemetry HTTP client, and no emission code. With telemetry compiled out, the gateway emits nothing. Cargo cannot subtract a single default feature, so `defaults-without-telemetry` must be paired with `--no-default-features`. Passing it on its own leaves the defaults in place and fails the build rather than producing a binary that still emits. diff --git a/skills/debug-openshell-cluster/SKILL.md b/skills/debug-openshell-cluster/SKILL.md index 43c68dfeeb..564fbcec2a 100644 --- a/skills/debug-openshell-cluster/SKILL.md +++ b/skills/debug-openshell-cluster/SKILL.md @@ -572,7 +572,7 @@ kubectl -n openshell logs -c openshell-gateway --tail=200 ``` `server.telemetryEnabled` renders `OPENSHELL_TELEMETRY_ENABLED` on the gateway -pod, and the gateway propagates the effective value to sandbox supervisors. +pod. Gateway pod scheduling accepts top-level `nodeSelector`, `affinity`, `tolerations`, `priorityClassName`, and `topologySpreadConstraints` values for From c73124b5571a86a7a3243a222f2a5d2117cbf20a Mon Sep 17 00:00:00 2001 From: Kris Hicks Date: Mon, 23 Nov 2026 07:50:10 -0800 Subject: [PATCH 3/5] refactor(build): make the VM driver and supervisor telemetry features no-ops The VM driver's telemetry feature only enabled enabled_env_value(), which the previous commit removed, and the supervisor's never compiled in anything it called. Both still forwarded to openshell-core/telemetry and carried a compile_error! guard, and the telemetry docs told operators to build them, and openshell-sandbox, with defaults-without-telemetry. Keep both features as deprecated no-ops so existing build flags still work, drop the guards and their verify-script entries, and check that the default supervisor build contains no telemetry markers. Signed-off-by: Kris Hicks --- .github/workflows/branch-checks.yml | 2 +- crates/openshell-driver-vm/Cargo.toml | 16 ++++------------ crates/openshell-driver-vm/src/lib.rs | 10 ---------- crates/openshell-supervisor/Cargo.toml | 8 +++++--- crates/openshell-supervisor/src/lib.rs | 10 ---------- docs/observability/telemetry.mdx | 6 ++---- tasks/rust.toml | 3 ++- .../scripts/verify-defaults-without-telemetry.sh | 2 -- 8 files changed, 14 insertions(+), 43 deletions(-) diff --git a/.github/workflows/branch-checks.yml b/.github/workflows/branch-checks.yml index 5505a1fa1b..7214077893 100644 --- a/.github/workflows/branch-checks.yml +++ b/.github/workflows/branch-checks.yml @@ -483,7 +483,7 @@ jobs: tasks/scripts/verify-telemetry-compiled-out.sh present target/debug/openshell-gateway cargo build --locked -p openshell-gateway --bin openshell-gateway --no-default-features --features defaults-without-telemetry tasks/scripts/verify-telemetry-compiled-out.sh absent target/debug/openshell-gateway - cargo build --locked -p openshell-supervisor --bin openshell-supervisor --no-default-features --features defaults-without-telemetry + cargo build --locked -p openshell-supervisor --bin openshell-supervisor tasks/scripts/verify-telemetry-compiled-out.sh absent target/debug/openshell-supervisor cargo check --locked -p openshell-supervisor --all-targets --no-default-features --features system-ca-roots diff --git a/crates/openshell-driver-vm/Cargo.toml b/crates/openshell-driver-vm/Cargo.toml index 0a67b2436e..c6ec243bd4 100644 --- a/crates/openshell-driver-vm/Cargo.toml +++ b/crates/openshell-driver-vm/Cargo.toml @@ -66,7 +66,7 @@ zstd = { version = "0.14", optional = true } [features] # Portable test instrumentation, independent of the compute runtime. allocation-tracking = [] -default = ["compute-driver", "telemetry"] +default = ["compute-driver"] ## Build the standalone compute driver and its host runtime implementation. compute-driver = [ "dep:base64", @@ -101,17 +101,9 @@ compute-driver = [ "dep:url", "dep:zstd", ] -## Compile in telemetry support (forwards to openshell-core/telemetry). On by -## default; build with `--no-default-features` for a telemetry-free VM driver. -telemetry = ["openshell-core/telemetry"] -## Convenience alias: every default feature except `telemetry`. Build a -## telemetry-free VM driver with -## `--no-default-features --features defaults-without-telemetry` and stay -## correct as new default features are added. Cargo cannot subtract a single -## default feature, so this alias must be paired with `--no-default-features`; -## enabling it alongside `telemetry` is a compile error rather than a silent -## telemetry-on build. Kept in sync with `default` by -## `rust:verify:defaults-without-telemetry`. +## Deprecated no-ops: this crate contains no anonymous usage telemetry. Kept +## so builds that still pass these features keep working. +telemetry = [] defaults-without-telemetry = ["compute-driver"] [dev-dependencies] diff --git a/crates/openshell-driver-vm/src/lib.rs b/crates/openshell-driver-vm/src/lib.rs index 66041ea034..d2e0ab5eb4 100644 --- a/crates/openshell-driver-vm/src/lib.rs +++ b/crates/openshell-driver-vm/src/lib.rs @@ -1,16 +1,6 @@ // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -// `defaults-without-telemetry` is an alias for the default feature set minus -// `telemetry`, not a switch that turns telemetry off. Cargo cannot subtract a -// default feature, so adding it on top of the defaults would otherwise produce -// a telemetry-on build that reads as telemetry-free. Fail the build instead. -#[cfg(all(feature = "telemetry", feature = "defaults-without-telemetry"))] -compile_error!( - "features `telemetry` and `defaults-without-telemetry` are mutually exclusive; \ - build a telemetry-free VM driver with `--no-default-features --features defaults-without-telemetry`" -); - #[cfg(feature = "allocation-tracking")] pub mod allocation_tracking; diff --git a/crates/openshell-supervisor/Cargo.toml b/crates/openshell-supervisor/Cargo.toml index 396d19e993..66158fd0fb 100644 --- a/crates/openshell-supervisor/Cargo.toml +++ b/crates/openshell-supervisor/Cargo.toml @@ -61,10 +61,12 @@ tracing-subscriber = { workspace = true } uuid = { workspace = true } [features] -default = ["telemetry", "bundled-ca-roots"] -system-ca-roots = ["telemetry"] +default = ["bundled-ca-roots"] +system-ca-roots = [] +## Deprecated no-ops: this crate contains no anonymous usage telemetry. Kept +## so builds that still pass these features keep working. +telemetry = [] defaults-without-telemetry = ["bundled-ca-roots"] -telemetry = ["openshell-core/telemetry"] bundled-ca-roots = ["openshell-supervisor-network/bundled-ca-roots"] [dev-dependencies] diff --git a/crates/openshell-supervisor/src/lib.rs b/crates/openshell-supervisor/src/lib.rs index fe1cbec6d9..9d4b96436c 100644 --- a/crates/openshell-supervisor/src/lib.rs +++ b/crates/openshell-supervisor/src/lib.rs @@ -7,16 +7,6 @@ #![forbid(unsafe_code)] -// `defaults-without-telemetry` is an alias for the default feature set minus -// `telemetry`, not a switch that turns telemetry off. Cargo cannot subtract a -// default feature, so adding it on top of the defaults would otherwise produce -// a telemetry-on build that reads as telemetry-free. Fail the build instead. -#[cfg(all(feature = "telemetry", feature = "defaults-without-telemetry"))] -compile_error!( - "features `telemetry` and `defaults-without-telemetry` are mutually exclusive; \ - build a telemetry-free supervisor with `--no-default-features --features defaults-without-telemetry`" -); - mod activity_aggregator; pub mod app_listener; pub mod backend_setup; diff --git a/docs/observability/telemetry.mdx b/docs/observability/telemetry.mdx index 7bc99faa02..e062edf8e6 100644 --- a/docs/observability/telemetry.mdx +++ b/docs/observability/telemetry.mdx @@ -23,15 +23,13 @@ Set `OPENSHELL_TELEMETRY_ENABLED=false` on the gateway deployment. For Helm inst ## Compile Telemetry Out -Telemetry support is a default-on `telemetry` Cargo feature. Each crate that carries it also defines a `defaults-without-telemetry` alias covering every other default feature. Build telemetry-free artifacts with `--no-default-features --features defaults-without-telemetry`: +Telemetry support is a default-on `telemetry` Cargo feature of the gateway. The gateway also defines a `defaults-without-telemetry` alias covering every other default feature. Build a telemetry-free gateway with `--no-default-features --features defaults-without-telemetry`: ```shell cargo build --release -p openshell-gateway --no-default-features --features defaults-without-telemetry -cargo build --release -p openshell-sandbox --no-default-features --features defaults-without-telemetry -cargo build --release -p openshell-driver-vm --no-default-features --features defaults-without-telemetry ``` -The resulting binaries contain no telemetry endpoint, no telemetry HTTP client, and no emission code. With telemetry compiled out, the gateway emits nothing. +The resulting binary contains no telemetry endpoint, no telemetry HTTP client, and no emission code. With telemetry compiled out, the gateway emits nothing. Cargo cannot subtract a single default feature, so `defaults-without-telemetry` must be paired with `--no-default-features`. Passing it on its own leaves the defaults in place and fails the build rather than producing a binary that still emits. diff --git a/tasks/rust.toml b/tasks/rust.toml index 7795a6de9a..d3afee57a1 100644 --- a/tasks/rust.toml +++ b/tasks/rust.toml @@ -113,7 +113,8 @@ run = [ # operators to produce these artifacts. "cargo build -p openshell-gateway --bin openshell-gateway --no-default-features --features defaults-without-telemetry", "tasks/scripts/verify-telemetry-compiled-out.sh absent target/debug/openshell-gateway", - "cargo build -p openshell-supervisor --bin openshell-supervisor --no-default-features --features defaults-without-telemetry", + # The supervisor has no telemetry feature; its default build must stay clean. + "cargo build -p openshell-supervisor --bin openshell-supervisor", "tasks/scripts/verify-telemetry-compiled-out.sh absent target/debug/openshell-supervisor", ] diff --git a/tasks/scripts/verify-defaults-without-telemetry.sh b/tasks/scripts/verify-defaults-without-telemetry.sh index 104523b04b..cbebf379d0 100755 --- a/tasks/scripts/verify-defaults-without-telemetry.sh +++ b/tasks/scripts/verify-defaults-without-telemetry.sh @@ -23,8 +23,6 @@ set -euo pipefail # `defaults-without-telemetry`. CRATES=( openshell-gateway - openshell-supervisor - openshell-driver-vm ) if ! command -v jq >/dev/null 2>&1; then From 0d941f2a88386c8990ba1e17105bdb49ff021bc9 Mon Sep 17 00:00:00 2001 From: Kris Hicks Date: Mon, 23 Nov 2026 07:55:37 -0800 Subject: [PATCH 4/5] chore(driver-docker): drop the unused temp-env dev-dependency No Docker driver test uses temp-env. Signed-off-by: Kris Hicks --- Cargo.lock | 1 - crates/openshell-driver-docker/Cargo.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 857ef6b72d..017a0c0bed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4639,7 +4639,6 @@ dependencies = [ "serde_json", "sha2 0.10.9", "tar", - "temp-env", "tempfile", "tokio", "tokio-stream", diff --git a/crates/openshell-driver-docker/Cargo.toml b/crates/openshell-driver-docker/Cargo.toml index e4ba6f40c0..b722fbf8cc 100644 --- a/crates/openshell-driver-docker/Cargo.toml +++ b/crates/openshell-driver-docker/Cargo.toml @@ -52,7 +52,6 @@ openshell-otel-test-support = { path = "../openshell-otel-test-support" } opentelemetry = { workspace = true } opentelemetry_sdk = { workspace = true, features = ["testing"] } prost-types = { workspace = true } -temp-env = "0.3" tracing-subscriber = { workspace = true } [lints] From 8a763e74333b8f77856fe0bd5c90ef2c8aa886df Mon Sep 17 00:00:00 2001 From: Kris Hicks Date: Mon, 23 Nov 2026 08:09:24 -0800 Subject: [PATCH 5/5] refactor: remove anonymous usage telemetry The gateway sent anonymous usage events to an NVIDIA endpoint, and the supervisor counted network activity only to feed them. Remove the emitter, the server's lifecycle, policy and provider emission, the compute-driver telemetry categories, the supervisor activity aggregator and its producers, OPENSHELL_TELEMETRY_ENABLED, the Helm server.telemetryEnabled value, the telemetry docs page and community reports, and the CI checks that verified telemetry-free builds. Delete the NetworkActivitySummary and DenialGroupCount messages and reserve SubmitPolicyAnalysisRequest field 5. Supervisors that still send it reach an early return for requests with no chunks or summaries, so they don't trigger policy analysis or watch notifications. The gateway's telemetry and defaults-without-telemetry features stay as deprecated no-ops so existing build flags still work. Signed-off-by: Kris Hicks --- .../build-openshell-mxc-windows/SKILL.md | 4 +- .agents/skills/test-release-canary/SKILL.md | 6 - .github/workflows/branch-checks.yml | 32 - .github/workflows/release-canary.yml | 12 +- Cargo.lock | 1 - README.md | 4 - .../tests/provider_commands_integration.rs | 1 - .../tests/ssh_proxy_shutdown_integration.rs | 1 - crates/openshell-core/Cargo.toml | 9 +- crates/openshell-core/src/activity.rs | 50 -- crates/openshell-core/src/grpc_client.rs | 11 +- crates/openshell-core/src/lib.rs | 2 - crates/openshell-core/src/telemetry.rs | 754 ------------------ crates/openshell-crypto/README.md | 2 +- crates/openshell-driver-mxc/src/driver.rs | 1 - crates/openshell-gateway/Cargo.toml | 14 +- crates/openshell-gateway/src/lib.rs | 42 +- .../src/activity_aggregator.rs | 224 ------ crates/openshell-server/Cargo.toml | 5 - crates/openshell-server/src/compute/mod.rs | 19 - crates/openshell-server/src/grpc/policy.rs | 181 +---- crates/openshell-server/src/grpc/provider.rs | 248 +----- crates/openshell-server/src/grpc/sandbox.rs | 252 +----- crates/openshell-server/src/lib.rs | 49 +- .../src/supervisor_session.rs | 2 - crates/openshell-server/src/telemetry.rs | 123 --- crates/openshell-server/src/tracing_setup.rs | 2 - .../openshell-supervisor-network/src/host.rs | 4 - .../src/l7/relay.rs | 46 +- .../src/l7/token_grant_injection.rs | 1 - .../src/policy_local.rs | 2 +- .../openshell-supervisor-network/src/proxy.rs | 235 +----- .../src/proxy/relay.rs | 5 - .../src/proxy/tests/compatibility.rs | 3 - .../src/proxy/tests/request_trace.rs | 3 - .../src/proxy/trace_tests.rs | 1 - .../openshell-supervisor-network/src/run.rs | 4 - .../src/activity_aggregator.rs | 224 ------ crates/openshell-supervisor/src/lib.rs | 114 +-- deploy/helm/openshell/README.md | 1 - .../openshell/templates/_gateway-workload.tpl | 2 - .../openshell/tests/gateway_config_test.yaml | 20 - deploy/helm/openshell/values.yaml | 2 - docs/how-it-works/gateways/overview.mdx | 17 + docs/kubernetes/setup.mdx | 1 - docs/observability/overview.mdx | 1 - docs/observability/telemetry.mdx | 51 -- e2e/no-compute-driver-gateway.sh | 4 +- e2e/rust/e2e-vm.sh | 2 +- e2e/support/gateway-common.sh | 6 +- e2e/with-kube-gateway.sh | 3 +- examples/governance-interceptor/README.md | 10 +- .../src/smoke_client.rs | 13 +- examples/governance-interceptor/src/tests.rs | 6 +- proto/openshell.proto | 23 +- skills/debug-openshell-cluster/SKILL.md | 3 - tasks/rust.toml | 21 - tasks/scripts/run-postgres-tests.sh | 1 - .../verify-defaults-without-telemetry.sh | 86 -- .../scripts/verify-telemetry-compiled-out.sh | 73 -- tasks/test.toml | 1 - telemetry/2026-07-08.md | 46 -- telemetry/2026-07-26.md | 46 -- telemetry/2026-08-10.md | 46 -- telemetry/README.md | 13 - tests/suites/conformance/Cargo.lock | 4 - tests/suites/continuity/Cargo.lock | 4 - tests/suites/drivers/podman/Cargo.lock | 4 - tests/suites/features/Cargo.lock | 4 - tests/support/Cargo.lock | 4 - tests/testkit/Cargo.lock | 4 - .../ansible/playbooks/openshell-k3s.yaml | 1 - 72 files changed, 156 insertions(+), 3060 deletions(-) delete mode 100644 crates/openshell-core/src/activity.rs delete mode 100644 crates/openshell-core/src/telemetry.rs delete mode 100644 crates/openshell-sandbox/src/activity_aggregator.rs delete mode 100644 crates/openshell-server/src/telemetry.rs delete mode 100644 crates/openshell-supervisor/src/activity_aggregator.rs delete mode 100644 docs/observability/telemetry.mdx delete mode 100755 tasks/scripts/verify-defaults-without-telemetry.sh delete mode 100755 tasks/scripts/verify-telemetry-compiled-out.sh delete mode 100644 telemetry/2026-07-08.md delete mode 100644 telemetry/2026-07-26.md delete mode 100644 telemetry/2026-08-10.md delete mode 100644 telemetry/README.md diff --git a/.agents/skills/build-openshell-mxc-windows/SKILL.md b/.agents/skills/build-openshell-mxc-windows/SKILL.md index 04eb87ae57..5ac119edaf 100644 --- a/.agents/skills/build-openshell-mxc-windows/SKILL.md +++ b/.agents/skills/build-openshell-mxc-windows/SKILL.md @@ -386,8 +386,8 @@ The gateway's `compute-driver-mxc` feature independently links and registers MXC on Windows. Each other `compute-driver-*` feature installs its own Windows rejection stub without linking that driver crate. The default `in-tree-compute-drivers` alias enables all five features. An MXC-only build -uses `--no-default-features --features compute-driver-mxc` (add `telemetry` -and `openshell-server/prebuilt-z3` as needed). +uses `--no-default-features --features compute-driver-mxc` (add +`openshell-server/prebuilt-z3` as needed). | Driver | Windows build behavior | Runtime behavior | |---|---|---| diff --git a/.agents/skills/test-release-canary/SKILL.md b/.agents/skills/test-release-canary/SKILL.md index e35cb661fe..e4ba8be1e2 100644 --- a/.agents/skills/test-release-canary/SKILL.md +++ b/.agents/skills/test-release-canary/SKILL.md @@ -20,11 +20,6 @@ The Release Canary (`.github/workflows/release-canary.yml`) smoke-tests the arti | `ubuntu-snap-docker-preflight` | `ubuntu-latest` | Verifies that `install.sh` rejects the OpenShell snap path when Docker is absent or supplied by the Docker snap, without installing OpenShell. | | `kubernetes` | `ubuntu-latest` + kind | Installs the dev Helm chart, reaches the in-cluster gateway, and creates, executes in, and deletes a sandbox using the published runtime images. | -All canary jobs disable anonymous OpenShell telemetry. Host package jobs inject -`OPENSHELL_TELEMETRY_ENABLED=false` through the service environment, and the -Kubernetes job installs with `server.telemetryEnabled=false`, so smoke traffic -does not contribute to product usage metrics. - The workflow sets `OPENSHELL_VERSION=dev` for every `install.sh` job. Positive jobs consume the rolling dev release produced by the triggering workflow. The system-Docker snap lane tracks `latest/edge`; the missing-Docker lane exits @@ -118,7 +113,6 @@ helm install openshell oci://ghcr.io/ai-openshell/openshell/helm-chart \ --version 0.0.0-dev \ --namespace openshell --create-namespace \ --set server.disableTls=true \ - --set server.telemetryEnabled=false \ --wait --timeout 5m kubectl wait --namespace openshell \ diff --git a/.github/workflows/branch-checks.yml b/.github/workflows/branch-checks.yml index 7214077893..88e07f3946 100644 --- a/.github/workflows/branch-checks.yml +++ b/.github/workflows/branch-checks.yml @@ -410,8 +410,6 @@ jobs: - name: Test shell: nix develop -c bash -euo pipefail {0} - env: - OPENSHELL_TELEMETRY_ENABLED: "false" run: | cargo nextest run --locked --profile ci --workspace --features openshell-server/test-support cargo nextest run --locked --config-file .config/nextest.toml --profile ci --manifest-path examples/supervisor-middleware-content-guard/Cargo.toml @@ -446,7 +444,6 @@ jobs: shell: nix develop -c bash -euo pipefail {0} env: CONTAINER_ENGINE: docker - OPENSHELL_TELEMETRY_ENABLED: "false" run: tasks/scripts/run-postgres-tests.sh --locked --profile ci rust-build-modes: @@ -479,12 +476,6 @@ jobs: - name: Verify build modes shell: nix develop -c bash -euo pipefail {0} run: | - cargo build --locked -p openshell-gateway --bin openshell-gateway - tasks/scripts/verify-telemetry-compiled-out.sh present target/debug/openshell-gateway - cargo build --locked -p openshell-gateway --bin openshell-gateway --no-default-features --features defaults-without-telemetry - tasks/scripts/verify-telemetry-compiled-out.sh absent target/debug/openshell-gateway - cargo build --locked -p openshell-supervisor --bin openshell-supervisor - tasks/scripts/verify-telemetry-compiled-out.sh absent target/debug/openshell-supervisor cargo check --locked -p openshell-supervisor --all-targets --no-default-features --features system-ca-roots - name: Verify system CA roots dependency boundary @@ -507,29 +498,6 @@ jobs: exit 1 fi - rust-feature-alias: - name: Rust feature alias - runs-on: ubuntu-24.04 - timeout-minutes: 30 - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - uses: ./.github/actions/setup-nix - with: - prepare-shell: "true" - cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }} - - - uses: ./.github/actions/setup-rust - with: - cache-key: rust-checks-v2 - save-cache: "false" - - - name: Verify defaults-without-telemetry feature alias - shell: nix develop -c bash -euo pipefail {0} - run: | - tasks/scripts/verify-defaults-without-telemetry.sh - git diff --exit-code HEAD -- ':(glob)**/Cargo.lock' - rust-gateway-core-features: name: Rust gateway core features runs-on: ubuntu-24.04 diff --git a/.github/workflows/release-canary.yml b/.github/workflows/release-canary.yml index a9c8875fd5..b90a6d763a 100644 --- a/.github/workflows/release-canary.yml +++ b/.github/workflows/release-canary.yml @@ -16,7 +16,6 @@ defaults: env: OPENSHELL_VERSION: dev - OPENSHELL_TELEMETRY_ENABLED: "false" INSTALL_SHA: ${{ github.event.workflow_run.head_sha || github.sha }} jobs: @@ -29,7 +28,6 @@ jobs: - name: Ensure VM driver run: | launchctl setenv OPENSHELL_COMPUTE_DRIVER vm - launchctl setenv OPENSHELL_TELEMETRY_ENABLED "$OPENSHELL_TELEMETRY_ENABLED" - name: Install and check gateway status run: | @@ -78,8 +76,7 @@ jobs: fi sudo systemctl start docker || sudo service docker start mkdir -p "${HOME}/.config/openshell" - printf 'OPENSHELL_COMPUTE_DRIVER=docker\nOPENSHELL_TELEMETRY_ENABLED=%s\n' \ - "$OPENSHELL_TELEMETRY_ENABLED" > "${HOME}/.config/openshell/gateway.env" + printf 'OPENSHELL_COMPUTE_DRIVER=docker\n' > "${HOME}/.config/openshell/gateway.env" docker info - name: Install and check status @@ -171,14 +168,12 @@ jobs: XDG_RUNTIME_DIR=/run/user/0 \ DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/0/bus \ OPENSHELL_VERSION="$OPENSHELL_VERSION" \ - OPENSHELL_TELEMETRY_ENABLED="$OPENSHELL_TELEMETRY_ENABLED" \ CANARY_SANDBOX="rc-${GITHUB_RUN_ID}" \ INSTALL_SH_URL="https://raw.githubusercontent.com/ai-openshell/openshell/${INSTALL_SHA}/install.sh" \ bash -s <<'EOF' set -euo pipefail mkdir -p "${HOME}/.config/openshell" - printf 'OPENSHELL_COMPUTE_DRIVER=podman\nOPENSHELL_TELEMETRY_ENABLED=%s\n' \ - "$OPENSHELL_TELEMETRY_ENABLED" > "${HOME}/.config/openshell/gateway.env" + printf 'OPENSHELL_COMPUTE_DRIVER=podman\n' > "${HOME}/.config/openshell/gateway.env" podman info curl -LsSf "${INSTALL_SH_URL}" | sh openshell status @@ -227,8 +222,6 @@ jobs: other_uid=$(id -u "$other_user") sudo loginctl enable-linger "$other_user" sudo systemctl start "user@${other_uid}.service" - systemctl --user set-environment \ - "OPENSHELL_TELEMETRY_ENABLED=${OPENSHELL_TELEMETRY_ENABLED}" curl -LsSf https://raw.githubusercontent.com/ai-openshell/openshell/${INSTALL_SHA}/install.sh | DOCKER_HOST=unix:///tmp/nonexistent-docker.sock DOCKER_CONTEXT=nonexistent sh sudo snap list openshell @@ -432,7 +425,6 @@ jobs: --namespace "$RELEASE_NAMESPACE" --create-namespace \ --set server.disableTls=true \ --set server.auth.allowUnauthenticatedUsers=true \ - --set "server.telemetryEnabled=${OPENSHELL_TELEMETRY_ENABLED}" \ --wait --timeout 5m - name: Verify gateway pod is Ready diff --git a/Cargo.lock b/Cargo.lock index 017a0c0bed..aec51488aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4498,7 +4498,6 @@ version = "0.0.0" dependencies = [ "async-trait", "base64 0.22.1", - "chrono", "clap", "glob", "h2", diff --git a/README.md b/README.md index 0752ddaf13..a38dda1be3 100644 --- a/README.md +++ b/README.md @@ -87,10 +87,6 @@ SDKs connect applications to an OpenShell gateway. They do not install the CLI. OpenShell is built agent-first: it is developed with the same agent-driven workflows it enables. See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and the contribution workflow, and [AGENTS.md](AGENTS.md) for repository coding conventions. -## Telemetry - -OpenShell collects anonymous telemetry, limited to operational categories and counts, to help improve the project. It does not collect sandbox names, hostnames, file paths, prompts, credentials, provider or model names, or user content. To disable it, set `OPENSHELL_TELEMETRY_ENABLED=false` on the gateway, or `server.telemetryEnabled=false` for Helm installs. You can also compile telemetry out entirely. See [Telemetry](https://docs.nvidia.com/openshell/latest/observability/telemetry) for details and the [community telemetry reports](telemetry/README.md) for published usage trends. - ## Notice and Disclaimer This software automatically retrieves, accesses or interacts with external materials. Those retrieved materials are not distributed with this software and are governed solely by separate terms, conditions and licenses. You are solely responsible for finding, reviewing and complying with all applicable terms, conditions, and licenses, and for verifying the security, integrity and suitability of any retrieved materials for your specific use case. This software is provided "AS IS", without warranty of any kind. The author makes no representations or warranties regarding any retrieved materials, and assumes no liability for any losses, damages, liabilities or legal consequences from your use or inability to use this software or any retrieved materials. Use this software and the retrieved materials at your own risk. diff --git a/crates/openshell-cli/tests/provider_commands_integration.rs b/crates/openshell-cli/tests/provider_commands_integration.rs index f5563a7e77..4bde06b423 100644 --- a/crates/openshell-cli/tests/provider_commands_integration.rs +++ b/crates/openshell-cli/tests/provider_commands_integration.rs @@ -3292,7 +3292,6 @@ async fn profile_commands_dispatch_scope_and_output_to_gateway() { let mut command = tokio::process::Command::new(env!("CARGO_BIN_EXE_openshell")); command .env("XDG_CONFIG_HOME", config.path()) - .env("OPENSHELL_TELEMETRY_ENABLED", "false") .env_remove("OPENSHELL_GATEWAY") .env_remove("COMPLETE") .args([ diff --git a/crates/openshell-cli/tests/ssh_proxy_shutdown_integration.rs b/crates/openshell-cli/tests/ssh_proxy_shutdown_integration.rs index 76f9b32f5e..5429b8d4bb 100644 --- a/crates/openshell-cli/tests/ssh_proxy_shutdown_integration.rs +++ b/crates/openshell-cli/tests/ssh_proxy_shutdown_integration.rs @@ -74,7 +74,6 @@ async fn proxy_exits_with_stdin_open(relay_status: tonic::Status) { "test-token", ]) .env("XDG_CONFIG_HOME", config.path()) - .env("OPENSHELL_TELEMETRY_ENABLED", "false") .stdin(Stdio::piped()) .stdout(Stdio::null()) .stderr(Stdio::piped()) diff --git a/crates/openshell-core/Cargo.toml b/crates/openshell-core/Cargo.toml index 55339e09b5..01566db989 100644 --- a/crates/openshell-core/Cargo.toml +++ b/crates/openshell-core/Cargo.toml @@ -37,8 +37,7 @@ rustls = { workspace = true } base64 = { workspace = true } jsonwebtoken = { workspace = true, optional = true } zeroize = { workspace = true, optional = true } -chrono = { version = "0.4", default-features = false, features = ["clock", "std"], optional = true } -reqwest = { workspace = true, features = ["blocking", "rustls-tls-native-roots-no-provider"], optional = true } +reqwest = { workspace = true, features = ["rustls-tls-native-roots-no-provider"], optional = true } tar = { version = "0.4", optional = true } tempfile = { version = "3", optional = true } openshell-otel = { path = "../openshell-otel", optional = true } @@ -50,12 +49,8 @@ rustix = { workspace = true } libc = "0.2" [features] -default = ["telemetry"] -## Compile in anonymous telemetry emission support. On by default; disable with -## `--no-default-features` (plus any other features you need) for a build that -## contains no telemetry endpoint, no HTTP client, and no emission code at all. +default = [] driver-extraction = ["dep:tar", "dep:tempfile"] -telemetry = ["dep:reqwest", "dep:chrono", "reqwest?/blocking"] ## OAuth2 token request helpers used by supervisor and gateway. oauth = ["dep:reqwest"] ## Strict Ed25519 JWT issuance and verification for authenticated sandbox sessions. diff --git a/crates/openshell-core/src/activity.rs b/crates/openshell-core/src/activity.rs deleted file mode 100644 index 4a51f6947b..0000000000 --- a/crates/openshell-core/src/activity.rs +++ /dev/null @@ -1,50 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -//! Cross-component anonymous network activity event type. -//! -//! `ActivityEvent` is emitted by the supervisor's networking proxy and by -//! the supervisor's bypass monitor on every observed connection attempt -//! (allowed or denied). It is consumed by the orchestrator-side -//! `ActivityAggregator` which counts events, sanitizes deny groups, and -//! periodically flushes anonymous summaries to the gateway. -//! -//! It lives in `openshell-core` because both supervisor leaves -//! (`openshell-supervisor-network` and `openshell-supervisor-process`) -//! produce it and need a shared type without depending on each other. - -use tokio::sync::mpsc; - -/// Channel capacity for the per-sandbox activity event queue. -pub const ACTIVITY_EVENT_QUEUE_CAPACITY: usize = 1024; - -/// A single anonymous network activity event. -#[derive(Debug, Clone)] -pub struct ActivityEvent { - /// Whether the action was denied. - pub denied: bool, - /// The deny group label (e.g. `connect_policy`, `l7_policy`, `bypass`). - /// Static so producers cannot leak per-request data into the channel. - pub deny_group: &'static str, -} - -/// Shorthand for the producer side of the activity channel. -pub type ActivitySender = mpsc::Sender; - -/// Non-blocking emit. Drops the event if the queue is full. -/// Returns whether the event was enqueued. -pub fn try_record_activity(tx: &ActivitySender, denied: bool, deny_group: &'static str) -> bool { - tx.try_send(ActivityEvent { denied, deny_group }).is_ok() -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn activity_send_drops_when_queue_is_full() { - let (tx, _rx) = mpsc::channel(1); - assert!(try_record_activity(&tx, false, "unknown")); - assert!(!try_record_activity(&tx, true, "connect_policy")); - } -} diff --git a/crates/openshell-core/src/grpc_client.rs b/crates/openshell-core/src/grpc_client.rs index acc3e9a10a..e0dc6a2c68 100644 --- a/crates/openshell-core/src/grpc_client.rs +++ b/crates/openshell-core/src/grpc_client.rs @@ -29,11 +29,10 @@ use crate::proto::{ DenialSummary, EndpointObservation as ProtoEndpointObservation, EndpointResult as ProtoEndpointResult, ExchangeProviderSubjectTokenRequest, GetDraftPolicyRequest, GetSandboxConfigRequest, GetSandboxProviderEnvironmentRequest, - GetSandboxProviderEnvironmentResponse, IssueSandboxTokenRequest, NetworkActivitySummary, - PolicyChunk, PolicySource, PolicyStatus, RefreshSandboxTokenRequest, - ReportEndpointStatusRequest, ReportPolicyStatusRequest, SandboxPolicy as ProtoSandboxPolicy, - SubmitPolicyAnalysisRequest, SubmitPolicyAnalysisResponse, UpdateConfigRequest, - open_shell_client::OpenShellClient, + GetSandboxProviderEnvironmentResponse, IssueSandboxTokenRequest, PolicyChunk, PolicySource, + PolicyStatus, RefreshSandboxTokenRequest, ReportEndpointStatusRequest, + ReportPolicyStatusRequest, SandboxPolicy as ProtoSandboxPolicy, SubmitPolicyAnalysisRequest, + SubmitPolicyAnalysisResponse, UpdateConfigRequest, open_shell_client::OpenShellClient, }; use crate::sandbox_env; use crate::time::{duration_to_std, timestamp_to_millis}; @@ -2472,7 +2471,6 @@ impl CachedOpenShellClient { sandbox_name: &str, summaries: Vec, proposed_chunks: Vec, - network_activity_summaries: Vec, analysis_mode: &str, ) -> Result { let response = self @@ -2482,7 +2480,6 @@ impl CachedOpenShellClient { name: sandbox_name.to_string(), summaries, proposed_chunks, - network_activity_summaries, analysis_mode: analysis_mode.to_string(), workspace_scope: Some(crate::proto::workspace_selector(self.workspace())), }) diff --git a/crates/openshell-core/src/lib.rs b/crates/openshell-core/src/lib.rs index 6e97f2dd1f..7caf0d7bf4 100644 --- a/crates/openshell-core/src/lib.rs +++ b/crates/openshell-core/src/lib.rs @@ -9,7 +9,6 @@ //! - Common error types //! - Build version metadata -pub mod activity; pub mod app_listener; pub mod auth; pub mod color; @@ -65,7 +64,6 @@ pub mod sandbox_update; pub mod secrets; pub mod settings; pub mod shell; -pub mod telemetry; pub mod time; pub mod token_endpoint; pub mod token_grant_failure; diff --git a/crates/openshell-core/src/telemetry.rs b/crates/openshell-core/src/telemetry.rs deleted file mode 100644 index 7de98b22b7..0000000000 --- a/crates/openshell-core/src/telemetry.rs +++ /dev/null @@ -1,754 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -//! Best-effort anonymous telemetry emission helpers. - -#[cfg(feature = "telemetry")] -use chrono::{SecondsFormat, Utc}; -#[cfg(feature = "telemetry")] -use reqwest::blocking::Client; -use serde_json::{Value, json}; -use std::collections::BTreeMap; -#[cfg(feature = "telemetry")] -use std::sync::{OnceLock, mpsc}; -#[cfg(feature = "telemetry")] -use std::thread; -#[cfg(feature = "telemetry")] -use std::time::Duration; - -const MAX_TELEMETRY_INTEGER: u64 = 9_223_372_036_854_775_807; -const SOURCE: TelemetrySource = TelemetrySource::OpenShell; - -#[cfg(feature = "telemetry")] -const TELEMETRY_EVENT_QUEUE_CAPACITY: usize = 1024; -#[cfg(feature = "telemetry")] -const CLIENT_ID: &str = "415437562476676"; -#[cfg(feature = "telemetry")] -const DEFAULT_ENDPOINT: &str = "https://events.telemetry.data.nvidia.com/v1.1/events/json"; -#[cfg(feature = "telemetry")] -const EVENT_SCHEMA_VERSION: &str = "4.0"; -#[cfg(feature = "telemetry")] -const EVENT_PROTOCOL_VERSION: &str = "1.6"; -#[cfg(feature = "telemetry")] -const EVENT_SYSTEM_VERSION: &str = "openshell-telemetry/1.0"; -#[cfg(feature = "telemetry")] -const HTTP_TIMEOUT: Duration = Duration::from_secs(5); -#[cfg(feature = "telemetry")] -static TELEMETRY_SENDER: OnceLock>> = OnceLock::new(); - -#[cfg(feature = "telemetry")] -#[derive(Debug)] -struct TelemetryEvent { - endpoint: String, - name: &'static str, - event_ts: String, - event: Value, -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -enum TelemetrySource { - OpenShell, -} - -impl TelemetrySource { - const fn as_str(self) -> &'static str { - match self { - Self::OpenShell => "openshell", - } - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum TelemetryOutcome { - Success, - Failure, -} - -impl TelemetryOutcome { - #[must_use] - pub const fn as_str(self) -> &'static str { - match self { - Self::Success => "success", - Self::Failure => "failure", - } - } - - #[must_use] - pub const fn from_success(success: bool) -> Self { - if success { - Self::Success - } else { - Self::Failure - } - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum LifecycleResource { - Sandbox, - SandboxPolicy, -} - -impl LifecycleResource { - #[must_use] - pub const fn as_str(self) -> &'static str { - match self { - Self::Sandbox => "sandbox", - Self::SandboxPolicy => "sandbox_policy", - } - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum LifecycleOperation { - Create, - Delete, - Stop, - Start, - Suspend, - Resume, - Update, -} - -impl LifecycleOperation { - #[must_use] - pub const fn as_str(self) -> &'static str { - match self { - Self::Create => "create", - Self::Delete => "delete", - Self::Stop => "stop", - Self::Start => "start", - Self::Suspend => "suspend", - Self::Resume => "resume", - Self::Update => "update", - } - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum PolicyDecisionOperation { - Approve, - Reject, - Undo, - ApproveAll, -} - -impl PolicyDecisionOperation { - #[must_use] - pub const fn as_str(self) -> &'static str { - match self { - Self::Approve => "approve", - Self::Reject => "reject", - Self::Undo => "undo", - Self::ApproveAll => "approve_all", - } - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum SandboxTemplateSource { - Default, - Image, - WorkloadTemplate, - Undefined, -} - -impl SandboxTemplateSource { - #[must_use] - pub const fn as_str(self) -> &'static str { - match self { - Self::Default => "default", - Self::Image => "image", - Self::WorkloadTemplate => "workload_template", - Self::Undefined => "undefined", - } - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct TelemetryComputeDriver(&'static str); - -impl TelemetryComputeDriver { - #[must_use] - pub const fn as_str(self) -> &'static str { - self.0 - } - - /// Classify an unregistered compute driver without exposing its configured - /// name. - #[must_use] - pub const fn custom() -> Self { - Self("custom") - } - - /// Define a bounded, anonymous category at a binary composition boundary. - /// - /// The category must be a static operational label. Never construct it - /// from user input, configuration, resource names, or other runtime data. - #[must_use] - pub const fn anonymous_category(category: &'static str) -> Self { - Self(category) - } -} - -impl Default for TelemetryComputeDriver { - fn default() -> Self { - Self::custom() - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum ProviderProfile { - Anthropic, - Claude, - Codex, - Copilot, - Deepinfra, - Github, - Gitlab, - Nvidia, - Openai, - Opencode, - Outlook, - Custom, -} - -impl ProviderProfile { - #[must_use] - pub const fn as_str(self) -> &'static str { - match self { - Self::Anthropic => "anthropic", - Self::Claude => "claude", - Self::Codex => "codex", - Self::Copilot => "copilot", - Self::Deepinfra => "deepinfra", - Self::Github => "github", - Self::Gitlab => "gitlab", - Self::Nvidia => "nvidia", - Self::Openai => "openai", - Self::Opencode => "opencode", - Self::Outlook => "outlook", - Self::Custom => "custom", - } - } - - #[must_use] - pub fn from_raw(raw: &str) -> Self { - match raw.trim().to_ascii_lowercase().as_str() { - "anthropic" => Self::Anthropic, - "claude" | "claude-code" => Self::Claude, - "codex" => Self::Codex, - "copilot" => Self::Copilot, - "deepinfra" => Self::Deepinfra, - "github" | "gh" => Self::Github, - "gitlab" | "glab" => Self::Gitlab, - "nvidia" => Self::Nvidia, - "openai" => Self::Openai, - "opencode" => Self::Opencode, - "outlook" => Self::Outlook, - _ => Self::Custom, - } - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum DenyGroup { - Bypass, - ConnectPolicy, - ForwardPolicy, - L7ParseRejection, - L7Policy, - PolicyStale, - Ssrf, - Unknown, -} - -impl DenyGroup { - #[must_use] - pub const fn as_str(self) -> &'static str { - match self { - Self::Bypass => "bypass", - Self::ConnectPolicy => "connect_policy", - Self::ForwardPolicy => "forward_policy", - Self::L7ParseRejection => "l7_parse_rejection", - Self::L7Policy => "l7_policy", - Self::PolicyStale => "policy_stale", - Self::Ssrf => "ssrf", - Self::Unknown => "unknown", - } - } - - #[must_use] - pub fn from_raw(raw: &str) -> Self { - match raw { - "connect_policy" | "connect" | "l4_deny" => Self::ConnectPolicy, - "forward_policy" | "forward" => Self::ForwardPolicy, - "l7_policy" | "l7" | "l7_deny" | "forward-l7-deny" => Self::L7Policy, - "l7_parse_rejection" | "parse_rejection" => Self::L7ParseRejection, - "ssrf" => Self::Ssrf, - "bypass" => Self::Bypass, - "policy_stale" => Self::PolicyStale, - _ => Self::Unknown, - } - } -} - -#[cfg(feature = "telemetry")] -pub fn enabled() -> bool { - telemetry_enabled_from(std::env::var("OPENSHELL_TELEMETRY_ENABLED").ok().as_deref()) -} - -/// Telemetry support is compiled out: always disabled. -#[cfg(not(feature = "telemetry"))] -pub fn enabled() -> bool { - false -} - -#[cfg(feature = "telemetry")] -fn telemetry_enabled_from(value: Option<&str>) -> bool { - let value = value.unwrap_or("true"); - !matches!( - value.trim().to_ascii_lowercase().as_str(), - "0" | "false" | "no" | "off" - ) -} - -#[cfg(feature = "telemetry")] -fn telemetry_endpoint() -> Option { - telemetry_endpoint_from( - std::env::var("OPENSHELL_TELEMETRY_ENDPOINT") - .ok() - .as_deref(), - ) -} - -#[cfg(feature = "telemetry")] -fn telemetry_endpoint_from(endpoint: Option<&str>) -> Option { - let endpoint = endpoint.unwrap_or(DEFAULT_ENDPOINT); - let endpoint = endpoint.trim(); - if endpoint.is_empty() { - None - } else { - Some(endpoint.to_string()) - } -} - -#[cfg(feature = "telemetry")] -fn timestamp() -> String { - Utc::now().to_rfc3339_opts(SecondsFormat::Millis, true) -} - -#[cfg(feature = "telemetry")] -fn client_version() -> &'static str { - crate::VERSION -} - -#[cfg(feature = "telemetry")] -fn build_payload(name: &str, event: Value, event_ts: &str, sent_ts: &str) -> Value { - json!({ - "browserType": "undefined", - "clientId": CLIENT_ID, - "clientType": "Native", - "clientVariant": "Release", - "clientVer": client_version(), - "cpuArchitecture": std::env::consts::ARCH, - "deviceGdprBehOptIn": "None", - "deviceGdprFuncOptIn": "None", - "deviceGdprTechOptIn": "None", - "deviceId": "undefined", - "deviceMake": "undefined", - "deviceModel": "undefined", - "deviceOS": "undefined", - "deviceOSVersion": "undefined", - "deviceType": "undefined", - "eventProtocol": EVENT_PROTOCOL_VERSION, - "eventSchemaVer": EVENT_SCHEMA_VERSION, - "eventSysVer": EVENT_SYSTEM_VERSION, - "externalUserId": "undefined", - "gdprBehOptIn": "None", - "gdprFuncOptIn": "None", - "gdprTechOptIn": "None", - "idpId": "undefined", - "integrationId": "undefined", - "productName": "undefined", - "productVersion": "undefined", - "sentTs": sent_ts, - "sessionId": "undefined", - "userId": "undefined", - "events": [ - { - "ts": event_ts, - "parameters": event, - "name": name, - } - ], - }) -} - -#[cfg(feature = "telemetry")] -fn telemetry_sender() -> Option<&'static mpsc::SyncSender> { - TELEMETRY_SENDER - .get_or_init(|| { - let (tx, rx) = mpsc::sync_channel(TELEMETRY_EVENT_QUEUE_CAPACITY); - thread::Builder::new() - .name("openshell-telemetry".to_string()) - .spawn(move || telemetry_worker(rx)) - .ok() - .map(|_| tx) - }) - .as_ref() -} - -#[cfg(feature = "telemetry")] -fn telemetry_worker(rx: mpsc::Receiver) { - for event in rx { - let payload = build_payload(event.name, event.event, &event.event_ts, ×tamp()); - let _ = publish_payload(&event.endpoint, payload); - } -} - -#[cfg(feature = "telemetry")] -fn publish_payload(endpoint: &str, payload: Value) -> Result<(), reqwest::Error> { - openshell_crypto::tls::ensure_default_provider(); - Client::builder() - .use_rustls_tls() - .tls_built_in_root_certs(true) - .timeout(HTTP_TIMEOUT) - .build()? - .post(endpoint) - .json(&payload) - .send()? - .error_for_status()?; - Ok(()) -} - -#[cfg(feature = "telemetry")] -fn try_enqueue_event(sender: &mpsc::SyncSender, event: TelemetryEvent) -> bool { - sender.try_send(event).is_ok() -} - -#[cfg(feature = "telemetry")] -fn emit_event(name: &'static str, event: Value) { - if !enabled() { - return; - } - let Some(endpoint) = telemetry_endpoint() else { - return; - }; - let Some(sender) = telemetry_sender() else { - return; - }; - - let _ = try_enqueue_event( - sender, - TelemetryEvent { - endpoint, - name, - event_ts: timestamp(), - event, - }, - ); -} - -/// Telemetry support is compiled out: emission is a no-op. -#[cfg(not(feature = "telemetry"))] -fn emit_event(_name: &'static str, _event: Value) {} - -pub fn emit_lifecycle( - resource: LifecycleResource, - operation: LifecycleOperation, - outcome: TelemetryOutcome, -) { - emit_event( - "openshell_lifecycle_event", - json!({ - "nvidiaSource": SOURCE.as_str(), - "resource": resource.as_str(), - "operation": operation.as_str(), - "outcome": outcome.as_str(), - }), - ); -} - -pub fn emit_provider_lifecycle( - operation: LifecycleOperation, - outcome: TelemetryOutcome, - provider_profile: ProviderProfile, -) { - emit_event( - "openshell_provider_lifecycle_event", - json!({ - "nvidiaSource": SOURCE.as_str(), - "operation": operation.as_str(), - "outcome": outcome.as_str(), - "providerProfile": provider_profile.as_str(), - }), - ); -} - -pub fn emit_sandbox_create( - outcome: TelemetryOutcome, - requested_gpu: bool, - provider_count: u64, - has_custom_policy: bool, - template_source: SandboxTemplateSource, - compute_driver: TelemetryComputeDriver, -) { - if !valid_count(provider_count) { - return; - } - emit_event( - "openshell_sandbox_create_event", - json!({ - "nvidiaSource": SOURCE.as_str(), - "outcome": outcome.as_str(), - "requestedGpu": requested_gpu, - "providerCount": provider_count, - "hasCustomPolicy": has_custom_policy, - "templateSource": template_source.as_str(), - "computeDriver": compute_driver.as_str(), - }), - ); -} - -pub fn emit_policy_decision( - operation: PolicyDecisionOperation, - outcome: TelemetryOutcome, - rule_count: u64, -) { - if !valid_count(rule_count) { - return; - } - emit_event( - "openshell_policy_decision_event", - json!({ - "nvidiaSource": SOURCE.as_str(), - "operation": operation.as_str(), - "outcome": outcome.as_str(), - "ruleCount": rule_count, - }), - ); -} - -pub fn emit_sandbox_activity_summary( - network_activity_count: u64, - denied_action_count: u64, - denial_rate_pct: f64, - denials_by_group: I, -) where - I: IntoIterator, -{ - if !valid_count(network_activity_count) - || !valid_count(denied_action_count) - || !denial_rate_pct.is_finite() - || !(0.0..=100.0).contains(&denial_rate_pct) - { - return; - } - let Some(denials_by_group) = sanitize_denials_by_group(denials_by_group) else { - return; - }; - let rows: Vec = denials_by_group - .into_iter() - .map(|(group, count)| json!({ "denyGroup": group.as_str(), "deniedCount": count })) - .collect(); - emit_event( - "openshell_sandbox_activity_summary_event", - json!({ - "nvidiaSource": SOURCE.as_str(), - "networkActivityCount": network_activity_count, - "deniedActionCount": denied_action_count, - "denialRatePct": denial_rate_pct, - "denialsByGroup": rows, - }), - ); -} - -fn valid_count(value: u64) -> bool { - value <= MAX_TELEMETRY_INTEGER -} - -fn sanitize_denials_by_group(denials_by_group: I) -> Option> -where - I: IntoIterator, -{ - let mut sanitized = BTreeMap::::new(); - for (group, count) in denials_by_group { - if !valid_count(count) { - return None; - } - let next_count = sanitized - .get(&group) - .copied() - .unwrap_or(0) - .checked_add(count)?; - if !valid_count(next_count) { - return None; - } - sanitized.insert(group, next_count); - } - Some(sanitized) -} - -#[cfg(all(test, feature = "telemetry"))] -mod tests { - use super::*; - - #[test] - fn telemetry_enabled_defaults_true() { - assert!(telemetry_enabled_from(None)); - } - - #[test] - fn telemetry_enabled_honors_false_values() { - assert!(!telemetry_enabled_from(Some("off"))); - assert!(!telemetry_enabled_from(Some("false"))); - assert!(telemetry_enabled_from(Some("yes"))); - } - - #[test] - fn telemetry_endpoint_empty_disables_publish() { - assert_eq!(telemetry_endpoint_from(Some(" ")), None); - assert_eq!( - telemetry_endpoint_from(None), - Some(DEFAULT_ENDPOINT.to_string()) - ); - } - - #[test] - fn build_payload_matches_schema_metadata() { - let payload = build_payload( - "openshell_sandbox_create_event", - json!({ - "nvidiaSource": SOURCE.as_str(), - "outcome": "success", - "requestedGpu": false, - "providerCount": 1, - "hasCustomPolicy": true, - "templateSource": "default", - "computeDriver": "docker", - }), - "2026-05-18T00:00:00.000Z", - "2026-05-18T00:00:01.000Z", - ); - - assert_eq!(payload["clientId"], CLIENT_ID); - assert_eq!(payload["clientVer"], crate::VERSION); - assert_eq!(payload["eventSchemaVer"], EVENT_SCHEMA_VERSION); - assert_eq!(payload["deviceId"], "undefined"); - assert_eq!(payload["userId"], "undefined"); - assert_eq!( - payload["events"][0]["name"], - "openshell_sandbox_create_event" - ); - assert_eq!( - payload["events"][0]["parameters"]["nvidiaSource"], - SOURCE.as_str() - ); - assert_eq!(payload["events"][0]["ts"], "2026-05-18T00:00:00.000Z"); - assert_eq!(payload["sentTs"], "2026-05-18T00:00:01.000Z"); - } - - #[test] - fn compute_driver_values_are_bounded_by_the_composition_boundary() { - assert_eq!(TelemetryComputeDriver::custom().as_str(), "custom"); - assert_eq!( - TelemetryComputeDriver::anonymous_category("first_party").as_str(), - "first_party" - ); - } - - #[test] - fn telemetry_enqueue_drops_when_queue_is_full() { - let (tx, _rx) = mpsc::sync_channel(1); - let event = || TelemetryEvent { - endpoint: "https://example.test/events".to_string(), - name: "openshell_lifecycle_event", - event_ts: "2026-05-18T00:00:00.000Z".to_string(), - event: json!({ - "nvidiaSource": SOURCE.as_str(), - "resource": "sandbox", - "operation": "create", - "outcome": "success", - }), - }; - - assert!(try_enqueue_event(&tx, event())); - assert!(!try_enqueue_event(&tx, event())); - } - - #[test] - fn telemetry_validation_maps_privacy_sensitive_strings_to_safe_buckets() { - assert_eq!( - ProviderProfile::from_raw("corp-llm-prod"), - ProviderProfile::Custom - ); - assert_eq!( - DenyGroup::from_raw("host=private.example"), - DenyGroup::Unknown - ); - } - - #[test] - fn telemetry_enums_serialize_to_expected_strings() { - assert_eq!(LifecycleResource::SandboxPolicy.as_str(), "sandbox_policy"); - assert_eq!(LifecycleOperation::Delete.as_str(), "delete"); - assert_eq!(PolicyDecisionOperation::ApproveAll.as_str(), "approve_all"); - assert_eq!(TelemetryOutcome::Failure.as_str(), "failure"); - assert_eq!(SandboxTemplateSource::Undefined.as_str(), "undefined"); - assert!(!valid_count(MAX_TELEMETRY_INTEGER + 1)); - } - - #[test] - fn activity_groups_are_sanitized_and_aggregated() { - let rows = sanitize_denials_by_group([ - (DenyGroup::from_raw("connect"), 1), - (DenyGroup::from_raw("connect_policy"), 2), - (DenyGroup::from_raw("host=private.example"), 3), - ]) - .expect("rows should sanitize"); - - assert_eq!(rows.get(&DenyGroup::ConnectPolicy), Some(&3)); - assert_eq!(rows.get(&DenyGroup::Unknown), Some(&3)); - } -} - -#[cfg(all(test, not(feature = "telemetry")))] -mod disabled_tests { - use super::*; - - #[test] - fn telemetry_reports_disabled_when_compiled_out() { - assert!(!enabled()); - } - - #[test] - fn emit_functions_are_no_ops_when_compiled_out() { - // These must remain callable so dependent crates compile unchanged; - // with telemetry compiled out they do nothing and never panic. - emit_lifecycle( - LifecycleResource::Sandbox, - LifecycleOperation::Create, - TelemetryOutcome::Success, - ); - emit_provider_lifecycle( - LifecycleOperation::Create, - TelemetryOutcome::Success, - ProviderProfile::Custom, - ); - emit_sandbox_create( - TelemetryOutcome::Success, - false, - 1, - false, - SandboxTemplateSource::Default, - TelemetryComputeDriver::custom(), - ); - emit_policy_decision( - PolicyDecisionOperation::Approve, - TelemetryOutcome::Success, - 1, - ); - emit_sandbox_activity_summary(0, 0, 0.0, [(DenyGroup::ConnectPolicy, 0)]); - } -} diff --git a/crates/openshell-crypto/README.md b/crates/openshell-crypto/README.md index a975391bfc..4a7b6e2124 100644 --- a/crates/openshell-crypto/README.md +++ b/crates/openshell-crypto/README.md @@ -241,7 +241,7 @@ not a whole-application crypto coverage claim: | Remaining use | Current scope and follow-up | | --- | --- | -| Reqwest clients (OIDC/JWKS, token exchange, provider refresh, Vault, token grants, telemetry) | These use Rustls's process-default provider after ensuring one exists; they do not necessarily honor an explicitly selected `CryptoContext`. The OpenSSL follow-up must supply compatible preconfigured TLS or another supported transport integration and test actual provider use. | +| Reqwest clients (OIDC/JWKS, token exchange, provider refresh, Vault, token grants) | These use Rustls's process-default provider after ensuring one exists; they do not necessarily honor an explicitly selected `CryptoContext`. The OpenSSL follow-up must supply compatible preconfigured TLS or another supported transport integration and test actual provider use. | | OTLP gRPC export TLS (`openshell-otel`, the supervisor's agent trace relay) | Tonic's `ClientTlsConfig` verifies collectors and signs for client certificates with Rustls's process-default provider, as other first-party tonic clients do. OTLP/HTTP export builds its configuration through `openshell_crypto::tls::try_client_builder`. The OpenSSL follow-up must move the gRPC path to a preconfigured connector before claiming selected-backend coverage. | | Kubernetes client TLS (`kube-client` 0.99) | The AWS-LC-enabled client attempts to install AWS-LC as the Rustls process default. It does not consult `CryptoContext`; the OpenSSL follow-up must adapt this transport before claiming selected-backend coverage. | | Outer-fence evidence digest (`openshell-isolation-interface::contract`) | The digest binds generation and native enforcement evidence using `sha2` through `Sha256Digest::compute`. This security-relevant hash remains outside facade dispatch and must be migrated with failure propagation before claiming exclusive backend ownership. | diff --git a/crates/openshell-driver-mxc/src/driver.rs b/crates/openshell-driver-mxc/src/driver.rs index 2772f1a69c..817e84b576 100644 --- a/crates/openshell-driver-mxc/src/driver.rs +++ b/crates/openshell-driver-mxc/src/driver.rs @@ -874,7 +874,6 @@ async fn run_lifecycle( provider_credentials: None, agent_proposals: openshell_core::proposals::AgentProposals::default(), denial_tx: None, - activity_tx: None, }, ) .await diff --git a/crates/openshell-gateway/Cargo.toml b/crates/openshell-gateway/Cargo.toml index 86249568ba..7b35132282 100644 --- a/crates/openshell-gateway/Cargo.toml +++ b/crates/openshell-gateway/Cargo.toml @@ -40,7 +40,7 @@ tracing = { workspace = true, optional = true } openshell-driver-mxc = { path = "../openshell-driver-mxc", optional = true } [features] -default = ["telemetry", "in-tree-compute-drivers"] +default = ["in-tree-compute-drivers"] in-tree-compute-drivers = [ "compute-driver-docker", "compute-driver-kubernetes", @@ -63,15 +63,9 @@ compute-driver-vm = [ "dep:tower", "dep:tracing", ] -telemetry = ["openshell-core/telemetry", "openshell-server/telemetry"] -## Convenience alias: every default feature except `telemetry`. Build a -## telemetry-free gateway with -## `--no-default-features --features defaults-without-telemetry` and stay -## correct as new default features are added. Cargo cannot subtract a single -## default feature, so this alias must be paired with `--no-default-features`; -## enabling it alongside `telemetry` is a compile error rather than a silent -## telemetry-on build. Kept in sync with `default` by -## `rust:verify:defaults-without-telemetry`. +## Deprecated no-ops: this crate contains no anonymous usage telemetry. Kept +## so builds that still pass these features keep working. +telemetry = [] defaults-without-telemetry = ["in-tree-compute-drivers"] vendored-z3 = ["openshell-server/vendored-z3"] diff --git a/crates/openshell-gateway/src/lib.rs b/crates/openshell-gateway/src/lib.rs index 2e75ec61f6..b0a0a903fc 100644 --- a/crates/openshell-gateway/src/lib.rs +++ b/crates/openshell-gateway/src/lib.rs @@ -6,32 +6,9 @@ //! The server remains backend-agnostic. This crate is the composition boundary //! that links first-party compute drivers into the distributed gateway binary. -// `defaults-without-telemetry` is an alias for the default feature set minus -// `telemetry`, not a switch that turns telemetry off. Cargo cannot subtract a -// default feature, so adding it on top of the defaults would otherwise produce -// a telemetry-on build that reads as telemetry-free. Fail the build instead. -#[cfg(all(feature = "telemetry", feature = "defaults-without-telemetry"))] -compile_error!( - "features `telemetry` and `defaults-without-telemetry` are mutually exclusive; \ - build a telemetry-free gateway with `--no-default-features --features defaults-without-telemetry`" -); - #[cfg(all(not(target_os = "windows"), feature = "compute-driver-vm"))] mod vm; -#[cfg(any( - all(target_os = "windows", feature = "compute-driver-mxc"), - all( - not(target_os = "windows"), - any( - feature = "compute-driver-docker", - feature = "compute-driver-kubernetes", - feature = "compute-driver-podman", - feature = "compute-driver-vm" - ) - ) -))] -use openshell_core::telemetry::TelemetryComputeDriver; #[cfg(any( target_os = "windows", feature = "compute-driver-docker", @@ -72,8 +49,7 @@ pub fn install_default_compute_drivers() -> ComputeDriverRegistry { #[cfg(all(target_os = "windows", feature = "compute-driver-mxc"))] fn install_mxc_compute_driver(registry: &mut ComputeDriverRegistry) { let registration = ComputeDriverRegistration::new("mxc", u16::MAX, None, MxcFactory) - .expect("first-party driver name is valid") - .with_telemetry_category(TelemetryComputeDriver::anonymous_category("mxc")); + .expect("first-party driver name is valid"); registry .install(registration) .expect("first-party driver names are unique"); @@ -189,9 +165,7 @@ fn install_in_tree_compute_drivers(registry: &mut ComputeDriverRegistry) { KubernetesFactory, ) .map(|registration| { - registration - .with_telemetry_category(TelemetryComputeDriver::anonymous_category("kubernetes")) - .with_in_process_tracing(openshell_driver_kubernetes::otel_tracing::TRACING) + registration.with_in_process_tracing(openshell_driver_kubernetes::otel_tracing::TRACING) }), #[cfg(feature = "compute-driver-podman")] ComputeDriverRegistration::new( @@ -201,9 +175,7 @@ fn install_in_tree_compute_drivers(registry: &mut ComputeDriverRegistry) { PodmanFactory, ) .map(|registration| { - registration - .with_telemetry_category(TelemetryComputeDriver::anonymous_category("podman")) - .with_in_process_tracing(openshell_driver_podman::otel_tracing::TRACING) + registration.with_in_process_tracing(openshell_driver_podman::otel_tracing::TRACING) }), #[cfg(feature = "compute-driver-docker")] ComputeDriverRegistration::new( @@ -213,14 +185,10 @@ fn install_in_tree_compute_drivers(registry: &mut ComputeDriverRegistry) { DockerFactory, ) .map(|registration| { - registration - .with_telemetry_category(TelemetryComputeDriver::anonymous_category("docker")) - .with_in_process_tracing(openshell_driver_docker::otel_tracing::TRACING) + registration.with_in_process_tracing(openshell_driver_docker::otel_tracing::TRACING) }), #[cfg(feature = "compute-driver-vm")] - ComputeDriverRegistration::new("vm", u16::MAX, None, VmFactory).map(|registration| { - registration.with_telemetry_category(TelemetryComputeDriver::anonymous_category("vm")) - }), + ComputeDriverRegistration::new("vm", u16::MAX, None, VmFactory), ]; for registration in registrations { registry diff --git a/crates/openshell-sandbox/src/activity_aggregator.rs b/crates/openshell-sandbox/src/activity_aggregator.rs deleted file mode 100644 index 8bd2ffdb62..0000000000 --- a/crates/openshell-sandbox/src/activity_aggregator.rs +++ /dev/null @@ -1,224 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -//! Anonymous sandbox network activity counter aggregation. -//! -//! Producer-side types (`ActivityEvent`, `ActivitySender`, -//! `ACTIVITY_EVENT_QUEUE_CAPACITY`, `try_record_activity`) live in -//! `openshell_core::activity` so the supervisor leaves can emit without -//! depending on the orchestrator. This module hosts the aggregator that -//! runs orchestrator-side and flushes summaries to the gateway. - -use std::collections::HashMap; -use std::future::Future; -use tokio::sync::mpsc; -use tracing::{debug, warn}; - -pub use openshell_core::activity::ActivityEvent; - -const ACTIVITY_FLUSH_QUEUE_CAPACITY: usize = 1; -pub const DEFAULT_ACTIVITY_FLUSH_INTERVAL_SECS: u64 = 10; - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct FlushableActivitySummary { - pub network_activity_count: u32, - pub denied_action_count: u32, - pub denials_by_group: Vec<(String, u32)>, -} - -pub struct ActivityAggregator { - rx: mpsc::Receiver, - network_activity_count: u32, - denied_action_count: u32, - denials_by_group: HashMap, - flush_interval_secs: u64, -} - -impl ActivityAggregator { - pub fn new(rx: mpsc::Receiver, flush_interval_secs: u64) -> Self { - Self { - rx, - network_activity_count: 0, - denied_action_count: 0, - denials_by_group: HashMap::new(), - flush_interval_secs, - } - } - - /// `ready_gate` is checked before each flush. When it returns `false`, - /// the drain is skipped and events stay in the buffer until the next tick. - pub async fn run(mut self, flush_callback: F, ready_gate: G) - where - F: Fn(FlushableActivitySummary) -> Fut + Send + 'static, - Fut: Future + Send + 'static, - G: Fn() -> bool, - { - let (flush_tx, mut flush_rx) = - mpsc::channel::(ACTIVITY_FLUSH_QUEUE_CAPACITY); - tokio::spawn(async move { - while let Some(summary) = flush_rx.recv().await { - flush_callback(summary).await; - } - }); - - let mut flush_interval = - tokio::time::interval(std::time::Duration::from_secs(self.flush_interval_secs)); - flush_interval.tick().await; - - loop { - tokio::select! { - event = self.rx.recv() => { - if let Some(event) = event { - self.ingest(event); - } else { - if self.network_activity_count > 0 { - if ready_gate() { - if let Some(summary) = self.drain() { - queue_flush_summary(&flush_tx, summary); - } - } else { - warn!( - count = self.network_activity_count, - "ActivityAggregator: dropping unflushed events, workspace not yet known" - ); - } - } - debug!("ActivityAggregator: channel closed, exiting"); - return; - } - } - _ = flush_interval.tick() => { - if ready_gate() - && let Some(summary) = self.drain() - { - debug!( - count = summary.network_activity_count, - denied = summary.denied_action_count, - "ActivityAggregator: flushing anonymous activity summary" - ); - queue_flush_summary(&flush_tx, summary); - } - } - } - } - } - - fn ingest(&mut self, event: ActivityEvent) { - self.network_activity_count = self.network_activity_count.saturating_add(1); - if event.denied { - self.denied_action_count = self.denied_action_count.saturating_add(1); - let group = sanitize_deny_group(event.deny_group).to_string(); - let count = self.denials_by_group.entry(group).or_default(); - *count = count.saturating_add(1); - } - } - - fn drain(&mut self) -> Option { - if self.network_activity_count == 0 { - return None; - } - let mut denials_by_group: Vec<(String, u32)> = self.denials_by_group.drain().collect(); - denials_by_group.sort_by(|left, right| left.0.cmp(&right.0)); - let summary = FlushableActivitySummary { - network_activity_count: self.network_activity_count, - denied_action_count: self.denied_action_count, - denials_by_group, - }; - self.network_activity_count = 0; - self.denied_action_count = 0; - Some(summary) - } -} - -pub fn activity_flush_interval_secs_from_env(value: Option<&str>) -> u64 { - value - .and_then(|value| value.parse::().ok()) - .filter(|value| *value > 0) - .unwrap_or(DEFAULT_ACTIVITY_FLUSH_INTERVAL_SECS) -} - -fn queue_flush_summary( - tx: &mpsc::Sender, - summary: FlushableActivitySummary, -) -> bool { - tx.try_send(summary).is_ok() -} - -pub fn sanitize_deny_group(raw: &str) -> &'static str { - match raw { - "connect_policy" | "connect" | "l4_deny" => "connect_policy", - "forward_policy" | "forward" => "forward_policy", - "l7_policy" | "l7" | "l7_deny" | "forward-l7-deny" => "l7_policy", - "l7_parse_rejection" | "parse_rejection" => "l7_parse_rejection", - "ssrf" => "ssrf", - "bypass" => "bypass", - "policy_stale" => "policy_stale", - _ => "unknown", - } -} - -#[cfg(test)] -fn denial_rate_pct(network_activity_count: u32, denied_action_count: u32) -> f64 { - if network_activity_count == 0 { - return 0.0; - } - ((f64::from(denied_action_count) / f64::from(network_activity_count)) * 100.0).clamp(0.0, 100.0) -} - -#[cfg(test)] -mod tests { - use super::*; - - fn assert_float_eq(actual: f64, expected: f64) { - assert!((actual - expected).abs() <= f64::EPSILON); - } - - #[test] - fn deny_group_sanitization_uses_allowlist() { - assert_eq!(sanitize_deny_group("connect"), "connect_policy"); - assert_eq!(sanitize_deny_group("forward-l7-deny"), "l7_policy"); - assert_eq!(sanitize_deny_group("host=example.test/path"), "unknown"); - assert_eq!(sanitize_deny_group("acme.internal:443"), "unknown"); - assert_eq!( - sanitize_deny_group("binary=/usr/local/bin/private"), - "unknown" - ); - } - - #[test] - fn denial_rate_handles_zero_and_clamps() { - assert_float_eq(denial_rate_pct(0, 10), 0.0); - assert_float_eq(denial_rate_pct(4, 1), 25.0); - assert_float_eq(denial_rate_pct(4, 10), 100.0); - } - - #[test] - fn flush_summary_drops_when_queue_is_full() { - let (tx, _rx) = mpsc::channel(1); - let summary = FlushableActivitySummary { - network_activity_count: 1, - denied_action_count: 0, - denials_by_group: Vec::new(), - }; - - assert!(queue_flush_summary(&tx, summary.clone())); - assert!(!queue_flush_summary(&tx, summary)); - } - - #[test] - fn activity_flush_interval_uses_positive_values_only() { - assert_eq!( - activity_flush_interval_secs_from_env(None), - DEFAULT_ACTIVITY_FLUSH_INTERVAL_SECS - ); - assert_eq!( - activity_flush_interval_secs_from_env(Some("not-a-number")), - DEFAULT_ACTIVITY_FLUSH_INTERVAL_SECS - ); - assert_eq!( - activity_flush_interval_secs_from_env(Some("0")), - DEFAULT_ACTIVITY_FLUSH_INTERVAL_SECS - ); - assert_eq!(activity_flush_interval_secs_from_env(Some("5")), 5); - } -} diff --git a/crates/openshell-server/Cargo.toml b/crates/openshell-server/Cargo.toml index f62f37b3a9..e035c311ae 100644 --- a/crates/openshell-server/Cargo.toml +++ b/crates/openshell-server/Cargo.toml @@ -119,11 +119,6 @@ arc-swap = "1" notify = "8" [features] -default = ["telemetry"] -## Compile in anonymous telemetry emission (forwards to openshell-core/telemetry). -## On by default; build with `--no-default-features` for a telemetry-free gateway -## that contains no telemetry endpoint, HTTP client, or emission code. -telemetry = ["openshell-core/telemetry"] vendored-z3 = ["openshell-prover/vendored-z3"] prebuilt-z3 = ["openshell-prover/prebuilt-z3"] test-support = ["dep:tonic-prost", "openshell-credential-issuer/test-support"] diff --git a/crates/openshell-server/src/compute/mod.rs b/crates/openshell-server/src/compute/mod.rs index 32641d0937..4b14fc8c81 100644 --- a/crates/openshell-server/src/compute/mod.rs +++ b/crates/openshell-server/src/compute/mod.rs @@ -50,7 +50,6 @@ use openshell_core::proto::{ SandboxRestartPolicy, SandboxSpec, SandboxStatus, SandboxTemplate, SandboxWorkloadTemplate, ServiceEndpoint, SshSession, }; -use openshell_core::telemetry::TelemetryComputeDriver; use openshell_core::{ObjectLabels, ObjectWorkspace, SetResourceVersion}; use prost::Message; use std::collections::HashMap; @@ -933,7 +932,6 @@ pub struct ComputeRuntime { image_update_driver: Option, app_endpoint_resolver: Option, driver_info: ComputeDriverInfoSnapshot, - telemetry_compute_driver: TelemetryComputeDriver, driver_process: Option>, default_image: String, image_preparation_timeout_seconds: u32, @@ -1056,7 +1054,6 @@ impl ComputeRuntime { admission: openshell_core::resource_admission::DriverAdmissionConfig::default(), admission_acknowledgement: capabilities.resource_admission_policy, driver_info, - telemetry_compute_driver: TelemetryComputeDriver::custom(), driver_process, default_image, image_preparation_timeout_seconds: 1800, @@ -1431,20 +1428,6 @@ impl ComputeRuntime { .map(tonic::Response::into_inner) } - #[must_use] - pub(crate) fn telemetry_compute_driver(&self) -> TelemetryComputeDriver { - self.telemetry_compute_driver - } - - #[must_use] - pub(crate) fn with_telemetry_compute_driver( - mut self, - telemetry_compute_driver: TelemetryComputeDriver, - ) -> Self { - self.telemetry_compute_driver = telemetry_compute_driver; - self - } - pub(crate) async fn ensure_workspace(&self, workspace: &str) -> Result<(), Status> { let workspace = workspace.to_string(); match self @@ -8810,7 +8793,6 @@ pub fn new_test_runtime_with_driver( rootfs_tar_staging_dir: String::new(), rootfs_tar_max_bytes: 0, }, - telemetry_compute_driver: TelemetryComputeDriver::custom(), driver_process: None, default_image: "openshell/sandbox:test".to_string(), image_preparation_timeout_seconds: 1800, @@ -10109,7 +10091,6 @@ mod tests { rootfs_tar_staging_dir: String::new(), rootfs_tar_max_bytes: 0, }, - telemetry_compute_driver: TelemetryComputeDriver::custom(), driver_process: None, default_image: "openshell/sandbox:test".to_string(), image_preparation_timeout_seconds: 1800, diff --git a/crates/openshell-server/src/grpc/policy.rs b/crates/openshell-server/src/grpc/policy.rs index 4b79cab118..164108aa26 100644 --- a/crates/openshell-server/src/grpc/policy.rs +++ b/crates/openshell-server/src/grpc/policy.rs @@ -80,9 +80,6 @@ use openshell_core::proto::{ L7DenyRule, L7Rule, NetworkBinary, NetworkEndpoint, NetworkPolicyRule, Provider, Sandbox, SandboxPolicy as ProtoSandboxPolicy, StaticCredentialEndpointBinding, }; -use openshell_core::telemetry::{ - LifecycleOperation, LifecycleResource, PolicyDecisionOperation, TelemetryOutcome, -}; use openshell_core::{ endpoint_path::EndpointPathPattern, host_pattern::{host_matches, host_patterns_overlap}, @@ -231,58 +228,6 @@ fn decode_stored_policy(payload: &[u8]) -> Result bool { - !sandbox_caller -} - -fn emit_config_update_policy_success(sandbox_caller: bool) { - if should_emit_config_update_policy_telemetry(sandbox_caller) { - emit_sandbox_policy_update_success(); - } -} - -fn should_emit_full_policy_update_telemetry(sandbox_caller: bool, next_version: i64) -> bool { - !sandbox_caller && next_version > 1 -} - -fn emit_full_policy_update_success(sandbox_caller: bool, next_version: i64) { - if should_emit_full_policy_update_telemetry(sandbox_caller, next_version) { - emit_sandbox_policy_update_success(); - } -} - -fn emit_policy_decision_success(operation: PolicyDecisionOperation, rule_count: u64) { - openshell_core::telemetry::emit_policy_decision( - operation, - TelemetryOutcome::Success, - rule_count, - ); -} - -fn emit_policy_decision_failure(operation: PolicyDecisionOperation, rule_count: u64) { - openshell_core::telemetry::emit_policy_decision( - operation, - TelemetryOutcome::Failure, - rule_count, - ); -} - fn emit_gateway_policy_audit_log( sandbox_id: &str, sandbox_name: &str, @@ -4201,20 +4146,13 @@ pub(super) async fn handle_update_config( ) -> Result, Status> { let principal = super::extract_principal(&request)?; let sandbox_caller = matches!(&principal, Principal::Sandbox(_)); - let update = request.get_ref(); - let should_emit_policy_failure = should_emit_config_update_policy_telemetry(sandbox_caller) - && (update.policy.is_some() || !update.merge_operations.is_empty()); - let result = Box::pin(handle_update_config_inner( + Box::pin(handle_update_config_inner( state, request, &principal, sandbox_caller, )) - .await; - if result.is_err() && should_emit_policy_failure { - emit_sandbox_policy_update_failure(); - } - result + .await } async fn handle_update_config_inner( @@ -4683,7 +4621,6 @@ async fn handle_update_config_inner( "UpdateConfig: merged incremental policy operations" ); spawn_pending_chunk_refresh(state, &workspace, &sandbox); - emit_config_update_policy_success(sandbox_caller); publish_sandbox_config_update(state, &sandbox_id); @@ -4879,7 +4816,6 @@ async fn handle_update_config_inner( "UpdateConfig: new policy version persisted" ); spawn_pending_chunk_refresh(state, &workspace, &sandbox); - emit_full_policy_update_success(sandbox_caller, next_version); Ok(update_config_response( u32::try_from(next_version).unwrap_or(0), @@ -5676,15 +5612,9 @@ pub(super) async fn handle_submit_policy_analysis( ) .await?; let sandbox_id = sandbox.object_id().to_string(); - for summary in &req.network_activity_summaries { - state - .telemetry - .record_network_activity(&sandbox_id, summary); - } - if req.proposed_chunks.is_empty() - && req.summaries.is_empty() - && !req.network_activity_summaries.is_empty() - { + // Supervisors that predate the removal of field 5 still send requests + // with nothing else in them; answer without running the analysis. + if req.proposed_chunks.is_empty() && req.summaries.is_empty() { return Ok(Response::new(SubmitPolicyAnalysisResponse { accepted_chunks: 0, rejected_chunks: 0, @@ -6162,17 +6092,6 @@ pub(super) async fn handle_get_draft_policy( pub(super) async fn handle_approve_draft_chunk( state: &Arc, request: Request, -) -> Result, Status> { - let result = handle_approve_draft_chunk_inner(state, request).await; - if result.is_err() { - emit_policy_decision_failure(PolicyDecisionOperation::Approve, 1); - } - result -} - -async fn handle_approve_draft_chunk_inner( - state: &Arc, - request: Request, ) -> Result, Status> { let principal = super::extract_principal(&request)?; let replay_facts = super::mutation_replay::ordinary::Facts::from_request(&request); @@ -6298,8 +6217,6 @@ async fn handle_approve_draft_chunk_inner( policy_hash = %hash, "ApproveDraftChunk: rule merged successfully" ); - emit_sandbox_policy_update_success(); - emit_policy_decision_success(PolicyDecisionOperation::Approve, 1); Ok(Response::new(ApproveDraftChunkResponse { policy_version: u32::try_from(version).unwrap_or(0), @@ -6310,17 +6227,6 @@ async fn handle_approve_draft_chunk_inner( pub(super) async fn handle_reject_draft_chunk( state: &Arc, request: Request, -) -> Result, Status> { - let result = handle_reject_draft_chunk_inner(state, request).await; - if result.is_err() { - emit_policy_decision_failure(PolicyDecisionOperation::Reject, 1); - } - result -} - -async fn handle_reject_draft_chunk_inner( - state: &Arc, - request: Request, ) -> Result, Status> { let principal = super::extract_principal(&request)?; let replay_facts = super::mutation_replay::ordinary::Facts::from_request(&request); @@ -6385,7 +6291,6 @@ async fn handle_reject_draft_chunk_inner( version, &hash, ); - emit_sandbox_policy_update_success(); } let now_ms = current_time_ms(); @@ -6408,7 +6313,6 @@ async fn handle_reject_draft_chunk_inner( if was_approved { refresh_pending_chunk_evaluations_best_effort(state, &workspace, &sandbox).await; } - emit_policy_decision_success(PolicyDecisionOperation::Reject, 1); Ok(Response::new(RejectDraftChunkResponse {})) } @@ -6417,11 +6321,7 @@ pub(super) async fn handle_approve_all_draft_chunks( state: &Arc, request: Request, ) -> Result, Status> { - let result = Box::pin(handle_approve_all_draft_chunks_inner(state, request)).await; - if result.is_err() { - emit_policy_decision_failure(PolicyDecisionOperation::ApproveAll, 0); - } - result + Box::pin(handle_approve_all_draft_chunks_inner(state, request)).await } async fn handle_approve_all_draft_chunks_inner( @@ -6681,7 +6581,6 @@ async fn handle_approve_all_draft_chunks_inner( last_version, &last_hash, ); - emit_sandbox_policy_update_success(); } let chunks_approved = u32::try_from(accepted.len()).unwrap_or(u32::MAX); @@ -6715,10 +6614,6 @@ async fn handle_approve_all_draft_chunks_inner( policy_hash = %last_hash, "ApproveAllDraftChunks: bulk approval complete" ); - emit_policy_decision_success( - PolicyDecisionOperation::ApproveAll, - u64::from(chunks_approved), - ); Ok(Response::new(ApproveAllDraftChunksResponse { policy_version: u32::try_from(last_version).unwrap_or(0), @@ -6796,17 +6691,6 @@ pub(super) async fn handle_edit_draft_chunk( pub(super) async fn handle_undo_draft_chunk( state: &Arc, request: Request, -) -> Result, Status> { - let result = handle_undo_draft_chunk_inner(state, request).await; - if result.is_err() { - emit_policy_decision_failure(PolicyDecisionOperation::Undo, 1); - } - result -} - -async fn handle_undo_draft_chunk_inner( - state: &Arc, - request: Request, ) -> Result, Status> { let principal = super::extract_principal(&request)?; let replay_facts = super::mutation_replay::ordinary::Facts::from_request(&request); @@ -6885,8 +6769,6 @@ async fn handle_undo_draft_chunk_inner( "UndoDraftChunk: rule removed, chunk reverted to pending" ); refresh_pending_chunk_evaluations_best_effort(state, &workspace, &sandbox).await; - emit_sandbox_policy_update_success(); - emit_policy_decision_success(PolicyDecisionOperation::Undo, 1); Ok(Response::new(UndoDraftChunkResponse { policy_version: u32::try_from(version).unwrap_or(0), @@ -11284,6 +11166,44 @@ mod tests { assert!(messages.contains(&"epoch")); } + #[tokio::test] + async fn submit_policy_analysis_returns_early_for_an_empty_request() { + let state = test_server_state().await; + let sandbox_name = "empty-policy-analysis"; + state + .store + .put_message(&test_sandbox( + "sb-empty-policy-analysis", + sandbox_name, + ProtoSandboxPolicy::default(), + vec![], + )) + .await + .unwrap(); + let mut watch_rx = state + .sandbox_watch_bus + .subscribe("sb-empty-policy-analysis"); + + let response = handle_submit_policy_analysis( + &state, + with_user(Request::new(SubmitPolicyAnalysisRequest { + workspace_scope: Some(openshell_core::proto::workspace_selector("default")), + name: sandbox_name.to_string(), + analysis_mode: "mechanistic".to_string(), + ..Default::default() + })), + ) + .await + .unwrap() + .into_inner(); + + assert_eq!(response, SubmitPolicyAnalysisResponse::default()); + assert!(matches!( + watch_rx.try_recv(), + Err(tokio::sync::broadcast::error::TryRecvError::Empty) + )); + } + #[tokio::test] async fn submit_policy_analysis_rejects_only_chunks_with_invalid_timestamps() { use openshell_core::proto::{NetworkBinary, NetworkEndpoint, NetworkPolicyRule}; @@ -12434,19 +12354,6 @@ mod tests { assert_eq!(err.code(), Code::NotFound); } - #[test] - fn sandbox_caller_policy_sync_does_not_emit_policy_update_telemetry() { - assert!(!should_emit_config_update_policy_telemetry(true)); - assert!(should_emit_config_update_policy_telemetry(false)); - } - - #[test] - fn first_policy_revision_does_not_emit_policy_update_telemetry() { - assert!(!should_emit_full_policy_update_telemetry(false, 1)); - assert!(!should_emit_full_policy_update_telemetry(true, 2)); - assert!(should_emit_full_policy_update_telemetry(false, 2)); - } - // ---- Sandbox without policy ---- #[tokio::test] diff --git a/crates/openshell-server/src/grpc/provider.rs b/crates/openshell-server/src/grpc/provider.rs index 5ed71fa701..fce562fc4d 100644 --- a/crates/openshell-server/src/grpc/provider.rs +++ b/crates/openshell-server/src/grpc/provider.rs @@ -29,9 +29,6 @@ use openshell_core::proto::{ ProviderProfile, ProviderProfileCredential, Sandbox, StaticCredentialBinding, StaticCredentialEndpointBinding, }; -use openshell_core::telemetry::{ - LifecycleOperation, ProviderProfile as TelemetryProviderProfile, TelemetryOutcome, -}; use openshell_credential_issuer::refresh::CredentialRefresh; use openshell_credential_issuer::refresh::{minter, secret_refs}; use openshell_policy::ProviderPolicyLayer; @@ -2948,11 +2945,6 @@ pub(super) async fn handle_create_provider( .await? .ensure_active()?; let Some(mut provider) = req.provider else { - emit_provider_lifecycle( - "custom", - LifecycleOperation::Create, - TelemetryOutcome::Failure, - ); return Err(Status::invalid_argument("provider is required")); }; if let Some(metadata) = provider.metadata.as_mut() { @@ -2963,7 +2955,6 @@ pub(super) async fn handle_create_provider( "provider.credential_handles is internal gateway state and cannot be supplied", )); } - let provider_type = provider.r#type.clone(); let _mutation_guard = state .compute .mutation_guard(MutationScope::Workspace(&workspace)) @@ -2980,36 +2971,19 @@ pub(super) async fn handle_create_provider( if state.credentials.stores_provider_credentials() && !provider.credentials.is_empty() { state.compute.ensure_workspace(&workspace).await?; } - let result = create_provider_record_validating( + let provider = create_provider_record_validating( state.store.as_ref(), &workspace, &catalog, provider, Some(&state.credentials), ) - .await; - match result { - Ok(provider) => { - emit_provider_lifecycle( - &provider.r#type, - LifecycleOperation::Create, - TelemetryOutcome::Success, - ); - publish_provider_change(state, &workspace, provider.object_name()); - Ok(Response::new(ProviderResponse { - provider: Some(provider), - ..Default::default() - })) - } - Err(err) => { - emit_provider_lifecycle( - &provider_type, - LifecycleOperation::Create, - TelemetryOutcome::Failure, - ); - Err(err) - } - } + .await?; + publish_provider_change(state, &workspace, provider.object_name()); + Ok(Response::new(ProviderResponse { + provider: Some(provider), + ..Default::default() + })) } pub(super) async fn handle_get_provider( @@ -4594,14 +4568,8 @@ pub(super) async fn handle_update_provider( super::persistence_error_to_status(error, "acquire provider mutation lock") })?; let Some(mut provider) = req.provider else { - emit_provider_lifecycle( - "custom", - LifecycleOperation::Update, - TelemetryOutcome::Failure, - ); return Err(Status::invalid_argument("provider is required")); }; - let provider_type = provider.r#type.clone(); provider .credential_expiration_times .extend(req.credential_expiration_times); @@ -4619,7 +4587,7 @@ pub(super) async fn handle_update_provider( .provider_profile_sources .snapshot_catalog(state.store.as_ref(), &workspace) .await?; - let result = update_provider_record_validating( + let provider = update_provider_record_validating( state.store.as_ref(), &state.refresh, &workspace, @@ -4628,48 +4596,31 @@ pub(super) async fn handle_update_provider( &req.clear_credential_expiration_keys, Some(&state.credentials), ) - .await; - match result { - Ok(provider) => { - let provider_version = provider - .metadata - .as_ref() - .map_or(0, |metadata| metadata.resource_version); - let mut target_receipts = Vec::with_capacity(targets.len()); - for sandbox in &targets { - target_receipts.push( - super::provider_readiness::record_provider_mutation( - state, - sandbox, - provider.object_name(), - openshell_core::proto::ProviderMutationKind::Update, - Some((provider.object_id(), provider_version)), - &mutation_id, - ) - .await?, - ); - } - emit_provider_lifecycle( - &provider.r#type, - LifecycleOperation::Update, - TelemetryOutcome::Success, - ); - publish_provider_change(state, &workspace, provider.object_name()); - Ok(Response::new(ProviderResponse { - provider: Some(provider), - target_receipts, - mutation_id, - })) - } - Err(err) => { - emit_provider_lifecycle( - &provider_type, - LifecycleOperation::Update, - TelemetryOutcome::Failure, - ); - Err(err) - } + .await?; + let provider_version = provider + .metadata + .as_ref() + .map_or(0, |metadata| metadata.resource_version); + let mut target_receipts = Vec::with_capacity(targets.len()); + for sandbox in &targets { + target_receipts.push( + super::provider_readiness::record_provider_mutation( + state, + sandbox, + provider.object_name(), + openshell_core::proto::ProviderMutationKind::Update, + Some((provider.object_id(), provider_version)), + &mutation_id, + ) + .await?, + ); } + publish_provider_change(state, &workspace, provider.object_name()); + Ok(Response::new(ProviderResponse { + provider: Some(provider), + target_receipts, + mutation_id, + })) } /// Exchange a supervisor's attached provider credential with safe failure details. @@ -6266,87 +6217,20 @@ pub(super) async fn handle_delete_provider( .await .map_err(|e| super::persistence_error_to_status(e, "acquire provider mutation lock"))?; let name = req.name; - let provider_profile = provider_profile_for_name(state.store.as_ref(), &workspace, &name).await; - let result = delete_provider_record_with_credentials( + let deleted = delete_provider_record_with_credentials( state.store.as_ref(), &state.refresh, &workspace, &state.credentials, &name, ) - .await; - match result { - Ok(deleted) => { - let outcome = TelemetryOutcome::from_success(deleted || req.allow_missing); - emit_provider_profile_lifecycle( - provider_profile.unwrap_or(TelemetryProviderProfile::Custom), - LifecycleOperation::Delete, - outcome, - ); - if deleted { - publish_provider_change(state, &workspace, &name); - } - Ok(Response::new(DeleteProviderResponse { - outcome: super::deletion_outcome(deleted, req.allow_missing, "provider")?, - })) - } - Err(err) => { - emit_provider_profile_lifecycle( - provider_profile.unwrap_or(TelemetryProviderProfile::Custom), - LifecycleOperation::Delete, - TelemetryOutcome::Failure, - ); - Err(err) - } - } -} - -fn emit_provider_lifecycle( - provider_type: &str, - operation: LifecycleOperation, - outcome: TelemetryOutcome, -) { - let provider_profile = telemetry_provider_profile(provider_type); - emit_provider_profile_lifecycle(provider_profile, operation, outcome); -} - -fn emit_provider_profile_lifecycle( - provider_profile: TelemetryProviderProfile, - operation: LifecycleOperation, - outcome: TelemetryOutcome, -) { - openshell_core::telemetry::emit_provider_lifecycle(operation, outcome, provider_profile); -} - -async fn provider_profile_for_name( - store: &Store, - workspace: &str, - name: &str, -) -> Option { - store - .get_message_by_name::(workspace, name) - .await - .ok() - .flatten() - .map(|provider| telemetry_provider_profile(&provider.r#type)) -} - -/// Bucket a provider type for telemetry. -/// -/// Matches the profile ID exactly. Any ID without a bucket, including every -/// operator-authored profile, reports as `Custom`. -fn telemetry_provider_profile(provider_type: &str) -> TelemetryProviderProfile { - match normalize_profile_id(provider_type).as_deref() { - Some("anthropic") => TelemetryProviderProfile::Anthropic, - Some("claude-code") => TelemetryProviderProfile::Claude, - Some("codex") => TelemetryProviderProfile::Codex, - Some("copilot") => TelemetryProviderProfile::Copilot, - Some("deepinfra") => TelemetryProviderProfile::Deepinfra, - Some("github") => TelemetryProviderProfile::Github, - Some("nvidia") => TelemetryProviderProfile::Nvidia, - Some("openai") => TelemetryProviderProfile::Openai, - _ => TelemetryProviderProfile::Custom, + .await?; + if deleted { + publish_provider_change(state, &workspace, &name); } + Ok(Response::new(DeleteProviderResponse { + outcome: super::deletion_outcome(deleted, req.allow_missing, "provider")?, + })) } #[cfg(test)] @@ -6829,60 +6713,6 @@ pub(super) mod tests { validate_provider_create_credentials(&profile, &provider).unwrap(); } - #[test] - fn telemetry_provider_profile_maps_unknown_to_custom() { - assert_eq!( - telemetry_provider_profile("CLAUDE-CODE"), - TelemetryProviderProfile::Claude - ); - // A legacy alias is not a profile ID, so it buckets as custom. - assert_eq!( - telemetry_provider_profile("claude"), - TelemetryProviderProfile::Custom - ); - assert_eq!( - telemetry_provider_profile("github"), - TelemetryProviderProfile::Github - ); - // Legacy aliases are not profile IDs. - assert_eq!( - telemetry_provider_profile("gh"), - TelemetryProviderProfile::Custom - ); - assert_eq!( - telemetry_provider_profile("glab"), - TelemetryProviderProfile::Custom - ); - assert_eq!( - telemetry_provider_profile("gitlab"), - TelemetryProviderProfile::Custom - ); - assert_eq!( - telemetry_provider_profile("opencode"), - TelemetryProviderProfile::Custom - ); - assert_eq!( - telemetry_provider_profile("outlook"), - TelemetryProviderProfile::Custom - ); - assert_eq!( - telemetry_provider_profile("generic"), - TelemetryProviderProfile::Custom - ); - assert_eq!( - telemetry_provider_profile("unknown-private"), - TelemetryProviderProfile::Custom - ); - assert_eq!( - telemetry_provider_profile("acme-internal"), - TelemetryProviderProfile::Custom - ); - assert_eq!( - telemetry_provider_profile("corp-llm-prod"), - TelemetryProviderProfile::Custom - ); - } - #[test] fn dynamic_credentials_expand_endpoint_audience_overrides() { let service_audiences = [ diff --git a/crates/openshell-server/src/grpc/sandbox.rs b/crates/openshell-server/src/grpc/sandbox.rs index cdc701cbc1..a3da316825 100644 --- a/crates/openshell-server/src/grpc/sandbox.rs +++ b/crates/openshell-server/src/grpc/sandbox.rs @@ -44,9 +44,6 @@ use openshell_core::proto::{ BeginRootfsTarStagingRequest, BeginRootfsTarStagingResponse, Sandbox, SandboxPhase, SandboxRestartPolicy, SandboxTemplate, SshSession, }; -use openshell_core::telemetry::{ - LifecycleOperation, LifecycleResource, SandboxTemplateSource, TelemetryOutcome, -}; use openshell_core::{GetResourceVersion, ObjectId, ObjectName, ObjectWorkspace}; use prost::Message; use prost_types::{Struct, Value, value::Kind}; @@ -298,21 +295,9 @@ pub(super) async fn handle_create_sandbox( state: &Arc, request: Request, ) -> Result, Status> { - let create_request = request.get_ref().clone(); // Sandbox creation retains large configuration values across awaits. // Box the inner future to keep this wrapper small for every caller. - let result = Box::pin(handle_create_sandbox_inner(state, request)).await; - let created_sandbox = result - .as_ref() - .ok() - .and_then(|response| response.get_ref().sandbox.as_ref()); - emit_sandbox_create_telemetry( - state, - &create_request, - created_sandbox, - TelemetryOutcome::from_success(result.is_ok()), - ); - result + Box::pin(handle_create_sandbox_inner(state, request)).await } /// Only the workload image is mutable in the first update contract. Runtime @@ -485,76 +470,6 @@ fn staging_token_in_spec(spec: &SandboxSpec, driver_name: &str) -> Option, - request: &CreateSandboxRequest, - created_sandbox: Option<&Sandbox>, - outcome: TelemetryOutcome, -) { - let compute_driver = state.compute.telemetry_compute_driver(); - let attrs = sandbox_create_telemetry_attrs(request, created_sandbox); - openshell_core::telemetry::emit_sandbox_create( - outcome, - attrs.requested_gpu, - attrs.provider_count, - attrs.has_custom_policy, - attrs.template_source, - compute_driver, - ); -} - -fn sandbox_create_telemetry_attrs( - request: &CreateSandboxRequest, - created_sandbox: Option<&Sandbox>, -) -> SandboxCreateTelemetryAttrs { - if !request.workload_template.trim().is_empty() { - let spec = created_sandbox - .and_then(|sandbox| sandbox.spec.as_ref()) - .or(request.spec.as_ref()); - return SandboxCreateTelemetryAttrs { - requested_gpu: spec.is_some_and(|spec| { - openshell_core::gpu::sandbox_gpu_requested(spec.resource_requirements.as_ref()) - }), - provider_count: spec.map_or(0, |spec| spec.providers.len() as u64), - has_custom_policy: spec.is_some_and(|spec| spec.policy.is_some()), - template_source: SandboxTemplateSource::WorkloadTemplate, - }; - } - let Some(spec) = request.spec.as_ref() else { - return SandboxCreateTelemetryAttrs { - requested_gpu: false, - provider_count: 0, - has_custom_policy: false, - template_source: SandboxTemplateSource::Undefined, - }; - }; - let template_source = if spec - .template - .as_ref() - .is_some_and(|template| !template.image.trim().is_empty()) - { - SandboxTemplateSource::Image - } else { - SandboxTemplateSource::Default - }; - let gpu_requested = - openshell_core::gpu::sandbox_gpu_requested(spec.resource_requirements.as_ref()); - SandboxCreateTelemetryAttrs { - requested_gpu: gpu_requested, - provider_count: spec.providers.len() as u64, - has_custom_policy: spec.policy.is_some(), - template_source, - } -} - async fn handle_create_sandbox_inner( state: &Arc, request: Request, @@ -1793,23 +1708,6 @@ pub(super) async fn handle_detach_sandbox_provider( pub(super) async fn handle_delete_sandbox( state: &Arc, request: Request, -) -> Result, Status> { - let result = handle_delete_sandbox_inner(state, request).await; - let outcome = match &result { - Ok(_) => TelemetryOutcome::Success, - _ => TelemetryOutcome::Failure, - }; - openshell_core::telemetry::emit_lifecycle( - LifecycleResource::Sandbox, - LifecycleOperation::Delete, - outcome, - ); - result -} - -async fn handle_delete_sandbox_inner( - state: &Arc, - request: Request, ) -> Result, Status> { let principal = super::extract_principal(&request)?; let req = request.into_inner(); @@ -1848,9 +1746,6 @@ async fn handle_delete_sandbox_inner( preconditions, ) .await?; - if !result.sandbox_id.is_empty() { - state.telemetry.end_sandbox_session(&result.sandbox_id); - } info!(sandbox_name = %name, "DeleteSandbox request completed successfully"); Ok(Response::new(DeleteSandboxResponse { outcome: result.outcome.into(), @@ -1861,23 +1756,6 @@ async fn handle_delete_sandbox_inner( pub(super) async fn handle_stop_sandbox( state: &Arc, request: Request, -) -> Result, Status> { - let result = handle_stop_sandbox_inner(state, request).await; - openshell_core::telemetry::emit_lifecycle( - LifecycleResource::Sandbox, - LifecycleOperation::Stop, - if result.is_ok() { - TelemetryOutcome::Success - } else { - TelemetryOutcome::Failure - }, - ); - result -} - -async fn handle_stop_sandbox_inner( - state: &Arc, - request: Request, ) -> Result, Status> { let principal = super::extract_principal(&request)?; let req = request.into_inner(); @@ -1904,23 +1782,6 @@ async fn handle_stop_sandbox_inner( pub(super) async fn handle_start_sandbox( state: &Arc, request: Request, -) -> Result, Status> { - let result = handle_start_sandbox_inner(state, request).await; - openshell_core::telemetry::emit_lifecycle( - LifecycleResource::Sandbox, - LifecycleOperation::Start, - if result.is_ok() { - TelemetryOutcome::Success - } else { - TelemetryOutcome::Failure - }, - ); - result -} - -async fn handle_start_sandbox_inner( - state: &Arc, - request: Request, ) -> Result, Status> { let principal = super::extract_principal(&request)?; let req = request.into_inner(); @@ -1961,23 +1822,6 @@ async fn handle_start_sandbox_inner( pub(super) async fn handle_suspend_sandbox( state: &Arc, request: Request, -) -> Result, Status> { - let result = handle_suspend_sandbox_inner(state, request).await; - openshell_core::telemetry::emit_lifecycle( - LifecycleResource::Sandbox, - LifecycleOperation::Suspend, - if result.is_ok() { - TelemetryOutcome::Success - } else { - TelemetryOutcome::Failure - }, - ); - result -} - -async fn handle_suspend_sandbox_inner( - state: &Arc, - request: Request, ) -> Result, Status> { let principal = super::extract_principal(&request)?; let req = request.into_inner(); @@ -2004,23 +1848,6 @@ async fn handle_suspend_sandbox_inner( pub(super) async fn handle_resume_sandbox( state: &Arc, request: Request, -) -> Result, Status> { - let result = handle_resume_sandbox_inner(state, request).await; - openshell_core::telemetry::emit_lifecycle( - LifecycleResource::Sandbox, - LifecycleOperation::Resume, - if result.is_ok() { - TelemetryOutcome::Success - } else { - TelemetryOutcome::Failure - }, - ); - result -} - -async fn handle_resume_sandbox_inner( - state: &Arc, - request: Request, ) -> Result, Status> { let principal = super::extract_principal(&request)?; let req = request.into_inner(); @@ -4526,74 +4353,6 @@ mod tests { } } - #[test] - fn sandbox_create_telemetry_uses_resolved_template_gpu_request() { - let request = CreateSandboxRequest { - request_id: String::new(), - spec: Some(SandboxSpec { - providers: vec!["github".to_string()], - policy: Some(openshell_core::proto::SandboxPolicy::default()), - ..SandboxSpec::default() - }), - workload_template: "gpu-kata".to_string(), - workspace_scope: Some(openshell_core::proto::workspace_selector( - "default".to_string(), - )), - ..CreateSandboxRequest::default() - }; - let created = Sandbox { - spec: Some(SandboxSpec { - providers: vec!["github".to_string()], - policy: Some(openshell_core::proto::SandboxPolicy::default()), - resource_requirements: Some(ResourceRequirements { - gpu: Some(GpuResourceRequirements { count: Some(1) }), - }), - ..SandboxSpec::default() - }), - created_from_workload_template: Some(SandboxWorkloadTemplateProvenance { - name: "gpu-kata".to_string(), - resource_version: "7".to_string(), - }), - ..Sandbox::default() - }; - - assert_eq!( - sandbox_create_telemetry_attrs(&request, Some(&created)), - SandboxCreateTelemetryAttrs { - requested_gpu: true, - provider_count: 1, - has_custom_policy: true, - template_source: SandboxTemplateSource::WorkloadTemplate, - } - ); - } - - #[test] - fn sandbox_create_telemetry_falls_back_to_request_for_unresolved_template() { - let request = CreateSandboxRequest { - request_id: String::new(), - spec: Some(SandboxSpec { - providers: vec!["github".to_string()], - ..SandboxSpec::default() - }), - workload_template: "missing-template".to_string(), - workspace_scope: Some(openshell_core::proto::workspace_selector( - "default".to_string(), - )), - ..CreateSandboxRequest::default() - }; - - assert_eq!( - sandbox_create_telemetry_attrs(&request, None), - SandboxCreateTelemetryAttrs { - requested_gpu: false, - provider_count: 1, - has_custom_policy: false, - template_source: SandboxTemplateSource::WorkloadTemplate, - } - ); - } - #[test] fn shell_escape_safe_chars_pass_through() { assert_eq!(shell_escape("ls").unwrap(), "ls"); @@ -6446,7 +6205,7 @@ mod tests { } #[tokio::test] - async fn delete_handler_ends_telemetry_for_the_resolved_sandbox_id() { + async fn delete_handler_targets_the_resolved_sandbox_id() { let state = test_server_state().await; let mut original = test_sandbox("reused-name", Vec::new()); original.metadata.as_mut().unwrap().id = "sandbox-original".to_string(); @@ -6462,7 +6221,7 @@ mod tests { .unwrap(); let delete_state = state.clone(); let delete = tokio::spawn(async move { - handle_delete_sandbox_inner( + handle_delete_sandbox( &delete_state, authed_request(DeleteSandboxRequest { request_id: String::new(), @@ -6498,6 +6257,7 @@ mod tests { response.outcome(), openshell_core::proto::DeletionOutcome::Completed ); + assert_eq!(response.sandbox_id, original.object_id()); assert!( state .store @@ -6506,10 +6266,6 @@ mod tests { .unwrap() .is_some() ); - assert_eq!( - state.telemetry.ended_sandbox_sessions(), - [original.object_id().to_string()] - ); } #[tokio::test] diff --git a/crates/openshell-server/src/lib.rs b/crates/openshell-server/src/lib.rs index 799c46e397..10dbeecd4f 100644 --- a/crates/openshell-server/src/lib.rs +++ b/crates/openshell-server/src/lib.rs @@ -56,7 +56,6 @@ mod supervisor_owner; mod supervisor_pool; pub mod supervisor_session; mod supervisor_spread; -mod telemetry; #[cfg(any(test, feature = "test-support"))] pub mod test_support; mod tls; @@ -74,7 +73,6 @@ use hyper_util::{ service::TowerToHyperService, }; use openshell_core::net::set_tcp_nodelay_best_effort; -use openshell_core::telemetry::TelemetryComputeDriver; use openshell_core::token_grant_failure::TokenGrantFailure; use openshell_core::{Config, Error, NetworkSupervisorTrustBundle, ObjectLabels, Result}; use openshell_extension_core::{ @@ -354,9 +352,6 @@ pub struct ServerState { /// In-memory bus for server process logs. pub tracing_log_bus: TracingLogBus, - /// In-memory anonymous telemetry accounting for active sandbox sessions. - pub(crate) telemetry: telemetry::TelemetryState, - /// Active SSH tunnel connection counts per session token. pub ssh_connections_by_token: Mutex>, @@ -690,7 +685,6 @@ impl ServerState { sandbox_index, sandbox_watch_bus, tracing_log_bus, - telemetry: telemetry::TelemetryState::new(), ssh_connections_by_token: Mutex::new(HashMap::new()), ssh_connections_by_sandbox: Mutex::new(HashMap::new()), service_connections_by_sandbox: Mutex::new(HashMap::new()), @@ -1903,7 +1897,6 @@ pub struct ComputeDriverRegistration { detection_priority: u16, detect: Option bool>, factory: Arc, - telemetry_category: TelemetryComputeDriver, in_process_tracing: Option, } @@ -1933,19 +1926,10 @@ impl ComputeDriverRegistration { detection_priority, detect, factory: Arc::new(factory), - telemetry_category: TelemetryComputeDriver::custom(), in_process_tracing: None, }) } - /// Assign a bounded telemetry category chosen by the binary composition - /// boundary. Runtime driver names are never used as telemetry values. - #[must_use] - pub fn with_telemetry_category(mut self, category: TelemetryComputeDriver) -> Self { - self.telemetry_category = category; - self - } - /// Attach process-wide tracing for this in-process compiled driver. #[must_use] pub fn with_in_process_tracing( @@ -2310,7 +2294,6 @@ async fn build_compute_runtime( &config.log_level, driver_startup, )?; - let telemetry_compute_driver = driver.telemetry_compute_driver(registry); let admission = match &driver { ConfiguredComputeDriver::Registered(registration) => registration .factory @@ -2438,7 +2421,7 @@ async fn build_compute_runtime( .with_provisioning_repair_window_seconds(config.provisioning_repair_window_seconds) }) .map_err(Error::config)?; - Ok(runtime.with_telemetry_compute_driver(telemetry_compute_driver)) + Ok(runtime) } #[derive(Debug, Clone)] @@ -2454,17 +2437,6 @@ impl ConfiguredComputeDriver { Self::Remote { name } => name, } } - - fn telemetry_compute_driver(&self, registry: &ComputeDriverRegistry) -> TelemetryComputeDriver { - match self { - Self::Registered(registration) => registration.telemetry_category, - Self::Remote { name } => registry - .get(name) - .map_or_else(TelemetryComputeDriver::custom, |registration| { - registration.telemetry_category - }), - } - } } #[cfg(test)] @@ -2996,12 +2968,7 @@ mod tests { None, TestComputeDriverFactory, ) - .unwrap() - .with_telemetry_category( - openshell_core::telemetry::TelemetryComputeDriver::anonymous_category( - "registered", - ), - ), + .unwrap(), ) .unwrap(); } @@ -3976,10 +3943,6 @@ mod tests { let driver = configured_compute_driver(®istry, &config, test_driver_startup(&config, None)) .unwrap(); - assert_eq!( - driver.telemetry_compute_driver(®istry).as_str(), - "registered" - ); assert!(matches!( driver, ConfiguredComputeDriver::Registered(registration) if registration.name == "beta" @@ -3994,10 +3957,6 @@ mod tests { let driver = configured_compute_driver(®istry, &config, test_driver_startup(&config, None)) .unwrap(); - assert_eq!( - driver.telemetry_compute_driver(®istry).as_str(), - "custom" - ); match driver { ConfiguredComputeDriver::Remote { name } => { @@ -4022,10 +3981,6 @@ mod tests { let driver = configured_compute_driver(®istry, &config, test_driver_startup(&config, None)) .unwrap(); - assert_eq!( - driver.telemetry_compute_driver(®istry).as_str(), - "registered" - ); assert!(matches!( driver, ConfiguredComputeDriver::Remote { name } if name == "alpha" diff --git a/crates/openshell-server/src/supervisor_session.rs b/crates/openshell-server/src/supervisor_session.rs index 92a8ed6222..5da2be6524 100644 --- a/crates/openshell-server/src/supervisor_session.rs +++ b/crates/openshell-server/src/supervisor_session.rs @@ -2463,7 +2463,6 @@ async fn accept_supervisor_session(setup: SessionSetup) -> Result<(), Status> { "failed to persist supervisor session state; reconnect", )); } - state.telemetry.sandbox_session_connected(&sandbox_id); if outbound_tx.send(accepted).await.is_err() { // Only evict ourselves — a faster reconnect may already have @@ -2837,7 +2836,6 @@ async fn finish_supervisor_session( return; }; info!(sandbox_id, session_id, "supervisor session: ended"); - state.telemetry.sandbox_session_disconnected(sandbox_id); tokio::spawn( crate::grpc::policy::retry_endpoint_status_after_supervisor_disconnect( Arc::clone(state), diff --git a/crates/openshell-server/src/telemetry.rs b/crates/openshell-server/src/telemetry.rs deleted file mode 100644 index c0778b1ff8..0000000000 --- a/crates/openshell-server/src/telemetry.rs +++ /dev/null @@ -1,123 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -//! Anonymous sandbox activity telemetry forwarding. - -use openshell_core::proto::NetworkActivitySummary; -use openshell_core::telemetry::DenyGroup; -#[cfg(not(test))] -use std::collections::HashMap; - -#[derive(Debug, Default)] -pub struct TelemetryState { - #[cfg(test)] - ended_sandbox_sessions: std::sync::Mutex>, -} - -#[allow(clippy::unused_self)] -impl TelemetryState { - pub fn new() -> Self { - Self::default() - } - - pub fn sandbox_session_connected(&self, _sandbox_id: &str) {} - - pub fn sandbox_session_disconnected(&self, _sandbox_id: &str) {} - - pub fn end_sandbox_session(&self, sandbox_id: &str) { - #[cfg(test)] - self.ended_sandbox_sessions - .lock() - .expect("telemetry session lock poisoned") - .push(sandbox_id.to_string()); - #[cfg(not(test))] - let _ = sandbox_id; - } - - #[cfg(test)] - pub(crate) fn ended_sandbox_sessions(&self) -> Vec { - self.ended_sandbox_sessions - .lock() - .expect("telemetry session lock poisoned") - .clone() - } - - pub fn record_network_activity(&self, sandbox_id: &str, summary: &NetworkActivitySummary) { - if sandbox_id.is_empty() || !openshell_core::telemetry::enabled() { - return; - } - #[cfg(not(test))] - emit_network_activity_summary(summary); - #[cfg(test)] - let _ = summary; - } -} - -#[allow(clippy::cast_precision_loss)] -fn calculate_denial_rate_pct(network_activity_count: u64, denied_action_count: u64) -> f64 { - if network_activity_count == 0 { - return 0.0; - } - ((denied_action_count as f64 / network_activity_count as f64) * 100.0).clamp(0.0, 100.0) -} - -fn sanitize_deny_group(raw: &str) -> DenyGroup { - DenyGroup::from_raw(raw) -} - -#[cfg(not(test))] -fn emit_network_activity_summary(summary: &NetworkActivitySummary) { - let mut denials_by_group = HashMap::::new(); - for group in &summary.denials_by_group { - let deny_group = sanitize_deny_group(&group.deny_group); - let entry = denials_by_group.entry(deny_group).or_default(); - *entry = entry.saturating_add(u64::from(group.denied_count)); - } - openshell_core::telemetry::emit_sandbox_activity_summary( - u64::from(summary.network_activity_count), - u64::from(summary.denied_action_count), - calculate_denial_rate_pct( - u64::from(summary.network_activity_count), - u64::from(summary.denied_action_count), - ), - denials_by_group, - ); -} - -#[cfg(test)] -mod tests { - use super::*; - - fn assert_float_eq(actual: f64, expected: f64) { - assert!((actual - expected).abs() <= f64::EPSILON); - } - - #[test] - fn denial_rate_handles_empty_and_clamps() { - assert_float_eq(calculate_denial_rate_pct(0, 1), 0.0); - assert_float_eq(calculate_denial_rate_pct(10, 2), 20.0); - assert_float_eq(calculate_denial_rate_pct(10, 15), 100.0); - } - - #[test] - fn deny_group_sanitization_drops_raw_values() { - assert_eq!(sanitize_deny_group("forward-l7-deny"), DenyGroup::L7Policy); - assert_eq!( - sanitize_deny_group("host=/secret.example"), - DenyGroup::Unknown - ); - assert_eq!(sanitize_deny_group("acme.internal:443"), DenyGroup::Unknown); - assert_eq!( - sanitize_deny_group("binary=/usr/local/bin/private"), - DenyGroup::Unknown - ); - } - - #[test] - fn session_lifecycle_hooks_are_noops() { - let telemetry = TelemetryState::new(); - telemetry.sandbox_session_connected("sb-1"); - telemetry.sandbox_session_disconnected("sb-1"); - telemetry.end_sandbox_session("sb-1"); - } -} diff --git a/crates/openshell-server/src/tracing_setup.rs b/crates/openshell-server/src/tracing_setup.rs index 69ee91e5e7..77fe97ee72 100644 --- a/crates/openshell-server/src/tracing_setup.rs +++ b/crates/openshell-server/src/tracing_setup.rs @@ -4,8 +4,6 @@ //! Process-wide tracing subscriber setup for the gateway. //! //! This module routes gateway logs and spans to configured diagnostic outputs. -//! `OpenShell` product telemetry collected for maintainers is handled by -//! [`crate::telemetry`]. use openshell_ocsf::OcsfJsonlLayer; use opentelemetry_sdk::trace::SdkTracerProvider; diff --git a/crates/openshell-supervisor-network/src/host.rs b/crates/openshell-supervisor-network/src/host.rs index c26ead87b8..cb7929dedf 100644 --- a/crates/openshell-supervisor-network/src/host.rs +++ b/crates/openshell-supervisor-network/src/host.rs @@ -15,7 +15,6 @@ use std::sync::Arc; use std::sync::atomic::AtomicU32; use miette::Result; -use openshell_core::activity::ActivitySender; use openshell_core::denial::DenialEvent; use openshell_core::policy::ProxyPolicy; use openshell_core::proposals::AgentProposals; @@ -54,7 +53,6 @@ pub struct HostProxyConfig { /// Shared feature state for the policy.local agent proposal surface. pub agent_proposals: AgentProposals, pub denial_tx: Option>, - pub activity_tx: Option, } /// RAII handle for a host-side proxy. Dropping it aborts the proxy accept loop. @@ -216,7 +214,6 @@ pub async fn start_host_proxy(config: HostProxyConfig) -> Result, pub(crate) body_classifier: Option>, - /// Anonymous activity counter channel. - pub(crate) activity_tx: Option, /// Dynamic token grant resolver for endpoint-bound credentials. pub(crate) token_grant_resolver: Option>, @@ -391,7 +388,6 @@ where } else { egress_emit!(event); } - emit_activity(ctx, true, "l7_parse_rejection"); let body = serde_json::json!({ "error": "invalid_mcp_request", "detail": reason, @@ -500,14 +496,6 @@ where } else { egress_emit!(event); } - let deny_group = match error { - crate::l7::mcp::McpProtocolVersionError::NotAllowed(_) => "l7_policy", - crate::l7::mcp::McpProtocolVersionError::InvalidHeader - | crate::l7::mcp::McpProtocolVersionError::UnsupportedHeaderValue - | crate::l7::mcp::McpProtocolVersionError::InvalidRequestMetadata - | crate::l7::mcp::McpProtocolVersionError::MethodNotAllowed => "l7_parse_rejection", - }; - emit_activity(ctx, true, deny_group); let body = serde_json::json!({ "error": error.response_code(), "detail": reason, @@ -1450,7 +1438,6 @@ fn emit_parse_rejection(ctx: &L7EvalContext, detail: &str, engine_type: &str) { .status_detail(detail) .build(); egress_emit!(event); - emit_activity(ctx, true, "l7_parse_rejection"); } fn engine_type_for_protocol(protocol: L7Protocol) -> &'static str { @@ -2262,7 +2249,6 @@ fn emit_l7_request_log( protocol_summary, ); egress_emit!(event); - emit_activity(ctx, decision_str == "deny", "l7_policy"); } fn build_l7_request_event( @@ -2324,12 +2310,6 @@ fn l7_protocol_log_summary( None } -fn emit_activity(ctx: &L7EvalContext, denied: bool, deny_group: &'static str) { - if let Some(tx) = &ctx.activity_tx { - let _ = try_record_activity(tx, denied, deny_group); - } -} - pub(crate) async fn websocket_middleware_preflight( req: &crate::l7::provider::L7Request, chain: &[openshell_supervisor_middleware::ChainEntry], @@ -11428,17 +11408,13 @@ network_policies: } #[tokio::test] - async fn route_selected_unmatched_path_emits_denied_policy_activity() { + async fn route_selected_unmatched_path_is_denied() { let engine = OpaEngine::from_strings(TEST_POLICY, ENCODED_SLASH_SCOPING_POLICY).unwrap(); let tunnel_engine = engine .clone_engine_for_tunnel(engine.current_generation()) .unwrap(); let configs = encoded_slash_scoping_configs(); - let (activity_tx, mut activity_rx) = tokio::sync::mpsc::channel(1); - let ctx = L7EvalContext { - activity_tx: Some(activity_tx), - ..encoded_slash_scoping_ctx() - }; + let ctx = encoded_slash_scoping_ctx(); let (mut app, mut relay_client) = tokio::io::duplex(8192); let (mut relay_upstream, mut upstream) = tokio::io::duplex(8192); let relay = tokio::spawn(async move { @@ -11478,12 +11454,6 @@ network_policies: .await, Err(_) | Ok(Ok(0)) )); - let activity = tokio::time::timeout(std::time::Duration::from_secs(1), activity_rx.recv()) - .await - .expect("policy activity should be emitted") - .expect("activity channel should remain open"); - assert!(activity.denied); - assert_eq!(activity.deny_group, "l7_policy"); drop(app); tokio::time::timeout(std::time::Duration::from_secs(1), relay) @@ -11505,11 +11475,7 @@ network_policies: .clone_engine_for_tunnel(engine.current_generation()) .unwrap(); let configs = encoded_slash_scoping_configs(); - let (activity_tx, mut activity_rx) = tokio::sync::mpsc::channel(1); - let ctx = L7EvalContext { - activity_tx: Some(activity_tx), - ..encoded_slash_scoping_ctx() - }; + let ctx = encoded_slash_scoping_ctx(); let (mut app, mut relay_client) = tokio::io::duplex(8192); let (mut relay_upstream, mut upstream) = tokio::io::duplex(8192); @@ -11552,12 +11518,6 @@ network_policies: matches!(result, Err(_) | Ok(Ok(0))), "request must not reach upstream" ); - let activity = tokio::time::timeout(std::time::Duration::from_secs(1), activity_rx.recv()) - .await - .expect("parse rejection activity should be emitted") - .expect("activity channel should remain open"); - assert!(activity.denied); - assert_eq!(activity.deny_group, "l7_parse_rejection"); drop(app); tokio::time::timeout(std::time::Duration::from_secs(1), relay) diff --git a/crates/openshell-supervisor-network/src/l7/token_grant_injection.rs b/crates/openshell-supervisor-network/src/l7/token_grant_injection.rs index 2b76265970..b3b29a1631 100644 --- a/crates/openshell-supervisor-network/src/l7/token_grant_injection.rs +++ b/crates/openshell-supervisor-network/src/l7/token_grant_injection.rs @@ -1413,7 +1413,6 @@ mod tests { ancestors: vec![], cmdline_paths: vec![], secret_resolver: None, - activity_tx: None, provider_credentials: Some(fixture.provider_credentials()), token_grant_resolver: Some(fixture.resolver()), ..Default::default() diff --git a/crates/openshell-supervisor-network/src/policy_local.rs b/crates/openshell-supervisor-network/src/policy_local.rs index bdf8898986..ab26973d30 100644 --- a/crates/openshell-supervisor-network/src/policy_local.rs +++ b/crates/openshell-supervisor-network/src/policy_local.rs @@ -668,7 +668,7 @@ async fn submit_proposal(ctx: &PolicyLocalContext, body: &[u8]) -> (u16, serde_j let audit_summaries: Vec = chunks.iter().map(summarize_chunk_for_audit).collect(); let response = match client - .submit_policy_analysis(sandbox_name, vec![], chunks, vec![], "agent_authored") + .submit_policy_analysis(sandbox_name, vec![], chunks, "agent_authored") .await { Ok(response) => response, diff --git a/crates/openshell-supervisor-network/src/proxy.rs b/crates/openshell-supervisor-network/src/proxy.rs index e497ac5df9..0cb9ff9bd2 100644 --- a/crates/openshell-supervisor-network/src/proxy.rs +++ b/crates/openshell-supervisor-network/src/proxy.rs @@ -30,7 +30,6 @@ use crate::upstream_proxy::{self, UpstreamProxyConfig}; use futures::{FutureExt as _, StreamExt as _, stream::FuturesUnordered}; use http::StatusCode; use miette::{IntoDiagnostic, Result}; -use openshell_core::activity::{ActivitySender, try_record_activity}; use openshell_core::denial::DenialEvent; use openshell_core::endpoint_status::{ EndpointObservationContext, EndpointObservationSender, EndpointResult, @@ -315,7 +314,6 @@ impl ProxyHandle { provider_credentials: Option, policy_local_ctx: Option>, denial_tx: Option>, - activity_tx: Option, endpoint_observation_tx: Option, engine_ready: tokio::sync::watch::Receiver, upstream_proxy_args: &upstream_proxy::UpstreamProxyArgs, @@ -565,7 +563,6 @@ impl ProxyHandle { .as_ref() .and_then(ProviderCredentialState::resolver); let dtx = denial_tx.clone(); - let atx = activity_tx.clone(); let endpoint_observations = endpoint_observation_tx.clone(); let required_authorization = required_proxy_authorization.clone(); tokio::spawn(async move { @@ -588,7 +585,6 @@ impl ProxyHandle { credentials, resolver, dtx, - atx, endpoint_observations, required_authorization, ) @@ -1144,7 +1140,6 @@ impl TransparentTcpHandle { entrypoint_pid: Arc, agent_proposals: openshell_core::proposals::AgentProposals, denial_tx: Option>, - activity_tx: Option, upstream_proxy_args: &upstream_proxy::UpstreamProxyArgs, engine_ready: tokio::sync::watch::Receiver, ) -> Result { @@ -1160,7 +1155,6 @@ impl TransparentTcpHandle { let pid = entrypoint_pid.clone(); let proposals = agent_proposals.clone(); let denial_tx = denial_tx.clone(); - let activity_tx = activity_tx.clone(); let upstream_proxy = upstream_proxy.clone(); let mut engine_ready = engine_ready.clone(); joins.push(tokio::spawn(async move { @@ -1186,7 +1180,6 @@ impl TransparentTcpHandle { let pid = pid.clone(); let proposals = proposals.clone(); let denial_tx = denial_tx.clone(); - let activity_tx = activity_tx.clone(); let upstream_proxy = upstream_proxy.clone(); tokio::spawn(async move { if let Err(error) = handle_transparent_tcp_connection( @@ -1197,7 +1190,6 @@ impl TransparentTcpHandle { pid, proposals, denial_tx, - activity_tx, upstream_proxy, ) .await @@ -1234,7 +1226,6 @@ async fn handle_transparent_tcp_connection( entrypoint_pid: Arc, agent_proposals: openshell_core::proposals::AgentProposals, denial_tx: Option>, - activity_tx: Option, upstream_proxy: Arc>, ) -> Result<()> { let workload_addr = client.peer_addr().into_diagnostic()?; @@ -1250,7 +1241,6 @@ async fn handle_transparent_tcp_connection( } }; emit_transparent_mapping_denial(workload_addr, original, None, cause); - emit_activity(&activity_tx, true, "transparent_tcp_mapping"); return Ok(()); } }; @@ -1283,7 +1273,6 @@ async fn handle_transparent_tcp_connection( reason, "transparent-tcp", ); - emit_activity(&activity_tx, true, "transparent_tcp_policy"); return Ok(()); } @@ -1294,7 +1283,6 @@ async fn handle_transparent_tcp_connection( Some(&host), MappingLookupError::EndpointMismatch, ); - emit_activity(&activity_tx, true, "transparent_tcp_mapping"); return Ok(()); } @@ -1312,7 +1300,6 @@ async fn handle_transparent_tcp_connection( Some(&host), MappingLookupError::StalePolicy, ); - emit_activity(&activity_tx, true, "transparent_tcp_mapping"); return Ok(()); }; let mapping = match dns.store().lookup( @@ -1324,7 +1311,6 @@ async fn handle_transparent_tcp_connection( Ok(mapping) => mapping, Err(error) => { emit_transparent_mapping_denial(workload_addr, original, Some(&host), error); - emit_activity(&activity_tx, true, "transparent_tcp_mapping"); return Ok(()); } }; @@ -1353,7 +1339,6 @@ async fn handle_transparent_tcp_connection( reason, "transparent-tcp", ); - emit_activity(&activity_tx, true, "transparent_tcp_policy"); return Ok(()); }; @@ -1374,7 +1359,6 @@ async fn handle_transparent_tcp_connection( None, agent_proposals, relay::RelaySignals { - activity: activity_tx.clone(), endpoint_observation: None, }, ); @@ -1421,7 +1405,6 @@ async fn handle_transparent_tcp_connection( "upstream proxy did not preserve the validated IP target", "transparent-tcp", ); - emit_activity(&activity_tx, true, "transparent_tcp_destination"); return Ok(()); } None => (Some(upstream_socket_peer), "direct"), @@ -1457,7 +1440,6 @@ async fn handle_transparent_tcp_connection( policy_name, } )); - emit_activity(&activity_tx, false, "transparent_tcp"); relay::relay_tcp(&mut client, &mut upstream, &generation_guard, &ctx).await } @@ -1759,12 +1741,6 @@ fn classify_accept_error( } } -fn emit_activity(tx: &Option, denied: bool, deny_group: &'static str) { - if let Some(tx) = tx { - let _ = try_record_activity(tx, denied, deny_group); - } -} - fn l7_inspection_active(l7_route: Option<&L7RouteSnapshot>) -> bool { l7_route.is_some_and(|route| !route.configs.is_empty()) } @@ -1885,33 +1861,6 @@ where } } -fn emit_connect_activity_if_l4_only( - tx: &Option, - l7_route: Option<&L7RouteSnapshot>, -) { - if !l7_inspection_active(l7_route) { - emit_activity(tx, false, "unknown"); - } -} - -fn emit_activity_simple(tx: Option<&ActivitySender>, denied: bool, deny_group: &'static str) { - if let Some(tx) = tx { - let _ = try_record_activity(tx, denied, deny_group); - } -} - -fn emit_forward_success_activity(tx: Option<&ActivitySender>, l7_activity_pending: bool) { - emit_activity_simple( - tx, - false, - if l7_activity_pending { - "l7_policy" - } else { - "unknown" - }, - ); -} - /// Body-aware policy state carried from forward L7 admission to middleware /// execution. The selected route and its captured policy engine stay paired so /// middleware cannot be invoked with only half of the re-evaluation context. @@ -2389,7 +2338,6 @@ async fn deny_connect_destination( actor: &Process, decision: &EgressDecision, denial_tx: &Option>, - activity_tx: &Option, ) -> Result<()> where C: TokioAsyncWrite + Unpin, @@ -2408,11 +2356,6 @@ where &denial.reason, "ssrf", ); - // Preserve the current activity contract. The declared-endpoint branch - // historically emits the denial without a separate SSRF activity count. - if denial.kind != DestinationDenialKind::DeclaredEndpoint { - emit_activity(activity_tx, true, "ssrf"); - } respond( client, &build_json_error_response( @@ -2440,7 +2383,6 @@ async fn deny_forward_destination( policy: &str, decision: &EgressDecision, denial_tx: Option<&mpsc::UnboundedSender>, - activity_tx: Option<&ActivitySender>, correlation: Option<&crate::l7::correlation::RequestCorrelation>, ) -> Result<()> where @@ -2466,11 +2408,6 @@ where &denial.reason, "ssrf", ); - // Preserve the current activity contract. The declared-endpoint branch - // historically emits the denial without a separate SSRF activity count. - if denial.kind != DestinationDenialKind::DeclaredEndpoint { - emit_activity_simple(activity_tx, true, "ssrf"); - } respond( client, &build_json_error_response_with_request_id( @@ -2537,7 +2474,6 @@ async fn handle_tcp_connection( provider_credentials: Option, secret_resolver: Option>, denial_tx: Option>, - activity_tx: Option, endpoint_observation_tx: Option, ) -> Result<()> { let socket_addrs = client.peer_addr().ok().zip(client.local_addr().ok()); @@ -2560,7 +2496,6 @@ async fn handle_tcp_connection( provider_credentials, secret_resolver, denial_tx, - activity_tx, endpoint_observation_tx, None, )) @@ -2632,7 +2567,6 @@ async fn handle_mediated_connection( provider_credentials: Option, secret_resolver: Option>, denial_tx: Option>, - activity_tx: Option, endpoint_observation_tx: Option, required_proxy_authorization: Option>, ) -> Result<()> { @@ -2818,7 +2752,6 @@ async fn handle_mediated_connection( provider_credentials, secret_resolver, denial_tx.as_ref(), - activity_tx.as_ref(), endpoint_observation_tx, )) .await; @@ -2907,7 +2840,6 @@ async fn handle_mediated_connection( &deny_reason, "connect", ); - emit_activity(&activity_tx, true, "connect_policy"); respond( &mut client, &build_json_error_response_with_reason( @@ -2926,14 +2858,7 @@ async fn handle_mediated_connection( match relay::pin_policy_generation(&opa_engine, decision.policy_generation) { Ok(guard) => guard, Err(error) => { - reject_stale_connect_policy( - &mut client, - &host_lc, - port, - activity_tx.as_ref(), - error, - ) - .await?; + reject_stale_connect_policy(&mut client, &host_lc, port, error).await?; return Ok(()); } }; @@ -2997,7 +2922,6 @@ async fn handle_mediated_connection( &actor, &decision, &denial_tx, - &activity_tx, ) .await?; return Ok(()); @@ -3038,7 +2962,6 @@ async fn handle_mediated_connection( &actor, &decision, &denial_tx, - &activity_tx, ) .await?; return Ok(()); @@ -3075,7 +2998,6 @@ async fn handle_mediated_connection( .status_detail(TLS_TERMINATION_UNAVAILABLE_DETAIL) .build(); egress_emit!(event); - emit_activity_simple(activity_tx.as_ref(), true, "tls_termination_unavailable"); emit_denial( &denial_tx, &host_lc, @@ -3115,7 +3037,6 @@ async fn handle_mediated_connection( policy_str, if effective_tls_skip { "tls-skip" } else { "l4" }, ); - emit_activity_simple(activity_tx.as_ref(), true, "uninspected_credentials"); emit_denial( &denial_tx, &host_lc, @@ -3139,8 +3060,7 @@ async fn handle_mediated_connection( if let Err(error) = relay::validate_route_generation(l7_route, connect_generation_guard.captured_generation()) { - reject_stale_connect_policy(&mut client, &host_lc, port, activity_tx.as_ref(), error) - .await?; + reject_stale_connect_policy(&mut client, &host_lc, port, error).await?; return Ok(()); } @@ -3152,7 +3072,6 @@ async fn handle_mediated_connection( policy_local_ctx.as_deref(), agent_proposals, relay::RelaySignals { - activity: activity_tx.clone(), endpoint_observation: endpoint_observation_tx, }, ); @@ -3198,7 +3117,6 @@ async fn handle_mediated_connection( &mut client, &host_lc, port, - activity_tx.as_ref(), miette::miette!( "policy changed while CONNECT was dialing upstream \ [captured_generation:{} current_generation:{}]", @@ -3220,8 +3138,7 @@ async fn handle_mediated_connection( } }; if let Err(error) = connect_generation_guard.ensure_current() { - reject_stale_connect_policy(&mut client, &host_lc, port, activity_tx.as_ref(), error) - .await?; + reject_stale_connect_policy(&mut client, &host_lc, port, error).await?; return Ok(()); } @@ -3242,7 +3159,6 @@ async fn handle_mediated_connection( policy_str, should_inspect_l7, )); - emit_connect_activity_if_l4_only(&activity_tx, l7_route); // `effective_tls_skip` was resolved before the `200` above (the fail-closed // gate needs it) and drives the raw-tunnel branch below. @@ -3362,7 +3278,6 @@ async fn handle_mediated_connection( .status_detail(DETAIL) .build(); egress_emit!(event); - emit_activity_simple(activity_tx.as_ref(), true, "tls_termination_unavailable"); emit_denial( &denial_tx, &host_lc, @@ -3432,7 +3347,6 @@ async fn handle_mediated_connection( .status_detail(protocol_detail) .build(); egress_emit!(event); - emit_activity_simple(activity_tx.as_ref(), true, "l7_parse_rejection"); emit_denial( &denial_tx, &host_lc, @@ -4050,7 +3964,6 @@ async fn reject_stale_connect_policy( client: &mut C, host: &str, port: u16, - activity_tx: Option<&ActivitySender>, error: miette::Report, ) -> Result<()> where @@ -4063,7 +3976,6 @@ where "CONNECT rejected because policy changed after L4 authorization" ); emit_l7_tunnel_close_after_policy_change(host, port, error); - emit_activity_simple(activity_tx, true, "policy_stale"); respond( client, &build_json_error_response( @@ -5554,7 +5466,6 @@ async fn handle_forward_proxy( provider_credentials: Option, secret_resolver: Option>, denial_tx: Option<&mpsc::UnboundedSender>, - activity_tx: Option<&ActivitySender>, endpoint_observation_tx: Option, ) -> Result<()> { Box::pin(crate::l7::correlation::scope_connection( @@ -5576,7 +5487,6 @@ async fn handle_forward_proxy( provider_credentials, secret_resolver, denial_tx, - activity_tx, endpoint_observation_tx, ), )) @@ -5602,7 +5512,6 @@ async fn handle_forward_proxy_inner( provider_credentials: Option, secret_resolver: Option>, denial_tx: Option<&mpsc::UnboundedSender>, - activity_tx: Option<&ActivitySender>, endpoint_observation_tx: Option, ) -> Result<()> { let endpoint_observation_context = endpoint_observation_tx @@ -5777,7 +5686,6 @@ async fn handle_forward_proxy_inner( reason, "forward", ); - emit_activity_simple(activity_tx, true, "forward_policy"); respond( client, &build_json_error_response( @@ -5819,7 +5727,6 @@ async fn handle_forward_proxy_inner( "Forward proxy rejected request because policy generation changed after L4 decision" ); emit_l7_tunnel_close_after_policy_change(&host_lc, port, e); - emit_activity_simple(activity_tx, true, "policy_stale"); respond( client, &build_json_error_response( @@ -5847,7 +5754,6 @@ async fn handle_forward_proxy_inner( crate::l7::rest::request_is_websocket_upgrade(&forward_request_bytes); let mut request_body_credential_rewrite = false; let mut deny_uninspected_credentials = false; - let mut l7_activity_pending = false; // 4b. If the endpoint has L7 config, evaluate the request against // L7 policy. The forward proxy handles exactly one request per @@ -5873,7 +5779,6 @@ async fn handle_forward_proxy_inner( format!("FORWARD rejecting non-canonical request-target: {error}"), ); egress_emit!(event); - emit_activity_simple(activity_tx, true, "forward_parse_rejection"); respond( client, &build_json_error_response( @@ -5903,7 +5808,6 @@ async fn handle_forward_proxy_inner( policy_local_ctx.as_deref(), agent_proposals, relay::RelaySignals { - activity: activity_tx.cloned(), endpoint_observation: endpoint_observation_tx, }, ); @@ -5967,7 +5871,6 @@ async fn handle_forward_proxy_inner( route.l7_policy_generation, ), ); - emit_activity_simple(activity_tx, true, "policy_stale"); correlation.record_rejection(403, HttpOutcome::Denied, None); respond( client, @@ -5994,7 +5897,6 @@ async fn handle_forward_proxy_inner( "Forward proxy rejected request because L7 tunnel engine could not be cloned" ); emit_l7_tunnel_close_after_policy_change(&host_lc, port, e); - emit_activity_simple(activity_tx, true, "policy_stale"); correlation.record_rejection(403, HttpOutcome::Denied, None); respond( client, @@ -6034,7 +5936,6 @@ async fn handle_forward_proxy_inner( }; let Some(l7_config) = select_l7_config_for_path(&route.configs, &redacted_path) else { correlation.record_rejection(403, HttpOutcome::Denied, None); - emit_activity_simple(activity_tx, true, "l7_policy"); respond( client, &build_json_error_response_with_request_id( @@ -6078,7 +5979,6 @@ async fn handle_forward_proxy_inner( policy_str, FORWARD_ENCODED_SLASH_REJECTION_DETAIL, )); - emit_activity_simple(activity_tx, true, "forward_parse_rejection"); respond( client, &build_json_error_response_with_request_id( @@ -6124,7 +6024,6 @@ async fn handle_forward_proxy_inner( .status_detail(upgrade_detail) .build(); correlation.emit(event); - emit_activity_simple(activity_tx, true, "l7_parse_rejection"); emit_denial_simple( denial_tx, &host_lc, @@ -6189,7 +6088,6 @@ async fn handle_forward_proxy_inner( format!("FORWARD_GRAPHQL_L7 request rejected: {e}"), ); correlation.emit(event); - emit_activity_simple(activity_tx, true, "l7_parse_rejection"); respond( client, &build_json_error_response_with_request_id( @@ -6243,7 +6141,6 @@ async fn handle_forward_proxy_inner( format!("FORWARD_JSONRPC_L7 request rejected: {e}"), ); correlation.emit(event); - emit_activity_simple(activity_tx, true, "l7_parse_rejection"); respond( client, &build_json_error_response_with_request_id( @@ -6398,7 +6295,6 @@ async fn handle_forward_proxy_inner( if effectively_denied { correlation.record_outcome(HttpOutcome::Denied); correlation.record_response_status(403); - emit_activity_simple(activity_tx, true, "l7_policy"); emit_denial_simple( denial_tx, &host_lc, @@ -6423,7 +6319,6 @@ async fn handle_forward_proxy_inner( .await?; return Ok(()); } - l7_activity_pending = true; forward_tunnel_engine = Some(tunnel_engine); forward_l7_reeval = Some((l7_config.config.clone(), request_info)); } @@ -6453,7 +6348,6 @@ async fn handle_forward_proxy_inner( policy_str, &decision, denial_tx, - activity_tx, request_correlation, ) .await?; @@ -6506,7 +6400,6 @@ async fn handle_forward_proxy_inner( policy_str, &decision, denial_tx, - activity_tx, request_correlation, ) .await?; @@ -6524,7 +6417,6 @@ async fn handle_forward_proxy_inner( "Forward proxy rejected request because policy changed before upstream connect" ); emit_l7_tunnel_close_after_policy_change(&host_lc, port, e); - emit_activity_simple(activity_tx, true, "policy_stale"); correlation.record_rejection(403, HttpOutcome::Denied, None); respond( client, @@ -6611,7 +6503,6 @@ async fn handle_forward_proxy_inner( )); } crate::l7::middleware::MiddlewareApplyResult::RequestTimeout => { - emit_activity_simple(activity_tx, true, "middleware"); correlation.record_rejection( 408, HttpOutcome::PlatformError, @@ -6629,7 +6520,6 @@ async fn handle_forward_proxy_inner( return Ok(()); } crate::l7::middleware::MiddlewareApplyResult::Denied { denial, failure } => { - emit_activity_simple(activity_tx, true, "middleware"); correlation.record_rejection( 403, if denial.is_some() { @@ -6656,7 +6546,6 @@ async fn handle_forward_proxy_inner( return Ok(()); } crate::l7::middleware::MiddlewareApplyResult::AdmissionExhausted => { - emit_activity_simple(activity_tx, true, "middleware"); correlation.record_rejection( 503, HttpOutcome::PlatformError, @@ -7251,7 +7140,6 @@ async fn handle_forward_proxy_inner( &actor, policy_str, )); - emit_forward_success_activity(activity_tx, l7_activity_pending); match outcome { crate::l7::provider::RelayOutcome::Reusable @@ -8382,7 +8270,6 @@ process: { run_as_user: sandbox, run_as_group: sandbox } None, None, None, - None, )) .await .unwrap(); @@ -8641,7 +8528,6 @@ process: { run_as_user: sandbox, run_as_group: sandbox } None, None, None, - None, )); let server = async { let mut upstream = tokio::select! { @@ -9135,7 +9021,6 @@ process: {{ run_as_user: sandbox, run_as_group: sandbox }} None, None, None, - None, )); workload .write_all(b"GET /v1/policy/current HTTP/1.1\r\nHost: policy.local\r\nConnection: close\r\n\r\n") @@ -9267,7 +9152,6 @@ network_policies: None, None, None, - None, )); let request = tokio::select! { result = tokio::time::timeout(std::time::Duration::from_secs(5), request_rx) => @@ -10189,7 +10073,6 @@ network_policies: {} None, None, None, - None, )) .await .expect("malformed request should be handled"); @@ -10219,7 +10102,6 @@ network_policies: {} None, None, None, - None, ready_rx, &upstream_proxy::UpstreamProxyArgs::default(), None, @@ -10315,7 +10197,7 @@ network_policies: Some(("192.0.2.20:42123".parse().unwrap(), "192.0.2.10:3128".parse().unwrap())), engine, Arc::new(BinaryIdentityCache::new()), Arc::new(AtomicU32::new(0)), None, AgentProposals::default(), Arc::new(None), Arc::new(None), - None, None, None, None, None, + None, None, None, None, )).await; drop(proxy); result @@ -10375,7 +10257,7 @@ network_policies: } #[tokio::test] - async fn forward_upstream_eof_returns_502_and_preserves_allow_activity() { + async fn forward_upstream_eof_returns_502() { let Some(ip) = non_loopback_test_ipv4() else { eprintln!("skipping: no non-loopback IPv4 address"); return; @@ -10418,7 +10300,6 @@ network_policies: let request = format!("GET {target} HTTP/1.1\r\nHost: {ip}:{port}\r\n\r\n"); let (mut app, client) = tokio::io::duplex(8192); let mut client: ProxyClient = tokio::io::BufReader::new(Box::new(client)); - let (activity, mut events) = mpsc::channel(4); Box::pin(handle_forward_proxy( "GET", &target, @@ -10437,7 +10318,6 @@ network_policies: None, None, None, - Some(&activity), None, )) .await @@ -10451,10 +10331,6 @@ network_policies: ); assert!(response.contains("x-openshell-request-id:")); assert!(response.contains("Connection: close\r\n")); - assert!( - !events.try_recv().unwrap().denied, - "allowed decision must survive upstream EOF" - ); server.await.unwrap(); }) .await @@ -10634,7 +10510,6 @@ network_policies: None, None, None, - None, )), )) .await @@ -10765,7 +10640,6 @@ network_policies: None, None, None, - None, )), ) .await @@ -10883,7 +10757,6 @@ network_policies: None, None, None, - None, )), ) .await @@ -11010,7 +10883,6 @@ network_policies: None, None, None, - None, )), ) .await @@ -11152,7 +11024,6 @@ network_policies: None, None, None, - None, )) .await }); @@ -11913,40 +11784,6 @@ network_policies: ); } - #[test] - fn connect_activity_is_skipped_when_l7_will_count_the_request() { - let (tx, mut rx) = mpsc::channel(4); - let activity_tx = Some(tx); - let l7_route = L7RouteSnapshot { - configs: vec![L7ConfigSnapshot { - config: websocket_l7_config(crate::l7::L7Protocol::Rest, false), - }], - l7_policy_generation: 1, - }; - let l4_route = L7RouteSnapshot { - configs: Vec::new(), - l7_policy_generation: 1, - }; - - emit_connect_activity_if_l4_only(&activity_tx, Some(&l7_route)); - assert!( - rx.try_recv().is_err(), - "L7-inspected CONNECT should not emit an extra L4 activity event" - ); - - emit_connect_activity_if_l4_only(&activity_tx, Some(&l4_route)); - let event = rx.try_recv().expect("L4-only CONNECT should emit activity"); - assert!(!event.denied); - assert_eq!(event.deny_group, "unknown"); - - emit_connect_activity_if_l4_only(&activity_tx, None); - let event = rx - .try_recv() - .expect("CONNECT without an L7 route should emit activity"); - assert!(!event.denied); - assert_eq!(event.deny_group, "unknown"); - } - #[test] fn l7_hard_deny_reason_includes_jsonrpc_errors() { let cases: &[(&[u8], &str)] = &[ @@ -12266,66 +12103,6 @@ network_policies: ); } - #[test] - fn forward_l7_allowed_activity_is_deferred_until_after_ssrf() { - let (tx, mut rx) = mpsc::channel(4); - let activity_tx = Some(tx); - - let l7_activity_pending = true; - assert!( - rx.try_recv().is_err(), - "allowed L7 evaluation must not emit activity before SSRF succeeds" - ); - - emit_activity_simple(activity_tx.as_ref(), true, "ssrf"); - let event = rx - .try_recv() - .expect("SSRF denial should emit the request activity"); - assert!(event.denied); - assert_eq!(event.deny_group, "ssrf"); - assert!( - rx.try_recv().is_err(), - "SSRF-denied forward request must not also emit allowed L7 activity" - ); - - emit_forward_success_activity(activity_tx.as_ref(), l7_activity_pending); - let event = rx - .try_recv() - .expect("L7 activity should emit after SSRF succeeds"); - assert!(!event.denied); - assert_eq!(event.deny_group, "l7_policy"); - } - - #[test] - fn forward_middleware_denial_does_not_emit_success_activity() { - let (tx, mut rx) = mpsc::channel(4); - let activity_tx = Some(tx); - - emit_activity_simple(activity_tx.as_ref(), true, "middleware"); - let event = rx - .try_recv() - .expect("middleware denial should emit the request activity"); - assert!(event.denied); - assert_eq!(event.deny_group, "middleware"); - assert!( - rx.try_recv().is_err(), - "middleware-denied forward request must not emit success activity" - ); - } - - #[test] - fn forward_success_activity_uses_unknown_without_l7() { - let (tx, mut rx) = mpsc::channel(4); - let activity_tx = Some(tx); - - emit_forward_success_activity(activity_tx.as_ref(), false); - let event = rx - .try_recv() - .expect("non-L7 forward success should emit activity"); - assert!(!event.denied); - assert_eq!(event.deny_group, "unknown"); - } - fn forward_test_guard() -> PolicyGenerationGuard { let policy = include_str!("../data/sandbox-policy.rego"); let policy_data = "network_policies: {}\n"; @@ -16225,7 +16002,6 @@ network_policies: None, // provider_credentials None, // secret_resolver Some(denial_tx), // denial_tx — positive allow/deny signal - None, // activity_tx None, // endpoint_observation_tx )), ) @@ -16297,7 +16073,6 @@ network_policies: None, Some(denial_tx), None, - None, )) .await .expect("forward handler should complete"); diff --git a/crates/openshell-supervisor-network/src/proxy/relay.rs b/crates/openshell-supervisor-network/src/proxy/relay.rs index b982702186..98b7b31b06 100644 --- a/crates/openshell-supervisor-network/src/proxy/relay.rs +++ b/crates/openshell-supervisor-network/src/proxy/relay.rs @@ -7,7 +7,6 @@ use super::{EgressDecision, L7RouteSnapshot, emit_l7_tunnel_close_after_policy_c use crate::l7::relay::L7EvalContext; use crate::opa::{NetworkAction, OpaEngine, PolicyGenerationGuard, TunnelPolicyEngine}; use miette::{IntoDiagnostic, Result}; -use openshell_core::activity::ActivitySender; use openshell_core::endpoint_status::EndpointObservationSender; use openshell_core::secrets::SecretResolver; use std::sync::Arc; @@ -36,8 +35,6 @@ pub(super) struct RelayContext<'a> { /// Non-blocking observation channels attached to an authorized HTTP relay. pub(super) struct RelaySignals { - /// Receives general sandbox network activity. - pub(super) activity: Option, /// Receives terminal tool server results for endpoint status reporting. pub(super) endpoint_observation: Option, } @@ -96,7 +93,6 @@ pub(super) fn http_context( provider_credential_revision: None, provider_credential_installation_id: None, body_classifier: None, - activity_tx: signals.activity, token_grant_resolver, agent_proposals, workspace, @@ -410,7 +406,6 @@ mod tests { provider_credential_revision: None, provider_credential_installation_id: None, body_classifier: None, - activity_tx: None, token_grant_resolver: None, agent_proposals: openshell_core::proposals::AgentProposals::default(), workspace: String::new(), diff --git a/crates/openshell-supervisor-network/src/proxy/tests/compatibility.rs b/crates/openshell-supervisor-network/src/proxy/tests/compatibility.rs index 8037a09ea2..8db03233c0 100644 --- a/crates/openshell-supervisor-network/src/proxy/tests/compatibility.rs +++ b/crates/openshell-supervisor-network/src/proxy/tests/compatibility.rs @@ -103,7 +103,6 @@ async fn destination_denials_preserve_adapter_specific_wire_contracts() { &Process::from_bypass("/usr/bin/curl", "42", "/usr/bin/sh").with_cmd_line("curl"), &allowed_decision(EgressIntent::connect("target.example".to_string(), 8443)), &None, - &None, ) .await .unwrap(); @@ -152,7 +151,6 @@ async fn destination_denials_preserve_adapter_specific_wire_contracts() { 8080, )), None, - None, Some(&correlation), ) .await @@ -557,7 +555,6 @@ network_policies: None, None, None, - None, )) .await .unwrap(); diff --git a/crates/openshell-supervisor-network/src/proxy/tests/request_trace.rs b/crates/openshell-supervisor-network/src/proxy/tests/request_trace.rs index 597a5bc932..dc952d6083 100644 --- a/crates/openshell-supervisor-network/src/proxy/tests/request_trace.rs +++ b/crates/openshell-supervisor-network/src/proxy/tests/request_trace.rs @@ -139,7 +139,6 @@ network_policies: None, None, None, - None, ready_rx, &upstream_proxy::UpstreamProxyArgs::default(), None, @@ -435,7 +434,6 @@ network_policies: secret_resolver, None, None, - None, )) .await; drop(proxy); @@ -857,7 +855,6 @@ network_policies: None, None, None, - None, )) .await } diff --git a/crates/openshell-supervisor-network/src/proxy/trace_tests.rs b/crates/openshell-supervisor-network/src/proxy/trace_tests.rs index 2eab190a26..f031fa0cbf 100644 --- a/crates/openshell-supervisor-network/src/proxy/trace_tests.rs +++ b/crates/openshell-supervisor-network/src/proxy/trace_tests.rs @@ -134,7 +134,6 @@ async fn forward_denials_use_the_saved_connect_parent() { &decision, None, None, - None, )) .unwrap(); assert!(output.starts_with(b"HTTP/1.1 403 Forbidden")); diff --git a/crates/openshell-supervisor-network/src/run.rs b/crates/openshell-supervisor-network/src/run.rs index 9eb744da2b..00ad5a0a56 100644 --- a/crates/openshell-supervisor-network/src/run.rs +++ b/crates/openshell-supervisor-network/src/run.rs @@ -25,7 +25,6 @@ use openshell_ocsf::{ ConfigStateChangeBuilder, SeverityId, StateId, StatusId, ctx::ctx as ocsf_ctx, }; -use openshell_core::activity::ActivitySender; use openshell_core::denial::DenialEvent; use openshell_core::proposals::AgentProposals; use tokio::sync::mpsc::UnboundedSender; @@ -286,7 +285,6 @@ pub async fn run_networking( provider_credentials: &ProviderCredentialState, instance: SandboxInstanceNetwork, denial_tx: Option>, - activity_tx: Option, endpoint_observation_tx: Option, agent_proposals: AgentProposals, workspace_rx: tokio::sync::watch::Receiver, @@ -610,7 +608,6 @@ pub async fn run_networking( Some(provider_credentials.clone()), Some(policy_local_ctx.clone()), denial_tx.clone(), - activity_tx.clone(), endpoint_observation_tx, engine_ready_rx, upstream_proxy_args, @@ -658,7 +655,6 @@ pub async fn run_networking( entrypoint_pid, agent_proposals, denial_tx, - activity_tx, upstream_proxy_args, transparent_engine_ready_rx, )?; diff --git a/crates/openshell-supervisor/src/activity_aggregator.rs b/crates/openshell-supervisor/src/activity_aggregator.rs deleted file mode 100644 index 33605c1df9..0000000000 --- a/crates/openshell-supervisor/src/activity_aggregator.rs +++ /dev/null @@ -1,224 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -//! Anonymous supervised network activity counter aggregation. -//! -//! Producer-side types (`ActivityEvent`, `ActivitySender`, -//! `ACTIVITY_EVENT_QUEUE_CAPACITY`, `try_record_activity`) live in -//! `openshell_core::activity` so the supervisor leaves can emit without -//! depending on the orchestrator. This module hosts the aggregator that -//! runs orchestrator-side and flushes summaries to the gateway. - -use std::collections::HashMap; -use std::future::Future; -use tokio::sync::mpsc; -use tracing::{debug, warn}; - -pub use openshell_core::activity::ActivityEvent; - -const ACTIVITY_FLUSH_QUEUE_CAPACITY: usize = 1; -pub const DEFAULT_ACTIVITY_FLUSH_INTERVAL_SECS: u64 = 10; - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct FlushableActivitySummary { - pub network_activity_count: u32, - pub denied_action_count: u32, - pub denials_by_group: Vec<(String, u32)>, -} - -pub struct ActivityAggregator { - rx: mpsc::Receiver, - network_activity_count: u32, - denied_action_count: u32, - denials_by_group: HashMap, - flush_interval_secs: u64, -} - -impl ActivityAggregator { - pub fn new(rx: mpsc::Receiver, flush_interval_secs: u64) -> Self { - Self { - rx, - network_activity_count: 0, - denied_action_count: 0, - denials_by_group: HashMap::new(), - flush_interval_secs, - } - } - - /// `ready_gate` is checked before each flush. When it returns `false`, - /// the drain is skipped and events stay in the buffer until the next tick. - pub async fn run(mut self, flush_callback: F, ready_gate: G) - where - F: Fn(FlushableActivitySummary) -> Fut + Send + 'static, - Fut: Future + Send + 'static, - G: Fn() -> bool, - { - let (flush_tx, mut flush_rx) = - mpsc::channel::(ACTIVITY_FLUSH_QUEUE_CAPACITY); - tokio::spawn(async move { - while let Some(summary) = flush_rx.recv().await { - flush_callback(summary).await; - } - }); - - let mut flush_interval = - tokio::time::interval(std::time::Duration::from_secs(self.flush_interval_secs)); - flush_interval.tick().await; - - loop { - tokio::select! { - event = self.rx.recv() => { - if let Some(event) = event { - self.ingest(event); - } else { - if self.network_activity_count > 0 { - if ready_gate() { - if let Some(summary) = self.drain() { - queue_flush_summary(&flush_tx, summary); - } - } else { - warn!( - count = self.network_activity_count, - "ActivityAggregator: dropping unflushed events, workspace not yet known" - ); - } - } - debug!("ActivityAggregator: channel closed, exiting"); - return; - } - } - _ = flush_interval.tick() => { - if ready_gate() - && let Some(summary) = self.drain() - { - debug!( - count = summary.network_activity_count, - denied = summary.denied_action_count, - "ActivityAggregator: flushing anonymous activity summary" - ); - queue_flush_summary(&flush_tx, summary); - } - } - } - } - } - - fn ingest(&mut self, event: ActivityEvent) { - self.network_activity_count = self.network_activity_count.saturating_add(1); - if event.denied { - self.denied_action_count = self.denied_action_count.saturating_add(1); - let group = sanitize_deny_group(event.deny_group).to_string(); - let count = self.denials_by_group.entry(group).or_default(); - *count = count.saturating_add(1); - } - } - - fn drain(&mut self) -> Option { - if self.network_activity_count == 0 { - return None; - } - let mut denials_by_group: Vec<(String, u32)> = self.denials_by_group.drain().collect(); - denials_by_group.sort_by(|left, right| left.0.cmp(&right.0)); - let summary = FlushableActivitySummary { - network_activity_count: self.network_activity_count, - denied_action_count: self.denied_action_count, - denials_by_group, - }; - self.network_activity_count = 0; - self.denied_action_count = 0; - Some(summary) - } -} - -pub fn activity_flush_interval_secs_from_env(value: Option<&str>) -> u64 { - value - .and_then(|value| value.parse::().ok()) - .filter(|value| *value > 0) - .unwrap_or(DEFAULT_ACTIVITY_FLUSH_INTERVAL_SECS) -} - -fn queue_flush_summary( - tx: &mpsc::Sender, - summary: FlushableActivitySummary, -) -> bool { - tx.try_send(summary).is_ok() -} - -pub fn sanitize_deny_group(raw: &str) -> &'static str { - match raw { - "connect_policy" | "connect" | "l4_deny" => "connect_policy", - "forward_policy" | "forward" => "forward_policy", - "l7_policy" | "l7" | "l7_deny" | "forward-l7-deny" => "l7_policy", - "l7_parse_rejection" | "parse_rejection" => "l7_parse_rejection", - "ssrf" => "ssrf", - "bypass" => "bypass", - "policy_stale" => "policy_stale", - _ => "unknown", - } -} - -#[cfg(test)] -fn denial_rate_pct(network_activity_count: u32, denied_action_count: u32) -> f64 { - if network_activity_count == 0 { - return 0.0; - } - ((f64::from(denied_action_count) / f64::from(network_activity_count)) * 100.0).clamp(0.0, 100.0) -} - -#[cfg(test)] -mod tests { - use super::*; - - fn assert_float_eq(actual: f64, expected: f64) { - assert!((actual - expected).abs() <= f64::EPSILON); - } - - #[test] - fn deny_group_sanitization_uses_allowlist() { - assert_eq!(sanitize_deny_group("connect"), "connect_policy"); - assert_eq!(sanitize_deny_group("forward-l7-deny"), "l7_policy"); - assert_eq!(sanitize_deny_group("host=example.test/path"), "unknown"); - assert_eq!(sanitize_deny_group("acme.internal:443"), "unknown"); - assert_eq!( - sanitize_deny_group("binary=/usr/local/bin/private"), - "unknown" - ); - } - - #[test] - fn denial_rate_handles_zero_and_clamps() { - assert_float_eq(denial_rate_pct(0, 10), 0.0); - assert_float_eq(denial_rate_pct(4, 1), 25.0); - assert_float_eq(denial_rate_pct(4, 10), 100.0); - } - - #[test] - fn flush_summary_drops_when_queue_is_full() { - let (tx, _rx) = mpsc::channel(1); - let summary = FlushableActivitySummary { - network_activity_count: 1, - denied_action_count: 0, - denials_by_group: Vec::new(), - }; - - assert!(queue_flush_summary(&tx, summary.clone())); - assert!(!queue_flush_summary(&tx, summary)); - } - - #[test] - fn activity_flush_interval_uses_positive_values_only() { - assert_eq!( - activity_flush_interval_secs_from_env(None), - DEFAULT_ACTIVITY_FLUSH_INTERVAL_SECS - ); - assert_eq!( - activity_flush_interval_secs_from_env(Some("not-a-number")), - DEFAULT_ACTIVITY_FLUSH_INTERVAL_SECS - ); - assert_eq!( - activity_flush_interval_secs_from_env(Some("0")), - DEFAULT_ACTIVITY_FLUSH_INTERVAL_SECS - ); - assert_eq!(activity_flush_interval_secs_from_env(Some("5")), 5); - } -} diff --git a/crates/openshell-supervisor/src/lib.rs b/crates/openshell-supervisor/src/lib.rs index 9d4b96436c..3aceec8ec1 100644 --- a/crates/openshell-supervisor/src/lib.rs +++ b/crates/openshell-supervisor/src/lib.rs @@ -7,7 +7,6 @@ #![forbid(unsafe_code)] -mod activity_aggregator; pub mod app_listener; pub mod backend_setup; mod config_runtime; @@ -741,7 +740,6 @@ pub async fn run_network_proxy( }, None, None, - None, AgentProposals::new(initial_agent_proposals_enabled), workspace_rx, &upstream_proxy_args, @@ -1379,18 +1377,6 @@ pub async fn run_sandbox_instance( (None, None) }; - // Anonymous activity channel: same orchestrator-owned pattern as the - // denial channel. The proxy and the bypass monitor both emit per-event - // activity records; the orchestrator-side aggregator drains, sanitizes, - // and flushes anonymous summaries to the gateway. - let (activity_tx, activity_rx) = if sandbox_id.is_some() { - let (tx, rx) = - tokio::sync::mpsc::channel(openshell_core::activity::ACTIVITY_EVENT_QUEUE_CAPACITY); - (Some(tx), Some(rx)) - } else { - (None, None) - }; - // Endpoint observations are bounded and never backpressure proxied traffic. // Reports are authorized by the currently accepted supervisor session. let (endpoint_observation_tx, endpoint_status_rx) = if sandbox_id.is_some() { @@ -1471,7 +1457,6 @@ pub async fn run_sandbox_instance( proxy_tls, }, denial_tx, - activity_tx, endpoint_observation_tx.clone(), agent_proposals.clone(), workspace_rx.clone(), @@ -1572,51 +1557,6 @@ pub async fn run_sandbox_instance( }); } - // Spawn the activity-aggregator flush task. The aggregator drains - // anonymous activity events from the proxy, sanitizes deny groups, - // and ships periodic summaries to the gateway. - if let (Some(rx), Some(gateway)) = (activity_rx, gateway.as_ref()) { - let agg_name = sandbox_name_for_agg - .clone() - .or_else(|| sandbox_id.clone()) - .unwrap_or_default(); - let agg_gateway = gateway.clone(); - let flush_interval_secs = activity_aggregator::activity_flush_interval_secs_from_env( - std::env::var("OPENSHELL_ACTIVITY_FLUSH_INTERVAL_SECS") - .ok() - .as_deref(), - ); - - let aggregator = activity_aggregator::ActivityAggregator::new(rx, flush_interval_secs); - let activity_workspace_gate = workspace_rx.clone(); - let activity_workspace_rx = workspace_rx.clone(); - - tokio::spawn(async move { - aggregator - .run( - move |summary| { - let gateway = agg_gateway.clone(); - let sandbox_name = agg_name.clone(); - let workspace = activity_workspace_rx.borrow().clone(); - async move { - if let Err(e) = flush_activity_to_gateway( - &gateway, - &sandbox_name, - &workspace, - summary, - ) - .await - { - warn!(error = %e, "Failed to flush activity summary to gateway"); - } - } - }, - move || !activity_workspace_gate.borrow().is_empty(), - ) - .await; - }); - } - let app_instance = match app_router { Some(router) => { @@ -2143,59 +2083,7 @@ async fn flush_proposals_to_gateway( ); client - .submit_policy_analysis( - sandbox_name, - proto_summaries, - proposals, - Vec::new(), - "mechanistic", - ) - .await?; - - Ok(()) -} - -/// Flush an anonymous activity summary to the gateway via `SubmitPolicyAnalysis`. -async fn flush_activity_to_gateway( - gateway: &openshell_core::grpc_client::GatewayEndpoint, - sandbox_name: &str, - workspace: &str, - summary: activity_aggregator::FlushableActivitySummary, -) -> Result<()> { - use openshell_core::grpc_client::CachedOpenShellClient; - use openshell_core::proto::{DenialGroupCount, NetworkActivitySummary}; - - let client = CachedOpenShellClient::connect(gateway).await?; - client.set_workspace(workspace.to_string()); - - let proto_summary = NetworkActivitySummary { - network_activity_count: summary.network_activity_count, - denied_action_count: summary.denied_action_count, - denials_by_group: summary - .denials_by_group - .into_iter() - .map(|(group, count)| DenialGroupCount { - deny_group: group, - denied_count: count, - }) - .collect(), - }; - - info!( - sandbox_name = %sandbox_name, - network_activity_count = proto_summary.network_activity_count, - denied_action_count = proto_summary.denied_action_count, - "Flushed activity summary to gateway" - ); - - client - .submit_policy_analysis( - sandbox_name, - Vec::new(), - Vec::new(), - vec![proto_summary], - "activity", - ) + .submit_policy_analysis(sandbox_name, proto_summaries, proposals, "mechanistic") .await?; Ok(()) diff --git a/deploy/helm/openshell/README.md b/deploy/helm/openshell/README.md index deed9fc708..95cb0fee60 100644 --- a/deploy/helm/openshell/README.md +++ b/deploy/helm/openshell/README.md @@ -793,7 +793,6 @@ for peer identity policies, multi-node registrations, and authorization. | server.sandboxNamespace | string | `""` | Namespace where sandbox pods are created. Defaults to the Helm release namespace (.Release.Namespace) when left empty. | | server.sandboxUid | string | `""` | UID for sandbox pods (`sandbox_uid`). Empty (default) = use the OpenShift SCC namespace annotation if present, otherwise the driver default. Must be an integer between 1 and 4294967294. | | server.serviceHostnameFormat | string | `""` | Hostname format for exposed sandbox services. Empty or "readable" keeps readable `--[--]` hostnames; "hashed" mints opaque one-label hostnames discriminated by the gateway installation name (server.name, defaulting to the release name). The name must be unique among all gateways sharing the service base domain, and renaming the installation changes every minted hostname. | -| server.telemetryEnabled | bool | `true` | Enable anonymous OpenShell telemetry from the gateway. | | server.tls.certSecretName | string | `"openshell-server-tls"` | K8s secret (type kubernetes.io/tls) with tls.crt and tls.key for the server. | | server.tls.clientCaSecretName | string | `"openshell-server-client-ca"` | K8s secret with ca.crt for client certificate verification (mTLS). Only used when enableMtls is true. Set to "" to disable client certificate verification for HTTPS-only mode. | | server.tls.clientTlsSecretName | string | `"openshell-client-tls"` | K8s secret mounted into sandbox pods for mTLS to the server. | diff --git a/deploy/helm/openshell/templates/_gateway-workload.tpl b/deploy/helm/openshell/templates/_gateway-workload.tpl index a478e25ac2..b79c95107c 100644 --- a/deploy/helm/openshell/templates/_gateway-workload.tpl +++ b/deploy/helm/openshell/templates/_gateway-workload.tpl @@ -139,8 +139,6 @@ spec: # dedicated writable volume for both StatefulSet and Deployment modes. - name: XDG_STATE_HOME value: /var/lib/openshell-state - - name: OPENSHELL_TELEMETRY_ENABLED - value: {{ .Values.server.telemetryEnabled | quote }} {{- if $spiffeSocketPath }} - name: OPENSHELL_GATEWAY_SPIFFE_WORKLOAD_API_SOCKET value: {{ $spiffeSocketPath | quote }} diff --git a/deploy/helm/openshell/tests/gateway_config_test.yaml b/deploy/helm/openshell/tests/gateway_config_test.yaml index de4ea98448..adc646e557 100644 --- a/deploy/helm/openshell/tests/gateway_config_test.yaml +++ b/deploy/helm/openshell/tests/gateway_config_test.yaml @@ -455,26 +455,6 @@ tests: path: spec.template.spec.containers[0].name value: openshell-gateway - - it: enables anonymous telemetry by default - template: templates/statefulset.yaml - asserts: - - contains: - path: spec.template.spec.containers[0].env - content: - name: OPENSHELL_TELEMETRY_ENABLED - value: "true" - - - it: disables anonymous telemetry when configured - template: templates/statefulset.yaml - set: - server.telemetryEnabled: false - asserts: - - contains: - path: spec.template.spec.containers[0].env - content: - name: OPENSHELL_TELEMETRY_ENABLED - value: "false" - - it: renders OTLP tracing configuration when configured template: templates/gateway-config.yaml set: diff --git a/deploy/helm/openshell/values.yaml b/deploy/helm/openshell/values.yaml index 3825068f29..fd5a587aaf 100644 --- a/deploy/helm/openshell/values.yaml +++ b/deploy/helm/openshell/values.yaml @@ -487,8 +487,6 @@ server: # -- Additional environment variables for the gateway container, such as # OTEL_* exporter settings. Entries can read from a Secret with valueFrom. extraEnv: [] - # -- Enable anonymous OpenShell telemetry from the gateway. - telemetryEnabled: true # -- Namespace where sandbox pods are created. Defaults to the Helm release # namespace (.Release.Namespace) when left empty. sandboxNamespace: "" diff --git a/docs/how-it-works/gateways/overview.mdx b/docs/how-it-works/gateways/overview.mdx index 093f73517a..b33ebc060f 100644 --- a/docs/how-it-works/gateways/overview.mdx +++ b/docs/how-it-works/gateways/overview.mdx @@ -33,6 +33,23 @@ A gateway provisions sandboxes through the compute driver configured for that ga All compute drivers expose the same gateway API surface. Sandboxes, policies, and providers work the same after the CLI registers the gateway endpoint. The difference is how the gateway creates sandbox workloads and how operators expose the gateway to users. +### Build a Gateway with Selected Drivers + +The gateway exposes separate Cargo features for its built-in compute drivers: `compute-driver-kubernetes`, `compute-driver-docker`, `compute-driver-podman`, `compute-driver-vm`, and `compute-driver-mxc`. Disable the default feature set, then enable only the drivers the target binary needs: + +```shell +# Docker only. +cargo build --release -p openshell-gateway --no-default-features --features compute-driver-docker + +# Docker and VM only. +cargo build --release -p openshell-gateway --no-default-features --features compute-driver-docker,compute-driver-vm + +# Windows MXC only, with prebuilt Z3. +cargo build --release -p openshell-gateway --no-default-features --features compute-driver-mxc,openshell-server/prebuilt-z3 +``` + +Regular builds keep their platform driver set through the default `in-tree-compute-drivers` compatibility feature. On Windows, `compute-driver-mxc` selects MXC and the other four features install unsupported-driver stubs. On other platforms, MXC is excluded. + For driver setup, including Docker, Podman, MicroVM, and Kubernetes paths, refer to [Installation](/about/installation). diff --git a/docs/kubernetes/setup.mdx b/docs/kubernetes/setup.mdx index 703bbdbaf0..0c8ca92a52 100644 --- a/docs/kubernetes/setup.mdx +++ b/docs/kubernetes/setup.mdx @@ -310,7 +310,6 @@ The most commonly changed values are: | `server.externalDbSecret` | Secret containing a PostgreSQL connection URI in the `uri` key. Use when the database is managed outside the chart. | | `server.dataStorageSize` | Storage request for the gateway data PVC under `workload.kind=statefulset`. Defaults to `1Gi`. Requires an explicit unit, such as `20Gi`. | | `server.dataStorageClass` | `StorageClass` for the gateway data PVC under `workload.kind=statefulset`. Empty (default) omits `storageClassName` and uses the cluster's default `StorageClass`. Use a block-backed class, not NFS. | -| `server.telemetryEnabled` | Enable anonymous OpenShell telemetry from the gateway. Set to `false` to opt out. | | `sandbox.image.repository` / `sandbox.image.tag` / `sandbox.image.digest` | Default sandbox image used when a sandbox does not specify one. | | `sandboxRuntime.image.registry` / `sandboxRuntime.image.repository` / `sandboxRuntime.image.tag` / `sandboxRuntime.image.digest` | Trusted workload-side image that provides the `openshell-sandbox` binary. A digest takes precedence over the tag. | | `supervisor.image.registry` / `supervisor.image.repository` / `supervisor.image.tag` / `supervisor.image.digest` | Trusted control-side supervisor image. | diff --git a/docs/observability/overview.mdx b/docs/observability/overview.mdx index d6b5cfe6bd..be4aa30626 100644 --- a/docs/observability/overview.mdx +++ b/docs/observability/overview.mdx @@ -129,4 +129,3 @@ The records go to the `[openshell.gateway.otlp]` endpoint unless the table sets - Learn how spans are named and identified in [Traces](/observability/traces). - Learn how to [read the shorthand format](/observability/logging). -- Learn what anonymous usage data OpenShell collects in [Telemetry](/observability/telemetry). It is separate from the signals on this page. diff --git a/docs/observability/telemetry.mdx b/docs/observability/telemetry.mdx deleted file mode 100644 index e062edf8e6..0000000000 --- a/docs/observability/telemetry.mdx +++ /dev/null @@ -1,51 +0,0 @@ ---- -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 -title: "Telemetry" -sidebar-title: "Telemetry" -description: "What anonymous telemetry OpenShell collects and how to disable it at runtime or compile it out." -keywords: "Generative AI, Cybersecurity, Telemetry, Privacy, Opt Out, Cargo Features, Observability" ---- - -OpenShell collects anonymous telemetry to help improve the project. The data shows aggregate usage of sandbox, provider, and policy workflows. It is not used to track individual users. Aggregate usage trends are published every two weeks in the [community telemetry reports](https://github.com/ai-openshell/openshell/tree/main/telemetry). - -## What Is Collected - -Telemetry events are limited to anonymous operational categories and counts, such as sandbox lifecycle outcomes, provider profile buckets, policy decision counts, and aggregate network activity denial categories. - -OpenShell telemetry does not collect sandbox names or IDs, hostnames, file paths, binary paths, prompts, credentials, provider names, model names, or user content. - -Opting out applies only to telemetry emitted by OpenShell. Third-party services, model providers, inference endpoints, agents, or tools that you configure and use with OpenShell may have their own terms and privacy practices. - -## Disable Telemetry at Runtime - -Set `OPENSHELL_TELEMETRY_ENABLED=false` on the gateway deployment. For Helm installs, set `server.telemetryEnabled=false`. - -## Compile Telemetry Out - -Telemetry support is a default-on `telemetry` Cargo feature of the gateway. The gateway also defines a `defaults-without-telemetry` alias covering every other default feature. Build a telemetry-free gateway with `--no-default-features --features defaults-without-telemetry`: - -```shell -cargo build --release -p openshell-gateway --no-default-features --features defaults-without-telemetry -``` - -The resulting binary contains no telemetry endpoint, no telemetry HTTP client, and no emission code. With telemetry compiled out, the gateway emits nothing. - -Cargo cannot subtract a single default feature, so `defaults-without-telemetry` must be paired with `--no-default-features`. Passing it on its own leaves the defaults in place and fails the build rather than producing a binary that still emits. - -### Select Compute Drivers - -The gateway exposes separate Cargo features for its built-in compute drivers: `compute-driver-kubernetes`, `compute-driver-docker`, `compute-driver-podman`, `compute-driver-vm`, and `compute-driver-mxc`. Disable the default feature set, then enable only the drivers and telemetry mode the target binary needs: - -```shell -# Docker only, with telemetry support. -cargo build --release -p openshell-gateway --no-default-features --features telemetry,compute-driver-docker - -# Docker and VM only, with telemetry compiled out. -cargo build --release -p openshell-gateway --no-default-features --features compute-driver-docker,compute-driver-vm - -# Windows MXC only, with telemetry support and prebuilt Z3. -cargo build --release -p openshell-gateway --no-default-features --features telemetry,compute-driver-mxc,openshell-server/prebuilt-z3 -``` - -Regular builds keep their platform driver set through the default `in-tree-compute-drivers` compatibility feature. On Windows, `compute-driver-mxc` selects MXC and the other four features install unsupported-driver stubs. On other platforms, MXC is excluded. diff --git a/e2e/no-compute-driver-gateway.sh b/e2e/no-compute-driver-gateway.sh index baa4a7d193..451288c8e1 100755 --- a/e2e/no-compute-driver-gateway.sh +++ b/e2e/no-compute-driver-gateway.sh @@ -9,11 +9,11 @@ cd "${ROOT}" echo "Building gateway without compiled compute drivers..." cargo build -p openshell-gateway --bin openshell-gateway \ - --no-default-features --features telemetry + --no-default-features cargo check -p openshell-core --no-default-features --all-targets dependency_tree="$(cargo tree -p openshell-gateway \ - --no-default-features --features telemetry --edges normal)" + --no-default-features --edges normal)" server_dependency_tree="$(cargo tree -p openshell-server --edges normal)" for driver in \ openshell-driver-docker \ diff --git a/e2e/rust/e2e-vm.sh b/e2e/rust/e2e-vm.sh index bafaadbc71..a210a485d9 100755 --- a/e2e/rust/e2e-vm.sh +++ b/e2e/rust/e2e-vm.sh @@ -106,7 +106,7 @@ if [ -z "${OPENSHELL_GATEWAY_BIN:-}" ]; then echo "==> Building driver-free openshell-gateway" cargo build \ -p openshell-gateway --bin openshell-gateway \ - --no-default-features --features telemetry + --no-default-features else build_packages+=(-p openshell-gateway) fi diff --git a/e2e/support/gateway-common.sh b/e2e/support/gateway-common.sh index f69518f0bc..ef2b61269e 100644 --- a/e2e/support/gateway-common.sh +++ b/e2e/support/gateway-common.sh @@ -5,10 +5,6 @@ # Shared helpers for local gateway-backed e2e wrappers. Driver-specific setup, # cleanup, and runtime behavior stay in the Docker/Podman wrapper scripts. -# E2E traffic is synthetic and must not contribute to product usage metrics. -# Keep an explicit override so telemetry-specific tests can opt back in. -export OPENSHELL_TELEMETRY_ENABLED="${OPENSHELL_TELEMETRY_ENABLED:-false}" - # Resolve a test image override. Repository-only values inherit the caller's # tag, while tagged and digest-pinned references are already complete. e2e_image_reference_is_complete() { @@ -504,7 +500,7 @@ e2e_build_gateway_binaries() { if [ "${OPENSHELL_E2E_EXTERNAL_COMPUTE_DRIVER:-0}" = "1" ]; then cargo build ${jobs[@]+"${jobs[@]}"} \ -p openshell-gateway --bin openshell-gateway \ - --no-default-features --features telemetry + --no-default-features else cargo build ${jobs[@]+"${jobs[@]}"} \ -p openshell-gateway --bin openshell-gateway diff --git a/e2e/with-kube-gateway.sh b/e2e/with-kube-gateway.sh index 4611fd137d..04979974fd 100755 --- a/e2e/with-kube-gateway.sh +++ b/e2e/with-kube-gateway.sh @@ -1417,7 +1417,7 @@ if [ "${OPENSHELL_E2E_KUBE_BUILD_IMAGES}" = "1" ]; then external_driver="${OPENSHELL_EXTERNAL_DRIVER_BIN:-${ROOT}/target/debug/openshell-driver-kubernetes}" if [ -z "${OPENSHELL_GATEWAY_BIN:-}" ]; then cargo build -p openshell-gateway --bin openshell-gateway \ - --no-default-features --features telemetry,vendored-z3 + --no-default-features --features vendored-z3 fi if [ -z "${OPENSHELL_EXTERNAL_DRIVER_BIN:-}" ]; then cargo build -p openshell-driver-kubernetes --bin openshell-driver-kubernetes @@ -1559,7 +1559,6 @@ fi helm_extra_args=() helm_post_renderer_args=() -helm_extra_args+=(--set "server.telemetryEnabled=${OPENSHELL_TELEMETRY_ENABLED}") helm_extra_args+=(--set supervisor.sandboxRuntime.networkPolicyEnforced=true) if [ "${ADDITIONAL_CA_MODE}" = "1" ]; then helm_extra_args+=(--set "supervisor.network.additionalCaConfigMapName=${ADDITIONAL_CA_SOURCE_CONFIG_MAP}") diff --git a/examples/governance-interceptor/README.md b/examples/governance-interceptor/README.md index 8a4b061b8f..2cd70ce832 100644 --- a/examples/governance-interceptor/README.md +++ b/examples/governance-interceptor/README.md @@ -19,8 +19,8 @@ authoritative profile source. audit logs, plus non-secret policy hash/signing key metadata - sandbox policy synchronization must carry the current signed governance policy; unsigned, stale, or modified policies are denied for every caller -- sandbox policy analysis may report telemetry, but sandbox-authored policy - proposals are denied before they reach the gateway handler +- sandbox policy analysis may report denial summaries, but sandbox-authored + policy proposals are denied before they reach the gateway handler - `proposal_approval_mode=auto` is blocked at both sandbox and global scope - users cannot import or update provider profiles outside the vended set - provider profile deletion is blocked by the interceptor @@ -63,7 +63,7 @@ changes that the gateway rejects for existing sandboxes are logged and still apply to newly created sandboxes. The example also validates `SubmitPolicyAnalysis`. Requests without proposed -policy chunks remain available for denial and network-activity telemetry. +policy chunks remain available for denial summaries. Requests containing proposed chunks are denied, so a sandbox cannot use the gateway's optional auto-approval path to widen its governed policy. This rule belongs to the example: gateways without this binding retain the standard @@ -152,5 +152,5 @@ To run the governance smoke test suite and stop the gateway when it completes: The suite uses a gateway-signed JWT for the created sandbox identity to attempt an unsigned policy widening and a policy proposal. It verifies that both are -denied, telemetry is accepted, and the active policy version and hash remain -unchanged. +denied, denial summaries are accepted, and the active policy version and hash +remain unchanged. diff --git a/examples/governance-interceptor/src/smoke_client.rs b/examples/governance-interceptor/src/smoke_client.rs index d4ca7f6f48..b2ae65420f 100644 --- a/examples/governance-interceptor/src/smoke_client.rs +++ b/examples/governance-interceptor/src/smoke_client.rs @@ -5,7 +5,7 @@ use jsonwebtoken::{Algorithm, EncodingKey, Header}; use openshell_core::proto::{ - GetSandboxConfigRequest, NetworkActivitySummary, PolicyChunk, SubmitPolicyAnalysisRequest, + DenialSummary, GetSandboxConfigRequest, PolicyChunk, SubmitPolicyAnalysisRequest, UpdateConfigRequest, open_shell_client::OpenShellClient, }; use openshell_crypto::jwt::encode; @@ -113,15 +113,16 @@ async fn main() -> Result<(), Box> { client .submit_policy_analysis(SubmitPolicyAnalysisRequest { name: sandbox_name.clone(), - network_activity_summaries: vec![NetworkActivitySummary { - network_activity_count: 1, + summaries: vec![DenialSummary { + host: "denied.example".to_string(), + port: 443, ..Default::default() }], - analysis_mode: "activity".to_string(), + analysis_mode: "mechanistic".to_string(), ..Default::default() }) .await - .map_err(|status| format!("telemetry-only policy analysis was denied: {status}"))?; + .map_err(|status| format!("denial-summary policy analysis was denied: {status}"))?; let after = client .get_sandbox_config(GetSandboxConfigRequest { @@ -138,7 +139,7 @@ async fn main() -> Result<(), Box> { .into()); } - println!("authenticated governance bypasses denied; telemetry accepted; policy unchanged"); + println!("authenticated governance bypasses denied; denial summaries accepted; policy unchanged"); Ok(()) } diff --git a/examples/governance-interceptor/src/tests.rs b/examples/governance-interceptor/src/tests.rs index 640a3e2862..27389a4b8c 100644 --- a/examples/governance-interceptor/src/tests.rs +++ b/examples/governance-interceptor/src/tests.rs @@ -923,14 +923,10 @@ fn automatic_proposal_approval_settings_are_denied() { } #[test] -fn sandbox_policy_analysis_allows_telemetry_but_denies_proposals() { +fn sandbox_policy_analysis_allows_denial_summaries_but_denies_proposals() { let service = service(); for operation in [ - json!({ - "name": "demo", - "networkActivitySummaries": [{"networkActivityCount": 1}], - }), json!({ "name": "demo", "summaries": [{"host": "denied.example", "port": 443}], diff --git a/proto/openshell.proto b/proto/openshell.proto index 56a58e17f0..b4189e6b84 100644 --- a/proto/openshell.proto +++ b/proto/openshell.proto @@ -3796,25 +3796,6 @@ message DenialSummary { bool l7_inspection_active = 17; } -// Count of denied actions grouped only by sanitized telemetry category. -message DenialGroupCount { - // Sanitized denial category, e.g. "connect_policy", "l7_policy", "ssrf". - string deny_group = 1; - // Number of denied actions in this category. - uint32 denied_count = 2; -} - -// Anonymous sandbox network activity counters. This intentionally excludes -// hosts, paths, binaries, raw deny reasons, sandbox IDs, and user content. -message NetworkActivitySummary { - // Total observed network activities in the current window. - uint32 network_activity_count = 1; - // Total denied actions in the current window. - uint32 denied_action_count = 2; - // Denied action counts grouped by sanitized category. - repeated DenialGroupCount denials_by_group = 3; -} - // A proposed policy rule with rationale and approval status. message PolicyChunk { reserved 9, 10, 14, 15; @@ -3890,6 +3871,8 @@ message DraftPolicyUpdate { // Submit analysis results from sandbox to gateway. message SubmitPolicyAnalysisRequest { + reserved 5; + reserved "network_activity_summaries"; // Workspace scope. Only a named workspace selection is accepted. openshell.datamodel.v1.WorkspaceSelector workspace_scope = 6; // Aggregated denial summaries. @@ -3907,8 +3890,6 @@ message SubmitPolicyAnalysisRequest { // Sandbox name. The authenticated sandbox principal remains authoritative // for this internal callback. string name = 4; - // Anonymous network activity counters. - repeated NetworkActivitySummary network_activity_summaries = 5; } message SubmitPolicyAnalysisResponse { diff --git a/skills/debug-openshell-cluster/SKILL.md b/skills/debug-openshell-cluster/SKILL.md index 564fbcec2a..755668ba02 100644 --- a/skills/debug-openshell-cluster/SKILL.md +++ b/skills/debug-openshell-cluster/SKILL.md @@ -571,9 +571,6 @@ kubectl -n openshell rollout status /openshell kubectl -n openshell logs -c openshell-gateway --tail=200 ``` -`server.telemetryEnabled` renders `OPENSHELL_TELEMETRY_ENABLED` on the gateway -pod. - Gateway pod scheduling accepts top-level `nodeSelector`, `affinity`, `tolerations`, `priorityClassName`, and `topologySpreadConstraints` values for both StatefulSet and Deployment workloads. The last two default to unset. diff --git a/tasks/rust.toml b/tasks/rust.toml index d3afee57a1..d8785343b5 100644 --- a/tasks/rust.toml +++ b/tasks/rust.toml @@ -101,27 +101,6 @@ description = "Verify cargo-deny rejects crypto dependencies that bypass the fac run = "uv run --no-project python tasks/scripts/test-crypto-dependency-policy.py" -["rust:verify:telemetry-off"] -description = "Verify telemetry emission code is compiled out with --no-default-features" -run = [ - # Positive control: the default (telemetry-on) gateway must contain the - # markers, so the absent checks below can never become silently vacuous. - "cargo build -p openshell-gateway --bin openshell-gateway", - "tasks/scripts/verify-telemetry-compiled-out.sh present target/debug/openshell-gateway", - # Guard: telemetry-free builds must contain no telemetry markers. Built - # through the `defaults-without-telemetry` alias, which is how the docs tell - # operators to produce these artifacts. - "cargo build -p openshell-gateway --bin openshell-gateway --no-default-features --features defaults-without-telemetry", - "tasks/scripts/verify-telemetry-compiled-out.sh absent target/debug/openshell-gateway", - # The supervisor has no telemetry feature; its default build must stay clean. - "cargo build -p openshell-supervisor --bin openshell-supervisor", - "tasks/scripts/verify-telemetry-compiled-out.sh absent target/debug/openshell-supervisor", -] - -["rust:verify:defaults-without-telemetry"] -description = "Verify the defaults-without-telemetry feature alias matches default minus telemetry and cannot be used additively" -run = "tasks/scripts/verify-defaults-without-telemetry.sh" - ["rust:verify:system-ca-roots"] description = "Verify system CA roots build mode compiles and excludes bundled Mozilla root crates" run = [ diff --git a/tasks/scripts/run-postgres-tests.sh b/tasks/scripts/run-postgres-tests.sh index 06464f6492..97451b4aa6 100755 --- a/tasks/scripts/run-postgres-tests.sh +++ b/tasks/scripts/run-postgres-tests.sh @@ -84,7 +84,6 @@ fi # The mutation-replay test predates OPENSHELL_TEST_POSTGRES_URL. Always use # the selected database, even if a legacy URL is inherited from the caller. export OPENSHELL_REPLAY_TEST_DATABASE_URL="${OPENSHELL_TEST_POSTGRES_URL}" -export OPENSHELL_TELEMETRY_ENABLED=false # Advisory locks are database-wide, so run the tests one at a time. cargo nextest run -p openshell-server --features test-support \ diff --git a/tasks/scripts/verify-defaults-without-telemetry.sh b/tasks/scripts/verify-defaults-without-telemetry.sh deleted file mode 100755 index cbebf379d0..0000000000 --- a/tasks/scripts/verify-defaults-without-telemetry.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env bash -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -# Verify the `defaults-without-telemetry` alias still means "every default -# feature except telemetry", and that it cannot be used additively. -# -# Cargo cannot subtract a single default feature, so telemetry-free builds use -# `--no-default-features --features defaults-without-telemetry`. Two failure -# modes follow from that, and this guard covers both: -# -# 1. Drift. The alias enumerates the keep-list by hand, so it silently rots -# the moment a crate gains a new default feature. Telemetry-free builds -# would then quietly lose an unrelated default. -# 2. Additive misuse. `--features defaults-without-telemetry` without -# `--no-default-features` would otherwise compile a telemetry-on binary -# that reads as telemetry-free. Each crate root carries a `compile_error!` -# for that combination; this asserts the error is actually wired up. - -set -euo pipefail - -# Crates that define the alias. Each must forward `telemetry` and define -# `defaults-without-telemetry`. -CRATES=( - openshell-gateway -) - -if ! command -v jq >/dev/null 2>&1; then - echo "error: 'jq' is required to inspect cargo metadata" >&2 - exit 2 -fi - -metadata=$(cargo metadata --no-deps --format-version 1) - -failed=0 -for crate in "${CRATES[@]}"; do - features=$(jq -c --arg crate "$crate" \ - '.packages[] | select(.name == $crate) | .features' <<<"$metadata") - - if [[ -z $features || $features == "null" ]]; then - echo "FAIL: crate '$crate' not found in workspace metadata" >&2 - failed=1 - continue - fi - - if ! jq -e 'has("defaults-without-telemetry")' <<<"$features" >/dev/null; then - echo "FAIL: $crate defines no 'defaults-without-telemetry' feature" >&2 - failed=1 - continue - fi - - expected=$(jq -r '(.default // []) - ["telemetry"] | sort | join(",")' <<<"$features") - actual=$(jq -r '(."defaults-without-telemetry" // []) | sort | join(",")' <<<"$features") - - if [[ $expected != "$actual" ]]; then - echo "FAIL: $crate 'defaults-without-telemetry' is out of sync with 'default'" >&2 - echo " default minus telemetry: [${expected}]" >&2 - echo " defaults-without-telemetry: [${actual}]" >&2 - echo " Update 'defaults-without-telemetry' in crates/$crate/Cargo.toml to match." >&2 - failed=1 - continue - fi - - echo "OK: $crate 'defaults-without-telemetry' == default minus telemetry [${expected}]" -done - -# Additive misuse must be a hard error. Match on the `compile_error!` text -# rather than a nonzero exit code: openshell-driver-vm does not build on every -# host, and a check that failed for an unrelated reason would make this guard -# silently vacuous. -for crate in "${CRATES[@]}"; do - output=$(cargo check -p "$crate" --features defaults-without-telemetry 2>&1 || true) - - if grep -qF "features \`telemetry\` and \`defaults-without-telemetry\` are mutually exclusive" <<<"$output"; then - echo "OK: $crate rejects 'telemetry' + 'defaults-without-telemetry'" - continue - fi - - echo "FAIL: $crate did not reject 'telemetry' + 'defaults-without-telemetry'" >&2 - echo " Expected the mutual-exclusion compile_error! in crates/$crate/src/lib.rs." >&2 - echo " Got:" >&2 - sed 's/^/ /' <<<"$output" | tail -20 >&2 - failed=1 -done - -exit "$failed" diff --git a/tasks/scripts/verify-telemetry-compiled-out.sh b/tasks/scripts/verify-telemetry-compiled-out.sh deleted file mode 100755 index 22a238ea18..0000000000 --- a/tasks/scripts/verify-telemetry-compiled-out.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env bash -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -# Verify whether telemetry emission code is present in a compiled binary. -# -# The `telemetry` Cargo feature (default-on, defined in openshell-core) gates the -# telemetry endpoint, HTTP client, and emission code. Building with -# --no-default-features must produce a binary that contains none of it. This -# guard inspects a built binary for telemetry markers that only exist when the -# emission code is compiled in. - -set -euo pipefail - -# Markers that appear only in compiled-in telemetry emission code. Sourced from -# crates/openshell-core/src/telemetry.rs (DEFAULT_ENDPOINT host and CLIENT_ID). -# Keep in sync with that file; the `present` positive control fails loudly if a -# marker goes stale, so the `absent` checks can never become silently vacuous. -MARKERS=( - "events.telemetry.data.nvidia.com" - "415437562476676" -) - -usage() { - echo "Usage: verify-telemetry-compiled-out.sh [binary ...]" >&2 - echo " present assert telemetry markers ARE present (positive control for a telemetry-enabled build)" >&2 - echo " absent assert telemetry markers are NOT present (telemetry compiled out)" >&2 -} - -if [[ $# -lt 2 ]]; then - usage - exit 2 -fi - -mode=$1 -shift -case "$mode" in - present | absent) ;; - *) - usage - exit 2 - ;; -esac - -if ! command -v strings >/dev/null 2>&1; then - echo "error: 'strings' (binutils) is required to inspect the binary" >&2 - exit 2 -fi - -failed=0 -for binary in "$@"; do - if [[ ! -f $binary ]]; then - echo "error: binary not found: $binary" >&2 - failed=1 - continue - fi - - dump=$(strings -a "$binary") - for marker in "${MARKERS[@]}"; do - count=$(grep -c -F "$marker" <<<"$dump" || true) - if [[ $mode == absent && $count -ne 0 ]]; then - echo "FAIL: telemetry marker '$marker' found in $binary ($count occurrence(s)); telemetry was not compiled out" >&2 - failed=1 - elif [[ $mode == present && $count -eq 0 ]]; then - echo "FAIL: telemetry marker '$marker' missing from $binary; positive control failed (marker stale or build misconfigured)" >&2 - failed=1 - else - echo "OK: marker '$marker' $mode in $(basename "$binary") ($count occurrence(s))" - fi - done -done - -exit "$failed" diff --git a/tasks/test.toml b/tasks/test.toml index 07f4986002..20f843259d 100644 --- a/tasks/test.toml +++ b/tasks/test.toml @@ -156,7 +156,6 @@ run = "bash tasks/scripts/e2e-gpu-build-images.sh" ["test:rust"] description = "Run Rust tests" depends = ["rust:lockfiles:check"] -env = { OPENSHELL_TELEMETRY_ENABLED = "false" } run = [ # Prove the facade contract without the default backend's compiled features. "cargo test -p openshell-crypto --no-default-features --test independent_backend", diff --git a/telemetry/2026-07-08.md b/telemetry/2026-07-08.md deleted file mode 100644 index 39340605ff..0000000000 --- a/telemetry/2026-07-08.md +++ /dev/null @@ -1,46 +0,0 @@ -# OpenShell Telemetry — June 24 – July 8, 2026 - -[← All reports](README.md) - -First public telemetry update, so there is no prior period to compare against. The **Last 2 weeks** column covers this two-week window; **All-time** is cumulative since telemetry landed on June 1, 2026 (~5 weeks). A large share of all-time activity falls within this two-week window. Numbers are aggregate counts only — see the [Telemetry section](../README.md#telemetry) of the main README for what's collected and how to opt out. - -| Metric | Last 2 weeks | All-time | -|---|---:|---:| -| Sandboxes created | 269,220 | 383,224 | -| Sandboxes deleted | 247,727 | 343,216 | -| Sandbox creation failures | 5,345 | 12,822 | -| Actions denied | 2,323,468 | 3,861,935 | -| Network activity events | 29,935,431 | 43,079,862 | - -Creation failure rate held around 2% over the last two weeks (~3% all-time). - -**Sandbox drivers.** Docker dominates at 208,816, followed by Podman (34,637) and Kubernetes (23,480). VM (1,562), unknown (422), and MXC (303) make up the long tail. All-time we've also seen a handful of apple-container and macos sandboxes. - -```mermaid -xychart-beta - title "Sandboxes Created by Driver (Jun 24 – Jul 8)" - x-axis ["docker", "podman", "kubernetes", "vm", "unknown", "mxc"] - y-axis "Sandboxes created" 0 --> 220000 - bar [208816, 34637, 23480, 1562, 422, 303] -``` - -**Where sandboxes are created.** The United States leads by a wide margin, followed by Israel, Australia, Hong Kong, India, Singapore, South Korea, Germany, Japan, and China. - -**Providers.** `custom` profiles lead (~30k), then `openai` (~21k), with nvidia, claude, anthropic, github, gitlab, opencode, codex, and copilot trailing. - -```mermaid -xychart-beta - title "Top Provider Profiles (Jun 24 – Jul 8, approx.)" - x-axis ["custom", "openai", "nvidia", "claude", "other"] - y-axis "Profiles created" 0 --> 32000 - bar [30300, 21100, 1200, 1000, 3000] -``` - -**Policy.** Roughly 73% of policy decisions were approved over the last two weeks. Of denied sandbox connections, ~99% fell under the "Connect Policy" deny group, with "Bypass" denials near zero. - -```mermaid -pie showData - title Policy Decisions — Jun 24 – Jul 8 (approx.) - "Approved" : 3700 - "Rejected" : 1400 -``` diff --git a/telemetry/2026-07-26.md b/telemetry/2026-07-26.md deleted file mode 100644 index 9247708dce..0000000000 --- a/telemetry/2026-07-26.md +++ /dev/null @@ -1,46 +0,0 @@ -# OpenShell Telemetry — July 13 – July 26, 2026 - -[← All reports](README.md) - -Metrics below cover this two-week window, compared with the prior period (June 24 – July 8, 2026). Numbers are aggregate counts only — see the [Telemetry section](../README.md#telemetry) of the main README for what's collected and how to opt out. - -| Metric | This period | Prior period | Change | -|---|---:|---:|---:| -| Sandboxes created | 556,370 | 269,220 | +106.7% | -| Sandboxes deleted | 421,946 | 247,727 | +70.3% | -| Sandbox creation failures | 100,246 | 5,345 | +1,775.5% | -| Actions denied | 3,505,237 | 2,323,468 | +50.9% | -| Network activity events | 34,946,280 | 29,935,431 | +16.7% | - -The creation failure rate was ~18% this period (100,246 failures against 556,370 creates), up from ~2% in the prior period. Docker was the most-used driver at 332,238, ahead of Kubernetes (172,834). - -**Sandbox drivers.** Docker leads at 332,238, then Kubernetes (172,834) and Podman (47,374). The long tail: VM (3,198), unknown (399), and MXC (327). - -```mermaid -xychart-beta - title "Sandboxes Created by Driver (Jul 13 – Jul 26)" - x-axis ["docker", "kubernetes", "podman", "vm", "unknown", "mxc"] - y-axis "Sandboxes created" 0 --> 350000 - bar [332238, 172834, 47374, 3198, 399, 327] -``` - -**Where sandboxes are created.** The United States leads by a wide margin, followed by Israel, Japan, India, Singapore, Hong Kong, China, Germany, Thailand, and Sweden. - -**Providers.** `custom` profiles lead at 42,758, then `openai` (33,074), claude (2,261), nvidia (1,744), github (784), anthropic (660), opencode (624), gitlab (284), codex (38), and copilot (18). - -```mermaid -xychart-beta - title "Top Provider Profiles (Jul 13 – Jul 26)" - x-axis ["custom", "openai", "claude", "nvidia", "other"] - y-axis "Profiles created" 0 --> 50000 - bar [42758, 33074, 2261, 1744, 2414] -``` - -**Policy.** Roughly 70% of policy decisions were approved this period (~8.7k approved vs ~3.7k rejected). Of denied sandbox connections, ~98% fell under the "Connect Policy" deny group. - -```mermaid -pie showData - title Policy Decisions — Jul 13 – Jul 26 (approx.) - "Approved" : 8700 - "Rejected" : 3700 -``` diff --git a/telemetry/2026-08-10.md b/telemetry/2026-08-10.md deleted file mode 100644 index 9f2da71eb7..0000000000 --- a/telemetry/2026-08-10.md +++ /dev/null @@ -1,46 +0,0 @@ -# OpenShell Telemetry — July 27 – August 10, 2026 - -[← All reports](README.md) - -Metrics below cover this two-week window, compared with the prior period (July 13 – July 26, 2026). Numbers are aggregate counts only — see the [Telemetry section](../README.md#telemetry) of the main README for what's collected and how to opt out. - -| Metric | This period | Prior period | Change | -|---|---:|---:|---:| -| Sandboxes created | 556,389 | 556,370 | +0.0% | -| Sandboxes deleted | 457,086 | 421,946 | +8.3% | -| Sandbox creation failures | 66,511 | 100,246 | -33.7% | -| Actions denied | 4,220,436 | 3,505,237 | +20.4% | -| Network activity events | 27,077,441 | 34,946,280 | -22.5% | - -The creation failure rate was ~12% this period (66,511 failures against 556,389 creates), down from ~18% in the prior period. Kubernetes (245,144) overtook Docker (239,444) as the most-used sandbox driver. - -**Sandbox drivers.** Kubernetes leads at 245,144, just ahead of Docker (239,444), with Podman third at 58,657. The long tail: unknown (6,386), VM (6,267), MXC (461), apple-container (23), and LXD (7). - -```mermaid -xychart-beta - title "Sandboxes Created by Driver (Jul 27 – Aug 10)" - x-axis ["kubernetes", "docker", "podman", "unknown", "vm", "mxc"] - y-axis "Sandboxes created" 0 --> 260000 - bar [245144, 239444, 58657, 6386, 6267, 461] -``` - -**Where sandboxes are created.** The United States again leads by a wide margin, followed by India, Germany, China, Poland, Japan, the United Kingdom, Israel, Hong Kong, and Denmark. - -**Providers.** `custom` profiles lead (~61k), then `openai` (~51k), with claude, nvidia, github, anthropic, gitlab, opencode, codex, and copilot trailing. - -```mermaid -xychart-beta - title "Top Provider Profiles (Jul 27 – Aug 10, approx.)" - x-axis ["custom", "openai", "claude", "nvidia", "other"] - y-axis "Profiles created" 0 --> 65000 - bar [61000, 51000, 3000, 2000, 4000] -``` - -**Policy.** Roughly 67% of policy decisions were approved this period (~16.5k approved vs ~8.2k rejected). Of denied sandbox connections, ~93% fell under the "Connect Policy" deny group, with "Bypass" denials near zero. - -```mermaid -pie showData - title Policy Decisions — Jul 27 – Aug 10 (approx.) - "Approved" : 16500 - "Rejected" : 8200 -``` diff --git a/telemetry/README.md b/telemetry/README.md deleted file mode 100644 index e6e378eb65..0000000000 --- a/telemetry/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# OpenShell Community Telemetry Reports - -OpenShell collects anonymous, aggregate usage telemetry (see the [Telemetry section](../README.md#telemetry) of the main README for what's collected and how to opt out). We publish periodic summaries of the trends here so the community can see how the project is being used. - -Numbers are aggregate counts only — no user data, code, prompts, or command contents are collected. Each report covers one two-week period and, where available, compares against the prior period. Reports are listed newest first. - -## Reports - -| Reporting period | Report | -|---|---| -| July 27 – August 10, 2026 | [View report](2026-08-10.md) | -| July 13 – July 26, 2026 | [View report](2026-07-26.md) | -| June 24 – July 8, 2026 | [View report](2026-07-08.md) | diff --git a/tests/suites/conformance/Cargo.lock b/tests/suites/conformance/Cargo.lock index 76506381c3..e990d4b334 100644 --- a/tests/suites/conformance/Cargo.lock +++ b/tests/suites/conformance/Cargo.lock @@ -2283,7 +2283,6 @@ version = "0.0.0" dependencies = [ "async-trait", "base64 0.22.1", - "chrono", "glob", "ipnet", "libc", @@ -2296,7 +2295,6 @@ dependencies = [ "prost", "prost-types", "protoc-bin-vendored", - "reqwest", "rustix", "rustls", "serde", @@ -2996,9 +2994,7 @@ checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" dependencies = [ "base64 0.22.1", "bytes", - "futures-channel", "futures-core", - "futures-util", "http", "http-body", "http-body-util", diff --git a/tests/suites/continuity/Cargo.lock b/tests/suites/continuity/Cargo.lock index 26179cb602..79a32af458 100644 --- a/tests/suites/continuity/Cargo.lock +++ b/tests/suites/continuity/Cargo.lock @@ -2270,7 +2270,6 @@ version = "0.0.0" dependencies = [ "async-trait", "base64 0.22.1", - "chrono", "glob", "ipnet", "libc", @@ -2283,7 +2282,6 @@ dependencies = [ "prost", "prost-types", "protoc-bin-vendored", - "reqwest", "rustix", "rustls", "serde", @@ -2983,9 +2981,7 @@ checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" dependencies = [ "base64 0.22.1", "bytes", - "futures-channel", "futures-core", - "futures-util", "http", "http-body", "http-body-util", diff --git a/tests/suites/drivers/podman/Cargo.lock b/tests/suites/drivers/podman/Cargo.lock index 560b02aa72..28ad7536fe 100644 --- a/tests/suites/drivers/podman/Cargo.lock +++ b/tests/suites/drivers/podman/Cargo.lock @@ -2271,7 +2271,6 @@ version = "0.0.0" dependencies = [ "async-trait", "base64 0.22.1", - "chrono", "glob", "ipnet", "libc", @@ -2284,7 +2283,6 @@ dependencies = [ "prost", "prost-types", "protoc-bin-vendored", - "reqwest", "rustix", "rustls", "serde", @@ -3001,9 +2999,7 @@ checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" dependencies = [ "base64 0.22.1", "bytes", - "futures-channel", "futures-core", - "futures-util", "http", "http-body", "http-body-util", diff --git a/tests/suites/features/Cargo.lock b/tests/suites/features/Cargo.lock index b16d3fb67d..9366fa114c 100644 --- a/tests/suites/features/Cargo.lock +++ b/tests/suites/features/Cargo.lock @@ -2343,7 +2343,6 @@ version = "0.0.0" dependencies = [ "async-trait", "base64 0.22.1", - "chrono", "glob", "ipnet", "libc", @@ -2356,7 +2355,6 @@ dependencies = [ "prost", "prost-types", "protoc-bin-vendored", - "reqwest", "rustix", "rustls", "serde", @@ -3068,9 +3066,7 @@ checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" dependencies = [ "base64 0.22.1", "bytes", - "futures-channel", "futures-core", - "futures-util", "http", "http-body", "http-body-util", diff --git a/tests/support/Cargo.lock b/tests/support/Cargo.lock index 0883511b5c..fcbeacdafb 100644 --- a/tests/support/Cargo.lock +++ b/tests/support/Cargo.lock @@ -2289,7 +2289,6 @@ version = "0.0.0" dependencies = [ "async-trait", "base64 0.22.1", - "chrono", "glob", "ipnet", "libc", @@ -2302,7 +2301,6 @@ dependencies = [ "prost", "prost-types", "protoc-bin-vendored", - "reqwest", "rustix", "rustls", "serde", @@ -3010,9 +3008,7 @@ checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" dependencies = [ "base64 0.22.1", "bytes", - "futures-channel", "futures-core", - "futures-util", "http", "http-body", "http-body-util", diff --git a/tests/testkit/Cargo.lock b/tests/testkit/Cargo.lock index bad3c82e89..26fda0f0da 100644 --- a/tests/testkit/Cargo.lock +++ b/tests/testkit/Cargo.lock @@ -2262,7 +2262,6 @@ version = "0.0.0" dependencies = [ "async-trait", "base64 0.22.1", - "chrono", "glob", "ipnet", "libc", @@ -2275,7 +2274,6 @@ dependencies = [ "prost", "prost-types", "protoc-bin-vendored", - "reqwest", "rustix", "rustls", "serde", @@ -2975,9 +2973,7 @@ checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" dependencies = [ "base64 0.22.1", "bytes", - "futures-channel", "futures-core", - "futures-util", "http", "http-body", "http-body-util", diff --git a/tests/tmachine/ansible/playbooks/openshell-k3s.yaml b/tests/tmachine/ansible/playbooks/openshell-k3s.yaml index 5b68bc0067..9e9534f25b 100644 --- a/tests/tmachine/ansible/playbooks/openshell-k3s.yaml +++ b/tests/tmachine/ansible/playbooks/openshell-k3s.yaml @@ -125,7 +125,6 @@ allowUnauthenticatedUsers: true disableTls: true hostGatewayIP: "{{ k3s_node_ipv4 }}" - telemetryEnabled: false - name: Write OpenShell Helm values overlay ansible.builtin.copy: