宿主:开发构建跳过 Codex 执行器版本门禁
- codex_app_server 逐次审批门禁与 direct_execution 补丁执行器门禁改为按 profile 分流:发行构建仍要求严格等于捆绑侧车固定版本,开发构建(debug_assertions)直接通过 - 修正开发态必然被拒的问题:开发构建从宿主 PATH 解析到的 Codex(本机 codex-cli 0.156.0)与固定版本 codex-cli 0.155.1 不等,且 Linux 与未 stage 侧车时没有可选固定版本,导致 Direct 回合在建连前就被拒 - 发行构建的拒单文案补上期望版本与实际版本,便于排障 - 同步调整受影响的单测:开发构建断言跳过门禁,发行构建断言仍拒绝版本漂移
This commit is contained in:
@@ -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",
|
||||
] {
|
||||
|
||||
@@ -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: 无法锚定执行器")?;
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user