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

@@ -14,7 +14,6 @@ doctest = false
workspace = true
[dependencies]
codex-analytics = { workspace = true }
codex-core = { workspace = true }
codex-extension-api = { workspace = true }
codex-otel = { workspace = true }

View File

@@ -1,77 +0,0 @@
use codex_analytics::AnalyticsEventsClient;
use codex_analytics::CodexGoalEvent;
use codex_analytics::GoalEventKind;
#[derive(Clone)]
pub(crate) struct GoalAnalytics {
client: AnalyticsEventsClient,
}
pub(crate) enum GoalEventAttribution<'a> {
Turn(&'a str),
NoTurn,
}
impl GoalAnalytics {
pub(crate) fn new(client: AnalyticsEventsClient) -> Self {
Self { client }
}
pub(crate) fn created(
&self,
goal: &codex_state::ThreadGoal,
attribution: GoalEventAttribution<'_>,
) {
self.track(goal, attribution, GoalEventKind::Created);
}
pub(crate) fn usage_accounted(
&self,
goal: &codex_state::ThreadGoal,
attribution: GoalEventAttribution<'_>,
) {
self.track(goal, attribution, GoalEventKind::UsageAccounted);
}
pub(crate) fn status_changed(
&self,
goal: &codex_state::ThreadGoal,
previous_status: Option<codex_state::ThreadGoalStatus>,
attribution: GoalEventAttribution<'_>,
) {
if previous_status.is_some_and(|status| status != goal.status) {
self.track(goal, attribution, GoalEventKind::StatusChanged);
}
}
pub(crate) fn cleared(&self, goal: &codex_state::ThreadGoal) {
self.track(goal, GoalEventAttribution::NoTurn, GoalEventKind::Cleared);
}
fn track(
&self,
goal: &codex_state::ThreadGoal,
attribution: GoalEventAttribution<'_>,
event_kind: GoalEventKind,
) {
let (cumulative_tokens_accounted, cumulative_time_accounted_seconds) = match event_kind {
GoalEventKind::UsageAccounted => (Some(goal.tokens_used), Some(goal.time_used_seconds)),
GoalEventKind::Created | GoalEventKind::StatusChanged | GoalEventKind::Cleared => {
(None, None)
}
};
self.client.track_goal_event(CodexGoalEvent {
thread_id: goal.thread_id.to_string(),
turn_id: match attribution {
GoalEventAttribution::Turn(turn_id) => Some(turn_id.to_string()),
GoalEventAttribution::NoTurn => None,
},
goal_id: goal.goal_id.clone(),
event_kind,
goal_status: goal.status,
has_token_budget: goal.token_budget.is_some(),
cumulative_tokens_accounted,
cumulative_time_accounted_seconds,
});
}
}

View File

