From 5755265f74016c3de01db8eb4d9779eb3529a278 Mon Sep 17 00:00:00 2001 From: Linghong Date: Thu, 24 Sep 2026 05:49:48 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E6=97=A0=E7=94=A8=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E8=BE=85=E5=8A=A9=E4=BB=A3=E7=A0=81=E5=B9=B6=E6=94=B6?= =?UTF-8?q?=E7=B4=A7=E6=9D=A1=E4=BB=B6=E7=BC=96=E8=AF=91=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除七个无调用的测试辅助函数和包装方法 限定 Unix、Unity 与模板假数据辅助代码的编译条件 删除失去测试入口的旧协议措辞断言及多余导入 同步记录测试辅助代码与现役协议的保留边界 --- .../src/agent/codex_app_server/mod.rs | 37 +---------- .../provider_request_builders.rs | 35 +---------- .../runtime_protocol/autonomous_completion.rs | 5 -- .../src/editor_adapters/execution.rs | 14 ++++- .../src/project/agent_db/security_tests.rs | 1 + .../src-tauri/src/template_library.rs | 2 + .../src-tauri/src/tests/mod.rs | 62 ------------------- ...发运维】本地开发验证与生产运维-2026-05-15.md | 1 + 8 files changed, 18 insertions(+), 139 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/codex_app_server/mod.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/codex_app_server/mod.rs index 82c02728a..26e0704e4 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/codex_app_server/mod.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/codex_app_server/mod.rs @@ -2480,42 +2480,7 @@ impl CodexAppServerConnection { Ok(connection) } - #[cfg(test)] - async fn spawn( - llm: &GameCreatorLlmConfig, - credential: &CodexAppServerCredential, - ) -> Result { - let executable = game_creator_codex_cli_executable_path() - .map_err(platform_llm::LlmError::InvalidConfig)?; - Self::spawn_with_executable_and_credential(llm, credential, executable.as_os_str()).await - } - - #[cfg(test)] - async fn spawn_with_executable( - llm: &GameCreatorLlmConfig, - executable: &std::ffi::OsStr, - ) -> Result { - let credential = resolve_game_creator_codex_app_server_credential(llm)?; - Self::spawn_with_executable_and_credential(llm, &credential, executable).await - } - - #[cfg(test)] - async fn spawn_with_executable_and_credential( - llm: &GameCreatorLlmConfig, - credential: &CodexAppServerCredential, - executable: &std::ffi::OsStr, - ) -> Result { - Self::spawn_with_executable_and_credential_at_workspace( - llm, - credential, - executable, - None, - CodexAppServerWorkspaceMode::ToolHost, - ) - .await - } - - #[cfg(test)] + #[cfg(all(test, unix))] async fn spawn_with_executable_and_credential_at_workspace( llm: &GameCreatorLlmConfig, credential: &CodexAppServerCredential, diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/provider_request_builders.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/provider_request_builders.rs index b21662952..7e3327881 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/provider_request_builders.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/provider_request_builders.rs @@ -824,8 +824,7 @@ mod tests { start_game_creator_agent_runtime_task_at, AgentRuntimeGoalContractAcceptanceNodeDraft, AgentRuntimeGoalContractDraft, AgentRuntimeTaskLink, AgentRuntimeToolObservation, AgentRuntimeToolPlanRequestSnapshot, GameCreatorLlmConfig, - AGENT_RUNTIME_AUTONOMOUS_PRE_MUTATION_LOOP_LIMIT, - AGENT_RUNTIME_COMPLETION_BLOCKER_TOOL_PLAN_PROTOCOL, AGENT_RUNTIME_RESPOND_FUNCTION_NAME, + AGENT_RUNTIME_AUTONOMOUS_PRE_MUTATION_LOOP_LIMIT, AGENT_RUNTIME_RESPOND_FUNCTION_NAME, AGENT_RUNTIME_RUN_PROFILE_AUTONOMOUS_GAME_BUILD, AGENT_RUNTIME_SUPERVISOR_CLI_SOURCE, AGENT_RUNTIME_SUPERVISOR_GUI_SOURCE, AGENT_RUNTIME_UPDATE_PLAN_FUNCTION_NAME, GAME_CREATOR_PROJECT_SUPERVISOR_AGENT_ID, @@ -865,24 +864,6 @@ mod tests { ) } - fn native_input_required_fields( - request: &platform_llm::LlmRunRequest, - tool: &str, - ) -> Vec { - let function_name = crate::agent_native_tools::native_runtime_function_name(tool) - .expect("native runtime function name"); - request - .function_tools - .iter() - .find(|function| function.name == function_name) - .and_then(|function| function.parameters.pointer("/properties/input/required")) - .and_then(serde_json::Value::as_array) - .expect("native input required fields") - .iter() - .map(|field| field.as_str().expect("required field string").to_string()) - .collect() - } - #[test] fn relaxed_request_keeps_general_catalog_after_plan_rejection() { let directory = crate::tests::canonical_test_tempdir("provider-plan-rejection-repair-"); @@ -1431,20 +1412,6 @@ mod tests { assert!(!prompt.contains("本轮唯一可用工具是 agent.goal_contract")); } - fn completion_blocker_protocol_requires_tool_repair_before_response() { - let protocol = AGENT_RUNTIME_COMPLETION_BLOCKER_TOOL_PLAN_PROTOCOL; - - assert!(protocol.contains("最新 observation")); - assert!(protocol.contains("runtime.autonomous_completion")); - assert!(protocol.contains("status 为 blocked")); - assert!(protocol.contains("才能调用 respond_to_user")); - assert!(!protocol.contains("legacy response")); - assert!(protocol.contains("observation.detail 的 nextRequiredAction")); - assert!(protocol.contains("读取、修复和验证工具")); - assert!(protocol.contains("完成要求的动作、取得后续可信 observation")); - assert!(protocol.contains("通过完成门禁后")); - } - #[test] fn supervisor_request_snapshot_preserves_prompt_visible_running_sibling_after_manifest_failure() { diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_protocol/autonomous_completion.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_protocol/autonomous_completion.rs index 3618ca475..57a094da1 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_protocol/autonomous_completion.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_protocol/autonomous_completion.rs @@ -11943,11 +11943,6 @@ impl ExternalGameplayJavascript { .iter() .any(|unit| unit.to_ascii_lowercase().contains(&marker)) } - - #[cfg(test)] - pub(in crate::agent) fn module_units(&self) -> &[String] { - &self.module_units - } } fn normalize_javascript_module_analysis_sources( diff --git a/apps/ai-game-creator-shell/src-tauri/src/editor_adapters/execution.rs b/apps/ai-game-creator-shell/src-tauri/src/editor_adapters/execution.rs index 00d7f7dcb..f9b87d922 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/editor_adapters/execution.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/editor_adapters/execution.rs @@ -525,11 +525,21 @@ pub(crate) fn disconnect_unity_editor_connection() { let _ = disconnect_managed_editor_connection(ManagedEditor::Unity); } -#[cfg(test)] +#[cfg(all( + test, + windows, + target_arch = "x86_64", + feature = "unity-editor-execute" +))] pub(super) fn unity_pending_delivery() -> &'static Mutex> { pending_delivery(ManagedEditor::Unity) } -#[cfg(test)] +#[cfg(all( + test, + windows, + target_arch = "x86_64", + feature = "unity-editor-execute" +))] pub(crate) fn unity_delivery_requires_ack(id: &str) -> bool { pending_delivery(ManagedEditor::Unity) .try_lock() diff --git a/apps/ai-game-creator-shell/src-tauri/src/project/agent_db/security_tests.rs b/apps/ai-game-creator-shell/src-tauri/src/project/agent_db/security_tests.rs index 43fe2df3e..7ebf7e7d1 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/project/agent_db/security_tests.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/project/agent_db/security_tests.rs @@ -452,6 +452,7 @@ fn write_sparse_agent_db_with_complete_tail(root: &Path, length: u64) { } } +#[cfg(unix)] fn assert_agent_db_read_and_append_rejected(root: &Path) { let read_error = read_agent_db_records_bounded(root, 1024) .expect_err("linked Agent DB read must be rejected"); diff --git a/apps/ai-game-creator-shell/src-tauri/src/template_library.rs b/apps/ai-game-creator-shell/src-tauri/src/template_library.rs index 45f9b0330..f986be1ec 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/template_library.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/template_library.rs @@ -454,11 +454,13 @@ fn apply_template_library_fixtures(entries: Vec) -> Vec usize { parse_synthetic_count(std::env::var(SYNTHETIC_COUNT_ENV).ok().as_deref()) } diff --git a/apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs b/apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs index 324ce4988..cf32c528f 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs @@ -392,64 +392,6 @@ pub(crate) fn freeze_test_root_goal_contract_at( .expect("freeze test root Goal Contract") } -pub(crate) fn pass_test_root_acceptance_graph_at( - root: &Path, - state: &AgentRuntimeState, -) -> AgentRuntimeAcceptanceGraphState { - let contract = read_game_creator_agent_runtime_goal_contract_at( - root, - GAME_CREATOR_PROJECT_SUPERVISOR_AGENT_ID, - &state.run_id, - ) - .expect("read test root Goal Contract") - .unwrap_or_else(|| freeze_test_root_goal_contract_at(root, &state.run_id)); - let action = AgentRuntimeToolAction { - tool: "file.list".to_string(), - reason: Some("提供测试验收图的当前 revision 机器证据".to_string()), - input: serde_json::json!({ "path": "" }), - }; - let action_fingerprint = agent_runtime_tool_action_fingerprint(&action, &state.current_task); - let action_id = - agent_runtime_tool_action_id(&state.run_id, u32::MAX - 1, 0, 0, &action_fingerprint); - let revision = read_game_creator_agent_runtime_project_revision(root) - .expect("read test project revision") - .revision; - append_agent_runtime_action_receipt_with_project_revision_before( - root, - state, - &action_id, - &action_fingerprint, - "file.list", - "auto", - None, - &AgentRuntimeToolObservation { - tool: "file.list".to_string(), - status: "ok".to_string(), - summary: "测试验收证据已持久化".to_string(), - detail: None, - }, - revision, - ) - .expect("append test acceptance receipt"); - update_game_creator_agent_runtime_acceptance_graph_at( - root, - GAME_CREATOR_PROJECT_SUPERVISOR_AGENT_ID, - &state.run_id, - &contract.contract_fingerprint, - &[AgentRuntimeAcceptanceEvaluationDraft { - criterion_id: "test-acceptance".to_string(), - status: "passed".to_string(), - evidence: vec![AgentRuntimeAcceptanceEvidenceRef { - agent_id: state.agent_id.clone(), - run_id: state.run_id.clone(), - action_id, - }], - summary: "测试声明的验收条件已满足".to_string(), - }], - ) - .expect("pass test root Acceptance Graph") -} - pub(crate) fn canonical_test_tempdir(prefix: &str) -> tempfile::TempDir { let temp_root = std::env::temp_dir() .canonicalize() @@ -3492,10 +3434,6 @@ fn spawn_mock_external_canvas_api_server_with_capture_and_generation_gate( base_url } -fn spawn_mock_external_canvas_api_server() -> String { - spawn_mock_external_canvas_api_server_with_capture(3, None) -} - fn spawn_mock_external_canvas_generation_api_server( request_sender: Option>, ) -> String { diff --git a/docs/【开发运维】本地开发验证与生产运维-2026-05-15.md b/docs/【开发运维】本地开发验证与生产运维-2026-05-15.md index 735eb667a..8509847e5 100644 --- a/docs/【开发运维】本地开发验证与生产运维-2026-05-15.md +++ b/docs/【开发运维】本地开发验证与生产运维-2026-05-15.md @@ -292,6 +292,7 @@ npm run check ### 编译告警的保留边界与待优化项 - 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 路径校验的测试分支不触发宿主提权修复,修复范围参数仅由生产分支消费。 +- 测试 helper 的条件要覆盖真实使用范围:Unity delivery 观测 helper 限于 Windows x86_64 的 `unity-editor-execute` 测试,Agent DB 链接安全断言与 app-server 工作区启动包装限于 Unix 测试,模板假数据的环境变量读取限于 `template-library-fixtures` feature。底层生产实现与共享测试逻辑继续保留。仅检查完成阻塞协议固定中文措辞、且失去测试标记的遗留函数直接删除;现役自由执行请求使用短任务协议,不向其测试搬入标准模式的完成阻塞提示词要求,标准模式的生产协议保持不变。 - AGC 默认 Windows dev 构建在 2026-09-23 清理后的 `cargo check --locked --offline --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml -p genarrative-ai-game-creator-shell` 复核通过,剩余 3 条 AuthBridge 相关 Rust warning 和 5 条 ts-rs 提示。这是当次配置的检查结果,不代表后续提交、正式 editor features、其它平台、test targets、release 链接或安装包均无告警;后续按改动范围定向验证。 - AuthBridge 的 3 条 warning 暂缓处理,支持或退役 OAuth 的决策仍未确定。完整证据、保留边界和关闭条件以 [AGC 主方案“OAuth 认证路线的契约冲突与待决边界”](./technical/【技术方案】AI游戏创作智能体App实施计划-2026-06-24.md#oauth-认证路线的契约冲突与待决边界)为准。 - ts-rs 12.0.1 的 5 条提示来自四个枚举(`DirectCodexUserItem`、`DirectCodexUserContentPart`、`DirectThreadItem`、`DirectThreadEvent`)的 `serde(deny_unknown_fields)` 和图片组件的 `serde(deserialize_with = "deserialize_fill_amount")`。已静态核对 TypeScript 类型形状及基础类型正确、Serde 运行时校验仍有效;暂保留提示,不引入依赖补丁、不改业务校验或全局屏蔽,待上游正式版本支持后再评估。