Files
Russell Bryant 3aba30c36f feat(telemetry): add build-time option to compile out telemetry (#1845)
* feat(telemetry): add build-time option to compile out telemetry

Gate anonymous telemetry emission behind a default-on `telemetry` Cargo
feature in openshell-core. The data model (enums, validation, emit_*/enabled*
signatures) stays always-compiled, while the endpoint, HTTP client, queue, and
emission code are feature-gated. With the feature off, enabled() returns false
and emit_* are no-ops, so dependent crates compile unchanged and no telemetry
endpoint, HTTP client, or emission code is included in the binary.

chrono and reqwest become optional dependencies of openshell-core, dropped from
its dependency graph when telemetry is disabled.

Thread the switch through the workspace: every crate depends on openshell-core
with default-features = false, and the default-on `telemetry` passthrough lives
on the binary crates that emit or collect telemetry (openshell-server,
openshell-sandbox, openshell-driver-vm). In-process drivers inherit it via
resolver v2 feature unification.

Build a telemetry-free binary with, e.g.:
  cargo build --release -p openshell-server --no-default-features

The runtime OPENSHELL_TELEMETRY_ENABLED switch is unchanged for default builds.

Signed-off-by: Russell Bryant <russell.bryant@gmail.com>

* ci(telemetry): guard that telemetry can be compiled out

Add tasks/scripts/verify-telemetry-compiled-out.sh, which inspects a built
binary for telemetry markers (the telemetry endpoint host and client ID) that
exist only when emission code is compiled in. The rust:verify:telemetry-off
mise task builds the gateway with default features (positive control: markers
must be present, so the absent checks can never be silently vacuous) and with
--no-default-features (markers must be absent), and checks the
--no-default-features sandbox binary as well.

Wire the task into the Rust branch-checks job so a regression that reintroduces
telemetry code into a --no-default-features build fails CI.

Signed-off-by: Russell Bryant <russell.bryant@gmail.com>

---------

Signed-off-by: Russell Bryant <russell.bryant@gmail.com>
2026-06-09 14:19:26 -07:00
..

openshell-router

openshell-router is the inference routing and upstream execution engine used by the sandbox proxy and gateway inference validation paths.

Responsibilities

  • Select an upstream route from a candidate set (based on protocol compatibility).
  • Forward raw HTTP requests to the selected upstream backend.
  • Normalize upstream failures into router-level errors (unauthorized, unavailable, protocol/internal errors).
  • Keep routing decision logic in one place so strategies can evolve (fallbacks, scoring, health-based routing).

Non-responsibilities

  • Authentication and sandbox identity.
  • Authorization and policy enforcement.
  • Persistence of routes/entities.
  • Loading sandbox or policy objects.

These are owned by openshell-server and openshell-sandbox.

Integration Contract

Current split:

  • openshell-server:
    • authenticates user-facing inference configuration changes
    • resolves managed route candidates from provider records
    • validates backend endpoints
  • openshell-sandbox:
    • intercepts https://inference.local
    • detects the source inference protocol
    • passes sanitized requests and resolved route candidates to the router
  • openshell-router:
    • picks a route from candidates (proxy_with_candidates)
    • forwards the HTTP request upstream and returns the raw response

Public APIs

  • Router::proxy_with_candidates(source_protocol, method, path, headers, body, &[ResolvedRoute])
    • Filters candidates by protocol compatibility, then forwards the request to the first match.
    • Preferred path for entity-driven server routing.

Notes

  • Route selection matches candidates by protocol field (e.g. openai_chat_completions).
  • Route selection is intentionally simple and will evolve.