清理测试编译中的未使用导入与辅助代码
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m24s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 2m3s
Project CI / Backend tests (pull_request) Successful in 3m48s
Project CI / Frontend tests (pull_request) Successful in 1m49s
Project CI / Native shell tests (pull_request) Successful in 5m43s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 8m17s
Project CI / Repository checks (pull_request) Successful in 1m57s
Project CI / AI game creator shell web tests (pull_request) Successful in 1m20s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 9m10s

限定 GUI 和平台测试导入的编译范围,删除多余导入与重导出
删除三个无调用的测试辅助函数,消除冗余赋值
补齐 DirectHome 命令工具禁用断言,明确测试路径校验参数用途
更新开发运维文档中的测试编译告警处理边界
This commit is contained in:
2026-09-24 05:28:04 +00:00
parent ec3a187dd7
commit 1424c3ee5a
21 changed files with 52 additions and 125 deletions
@@ -55,6 +55,7 @@ pub(crate) use codex_cli::{
game_creator_codex_cli_executable_path, game_creator_codex_cli_version_identity,
};
pub(crate) use codex_provider_proxy::*;
#[cfg(not(test))]
pub(crate) use design_runtime::*;
pub(crate) use direct_codex_attachments::*;
pub(crate) use direct_codex_user_item::*;
@@ -7095,6 +7095,8 @@ while IFS= read -r line; do :; done
.map(|argument| argument.to_string_lossy().into_owned())
.collect::<Vec<_>>()
.join("\n");
assert!(home_arguments.contains("--disable\nshell_tool"));
assert!(home_arguments.contains("--disable\nunified_exec"));
}
#[cfg(windows)]
@@ -1688,7 +1688,6 @@ pub(crate) fn read_design_workspace_file(
#[cfg(test)]
mod fake_provider {
use super::*;
use std::cell::{Cell, RefCell};
use std::collections::VecDeque;
@@ -8,6 +8,7 @@ use std::sync::{Mutex, OnceLock};
use std::time::{SystemTime, UNIX_EPOCH};
mod user_input;
#[cfg(not(test))]
pub(crate) use user_input::chat_with_game_creator_direct_codex;
#[cfg(test)]
pub(crate) use user_input::normalize_direct_client_turn_id;
@@ -49,7 +49,6 @@ pub(in crate::agent) use external_generation_state::{
};
#[cfg(test)]
pub(crate) use external_generation_state::{
platform_art_generation_external_configuration_fingerprint,
platform_art_generation_legacy_external_configuration_fingerprint,
setup_platform_art_generation_runtime_accepted_for_recovery_test,
write_platform_art_generation_runtime_accepted_for_test,
@@ -817,24 +817,18 @@ mod tests {
use super::{
acquire_game_creator_agent_provider_plan_project_write_lock_with_wait,
agent_runtime_root_source_at, bind_game_creator_agent_runtime_run_profile_at,
build_game_creator_agent_background_final_reply_request,
build_game_creator_agent_background_tool_plan_request_locked,
game_creator_agent_context_preload_notice,
game_creator_agent_runtime_run_profile_binding_path,
game_creator_project_supervisor_chat_system_prompt, init_local_game_project_at,
new_game_creation_app_seed_tasks, provider_command_exec_contract,
provider_command_start_contract,
game_creator_agent_context_preload_notice, init_local_game_project_at,
new_game_creation_app_seed_tasks,
render_relaxed_autonomous_manifest_ready_task_background_prompt,
required_runtime_prompt_section, start_game_creator_agent_runtime_task_at,
AgentRuntimeGoalContractAcceptanceNodeDraft, AgentRuntimeGoalContractDraft,
AgentRuntimeTaskLink, AgentRuntimeToolObservation, AgentRuntimeToolPlan,
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_RUN_PROFILE_AUTONOMOUS_GAME_BUILD, AGENT_RUNTIME_RUN_PROFILE_STANDARD,
AGENT_RUNTIME_SUPERVISOR_CLI_SOURCE, AGENT_RUNTIME_SUPERVISOR_GUI_SOURCE,
AGENT_RUNTIME_UPDATE_PLAN_FUNCTION_NAME, GAME_CREATOR_PROJECT_SUPERVISOR_AGENT_ID,
RUNTIME_PROMPT_SUPERVISOR_CHAT_COMPOSITION,
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,
};
fn build_game_creator_agent_background_tool_plan_request_for_test(
@@ -302,10 +302,7 @@ pub(crate) use entrypoints::{
pub(crate) use finalization::resume_game_creator_agent_finalization_for_test_at;
pub(crate) use finalization::AgentRuntimePendingActionResume;
#[cfg(test)]
pub(crate) use interaction::{
acquire_game_creator_agent_runtime_user_input_answer_locks_for_test,
agent_runtime_tool_requires_repository_context_fingerprint_gate,
};
pub(crate) use interaction::agent_runtime_tool_requires_repository_context_fingerprint_gate;
pub(crate) use interaction::{
answer_game_creator_agent_runtime_user_input_at, confirm_game_creator_agent_runtime_task_at,
pending_repository_context_drift_observation, reject_game_creator_agent_runtime_task_at,
@@ -477,20 +477,6 @@ fn resolve_game_creator_agent_runtime_user_input_action_with_ordered_locks(
Ok((None, runtime_lock, resolved))
}
#[cfg(test)]
pub(crate) fn acquire_game_creator_agent_runtime_user_input_answer_locks_for_test(
root: &Path,
agent_id: &str,
run_id: &str,
action_id: &str,
) -> Result<(Option<ProjectWriteLock>, AgentRuntimeTaskLock), String> {
let (project_lock, runtime_lock, _) =
resolve_game_creator_agent_runtime_user_input_action_with_ordered_locks(
root, agent_id, run_id, action_id,
)?;
Ok((project_lock, runtime_lock))
}
pub(crate) fn answer_game_creator_agent_runtime_user_input_at(
root: &Path,
agent_id: &str,
@@ -44,9 +44,7 @@ pub(in crate::agent) use ui_workflow::*;
#[cfg(test)]
pub(crate) use delegation::observe_agent_runtime_agent_delegate_at_locked;
#[cfg(test)]
pub(crate) use delivery::{
build_static_delegate_result_for_child_at, wake_waiting_static_delegate_parent_run_for_test_at,
};
pub(crate) use delivery::build_static_delegate_result_for_child_at;
#[cfg(test)]
pub(crate) use isolated_joins::render_isolated_join_status_batch_with_limit;
#[cfg(test)]
@@ -408,14 +408,6 @@ pub(in crate::agent) fn wake_waiting_static_delegate_parent_run_at(
Ok(true)
}
#[cfg(test)]
pub(crate) fn wake_waiting_static_delegate_parent_run_for_test_at(
root: &Path,
parent_task: &AgentRuntimeTaskRecord,
) -> Result<bool, String> {
wake_waiting_static_delegate_parent_run_at(root, parent_task)
}
pub(in crate::agent) fn wake_waiting_autonomous_manifest_parent_run_at(
root: &Path,
parent_task: &AgentRuntimeTaskRecord,
@@ -13,8 +13,6 @@ use crate::agent::{
AgentRuntimeToolPlan, AGENT_RUNTIME_BACKGROUND_TOOL_ACTION_LIMIT,
AGENT_RUNTIME_CANVAS_ASSET_KINDS, AGENT_RUNTIME_PLAN_STEP_LIMIT,
};
#[cfg(test)]
use crate::GAME_CREATOR_PROJECT_SUPERVISOR_AGENT_ID;
pub(crate) const AGENT_RUNTIME_UPDATE_PLAN_FUNCTION_NAME: &str = "update_agent_plan";
pub(crate) const AGENT_RUNTIME_RESPOND_FUNCTION_NAME: &str = "respond_to_user";
@@ -32,6 +32,7 @@ use super::playtest::{
GENERIC_PLAYTEST_START_OPPORTUNITY_MIN_STABILITY_SAMPLES,
GENERIC_PLAYTEST_START_OPPORTUNITY_WINDOW, PLAYABLE_GAME_STATE_SCHEMA_VERSION,
};
#[cfg(unix)]
use super::process::create_browser_process_temp_dir;
static PATH_TEST_LOCK: Mutex<()> = Mutex::new(());
@@ -1291,6 +1291,8 @@ fn validate_game_creator_private_path_ancestors_with_auto_elevation_scoped(
) -> Result<(), String> {
#[cfg(test)]
{
// 测试只校验路径,不触发宿主提权修复,因此不消费修复范围。
let _ = scope;
return validate_game_creator_private_path_ancestors(path, label);
}
#[cfg(not(test))]
@@ -7,9 +7,10 @@ use std::io::Read;
use std::path::{Path, PathBuf};
use std::process::Stdio;
use std::time::{Duration, Instant};
#[cfg(not(test))]
pub(crate) use web_creation::preflight_web_game_creation;
pub(crate) use web_creation::{
host_web_creation_preflight, preflight_web_game_creation, prepare_new_web_project_at,
record_new_web_scaffold_at,
host_web_creation_preflight, prepare_new_web_project_at, record_new_web_scaffold_at,
};
use serde::Deserialize;
@@ -50,6 +50,7 @@ use shared_contracts::game_creation_app::{
};
// `Emitter` 同时被 `use super::*` 的子模块依赖(通知、Agent 事件等都从 crate 根取该 trait),
// 不要因为根模块自身不再直接 `.emit(..)` 就删掉它。
#[cfg(not(test))]
use environment_check::preflight_web_game_creation;
use tauri::{Emitter, Manager};
use tauri_plugin_dialog::DialogExt;
@@ -156,13 +157,16 @@ mod tool_plan_handoff;
mod user_input;
mod windows;
#[cfg(not(test))]
use agent::design_tools::*;
use agent::*;
use agent_native_tools::*;
#[cfg(not(test))]
use asset_generation_tasks::*;
use assets::*;
use browser::*;
use cli::*;
#[cfg(not(test))]
use client_extensions::*;
use collaboration::*;
use command_exec::*;
@@ -172,6 +176,7 @@ use commands::*;
use config::*;
use context_compaction::*;
use delegation::*;
#[cfg(not(test))]
use error_report::*;
use git_inspect::*;
use goal::*;
@@ -179,6 +184,7 @@ use image_inspect::*;
use isolated_agent::*;
use patchset::*;
use platform_session::*;
#[cfg(not(test))]
use plugin_host::{
call_agc_plugin, list_agc_extensions, list_agc_plugins, read_agc_plugin_panel,
refresh_agc_plugins, reload_agc_plugin, set_agc_plugin_enabled, set_agc_plugin_project_path,
@@ -192,6 +198,7 @@ use repository_context::*;
use resource_inspect::*;
use resource_preview_scheduler::*;
use runner::*;
#[cfg(not(test))]
use template_library::*;
use user_input::*;
use windows::*;
@@ -31,9 +31,9 @@ pub(crate) use endpoint::validate_windows_regular_file_handle;
pub(crate) use endpoint::{external_agent_runner_enabled, external_agent_runner_is_server_process};
#[allow(unused_imports)]
pub(crate) use protocol::{ExternalAgentRunnerStatus, EXTERNAL_AGENT_RUNNER_PROTOCOL_VERSION};
pub(crate) use server::{
bind_loopback_listener_with_linux_fallback, run_external_agent_runner_server,
};
pub(crate) use server::bind_loopback_listener_with_linux_fallback;
#[cfg(not(test))]
pub(crate) use server::run_external_agent_runner_server;
#[cfg(test)]
pub(crate) fn simulate_external_agent_runner_cross_boot_owner_claim_for_test(
@@ -3,6 +3,7 @@ use super::{
};
use serde_json::{json, Value};
use sha2::{Digest as _, Sha256};
#[cfg(target_os = "linux")]
use std::collections::BTreeSet;
use std::ffi::OsString;
use std::fs;
@@ -1,7 +1,7 @@
use super::*;
use base64::Engine as _;
use serde_json::Value;
use sha2::{Digest as _, Sha256};
use sha2::Sha256;
use std::collections::{BTreeMap, BTreeSet};
use std::io::{self, Read, Write};
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
@@ -647,62 +647,6 @@ pub(crate) async fn wait_for_agent_runtime_terminal_and_lane_release_async(
}
}
pub(crate) async fn wait_for_agent_runtime_manifest_projection_async(
root: &Path,
agent_id: &str,
run_id: &str,
runtime_status: &str,
phase: &str,
manifest_status: GameCreationAppTaskStatus,
) -> AgentRuntimeResult {
let deadline = Instant::now() + AGENT_RUNTIME_TERMINAL_WAIT_BUDGET;
let mut terminal = wait_for_agent_runtime_terminal_and_lane_release_async(
root,
agent_id,
run_id,
runtime_status,
phase,
)
.await;
let mut stable_samples = 0_u8;
loop {
if let Ok(project_lock) = acquire_game_creator_agent_runtime_project_write_lock_with_wait(
root,
"test.wait_runtime_manifest_projection",
) {
let manifest = read_manifest_for_project(root)
.expect("read manifest while waiting for terminal projection");
let projected = manifest
.tasks
.iter()
.find(|task| task.id == agent_id)
.is_some_and(|task| task.status == manifest_status);
let reread = read_game_creator_agent_runtime_at(root, agent_id)
.expect("reread runtime while waiting for terminal projection");
drop(project_lock);
if projected
&& reread.state.run_id == run_id
&& reread.state.status == runtime_status
&& reread.state.phase == phase
{
stable_samples = stable_samples.saturating_add(1);
terminal = reread;
if stable_samples >= 2 {
return terminal;
}
} else {
stable_samples = 0;
terminal = reread;
}
}
assert!(
Instant::now() < deadline,
"runtime terminal manifest projection did not settle for {agent_id}/{run_id}"
);
tokio::time::sleep(Duration::from_millis(20)).await;
}
}
async fn wait_for_agent_runtime_lane_release_async(
root: &Path,
agent_id: &str,
@@ -14,13 +14,12 @@ pub(super) use super::super::{
append_auto_tool_action_audit_pair_for_test, assert_auto_tool_action_audit_pair,
assert_pending_runtime_decision_revalidates_after_lock, assert_task_status,
fake_llm_game_draft, final_tool_plan_response, mock_http_request_json,
native_agent_tool_plan_chat_response, observe_agent_runtime_agent_delegate,
pending_tool_action_for_test, persist_needs_reconciliation_runtime_for_test,
persist_project_verification_for_test, read_agent_db_records_for_test,
register_canvas_visual_asset_fixture, spawn_barrier_mock_llm_server,
spawn_interruptible_mock_llm_server_with_capture, spawn_mock_llm_raw_responses_with_capture,
spawn_mock_llm_server, spawn_mock_llm_server_responses,
spawn_mock_llm_server_responses_with_capture,
native_agent_tool_plan_chat_response, pending_tool_action_for_test,
persist_needs_reconciliation_runtime_for_test, persist_project_verification_for_test,
read_agent_db_records_for_test, register_canvas_visual_asset_fixture,
spawn_barrier_mock_llm_server, spawn_interruptible_mock_llm_server_with_capture,
spawn_mock_llm_raw_responses_with_capture, spawn_mock_llm_server,
spawn_mock_llm_server_responses, spawn_mock_llm_server_responses_with_capture,
spawn_releasable_mock_llm_server_responses_with_capture,
spawn_releasable_mock_llm_server_responses_with_capture_at, start_agent_runtime_steer_fixture,
ui_prototype_assessment_fixture, unique_project_path, use_test_runtime_config_dir,
@@ -38,10 +37,9 @@ pub(super) use crate::{
agent_runtime_background_worker_threads_for_test, agent_runtime_executable_tools,
agent_runtime_read_only_delivery_completion_plan_update, agent_runtime_run_profile_identity_at,
agent_runtime_tool_action_fingerprint, agent_runtime_tool_action_id,
agent_runtime_tool_allowed_for_agent, agent_runtime_tool_policy_snapshot_for_run_at,
agent_runtime_tool_policy_snapshot_for_run_at,
agent_runtime_tool_requires_pending_revision_gate,
agent_runtime_tool_requires_repository_context_fingerprint_gate,
agent_runtime_verified_delivery_completion_plan_update, append_agent_db_record,
agent_runtime_tool_requires_repository_context_fingerprint_gate, append_agent_db_record,
append_agent_db_terminal_observation_if_missing_for_action,
append_agent_runtime_action_receipt, append_agent_runtime_tool_call_record,
append_game_creator_agent_runtime_action_event, append_game_creator_agent_runtime_task,
@@ -67,8 +65,8 @@ pub(super) use crate::{
game_creator_agent_runtime_tool_policy_rule_for_run, init_local_game_project_at,
invalidate_agent_runtime_project_verification_after_preview_failure_at,
native_runtime_function_name, observe_agent_runtime_action_history,
observe_agent_runtime_agent_message, observe_agent_runtime_agent_spawn_isolated,
plan_game_creation_agent_pass, prepare_agent_runtime_project_mutation_locked,
observe_agent_runtime_agent_message, plan_game_creation_agent_pass,
prepare_agent_runtime_project_mutation_locked,
prepare_game_creator_agent_runtime_provider_action_batch,
project_verification_completion_blocker_at, read_all_game_creator_agent_runtime_tasks,
read_game_creator_agent_runtime_at, read_game_creator_agent_runtime_context_bundle,
@@ -18,15 +18,18 @@ use super::identity_order_validation::{
parse_tool_plan_base_request_slot, request_slot_for_attempt,
};
use super::ledger::response_for_persistence;
#[cfg(unix)]
use super::model::TOOL_PLAN_HANDOFF_RELATIVE_DIRECTORY;
use super::model::{
INVALID_THINKING_CLOSE_MARKER, INVALID_THINKING_OPEN_MARKER,
TOOL_PLAN_HANDOFF_ARGUMENTS_MAX_BYTES, TOOL_PLAN_HANDOFF_LABEL, TOOL_PLAN_HANDOFF_MAX_ENTRIES,
TOOL_PLAN_HANDOFF_MAX_TOOL_CALLS, TOOL_PLAN_HANDOFF_RELATIVE_DIRECTORY,
TOOL_PLAN_HANDOFF_REQUEST_RESERVE_BYTES, TOOL_PLAN_HANDOFF_SIDECAR_MAX_BYTES,
TOOL_PLAN_HANDOFF_MAX_TOOL_CALLS, TOOL_PLAN_HANDOFF_REQUEST_RESERVE_BYTES,
TOOL_PLAN_HANDOFF_SIDECAR_MAX_BYTES,
};
#[cfg(unix)]
use super::storage_common::serialize_ledger_for_storage;
use super::storage_common::{
path_key, response_fingerprint, serialize_ledger_for_storage, tool_plan_handoff_path,
tool_plan_handoff_relative_path,
path_key, response_fingerprint, tool_plan_handoff_path, tool_plan_handoff_relative_path,
};
#[cfg(unix)]
use super::storage_unix::{
@@ -43,7 +46,9 @@ use super::*;
use crate::agent::{
agent_runtime_json_sidecar_backup_path, write_agent_runtime_json_sidecar_with_max_bytes,
};
use crate::provider_retry::{self, AgentRuntimeProviderRetryIdentity};
#[cfg(unix)]
use crate::provider_retry;
use crate::provider_retry::AgentRuntimeProviderRetryIdentity;
#[test]
fn tool_plan_handoff_classifies_windows_handle_install_failure_as_storage() {
@@ -291,6 +291,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 路径校验的测试分支不触发宿主提权修复,修复范围参数仅由生产分支消费。
- 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 运行时校验仍有效;暂保留提示,不引入依赖补丁、不改业务校验或全局屏蔽,待上游正式版本支持后再评估。