fix(chv): V-3/F1/F2 真机缺陷修复 + V-1/V-4 附带修复

V-3 快照/restore:
- snapshot 改传裸 URL(source_url= 是 restore 的键,服务端
  Could not extract path from URL);快照产物是目录,校验
  改为目录非空,登记计量/剪枝同步支持目录
- restore 起 VMM 前补 _restore_prepare:杀旧 VMM(登记的 +
  未登记跨实例扫描)并清旧 socket,与 _wake_prepare 对等
- hibernate 评估结论:快照 config.json 引用原盘,旧 stop 删
  盘致 restore 必失败;hibernate 的 stop 改 keep_disk=True,
  GC 不删有登记快照的 VM 的盘,restore 前预检快照引用的盘
  (snapshot_disk_missing fail-fast)

F1:re-wake 删旧盘——H5 删私钥致 re-wake 必然生成新 key 对,
旧盘复用时 cloud-init 不重应用新 seed,sshd 仍呈旧 key 而
known_hosts 钉新 key;wake 本就是冷启动,旧盘不是要保留的状态

F2:stop_vm 跨实例按 socket 进程扫描杀未登记 VMM
(/proc cmdline 精确 socket + VMM 二进制名 + 跳过自身/pid 1,
绝不误杀 ch-remote 与他人 VMM)

V-4:remote_command source 失败改 || exit 126 fail-fast;
guest-env 条目 owner 改归 SSH 用户(0600 不变),root 仍 root:root

V-1 附带:build.sh 预建 /app/work(1777 粘滞位 + stat 断言);
host.py default_codex_bin() 改 shutil.which,裸名不再让
health 报 ok:false

测试:新 test_chv_v3_fixes.py 23 项;旧快照测试按目录产物改写;
test_chv* 458 全过,全量 cloud 套件 1930 全过(skipped=8)
This commit is contained in:
host committed 2026-11-08 09:45:00 +00:00
1 parent ef206cf554
commit 65504ae8cb
10 files changed
+962 -91

No files matched your search

+8
View File
@@ -51,6 +51,7 @@ import os
import queue
import re
import shlex
import shutil
import subprocess
import sys
import threading
@@ -291,6 +292,13 @@ def default_codex_bin():
paired = os.path.join(HERE, "bin", "codex")
if os.path.exists(paired):
return paired
# V-1 附带(2026-11-07):旧写法返回裸 "codex",健康检查
# 的 os.path.exists("codex") 查相对路径恒假,health 报
# ok:false。PATH 里找得到就返回绝对路径,找不到才回落
# 裸名(调用方报错时仍能看到名字)。
found = shutil.which("codex")
if found:
return found
return "codex"