aKode fase 2b-2: rimosso login ChatGPT e tutti i sottosistemi solo-ChatGPT

- Login: resta solo chiave API (+ header, Bedrock). Rimossi OAuth/browser,
  device code, refresh/revoke su auth.openai.com, PAT, agent/workload identity,
  runtime agent instance, backend-client e openapi-models, workspace routing.
- Rimossi: generazione immagini (ext + skill imagegen), history notes, plugin
  remoti (catalogo, sync, share), cyber access program, daybreak, cloud config
  e requirements (config_server ora fail-closed), attestation, frozen cloud
  skills, EMA MCP auth, Codex Apps/connettori, ricerca ospitata, header/zstd/
  routing/cookie del backend Codex, fallback OPENAI_API_KEY del realtime.
- Messaggi d'errore senza link a chatgpt.com.
- Chiavi di config legacy accettate e ignorate; feature rimosse = Stage::Removed.
- Test: cancellati solo quelli del codice rimosso; test di sicurezza
  (sandbox estensioni, permessi, redazione, auth storage, requirements)
  adattati. Restano solo fallimenti d'ambiente (code-mode-host/V8, ~/.agents).
- Istruzioni di sistema invariate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-10 16:20:15 +01:00
parent 82347a58ed
commit 6089fbde91
1573 changed files with 10289 additions and 177679 deletions

View File

