Skip to content

Commit 4c1cbbd

Browse files
committed
feat(build): add defaults-without-telemetry feature alias
Cargo cannot subtract a single default feature, so compiling telemetry out meant `--no-default-features` plus a hand-maintained keep-list of the crate's other defaults. That keep-list was already wrong for operators: telemetry is the only default on openshell-server and openshell-driver-vm, but openshell-sandbox also defaults to `bundled-ca-roots`, so a bare `--no-default-features` silently swapped the supervisor onto the platform trust store. Add a `defaults-without-telemetry` alias to each of the three telemetry- carrying binary crates, enumerating every default except `telemetry`. Telemetry-free builds become `--no-default-features --features defaults-without-telemetry` and stay correct as the default set grows. The alias is a keep-list, not a switch. Enabling it on top of the defaults would otherwise produce a telemetry-on binary that reads as telemetry-free, so each crate root carries a `compile_error!` for the `telemetry` + `defaults-without-telemetry` combination. Add `rust:verify:defaults-without-telemetry` to guard both properties: each alias still equals its crate's defaults minus `telemetry`, and the mutual-exclusion error is wired up. The additive-misuse check matches on the `compile_error!` text rather than a nonzero exit code so it cannot pass vacuously on hosts where openshell-driver-vm fails to build for unrelated reasons. `rust:verify:telemetry-off` now builds through the alias. Signed-off-by: Russell Bryant <rbryant@redhat.com>
1 parent 74654ac commit 4c1cbbd

11 files changed

Lines changed: 195 additions & 10 deletions

File tree

.github/workflows/branch-checks.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,15 @@ jobs:
167167
run: |
168168
cargo nextest run --profile ci --workspace --features openshell-server/test-support
169169
170+
- name: Verify telemetry can be compiled out
171+
run: mise run rust:verify:telemetry-off
172+
173+
- name: Verify the defaults-without-telemetry feature alias tracks the default feature set
174+
run: mise run rust:verify:defaults-without-telemetry
175+
176+
- name: Verify system CA roots build mode compiles and excludes bundled Mozilla roots
177+
run: mise run rust:verify:system-ca-roots
178+
170179
python:
171180
name: Python (${{ matrix.runner }})
172181
needs: pr_metadata

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,15 @@ OpenShell collects anonymous telemetry to help improve the project for developer
258258

259259
Disable telemetry at runtime by setting `OPENSHELL_TELEMETRY_ENABLED=false` on the gateway deployment. For Helm installs, set `server.telemetryEnabled=false`. OpenShell propagates this deployment setting into sandbox supervisor environments so sandbox-side telemetry collection is disabled as well.
260260

