Merge remote-tracking branch 'upstream/main' into codex/fix-antigravity-quota

This commit is contained in:
ZheFox
2026-09-03 13:24:39 +08:00
94 changed files with 1926 additions and 3765 deletions
@@ -53,7 +53,6 @@ use crate::scheduler::affinity::{
scheduler_affinity_policy_context_from_report_context, SCHEDULER_AFFINITY_POLICY_REPORT_FIELD,
SCHEDULER_AFFINITY_TTL,
};
use crate::scheduler::config::{read_scheduler_ordering_config, SchedulerSchedulingMode};
use crate::AppState;
const POOL_SCORE_FEEDBACK_GATE_MAX_ENTRIES: usize = 50_000;
@@ -763,36 +762,19 @@ async fn local_scheduler_affinity_matches_failed_target(
local_execution_plan_uses_pool(state, plan).await
}
async fn scheduler_cache_affinity_enabled(
state: &AppState,
report_context: Option<&Value>,
) -> bool {
if report_context
fn scheduler_cache_affinity_enabled(report_context: Option<&Value>) -> bool {
report_context
.and_then(|context| context.get(SCHEDULER_AFFINITY_POLICY_REPORT_FIELD))
.is_some()
{
return scheduler_affinity_policy_context_from_report_context(report_context)
.is_some_and(|context| context.cache_affinity_enabled());
}
match read_scheduler_ordering_config(state).await {
Ok(config) => config.scheduling_mode == SchedulerSchedulingMode::CacheAffinity,
Err(error) => {
warn!(
event_name = "orchestration_scheduler_affinity_config_load_failed",
log_type = "event",
error = ?error,
"failed to load scheduler config while checking cache affinity mode"
);
SchedulerSchedulingMode::default() == SchedulerSchedulingMode::CacheAffinity
}
}
&& scheduler_affinity_policy_context_from_report_context(report_context)
.is_some_and(|context| context.cache_affinity_enabled())
}
async fn remember_successful_local_scheduler_affinity(
state: &AppState,
context: LocalExecutionEffectContext<'_>,
) {
if !scheduler_cache_affinity_enabled(state, context.report_context).await {
if !scheduler_cache_affinity_enabled(context.report_context) {
return;
}
let Some(cache_key) = local_scheduler_affinity_cache_key(context.report_context) else {
+5 -4
View File
@@ -56,10 +56,11 @@ pub(crate) use self::oauth_error::{
};
pub(crate) use self::policy::{
append_local_failover_policy_to_value, codex_cyber_flag_passthrough_enabled,
cyber_continue_failover_enabled, local_failover_policy_from_report_context,
local_failover_policy_from_transport, resolve_local_failover_policy,
responses_websocket_adapter, LocalFailoverPolicy, LocalFailoverRegexRule,
ResponsesWebSocketAdapter, CYBER_CONTINUE_FAILOVER_CONFIG_KEY, RESPONSES_WEBSOCKET_CONFIG_KEY,
local_failover_policy_from_report_context, local_failover_policy_from_transport,
resolve_local_failover_policy, responses_websocket_adapter,
routing_execution_policy_from_report_context, LocalFailoverPolicy, LocalFailoverRegexRule,
ResponsesWebSocketAdapter, RESPONSES_WEBSOCKET_CONFIG_KEY,
ROUTING_EXECUTION_POLICY_REPORT_FIELD,
};
pub(crate) use self::recovery::{
analyze_local_failover, analyze_local_transport_error, apply_provider_failure_disposition,
+13 -12
View File
@@ -4,11 +4,13 @@ use aether_contracts::ExecutionPlan;
use serde_json::{json, Value};
use tracing::debug;
use aether_routing_core::RoutingExecutionPolicy;
use crate::provider_transport::GatewayProviderTransportSnapshot;
use crate::AppState;
pub(crate) const CYBER_CONTINUE_FAILOVER_CONFIG_KEY: &str = "cyber_continue_failover";
pub(crate) const RESPONSES_WEBSOCKET_CONFIG_KEY: &str = "responses_websocket";
pub(crate) const ROUTING_EXECUTION_POLICY_REPORT_FIELD: &str = "routing_execution_policy";
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct LocalFailoverPolicy {
@@ -50,7 +52,7 @@ pub(crate) struct LocalFailoverRegexRule {
pub(crate) async fn resolve_local_failover_policy(
state: &AppState,
plan: &ExecutionPlan,
_report_context: Option<&serde_json::Value>,
report_context: Option<&serde_json::Value>,
) -> LocalFailoverPolicy {
let mut policy = match state
.read_provider_transport_snapshot(&plan.provider_id, &plan.endpoint_id, &plan.key_id)
@@ -59,7 +61,8 @@ pub(crate) async fn resolve_local_failover_policy(
Ok(Some(transport)) => local_failover_policy_from_transport(&transport),
Ok(None) | Err(_) => LocalFailoverPolicy::default(),
};
let cyber_continue_failover = cyber_continue_failover_enabled(state).await;
let cyber_continue_failover = routing_execution_policy_from_report_context(report_context)
.is_some_and(|policy| policy.cyber_continue_failover);
policy.stop_cyber_policy_errors = !cyber_continue_failover;
debug!(
event_name = "local_failover_policy_loaded",
@@ -83,15 +86,13 @@ pub(crate) async fn resolve_local_failover_policy(
policy
}
pub(crate) async fn cyber_continue_failover_enabled(state: &AppState) -> bool {
state
.read_system_config_json_value(CYBER_CONTINUE_FAILOVER_CONFIG_KEY)
.await
.ok()
.flatten()
.as_ref()
.and_then(Value::as_bool)
.unwrap_or(false)
pub(crate) fn routing_execution_policy_from_report_context(
report_context: Option<&Value>,
) -> Option<RoutingExecutionPolicy> {
report_context
.and_then(Value::as_object)
.and_then(|object| object.get(ROUTING_EXECUTION_POLICY_REPORT_FIELD))
.and_then(|value| serde_json::from_value(value.clone()).ok())
}
pub(crate) fn local_failover_policy_from_transport(