@@ -740,20 +740,6 @@ async fn child_session_inherits_resumed_parent_auth(host_child: bool) {
Arc::ptr_eq(&child.thread.session.services.auth_manager, &replacement),
"child must use the resumed parent's credentials",
);
assert!(
Arc::ptr_eq(
&child.thread.session.services.runtime_auth,
&parent.thread.session.services.runtime_auth,
),
"child must share the resumed parent's runtime owner",
);
assert!(
!Arc::ptr_eq(
&child.thread.session.services.runtime_auth,
&manager.state.runtime_auth
),
"replacement-auth descendants must stay separate from the harness runtime",
);
let report = manager
.shutdown_all_threads_bounded(Duration::from_secs(10))
.await;
@@ -1338,7 +1324,6 @@ async fn mcp_invalidation_refreshes_threads_that_are_still_starting() {
TEST_INSTALLATION_ID.to_string(),
Arc::new(ModelCatalogSettings::disk(config.codex_home.to_path_buf())),
),
crate::CodexAppsToolsCache::default(),
SessionSource::Exec,
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
Arc::new(extensions.build()),
@@ -1346,7 +1331,6 @@ async fn mcp_invalidation_refreshes_threads_that_are_still_starting() {
passthrough_image_store(),
ThreadStoreBuilder::from_config(&config, /*state_db*/ None).build(),
/*agent_graph_store*/ None,
/*attestation_provider*/ None,
/*external_time_provider*/ None,
));
let starting = tokio::spawn({
@@ -1624,7 +1608,6 @@ async fn spawn_internal_session_preserves_parent_lineage_without_forking_history
manager_state.mcp_manager = Arc::new(McpManager::new_with_extensions(
Arc::clone(&manager_state.plugins_manager),
Arc::clone(&manager_state.extensions),
manager_state.mcp_manager.codex_apps_tools_cache(),
));
let parent_provider = Arc::new(ParentInstructionsProvider(parent_instructions.clone()));
manager_state.user_instructions_provider = parent_provider.clone();
@@ -1964,7 +1947,6 @@ async fn start_thread_seeds_extension_data_for_mcp_and_lifecycle_contributors()
codex_extension_api::SelectedPluginContribution {
plugin_display_name: plugin_id,
source_environment_id,
connector_ids: vec![format!("{selected_root_id}-connector")],
servers: vec![(selected_root_id, server)],
}
}),
@@ -2000,8 +1982,7 @@ async fn start_thread_seeds_extension_data_for_mcp_and_lifecycle_contributors()
let mut extensions = codex_extension_api::ExtensionRegistryBuilder::new();
extensions.thread_lifecycle_contributor(recorder.clone());
extensions.mcp_server_contributor(recorder.clone());
let auth_manager =
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
let manager = ThreadManager::new(
&config,
crate::build_startup_models(
@@ -2010,7 +1991,6 @@ async fn start_thread_seeds_extension_data_for_mcp_and_lifecycle_contributors()
TEST_INSTALLATION_ID.to_string(),
Arc::new(ModelCatalogSettings::disk(config.codex_home.to_path_buf())),
),
crate::CodexAppsToolsCache::default(),
SessionSource::Exec,
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
Arc::new(extensions.build()),
@@ -2018,7 +1998,6 @@ async fn start_thread_seeds_extension_data_for_mcp_and_lifecycle_contributors()
passthrough_image_store(),
ThreadStoreBuilder::from_config(&config, /*state_db*/ None).build(),
/*agent_graph_store*/ None,
/*attestation_provider*/ None,
/*external_time_provider*/ None,
);
let selected_root_init = |id: &str, environment_id: &str| {
@@ -2156,11 +2135,6 @@ async fn start_thread_seeds_extension_data_for_mcp_and_lifecycle_contributors()
));
assert_eq!(Some(server), expected.build().server(name));
}
// aKode never contributes the ChatGPT-hosted Codex Apps server.
assert!(
!codex_mcp::configured_mcp_servers(&first_resolved.config)
.contains_key(codex_mcp::CODEX_APPS_MCP_SERVER_NAME)
);
for (policy, disabled_plugin_ids, selected_enabled, expected_mcp_loads) in [
("", vec!["plugin-selected-a".to_string()], false, 1),
("", vec![], true, 1),
@@ -2217,14 +2191,6 @@ async fn start_thread_seeds_extension_data_for_mcp_and_lifecycle_contributors()
selected_servers(&projection.config).contains_key("selected-a"),
selected_enabled
);
assert_eq!(
projection
.config
.connector_snapshot
.disabled_connector_ids()
.contains("selected-a-connector"),
!disabled_plugin_ids.is_empty()
);
assert_eq!(
projection.selected_plugins.plugins.len(),
usize::from(selected_enabled)
@@ -2439,8 +2405,7 @@ async fn resume_and_fork_do_not_restore_thread_environments_from_rollout() {
config.cwd = config.codex_home.abs();
std::fs::create_dir_all(&config.codex_home).expect("create codex home");
let auth_manager =
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
let manager = ThreadManager::new(
&config,
crate::build_startup_models(
@@ -2449,7 +2414,6 @@ async fn resume_and_fork_do_not_restore_thread_environments_from_rollout() {
TEST_INSTALLATION_ID.to_string(),
Arc::new(ModelCatalogSettings::disk(config.codex_home.to_path_buf())),
),
crate::CodexAppsToolsCache::default(),
SessionSource::Exec,
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
empty_extension_registry(),
@@ -2457,7 +2421,6 @@ async fn resume_and_fork_do_not_restore_thread_environments_from_rollout() {
passthrough_image_store(),
ThreadStoreBuilder::from_config(&config, /*state_db*/ None).build(),
/*agent_graph_store*/ None,
/*attestation_provider*/ None,
/*external_time_provider*/ None,
);
let selected_cwd =
@@ -2598,8 +2561,7 @@ async fn explicit_installation_id_skips_codex_home_file() {
config.cwd = config.codex_home.abs();
std::fs::create_dir_all(&config.codex_home).expect("create codex home");
let auth_manager =
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
let installation_id = uuid::Uuid::new_v4().to_string();
let state_db = init_state_db(&config).await;
let thread_store = ThreadStoreBuilder::from_config(&config, state_db.clone()).build();
@@ -2611,7 +2573,6 @@ async fn explicit_installation_id_skips_codex_home_file() {
installation_id.clone(),
Arc::new(ModelCatalogSettings::disk(config.codex_home.to_path_buf())),
),
crate::CodexAppsToolsCache::default(),
SessionSource::Exec,
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
empty_extension_registry(),
@@ -2619,7 +2580,6 @@ async fn explicit_installation_id_skips_codex_home_file() {
passthrough_image_store(),
thread_store,
local_agent_graph_store_from_state_db(state_db.as_ref()),
/*attestation_provider*/ None,
/*external_time_provider*/ None,
);
@@ -2647,8 +2607,7 @@ async fn resume_active_thread_from_rollout_returns_running_thread() {
config.cwd = config.codex_home.abs();
std::fs::create_dir_all(&config.codex_home).expect("create codex home");
let auth_manager =
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
let manager = ThreadManager::new(
&config,
crate::build_startup_models(
@@ -2657,7 +2616,6 @@ async fn resume_active_thread_from_rollout_returns_running_thread() {
TEST_INSTALLATION_ID.to_string(),
Arc::new(ModelCatalogSettings::disk(config.codex_home.to_path_buf())),
),
crate::CodexAppsToolsCache::default(),
SessionSource::Exec,
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
empty_extension_registry(),
@@ -2665,7 +2623,6 @@ async fn resume_active_thread_from_rollout_returns_running_thread() {
passthrough_image_store(),
ThreadStoreBuilder::from_config(&config, /*state_db*/ None).build(),
/*agent_graph_store*/ None,
/*attestation_provider*/ None,
/*external_time_provider*/ None,
);
@@ -2715,8 +2672,7 @@ async fn resume_stopped_thread_from_rollout_spawns_new_thread() {
config.cwd = config.codex_home.abs();
std::fs::create_dir_all(&config.codex_home).expect("create codex home");
let auth_manager =
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
let manager = ThreadManager::new(
&config,
crate::build_startup_models(
@@ -2725,7 +2681,6 @@ async fn resume_stopped_thread_from_rollout_spawns_new_thread() {
TEST_INSTALLATION_ID.to_string(),
Arc::new(ModelCatalogSettings::disk(config.codex_home.to_path_buf())),
),
crate::CodexAppsToolsCache::default(),
SessionSource::Exec,
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
empty_extension_registry(),
@@ -2733,7 +2688,6 @@ async fn resume_stopped_thread_from_rollout_spawns_new_thread() {
passthrough_image_store(),
ThreadStoreBuilder::from_config(&config, /*state_db*/ None).build(),
/*agent_graph_store*/ None,
/*attestation_provider*/ None,
/*external_time_provider*/ None,
);
@@ -2788,8 +2742,7 @@ async fn resume_stopped_thread_from_rollout_preserves_thread_source() {
config.cwd = config.codex_home.abs();
std::fs::create_dir_all(&config.codex_home).expect("create codex home");
let auth_manager =
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
let state_db = init_state_db(&config).await;
let thread_store = ThreadStoreBuilder::from_config(&config, state_db.clone()).build();
let manager = ThreadManager::new(
@@ -2800,7 +2753,6 @@ async fn resume_stopped_thread_from_rollout_preserves_thread_source() {
TEST_INSTALLATION_ID.to_string(),
Arc::new(ModelCatalogSettings::disk(config.codex_home.to_path_buf())),
),
crate::CodexAppsToolsCache::default(),
SessionSource::Exec,
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
empty_extension_registry(),
@@ -2808,7 +2760,6 @@ async fn resume_stopped_thread_from_rollout_preserves_thread_source() {
passthrough_image_store(),
thread_store,
local_agent_graph_store_from_state_db(state_db.as_ref()),
/*attestation_provider*/ None,
/*external_time_provider*/ None,
);
@@ -2879,8 +2830,7 @@ async fn subtree_listing_uses_injected_graph_store_without_state_db() {
root_thread_id,
descendant_thread_ids: descendant_thread_ids.clone(),
});
let auth_manager =
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
let manager = ThreadManager::new(
&config,
crate::build_startup_models(
@@ -2889,7 +2839,6 @@ async fn subtree_listing_uses_injected_graph_store_without_state_db() {
TEST_INSTALLATION_ID.to_string(),
Arc::new(ModelCatalogSettings::disk(config.codex_home.to_path_buf())),
),
crate::CodexAppsToolsCache::default(),
SessionSource::Exec,
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
empty_extension_registry(),
@@ -2897,7 +2846,6 @@ async fn subtree_listing_uses_injected_graph_store_without_state_db() {
passthrough_image_store(),
ThreadStoreBuilder::from_config(&config, /*state_db*/ None).build(),
Some(agent_graph_store),
/*attestation_provider*/ None,
/*external_time_provider*/ None,
);
@@ -2923,8 +2871,7 @@ async fn rollout_path_resume_and_fork_read_history_through_thread_store() {
};
std::fs::create_dir_all(&config.codex_home).expect("create codex home");
let auth_manager =
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
let state_db = init_state_db(&config).await;
let thread_store = ThreadStoreBuilder::from_config(&config, state_db.clone()).build();
let in_memory_store = thread_store
@@ -2939,7 +2886,6 @@ async fn rollout_path_resume_and_fork_read_history_through_thread_store() {
TEST_INSTALLATION_ID.to_string(),
Arc::new(ModelCatalogSettings::disk(config.codex_home.to_path_buf())),
),
crate::CodexAppsToolsCache::default(),
SessionSource::Exec,
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
empty_extension_registry(),
@@ -2947,7 +2893,6 @@ async fn rollout_path_resume_and_fork_read_history_through_thread_store() {
passthrough_image_store(),
thread_store.clone(),
local_agent_graph_store_from_state_db(state_db.as_ref()),
/*attestation_provider*/ None,
/*external_time_provider*/ None,
);
@@ -3036,8 +2981,7 @@ async fn metadata_update_without_result_reads_only_when_the_caller_needs_the_thr
};
std::fs::create_dir_all(&config.codex_home).expect("create codex home");
let auth_manager =
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
let thread_store = ThreadStoreBuilder::from_config(&config, /*state_db*/ None).build();
let in_memory_store = thread_store
.as_any()
@@ -3051,7 +2995,6 @@ async fn metadata_update_without_result_reads_only_when_the_caller_needs_the_thr
TEST_INSTALLATION_ID.to_string(),
Arc::new(ModelCatalogSettings::disk(config.codex_home.to_path_buf())),
),
crate::CodexAppsToolsCache::default(),
SessionSource::Exec,
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
empty_extension_registry(),
@@ -3059,7 +3002,6 @@ async fn metadata_update_without_result_reads_only_when_the_caller_needs_the_thr
passthrough_image_store(),
thread_store.clone(),
/*agent_graph_store*/ None,
/*attestation_provider*/ None,
/*external_time_provider*/ None,
);
let started = manager
@@ -3157,6 +3099,27 @@ async fn metadata_update_without_result_reads_only_when_the_caller_needs_the_thr
);
}
/// Stored API keys never refresh the OpenAI catalog, so these refresh tests use a
/// command-authenticated provider, which keeps catalog refresh enabled.
fn refreshable_provider_auth(
cwd: &std::path::Path,
) -> codex_protocol::config_types::ModelProviderAuthInfo {
codex_protocol::config_types::ModelProviderAuthInfo {
command: if cfg!(windows) { "cmd.exe" } else { "echo" }.into(),
args: if cfg!(windows) {
vec!["/D", "/C", "echo", "test-token"]
} else {
vec!["test-token"]
}
.into_iter()
.map(Into::into)
.collect(),
timeout_ms: std::num::NonZeroU64::new(/*n*/ 5_000).expect("nonzero timeout"),
refresh_interval_ms: 60_000,
cwd: cwd.try_into().expect("absolute cwd"),
}
}
#[test_case::test_case(true; "disk_cache")]
#[test_case::test_case(false; "without_cache")]
#[tokio::test]
@@ -3171,9 +3134,9 @@ async fn new_uses_active_provider_for_model_refresh(with_cache: bool) {
std::fs::create_dir_all(&config.codex_home).expect("create codex home");
config.model_catalog = None;
config.model_provider.base_url = Some(server.uri());
config.model_provider.auth = Some(refreshable_provider_auth(config.codex_home.as_path()));
let auth_manager =
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
let manager = ThreadManager::new(
&config,
crate::build_startup_models(
@@ -3186,7 +3149,6 @@ async fn new_uses_active_provider_for_model_refresh(with_cache: bool) {
ModelCatalogSettings::default()
}),
),
crate::CodexAppsToolsCache::default(),
SessionSource::Exec,
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
empty_extension_registry(),
@@ -3194,7 +3156,6 @@ async fn new_uses_active_provider_for_model_refresh(with_cache: bool) {
passthrough_image_store(),
ThreadStoreBuilder::from_config(&config, /*state_db*/ None).build(),
/*agent_graph_store*/ None,
/*attestation_provider*/ None,
/*external_time_provider*/ None,
);
@@ -3330,9 +3291,9 @@ async fn startup_catalog_cache_policy_controls_refresh() {
std::fs::create_dir_all(&config.codex_home).expect("create codex home");
config.model_catalog = None;
config.model_provider.base_url = Some(server.uri());
config.model_provider.auth = Some(refreshable_provider_auth(config.codex_home.as_path()));
let auth_manager =
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
let manager = ThreadManager::new(
&config,
crate::build_startup_models(
@@ -3341,7 +3302,6 @@ async fn startup_catalog_cache_policy_controls_refresh() {
TEST_INSTALLATION_ID.to_string(),
Arc::new(ModelCatalogSettings::default()),
),
crate::CodexAppsToolsCache::default(),
SessionSource::Custom("test-embedder".to_string()),
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
empty_extension_registry(),
@@ -3349,7 +3309,6 @@ async fn startup_catalog_cache_policy_controls_refresh() {
passthrough_image_store(),
ThreadStoreBuilder::from_config(&config, /*state_db*/ None).build(),
/*agent_graph_store*/ None,
/*attestation_provider*/ None,
/*external_time_provider*/ None,
);
@@ -3614,8 +3573,7 @@ async fn interrupted_fork_snapshot_does_not_synthesize_turn_id_for_legacy_histor
config.cwd = config.codex_home.abs();
std::fs::create_dir_all(&config.codex_home).expect("create codex home");
let auth_manager =
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
let state_db = init_state_db(&config).await;
let manager = ThreadManager::new(
&config,
@@ -3625,7 +3583,6 @@ async fn interrupted_fork_snapshot_does_not_synthesize_turn_id_for_legacy_histor
TEST_INSTALLATION_ID.to_string(),
Arc::new(ModelCatalogSettings::disk(config.codex_home.to_path_buf())),
),
crate::CodexAppsToolsCache::default(),
SessionSource::Exec,
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
empty_extension_registry(),
@@ -3633,7 +3590,6 @@ async fn interrupted_fork_snapshot_does_not_synthesize_turn_id_for_legacy_histor
passthrough_image_store(),
ThreadStoreBuilder::from_config(&config, state_db.clone()).build(),
local_agent_graph_store_from_state_db(state_db.as_ref()),
/*attestation_provider*/ None,
/*external_time_provider*/ None,
);
@@ -3728,8 +3684,7 @@ async fn interrupted_fork_snapshot_preserves_explicit_turn_id() {
config.cwd = config.codex_home.abs();
std::fs::create_dir_all(&config.codex_home).expect("create codex home");
let auth_manager =
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
let state_db = init_state_db(&config).await;
let manager = ThreadManager::new(
&config,
@@ -3739,7 +3694,6 @@ async fn interrupted_fork_snapshot_preserves_explicit_turn_id() {
TEST_INSTALLATION_ID.to_string(),
Arc::new(ModelCatalogSettings::disk(config.codex_home.to_path_buf())),
),
crate::CodexAppsToolsCache::default(),
SessionSource::Exec,
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
empty_extension_registry(),
@@ -3747,7 +3701,6 @@ async fn interrupted_fork_snapshot_preserves_explicit_turn_id() {
passthrough_image_store(),
ThreadStoreBuilder::from_config(&config, state_db.clone()).build(),
local_agent_graph_store_from_state_db(state_db.as_ref()),
/*attestation_provider*/ None,
/*external_time_provider*/ None,
);
@@ -3835,8 +3788,7 @@ async fn interrupted_fork_snapshot_uses_persisted_mid_turn_history_without_live_
config.cwd = config.codex_home.abs();
std::fs::create_dir_all(&config.codex_home).expect("create codex home");
let auth_manager =
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
let auth_manager = AuthManager::from_auth_for_testing(CodexAuth::from_api_key("Test API Key"));
let state_db = init_state_db(&config).await;
let manager = ThreadManager::new(
&config,
@@ -3846,7 +3798,6 @@ async fn interrupted_fork_snapshot_uses_persisted_mid_turn_history_without_live_
TEST_INSTALLATION_ID.to_string(),
Arc::new(ModelCatalogSettings::disk(config.codex_home.to_path_buf())),
),
crate::CodexAppsToolsCache::default(),
SessionSource::Exec,
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
empty_extension_registry(),
@@ -3854,7 +3805,6 @@ async fn interrupted_fork_snapshot_uses_persisted_mid_turn_history_without_live_
passthrough_image_store(),
ThreadStoreBuilder::from_config(&config, state_db.clone()).build(),
local_agent_graph_store_from_state_db(state_db.as_ref()),
/*attestation_provider*/ None,
/*external_time_provider*/ None,
);