fix(chv-muse-r11fix): 执行器以 sudo 调 chv-cell(缺陷 1)

chv-cell 须 root(nspawn + 配网),执行器经 SSH 以 chv 身份调,
此前无 sudo 即 rc=2。改 _guest_host_command 在单元开时前缀 sudo
(探针 p2.log 的手动调用即 sudo chv-cell run;chv 的 NOPASSWD
sudo 来自 seed users 块)。关时原命令不变。
This commit is contained in:
host committed 2026-11-07 03:52:34 +00:00
1 parent e02828c590
commit b41fb67026
2 files changed
+21 -13

No files matched your search

+9 -6
View File
@@ -1,9 +1,10 @@
"""round-11 集成补洞:执行器接 nspawn 单元(P2 差距表 §4)。
只测 _guest_host_command 的命令构造与 CHV_CELL_ENABLED 开关:
单元开(默认)时 host.py 调用改为 chv-cell run -- python3
单元开(默认)时 host.py 调用改为 sudo chv-cell run -- python3
/app/host.py --state … --codex-home … --sandbox
danger-full-access …;单元关时走原命令;非法开关值即
danger-full-access …(sudo 不可省:chv-cell 须 root,执行器以
chv 身份调;round-11 真机修复);单元关时走原命令;非法开关值即
ValueError。只用 mock,不启动真实 VM、不连真实网络。
"""
@@ -83,7 +84,7 @@ class CellCommandTest(CellCase):
ex = self.make_exec()
cmd = ex._guest_host_command("status", "--task", "t1")
self.assertEqual(cmd, [
"chv-cell", "run", "--",
"sudo", "chv-cell", "run", "--",
"python3", "/app/host.py",
"--state", "/home/chv/.codex/host-state.json",
"--codex-home", "/home/chv/.codex",
@@ -93,7 +94,7 @@ class CellCommandTest(CellCase):
def test_cell_on_explicit_1(self):
ex = self.make_exec(env_extra={"CHV_CELL_ENABLED": "1"})
cmd = ex._guest_host_command("status", "--task", "t1")
self.assertEqual(cmd[:3], ["chv-cell", "run", "--"])
self.assertEqual(cmd[:4], ["sudo", "chv-cell", "run", "--"])
self.assertIn("--sandbox", cmd)
self.assertEqual(
cmd[cmd.index("--sandbox") + 1], "danger-full-access")
@@ -120,7 +121,7 @@ class CellCommandTest(CellCase):
model="m1", effort="low", approval="ask",
model_provider="sub2api", sandbox="read-only")
self.assertEqual(cmd, [
"chv-cell", "run", "--",
"sudo", "chv-cell", "run", "--",
"python3", "/app/host.py",
"--state", "/home/chv/.codex/host-state.json",
"--codex-home", "/home/chv/.codex",
@@ -164,12 +165,14 @@ class CellCommandTest(CellCase):
def test_cell_wiring_reaches_ssh_command(self):
# 接线落到 SSH 层:build_ssh_command 的远端命令里
# chv-cell 前缀在、python3 在其后。
# sudo chv-cell 前缀在、python3 在其后。
ex = self.make_exec()
inner = ex._guest_host_command("status", "--task", "t1")
cmd = ex.build_ssh_command({"id": "t1"}, inner)
self.assertIn("sudo", cmd)
self.assertIn("chv-cell", cmd)
self.assertIn("danger-full-access", cmd)
self.assertLess(cmd.index("sudo"), cmd.index("chv-cell"))
self.assertLess(cmd.index("chv-cell"), cmd.index("python3"))