清理无用测试辅助代码并收紧条件编译范围

删除七个无调用的测试辅助函数和包装方法
限定 Unix、Unity 与模板假数据辅助代码的编译条件
删除失去测试入口的旧协议措辞断言及多余导入
同步记录测试辅助代码与现役协议的保留边界
This commit is contained in:
2026-09-24 05:49:48 +00:00
parent 1424c3ee5a
commit 5755265f74
8 changed files with 18 additions and 139 deletions
@@ -2480,42 +2480,7 @@ impl CodexAppServerConnection {
Ok(connection)
}
#[cfg(test)]
async fn spawn(
llm: &GameCreatorLlmConfig,
credential: &CodexAppServerCredential,
) -> Result<Self, platform_llm::LlmError> {
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<Self, platform_llm::LlmError> {
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, platform_llm::LlmError> {
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,
@@ -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<String> {
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()
{
@@ -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(
@@ -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<Option<PendingDelivery>> {
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()
@@ -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");
@@ -454,11 +454,13 @@ fn apply_template_library_fixtures(entries: Vec<GameTemplateEntry>) -> Vec<GameT
pub(crate) mod fixtures {
use super::*;
#[cfg(feature = "template-library-fixtures")]
pub(crate) const SYNTHETIC_COUNT_ENV: &str = "AGC_TEMPLATE_LIBRARY_SYNTHETIC_COUNT";
pub(crate) const DEFAULT_SYNTHETIC_COUNT: usize = 1_000;
const MAX_SYNTHETIC_COUNT: usize = 20_000;
/// 假数据条数:环境变量优先,缺省 1000;0 表示不注入。
#[cfg(feature = "template-library-fixtures")]
pub(crate) fn synthetic_template_count() -> usize {
parse_synthetic_count(std::env::var(SYNTHETIC_COUNT_ENV).ok().as_deref())
}
@@ -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<mpsc::Sender<String>>,
) -> String {