清理无用测试辅助代码并收紧条件编译范围
删除七个无调用的测试辅助函数和包装方法 限定 Unix、Unity 与模板假数据辅助代码的编译条件 删除失去测试入口的旧协议措辞断言及多余导入 同步记录测试辅助代码与现役协议的保留边界
This commit is contained in:
@@ -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,
|
||||
|
||||
+1
-34
@@ -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()
|
||||
{
|
||||
|
||||
-5
@@ -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 {
|
||||
|
||||
@@ -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 运行时校验仍有效;暂保留提示,不引入依赖补丁、不改业务校验或全局屏蔽,待上游正式版本支持后再评估。
|
||||
|
||||
Reference in New Issue
Block a user