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

@@ -94,10 +94,7 @@ async fn background_routing_skips_config_until_chatgpt_sign_in(
),
);
let (sender, _receiver) = tokio::sync::mpsc::channel(16);
let outgoing = Arc::new(OutgoingMessageSender::new(
sender,
codex_analytics::AnalyticsEventsClient::disabled(),
));
let outgoing = Arc::new(OutgoingMessageSender::new(sender));
let model_catalog = Arc::new(crate::model_catalog::ModelCatalog::new(
manager.clone(),
Some(config.cwd.to_path_buf()),

View File

@@ -9,7 +9,6 @@ use crate::model_catalog::ModelCatalog;
use crate::otel_config::map_otel_requirements_to_api;
use crate::outgoing_message::ConnectionRequestId;
use crate::outgoing_message::OutgoingMessageSender;
use codex_analytics::AnalyticsEventsClient;
use codex_app_server_protocol::AllowDenyRequirement;
use codex_app_server_protocol::AutoReviewRequirements;
use codex_app_server_protocol::BrowserUseAccessApprovalLifetime;
@@ -57,7 +56,6 @@ use codex_features::Feature;
use codex_features::canonical_feature_for_key;
use codex_features::feature_for_key;
use codex_model_provider::create_model_provider;
use codex_plugin::PluginId;
use codex_protocol::config_types::ForcedLoginMethod;
use codex_protocol::config_types::WebSearchMode;
use serde_json::json;
@@ -89,7 +87,6 @@ pub(crate) struct ConfigRequestProcessor {
config_manager: ConfigManager,
thread_manager: Arc<ThreadManager>,
model_catalog: Arc<ModelCatalog>,
analytics_events_client: AnalyticsEventsClient,
}
impl ConfigRequestProcessor {
@@ -98,14 +95,12 @@ impl ConfigRequestProcessor {
config_manager: ConfigManager,
thread_manager: Arc<ThreadManager>,
model_catalog: Arc<ModelCatalog>,
analytics_events_client: AnalyticsEventsClient,
) -> Self {
Self {
outgoing,
config_manager,
thread_manager,
model_catalog,
analytics_events_client,
}
}
@@ -283,35 +278,20 @@ impl ConfigRequestProcessor {
&self,
params: ConfigValueWriteParams,
) -> Result<ConfigWriteResponse, JSONRPCErrorError> {
let pending_changes = codex_core_plugins::toggles::collect_plugin_enabled_candidates(
[(&params.key_path, &params.value)].into_iter(),
);
let response = self
.config_manager
self.config_manager
.write_value(params)
.await
.map_err(map_error)?;
self.emit_plugin_toggle_events(pending_changes).await;
Ok(response)
.map_err(map_error)
}
async fn batch_write_inner(
&self,
params: ConfigBatchWriteParams,
) -> Result<ConfigWriteResponse, JSONRPCErrorError> {
let pending_changes = codex_core_plugins::toggles::collect_plugin_enabled_candidates(
params
.edits
.iter()
.map(|edit| (&edit.key_path, &edit.value)),
);
let response = self
.config_manager
self.config_manager
.batch_write(params)
.await
.map_err(map_error)?;
self.emit_plugin_toggle_events(pending_changes).await;
Ok(response)
.map_err(map_error)
}
async fn set_experimental_feature_enablement(
@@ -367,26 +347,6 @@ impl ConfigRequestProcessor {
Ok(ExperimentalFeatureEnablementSetResponse { enablement })
}
async fn emit_plugin_toggle_events(
&self,
pending_changes: std::collections::BTreeMap<String, bool>,
) {
let plugins_manager = self.thread_manager.plugins_manager();
for (plugin_id, enabled) in pending_changes {
let Ok(plugin_id) = PluginId::parse(&plugin_id) else {
continue;
};
let metadata = plugins_manager
.telemetry_metadata_for_installed_plugin(&plugin_id)
.await;
if enabled {
self.analytics_events_client.track_plugin_enabled(metadata);
} else {
self.analytics_events_client.track_plugin_disabled(metadata);
}
}
}
}
pub(super) async fn reload_user_config(

View File

@@ -2,7 +2,7 @@
//!
//! Feedback upload should never depend on doctor succeeding. This module runs
//! the configured Codex executable as a subprocess, accepts only valid JSON from
//! `codex doctor --json --feedback`, derives a small set of Sentry tags, and otherwise
//! `codex doctor --json --feedback`, derives a small set of report tags, and otherwise
//! skips the attachment with a warning. Keeping the report generation out of the
//! app-server process avoids sharing doctor internals across crates while still
//! using the CLI's JSON report format with bounded database scans.
@@ -29,7 +29,7 @@ const MAX_DOCTOR_TAG_VALUE_LEN: usize = 256;
pub(crate) struct DoctorFeedbackReport {
/// JSON support report to upload as `codex-doctor-report.json`.
pub(crate) attachment: FeedbackAttachment,
/// Low-cardinality Sentry tags derived from the report status and check ids.
/// Low-cardinality report tags derived from the report status and check ids.
pub(crate) tags: BTreeMap<String, String>,
}

View File

@@ -21,6 +21,11 @@ use sha2::Sha256;
use std::path::Path;
use tokio::sync::Semaphore;
struct SavedFeedback {
thread_id: String,
prompt_hash: Option<String>,
}
#[derive(Clone)]
pub(crate) struct FeedbackRequestProcessor {
auth_manager: Arc<AuthManager>,
@@ -29,7 +34,7 @@ pub(crate) struct FeedbackRequestProcessor {
feedback: CodexFeedback,
log_db: Option<LogDbLayer>,
state_db: Option<StateDbHandle>,
uploads: Arc<Semaphore>,
saves: Arc<Semaphore>,
}
impl FeedbackRequestProcessor {
@@ -48,24 +53,10 @@ impl FeedbackRequestProcessor {
feedback,
log_db,
state_db,
uploads: Arc::new(Semaphore::new(/*permits*/ 3)),
saves: Arc::new(Semaphore::new(/*permits*/ 3)),
}
}
pub(crate) async fn feedback_upload(
&self,
params: FeedbackUploadParams,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
if !self.config.feedback_enabled {
return Err(invalid_request(
"sending feedback is disabled by configuration",
));
}
self.feedback_response(params, /*save_path*/ None)
.await
.map(|response| Some(response.into()))
}
pub(crate) async fn feedback_save(
&self,
params: FeedbackSaveParams,
@@ -78,9 +69,7 @@ impl FeedbackRequestProcessor {
let save_path = AbsolutePathBuf::try_from(params.save_path)
.map_err(|error| invalid_request(format!("invalid feedback savePath: {error}")))?;
let saved_path = LegacyAppPathString::from_abs_path(&save_path);
let response = self
.feedback_response(params.feedback, Some(save_path))
.await?;
let response = self.feedback_response(params.feedback, save_path).await?;
Ok(Some(
FeedbackSaveResponse {
saved_path,
@@ -93,22 +82,22 @@ impl FeedbackRequestProcessor {
async fn feedback_response(
&self,
params: FeedbackUploadParams,
save_path: Option<AbsolutePathBuf>,
) -> Result<FeedbackUploadResponse, JSONRPCErrorError> {
params: FeedbackReportParams,
save_path: AbsolutePathBuf,
) -> Result<SavedFeedback, JSONRPCErrorError> {
let permit = self
.uploads
.saves
.clone()
.try_acquire_owned()
.map_err(|_| JSONRPCErrorError {
code: OVERLOADED_ERROR_CODE,
message:
"Three feedback uploads are already in progress; try again after one finishes"
"Three feedback saves are already in progress; try again after one finishes"
.to_string(),
data: None,
})?;
let FeedbackUploadParams {
let FeedbackReportParams {
classification,
reason,
thread_id,
@@ -116,7 +105,7 @@ impl FeedbackRequestProcessor {
extra_log_files,
tags,
} = params;
let mut upload_tags = tags.unwrap_or_default();
let mut report_tags = tags.unwrap_or_default();
let conversation_id = match thread_id.as_deref() {
Some(thread_id) => match ThreadId::from_string(thread_id) {
@@ -126,23 +115,22 @@ impl FeedbackRequestProcessor {
None => None,
};
let http_client_factory = self.config.http_client_factory();
let auth = self.auth_manager.auth_cached();
let turn_metadata = if let Some(conversation_id) = conversation_id
&& let Some(rollout_path) = self
.resolve_rollout_path(conversation_id, self.state_db.as_ref(), save_path.as_ref())
.resolve_rollout_path(conversation_id, self.state_db.as_ref())
.await?
{
feedback_turn_metadata_from_rollout(
&rollout_path,
upload_tags.get("turn_id").map(String::as_str),
report_tags.get("turn_id").map(String::as_str),
)
.await
} else {
None
};
apply_feedback_turn_metadata(&mut upload_tags, turn_metadata);
let prompt_hash = upload_tags.get("prompt_hash").cloned();
apply_feedback_turn_metadata(&mut report_tags, turn_metadata);
let prompt_hash = report_tags.get("prompt_hash").cloned();
if let Some(chatgpt_user_id) = auth
.as_ref()
@@ -230,11 +218,7 @@ impl FeedbackRequestProcessor {
.flat_map(|index| &mut index.threads)
{
if let Some(rollout_path) = self
.resolve_rollout_path(
thread.thread_id,
state_db_ctx.as_ref(),
save_path.as_ref(),
)
.resolve_rollout_path(thread.thread_id, state_db_ctx.as_ref())
.await?
&& seen_attachment_paths.insert(rollout_path.clone())
{
@@ -259,10 +243,7 @@ impl FeedbackRequestProcessor {
});
}
}
if let Some(mut index) = feedback_index {
if save_path.is_some() {
index.rollout_archive_filename = None;
}
if let Some(index) = feedback_index {
match index.attachment() {
Ok(attachment) => extra_attachments.insert(0, attachment),
Err(err) => warn!("failed to serialize feedback thread index: {err}"),
@@ -309,7 +290,7 @@ impl FeedbackRequestProcessor {
{
extra_attachments.push(doctor_report.attachment);
for (key, value) in doctor_report.tags {
upload_tags.entry(key).or_insert(value);
report_tags.entry(key).or_insert(value);
}
}
extra_attachments.extend(
@@ -322,23 +303,17 @@ impl FeedbackRequestProcessor {
}
let session_source = self.thread_manager.session_source();
let runtime_handle = tokio::runtime::Handle::current();
let codex_home = self.config.codex_home.clone();
let operation = if save_path.is_some() {
"save"
} else {
"upload"
};
let upload_result = tokio::task::spawn_blocking(move || {
// Cancelling the RPC waiter must not release a still-running upload's slot.
let save_result = tokio::task::spawn_blocking(move || {
// Cancelling the RPC waiter must not release a still-running save's slot.
let _permit = permit;
if include_logs {
extra_attachments
.extend(codex_feedback::daemon_log_attachments(codex_home.as_path()));
}
let tags = (!upload_tags.is_empty()).then_some(&upload_tags);
let options = FeedbackUploadOptions {
let tags = (!report_tags.is_empty()).then_some(&report_tags);
let options = FeedbackSaveOptions {
classification: &classification,
reason: reason.as_deref(),
tags,
@@ -348,27 +323,21 @@ impl FeedbackRequestProcessor {
session_source: Some(session_source),
logs_override: sqlite_feedback_logs,
};
match save_path {
Some(path) => snapshot.save_feedback(options, path.as_path()),
None => {
runtime_handle.block_on(snapshot.upload_feedback(options, &http_client_factory))
}
}
snapshot.save_feedback(options, save_path.as_path())
})
.await;
let upload_result = match upload_result {
let save_result = match save_result {
Ok(result) => result,
Err(join_err) => {
return Err(internal_error(format!(
"failed to {operation} feedback: {join_err}"
"failed to save feedback: {join_err}"
)));
}
};
upload_result
.map_err(|err| internal_error(format!("failed to {operation} feedback: {err:#}")))?;
Ok(FeedbackUploadResponse {
save_result.map_err(|err| internal_error(format!("failed to save feedback: {err:#}")))?;
Ok(SavedFeedback {
thread_id,
prompt_hash,
})
@@ -378,19 +347,13 @@ impl FeedbackRequestProcessor {
&self,
conversation_id: ThreadId,
state_db_ctx: Option<&StateDbHandle>,
save_path: Option<&AbsolutePathBuf>,
) -> Result<Option<PathBuf>, JSONRPCErrorError> {
if let Ok(conversation) = self.thread_manager.get_thread(conversation_id).await {
if save_path.is_some() {
// Explicit extraLogFiles are collected separately and remain strict, even
// when they name this same not-yet-materialized automatic rollout.
return conversation.feedback_rollout_path().await.map_err(|error| {
internal_error(format!("failed to select feedback rollout: {error}"))
});
}
if let Some(rollout_path) = conversation.rollout_path() {
return Ok(Some(rollout_path));
}
// Explicit extraLogFiles are collected separately and remain strict, even
// when they name this same not-yet-materialized automatic rollout.
return conversation.feedback_rollout_path().await.map_err(|error| {
internal_error(format!("failed to select feedback rollout: {error}"))
});
}
let Some(state_db_ctx) = state_db_ctx else {
@@ -441,13 +404,13 @@ struct FeedbackTurnMetadata {
}
fn apply_feedback_turn_metadata(
upload_tags: &mut BTreeMap<String, String>,
report_tags: &mut BTreeMap<String, String>,
turn_metadata: Option<FeedbackTurnMetadata>,
) {
// These are reserved tags derived from the persisted rollout rather than
// accepted from the feedback request.
upload_tags.remove("prompt_hash");
upload_tags.remove("prompt_version");
report_tags.remove("prompt_hash");
report_tags.remove("prompt_version");
if let Some(FeedbackTurnMetadata {
model,
@@ -455,10 +418,10 @@ fn apply_feedback_turn_metadata(
prompt_hash,
}) = turn_metadata
{
upload_tags.insert("model".to_string(), model);
upload_tags.insert("effort".to_string(), format!("{effort:?}"));
report_tags.insert("model".to_string(), model);
report_tags.insert("effort".to_string(), format!("{effort:?}"));
if let Some(prompt_hash) = prompt_hash {
upload_tags.insert("prompt_hash".to_string(), prompt_hash);
report_tags.insert("prompt_hash".to_string(), prompt_hash);
}
}
}
@@ -649,7 +612,7 @@ mod tests {
#[test]
fn feedback_tags_drop_unverified_client_prompt_tags() {
let mut upload_tags = BTreeMap::from([
let mut report_tags = BTreeMap::from([
("custom".to_string(), "preserved".to_string()),
(
"prompt_hash".to_string(),
@@ -658,23 +621,23 @@ mod tests {
("prompt_version".to_string(), "client-prompt-v1".to_string()),
]);
apply_feedback_turn_metadata(&mut upload_tags, /*turn_metadata*/ None);
apply_feedback_turn_metadata(&mut report_tags, /*turn_metadata*/ None);
assert_eq!(
upload_tags,
report_tags,
BTreeMap::from([("custom".to_string(), "preserved".to_string())])
);
}
#[test]
fn feedback_tags_drop_client_prompt_hash_when_rollout_has_no_hash() {
let mut upload_tags = BTreeMap::from([(
let mut report_tags = BTreeMap::from([(
"prompt_hash".to_string(),
"unverified-client-hash".to_string(),
)]);
apply_feedback_turn_metadata(
&mut upload_tags,
&mut report_tags,
Some(FeedbackTurnMetadata {
model: "reported-model".to_string(),
effort: Some(ReasoningEffort::High),
@@ -683,7 +646,7 @@ mod tests {
);
assert_eq!(
upload_tags,
report_tags,
BTreeMap::from([
("effort".to_string(), "Some(High)".to_string()),
("model".to_string(), "reported-model".to_string()),
@@ -693,13 +656,13 @@ mod tests {
#[test]
fn feedback_tags_replace_client_prompt_hash_with_rollout_hash() {
let mut upload_tags = BTreeMap::from([(
let mut report_tags = BTreeMap::from([(
"prompt_hash".to_string(),
"unverified-client-hash".to_string(),
)]);
apply_feedback_turn_metadata(
&mut upload_tags,
&mut report_tags,
Some(FeedbackTurnMetadata {
model: "reported-model".to_string(),
effort: Some(ReasoningEffort::High),
@@ -708,7 +671,7 @@ mod tests {
);
assert_eq!(
upload_tags,
report_tags,
BTreeMap::from([
("effort".to_string(), "Some(High)".to_string()),
("model".to_string(), "reported-model".to_string()),
@@ -721,17 +684,17 @@ mod tests {
async fn feedback_tags_do_not_trust_the_prompt_version_from_the_reported_rollout() {
let (_tempdir, rollout_path) =
feedback_rollout(&[("turn-1", "synthetic-model", Some(ReasoningEffort::High))]);
let mut upload_tags = BTreeMap::from([(
let mut report_tags = BTreeMap::from([(
"prompt_version".to_string(),
"unverified-client-prompt".to_string(),
)]);
let turn_metadata =
feedback_turn_metadata_from_rollout(&rollout_path, Some("turn-1")).await;
apply_feedback_turn_metadata(&mut upload_tags, turn_metadata);
apply_feedback_turn_metadata(&mut report_tags, turn_metadata);
assert_eq!(
upload_tags,
report_tags,
BTreeMap::from([
("effort".to_string(), "Some(High)".to_string()),
("model".to_string(), "synthetic-model".to_string()),

View File

@@ -1,6 +1,6 @@
//! Selects a bounded set of spawned descendants and directly attached threads for feedback,
//! preserving the reported thread and prioritizing children with retained failed reviews.
//! Filenames identify selected archive entries or fallback attachments. Delivery is best effort.
//! Filenames identify the rollout entries saved in the local feedback archive.
use codex_feedback::FeedbackAttachment;
use codex_feedback::GuardianReviewFailures;
@@ -14,7 +14,6 @@ const MAX_LISTED_OMISSIONS: usize = 64;
#[derive(Serialize)]
pub(super) struct FeedbackThreadIndex {
pub(super) rollout_archive_filename: Option<&'static str>,
pub threads: Vec<FeedbackThread>,
retained_failure_thread_ids: Vec<ThreadId>,
omitted_thread_ids: Vec<ThreadId>,
@@ -58,7 +57,6 @@ impl FeedbackThreadIndex {
.take(MAX_LISTED_OMISSIONS)
.collect::<Vec<_>>();
Self {
rollout_archive_filename: Some("rollouts.tar.gz"),
threads: thread_ids
.into_iter()
.map(|thread_id| FeedbackThread {
@@ -71,7 +69,7 @@ impl FeedbackThreadIndex {
unlisted_omitted_thread_count: omitted_count - omitted_thread_ids.len(),
omitted_thread_ids,
process_discarded_review_records: failures.process_discarded_records,
notes: "Selection only, not an upload receipt. Null filenames mean no path was available. \
notes: "Selection only. Null filenames mean no path was available. \
Omitted threads exceeded the rollout thread limit; their retained reviews are \
still in auto-review-failures.jsonl. Review evidence is persisted and bounded; \
missing evidence does not imply no denial. The discarded-record count covers \

View File

@@ -28,7 +28,6 @@ fn old_failed_child_precedes_new_children_and_index_explains_selection() -> anyh
assert_eq!(
serde_json::from_slice::<serde_json::Value>(&attachment.buffer)?,
json!({
"rollout_archive_filename": "rollouts.tar.gz",
"threads": selected.into_iter().map(|i| json!({
"thread_id": ids[i],
"rollout_filename": match i {

View File

@@ -2,7 +2,6 @@ use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
use axum::http::HeaderValue;
use codex_analytics::AppServerRpcTransport;
use codex_login::default_client::SetOriginatorError;
use codex_login::default_client::USER_AGENT_SUFFIX;
use codex_login::default_client::get_codex_user_agent;
@@ -23,9 +22,7 @@ pub(crate) struct InitializeRequestProcessor {
gateway_login_control: Arc<codex_login::GatewayLoginControl>,
gateway_login_initialized: Arc<std::sync::OnceLock<()>>,
outgoing: Arc<OutgoingMessageSender>,
analytics_events_client: AnalyticsEventsClient,
config: Arc<Config>,
rpc_transport: AppServerRpcTransport,
user_verification: Arc<crate::user_verification::Service>,
}
@@ -34,18 +31,14 @@ impl InitializeRequestProcessor {
pub(crate) fn new(
gateway_login_control: Arc<codex_login::GatewayLoginControl>,
outgoing: Arc<OutgoingMessageSender>,
analytics_events_client: AnalyticsEventsClient,
config: Arc<Config>,
rpc_transport: AppServerRpcTransport,
user_verification: Arc<crate::user_verification::Service>,
) -> Self {
Self {
gateway_login_control,
gateway_login_initialized: Arc::new(std::sync::OnceLock::new()),
outgoing,
analytics_events_client,
config,
rpc_transport,
user_verification,
}
}
@@ -75,7 +68,6 @@ impl InitializeRequestProcessor {
// shared thread when another connected client did not opt into
// experimental API). Proposed direction is instance-global first-write-wins
// with initialize-time mismatch rejection.
let analytics_initialize_params = params.clone();
let capabilities = params.capabilities.unwrap_or_default();
let experimental_api_enabled = capabilities.experimental_api;
let request_attestation = capabilities.request_attestation;
@@ -184,12 +176,6 @@ impl InitializeRequestProcessor {
}
}
}
self.analytics_events_client.track_initialize(
connection_id.0,
analytics_initialize_params,
originator,
self.rpc_transport,
);
set_default_client_residency_requirement(self.config.enforce_residency.value());
if mutates_global_identity && let Ok(mut suffix) = USER_AGENT_SUFFIX.lock() {
*suffix = Some(user_agent_suffix);
@@ -230,14 +216,4 @@ impl InitializeRequestProcessor {
Ok(false)
}
pub(crate) fn track_initialized_request(
&self,
connection_id: ConnectionId,
request_id: RequestId,
request: &ClientRequest,
) {
self.analytics_events_client
.track_request(connection_id.0, request_id, request);
}
}

View File

@@ -3,7 +3,6 @@ use super::*;
use crate::error_code::internal_error;
use crate::error_code::invalid_request;
use crate::error_code::method_not_found;
use codex_analytics::PluginInstallSource;
use codex_app_server_protocol::PluginAvailability;
use codex_app_server_protocol::PluginSharePrincipalRole;
use codex_config::types::McpServerConfig;
@@ -34,7 +33,6 @@ use codex_mcp::oauth_login_support;
use codex_mcp::resolve_oauth_callback;
use codex_mcp::should_retry_without_scopes;
use codex_plugin::PluginId;
use codex_plugin::PluginTelemetryMetadata;
use codex_protocol::auth::AuthMode as DomainAuthMode;
use codex_rmcp_client::McpOAuthClientRegistration;
use codex_rmcp_client::OAuthDiscoveryTimeout;
@@ -60,7 +58,6 @@ pub(crate) struct PluginRequestProcessor {
auth_manager: Arc<AuthManager>,
thread_manager: Arc<ThreadManager>,
outgoing: Arc<OutgoingMessageSender>,
analytics_events_client: AnalyticsEventsClient,
config_manager: ConfigManager,
on_effective_plugins_changed:
Arc<dyn Fn(codex_core_plugins::EffectivePluginsChange) + Send + Sync>,
@@ -326,7 +323,6 @@ impl PluginRequestProcessor {
auth_manager: Arc<AuthManager>,
thread_manager: Arc<ThreadManager>,
outgoing: Arc<OutgoingMessageSender>,
analytics_events_client: AnalyticsEventsClient,
config_manager: ConfigManager,
on_effective_plugins_changed: Arc<
dyn Fn(codex_core_plugins::EffectivePluginsChange) + Send + Sync,
@@ -336,7 +332,6 @@ impl PluginRequestProcessor {
auth_manager,
thread_manager,
outgoing,
analytics_events_client,
config_manager,
on_effective_plugins_changed,
}
@@ -1363,7 +1358,7 @@ impl PluginRequestProcessor {
.as_ref()
.map(|id| id.marketplace_name.as_str())
.unwrap_or(&remote_marketplace_name);
self.track_plugin_install_failed_for_remote_plugin(
self.log_remote_plugin_install_failure(
&remote_plugin_id,
marketplace,
err.plugin_id.as_ref(),
@@ -1378,17 +1373,6 @@ impl PluginRequestProcessor {
let remote_detail = installation.detail;
let result = installation.installed;
let plugin_metadata = self
.thread_manager
.plugins_manager()
.telemetry_metadata_for_installed_plugin_with_remote_id(
&result.plugin_id,
&remote_plugin_id,
)
.await;
self.analytics_events_client
.track_plugin_installed(plugin_metadata);
let config = match self.load_latest_config(/*fallback_cwd*/ None).await {
Ok(mut reloaded_config) => {
// Keep the policy captured with this installation's auth snapshot.
@@ -1476,11 +1460,11 @@ impl PluginRequestProcessor {
})
}
fn track_plugin_install_failed_for_remote_plugin(
fn log_remote_plugin_install_failure(
&self,
remote_plugin_id: &str,
marketplace_name: &str,
plugin_id: Option<&PluginId>,
_plugin_id: Option<&PluginId>,
error_type: &'static str,
sub_error_type: Option<String>,
error_message: String,
@@ -1493,23 +1477,6 @@ impl PluginRequestProcessor {
error = %error_message,
"remote plugin install failed"
);
let plugin = if let Some(plugin_id) = plugin_id {
self.thread_manager
.plugins_manager()
.telemetry_metadata_for_plugin_id_with_remote_id(plugin_id, remote_plugin_id)
} else {
PluginTelemetryMetadata {
plugin_id: None,
remote_plugin_id: Some(remote_plugin_id.to_string()),
capability_summary: None,
}
};
self.analytics_events_client.track_plugin_install_failed(
plugin,
PluginInstallSource::Manual,
error_type.to_string(),
sub_error_type,
);
}
/// ChatGPT apps never need auth in aKode: the hosted apps MCP server is never used.
@@ -1784,8 +1751,6 @@ impl PluginRequestProcessor {
)
.await
.map_err(remote_plugin_operation_error_to_jsonrpc)?;
self.analytics_events_client
.track_plugin_uninstalled(outcome.telemetry);
if outcome.effective_plugins_changed {
self.on_effective_plugins_changed().await;
}

View File

@@ -4,7 +4,6 @@
use super::*;
use crate::outgoing_message::OutgoingEnvelope;
use crate::outgoing_message::OutgoingMessage;
use codex_analytics::AnalyticsEventsClient;
use pretty_assertions::assert_eq;
fn start_collector(
@@ -22,10 +21,7 @@ fn start_collector(
output_rx,
reader: None,
process_exited,
outgoing: Arc::new(OutgoingMessageSender::new(
tx,
AnalyticsEventsClient::disabled(),
)),
outgoing: Arc::new(OutgoingMessageSender::new(tx)),
stream: ProcessOutputStream::Stdout,
stream_output: true,
output_bytes_cap: None,
@@ -128,10 +124,7 @@ async fn timed_out_stderr_closes_while_stdout_is_still_open() {
output_rx: child.stderr_rx,
reader: child.session.stderr_reader(),
process_exited: process_exited.clone(),
outgoing: Arc::new(OutgoingMessageSender::new(
tx,
AnalyticsEventsClient::disabled(),
)),
outgoing: Arc::new(OutgoingMessageSender::new(tx)),
stream: ProcessOutputStream::Stderr,
stream_output: false,
output_bytes_cap: Some(3),
@@ -189,10 +182,7 @@ async fn windows_terminal_reports_exit_before_closing_the_console() {
let (_control_tx, control_rx) = mpsc::channel(1);
let (tx, mut notifications) = mpsc::channel(1);
let process = tokio::spawn(run_process(RunProcessParams {
outgoing: Arc::new(OutgoingMessageSender::new(
tx,
AnalyticsEventsClient::disabled(),
)),
outgoing: Arc::new(OutgoingMessageSender::new(tx)),
request_id: ConnectionRequestId {
connection_id: ConnectionId(1),
request_id: codex_app_server_protocol::RequestId::Integer(1),

View File

@@ -1212,7 +1212,6 @@ pub(super) async fn handle_pending_thread_resume_request(
workspace_roots,
reasoning_effort,
collaboration_mode,
originator,
..
} = config_snapshot;
let instruction_sources = pending.instruction_sources;
@@ -1241,9 +1240,7 @@ pub(super) async fn handle_pending_thread_resume_request(
turns_backwards_cursor,
items_backwards_cursor,
};
outgoing
.send_response_with_thread_originator(request_id, response, originator)
.await;
outgoing.send_response(request_id, response).await;
// Warm metadata-only resumes skip history reconstruction. Cold paginated children can
// replay usage using attribution captured before the listener was attached.
if let Some(token_usage_turn_id) = token_usage_turn_id {

View File

@@ -15,7 +15,6 @@ use crate::thread_state::PendingNetworkApproval;
use crate::thread_state::resolve_server_request_on_thread_listener;
use anyhow::Context;
use anyhow::Result;
use codex_analytics::AnalyticsEventsClient;
use codex_app_server_protocol::ClientResponsePayload;
use codex_app_server_protocol::RequestId;
use codex_app_server_protocol::ThreadResumeParams;
@@ -54,10 +53,7 @@ async fn listener_shutdown_releases_runtime_and_preserves_other_subscribers(
let config_manager =
ConfigManager::without_managed_config_for_tests(config.codex_home.to_path_buf());
let (outgoing_tx, mut outgoing_rx) = mpsc::channel(/*buffer*/ 16);
let outgoing = Arc::new(OutgoingMessageSender::new(
outgoing_tx,
AnalyticsEventsClient::disabled(),
));
let outgoing = Arc::new(OutgoingMessageSender::new(outgoing_tx));
let thread_state_manager = ThreadStateManager::new();
let thread_watch_manager = ThreadWatchManager::new_with_outgoing(outgoing.clone());
let skills_watcher = SkillsWatcher::new(

View File

@@ -1752,7 +1752,6 @@ impl ThreadRequestProcessor {
let cwd = config_snapshot.cwd().clone();
let active_permission_profile =
thread_response_active_permission_profile(config_snapshot.active_permission_profile);
let thread_originator = config_snapshot.originator.clone();
let response = ThreadStartResponse {
thread: thread.clone(),
@@ -1773,7 +1772,7 @@ impl ThreadRequestProcessor {
let notif = thread_started_notification(thread);
listener_task_context
.outgoing
.send_response_with_thread_originator(request_id, response, thread_originator)
.send_response(request_id, response)
.instrument(tracing::info_span!(
"app_server.thread_start.send_response",
otel.name = "app_server.thread_start.send_response",
@@ -4577,7 +4576,6 @@ impl ThreadRequestProcessor {
}
}
let thread_originator = config_snapshot.originator.clone();
let response = ThreadResumeResponse {
thread,
disabled_plugin_ids: config_snapshot.disabled_plugin_ids,
@@ -4600,9 +4598,7 @@ impl ThreadRequestProcessor {
};
let connection_id = request_id.connection_id;
self.outgoing
.send_response_with_thread_originator(request_id, response, thread_originator)
.await;
self.outgoing.send_response(request_id, response).await;
// `excludeTurns` is explicitly the cheap resume path, so avoid
// rebuilding history only to attribute a replayed usage update.
if let Some(token_usage_turn_id) = token_usage_turn_id {
@@ -5946,7 +5942,6 @@ impl ThreadRequestProcessor {
let sandbox = config_snapshot.sandbox_policy().into();
let active_permission_profile =
thread_response_active_permission_profile(config_snapshot.active_permission_profile);
let thread_originator = config_snapshot.originator.clone();
let response = ThreadForkResponse {
thread: thread.clone(),
disabled_plugin_ids: config_snapshot.disabled_plugin_ids,
@@ -5966,9 +5961,7 @@ impl ThreadRequestProcessor {
let notif = thread_started_notification(thread);
let connection_id = request_id.connection_id;
self.outgoing
.send_response_with_thread_originator(request_id, response, thread_originator)
.await;
self.outgoing.send_response(request_id, response).await;
// `excludeTurns` is the cheap fork path, so skip restored usage replay
// instead of rebuilding history only to attribute a historical update.
if let Some(token_usage_turn_id) = token_usage_turn_id {

View File

@@ -1138,10 +1138,7 @@ mod thread_processor_behavior_tests {
let connection_id = ConnectionId(7);
let (outgoing_tx, mut outgoing_rx) = tokio::sync::mpsc::channel(8);
let outgoing = Arc::new(OutgoingMessageSender::new(
outgoing_tx,
codex_analytics::AnalyticsEventsClient::disabled(),
));
let outgoing = Arc::new(OutgoingMessageSender::new(outgoing_tx));
let thread_outgoing = ThreadScopedOutgoingMessageSender::new(
outgoing.clone(),
vec![connection_id],

View File

@@ -82,7 +82,6 @@ fn validate_response_item_image_urls(items: &[ResponseItem]) -> Result<(), JSONR
pub(crate) struct TurnRequestProcessor {
thread_manager: Arc<ThreadManager>,
outgoing: Arc<OutgoingMessageSender>,
analytics_events_client: AnalyticsEventsClient,
config: Arc<Config>,
config_manager: ConfigManager,
pending_thread_unloads: PendingThreadUnloads,
@@ -139,7 +138,6 @@ impl TurnRequestProcessor {
pub(crate) fn new(
thread_manager: Arc<ThreadManager>,
outgoing: Arc<OutgoingMessageSender>,
analytics_events_client: AnalyticsEventsClient,
config: Arc<Config>,
config_manager: ConfigManager,
pending_thread_unloads: PendingThreadUnloads,
@@ -150,7 +148,6 @@ impl TurnRequestProcessor {
Self {
thread_manager,
outgoing,
analytics_events_client,
config,
config_manager,
pending_thread_unloads,
@@ -305,11 +302,9 @@ impl TurnRequestProcessor {
request_id: &ConnectionRequestId,
params: TurnInterruptParams,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
let result = self.turn_interrupt_inner(request_id, params).await;
if let Err(error) = &result {
self.track_error_response(request_id, error, /*error_type*/ None);
}
result.map(|response| response.map(Into::into))
self.turn_interrupt_inner(request_id, params)
.await
.map(|response| response.map(Into::into))
}
pub(crate) async fn thread_realtime_start(
@@ -400,20 +395,6 @@ impl TurnRequestProcessor {
))
}
fn track_error_response(
&self,
request_id: &ConnectionRequestId,
error: &JSONRPCErrorError,
error_type: Option<AnalyticsJsonRpcError>,
) {
self.analytics_events_client.track_error_response(
request_id.connection_id.0,
request_id.request_id.clone(),
error.clone(),
error_type,
);
}
async fn load_thread(
&self,
thread_id: &str,
@@ -433,14 +414,10 @@ impl TurnRequestProcessor {
async fn ensure_direct_input_allowed(
&self,
request_id: &ConnectionRequestId,
_request_id: &ConnectionRequestId,
thread: &CodexThread,
) -> Result<(), JSONRPCErrorError> {
ensure_direct_input_allowed(thread)
.await
.inspect_err(|error| {
self.track_error_response(request_id, error, /*error_type*/ None);
})
ensure_direct_input_allowed(thread).await
}
fn normalize_collaboration_mode(
@@ -544,12 +521,7 @@ impl TurnRequestProcessor {
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
) -> Result<TurnStartResponse, JSONRPCErrorError> {
let (thread_id, thread) =
self.load_thread(&params.thread_id)
.await
.inspect_err(|error| {
self.track_error_response(&request_id, error, /*error_type*/ None);
})?;
let (thread_id, thread) = self.load_thread(&params.thread_id).await?;
self.ensure_direct_input_allowed(&request_id, thread.as_ref())
.await?;
self.config_manager
@@ -588,11 +560,6 @@ impl TurnRequestProcessor {
});
if actual_chars > MAX_USER_INPUT_TEXT_CHARS {
let error = Self::input_too_large_error(actual_chars);
self.track_error_response(
&request_id,
&error,
Some(AnalyticsJsonRpcError::Input(InputError::TooLarge)),
);
return Err(error);
}
// Validate before changing the thread's live MCP policy.
@@ -600,19 +567,13 @@ impl TurnRequestProcessor {
additional_context
.values()
.try_for_each(CoreAdditionalContextEntry::validate)
.map_err(invalid_request)
.inspect_err(|error| {
self.track_error_response(&request_id, error, /*error_type*/ None);
})?;
.map_err(invalid_request)?;
Self::set_app_server_client_info(
thread.as_ref(),
app_server_client_name,
app_server_client_version,
)
.await
.inspect_err(|error| {
self.track_error_response(&request_id, error, /*error_type*/ None);
})?;
.await?;
let runtime_workspace_roots = params
.runtime_workspace_roots
.map(resolve_runtime_workspace_roots);
@@ -706,7 +667,6 @@ impl TurnRequestProcessor {
CodexErrorDetails::InvalidRequest(message) => invalid_request(message.clone()),
_ => internal_error(format!("failed to submit turn input: {err}")),
};
self.track_error_response(&request_id, &error, /*error_type*/ None);
error
})?;
let (turn_id, root_turn_id, started) = match submission {
@@ -729,7 +689,6 @@ impl TurnRequestProcessor {
} else {
internal_error(format!("failed to submit turn input: {reason:?}"))
};
self.track_error_response(&request_id, &error, /*error_type*/ None);
return Err(error);
}
};
@@ -1079,12 +1038,7 @@ impl TurnRequestProcessor {
request_id: &ConnectionRequestId,
params: TurnSteerParams,
) -> Result<TurnSteerResponse, JSONRPCErrorError> {
let (_, thread) = self
.load_thread(&params.thread_id)
.await
.inspect_err(|error| {
self.track_error_response(request_id, error, /*error_type*/ None);
})?;
let (_, thread) = self.load_thread(&params.thread_id).await?;
self.ensure_direct_input_allowed(request_id, thread.as_ref())
.await?;
self.config_manager
@@ -1099,11 +1053,6 @@ impl TurnRequestProcessor {
.record_request_turn_id(request_id, &params.expected_turn_id)
.await;
if let Err(error) = Self::validate_v2_input_limit(&params.input) {
self.track_error_response(
request_id,
&error,
Some(AnalyticsJsonRpcError::Input(InputError::TooLarge)),
);
return Err(error);
}
@@ -1131,40 +1080,30 @@ impl TurnRequestProcessor {
CodexErrorDetails::InvalidRequest(message) => invalid_request(message.clone()),
_ => internal_error(format!("failed to steer turn: {err}")),
};
self.track_error_response(request_id, &error, /*error_type*/ None);
error
})?;
let turn_id = match submission {
SteerSubmission::Steered { turn_id } => turn_id,
SteerSubmission::NotSubmitted { reason } => {
let (message, data, error_type) = match reason {
let (message, data) = match reason {
NotSubmittedReason::ServerDraining => {
return Err(crate::error_code::server_draining_error());
}
NotSubmittedReason::NoActiveTurn | NotSubmittedReason::NotIdle => (
"no active turn to steer".to_string(),
None,
Some(AnalyticsJsonRpcError::TurnSteer(
TurnSteerRequestError::NoActiveTurn,
)),
),
NotSubmittedReason::NoActiveTurn | NotSubmittedReason::NotIdle => {
("no active turn to steer".to_string(), None)
}
NotSubmittedReason::ExpectedTurnMismatch { expected, actual } => (
format!("expected active turn id `{expected}` but found `{actual}`"),
None,
Some(AnalyticsJsonRpcError::TurnSteer(
TurnSteerRequestError::ExpectedTurnMismatch,
)),
),
NotSubmittedReason::ActiveTurnNotSteerable { turn_kind } => {
let (message, turn_steer_error) = match turn_kind {
codex_protocol::protocol::NonSteerableTurnKind::Review => (
"cannot steer a review turn".to_string(),
TurnSteerRequestError::NonSteerableReview,
),
codex_protocol::protocol::NonSteerableTurnKind::Compact => (
"cannot steer a compact turn".to_string(),
TurnSteerRequestError::NonSteerableCompact,
),
let message = match turn_kind {
codex_protocol::protocol::NonSteerableTurnKind::Review => {
"cannot steer a review turn".to_string()
}
codex_protocol::protocol::NonSteerableTurnKind::Compact => {
"cannot steer a compact turn".to_string()
}
};
let error = TurnError {
misalignment: None,
@@ -1184,35 +1123,21 @@ impl TurnRequestProcessor {
None
}
};
(
message,
data,
Some(AnalyticsJsonRpcError::TurnSteer(turn_steer_error)),
)
(message, data)
}
NotSubmittedReason::EmptyInput => (
"input must not be empty".to_string(),
None,
Some(AnalyticsJsonRpcError::Input(InputError::Empty)),
),
NotSubmittedReason::EmptyInput => ("input must not be empty".to_string(), None),
NotSubmittedReason::ActiveTurnOutputSchemaMismatch => (
"active turn uses a different output schema".to_string(),
None,
None,
),
NotSubmittedReason::PendingTriggerTurn
| NotSubmittedReason::PlanMode
| NotSubmittedReason::Superseded => (
"no active turn to steer".to_string(),
None,
Some(AnalyticsJsonRpcError::TurnSteer(
TurnSteerRequestError::NoActiveTurn,
)),
),
| NotSubmittedReason::Superseded => {
("no active turn to steer".to_string(), None)
}
};
let mut error = invalid_request(message);
error.data = data;
self.track_error_response(request_id, &error, error_type);
return Err(error);
}
};