Rinomina: crate akode-*, cartelle akode-rs/ e akode-cli/, binario akode, ~/.akode, AKODE_* (A)
Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
84
akode-rs/models-manager/src/cache_identity_tests.rs
Normal file
84
akode-rs/models-manager/src/cache_identity_tests.rs
Normal file
@@ -0,0 +1,84 @@
|
||||
//! Coverage for cache identity validation and conditional freshness updates.
|
||||
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[tokio::test]
|
||||
async fn mismatched_and_legacy_cache_entries_fetch_the_current_catalog() {
|
||||
for identity in [None, Some("other-provider-or-account".to_string())] {
|
||||
let stale = remote_model("stale", "Stale", /*priority*/ 0);
|
||||
let current = remote_model("current", "Current", /*priority*/ 0);
|
||||
let cache = TestModelsCache::with_entry(ModelsCacheEntry {
|
||||
fetched_at: Utc::now(),
|
||||
etag: Some("old-etag".into()),
|
||||
client_version: Some(crate::client_version_to_whole()),
|
||||
identity,
|
||||
models: vec![stale],
|
||||
});
|
||||
let endpoint = TestModelsEndpoint::new(vec![vec![current.clone()]]);
|
||||
let manager = OpenAiModelsManager::new_with_cache(
|
||||
cache.clone(),
|
||||
endpoint.clone(),
|
||||
Some(AuthManager::from_auth_for_testing(CodexAuth::from_api_key(
|
||||
"test-api-key",
|
||||
))),
|
||||
);
|
||||
manager.set_api_key_model_discovery_enabled(/*enabled*/ true);
|
||||
manager
|
||||
.ensure_initialized(DEFAULT_HTTP_CLIENT_FACTORY)
|
||||
.await;
|
||||
assert_eq!(
|
||||
manager
|
||||
.raw_model_catalog(RefreshStrategy::InMemory, DEFAULT_HTTP_CLIENT_FACTORY)
|
||||
.await
|
||||
.models,
|
||||
vec![current.clone()]
|
||||
);
|
||||
assert_eq!(endpoint.fetch_count(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn matching_etag_cannot_renew_a_different_identity_or_catalog() {
|
||||
let home = tempdir().unwrap();
|
||||
let cache = FileModelsCache::new(home.path().join(MODEL_CACHE_FILE), DEFAULT_MODEL_CACHE_TTL);
|
||||
let expected = ModelsCacheEntry {
|
||||
fetched_at: Utc::now() - chrono::Duration::hours(1),
|
||||
etag: Some("etag".into()),
|
||||
client_version: Some(crate::client_version_to_whole()),
|
||||
identity: Some("first-account".into()),
|
||||
models: vec![remote_model("model", "Model", /*priority*/ 0)],
|
||||
};
|
||||
for (key, etag, version) in [
|
||||
("other-account", "etag", crate::client_version_to_whole()),
|
||||
(
|
||||
"first-account",
|
||||
"new-etag",
|
||||
crate::client_version_to_whole(),
|
||||
),
|
||||
("first-account", "etag", "other-version".into()),
|
||||
] {
|
||||
let stored = ModelsCacheEntry {
|
||||
identity: Some(key.into()),
|
||||
etag: Some(etag.into()),
|
||||
client_version: Some(version),
|
||||
..expected.clone()
|
||||
};
|
||||
cache.store(&stored).await.unwrap();
|
||||
cache
|
||||
.refresh_ttl(
|
||||
expected.client_version.as_deref().unwrap(),
|
||||
expected.identity.as_deref().unwrap(),
|
||||
expected.etag.as_deref().unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let actual: ModelsCacheEntry = serde_json::from_slice(
|
||||
&tokio::fs::read(home.path().join(MODEL_CACHE_FILE))
|
||||
.await
|
||||
.unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(actual, stored);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user