aKode fase 1: niente sync plugin OpenAI, CDN pets, CIMD chatgpt.com, npm registry; pulizia codice morto

This commit is contained in:
Andrea
2026-11-09 12:06:16 +01:00
parent 5b5b83964d
commit 39a103d16f
34 changed files with 136 additions and 4668 deletions

View File

@@ -30,7 +30,6 @@ use crate::loaded_cache_metrics;
use crate::loaded_cache_metrics::RequestOutcome;
use crate::loader::PluginHookLoadOutcome;
use crate::loader::TargetCuratedMarketplace;
use crate::loader::configured_curated_plugin_ids_from_codex_home;
use crate::loader::curated_plugin_cache_version;
use crate::loader::load_plugin_apps_from_manifest;
use crate::loader::load_plugin_hooks;
@@ -42,7 +41,6 @@ use crate::loader::log_plugin_load_errors;
use crate::loader::materialize_marketplace_plugin_source;
use crate::loader::plugin_capability_summary_from_root;
use crate::loader::plugin_is_eligible_for_target_marketplace;
use crate::loader::refresh_curated_plugin_cache;
use crate::loader::refresh_non_curated_plugin_cache_detailed;
use crate::loader::refresh_non_curated_plugin_cache_force_reinstall_detailed;
use crate::loader::remote_installed_plugins_to_config;
@@ -86,11 +84,9 @@ use crate::remote_plugin_id_resolver::RemoteInstalledPluginsSnapshot;
use crate::remote_plugin_id_resolver::RemotePluginIdResolver;
use crate::remote_plugin_id_resolver::persisted_remote_plugin_id_for_installation;
use crate::skill_snapshots::new_plugin_skill_snapshots;
use crate::startup_sync::OPENAI_PLUGINS_GIT_URL;
use crate::startup_sync::curated_plugins_api_marketplace_path;
use crate::startup_sync::curated_plugins_repo_path;
use crate::startup_sync::read_curated_plugins_sha;
use crate::startup_sync::sync_openai_plugins_repo;
use crate::store::PluginInstallResult as StorePluginInstallResult;
use crate::store::PluginStore;
use crate::store::PluginStoreError;
@@ -146,8 +142,6 @@ use std::sync::Arc;
use std::sync::Mutex;
use std::sync::OnceLock;
use std::sync::RwLock;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
use std::time::Duration;
use std::time::Instant;
use tokio::sync::OnceCell;
@@ -158,7 +152,6 @@ use tokio::sync::watch;
use tracing::instrument;
use tracing::warn;
static CURATED_REPO_SYNC_STARTED: AtomicBool = AtomicBool::new(false);
const FEATURED_PLUGIN_IDS_CACHE_TTL: std::time::Duration =
std::time::Duration::from_secs(60 * 60 * 3);
const REMOTE_INSTALLED_PLUGIN_SYNC_WAIT_TIMEOUT: Duration = Duration::from_secs(120);
@@ -828,25 +821,6 @@ impl PluginsManager {
config.remote_plugin_enabled && self.auth_mode().is_some_and(AuthMode::uses_codex_backend)
}
/// Starts the local curated marketplace sync when the remote catalog is unavailable.
pub fn maybe_start_curated_repo_sync_for_config(
self: &Arc<Self>,
config: &PluginsConfigInput,
on_effective_plugins_changed: Option<EffectivePluginsChangedCallback>,
) {
if config.plugins_enabled
&& !self.remote_global_catalog_active(config)
&& MarketplacePolicy::from_requirements(config.config_layer_stack.requirements())
.validate_git_source(OPENAI_PLUGINS_GIT_URL, /*ref_name*/ None)
.is_ok()
{
self.start_curated_repo_sync(
config.http_client_factory.clone(),
on_effective_plugins_changed,
);
}
}
pub fn set_analytics_events_client(&self, analytics_events_client: AnalyticsEventsClient) {
let mut stored_client = match self.analytics_events_client.write() {
Ok(client_guard) => client_guard,
@@ -2947,10 +2921,7 @@ impl PluginsManager {
upgrade_warnings: mpsc::UnboundedSender<String>,
) {
if config.plugins_enabled {
self.maybe_start_curated_repo_sync_for_config(
config,
on_effective_plugins_changed.clone(),
);
// aKode: the OpenAI curated marketplace is never synced at startup.
let should_spawn_marketplace_auto_upgrade = {
let mut state = match self.configured_marketplace_upgrade_state.write() {
Ok(state) => state,
@@ -3384,66 +3355,6 @@ impl PluginsManager {
}
}
fn start_curated_repo_sync(
self: &Arc<Self>,
http_client_factory: HttpClientFactory,
on_effective_plugins_changed: Option<EffectivePluginsChangedCallback>,
) {
if CURATED_REPO_SYNC_STARTED.swap(true, Ordering::SeqCst) {
return;
}
let on_effective_plugins_changed =
on_effective_plugins_changed.map(|on_effective_plugins_changed| {
let Ok(runtime) = tokio::runtime::Handle::try_current() else {
return on_effective_plugins_changed;
};
let callback: EffectivePluginsChangedCallback = Arc::new(move |change| {
let on_effective_plugins_changed = Arc::clone(&on_effective_plugins_changed);
runtime.spawn(async move {
on_effective_plugins_changed(change);
});
});
callback
});
let manager = Arc::clone(self);
let codex_home = self.codex_home.clone();
if let Err(err) = std::thread::Builder::new()
.name("plugins-curated-repo-sync".to_string())
.spawn(move || {
match sync_openai_plugins_repo(codex_home.as_path(), http_client_factory) {
Ok(curated_plugin_version) => {
let configured_curated_plugin_ids =
configured_curated_plugin_ids_from_codex_home(codex_home.as_path());
match refresh_curated_plugin_cache(
codex_home.as_path(),
&curated_plugin_version,
&configured_curated_plugin_ids,
) {
Ok(cache_refreshed) => {
manager.clear_caches_after_marketplace_source_refresh(
cache_refreshed,
on_effective_plugins_changed.as_ref(),
);
}
Err(err) => {
manager.clear_cache();
CURATED_REPO_SYNC_STARTED.store(false, Ordering::SeqCst);
warn!("failed to refresh curated plugin cache after sync: {err}");
}
}
}
Err(err) => {
CURATED_REPO_SYNC_STARTED.store(false, Ordering::SeqCst);
warn!("failed to sync curated plugins repo: {err}");
}
}
})
{
CURATED_REPO_SYNC_STARTED.store(false, Ordering::SeqCst);
warn!("failed to start curated plugins repo sync task: {err}");
}
}
async fn run_remote_installed_plugins_cache_refresh_loop(self: Arc<Self>) {
loop {
let request = {

View File

@@ -6,9 +6,11 @@ use crate::PluginLoadOutcome;
use crate::ToolSuggestDiscoverablePlugin;
use crate::ToolSuggestPluginDiscoveryInput;
use crate::installed_marketplaces::marketplace_install_root;
use crate::loader::configured_curated_plugin_ids_from_codex_home;
use crate::loader::load_plugin_skill_inventory;
use crate::loader::load_plugins_from_layer_stack;
use crate::loader::plugin_capability_summary_from_root;
use crate::loader::refresh_curated_plugin_cache;
use crate::loader::refresh_non_curated_plugin_cache;
use crate::loader::refresh_non_curated_plugin_cache_force_reinstall;
use crate::marketplace::MarketplacePluginInstallPolicy;
@@ -160,33 +162,6 @@ async fn plugins_manager_reads_auth_mode_from_auth_manager() {
assert_eq!(manager_with_auth.auth_mode(), Some(AuthMode::Chatgpt));
}
#[test]
fn curated_repo_sync_stays_deferred_for_remote_chatgpt_catalog() {
CURATED_REPO_SYNC_STARTED.store(false, std::sync::atomic::Ordering::SeqCst);
let tmp = TempDir::new().unwrap();
let config = PluginsConfigInput::new(
unrestricted_config_layer_stack(),
Default::default(),
"openai".to_string(),
/*plugins_enabled*/ true,
/*remote_plugin_enabled*/ true,
"https://chatgpt.com".to_string(),
test_http_client_factory(),
/*product_sku*/ None,
);
let manager = Arc::new(test_plugins_manager_with_options(
tmp.path().to_path_buf(),
Some(Product::Codex),
Some(AuthMode::Chatgpt),
));
manager.maybe_start_curated_repo_sync_for_config(
&config, /*on_effective_plugins_changed*/ None,
);
assert!(!CURATED_REPO_SYNC_STARTED.load(std::sync::atomic::Ordering::SeqCst));
}
#[test]
fn marketplace_source_refresh_notifies_only_after_installed_cache_changes() {
let tmp = TempDir::new().unwrap();

View File

@@ -88,10 +88,6 @@ host_pattern = '^github[.]com$'
permitted
);
}
manager.maybe_start_curated_repo_sync_for_config(
&blocked, /*on_effective_plugins_changed*/ None,
);
assert!(!CURATED_REPO_SYNC_STARTED.load(std::sync::atomic::Ordering::SeqCst));
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,37 +0,0 @@
//! HTTP transport for curated plugin startup sync.
//!
//! Both proxy modes retain the supplied application network policy. The default proxy mode also
//! keeps the legacy fallback for invalid custom CA configuration; system-proxy mode fails closed.
//! Startup-sync request helpers apply the standard Codex headers.
use std::sync::Arc;
use crate::http_client_selector::HttpClientSelector;
use codex_http_client::ClientRouteClass;
use codex_http_client::HttpClientFactory;
use codex_http_client::RequestBuilder;
use codex_http_client::RouteAwareClientPool;
use http::Method;
pub(super) struct StartupSyncHttpClient(Arc<dyn HttpClientSelector>);
impl StartupSyncHttpClient {
pub(super) fn new(http_client_factory: &HttpClientFactory) -> Self {
let http_clients =
RouteAwareClientPool::with_chatgpt_cloudflare_cookies_without_request_logging(
http_client_factory.clone(),
ClientRouteClass::Api,
)
.with_legacy_custom_ca_fallback();
Self(Arc::new(http_clients))
}
#[cfg(test)]
pub(super) fn route_aware(http_clients: Arc<dyn HttpClientSelector>) -> Self {
Self(http_clients)
}
pub(super) fn request(&self, method: Method, url: &str) -> RequestBuilder {
self.0.request(method, url)
}
}

File diff suppressed because it is too large Load Diff