aKode fase 2c: eliminato il codice di invio dati (crate analytics, otel-trace-websocket, sentry, esportatori OTLP); /feedback salva solo in locale; chiavi legacy [analytics]/[otel] accettate e ignorate; test di analytics/OTLP/upload rimossi
Some checks failed
blocking-ci / rust-ci (push) Has been cancelled
blocking-ci / sdk (push) Has been cancelled
blocking-ci / CI required (push) Has been cancelled
blocking-ci / Bazel (push) Has been cancelled
blocking-ci / Blob size policy (push) Has been cancelled
blocking-ci / cargo-deny (push) Has been cancelled
blocking-ci / Codespell (push) Has been cancelled
blocking-ci / repo-checks (push) Has been cancelled
postmerge-ci / rust-ci-full (push) Has been cancelled
postmerge-ci / v8-canary (push) Has been cancelled
postmerge-ci / Postmerge CI results (push) Has been cancelled

This commit is contained in:
Andrea
2026-11-09 18:45:41 +01:00
parent 981745ccc8
commit 60532b6337
509 changed files with 2043 additions and 46606 deletions

View File

@@ -409,8 +409,6 @@ impl PidBackend {
}
};
if matches!(self.command_kind, PidCommandKind::AppServer { .. }) {
// Match first-party clients' default while preserving explicit analytics opt-outs.
args.push("--analytics-default-enabled".into());
for (name, enabled) in &self.feature_overrides {
args.extend(["-c".into(), format!("features.{name}={enabled}").into()]);
}

View File

@@ -10,7 +10,7 @@ use super::PidFileState;
use super::PidRecord;
use super::read_process_start_time;
use crate::managed_install::executable_identity;
use crate::telemetry::StartFailure;
use crate::start_error::StartFailure;
use anyhow::Context;
use anyhow::Result;
use anyhow::bail;
@@ -107,8 +107,6 @@ impl PidBackend {
}
};
command
// Handoff suppression belongs to the foreground CLI, not its long-lived children.
.env_remove(crate::telemetry::HANDOFF_ENV)
.args(self.command_args().iter().map(std::borrow::Cow::as_ref))
.stdin(Stdio::null())
.stdout(Stdio::null())

View File

