Rinomina: crate akode-*, cartelle akode-rs/ e akode-cli/, binario akode, ~/.akode, AKODE_* (A)
Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
59
akode-rs/core/src/turn_timing/profile.rs
Normal file
59
akode-rs/core/src/turn_timing/profile.rs
Normal file
@@ -0,0 +1,59 @@
|
||||
//! Turn profile and critical-path summaries, used for local tracing and local metrics only.
|
||||
//! Missing capture never becomes a zero-duration measurement.
|
||||
|
||||
/// Capture coverage for one finalized turn, independent of its completion status.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub(crate) enum TurnCriticalPath {
|
||||
#[default]
|
||||
Disabled,
|
||||
Incomplete,
|
||||
Complete(TurnCriticalPathDurations),
|
||||
}
|
||||
|
||||
impl TurnCriticalPath {
|
||||
pub(crate) fn status(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Disabled => "disabled",
|
||||
Self::Incomplete => "incomplete",
|
||||
Self::Complete(_) => "complete",
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn durations(&self) -> Option<&TurnCriticalPathDurations> {
|
||||
match self {
|
||||
Self::Complete(durations) => Some(durations),
|
||||
Self::Disabled | Self::Incomplete => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Category totals over the server turn interval, truncated to milliseconds.
|
||||
/// Inference is the compatibility total of sampling and compaction, not another leaf.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub(crate) struct TurnCriticalPathDurations {
|
||||
pub(crate) duration_ms: u64,
|
||||
pub(crate) inference_ms: u64,
|
||||
pub(crate) sampling_ms: u64,
|
||||
pub(crate) compaction_ms: u64,
|
||||
pub(crate) auto_review_ms: u64,
|
||||
/// Portion of auto_review_ms outside observed Guardian turn execution; not additive.
|
||||
pub(crate) auto_review_overhead_ms: Option<u64>,
|
||||
pub(crate) user_wait_ms: u64,
|
||||
pub(crate) tools_ms: u64,
|
||||
pub(crate) overhead_ms: u64,
|
||||
pub(crate) unknown_ms: u64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub(crate) struct TurnProfile {
|
||||
pub(crate) critical_path: TurnCriticalPath,
|
||||
pub(crate) before_first_sampling_ms: u64,
|
||||
pub(crate) sampling_ms: u64,
|
||||
pub(crate) compaction_ms: u64,
|
||||
pub(crate) between_sampling_overhead_ms: u64,
|
||||
pub(crate) tool_blocking_ms: u64,
|
||||
pub(crate) after_last_sampling_ms: u64,
|
||||
pub(crate) sampling_request_count: u32,
|
||||
pub(crate) sampling_retry_count: u32,
|
||||
pub(crate) tools_change_count: u32,
|
||||
}
|
||||
74
akode-rs/core/src/turn_timing/report.rs
Normal file
74
akode-rs/core/src/turn_timing/report.rs
Normal file
@@ -0,0 +1,74 @@
|
||||
//! Report the frozen critical path over the same interval as the turn profile.
|
||||
|
||||
use super::TurnCriticalPath;
|
||||
use super::TurnCriticalPathDurations;
|
||||
use super::TurnProfileState;
|
||||
use super::duration_to_u64_ms;
|
||||
use akode_otel::TURN_CRITICAL_PATH_CAPTURE_METRIC;
|
||||
use akode_otel::TURN_CRITICAL_PATH_COMPONENT_METRIC;
|
||||
use akode_otel::TURN_CRITICAL_PATH_DURATION_METRIC;
|
||||
use std::time::Instant;
|
||||
|
||||
pub(super) fn completed_critical_path(state: &TurnProfileState, end: Instant) -> TurnCriticalPath {
|
||||
if !state.capture_enabled {
|
||||
return TurnCriticalPath::Disabled;
|
||||
}
|
||||
let (Some(path), Some(start)) = (&state.path, state.started_at) else {
|
||||
return TurnCriticalPath::Incomplete;
|
||||
};
|
||||
let totals = path.durations(start, end);
|
||||
TurnCriticalPath::Complete(TurnCriticalPathDurations {
|
||||
duration_ms: duration_to_u64_ms(end.saturating_duration_since(start)),
|
||||
inference_ms: duration_to_u64_ms(totals.sampling.saturating_add(totals.compaction)),
|
||||
sampling_ms: duration_to_u64_ms(totals.sampling),
|
||||
compaction_ms: duration_to_u64_ms(totals.compaction),
|
||||
auto_review_ms: duration_to_u64_ms(totals.auto_review),
|
||||
auto_review_overhead_ms: totals.auto_review_overhead.map(duration_to_u64_ms),
|
||||
user_wait_ms: duration_to_u64_ms(totals.user_wait),
|
||||
tools_ms: duration_to_u64_ms(totals.tools),
|
||||
overhead_ms: duration_to_u64_ms(totals.overhead),
|
||||
unknown_ms: duration_to_u64_ms(totals.unknown),
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn record_turn_profile_metrics(turn: &super::TurnContext, profile: &super::TurnProfile) {
|
||||
let telemetry = &turn.session_telemetry;
|
||||
let sku = akode_otel::bounded_product_sku(turn.config.apps_mcp_product_sku.as_deref())
|
||||
.unwrap_or("unknown");
|
||||
let effort = turn.effective_reasoning_effort_for_tracing();
|
||||
telemetry.counter(
|
||||
TURN_CRITICAL_PATH_CAPTURE_METRIC,
|
||||
/*inc*/ 1,
|
||||
&[
|
||||
("product_sku", sku),
|
||||
("reasoning_effort", effort.as_str()),
|
||||
("capture_status", profile.critical_path.status()),
|
||||
],
|
||||
);
|
||||
let Some(times) = profile.critical_path.durations() else {
|
||||
return;
|
||||
};
|
||||
telemetry.record_duration(
|
||||
TURN_CRITICAL_PATH_DURATION_METRIC,
|
||||
std::time::Duration::from_millis(times.duration_ms),
|
||||
&[("product_sku", sku), ("reasoning_effort", effort.as_str())],
|
||||
);
|
||||
for (component, ms) in [
|
||||
("inference", times.inference_ms),
|
||||
("auto_review", times.auto_review_ms),
|
||||
("tools", times.tools_ms),
|
||||
("user_wait", times.user_wait_ms),
|
||||
("overhead", times.overhead_ms),
|
||||
("unknown", times.unknown_ms),
|
||||
] {
|
||||
telemetry.record_duration(
|
||||
TURN_CRITICAL_PATH_COMPONENT_METRIC,
|
||||
std::time::Duration::from_millis(ms),
|
||||
&[
|
||||
("product_sku", sku),
|
||||
("reasoning_effort", effort.as_str()),
|
||||
("component", component),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
67
akode-rs/core/src/turn_timing/review_execution.rs
Normal file
67
akode-rs/core/src/turn_timing/review_execution.rs
Normal file
@@ -0,0 +1,67 @@
|
||||
//! Attaches submitted review execution to its child turn before measurement starts.
|
||||
|
||||
use super::TurnTimingState;
|
||||
use crate::session::session::Session;
|
||||
use akode_utils_critical_path::ReviewExecution;
|
||||
use akode_utils_critical_path::ReviewExecutionAttempt;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub(crate) struct PendingReviewExecution(pub(crate) ReviewExecution);
|
||||
|
||||
/// Keeps a submission unresolved until completion and removes only its pending observer.
|
||||
pub(crate) struct ReviewExecutionObservation {
|
||||
session: Arc<Session>,
|
||||
execution: Option<ReviewExecution>,
|
||||
attempt: Option<ReviewExecutionAttempt>,
|
||||
}
|
||||
|
||||
impl ReviewExecutionObservation {
|
||||
pub(crate) fn install(session: Arc<Session>, execution: Option<ReviewExecution>) -> Self {
|
||||
let attempt = execution.as_ref().map(ReviewExecution::start_attempt);
|
||||
if let Some(execution) = &execution {
|
||||
session
|
||||
.services
|
||||
.thread_extension_data
|
||||
.insert(PendingReviewExecution(execution.clone()));
|
||||
}
|
||||
Self {
|
||||
session,
|
||||
execution,
|
||||
attempt,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn finish(&mut self, completed: bool) {
|
||||
if let Some(attempt) = self.attempt.take() {
|
||||
attempt.finish(completed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for ReviewExecutionObservation {
|
||||
fn drop(&mut self) {
|
||||
if let Some(execution) = &self.execution
|
||||
&& self
|
||||
.session
|
||||
.services
|
||||
.thread_extension_data
|
||||
.get::<PendingReviewExecution>()
|
||||
.is_some_and(|pending| pending.0 == *execution)
|
||||
{
|
||||
self.session
|
||||
.services
|
||||
.thread_extension_data
|
||||
.remove::<PendingReviewExecution>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn observe_pending_review_execution(session: &Session, timing: &TurnTimingState) {
|
||||
if let Some(execution) = session
|
||||
.services
|
||||
.thread_extension_data
|
||||
.remove::<PendingReviewExecution>()
|
||||
{
|
||||
timing.observe_review_execution(execution.0.clone()).await;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user