refactor: 大规模模块拆分与重组,新增 aether-admin crate

- 新建独立 aether-admin crate 承载 admin 相关共享契约与纯辅助函数
- 拆分 ai_pipeline 下 kiro/private_envelope/conversion/planner 等大文件为子模块目录
- 重组 admin handlers 各业务域(billing/oauth/provider/system/users 等)为目录结构,移除 shared.rs/builders.rs 等反模式
- 移除 ai_pipeline runtime adapters 旧实现(claude/openai/gemini/kiro/vertex/antigravity 等),改由 provider transport 统一承载
- 移除 control_facade/execution_facade/auth_snapshot_facade 等冗余 facade 层
- 拆分 query/billing 与 query/monitoring 模块、state/runtime/payments 与 security 模块
- 扩展架构测试覆盖 admin_billing/admin_model/admin_users 等新模块
- 删除 docs/architecture/refactor-execution-plan.md 已完成的执行计划文档
This commit is contained in:
fawney19
2026-04-09 00:10:38 +08:00
parent 4fb9882b54
commit 4fc95adfb9
663 changed files with 48471 additions and 40232 deletions
@@ -2,6 +2,87 @@ use std::path::{Path, PathBuf};
use super::*;
#[test]
fn gateway_small_runtime_shims_stay_deleted() {
for path in [
"apps/aether-gateway/src/hooks/audit.rs",
"apps/aether-gateway/src/hooks/shadow.rs",
"apps/aether-gateway/src/auth/runtime.rs",
"apps/aether-gateway/src/auth/trusted.rs",
"apps/aether-gateway/src/usage/runtime.rs",
"apps/aether-gateway/src/usage/config.rs",
"apps/aether-gateway/src/usage/queue.rs",
"apps/aether-gateway/src/usage/event.rs",
"apps/aether-gateway/src/executor/diagnostics.rs",
"apps/aether-gateway/src/executor/reports.rs",
"apps/aether-gateway/src/executor/retries.rs",
"apps/aether-gateway/src/query/billing/mod.rs",
"apps/aether-gateway/src/query/monitoring/mod.rs",
"apps/aether-gateway/src/state/runtime/security/mod.rs",
"apps/aether-gateway/src/state/runtime/payments/mod.rs",
] {
assert!(
!workspace_file_exists(path),
"{path} should stay removed after M6 shim cleanup"
);
}
let hooks_mod = read_workspace_file("apps/aether-gateway/src/hooks/mod.rs");
assert!(
hooks_mod.contains("pub(crate) use crate::audit::record_shadow_result_non_blocking;"),
"hooks/mod.rs should re-export shadow audit directly from crate::audit"
);
assert!(
hooks_mod.contains("pub(crate) use crate::usage::http::{get_request_audit_bundle, get_request_usage_audit};"),
"hooks/mod.rs should re-export request audit helpers directly from usage/http"
);
let auth_mod = read_workspace_file("apps/aether-gateway/src/auth/mod.rs");
for pattern in [
"resolve_execution_runtime_auth_context",
"should_buffer_request_for_local_auth",
"GatewayControlAuthContext",
"request_model_local_rejection",
"trusted_auth_local_rejection",
"GatewayLocalAuthRejection",
] {
assert!(
auth_mod.contains(pattern),
"auth/mod.rs should expose control-owned auth seam {pattern}"
);
}
for forbidden in ["mod runtime;", "mod trusted;"] {
assert!(
!auth_mod.contains(forbidden),
"auth/mod.rs should not keep local shim {forbidden}"
);
}
let usage_mod = read_workspace_file("apps/aether-gateway/src/usage/mod.rs");
assert!(
usage_mod.contains("pub(crate) use aether_usage_runtime::UsageRuntime;"),
"usage/mod.rs should expose UsageRuntime directly from aether_usage_runtime"
);
assert!(
!usage_mod.contains("mod runtime;"),
"usage/mod.rs should not keep a local runtime shim"
);
for forbidden in ["mod config;", "mod queue;", "mod event;"] {
assert!(
!usage_mod.contains(forbidden),
"usage/mod.rs should not keep deleted shim module {forbidden}"
);
}
let executor_mod = read_workspace_file("apps/aether-gateway/src/executor/mod.rs");
for forbidden in ["mod diagnostics;", "mod reports;", "mod retries;"] {
assert!(
!executor_mod.contains(forbidden),
"executor/mod.rs should not keep deleted shim module {forbidden}"
);
}
}
#[test]
fn gateway_request_candidate_trace_type_is_owned_by_aether_data_contracts() {
let gateway_candidates = read_workspace_file("apps/aether-gateway/src/data/candidates.rs");
@@ -1241,3 +1322,40 @@ fn execution_runtime_video_finalize_paths_depend_on_shared_video_task_core() {
"internal gateway finalize path should not own local finalize signature inference"
);
}
#[test]
fn ai_pipeline_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",
] {
assert!(
!workspace_file_exists(path),
"{path} should be removed once gateway ai_pipeline 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");
assert!(
adaptation_mod.contains("pub(crate) use kiro::KiroToClaudeCliStreamState;"),
"adaptation/mod.rs should own KiroToClaudeCliStreamState export after runtime facade removal"
);
}