WIP fase 2b-3: rimozione sottosistemi solo-ChatGPT (plugin remoti, image gen, daybreak, cyber, attestation, cloud config, app/connettori) - test in corso

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-10 16:07:22 +01:00
parent 231e8cd136
commit 5afc7e9f7f
1223 changed files with 6225 additions and 113722 deletions

View File

@@ -11,9 +11,8 @@ use serde::Serialize;
#[derive(Debug, Clone, Copy, Default, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
#[schemars(deny_unknown_fields)]
pub struct ModelProviderCapabilities {
/// Whether the provider accepts explicit `access_programs.cyber` selections.
/// Defaults to enabled for the built-in OpenAI provider and disabled otherwise.
/// This does not grant program access or change authentication.
/// Removed: explicit access-program selection was deleted. Accepted and ignored
/// so existing provider configs keep loading.
pub cyber_access_programs: Option<bool>,
/// Whether hosted web search may access the live web.
pub external_web_access: Option<bool>,

View File

@@ -683,14 +683,6 @@ other non-default provider fields are not supported"
}
}
/// Whether explicit Cyber programs may be selected and forwarded to this provider.
/// Use the configured provider ID, never its user-controlled display name, for defaults.
pub fn supports_cyber_access_programs(&self, provider_id: &str) -> bool {
self.capabilities
.and_then(|capabilities| capabilities.cyber_access_programs)
.unwrap_or(provider_id == OPENAI_PROVIDER_ID)
}
pub fn is_openai(&self) -> bool {
self.name == OPENAI_PROVIDER_NAME
}
@@ -768,22 +760,10 @@ pub fn merge_configured_model_providers(
if key == "openai" {
// Keep the built-in identity, inference routing, and authentication.
// Only catalog routing is configurable through this provider entry.
if let Some(catalog_url) = provider.model_catalog_url.take()
&& let Some(built_in_provider) = model_providers.get_mut(&key)
{
let allowed = catalog_url.parse::<http::Uri>().ok().is_some_and(|uri| {
uri.scheme_str() == Some("https")
&& uri.host().is_some_and(|host| {
codex_http_client::is_allowed_chatgpt_host(&host.to_ascii_lowercase())
})
&& uri
.authority()
.is_some_and(|authority| !authority.as_str().contains('@'))
});
if !allowed {
return Err("model_providers.openai.model_catalog_url must use an allowed ChatGPT host. If you need to use a 3rd party host, configure a custom model_provider".to_string());
}
built_in_provider.model_catalog_url = Some(catalog_url);
// aKode never routes the built-in OpenAI provider's catalog to a ChatGPT host;
// catalogs from any other host need a custom model_provider.
if provider.model_catalog_url.is_some() {
return Err("model_providers.openai.model_catalog_url is not supported. If you need a model catalog, configure a custom model_provider".to_string());
}
} else if matches!(
key.as_str(),

View File

@@ -936,7 +936,8 @@ model_catalog_url = "https://gateway.example/codex/catalog?token=catalog-secret"
#[test]
fn builtin_openai_catalog_override_preserves_inference_and_identity() {
for inference_url in [None, Some("https://us.api.openai.com/v1")] {
for catalog_url in [None, Some("https://chatgpt.com/backend-api/codex/models")] {
// A catalog override on the built-in provider is rejected; see the tests below.
for catalog_url in [None::<&str>] {
let configured: ModelProviderInfo = toml::from_str(&format!(
"name = \"Ignored name\"\nbase_url = \"https://ignored.example/v1\"\nrequires_openai_auth = false\n{}",
catalog_url.map(|url| format!("model_catalog_url = {url:?}")).unwrap_or_default()
@@ -978,7 +979,7 @@ fn builtin_openai_catalog_rejects_untrusted_destinations() {
HashMap::from([("openai".to_string(), provider.clone())]),
)
.unwrap_err(),
"model_providers.openai.model_catalog_url must use an allowed ChatGPT host. If you need to use a 3rd party host, configure a custom model_provider",
"model_providers.openai.model_catalog_url is not supported. If you need a model catalog, configure a custom model_provider",
);
let mut expected = built_in_model_providers(/*openai_base_url*/ None);
expected.insert("custom".into(), provider.clone());
@@ -994,7 +995,8 @@ fn builtin_openai_catalog_rejects_untrusted_destinations() {
}
#[test]
fn builtin_openai_catalog_accepts_existing_chatgpt_hosts() {
fn builtin_openai_catalog_rejects_chatgpt_hosts() {
// aKode never fetches the built-in provider's catalog from ChatGPT.
for host in [
"chatgpt.com",
"gov.chatgpt.com",
@@ -1003,48 +1005,33 @@ fn builtin_openai_catalog_accepts_existing_chatgpt_hosts() {
"api.chatgpt-staging.com",
"CHATGPT.COM",
] {
let url = format!("https://{host}/backend-api/codex/models");
let provider = ModelProviderInfo {
model_catalog_url: Some(url.clone().into()),
model_catalog_url: Some(format!("https://{host}/backend-api/codex/models").into()),
..Default::default()
};
let mut expected = built_in_model_providers(/*openai_base_url*/ None);
expected.get_mut("openai").unwrap().model_catalog_url = Some(url.into());
assert_eq!(
merge_configured_model_providers(
built_in_model_providers(/*openai_base_url*/ None),
HashMap::from([("openai".into(), provider)]),
)
.unwrap(),
expected
.unwrap_err(),
"model_providers.openai.model_catalog_url is not supported. If you need a model catalog, configure a custom model_provider",
);
}
}
#[test]
fn cyber_access_program_capability_uses_provider_identity_and_explicit_overrides() {
for provider_id in [
OPENAI_PROVIDER_ID,
"proxy",
AMAZON_BEDROCK_PROVIDER_ID,
GCP_PROVIDER_ID,
] {
for configured in [None, Some(false), Some(true)] {
// A custom provider cannot gain the default by copying OpenAI's display name.
let config = match configured {
Some(enabled) => format!(
"name = \"OpenAI\"\n[capabilities]\ncyber_access_programs = {enabled}\n"
),
None => "name = \"OpenAI\"\n".to_owned(),
};
let provider: ModelProviderInfo = toml::from_str(&config).unwrap();
assert_eq!(
provider.supports_cyber_access_programs(provider_id),
configured.unwrap_or(provider_id == OPENAI_PROVIDER_ID),
);
let round_trip: ModelProviderInfo =
toml::from_str(&toml::to_string(&provider).unwrap()).unwrap();
assert_eq!(round_trip, provider);
}
fn legacy_cyber_access_programs_capability_is_accepted_and_ignored() {
for configured in [None, Some(false), Some(true)] {
let config = match configured {
Some(enabled) => {
format!("name = \"OpenAI\"\n[capabilities]\ncyber_access_programs = {enabled}\n")
}
None => "name = \"OpenAI\"\n".to_owned(),
};
let provider: ModelProviderInfo = toml::from_str(&config).unwrap();
let round_trip: ModelProviderInfo =
toml::from_str(&toml::to_string(&provider).unwrap()).unwrap();
assert_eq!(round_trip, provider);
}
}