fix scheduler affinity candidate selection

This commit is contained in:
fawney19
2026-04-30 16:27:24 +08:00
parent 558abfcfa3
commit 33aa70c22b
24 changed files with 1715 additions and 104 deletions

View File

@@ -25,6 +25,30 @@ use aether_data_contracts::repository::provider_catalog::{
};
use sha2::{Digest, Sha256};
const KIRO_CLAUDE_CLI_FINALIZE_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
fn run_kiro_claude_cli_finalize_test<F, Fut>(test_name: &'static str, make_future: F)
where
F: FnOnce() -> Fut + Send + 'static,
Fut: std::future::Future<Output = ()> + 'static,
{
let handle = std::thread::Builder::new()
.name(test_name.to_string())
.stack_size(KIRO_CLAUDE_CLI_FINALIZE_TEST_STACK_BYTES)
.spawn(move || {
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("test runtime should build");
runtime.block_on(make_future());
})
.expect("kiro claude cli finalize test thread should spawn");
if let Err(payload) = handle.join() {
std::panic::resume_unwind(payload);
}
}
#[tokio::test]
async fn gateway_executes_openai_responses_sync_upstream_stream_via_local_finalize_response() {
use base64::Engine as _;
@@ -474,8 +498,15 @@ async fn gateway_executes_openai_responses_sync_upstream_stream_via_local_finali
upstream_handle.abort();
}
#[tokio::test]
async fn gateway_executes_kiro_claude_cli_sync_upstream_stream_via_local_finalize_response() {
#[test]
fn gateway_executes_kiro_claude_cli_sync_upstream_stream_via_local_finalize_response() {
run_kiro_claude_cli_finalize_test(
"gateway_executes_kiro_claude_cli_sync_upstream_stream_via_local_finalize_response",
gateway_executes_kiro_claude_cli_sync_upstream_stream_via_local_finalize_response_impl,
);
}
async fn gateway_executes_kiro_claude_cli_sync_upstream_stream_via_local_finalize_response_impl() {
use base64::Engine as _;
fn crc32(data: &[u8]) -> u32 {

View File

@@ -23,8 +23,39 @@ use aether_data_contracts::repository::provider_catalog::{
};
use sha2::{Digest, Sha256};
#[tokio::test]
async fn gateway_executes_claude_chat_sync_same_format_via_local_finalize_response() {
const CLAUDE_PROVIDER_FINALIZE_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
fn run_claude_provider_finalize_test<F, Fut>(test_name: &'static str, make_future: F)
where
F: FnOnce() -> Fut + Send + 'static,
Fut: std::future::Future<Output = ()> + 'static,
{
let handle = std::thread::Builder::new()
.name(test_name.to_string())
.stack_size(CLAUDE_PROVIDER_FINALIZE_TEST_STACK_BYTES)
.spawn(move || {
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("test runtime should build");
runtime.block_on(make_future());
})
.expect("claude provider finalize test thread should spawn");
if let Err(payload) = handle.join() {
std::panic::resume_unwind(payload);
}
}
#[test]
fn gateway_executes_claude_chat_sync_same_format_via_local_finalize_response() {
run_claude_provider_finalize_test(
"gateway_executes_claude_chat_sync_same_format_via_local_finalize_response",
gateway_executes_claude_chat_sync_same_format_via_local_finalize_response_impl,
);
}
async fn gateway_executes_claude_chat_sync_same_format_via_local_finalize_response_impl() {
#[derive(Debug, Clone)]
struct SeenRemoteExecutionRuntimeRequest {
trace_id: String,
@@ -468,8 +499,15 @@ async fn gateway_executes_claude_chat_sync_same_format_via_local_finalize_respon
upstream_handle.abort();
}
#[tokio::test]
async fn gateway_executes_claude_chat_sync_upstream_stream_via_local_finalize_response() {
#[test]
fn gateway_executes_claude_chat_sync_upstream_stream_via_local_finalize_response() {
run_claude_provider_finalize_test(
"gateway_executes_claude_chat_sync_upstream_stream_via_local_finalize_response",
gateway_executes_claude_chat_sync_upstream_stream_via_local_finalize_response_impl,
);
}
async fn gateway_executes_claude_chat_sync_upstream_stream_via_local_finalize_response_impl() {
use base64::Engine as _;
#[derive(Debug, Clone)]
@@ -921,8 +959,15 @@ async fn gateway_executes_claude_chat_sync_upstream_stream_via_local_finalize_re
upstream_handle.abort();
}
#[tokio::test]
async fn gateway_executes_claude_cli_sync_upstream_stream_via_local_finalize_response() {
#[test]
fn gateway_executes_claude_cli_sync_upstream_stream_via_local_finalize_response() {
run_claude_provider_finalize_test(
"gateway_executes_claude_cli_sync_upstream_stream_via_local_finalize_response",
gateway_executes_claude_cli_sync_upstream_stream_via_local_finalize_response_impl,
);
}
async fn gateway_executes_claude_cli_sync_upstream_stream_via_local_finalize_response_impl() {
use base64::Engine as _;
#[derive(Debug, Clone)]

View File

@@ -23,8 +23,39 @@ use aether_data_contracts::repository::provider_catalog::{
};
use sha2::{Digest, Sha256};
#[tokio::test]
async fn gateway_executes_gemini_chat_sync_same_format_via_local_finalize_response() {
const GEMINI_PROVIDER_FINALIZE_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
fn run_gemini_provider_finalize_test<F, Fut>(test_name: &'static str, make_future: F)
where
F: FnOnce() -> Fut + Send + 'static,
Fut: std::future::Future<Output = ()> + 'static,
{
let handle = std::thread::Builder::new()
.name(test_name.to_string())
.stack_size(GEMINI_PROVIDER_FINALIZE_TEST_STACK_BYTES)
.spawn(move || {
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("test runtime should build");
runtime.block_on(make_future());
})
.expect("gemini provider finalize test thread should spawn");
if let Err(payload) = handle.join() {
std::panic::resume_unwind(payload);
}
}
#[test]
fn gateway_executes_gemini_chat_sync_same_format_via_local_finalize_response() {
run_gemini_provider_finalize_test(
"gateway_executes_gemini_chat_sync_same_format_via_local_finalize_response",
gateway_executes_gemini_chat_sync_same_format_via_local_finalize_response_impl,
);
}
async fn gateway_executes_gemini_chat_sync_same_format_via_local_finalize_response_impl() {
#[derive(Debug, Clone)]
struct SeenRemoteExecutionRuntimeRequest {
trace_id: String,
@@ -517,8 +548,15 @@ async fn gateway_executes_gemini_chat_sync_same_format_via_local_finalize_respon
upstream_handle.abort();
}
#[tokio::test]
async fn gateway_executes_gemini_chat_sync_upstream_stream_via_local_finalize_response() {
#[test]
fn gateway_executes_gemini_chat_sync_upstream_stream_via_local_finalize_response() {
run_gemini_provider_finalize_test(
"gateway_executes_gemini_chat_sync_upstream_stream_via_local_finalize_response",
gateway_executes_gemini_chat_sync_upstream_stream_via_local_finalize_response_impl,
);
}
async fn gateway_executes_gemini_chat_sync_upstream_stream_via_local_finalize_response_impl() {
use base64::Engine as _;
#[derive(Debug, Clone)]
@@ -1003,8 +1041,15 @@ async fn gateway_executes_gemini_chat_sync_upstream_stream_via_local_finalize_re
upstream_handle.abort();
}
#[tokio::test]
async fn gateway_executes_gemini_cli_sync_upstream_stream_via_local_finalize_response() {
#[test]
fn gateway_executes_gemini_cli_sync_upstream_stream_via_local_finalize_response() {
run_gemini_provider_finalize_test(
"gateway_executes_gemini_cli_sync_upstream_stream_via_local_finalize_response",
gateway_executes_gemini_cli_sync_upstream_stream_via_local_finalize_response_impl,
);
}
async fn gateway_executes_gemini_cli_sync_upstream_stream_via_local_finalize_response_impl() {
use base64::Engine as _;
#[derive(Debug, Clone)]
@@ -1491,9 +1536,16 @@ async fn gateway_executes_gemini_cli_sync_upstream_stream_via_local_finalize_res
upstream_handle.abort();
}
#[tokio::test]
async fn gateway_executes_antigravity_gemini_cli_sync_upstream_stream_via_local_finalize_response()
{
#[test]
fn gateway_executes_antigravity_gemini_cli_sync_upstream_stream_via_local_finalize_response() {
run_gemini_provider_finalize_test(
"gateway_executes_antigravity_gemini_cli_sync_upstream_stream_via_local_finalize_response",
gateway_executes_antigravity_gemini_cli_sync_upstream_stream_via_local_finalize_response_impl,
);
}
async fn gateway_executes_antigravity_gemini_cli_sync_upstream_stream_via_local_finalize_response_impl(
) {
use base64::Engine as _;
#[derive(Debug, Clone)]

View File

@@ -9,8 +9,40 @@ use super::{
DEVELOPMENT_ENCRYPTION_KEY, TRACE_ID_HEADER,
};
#[tokio::test]
async fn gateway_executes_claude_code_cli_sync_via_local_decision_gate_with_local_sync_decision() {
const CLAUDE_CODE_CLI_SYNC_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
fn run_claude_code_cli_sync_test<F, Fut>(test_name: &'static str, make_future: F)
where
F: FnOnce() -> Fut + Send + 'static,
Fut: std::future::Future<Output = ()> + 'static,
{
let handle = std::thread::Builder::new()
.name(test_name.to_string())
.stack_size(CLAUDE_CODE_CLI_SYNC_TEST_STACK_BYTES)
.spawn(move || {
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("test runtime should build");
runtime.block_on(make_future());
})
.expect("claude code cli sync test thread should spawn");
if let Err(payload) = handle.join() {
std::panic::resume_unwind(payload);
}
}
#[test]
fn gateway_executes_claude_code_cli_sync_via_local_decision_gate_with_local_sync_decision() {
run_claude_code_cli_sync_test(
"gateway_executes_claude_code_cli_sync_via_local_decision_gate_with_local_sync_decision",
gateway_executes_claude_code_cli_sync_via_local_decision_gate_with_local_sync_decision_impl,
);
}
async fn gateway_executes_claude_code_cli_sync_via_local_decision_gate_with_local_sync_decision_impl(
) {
#[derive(Debug, Clone)]
struct SeenExecutionRuntimeSyncRequest {
trace_id: String,

View File

@@ -11,8 +11,39 @@ use super::{
TRACE_ID_HEADER,
};
#[tokio::test]
async fn gateway_executes_claude_chat_sync_via_local_decision_gate_with_local_sync_decision() {
const CLAUDE_CHAT_SYNC_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
fn run_claude_chat_sync_test<F, Fut>(test_name: &'static str, make_future: F)
where
F: FnOnce() -> Fut + Send + 'static,
Fut: std::future::Future<Output = ()> + 'static,
{
let handle = std::thread::Builder::new()
.name(test_name.to_string())
.stack_size(CLAUDE_CHAT_SYNC_TEST_STACK_BYTES)
.spawn(move || {
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("test runtime should build");
runtime.block_on(make_future());
})
.expect("claude chat sync test thread should spawn");
if let Err(payload) = handle.join() {
std::panic::resume_unwind(payload);
}
}
#[test]
fn gateway_executes_claude_chat_sync_via_local_decision_gate_with_local_sync_decision() {
run_claude_chat_sync_test(
"gateway_executes_claude_chat_sync_via_local_decision_gate_with_local_sync_decision",
gateway_executes_claude_chat_sync_via_local_decision_gate_with_local_sync_decision_impl,
);
}
async fn gateway_executes_claude_chat_sync_via_local_decision_gate_with_local_sync_decision_impl() {
#[derive(Debug, Clone)]
struct SeenExecutionRuntimeSyncRequest {
trace_id: String,
@@ -452,8 +483,15 @@ async fn gateway_executes_claude_chat_sync_via_local_decision_gate_with_local_sy
upstream_handle.abort();
}
#[tokio::test]
async fn gateway_surfaces_candidate_list_empty_reason_for_claude_chat_runtime_miss() {
#[test]
fn gateway_surfaces_candidate_list_empty_reason_for_claude_chat_runtime_miss() {
run_claude_chat_sync_test(
"gateway_surfaces_candidate_list_empty_reason_for_claude_chat_runtime_miss",
gateway_surfaces_candidate_list_empty_reason_for_claude_chat_runtime_miss_impl,
);
}
async fn gateway_surfaces_candidate_list_empty_reason_for_claude_chat_runtime_miss_impl() {
fn hash_api_key(value: &str) -> String {
let mut hasher = Sha256::new();
hasher.update(value.as_bytes());
@@ -577,8 +615,15 @@ async fn gateway_surfaces_candidate_list_empty_reason_for_claude_chat_runtime_mi
upstream_handle.abort();
}
#[tokio::test]
async fn gateway_returns_claude_chat_error_for_local_sync_failure() {
#[test]
fn gateway_returns_claude_chat_error_for_local_sync_failure() {
run_claude_chat_sync_test(
"gateway_returns_claude_chat_error_for_local_sync_failure",
gateway_returns_claude_chat_error_for_local_sync_failure_impl,
);
}
async fn gateway_returns_claude_chat_error_for_local_sync_failure_impl() {
fn hash_api_key(value: &str) -> String {
let mut hasher = Sha256::new();
hasher.update(value.as_bytes());

View File

@@ -11,8 +11,39 @@ use super::{
TRACE_ID_HEADER,
};
#[tokio::test]
async fn gateway_executes_claude_cli_sync_via_local_decision_gate_with_local_sync_decision() {
const CLAUDE_CLI_SYNC_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
fn run_claude_cli_sync_test<F, Fut>(test_name: &'static str, make_future: F)
where
F: FnOnce() -> Fut + Send + 'static,
Fut: std::future::Future<Output = ()> + 'static,
{
let handle = std::thread::Builder::new()
.name(test_name.to_string())
.stack_size(CLAUDE_CLI_SYNC_TEST_STACK_BYTES)
.spawn(move || {
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("test runtime should build");
runtime.block_on(make_future());
})
.expect("claude cli sync test thread should spawn");
if let Err(payload) = handle.join() {
std::panic::resume_unwind(payload);
}
}
#[test]
fn gateway_executes_claude_cli_sync_via_local_decision_gate_with_local_sync_decision() {
run_claude_cli_sync_test(
"gateway_executes_claude_cli_sync_via_local_decision_gate_with_local_sync_decision",
gateway_executes_claude_cli_sync_via_local_decision_gate_with_local_sync_decision_impl,
);
}
async fn gateway_executes_claude_cli_sync_via_local_decision_gate_with_local_sync_decision_impl() {
#[derive(Debug, Clone)]
struct SeenExecutionRuntimeSyncRequest {
trace_id: String,
@@ -460,8 +491,15 @@ async fn gateway_executes_claude_cli_sync_via_local_decision_gate_with_local_syn
upstream_handle.abort();
}
#[tokio::test]
async fn gateway_returns_claude_cli_error_for_local_sync_failure() {
#[test]
fn gateway_returns_claude_cli_error_for_local_sync_failure() {
run_claude_cli_sync_test(
"gateway_returns_claude_cli_error_for_local_sync_failure",
gateway_returns_claude_cli_error_for_local_sync_failure_impl,
);
}
async fn gateway_returns_claude_cli_error_for_local_sync_failure_impl() {
fn hash_api_key(value: &str) -> String {
let mut hasher = Sha256::new();
hasher.update(value.as_bytes());
@@ -734,8 +772,16 @@ async fn gateway_returns_claude_cli_error_for_local_sync_failure() {
upstream_handle.abort();
}
#[tokio::test]
async fn gateway_marks_claude_cli_cross_format_runtime_miss_when_format_conversion_is_disabled() {
#[test]
fn gateway_marks_claude_cli_cross_format_runtime_miss_when_format_conversion_is_disabled() {
run_claude_cli_sync_test(
"gateway_marks_claude_cli_cross_format_runtime_miss_when_format_conversion_is_disabled",
gateway_marks_claude_cli_cross_format_runtime_miss_when_format_conversion_is_disabled_impl,
);
}
async fn gateway_marks_claude_cli_cross_format_runtime_miss_when_format_conversion_is_disabled_impl(
) {
fn hash_api_key(value: &str) -> String {
let mut hasher = Sha256::new();
hasher.update(value.as_bytes());

View File

@@ -10,8 +10,39 @@ use super::{
TRACE_ID_HEADER,
};
#[tokio::test]
async fn gateway_executes_gemini_cli_sync_via_local_decision_gate_with_local_sync_decision() {
const GEMINI_CLI_SYNC_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
fn run_gemini_cli_sync_test<F, Fut>(test_name: &'static str, make_future: F)
where
F: FnOnce() -> Fut + Send + 'static,
Fut: std::future::Future<Output = ()> + 'static,
{
let handle = std::thread::Builder::new()
.name(test_name.to_string())
.stack_size(GEMINI_CLI_SYNC_TEST_STACK_BYTES)
.spawn(move || {
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("test runtime should build");
runtime.block_on(make_future());
})
.expect("gemini cli sync test thread should spawn");
if let Err(payload) = handle.join() {
std::panic::resume_unwind(payload);
}
}
#[test]
fn gateway_executes_gemini_cli_sync_via_local_decision_gate_with_local_sync_decision() {
run_gemini_cli_sync_test(
"gateway_executes_gemini_cli_sync_via_local_decision_gate_with_local_sync_decision",
gateway_executes_gemini_cli_sync_via_local_decision_gate_with_local_sync_decision_impl,
);
}
async fn gateway_executes_gemini_cli_sync_via_local_decision_gate_with_local_sync_decision_impl() {
#[derive(Debug, Clone)]
struct SeenExecutionRuntimeSyncRequest {
trace_id: String,
@@ -445,8 +476,15 @@ async fn gateway_executes_gemini_cli_sync_via_local_decision_gate_with_local_syn
upstream_handle.abort();
}
#[tokio::test]
async fn gateway_returns_gemini_cli_error_for_local_sync_failure() {
#[test]
fn gateway_returns_gemini_cli_error_for_local_sync_failure() {
run_gemini_cli_sync_test(
"gateway_returns_gemini_cli_error_for_local_sync_failure",
gateway_returns_gemini_cli_error_for_local_sync_failure_impl,
);
}
async fn gateway_returns_gemini_cli_error_for_local_sync_failure_impl() {
fn hash_api_key(value: &str) -> String {
let mut hasher = Sha256::new();
hasher.update(value.as_bytes());
@@ -716,8 +754,15 @@ async fn gateway_returns_gemini_cli_error_for_local_sync_failure() {
upstream_handle.abort();
}
#[tokio::test]
async fn gateway_executes_gemini_cli_sync_via_local_decision_gate_after_oauth_refresh() {
#[test]
fn gateway_executes_gemini_cli_sync_via_local_decision_gate_after_oauth_refresh() {
run_gemini_cli_sync_test(
"gateway_executes_gemini_cli_sync_via_local_decision_gate_after_oauth_refresh",
gateway_executes_gemini_cli_sync_via_local_decision_gate_after_oauth_refresh_impl,
);
}
async fn gateway_executes_gemini_cli_sync_via_local_decision_gate_after_oauth_refresh_impl() {
#[derive(Debug, Clone)]
struct SeenExecutionRuntimeSyncRequest {
trace_id: String,
@@ -1220,8 +1265,15 @@ async fn gateway_executes_gemini_cli_sync_via_local_decision_gate_after_oauth_re
upstream_handle.abort();
}
#[tokio::test]
async fn gateway_executes_vertex_ai_gemini_cli_sync_via_local_decision_gate_with_local_sync_decision(
#[test]
fn gateway_executes_vertex_ai_gemini_cli_sync_via_local_decision_gate_with_local_sync_decision() {
run_gemini_cli_sync_test(
"gateway_executes_vertex_ai_gemini_cli_sync_via_local_decision_gate_with_local_sync_decision",
gateway_executes_vertex_ai_gemini_cli_sync_via_local_decision_gate_with_local_sync_decision_impl,
);
}
async fn gateway_executes_vertex_ai_gemini_cli_sync_via_local_decision_gate_with_local_sync_decision_impl(
) {
#[derive(Debug, Clone)]
struct SeenExecutionRuntimeSyncRequest {
@@ -1642,9 +1694,16 @@ async fn gateway_executes_vertex_ai_gemini_cli_sync_via_local_decision_gate_with
upstream_handle.abort();
}
#[tokio::test]
async fn gateway_executes_antigravity_gemini_cli_sync_via_local_decision_gate_after_oauth_refresh()
{
#[test]
fn gateway_executes_antigravity_gemini_cli_sync_via_local_decision_gate_after_oauth_refresh() {
run_gemini_cli_sync_test(
"gateway_executes_antigravity_gemini_cli_sync_via_local_decision_gate_after_oauth_refresh",
gateway_executes_antigravity_gemini_cli_sync_via_local_decision_gate_after_oauth_refresh_impl,
);
}
async fn gateway_executes_antigravity_gemini_cli_sync_via_local_decision_gate_after_oauth_refresh_impl(
) {
use base64::Engine as _;
#[derive(Debug, Clone)]

View File

@@ -10,8 +10,39 @@ use super::{
TRACE_ID_HEADER,
};
#[tokio::test]
async fn gateway_executes_gemini_chat_sync_via_local_decision_gate_with_local_sync_decision() {
const GEMINI_CHAT_SYNC_TEST_STACK_BYTES: usize = 16 * 1024 * 1024;
fn run_gemini_chat_sync_test<F, Fut>(test_name: &'static str, make_future: F)
where
F: FnOnce() -> Fut + Send + 'static,
Fut: std::future::Future<Output = ()> + 'static,
{
let handle = std::thread::Builder::new()
.name(test_name.to_string())
.stack_size(GEMINI_CHAT_SYNC_TEST_STACK_BYTES)
.spawn(move || {
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("test runtime should build");
runtime.block_on(make_future());
})
.expect("gemini chat sync test thread should spawn");
if let Err(payload) = handle.join() {
std::panic::resume_unwind(payload);
}
}
#[test]
fn gateway_executes_gemini_chat_sync_via_local_decision_gate_with_local_sync_decision() {
run_gemini_chat_sync_test(
"gateway_executes_gemini_chat_sync_via_local_decision_gate_with_local_sync_decision",
gateway_executes_gemini_chat_sync_via_local_decision_gate_with_local_sync_decision_impl,
);
}
async fn gateway_executes_gemini_chat_sync_via_local_decision_gate_with_local_sync_decision_impl() {
#[derive(Debug, Clone)]
struct SeenExecutionRuntimeSyncRequest {
trace_id: String,
@@ -435,8 +466,15 @@ async fn gateway_executes_gemini_chat_sync_via_local_decision_gate_with_local_sy
upstream_handle.abort();
}
#[tokio::test]
async fn gateway_returns_gemini_chat_error_for_local_sync_failure() {
#[test]
fn gateway_returns_gemini_chat_error_for_local_sync_failure() {
run_gemini_chat_sync_test(
"gateway_returns_gemini_chat_error_for_local_sync_failure",
gateway_returns_gemini_chat_error_for_local_sync_failure_impl,
);
}
async fn gateway_returns_gemini_chat_error_for_local_sync_failure_impl() {
fn hash_api_key(value: &str) -> String {
let mut hasher = Sha256::new();
hasher.update(value.as_bytes());