@@ -274,7 +274,7 @@ async fn start_retries_stale_empty_pid_file_under_its_own_lock() {
.starts_with("failed to spawn detached app-server process using ")
);
assert_eq!(
crate::telemetry::StartError::from(err).failure_reason(),
crate::start_error::StartError::from(err).failure_reason(),
"spawn"
);
}
@@ -721,12 +721,7 @@ fn app_server_remote_control_setting_never_passes_runtime_flag() {
assert_eq!(
backend.command_args(),
vec![
"app-server",
"--listen",
"unix://",
"--analytics-default-enabled"
]
vec!["app-server", "--listen", "unix://"]
);
}
@@ -740,12 +735,7 @@ fn app_server_disabled_remote_control_uses_compatible_args_and_runtime_env() {
assert_eq!(
backend.command_args(),
vec![
"app-server",
"--listen",
"unix://",
"--analytics-default-enabled"
]
vec!["app-server", "--listen", "unix://"]
);
assert_eq!(
backend.command_env(),

View File

@@ -157,7 +157,7 @@ pub(crate) fn ensure_detached_launch(executable: &Path) -> Result<()> {
let child = match command.spawn() {
Ok(child) => child,
Err(_) => {
return Err(err).context(crate::telemetry::StartFailure::Spawn(
return Err(err).context(crate::start_error::StartFailure::Spawn(
"cannot launch detached daemon".into(),
));
}
@@ -165,7 +165,7 @@ pub(crate) fn ensure_detached_launch(executable: &Path) -> Result<()> {
(child, Err(err).context(DetachedLaunchRestricted))
}
Err(err) => {
return Err(err).context(crate::telemetry::StartFailure::Spawn(
return Err(err).context(crate::start_error::StartFailure::Spawn(
"cannot launch detached daemon".into(),
));
}

View File

@@ -4,7 +4,7 @@
use crate::Daemon;
use crate::LifecycleOutput;
use crate::ensure_supported_platform;
use crate::telemetry::StartError;
use crate::start_error::StartError;
use anyhow::Result;
use anyhow::ensure;
use std::collections::BTreeMap;

View File

@@ -22,7 +22,7 @@ pub use prepare_install::InstallRequest;
pub use prepare_install::update_from_cli;
mod remote_control_client;
mod settings;
pub mod telemetry;
pub mod start_error;
mod thread_recovery;
mod update_loop;
@@ -47,8 +47,8 @@ use managed_install::managed_codex_version;
use serde::Serialize;
use settings::DaemonSettings;
use settings::MAX_SHUTDOWN_GRACE_SECONDS;
use telemetry::StartError;
use telemetry::StartFailure;
use start_error::StartError;
use start_error::StartFailure;
use tokio::time::sleep;
const START_POLL_INTERVAL: Duration = Duration::from_millis(50);

View File

@@ -193,38 +193,6 @@ impl DaemonSettings {
}
}
pub(crate) async fn telemetry_tags(path: &Path) -> Result<[(&'static str, &'static str); 4]> {
let raw: Map<String, Value> = read_settings(path).await?;
// Validate the same snapshot used for presence checks, using the existing settings parser.
let settings: StoredSettings = serde_json::from_value(Value::Object(raw.clone()))?;
settings.updater.validate()?;
validate_shutdown_grace(settings.shutdown_grace_seconds)?;
let updater = raw.get("updater");
let presence = |configured| if configured { "configured" } else { "default" };
Ok([
(
"auto_update",
if settings.updater.auto_update_enabled {
"enabled"
} else {
"disabled"
},
),
(
"auto_update_setting",
presence(updater.is_some_and(|value| value.get("autoUpdateEnabled").is_some())),
),
(
"update_interval_setting",
presence(updater.is_some_and(|value| value.get("updateIntervalMinutes").is_some())),
),
(
"shutdown_grace_setting",
presence(raw.contains_key("shutdownGraceSeconds")),
),
])
}
async fn read_settings<T: DeserializeOwned + Default>(path: &Path) -> Result<T> {
let contents = match fs::read_to_string(path).await {
Ok(contents) => contents,

View File

@@ -129,27 +129,3 @@ async fn update_interval_accepts_long_values_and_rejects_zero() {
}
}
}
#[tokio::test]
async fn telemetry_distinguishes_presence_from_default_values() -> anyhow::Result<()> {
let home = TempDir::new()?;
let dir = home.path().join("app-server-daemon");
tokio::fs::create_dir(&dir).await?;
let path = dir.join("settings.json");
for (contents, presence) in [
("{}", "default"),
(
r#"{"updater":{"autoUpdateEnabled":true,"updateIntervalMinutes":60},"shutdownGraceSeconds":60}"#,
"configured",
),
] {
tokio::fs::write(&path, contents).await?;
assert_eq!(
crate::telemetry::settings_tags(home.path())
.await
.map(|(_, value)| value),
["enabled", presence, presence, presence]
);
}
Ok(())
}

View File

@@ -1,9 +1,6 @@
//! Bounded observations for foreground callers. This module never exports telemetry;
//! in particular, the detached updater must not create a telemetry provider.
//! Typed start failures for foreground callers. Nothing here is reported anywhere.
use std::path::Path;
/// Failure of a foreground auto-start, with the original diagnostic kept separate from the metric.
/// Failure of a foreground auto-start, with the original diagnostic kept separate from its reason.
#[derive(Debug)]
pub struct StartError {
pub error: anyhow::Error,
@@ -59,20 +56,3 @@ impl std::fmt::Display for StartFailure {
}
}
}
/// Suppress child reporting when the foreground TUI handoff owns the observation.
pub const HANDOFF_ENV: &str = "CODEX_DAEMON_TELEMETRY_HANDOFF";
/// Only presence and enabled state leave the settings reader, never values or contents.
/// Missing files mean defaults; unreadable or invalid settings remain unknown.
pub async fn settings_tags(codex_home: &Path) -> [(&'static str, &'static str); 4] {
let path = codex_home
.join(crate::STATE_DIR_NAME)
.join(crate::SETTINGS_FILE_NAME);
crate::settings::telemetry_tags(&path).await.unwrap_or([
("auto_update", "unknown"),
("auto_update_setting", "unknown"),
("update_interval_setting", "unknown"),
("shutdown_grace_setting", "unknown"),
])
}

View File

@@ -842,7 +842,7 @@ async fn readiness_waits_for_a_slow_managed_daemon() {
// The process is alive but has no listening socket throughout the first deadline.
let error = daemon.wait_until_ready().await.unwrap_err();
assert_eq!(
crate::telemetry::StartError::from(error).failure_reason(),
crate::start_error::StartError::from(error).failure_reason(),
"readiness_timeout"
);
let (ready, listener) = tokio::join!(daemon.wait_until_ready(), async {
@@ -900,9 +900,9 @@ async fn daemon_start_and_restart_preserve_launch_features() {
features
);
let expected = if features.is_empty() {
"app-server\n--listen\nunix://\n--analytics-default-enabled\n--managed-daemon\n"
"app-server\n--listen\nunix://\n--managed-daemon\n"
} else {
"app-server\n--listen\nunix://\n--analytics-default-enabled\n-c\nfeatures.api_key_model_discovery=true\n-c\nfeatures.code_mode_host=false\n--managed-daemon\n"
"app-server\n--listen\nunix://\n-c\nfeatures.api_key_model_discovery=true\n-c\nfeatures.code_mode_host=false\n--managed-daemon\n"
};
assert_eq!(std::fs::read_to_string(&args_path).unwrap(), expected);
let reused = daemon