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

@@ -2,11 +2,11 @@ use std::collections::BTreeMap;
use std::collections::HashMap;
use std::io::ErrorKind;
use codex_analytics::CompactionImplementation;
use codex_analytics::CompactionPhase;
use codex_analytics::CompactionReason;
use codex_analytics::CompactionStrategy;
use codex_analytics::CompactionTrigger;
use crate::compaction_metadata::CompactionImplementation;
use crate::compaction_metadata::CompactionPhase;
use crate::compaction_metadata::CompactionReason;
use crate::compaction_metadata::CompactionStrategy;
use crate::compaction_metadata::CompactionTrigger;
use codex_git_utils::SanitizedGitUrl;
use codex_protocol::ContextWindowId;
use codex_protocol::ThreadId;
@@ -43,7 +43,9 @@ pub(crate) const LEGACY_CODE_MODE_TOOL_NAMES_KEY: &str = "code_mode_tool_names";
pub(crate) const TOOL_NAMESPACES_INFO_KEY: &str = "tool_namespaces_info";
pub(crate) const TURN_STARTED_AT_UNIX_MS_KEY: &str = "turn_started_at_unix_ms";
pub(crate) const HISTORY_INGEST_REQUESTED_KEY: &str = "history_ingest_requested";
pub(crate) const ANALYTICS_ENABLED_KEY: &str = "analytics_enabled";
// Formerly reported the session's usage-data collection state. Usage-data reporting was removed;
// the key stays reserved so configured or client metadata cannot reintroduce it.
pub(crate) const LEGACY_USAGE_DATA_ENABLED_KEY: &str = "analytics_enabled";
pub(crate) const HISTORY_INITIALIZATION_KEY: &str = "history_initialization";
pub(crate) const MCP_ATTRIBUTION_CLIENT_METADATA_KEY: &str = "mcp_attribution";
pub(crate) const MAX_MCP_ATTRIBUTION_BYTES: usize = 16 * 1024;
@@ -88,7 +90,7 @@ const RESERVED_METADATA_KEYS: &[&str] = &[
TOOL_NAMESPACES_INFO_KEY,
TURN_STARTED_AT_UNIX_MS_KEY,
HISTORY_INGEST_REQUESTED_KEY,
ANALYTICS_ENABLED_KEY,
LEGACY_USAGE_DATA_ENABLED_KEY,
HISTORY_INITIALIZATION_KEY,
FORKED_FROM_THREAD_ID_KEY,
FORKED_FROM_ORDINAL_EXCLUSIVE_KEY,
@@ -112,7 +114,7 @@ const BACKWARD_COMPATIBLE_RESERVED_METADATA_KEYS: &[&str] = &[
"guardian_recorded_items",
WINDOW_NUMBER_KEY,
FORKED_FROM_ORDINAL_EXCLUSIVE_KEY,
ANALYTICS_ENABLED_KEY,
LEGACY_USAGE_DATA_ENABLED_KEY,
];
const MAX_EXTRA_METADATA_ENTRIES: usize = 16;
const MAX_EXTRA_METADATA_KEY_BYTES: usize = 64;
@@ -122,7 +124,7 @@ pub(crate) const MAX_EXTRA_METADATA_VALUE_BYTES: usize = 128;
///
/// This covers both local and remote compaction requests sent through the `/responses` path. These
/// fields describe the operation at dispatch time. Post-response outcomes such as status, error,
/// duration, and token deltas remain in compaction analytics events.
/// duration, and token deltas are not reported anywhere.
#[derive(Clone, Copy, Debug, Serialize)]
pub(crate) struct CompactionTurnMetadata {
trigger: CompactionTrigger,
@@ -269,9 +271,6 @@ pub struct CodexResponsesMetadata {
pub(crate) tool_namespaces_info: Option<TurnToolNamespacesInfo>,
pub(crate) turn_started_at_unix_ms: Option<i64>,
pub(crate) history_ingest_requested: Option<bool>,
/// Selected session analytics client's collection state, independent of event eligibility or delivery.
/// Absent when the request has no initialized session analytics context.
pub(crate) analytics_enabled: Option<bool>,
/// Cumulative MCP attribution for this logical request; body-only and model-invisible.
pub(crate) mcp_attribution: Option<McpAttribution>,
pub(crate) extra: BTreeMap<String, String>,
@@ -317,7 +316,6 @@ impl CodexResponsesMetadata {
tool_namespaces_info: None,
turn_started_at_unix_ms: None,
history_ingest_requested: None,
analytics_enabled: None,
mcp_attribution: None,
extra: BTreeMap::new(),
}
@@ -460,7 +458,6 @@ impl CodexResponsesMetadata {
tool_namespaces_info: self.tool_namespaces_info.as_ref(),
turn_started_at_unix_ms: self.turn_started_at_unix_ms,
history_ingest_requested: self.history_ingest_requested,
analytics_enabled: self.analytics_enabled,
compaction,
// Extra metadata enriches the Codex turn metadata blob, not literal top-level
// Responses client_metadata. Product metadata is validated while loading config;
@@ -612,8 +609,6 @@ struct CodexTurnMetadataPayload<'a> {
#[serde(default, skip_serializing_if = "Option::is_none")]
history_ingest_requested: Option<bool>,
#[serde(default, skip_serializing_if = "Option::is_none")]
analytics_enabled: Option<bool>,
#[serde(default, skip_serializing_if = "Option::is_none")]
compaction: Option<CompactionTurnMetadata>,
#[serde(flatten)]
extra: &'a BTreeMap<String, String>,