aKode fase 5: rinomina interna (crate akode-*, akode-rs/, akode-cli/, binario akode, AKODE_*, ~/.akode, snapshot)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-11 11:06:46 +01:00
parent df99318392
commit 86e7c72e5f
10383 changed files with 749164 additions and 749170 deletions

View File

@@ -0,0 +1,154 @@
//! Regressions for reload entry points composing the final thread configuration.
use super::config_processor::reload_user_config;
use crate::config_manager::ConfigManager;
use crate::mcp_refresh::reload_mcp_config;
use akode_config::types::AuthKeyringBackendKind;
use akode_core::config::ConfigOverrides;
use akode_exec_server::EnvironmentManager;
use akode_login::CodexAuth;
use pretty_assertions::assert_eq;
use serde_json::json;
use std::collections::HashMap;
use std::sync::Arc;
#[tokio::test]
async fn reloads_accept_a_provider_supplied_by_thread_overrides() -> anyhow::Result<()> {
let home = tempfile::tempdir()?;
let manager = ConfigManager::without_managed_config_for_tests(home.path().to_path_buf());
let initial = manager
.load_for_cwd(
Some(HashMap::from([
("model_provider".to_string(), json!("thread-provider")),
(
"model_providers.thread-provider".to_string(),
json!({"name": "Thread provider", "base_url": "https://provider.example/v1", "wire_api": "responses"}),
),
])),
ConfigOverrides::default(),
Some(home.path().to_path_buf()),
)
.await?;
let threads = Arc::new(
akode_core::test_support::thread_manager_with_models_provider_and_home(
CodexAuth::from_api_key("dummy"),
initial.model_provider.clone(),
initial.codex_home.to_path_buf(),
Arc::new(EnvironmentManager::default_for_tests()),
),
);
let thread = threads
.start_thread(akode_core::StartThreadOptions::new(initial))
.await?
.thread;
for enabled in [true, false] {
std::fs::write(
home.path().join(akode_config::CONFIG_TOML_FILE),
format!(
"model_provider = 'missing-provider'\n[features]\nsecret_auth_storage = {enabled}\n"
),
)?;
if enabled {
reload_mcp_config(&threads, &manager).await?;
} else {
reload_user_config(&manager, &threads).await;
}
let config = thread.config().await;
assert_eq!(config.model_provider_id, "thread-provider");
assert_eq!(
config.auth_keyring_backend_kind(),
if enabled {
AuthKeyringBackendKind::Secrets
} else {
AuthKeyringBackendKind::Direct
}
);
}
Ok(())
}
#[tokio::test]
async fn user_reload_promotes_plugin_and_feature_requirements_without_server_changes()
-> anyhow::Result<()> {
let home = tempfile::tempdir()?;
let requirements_path = home.path().join("requirements.toml");
std::fs::write(&requirements_path, "")?;
std::fs::write(
home.path().join(akode_config::CONFIG_TOML_FILE),
"[features]\nenable_mcp_apps = true\n",
)?;
let mut overrides = akode_config::LoaderOverrides::without_managed_config_for_tests();
overrides.ignore_managed_requirements = false;
overrides.system_requirements_path = Some(requirements_path.clone());
let manager = ConfigManager::new(
home.path().to_path_buf(),
Vec::new(),
overrides,
/*strict_config*/ false,
akode_arg0::Arg0DispatchPaths::default(),
Arc::new(akode_config::NoopThreadConfigLoader),
);
let initial = manager
.load_latest_config(Some(home.path().to_path_buf()))
.await?;
let threads = Arc::new(
akode_core::test_support::thread_manager_with_models_provider_and_home(
CodexAuth::from_api_key("dummy"),
initial.model_provider.clone(),
initial.codex_home.to_path_buf(),
Arc::new(EnvironmentManager::default_for_tests()),
),
);
assert!(
initial
.features
.enabled(akode_features::Feature::EnableMcpApps)
);
let original_servers = initial.mcp_servers.get().clone();
let thread = threads
.start_thread(akode_core::StartThreadOptions::new(initial))
.await?
.thread;
std::fs::write(
&requirements_path,
"[features]\nenable_mcp_apps = false\n[plugins.example.mcp_servers]\n",
)?;
tokio::time::timeout(
std::time::Duration::from_secs(10),
reload_user_config(&manager, &threads),
)
.await
.expect("policy promotion must terminate");
let config = thread.config().await;
assert_eq!(config.mcp_servers.get(), &original_servers);
assert!(
!config
.features
.enabled(akode_features::Feature::EnableMcpApps)
);
assert!(
config
.config_layer_stack
.requirements()
.plugins
.as_ref()
.unwrap()
.value
.get("example")
.unwrap()
.mcp_servers
.as_ref()
.unwrap()
.is_empty()
);
assert!(
config
.config_layer_stack
.requirements()
.feature_requirements
.is_some()
);
Ok(())
}