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
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:
@@ -14,7 +14,6 @@ workspace = true
|
||||
|
||||
[dependencies]
|
||||
blake3 = { workspace = true }
|
||||
codex-analytics = { workspace = true }
|
||||
codex-config = { workspace = true }
|
||||
codex-exec-server = { workspace = true }
|
||||
codex-extension-api = { workspace = true }
|
||||
|
||||
@@ -189,7 +189,7 @@ pub struct SkillCatalogEntry {
|
||||
pub display_path: Option<String>,
|
||||
pub canonical_skill_id: Option<String>,
|
||||
pub plugin_id: Option<String>,
|
||||
pub analytics_scope: Option<SkillScope>,
|
||||
pub invocation_scope: Option<SkillScope>,
|
||||
/// Plugin-service identity for cross-source matching.
|
||||
pub remote_plugin_id: Option<String>,
|
||||
/// Alternate read routes that retain their original authority.
|
||||
@@ -220,7 +220,7 @@ impl SkillCatalogEntry {
|
||||
display_path: None,
|
||||
canonical_skill_id: None,
|
||||
plugin_id: None,
|
||||
analytics_scope: None,
|
||||
invocation_scope: None,
|
||||
remote_plugin_id: None,
|
||||
sources: Vec::new(),
|
||||
alias_root: None,
|
||||
|
||||
@@ -2,7 +2,6 @@ use std::sync::Arc;
|
||||
|
||||
use crate::HostSkillsSnapshot;
|
||||
use crate::InjectedHostSkillPrompts;
|
||||
use codex_analytics::InvocationType;
|
||||
use codex_exec_server::LOCAL_ENVIRONMENT_ID;
|
||||
use codex_extension_api::ConfigContributor;
|
||||
use codex_extension_api::ContextContributor;
|
||||
@@ -29,6 +28,7 @@ use codex_extension_api::WorldStateContributionInput;
|
||||
use codex_extension_api::WorldStateSectionContribution;
|
||||
use codex_mcp::McpResourceClient;
|
||||
use codex_otel::MetricsClient;
|
||||
use codex_otel::SkillInvocationType as InvocationType;
|
||||
use codex_protocol::openai_models::ModelInfo;
|
||||
|
||||
use crate::SkillsExtensionConfig;
|
||||
@@ -64,7 +64,7 @@ use crate::state::SkillsSessionState;
|
||||
use crate::state::SkillsThreadState;
|
||||
use crate::step_state::SkillsStepState;
|
||||
use crate::telemetry::SkillTelemetry;
|
||||
use crate::tools::SkillAnalytics;
|
||||
use crate::tools::SkillInvocationRecorder;
|
||||
use crate::tools::SkillToolAuthority;
|
||||
use crate::tools::skill_tools;
|
||||
use crate::warnings::bounded_warnings;
|
||||
@@ -430,7 +430,7 @@ where
|
||||
}
|
||||
|
||||
let mut injected_host_skill_prompts = InjectedHostSkillPrompts::default();
|
||||
let analytics = SkillAnalytics::from_stores(session_store, thread_store);
|
||||
let invocations = SkillInvocationRecorder::from_stores(session_store, thread_store);
|
||||
for entry in &selected_entries {
|
||||
match self
|
||||
.read_main_prompt(
|
||||
@@ -476,10 +476,10 @@ where
|
||||
fragments.push(Box::new(fragment));
|
||||
if entry.authority.kind == SkillSourceKind::Host {
|
||||
injected_host_skill_prompts.insert_path(entry.main_prompt.as_str());
|
||||
} else if let Some(analytics) = analytics.as_ref()
|
||||
} else if let Some(invocations) = invocations.as_ref()
|
||||
&& let Some(model_info) = thread_store.get::<ModelInfo>()
|
||||
{
|
||||
analytics.track_skill_invocation(
|
||||
invocations.record_skill_invocation(
|
||||
entry,
|
||||
&entry.primary_source(),
|
||||
model_info.slug.clone(),
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use codex_analytics::InvocationType;
|
||||
use codex_analytics::SkillInvocation;
|
||||
use codex_analytics::SkillInvocationLocation;
|
||||
use codex_exec_server::LOCAL_ENVIRONMENT_ID;
|
||||
use codex_extension_api::ExtensionData;
|
||||
use codex_otel::SkillInvocationType as InvocationType;
|
||||
use codex_protocol::protocol::SkillScope;
|
||||
use codex_skills::ImplicitSkillAccess;
|
||||
use codex_skills::detect_implicit_skill_invocation_for_command;
|
||||
use codex_skills::implicit_skill_accesses_for_command;
|
||||
@@ -16,6 +15,30 @@ use crate::catalog::SkillResourceId;
|
||||
use crate::catalog::SkillSourceKind;
|
||||
use crate::catalog::SkillSourceLocation;
|
||||
|
||||
/// A detected skill use, consumed by local logging, local metrics and skill contributors.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SkillInvocation {
|
||||
pub skill_name: String,
|
||||
pub location: SkillInvocationLocation,
|
||||
pub plugin_id: Option<String>,
|
||||
pub remote_plugin_id: Option<String>,
|
||||
pub invocation_type: InvocationType,
|
||||
}
|
||||
|
||||
/// Where the invoked skill was loaded from.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum SkillInvocationLocation {
|
||||
Host {
|
||||
path: PathUri,
|
||||
scope: SkillScope,
|
||||
},
|
||||
Resource {
|
||||
id: String,
|
||||
skill_id: Option<String>,
|
||||
scope: Option<SkillScope>,
|
||||
},
|
||||
}
|
||||
|
||||
impl SkillCatalogEntry {
|
||||
/// Uses merged identity and scope, with plugin attribution from the route actually used.
|
||||
pub(crate) fn invocation(
|
||||
@@ -28,7 +51,7 @@ impl SkillCatalogEntry {
|
||||
location: SkillInvocationLocation::Resource {
|
||||
id: self.main_prompt.as_str().to_owned(),
|
||||
skill_id: self.canonical_skill_id.clone(),
|
||||
scope: self.analytics_scope,
|
||||
scope: self.invocation_scope,
|
||||
},
|
||||
plugin_id: source.plugin_id.clone(),
|
||||
remote_plugin_id: self.remote_plugin_id.clone(),
|
||||
|
||||
@@ -44,6 +44,8 @@ pub use host_service::HostSkillsLoadInput;
|
||||
pub use host_service::HostSkillsRequest;
|
||||
pub use host_service::HostSkillsService;
|
||||
pub use host_snapshot::HostSkillsSnapshot;
|
||||
pub use invocation::SkillInvocation;
|
||||
pub use invocation::SkillInvocationLocation;
|
||||
pub use invocation::detect_implicit_skill_invocation;
|
||||
pub use provider::ExecutorSkillProvider;
|
||||
pub use provider::FrozenCloudSkillProvider;
|
||||
|
||||
@@ -73,7 +73,7 @@ pub(crate) fn attribute_executor_plugins(
|
||||
.find(|plugin| plugin.selected_root_id.as_ref() == Some(&skill.authority.id))
|
||||
{
|
||||
skill.plugin_id = Some(plugin.plugin_id.as_str().to_string());
|
||||
skill.analytics_scope = Some(SkillScope::User);
|
||||
skill.invocation_scope = Some(SkillScope::User);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ impl ExecutorSkillProvider {
|
||||
};
|
||||
entry.remote_plugin_id = plugin.remote_plugin_id.clone();
|
||||
entry.plugin_id = Some(plugin.id.clone());
|
||||
entry.analytics_scope = Some(SkillScope::User);
|
||||
entry.invocation_scope = Some(SkillScope::User);
|
||||
catalog.push_entry(entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ pub fn record_plugin_turn_usage(turn_store: &ExtensionData, plugin_id: Option<&s
|
||||
|
||||
pub(crate) struct SkillTurnMetrics {
|
||||
pub(crate) turn_id: String,
|
||||
pub(crate) turn_metadata: Option<Arc<dyn codex_analytics::TurnAnalyticsMetadata>>,
|
||||
model_slug: String,
|
||||
pub(crate) reasoning_effort: String,
|
||||
started_at: Instant,
|
||||
@@ -112,10 +111,6 @@ impl TurnLifecycleContributor for SkillTelemetry {
|
||||
.unwrap_or_else(|| "default".to_string());
|
||||
input.turn_store.insert(SkillTurnMetrics {
|
||||
turn_id: input.turn_id.to_string(),
|
||||
turn_metadata: input
|
||||
.turn_store
|
||||
.get::<Arc<dyn codex_analytics::TurnAnalyticsMetadata>>()
|
||||
.map(|metadata| metadata.as_ref().clone()),
|
||||
model_slug: sanitize_metric_tag_value(input.collaboration_mode.model()),
|
||||
reasoning_effort,
|
||||
started_at: Instant::now(),
|
||||
|
||||
@@ -3,15 +3,11 @@ use std::hash::Hash;
|
||||
use std::hash::Hasher;
|
||||
use std::sync::Arc;
|
||||
|
||||
use codex_analytics::AnalyticsEventsClient;
|
||||
use codex_analytics::InvocationType;
|
||||
use codex_analytics::build_track_events_context;
|
||||
use codex_extension_api::ExtensionData;
|
||||
use codex_extension_api::ExtensionMetrics;
|
||||
use codex_extension_api::FunctionCallError;
|
||||
use codex_extension_api::JsonToolOutput;
|
||||
use codex_extension_api::ResponsesApiTool;
|
||||
use codex_extension_api::ThreadOriginator;
|
||||
use codex_extension_api::ToolCall;
|
||||
use codex_extension_api::ToolExecutor;
|
||||
use codex_extension_api::ToolName;
|
||||
@@ -22,7 +18,7 @@ use codex_mcp::CODEX_APPS_MCP_SERVER_NAME;
|
||||
use codex_mcp::McpResourceClient;
|
||||
use codex_otel::SessionTelemetry;
|
||||
use codex_otel::SkillInvocationEvent;
|
||||
use codex_otel::SkillInvocationType;
|
||||
use codex_otel::SkillInvocationType as InvocationType;
|
||||
use codex_otel::sanitize_metric_tag_value;
|
||||
use codex_tools::ResponsesApiNamespace;
|
||||
use codex_tools::ResponsesApiNamespaceTool;
|
||||
@@ -72,7 +68,7 @@ pub(crate) fn skill_tools(
|
||||
let mcp_resources = session_store
|
||||
.get::<SkillsSessionState>()
|
||||
.and_then(|state| state.mcp_resources.clone());
|
||||
let analytics = SkillAnalytics::from_stores(session_store, thread_store);
|
||||
let invocations = SkillInvocationRecorder::from_stores(session_store, thread_store);
|
||||
let metrics = step_store
|
||||
.get::<Arc<dyn ExtensionMetrics>>()
|
||||
.map(|metrics| Arc::clone(metrics.as_ref()));
|
||||
@@ -81,7 +77,7 @@ pub(crate) fn skill_tools(
|
||||
providers,
|
||||
mcp_resources,
|
||||
thread_state,
|
||||
analytics,
|
||||
invocations,
|
||||
step_state,
|
||||
};
|
||||
let mut tools: Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> = vec![
|
||||
@@ -102,26 +98,20 @@ pub(crate) fn skill_tools(
|
||||
tools
|
||||
}
|
||||
|
||||
/// Records skill invocations to local logs and local metrics only.
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct SkillAnalytics {
|
||||
client: AnalyticsEventsClient,
|
||||
pub(crate) struct SkillInvocationRecorder {
|
||||
telemetry: Option<Arc<SessionTelemetry>>,
|
||||
metrics: Option<Arc<dyn ExtensionMetrics>>,
|
||||
turn_metrics: Option<Arc<SkillTurnMetrics>>,
|
||||
thread_id: String,
|
||||
product_client_id: String,
|
||||
}
|
||||
|
||||
impl SkillAnalytics {
|
||||
impl SkillInvocationRecorder {
|
||||
pub(crate) fn from_stores(
|
||||
session_store: &ExtensionData,
|
||||
thread_store: &ExtensionData,
|
||||
) -> Option<Self> {
|
||||
let client = session_store.get::<AnalyticsEventsClient>()?;
|
||||
let originator = thread_store.get::<ThreadOriginator>()?;
|
||||
|
||||
Some(Self {
|
||||
client: client.as_ref().clone(),
|
||||
telemetry: session_store.get::<SessionTelemetry>(),
|
||||
metrics: session_store
|
||||
.get::<SkillsSessionState>()
|
||||
@@ -133,12 +123,10 @@ impl SkillAnalytics {
|
||||
.lock()
|
||||
.unwrap_or_else(std::sync::PoisonError::into_inner)
|
||||
.upgrade(),
|
||||
thread_id: thread_store.level_id().to_string(),
|
||||
product_client_id: originator.0.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn track_skill_invocation(
|
||||
pub(crate) fn record_skill_invocation(
|
||||
&self,
|
||||
skill: &SkillCatalogEntry,
|
||||
source: &SkillSourceLocation,
|
||||
@@ -155,12 +143,9 @@ impl SkillAnalytics {
|
||||
.skill_invocation(SkillInvocationEvent {
|
||||
turn_id: &turn_id,
|
||||
skill_name: &skill.name,
|
||||
scope: skill.analytics_scope,
|
||||
scope: skill.invocation_scope,
|
||||
plugin_id: invocation.plugin_id.as_deref(),
|
||||
invocation_type: match invocation_type {
|
||||
InvocationType::Explicit => SkillInvocationType::Explicit,
|
||||
InvocationType::Implicit => SkillInvocationType::Implicit,
|
||||
},
|
||||
invocation_type,
|
||||
});
|
||||
}
|
||||
let turn_metrics = self
|
||||
@@ -197,16 +182,6 @@ impl SkillAnalytics {
|
||||
],
|
||||
);
|
||||
}
|
||||
self.client.track_skill_invocations(
|
||||
build_track_events_context(
|
||||
model,
|
||||
self.thread_id.clone(),
|
||||
turn_id,
|
||||
self.product_client_id.clone(),
|
||||
turn_metrics.and_then(|turn| turn.turn_metadata.clone()),
|
||||
),
|
||||
vec![invocation],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +191,7 @@ struct SkillToolContext {
|
||||
providers: SkillProviders,
|
||||
mcp_resources: Option<Arc<McpResourceClient>>,
|
||||
thread_state: Arc<SkillsThreadState>,
|
||||
analytics: Option<SkillAnalytics>,
|
||||
invocations: Option<SkillInvocationRecorder>,
|
||||
step_state: Arc<SkillsStepState>,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use codex_analytics::InvocationType;
|
||||
use codex_extension_api::ExtensionMetrics;
|
||||
use codex_extension_api::FunctionCallError;
|
||||
use codex_extension_api::ToolCall;
|
||||
@@ -8,6 +7,7 @@ use codex_extension_api::ToolExecutor;
|
||||
use codex_extension_api::ToolExecutorFuture;
|
||||
use codex_extension_api::ToolName;
|
||||
use codex_extension_api::ToolSpec;
|
||||
use codex_otel::SkillInvocationType as InvocationType;
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
@@ -433,9 +433,9 @@ impl<'call> ToolExecutor<ToolCall<'call>> for ReadTool {
|
||||
|
||||
if requested_resource == main_prompt
|
||||
&& args.cursor.is_none()
|
||||
&& let Some(analytics) = self.context.analytics.as_ref()
|
||||
&& let Some(invocations) = self.context.invocations.as_ref()
|
||||
{
|
||||
analytics.track_skill_invocation(
|
||||
invocations.record_skill_invocation(
|
||||
skill_entry,
|
||||
&selected_source,
|
||||
call.model.clone(),
|
||||
|
||||
@@ -1228,7 +1228,7 @@ async fn v2_implicit_and_explicit_invocations_retain_their_step_catalog() -> Tes
|
||||
let original = detect(&harness.step_store).expect("prepared step skill");
|
||||
assert_eq!(original.remote_plugin_id, cloud.remote_plugin_id);
|
||||
assert_eq!(original.plugin_id.as_deref(), Some("matching"));
|
||||
assert_matches!(&original.location, codex_analytics::SkillInvocationLocation::Resource { id, .. } if id == cloud.main_prompt.as_str());
|
||||
assert_matches!(&original.location, codex_skills_extension::SkillInvocationLocation::Resource { id, .. } if id == cloud.main_prompt.as_str());
|
||||
|
||||
let next_step = ExtensionData::new("step-2");
|
||||
harness.turn_store.insert(SelectedPluginSnapshot::default());
|
||||
|
||||
@@ -58,7 +58,7 @@ async fn source_events_cover_cached_cloud_and_explicit_executor_reads() -> TestR
|
||||
harness.render().await?;
|
||||
let events = ReadEvents::default();
|
||||
let subscriber = tracing_subscriber::registry().with(events.clone().with_filter(
|
||||
tracing_subscriber::filter::filter_fn(codex_otel::OtelProvider::trace_export_filter),
|
||||
tracing_subscriber::filter::filter_fn(codex_otel::trace_export_filter),
|
||||
));
|
||||
// Prevent parallel tests with no subscriber from disabling this callsite globally.
|
||||
let _interest_cache_guard =
|
||||
|
||||
Reference in New Issue
Block a user