mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
refactor ai serving modules and crates
This commit is contained in:
@@ -2,7 +2,7 @@ use super::{
|
||||
any, build_router_with_state, build_state_with_execution_runtime_override, json, start_server,
|
||||
to_bytes, Arc, Body, Json, Mutex, Request, Router, StatusCode, TRACE_ID_HEADER,
|
||||
};
|
||||
use crate::ai_pipeline::CODEX_OPENAI_IMAGE_INTERNAL_MODEL;
|
||||
use crate::ai_serving::CODEX_OPENAI_IMAGE_INTERNAL_MODEL;
|
||||
use aether_crypto::{encrypt_python_fernet_plaintext, DEVELOPMENT_ENCRYPTION_KEY};
|
||||
use aether_data::repository::auth::{
|
||||
InMemoryAuthApiKeySnapshotRepository, StoredAuthApiKeySnapshot,
|
||||
|
||||
@@ -2,7 +2,7 @@ use super::{
|
||||
any, build_router_with_state, build_state_with_execution_runtime_override, json, start_server,
|
||||
to_bytes, Arc, Body, Json, Mutex, Request, Router, StatusCode, TRACE_ID_HEADER,
|
||||
};
|
||||
use crate::ai_pipeline::CODEX_OPENAI_IMAGE_INTERNAL_MODEL;
|
||||
use crate::ai_serving::CODEX_OPENAI_IMAGE_INTERNAL_MODEL;
|
||||
use aether_crypto::{encrypt_python_fernet_plaintext, DEVELOPMENT_ENCRYPTION_KEY};
|
||||
use aether_data::repository::auth::{
|
||||
InMemoryAuthApiKeySnapshotRepository, StoredAuthApiKeySnapshot,
|
||||
|
||||
@@ -580,12 +580,10 @@ fn admin_handlers_expose_real_subdomains_without_facade() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ai_pipeline_external_consumers_use_single_api_facade() {
|
||||
let ai_pipeline_mod = read_workspace_file("apps/aether-gateway/src/ai_pipeline/mod.rs");
|
||||
fn ai_serving_external_consumers_use_single_api_facade() {
|
||||
let ai_serving_mod = read_workspace_file("apps/aether-gateway/src/ai_serving/mod.rs");
|
||||
for pattern in [
|
||||
"mod adaptation;",
|
||||
"mod contracts;",
|
||||
"mod conversion;",
|
||||
"mod finalize;",
|
||||
"mod planner;",
|
||||
"pub(crate) mod transport;",
|
||||
@@ -596,8 +594,8 @@ fn ai_pipeline_external_consumers_use_single_api_facade() {
|
||||
"pub(crate) fn maybe_build_local_sync_finalize_response(",
|
||||
] {
|
||||
assert!(
|
||||
ai_pipeline_mod.contains(pattern),
|
||||
"ai_pipeline/mod.rs should expose only the crate-facing ai_pipeline seam for {pattern}"
|
||||
ai_serving_mod.contains(pattern),
|
||||
"ai_serving/mod.rs should expose only the crate-facing ai_serving seam for {pattern}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -607,14 +605,16 @@ fn ai_pipeline_external_consumers_use_single_api_facade() {
|
||||
"pub(super) mod planner;",
|
||||
"pub(crate) mod adaptation;",
|
||||
"pub(crate) mod contracts;",
|
||||
"mod contracts;",
|
||||
"pub(crate) mod conversion;",
|
||||
"mod conversion;",
|
||||
"pub(crate) mod finalize;",
|
||||
"pub(crate) mod planner;",
|
||||
"pub(super) mod api;",
|
||||
] {
|
||||
assert!(
|
||||
!ai_pipeline_mod.contains(forbidden),
|
||||
"ai_pipeline/mod.rs should not expose internal module {forbidden}"
|
||||
!ai_serving_mod.contains(forbidden),
|
||||
"ai_serving/mod.rs should not expose internal module {forbidden}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -628,41 +628,37 @@ fn ai_pipeline_external_consumers_use_single_api_facade() {
|
||||
] {
|
||||
let contents = read_workspace_file(path);
|
||||
assert!(
|
||||
contents.contains("ai_pipeline_api"),
|
||||
"{path} should use the ai_pipeline_api facade"
|
||||
contents.contains("ai_serving::api"),
|
||||
"{path} should use the ai_serving::api facade"
|
||||
);
|
||||
for forbidden in [
|
||||
"crate::ai_pipeline::planner::",
|
||||
"crate::ai_pipeline::contracts::",
|
||||
"crate::ai_pipeline::adaptation::private_envelope",
|
||||
"crate::ai_pipeline::conversion::",
|
||||
"crate::ai_serving::planner::",
|
||||
"crate::ai_serving::contracts::",
|
||||
"crate::ai_serving::adaptation::private_envelope",
|
||||
"crate::ai_serving::conversion::",
|
||||
] {
|
||||
assert!(
|
||||
!contents.contains(forbidden),
|
||||
"{path} should not bypass ai_pipeline_api through {forbidden}"
|
||||
"{path} should not bypass ai_serving::api through {forbidden}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn crate_root_exposes_real_admin_and_ai_pipeline_facades() {
|
||||
fn crate_root_exposes_real_admin_and_ai_serving_facades() {
|
||||
let lib_rs = read_workspace_file("apps/aether-gateway/src/lib.rs");
|
||||
for pattern in ["mod admin_api;", "mod ai_pipeline_api;"] {
|
||||
for pattern in ["mod admin_api;", "mod ai_serving;"] {
|
||||
assert!(
|
||||
lib_rs.contains(pattern),
|
||||
"lib.rs should register crate root facade module {pattern}"
|
||||
);
|
||||
}
|
||||
for forbidden in [
|
||||
"pub(crate) use self::handlers::admin_api;",
|
||||
"pub(crate) use self::ai_pipeline::api as ai_pipeline_api;",
|
||||
] {
|
||||
assert!(
|
||||
!lib_rs.contains(forbidden),
|
||||
"lib.rs should not keep alias-only facade wiring {forbidden}"
|
||||
);
|
||||
}
|
||||
let forbidden = "pub(crate) use self::handlers::admin_api;";
|
||||
assert!(
|
||||
!lib_rs.contains(forbidden),
|
||||
"lib.rs should not keep alias-only facade wiring {forbidden}"
|
||||
);
|
||||
|
||||
let admin_api = read_workspace_file("apps/aether-gateway/src/admin_api.rs");
|
||||
assert!(
|
||||
@@ -684,31 +680,34 @@ fn crate_root_exposes_real_admin_and_ai_pipeline_facades() {
|
||||
"handlers/mod.rs should not keep alias-only admin_api wiring after crate root facade extraction"
|
||||
);
|
||||
|
||||
let ai_pipeline_api = read_workspace_file("apps/aether-gateway/src/ai_pipeline_api.rs");
|
||||
let ai_serving_api_mod = read_workspace_file("apps/aether-gateway/src/ai_serving/api.rs");
|
||||
assert!(
|
||||
ai_pipeline_api.contains("use crate::ai_pipeline::{is_json_request, GatewayControlDecision};"),
|
||||
"ai_pipeline_api.rs should depend on the crate-facing ai_pipeline seam instead of deep internal modules"
|
||||
ai_serving_api_mod.contains("use crate::ai_serving::{is_json_request, GatewayControlDecision};"),
|
||||
"ai_serving/api.rs should depend on the crate-facing ai_serving seam instead of deep internal modules"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gateway_ai_pipeline_api_facade_delegates_pure_ownership_to_pipeline_crate() {
|
||||
let gateway_api = read_workspace_file("apps/aether-gateway/src/ai_pipeline_api.rs");
|
||||
fn gateway_ai_serving_api_module_delegates_pure_ownership_to_surface_crate() {
|
||||
let gateway_api = read_workspace_file("apps/aether-gateway/src/ai_serving/api.rs");
|
||||
assert!(
|
||||
gateway_api.contains("pub(crate) use aether_ai_pipeline::api::{"),
|
||||
"crate root ai_pipeline_api.rs should re-export pure ownership through aether_ai_pipeline::api"
|
||||
gateway_api.contains("pub(crate) use aether_ai_surfaces::api::{"),
|
||||
"ai_serving/api.rs should re-export pure ownership through aether_ai_surfaces::api"
|
||||
);
|
||||
|
||||
let pipeline_crate_api = read_workspace_file("crates/aether-ai-pipeline/src/api.rs");
|
||||
let surface_crate_api = read_workspace_file("crates/aether-ai-surfaces/src/api.rs");
|
||||
for pattern in [
|
||||
"pub use crate::contracts::{",
|
||||
"pub use crate::conversion::{",
|
||||
"pub use aether_ai_formats::{",
|
||||
"pub use aether_ai_formats::conversion::request::{",
|
||||
"pub use aether_ai_formats::conversion::response::{",
|
||||
"pub use crate::finalize::error_body::{",
|
||||
"pub use crate::planner::common::{",
|
||||
"pub use crate::planner::route::{",
|
||||
] {
|
||||
assert!(
|
||||
pipeline_crate_api.contains(pattern),
|
||||
"aether-ai-pipeline/src/api.rs should expose crate facade seam {pattern}"
|
||||
surface_crate_api.contains(pattern),
|
||||
"aether-ai-surfaces/src/api.rs should expose crate facade seam {pattern}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
4793
apps/aether-gateway/src/tests/architecture/ai_serving.rs
Normal file
4793
apps/aether-gateway/src/tests/architecture/ai_serving.rs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -171,7 +171,7 @@ mod admin_provider;
|
||||
mod admin_shared;
|
||||
mod admin_system;
|
||||
mod admin_users;
|
||||
mod ai_pipeline;
|
||||
mod ai_serving;
|
||||
mod runtime_and_security;
|
||||
mod sql_and_data;
|
||||
mod usage;
|
||||
|
||||
@@ -608,7 +608,7 @@ fn scheduler_candidate_runtime_paths_depend_on_scheduler_core_and_state_trait()
|
||||
}
|
||||
|
||||
let planner_candidate_ranking =
|
||||
read_workspace_file("apps/aether-gateway/src/ai_pipeline/planner/candidate_ranking.rs");
|
||||
read_workspace_file("apps/aether-gateway/src/ai_serving/planner/candidate_ranking.rs");
|
||||
assert!(
|
||||
planner_candidate_ranking.contains("use aether_scheduler_core::{")
|
||||
&& planner_candidate_ranking.contains("SchedulerMinimalCandidateSelectionCandidate"),
|
||||
@@ -1302,7 +1302,7 @@ fn hotspot_modules_do_not_log_sensitive_payload_like_fields() {
|
||||
];
|
||||
|
||||
for root in [
|
||||
"src/ai_pipeline",
|
||||
"src/ai_serving",
|
||||
"src/execution_runtime",
|
||||
"src/usage",
|
||||
"src/async_task",
|
||||
@@ -1372,36 +1372,36 @@ fn execution_runtime_video_finalize_paths_depend_on_shared_video_task_core() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ai_pipeline_runtime_kiro_wrapper_is_facade_only() {
|
||||
fn ai_serving_runtime_kiro_wrapper_is_facade_only() {
|
||||
for path in [
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/mod.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/provider_types.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/mod.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/antigravity/mod.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/claude/mod.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/claude_code/mod.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/gemini/mod.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/generic_oauth.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/kiro/mod.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/openai/mod.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/vertex/mod.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/kiro/auth.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/kiro/converter.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/kiro/credentials.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/kiro/headers.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/kiro/policy.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/kiro/refresh.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/kiro/request.rs",
|
||||
"apps/aether-gateway/src/ai_pipeline/runtime/adapters/kiro/url.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/mod.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/provider_types.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/mod.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/antigravity/mod.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/claude/mod.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/claude_code/mod.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/gemini/mod.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/generic_oauth.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/kiro/mod.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/openai/mod.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/vertex/mod.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/kiro/auth.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/kiro/converter.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/kiro/credentials.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/kiro/headers.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/kiro/policy.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/kiro/refresh.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/kiro/request.rs",
|
||||
"apps/aether-gateway/src/ai_serving/runtime/adapters/kiro/url.rs",
|
||||
] {
|
||||
assert!(
|
||||
!workspace_file_exists(path),
|
||||
"{path} should be removed once gateway ai_pipeline runtime adapter ownership is flattened into adaptation/provider_transport facades"
|
||||
"{path} should be removed once gateway ai_serving runtime adapter ownership is flattened into adaptation/provider_transport facades"
|
||||
);
|
||||
}
|
||||
|
||||
let adaptation_mod =
|
||||
read_workspace_file("apps/aether-gateway/src/ai_pipeline/adaptation/mod.rs");
|
||||
read_workspace_file("apps/aether-gateway/src/ai_serving/adaptation/mod.rs");
|
||||
assert!(
|
||||
adaptation_mod.contains("pub(crate) use kiro::KiroToClaudeCliStreamState;"),
|
||||
"adaptation/mod.rs should own KiroToClaudeCliStreamState export after runtime facade removal"
|
||||
|
||||
Reference in New Issue
Block a user