mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-01 17:00:21 +08:00
Rename ranked minimal candidate reads
This commit is contained in:
@@ -51,14 +51,14 @@ pub(crate) async fn read_requested_model_rows(
|
||||
Ok(Some((resolved_global_model_name, rows)))
|
||||
}
|
||||
|
||||
pub(crate) async fn read_minimal_candidate_selection(
|
||||
pub(crate) async fn read_ranked_minimal_candidate_selection(
|
||||
state: &(impl MinimalCandidateSelectionRowSource + Sync),
|
||||
api_format: &str,
|
||||
requested_model_name: &str,
|
||||
require_streaming: bool,
|
||||
auth_snapshot: Option<&GatewayAuthApiKeySnapshot>,
|
||||
) -> Result<Vec<SchedulerMinimalCandidateSelectionCandidate>, DataLayerError> {
|
||||
read_minimal_candidate_selection_with_priority_mode(
|
||||
read_ranked_minimal_candidate_selection_with_priority_mode(
|
||||
state,
|
||||
api_format,
|
||||
requested_model_name,
|
||||
@@ -69,7 +69,7 @@ pub(crate) async fn read_minimal_candidate_selection(
|
||||
.await
|
||||
}
|
||||
|
||||
pub(crate) async fn read_minimal_candidate_selection_with_priority_mode(
|
||||
pub(crate) async fn read_ranked_minimal_candidate_selection_with_priority_mode(
|
||||
state: &(impl MinimalCandidateSelectionRowSource + Sync),
|
||||
api_format: &str,
|
||||
requested_model_name: &str,
|
||||
@@ -77,7 +77,7 @@ pub(crate) async fn read_minimal_candidate_selection_with_priority_mode(
|
||||
auth_snapshot: Option<&GatewayAuthApiKeySnapshot>,
|
||||
priority_mode: SchedulerPriorityMode,
|
||||
) -> Result<Vec<SchedulerMinimalCandidateSelectionCandidate>, DataLayerError> {
|
||||
read_minimal_candidate_selection_with_priority_mode_and_affinity_key(
|
||||
read_ranked_minimal_candidate_selection_with_priority_mode_and_affinity_key(
|
||||
state,
|
||||
api_format,
|
||||
requested_model_name,
|
||||
@@ -89,7 +89,7 @@ pub(crate) async fn read_minimal_candidate_selection_with_priority_mode(
|
||||
.await
|
||||
}
|
||||
|
||||
pub(crate) async fn read_minimal_candidate_selection_with_priority_mode_and_required_capabilities(
|
||||
pub(crate) async fn read_ranked_minimal_candidate_selection_with_priority_mode_and_required_capabilities(
|
||||
state: &(impl MinimalCandidateSelectionRowSource + Sync),
|
||||
api_format: &str,
|
||||
requested_model_name: &str,
|
||||
@@ -98,7 +98,7 @@ pub(crate) async fn read_minimal_candidate_selection_with_priority_mode_and_requ
|
||||
priority_mode: SchedulerPriorityMode,
|
||||
required_capabilities: Option<&serde_json::Value>,
|
||||
) -> Result<Vec<SchedulerMinimalCandidateSelectionCandidate>, DataLayerError> {
|
||||
read_minimal_candidate_selection_with_priority_mode_and_affinity_key_and_required_capabilities(
|
||||
read_ranked_minimal_candidate_selection_with_priority_mode_and_affinity_key_and_required_capabilities(
|
||||
state,
|
||||
api_format,
|
||||
requested_model_name,
|
||||
@@ -111,7 +111,7 @@ pub(crate) async fn read_minimal_candidate_selection_with_priority_mode_and_requ
|
||||
.await
|
||||
}
|
||||
|
||||
pub(crate) async fn read_minimal_candidate_selection_with_priority_mode_and_affinity_key(
|
||||
pub(crate) async fn read_ranked_minimal_candidate_selection_with_priority_mode_and_affinity_key(
|
||||
state: &(impl MinimalCandidateSelectionRowSource + Sync),
|
||||
api_format: &str,
|
||||
requested_model_name: &str,
|
||||
@@ -120,7 +120,7 @@ pub(crate) async fn read_minimal_candidate_selection_with_priority_mode_and_affi
|
||||
priority_mode: SchedulerPriorityMode,
|
||||
affinity_key: Option<&str>,
|
||||
) -> Result<Vec<SchedulerMinimalCandidateSelectionCandidate>, DataLayerError> {
|
||||
read_minimal_candidate_selection_with_priority_mode_and_affinity_key_and_required_capabilities(
|
||||
read_ranked_minimal_candidate_selection_with_priority_mode_and_affinity_key_and_required_capabilities(
|
||||
state,
|
||||
api_format,
|
||||
requested_model_name,
|
||||
@@ -133,7 +133,7 @@ pub(crate) async fn read_minimal_candidate_selection_with_priority_mode_and_affi
|
||||
.await
|
||||
}
|
||||
|
||||
pub(crate) async fn read_minimal_candidate_selection_with_priority_mode_and_affinity_key_and_required_capabilities(
|
||||
pub(crate) async fn read_ranked_minimal_candidate_selection_with_priority_mode_and_affinity_key_and_required_capabilities(
|
||||
state: &(impl MinimalCandidateSelectionRowSource + Sync),
|
||||
api_format: &str,
|
||||
requested_model_name: &str,
|
||||
|
||||
@@ -14,7 +14,7 @@ use aether_scheduler_core::SchedulerMinimalCandidateSelectionCandidate;
|
||||
use crate::cache::SchedulerAffinityTarget;
|
||||
use crate::data::auth::GatewayAuthApiKeySnapshot;
|
||||
use crate::data::candidate_selection::{
|
||||
read_minimal_candidate_selection, MinimalCandidateSelectionRowSource,
|
||||
read_ranked_minimal_candidate_selection, MinimalCandidateSelectionRowSource,
|
||||
};
|
||||
use crate::data::GatewayDataState;
|
||||
use crate::{AppState, GatewayError};
|
||||
@@ -86,7 +86,7 @@ async fn same_priority_candidates_are_distributed_by_affinity_key() {
|
||||
let state = GatewayDataState::with_candidate_selection_and_quota_for_tests(candidates, quotas);
|
||||
let auth_snapshot = sample_auth_snapshot("affinity-key-1");
|
||||
|
||||
let selection = read_minimal_candidate_selection(
|
||||
let selection = read_ranked_minimal_candidate_selection(
|
||||
&state,
|
||||
"openai:chat",
|
||||
"gpt-4.1",
|
||||
|
||||
@@ -7,7 +7,7 @@ use aether_scheduler_core::{
|
||||
resolve_requested_global_model_name, SchedulerMinimalCandidateSelectionCandidate,
|
||||
};
|
||||
|
||||
use crate::data::candidate_selection::read_minimal_candidate_selection;
|
||||
use crate::data::candidate_selection::read_ranked_minimal_candidate_selection;
|
||||
use crate::data::GatewayDataState;
|
||||
|
||||
use super::super::{
|
||||
@@ -119,7 +119,7 @@ fn scheduler_candidate_is_serializable() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn read_minimal_candidate_selection_resolves_provider_model_alias() {
|
||||
async fn read_ranked_minimal_candidate_selection_resolves_provider_model_alias() {
|
||||
let mut row = sample_row();
|
||||
row.global_model_name = "gpt-5".to_string();
|
||||
row.model_provider_model_name = "gpt-5.2".to_string();
|
||||
@@ -135,9 +135,10 @@ async fn read_minimal_candidate_selection_resolves_provider_model_alias() {
|
||||
let quotas = Arc::new(InMemoryProviderQuotaRepository::seed(vec![]));
|
||||
let state = GatewayDataState::with_candidate_selection_and_quota_for_tests(candidates, quotas);
|
||||
|
||||
let selection = read_minimal_candidate_selection(&state, "openai:chat", "gpt-5.2", false, None)
|
||||
.await
|
||||
.expect("selection should succeed");
|
||||
let selection =
|
||||
read_ranked_minimal_candidate_selection(&state, "openai:chat", "gpt-5.2", false, None)
|
||||
.await
|
||||
.expect("selection should succeed");
|
||||
|
||||
assert_eq!(selection.len(), 1);
|
||||
assert_eq!(selection[0].global_model_name, "gpt-5");
|
||||
@@ -145,7 +146,7 @@ async fn read_minimal_candidate_selection_resolves_provider_model_alias() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn read_minimal_candidate_selection_keeps_all_rows_supporting_requested_model() {
|
||||
async fn read_ranked_minimal_candidate_selection_keeps_all_rows_supporting_requested_model() {
|
||||
let mut exact = sample_row();
|
||||
exact.provider_id = "provider-exact".to_string();
|
||||
exact.endpoint_id = "endpoint-exact".to_string();
|
||||
@@ -177,9 +178,10 @@ async fn read_minimal_candidate_selection_keeps_all_rows_supporting_requested_mo
|
||||
let quotas = Arc::new(InMemoryProviderQuotaRepository::seed(vec![]));
|
||||
let state = GatewayDataState::with_candidate_selection_and_quota_for_tests(candidates, quotas);
|
||||
|
||||
let selection = read_minimal_candidate_selection(&state, "openai:chat", "gpt-5", false, None)
|
||||
.await
|
||||
.expect("selection should succeed");
|
||||
let selection =
|
||||
read_ranked_minimal_candidate_selection(&state, "openai:chat", "gpt-5", false, None)
|
||||
.await
|
||||
.expect("selection should succeed");
|
||||
|
||||
let provider_ids = selection
|
||||
.iter()
|
||||
@@ -193,7 +195,7 @@ async fn read_minimal_candidate_selection_keeps_all_rows_supporting_requested_mo
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn read_minimal_candidate_selection_allows_resolved_global_model_in_auth_snapshot() {
|
||||
async fn read_ranked_minimal_candidate_selection_allows_resolved_global_model_in_auth_snapshot() {
|
||||
let mut row = sample_row();
|
||||
row.global_model_name = "gpt-5".to_string();
|
||||
row.global_model_mappings = Some(vec!["gpt-5(?:\\.\\d+)?".to_string()]);
|
||||
@@ -213,7 +215,7 @@ async fn read_minimal_candidate_selection_allows_resolved_global_model_in_auth_s
|
||||
auth_snapshot.user_allowed_models = Some(vec!["gpt-5".to_string()]);
|
||||
auth_snapshot.api_key_allowed_models = Some(vec!["gpt-5".to_string()]);
|
||||
|
||||
let selection = read_minimal_candidate_selection(
|
||||
let selection = read_ranked_minimal_candidate_selection(
|
||||
&state,
|
||||
"openai:chat",
|
||||
"gpt-5.2",
|
||||
|
||||
@@ -169,7 +169,7 @@ fn scheduler_candidate_runtime_paths_depend_on_scheduler_core_and_state_trait()
|
||||
"provider_key_rpm_allows_request_since",
|
||||
"PROVIDER_KEY_RPM_WINDOW_SECS",
|
||||
"SchedulerMinimalCandidateSelectionCandidate",
|
||||
"read_minimal_candidate_selection",
|
||||
"read_ranked_minimal_candidate_selection",
|
||||
"read_cached_scheduler_affinity_target",
|
||||
"list_selectable_candidates",
|
||||
"list_selectable_candidates_for_required_capability_without_requested_model",
|
||||
@@ -187,7 +187,7 @@ fn scheduler_candidate_runtime_paths_depend_on_scheduler_core_and_state_trait()
|
||||
);
|
||||
assert!(
|
||||
!candidate_mod.contains("build_ranked_minimal_candidate_selection"),
|
||||
"candidate/mod.rs should not own the core minimal candidate builder anymore"
|
||||
"candidate/mod.rs should not own the core ranked minimal candidate builder anymore"
|
||||
);
|
||||
assert!(
|
||||
!candidate_mod.contains("collect_global_model_names_for_required_capability"),
|
||||
@@ -206,7 +206,7 @@ fn scheduler_candidate_runtime_paths_depend_on_scheduler_core_and_state_trait()
|
||||
"candidate/mod.rs should not own the minimal candidate DTO"
|
||||
);
|
||||
for pattern in [
|
||||
"pub(crate) async fn read_minimal_candidate_selection(",
|
||||
"pub(crate) async fn read_ranked_minimal_candidate_selection(",
|
||||
"pub(crate) async fn select_minimal_candidate(",
|
||||
"pub(crate) fn read_cached_scheduler_affinity_target(",
|
||||
"async fn collect_selectable_candidates(",
|
||||
@@ -539,7 +539,7 @@ fn scheduler_candidate_runtime_paths_depend_on_scheduler_core_and_state_trait()
|
||||
"impl MinimalCandidateSelectionRowSource for GatewayDataState",
|
||||
"impl MinimalCandidateSelectionRowSource for AppState",
|
||||
"impl SchedulerRuntimeState for AppState",
|
||||
"async fn read_minimal_candidate_selection(",
|
||||
"async fn read_ranked_minimal_candidate_selection(",
|
||||
] {
|
||||
assert!(
|
||||
!candidate_state.contains(pattern),
|
||||
@@ -558,8 +558,9 @@ fn scheduler_candidate_runtime_paths_depend_on_scheduler_core_and_state_trait()
|
||||
"data/candidate_selection.rs should host requested-model row lookup"
|
||||
);
|
||||
assert!(
|
||||
candidate_selection.contains("pub(crate) async fn read_minimal_candidate_selection("),
|
||||
"data/candidate_selection.rs should host minimal candidate selection builder"
|
||||
candidate_selection
|
||||
.contains("pub(crate) async fn read_ranked_minimal_candidate_selection("),
|
||||
"data/candidate_selection.rs should host ranked minimal candidate selection builder"
|
||||
);
|
||||
assert!(
|
||||
candidate_selection
|
||||
@@ -572,7 +573,7 @@ fn scheduler_candidate_runtime_paths_depend_on_scheduler_core_and_state_trait()
|
||||
);
|
||||
assert!(
|
||||
candidate_selection.contains("build_ranked_minimal_candidate_selection"),
|
||||
"data/candidate_selection.rs should depend on core minimal candidate builder"
|
||||
"data/candidate_selection.rs should depend on core ranked minimal candidate builder"
|
||||
);
|
||||
assert!(
|
||||
candidate_selection.contains("collect_global_model_names_for_required_capability"),
|
||||
@@ -653,7 +654,7 @@ fn scheduler_candidate_runtime_paths_depend_on_scheduler_core_and_state_trait()
|
||||
"state/integrations.rs should host SchedulerRuntimeState for AppState"
|
||||
);
|
||||
assert!(
|
||||
!state_integrations.contains("async fn read_minimal_candidate_selection("),
|
||||
!state_integrations.contains("async fn read_ranked_minimal_candidate_selection("),
|
||||
"state/integrations.rs should not re-host scheduler minimal candidate bridge anymore"
|
||||
);
|
||||
|
||||
@@ -806,15 +807,15 @@ fn gateway_data_state_does_not_depend_on_scheduler_candidate_selection() {
|
||||
read_workspace_file("apps/aether-gateway/src/state/runtime/auth/api_keys.rs");
|
||||
|
||||
assert!(
|
||||
!state_mod.contains("read_minimal_candidate_selection"),
|
||||
!state_mod.contains("read_ranked_minimal_candidate_selection"),
|
||||
"data/state/mod.rs should not import scheduler candidate selection entrypoints"
|
||||
);
|
||||
assert!(
|
||||
!state_runtime.contains("pub(crate) async fn read_minimal_candidate_selection("),
|
||||
!state_runtime.contains("pub(crate) async fn read_ranked_minimal_candidate_selection("),
|
||||
"data/state/runtime.rs should not own scheduler minimal candidate derived read"
|
||||
);
|
||||
assert!(
|
||||
!auth_api_keys.contains("read_minimal_candidate_selection("),
|
||||
!auth_api_keys.contains("read_ranked_minimal_candidate_selection("),
|
||||
"state/runtime/auth/api_keys.rs should not keep scheduler minimal candidate wrapper anymore"
|
||||
);
|
||||
for pattern in [
|
||||
|
||||
Reference in New Issue
Block a user