diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/codex_app_server/execution.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/codex_app_server/execution.rs index b089884e9..84473382d 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/codex_app_server/execution.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/codex_app_server/execution.rs @@ -16,11 +16,25 @@ use tokio::sync::{watch, Notify}; const MAX_PROTOCOL_ITEMS: usize = 2048; const MAX_REQUEST_CACHE: usize = 512; +/// 逐次审批协议的版本门禁:发行构建只接受捆绑侧车的固定版本;开发构建用宿主自带的 Codex +/// (Linux 与未 stage 侧车时没有固定版本可用),按 profile 直接跳过该门禁。 pub(super) fn validate_approval_version(version: &str) -> Result<(), String> { - if version.trim() == super::super::codex_cli::codex_bundle::CLI_VERSION { - return Ok(()); + #[cfg(not(debug_assertions))] + { + if version.trim() == super::super::codex_cli::codex_bundle::CLI_VERSION { + return Ok(()); + } + return Err(format!( + "direct-execution-protocol: 当前 Codex 版本未通过逐次审批协议验收,请使用客户端配套版本(期望 {},实际 {});禁止降级为无控制执行", + super::super::codex_cli::codex_bundle::CLI_VERSION, + version.trim() + )); + } + #[cfg(debug_assertions)] + { + let _ = version; + Ok(()) } - Err("direct-execution-protocol: 当前 Codex 版本未通过逐次审批协议验收,请使用客户端配套版本;禁止降级为无控制执行".into()) } pub(super) fn denied_response(id: u64, method: &str) -> Value { @@ -1604,9 +1618,13 @@ mod tests { super::super::super::codex_cli::codex_bundle::CLI_VERSION ) .is_ok()); + // 开发构建(含本测试构建)跳过版本门禁,只有发行构建要求严格等于固定版本。 + #[cfg(debug_assertions)] + assert!(validate_approval_version("codex-cli 0.156.0").is_ok()); + #[cfg(not(debug_assertions))] for version in [ "codex-cli 0.155.0", - "codex-cli 0.154.0", + "codex-cli 0.156.0", "unknown", "0.155.1", ] { diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_execution.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_execution.rs index ec31889d6..73a283b85 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_execution.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_execution.rs @@ -704,9 +704,19 @@ pub(super) fn open_with_analytics_at( impl ExecutionSession { pub(super) fn bind_codex_executor(&self, path: &Path, version: &str) -> Result<(), String> { - if version.trim() != super::codex_cli::codex_bundle::CLI_VERSION { - return Err("direct-execution-executor: 尚未验证该执行器的补丁协议".into()); + // 发行构建只接受捆绑侧车固定版本;开发构建用宿主自带的 Codex,按 profile 跳过该门禁。 + #[cfg(not(debug_assertions))] + { + if version.trim() != super::codex_cli::codex_bundle::CLI_VERSION { + return Err(format!( + "direct-execution-executor: 尚未验证该执行器的补丁协议(期望 {},实际 {})", + super::codex_cli::codex_bundle::CLI_VERSION, + version.trim() + )); + } } + #[cfg(debug_assertions)] + let _ = version; let path = path .canonicalize() .map_err(|_| "direct-execution-executor: 无法锚定执行器")?; diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_execution/tests.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_execution/tests.rs index 9f8ddb1f6..f71572b56 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_execution/tests.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_execution/tests.rs @@ -651,6 +651,8 @@ fn patch_executor_identity_is_frozen_and_content_changes_are_rejected() { std::fs::write(&path, "trusted test bytes").unwrap(); let pinned = super::super::codex_cli::codex_bundle::CLI_VERSION; assert!(session.codex_executor().is_err()); + // 开发构建跳过执行器版本门禁;发行构建仍然拒绝版本漂移。 + #[cfg(not(debug_assertions))] assert!(session .bind_codex_executor(&path, "codex-cli 0.155.0") .is_err());