From e53d4f611e56d6153d77dc7a5133fc77ec0a5984 Mon Sep 17 00:00:00 2001 From: Linghong Date: Thu, 1 Oct 2026 07:17:14 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=88=E5=B9=B6=E5=90=8E?= =?UTF-8?q?=E5=85=B1=E4=BA=AB=E8=BF=90=E8=A1=8C=E9=93=BE=E8=B7=AF=E7=9A=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=BC=96=E8=AF=91=E8=BE=B9=E7=95=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 恢复 Claude Direct 所需 MCP loopback 启停及工具桥的测试可见性 恢复认证会话校验与线程队列事件构造函数的测试可见性 同步编译边界文档,通过 AGC 测试目标编译检查 --- .../src-tauri/src/agent/direct_tool_bridge.rs | 1 - .../src-tauri/src/agent/direct_tools_mcp.rs | 8 -------- .../src-tauri/src/agent/runtime_driver/entrypoints.rs | 1 - .../src-tauri/src/platform_session.rs | 1 - docs/【开发运维】本地开发验证与生产运维-2026-05-15.md | 2 +- 5 files changed, 1 insertion(+), 12 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_tool_bridge.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_tool_bridge.rs index 439293313..1300be1b5 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_tool_bridge.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_tool_bridge.rs @@ -3143,7 +3143,6 @@ pub(crate) async fn start_direct_tool_bridge( start_tool_bridge_for_source(root, controlled_web_search, true).await } -#[cfg(not(test))] pub(crate) async fn start_external_client_tool_bridge( root: &Path, controlled_web_search: bool, diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_tools_mcp.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_tools_mcp.rs index 74e3143ed..35c166d53 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_tools_mcp.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_tools_mcp.rs @@ -1,12 +1,9 @@ use super::*; -#[cfg(not(test))] use axum::extract::DefaultBodyLimit; use axum::extract::State as AxumState; use axum::http::{HeaderMap, StatusCode}; -#[cfg(not(test))] use axum::routing::post; use axum::Json; -#[cfg(not(test))] use axum::Router; use serde_json::{json, Value}; use sha2::{Digest, Sha256}; @@ -30,19 +27,16 @@ const EXTERNAL_MCP_RESPONSE_SUMMARY_MAX_CHARS: usize = 240; const EXTERNAL_MCP_JOURNAL_MAX_BYTES: u64 = 8 * 1024 * 1024; const EXTERNAL_MCP_JOURNAL_RELATIVE_PATH: &str = ".agent/conversations/codex-responses.jsonl"; static EXTERNAL_MCP_JOURNAL_LOCK: OnceLock> = OnceLock::new(); -#[cfg(not(test))] static EXTERNAL_MCP_SERVER: OnceLock>> = OnceLock::new(); tokio::task_local! { static EXTERNAL_MCP_BRIDGE_URL: String; } -#[cfg(not(test))] pub(crate) struct ExternalMcpServer { _bridge: super::direct_tool_bridge::DirectToolBridge, task: tokio::task::JoinHandle<()>, } -#[cfg(not(test))] impl Drop for ExternalMcpServer { fn drop(&mut self) { self.task.abort(); @@ -2132,7 +2126,6 @@ async fn handle_external_mcp_http_request( Ok(Json(response)) } -#[cfg(not(test))] pub(crate) async fn start_external_mcp_loopback( root: &Path, controlled_web_search: bool, @@ -2181,7 +2174,6 @@ pub(crate) async fn start_external_mcp_loopback( Ok((url, token)) } -#[cfg(not(test))] pub(crate) fn stop_external_mcp_loopback() { if let Some(registry) = EXTERNAL_MCP_SERVER.get() { if let Ok(mut guard) = registry.lock() { diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_driver/entrypoints.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_driver/entrypoints.rs index 33f4daf7f..c7c523cee 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_driver/entrypoints.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_driver/entrypoints.rs @@ -69,7 +69,6 @@ pub(crate) struct DirectGameCreatorTurnUpdateEmitter { } impl DirectGameCreatorTurnUpdateEmitter { - #[cfg(not(test))] pub(crate) fn new(root: &Path, turn_id: String) -> Self { Self { project_path: root.to_string_lossy().into_owned(), diff --git a/apps/ai-game-creator-shell/src-tauri/src/platform_session.rs b/apps/ai-game-creator-shell/src-tauri/src/platform_session.rs index 53ae8b5f8..3e7ed9d46 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/platform_session.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/platform_session.rs @@ -238,7 +238,6 @@ fn validated_platform_session_snapshot( }) } -#[cfg(not(test))] pub(crate) fn validate_platform_session_input( user_id: &str, access_token: &str, diff --git a/docs/【开发运维】本地开发验证与生产运维-2026-05-15.md b/docs/【开发运维】本地开发验证与生产运维-2026-05-15.md index dee289912..ec8a2ef39 100644 --- a/docs/【开发运维】本地开发验证与生产运维-2026-05-15.md +++ b/docs/【开发运维】本地开发验证与生产运维-2026-05-15.md @@ -322,7 +322,7 @@ npm run check - 编辑器适配器注册、随包资源定位和平台会话 fixture 加载属于桌面/Runner 启动接入,按生产模块编译;fixture 的发行版拒绝、路径边界、文件大小及凭据校验不得随拆分改变。配置 setup、Windows 提权 helper 的票据消费和 Runner bootId 初始化随其生产调用方限定范围,配置迁移、ACL 安全规则、平台身份/凭据轮换、编辑器执行回执及进程归属的已有测试继续编译。 - 项目快照的周期调度、窗口事件、退出等待和桌面命令与共享同步核心分离;Analytics 的服务初始化、窗口/退出事件、上传定时启动和启动时补投同样属于生产接入。窗口登记状态机、快照索引与同步事务、埋点状态机、上传轮次和补投资格处理继续参与测试,不能用移除这些测试的方式消除告警。 - Runner 服务监听循环、连接读写接入、心跳和 GUI owner 监控按生产边界编译;共享 RPC 分发、endpoint 校验、请求幂等、项目 owner 和生命周期测试继续参与测试。只读配置入口有 Unix 专属测试,必须保留 `any(not(test), unix)` 的使用范围,不能直接归入仅生产模块。 -- MCP 的 STDIO/loopback 启停在原文件内精确限定生产编译,共享请求处理保留测试;Direct/设计工具及 UI 编辑器的纯命令包装随桌面入口编译。Thread Manager 的订阅/消费同时服务 Unix 集成测试与跨平台取消回合回归,不限定为生产或 Unix。项目资源的生产命令 DTO 与读取接入按实际消费者限定范围;分类更新测试从正式 camelCase 请求解码后验证同一身份与 revision 的写入,音频提交测试核对派发 operationId 与账本任务一致、幂等键不被替换。业务编排、网络鉴权和持久化安全逻辑不能仅因没有直接测试而整段排除。 +- MCP 的 STDIO 启动和 Tauri 命令包装限定生产编译;loopback 启停、服务注册表、析构与工具桥启动属于 Claude Direct 的共享依赖,必须参与测试编译。认证链路调用的 `validate_platform_session_input`、线程队列使用的 `DirectGameCreatorTurnUpdateEmitter::new` 同样保留在测试编译中;Direct/设计工具及 UI 编辑器的纯命令包装随桌面入口编译。Thread Manager 的订阅/消费同时服务 Unix 集成测试与跨平台取消回合回归,不限定为生产或 Unix。项目资源的生产命令 DTO 与读取接入按实际消费者限定范围;分类更新测试从正式 camelCase 请求解码后验证同一身份与 revision 的写入,音频提交测试核对派发 operationId 与账本任务一致、幂等键不被替换。业务编排、网络鉴权和持久化安全逻辑不能仅因没有直接测试而整段排除。 - Direct 取消入口必须验证错轮请求不取消、不释放、不发送终态;执行器退出后的残留守卫释放须返回原 clientTurnId,并发布对应 canonical userItemId 的 aborted 终态。旧守卫析构不能清掉随后启动的新回合。此类安全行为通过真实入口回归保留在测试构建,不以条件编译排除取消链。 - 预览测试使用系统临时目录,不依赖 Windows 未必提供的 `HOME`。Cocos 插件 RPC 往返测试在注册完成后,通过只读状态查询确认插件已接收启动时的项目上下文,再执行原有隐式项目路径断言;Unity 跨项目测试先等待项目事件订阅,再切换项目。不能把注册完成等同于项目订阅快照已到达,也不能重试写操作掩盖初始化竞态。 - AGC 测试编译使用 `cargo check --locked --offline --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml -p genarrative-ai-game-creator-shell --tests` 定向核对。GUI 主入口在测试构建中被排除,不能把测试目标的 `dead_code` 一律认定为废弃生产代码;仅生产入口使用的导入限定 `not(test)`,平台测试导入与对应 Unix/Linux 测试保持相同条件,失去调用方的测试 helper 和多余重导出直接删除。DirectHome 命令配置测试明确断言禁用 `shell_tool` 与 `unified_exec`;Windows 路径校验的测试分支不触发宿主提权修复,修复范围参数仅由生产分支消费。