@@ -1,7 +1,6 @@
use std::sync::Arc;
use std::sync::Weak;
use codex_analytics::AnalyticsEventsClient;
use codex_core::ThreadManager;
use codex_core::TurnStartOptions;
use codex_extension_api::ConfigContributor;
@@ -38,7 +37,6 @@ use codex_protocol::protocol::TokenUsageInfo;
use crate::accounting::BudgetLimitedGoalDisposition;
use crate::accounting::GoalAccountingState;
use crate::analytics::GoalAnalytics;
use crate::api::GoalService;
use crate::events::GoalEventEmitter;
use crate::metrics::GoalMetrics;
@@ -59,7 +57,6 @@ pub struct GoalExtensionConfig {
#[derive(Clone)]
pub struct GoalExtension<C> {
state_dbs: Arc<codex_state::StateRuntime>,
analytics: GoalAnalytics,
event_emitter: GoalEventEmitter,
metrics: GoalMetrics,
thread_manager: Weak<ThreadManager>,
@@ -76,7 +73,6 @@ impl<C> std::fmt::Debug for GoalExtension<C> {
impl<C> GoalExtension<C> {
pub(crate) fn new_with_host_capabilities(
state_dbs: Arc<codex_state::StateRuntime>,
analytics_events_client: AnalyticsEventsClient,
event_sink: Arc<dyn ExtensionEventSink>,
metrics_client: Option<MetricsClient>,
thread_manager: Weak<ThreadManager>,
@@ -85,7 +81,6 @@ impl<C> GoalExtension<C> {
) -> Self {
Self {
state_dbs,
analytics: GoalAnalytics::new(analytics_events_client),
event_emitter: GoalEventEmitter::new(event_sink),
metrics: GoalMetrics::new(metrics_client),
thread_manager,
@@ -149,7 +144,6 @@ where
self.thread_manager.clone(),
accounting_state,
GoalRuntimeConfig {
analytics: self.analytics.clone(),
enabled,
tools_available_for_thread,
tools_visible_for_thread,
@@ -578,7 +572,6 @@ where
runtime.thread_id(),
Arc::clone(&self.state_dbs),
runtime.accounting_state(),
self.analytics.clone(),
self.event_emitter.clone(),
self.metrics.clone(),
),
@@ -586,7 +579,6 @@ where
&runtime,
self.thread_manager.clone(),
Arc::clone(&self.state_dbs),
self.analytics.clone(),
self.event_emitter.clone(),
self.metrics.clone(),
max_goal_token_budget,
@@ -595,7 +587,6 @@ where
runtime.thread_id(),
Arc::clone(&self.state_dbs),
runtime.accounting_state(),
self.analytics.clone(),
self.event_emitter.clone(),
self.metrics.clone(),
),
@@ -613,7 +604,6 @@ where
pub fn install_with_backend<C>(
registry: &mut ExtensionRegistryBuilder<C>,
state_dbs: Arc<codex_state::StateRuntime>,
analytics_events_client: AnalyticsEventsClient,
metrics_client: Option<MetricsClient>,
thread_manager: Weak<ThreadManager>,
goal_service: Arc<GoalService>,
@@ -623,7 +613,6 @@ pub fn install_with_backend<C>(
{
let extension = Arc::new(GoalExtension::new_with_host_capabilities(
state_dbs,
analytics_events_client,
registry.event_sink(),
metrics_client,
thread_manager,

View File

@@ -1,7 +1,6 @@
//! Extension crate for the `/goal` feature.
mod accounting;
mod analytics;
mod api;
mod events;
mod extension;

View File

@@ -12,8 +12,6 @@ use codex_protocol::protocol::ThreadGoal;
use crate::accounting::BudgetLimitedGoalDisposition;
use crate::accounting::GoalAccountingState;
use crate::analytics::GoalAnalytics;
use crate::analytics::GoalEventAttribution;
use crate::events::GoalEventEmitter;
use crate::metrics::GoalMetrics;
use crate::steering::continuation_request;
@@ -28,7 +26,6 @@ pub struct GoalRuntimeHandle {
}
pub(crate) struct GoalRuntimeConfig {
pub(crate) analytics: GoalAnalytics,
pub(crate) enabled: bool,
pub(crate) tools_available_for_thread: bool,
pub(crate) tools_visible_for_thread: bool,
@@ -45,7 +42,6 @@ pub(crate) enum ActiveGoalStopReason {
struct GoalRuntimeInner {
thread_id: ThreadId,
state_dbs: Arc<codex_state::StateRuntime>,
analytics: GoalAnalytics,
event_emitter: GoalEventEmitter,
metrics: GoalMetrics,
thread_manager: Weak<ThreadManager>,
@@ -99,7 +95,6 @@ impl GoalRuntimeHandle {
inner: Arc::new(GoalRuntimeInner {
thread_id,
state_dbs,
analytics: config.analytics,
event_emitter,
metrics,
thread_manager,
@@ -201,9 +196,6 @@ impl GoalRuntimeHandle {
.is_some_and(|previous_goal| previous_goal.goal_id != goal.goal_id);
if previous_goal.is_none() || replaced_existing_goal {
self.inner.metrics.record_created();
self.inner
.analytics
.created(&goal, GoalEventAttribution::NoTurn);
}
let previous_status = previous_goal
.as_ref()
@@ -214,9 +206,6 @@ impl GoalRuntimeHandle {
self.inner
.metrics
.record_terminal_if_status_changed(previous_status, &goal);
self.inner
.analytics
.status_changed(&goal, previous_status, GoalEventAttribution::NoTurn);
let objective_changed = previous_goal.as_ref().is_some_and(|previous_goal| {
!replaced_existing_goal && previous_goal.objective != goal.objective
});
@@ -255,13 +244,11 @@ impl GoalRuntimeHandle {
pub async fn apply_external_goal_clear(
&self,
goal: codex_state::ThreadGoal,
_goal: codex_state::ThreadGoal,
) -> Result<(), String> {
if !self.is_enabled() {
return Ok(());
}
self.inner.analytics.cleared(&goal);
self.inner.accounting_state.clear_active_goal();
Ok(())
}
@@ -392,11 +379,6 @@ impl GoalRuntimeHandle {
self.inner
.metrics
.record_terminal_if_status_changed(previous_status, &goal);
self.inner.analytics.status_changed(
&goal,
previous_status,
GoalEventAttribution::Turn(turn_id),
);
self.inner.accounting_state.clear_active_goal();
let goal = protocol_goal_from_state(goal);
self.inner.event_emitter.thread_goal_updated(
@@ -581,14 +563,6 @@ impl GoalRuntimeHandle {
self.inner
.metrics
.record_terminal_if_status_changed(previous_status, &goal);
self.inner
.analytics
.usage_accounted(&goal, GoalEventAttribution::Turn(turn_id));
self.inner.analytics.status_changed(
&goal,
previous_status,
GoalEventAttribution::Turn(turn_id),
);
accounting.mark_progress_accounted_for_status(
turn_id,
&snapshot,
@@ -643,14 +617,6 @@ impl GoalRuntimeHandle {
self.inner
.metrics
.record_terminal_if_status_changed(previous_status, &goal);
self.inner
.analytics
.usage_accounted(&goal, GoalEventAttribution::NoTurn);
self.inner.analytics.status_changed(
&goal,
previous_status,
GoalEventAttribution::NoTurn,
);
accounting.mark_idle_progress_accounted_for_status(
&snapshot,
goal.status,

View File

@@ -18,8 +18,6 @@ use serde::Serialize;
use crate::accounting::BudgetLimitedGoalDisposition;
use crate::accounting::GoalAccountingState;
use crate::analytics::GoalAnalytics;
use crate::analytics::GoalEventAttribution;
use crate::events::GoalEventEmitter;
use crate::metrics::GoalMetrics;
use crate::runtime::GoalRuntimeHandle;
@@ -38,7 +36,6 @@ pub(crate) struct GoalToolExecutor {
thread_id: ThreadId,
state_db: Arc<codex_state::StateRuntime>,
accounting_state: Arc<GoalAccountingState>,
analytics: GoalAnalytics,
event_emitter: GoalEventEmitter,
metrics: GoalMetrics,
max_goal_token_budget: Option<i64>,
@@ -83,7 +80,6 @@ impl GoalToolExecutor {
thread_id: ThreadId,
state_db: Arc<codex_state::StateRuntime>,
accounting_state: Arc<GoalAccountingState>,
analytics: GoalAnalytics,
event_emitter: GoalEventEmitter,
metrics: GoalMetrics,
) -> Self {
@@ -93,7 +89,6 @@ impl GoalToolExecutor {
thread_id,
state_db,
accounting_state,
analytics,
event_emitter,
metrics,
max_goal_token_budget: None,
@@ -104,7 +99,6 @@ impl GoalToolExecutor {
runtime: &GoalRuntimeHandle,
thread_manager: Weak<ThreadManager>,
state_db: Arc<codex_state::StateRuntime>,
analytics: GoalAnalytics,
event_emitter: GoalEventEmitter,
metrics: GoalMetrics,
max_goal_token_budget: Option<i64>,
@@ -115,7 +109,6 @@ impl GoalToolExecutor {
thread_id: runtime.thread_id(),
state_db,
accounting_state: runtime.accounting_state(),
analytics,
event_emitter,
metrics,
max_goal_token_budget,
@@ -126,7 +119,6 @@ impl GoalToolExecutor {
thread_id: ThreadId,
state_db: Arc<codex_state::StateRuntime>,
accounting_state: Arc<GoalAccountingState>,
analytics: GoalAnalytics,
event_emitter: GoalEventEmitter,
metrics: GoalMetrics,
) -> Self {
@@ -136,7 +128,6 @@ impl GoalToolExecutor {
thread_id,
state_db,
accounting_state,
analytics,
event_emitter,
metrics,
max_goal_token_budget: None,
@@ -253,10 +244,6 @@ impl GoalToolExecutor {
.await;
}
self.metrics.record_created();
self.analytics.created(
&goal,
GoalEventAttribution::Turn(invocation.turn_id.as_str()),
);
let goal = protocol_goal_from_state(goal);
self.emit_goal_updated_from_tool_call(&invocation, turn_id, goal.clone());
goal_response(Some(goal), CompletionBudgetReport::Omit)
@@ -317,11 +304,6 @@ impl GoalToolExecutor {
})?;
self.metrics
.record_terminal_if_status_changed(previous_status, &goal);
self.analytics.status_changed(
&goal,
previous_status,
GoalEventAttribution::Turn(invocation.turn_id.as_str()),
);
let goal = protocol_goal_from_state(goal);
let turn_id = self.accounting_state.clear_current_turn_goal();
self.emit_goal_updated_from_tool_call(&invocation, turn_id, goal.clone());
@@ -387,13 +369,6 @@ impl GoalToolExecutor {
codex_state::GoalAccountingOutcome::Updated(goal) => {
self.metrics
.record_terminal_if_status_changed(previous_status, &goal);
self.analytics
.usage_accounted(&goal, GoalEventAttribution::Turn(turn_id.as_str()));
self.analytics.status_changed(
&goal,
previous_status,
GoalEventAttribution::Turn(turn_id.as_str()),
);
self.accounting_state.mark_progress_accounted_for_status(
turn_id.as_str(),
&snapshot,

View File

@@ -8,7 +8,6 @@ use std::sync::PoisonError;
use std::sync::Weak;
use std::time::Duration;
use codex_analytics::AnalyticsEventsClient;
use codex_extension_api::ExtensionData;
use codex_extension_api::ExtensionEventSink;
use codex_extension_api::ExtensionRegistryBuilder;
@@ -1658,7 +1657,6 @@ async fn installed_tools_with_start(
install_with_backend(
&mut builder,
runtime,
AnalyticsEventsClient::disabled(),
/*metrics_client*/ None,
Weak::new(),
goal_service,
@@ -1715,7 +1713,6 @@ impl GoalExtensionHarness {
install_with_backend(
&mut builder,
runtime,
AnalyticsEventsClient::disabled(),
/*metrics_client*/ None,
Weak::new(),
Arc::clone(&goal_service),