261-
You can also compile telemetry out entirely. Telemetry support is a default-on `telemetry` Cargo feature; building with `--no-default-features` produces binaries that contain no telemetry endpoint, no telemetry HTTP client, and no emission code. Build telemetry-free artifacts with, for example, `cargo build --release -p openshell-server --no-default-features` (gateway) and the equivalent for `openshell-sandbox` and `openshell-driver-vm`. With telemetry compiled out, the gateway emits nothing and reports telemetry disabled to the sandboxes it launches.
261+
You can also compile telemetry out entirely. Telemetry support is a default-on `telemetry` Cargo feature, and 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`:
262+
263+
```shell
264+
cargo build --release -p openshell-server --no-default-features --features defaults-without-telemetry
265+
cargo build --release -p openshell-sandbox --no-default-features --features defaults-without-telemetry
266+
cargo build --release -p openshell-driver-vm --no-default-features --features defaults-without-telemetry
267+
```
268+
269+
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. Cargo has no way to 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.
262270

263271
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.
264272

architecture/build.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,27 @@ is the single switch that enables `openshell-core/telemetry` for its build
3434
graph. In-process drivers (`docker`, `kubernetes`, `podman`) inherit the
3535
gateway's setting through feature unification and carry no passthrough.
3636

37-
Building a binary with `--no-default-features` compiles out telemetry entirely:
38-
no endpoint, no telemetry HTTP client, and no emission code. With telemetry
39-
compiled out, `telemetry::enabled()` is always `false` and the `emit_*` helpers
40-
are no-ops, so the data-model types stay available and dependent crates compile
41-
unchanged. The runtime `OPENSHELL_TELEMETRY_ENABLED` switch remains the way to
42-
disable telemetry in a default (telemetry-enabled) build.
37+
Building a binary without the `telemetry` feature compiles out telemetry
38+
entirely: no endpoint, no telemetry HTTP client, and no emission code. With
39+
telemetry compiled out, `telemetry::enabled()` is always `false` and the
40+
`emit_*` helpers are no-ops, so the data-model types stay available and
41+
dependent crates compile unchanged. The runtime `OPENSHELL_TELEMETRY_ENABLED`
42+
switch remains the way to disable telemetry in a default (telemetry-enabled)
43+
build.
44+
45+
Cargo cannot subtract a single default feature, so each of the three binary
46+
crates also defines a `defaults-without-telemetry` alias listing every default
47+
except `telemetry`. Telemetry-free builds use
48+
`--no-default-features --features defaults-without-telemetry` and stay correct
49+
as the default set grows, instead of dropping unrelated defaults the way a bare
50+
`--no-default-features` does on `openshell-sandbox`. The alias is a keep-list,
51+
not a switch: enabling it on top of the defaults would otherwise yield a
52+
telemetry-on binary that reads as telemetry-free, so each crate root carries a
53+
`compile_error!` for the `telemetry` + `defaults-without-telemetry` combination.
54+
`rust:verify:defaults-without-telemetry` guards both properties — that each
55+
alias still equals its crate's defaults minus `telemetry`, and that the
56+
mutual-exclusion error is wired up — and `rust:verify:telemetry-off` builds
57+
through the alias and inspects the resulting binaries for telemetry markers.
4358

4459
Supervisor upstream TLS root-store selection is controlled by the
4560
`bundled-ca-roots` Cargo feature (on by default). Default builds use Mozilla

crates/openshell-driver-vm/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ default = ["telemetry"]
5959
## default; build with `--no-default-features` for a telemetry-free VM driver
6060
## that reports telemetry disabled to the sandboxes it launches.
6161
telemetry = ["openshell-core/telemetry"]
62+
## Convenience alias: every default feature except `telemetry`. Build a
63+
## telemetry-free VM driver with
64+
## `--no-default-features --features defaults-without-telemetry` and stay
65+
## correct as new default features are added. Cargo cannot subtract a single
66+
## default feature, so this alias must be paired with `--no-default-features`;
67+
## enabling it alongside `telemetry` is a compile error rather than a silent
68+
## telemetry-on build. Kept in sync with `default` by
69+
## `rust:verify:defaults-without-telemetry`.
70+
defaults-without-telemetry = []
6271

6372
[dev-dependencies]
6473
openshell-otel-test-support = { path = "../openshell-otel-test-support" }

crates/openshell-driver-vm/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
// `defaults-without-telemetry` is an alias for the default feature set minus
5+
// `telemetry`, not a switch that turns telemetry off. Cargo cannot subtract a
6+
// default feature, so adding it on top of the defaults would otherwise produce
7+
// a telemetry-on build that reads as telemetry-free. Fail the build instead.
8+
#[cfg(all(feature = "telemetry", feature = "defaults-without-telemetry"))]
9+
compile_error!(
10+
"features `telemetry` and `defaults-without-telemetry` are mutually exclusive; \
11+
build a telemetry-free VM driver with `--no-default-features --features defaults-without-telemetry`"
12+
);
13+
414
pub mod driver;
515
mod embedded_runtime;
616
mod ffi;

crates/openshell-sandbox/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ default = ["telemetry", "bundled-ca-roots"]
6060
## `--no-default-features --features system-ca-roots` to build a supervisor
6161
## that uses the platform trust store with telemetry intact.
6262
system-ca-roots = ["telemetry"]
63+
## Convenience alias: every default feature except `telemetry`. Build a
64+
## telemetry-free supervisor with
65+
## `--no-default-features --features defaults-without-telemetry` and stay
66+
## correct as new default features are added. Cargo cannot subtract a single
67+
## default feature, so this alias must be paired with `--no-default-features`;
68+
## enabling it alongside `telemetry` is a compile error rather than a silent
69+
## telemetry-on build. Kept in sync with `default` by
70+
## `rust:verify:defaults-without-telemetry`. Do not pair it with
71+
## `system-ca-roots`, which re-enables `telemetry`; a build with neither
72+
## telemetry nor bundled CA roots is plain `--no-default-features`.
73+
defaults-without-telemetry = ["bundled-ca-roots"]
6374

6475
telemetry = ["openshell-core/telemetry"]
6576
bundled-ca-roots = ["openshell-supervisor-network/bundled-ca-roots"]

crates/openshell-sandbox/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
//!
66
//! This crate provides process sandboxing and monitoring capabilities.
77
8+
// `defaults-without-telemetry` is an alias for the default feature set minus
9+
// `telemetry`, not a switch that turns telemetry off. Cargo cannot subtract a
10+
// default feature, so adding it on top of the defaults would otherwise produce
11+
// a telemetry-on build that reads as telemetry-free. Fail the build instead.
12+
#[cfg(all(feature = "telemetry", feature = "defaults-without-telemetry"))]
13+
compile_error!(
14+
"features `telemetry` and `defaults-without-telemetry` are mutually exclusive; \
15+
build a telemetry-free supervisor with `--no-default-features --features defaults-without-telemetry`"
16+
);
17+
818
mod activity_aggregator;
919
mod denial_aggregator;
1020
#[cfg_attr(not(target_os = "linux"), allow(dead_code))]

crates/openshell-server/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ in-tree-compute-drivers = [
138138
## On by default; build with `--no-default-features` for a telemetry-free gateway
139139
## that contains no telemetry endpoint, HTTP client, or emission code.
140140
telemetry = ["openshell-core/telemetry"]
141+
## Convenience alias: every default feature except `telemetry`. Build a
142+
## telemetry-free gateway with
143+
## `--no-default-features --features defaults-without-telemetry` and stay
144+
## correct as new default features are added. Cargo cannot subtract a single
145+
## default feature, so this alias must be paired with `--no-default-features`;
146+
## enabling it alongside `telemetry` is a compile error rather than a silent
147+
## telemetry-on build. Kept in sync with `default` by
148+
## `rust:verify:defaults-without-telemetry`.
149+
defaults-without-telemetry = []
141150
bundled-z3 = ["openshell-prover/bundled-z3"]
142151
test-support = []
143152

crates/openshell-server/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313
//! startup. Runtime selection only consults that registry or a configured
1414
//! external endpoint; it does not switch on driver names.
1515
16+
// `defaults-without-telemetry` is an alias for the default feature set minus
17+
// `telemetry`, not a switch that turns telemetry off. Cargo cannot subtract a
18+
// default feature, so adding it on top of the defaults would otherwise produce
19+
// a telemetry-on build that reads as telemetry-free. Fail the build instead.
20+
#[cfg(all(feature = "telemetry", feature = "defaults-without-telemetry"))]
21+
compile_error!(
22+
"features `telemetry` and `defaults-without-telemetry` are mutually exclusive; \
23+
build a telemetry-free gateway with `--no-default-features --features defaults-without-telemetry`"
24+
);
25+
1626
mod auth;
1727
pub mod certgen;
1828
pub mod cli;

tasks/rust.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,19 @@ run = [
5353
# markers, so the absent checks below can never become silently vacuous.
5454
"cargo build -p openshell-server --bin openshell-gateway",
5555
"tasks/scripts/verify-telemetry-compiled-out.sh present target/debug/openshell-gateway",
56-
# Guard: telemetry-free builds must contain no telemetry markers.
57-
"cargo build -p openshell-server --bin openshell-gateway --no-default-features",
56+
# Guard: telemetry-free builds must contain no telemetry markers. Built
57+
# through the `defaults-without-telemetry` alias, which is how the docs tell
58+
# operators to produce these artifacts.
59+
"cargo build -p openshell-server --bin openshell-gateway --no-default-features --features defaults-without-telemetry",
5860
"tasks/scripts/verify-telemetry-compiled-out.sh absent target/debug/openshell-gateway",
59-
"cargo build -p openshell-sandbox --bin openshell-sandbox --no-default-features --features bundled-ca-roots",
61+
"cargo build -p openshell-sandbox --bin openshell-sandbox --no-default-features --features defaults-without-telemetry",
6062
"tasks/scripts/verify-telemetry-compiled-out.sh absent target/debug/openshell-sandbox",
6163
]
6264

65+
["rust:verify:defaults-without-telemetry"]
66+
description = "Verify the defaults-without-telemetry feature alias matches default minus telemetry and cannot be used additively"
67+
run = "tasks/scripts/verify-defaults-without-telemetry.sh"
68+
6369
["rust:verify:system-ca-roots"]
6470
description = "Verify system CA roots build mode compiles and excludes bundled Mozilla root crates"
6571
run = [

0 commit comments

Comments
 (0)