feat(chv): 对齐 Muse P6 privsep worker + 确定性安全检查层

- cloud/chv/privsep.py(新):Gitea worker 注册表(凭证白名单只含
  GITEA_TOKEN)+ 类型化请求/响应(request_id 绑定、64KB 上限)+
  Unix socket 客户端(超时/崩溃 -> 类型化失败 WorkerRefusal)+
  客户端白名单校验
- cloud/chv/safety.py(新):UntrustedData 来源标记 +
  InjectionScanner 确定性规则(block/flag/allow,中英)+
  redact_secrets + AuditLogger(只记指纹,不记值)+
  audit_inference_request/response
- chv-guest/chv-gitea-worker.py + .service(新):systemd 沙箱化
  worker(SO_PEERCRED 只放 root,仓限 ~/workspace,git 只配 authd
  helper,绝不持 token;输出先扫描再返回)
- chv-guest/chv-sync-worker-client.py(新):agent 侧薄 CLI
- chv-guest/chv-sync.sh:pull/push/status 有 socket 时走 worker,
  否则旧路径 + stderr 警告(过渡兼容)
- cloud/chv/executor.py:_run_guest 前后加推理边界审计钩子
  (best-effort)
- docs/chv-muse-p6-gap.md(新):差距表 + 覆盖边界 + 真机待验证清单
- docs/chv-production-readiness.md:§15
- cloud/tests/test_chv_muse_p6.py(新):43 项

测试:新测试 43/43;全量 cloud 套件 1910 OK(skipped=9);mypy
在新增文件上干净(剩余 4 处为基线旧错 executor.py:1396/1401、
marker_tools.py:142,未动)。
真机验证:未做,排队在 round-11 之后,清单见
docs/chv-muse-p6-gap.md §4。
This commit is contained in:
host committed 2026-11-06 22:31:54 +00:00
1 parent 06c3e172fe
commit 81e4eaf4db
10 files changed
+2071

No files matched your search

+24
View File
@@ -2142,6 +2142,7 @@ class CloudHypervisorExecutor(Executor):
ssh_cmd = self.build_ssh_command(
task, self._guest_host_command(*inner_args, **kwargs),
extra_env=extra_env)
self._audit_inference_request(task, ssh_cmd)
result = self._call_runner(ssh_cmd, timeout=self.task_timeout)
# 方法内 import:见模块头注释的循环导入说明。
from cloud.sandbox import SimpleNamespaceShim, _parse_host_result
@@ -2150,8 +2151,31 @@ class CloudHypervisorExecutor(Executor):
parsed["executor"] = "cloud-hypervisor"
parsed["vm"] = self.vm_name(task)
parsed["api_socket"] = self.api_socket(task)
self._audit_inference_response(task, parsed)
return parsed
def _audit_inference_request(self, task, ssh_cmd):
"""推理边界审计(feat-chv-muse-p6,hatch-safety 的确定性
等价):记一次进推理的请求。只记指纹,不记值;失败
best-effort,绝不中断任务(沿用 _emit 的既定语义)。"""
try:
from cloud.chv.safety import audit_inference_request
audit_inference_request(
str(task.get("id", "")), "dispatch",
" ".join(str(part) for part in ssh_cmd))
except Exception:
pass
def _audit_inference_response(self, task, parsed):
"""推理边界审计:记一次出推理的响应(附结果状态)。"""
try:
from cloud.chv.safety import audit_inference_response
audit_inference_response(
str(task.get("id", "")), "result",
str(parsed.get("status", "")))
except Exception:
pass
def _goal_result(self, task_id, result):
"""客内 host.py goal 输出解析:直接委托给三执行器共享
的 parse_goal_result(cloud/sandbox.py,Local 的