feat-chv-muse-p9: 推理与遥测受限通道(Sentinel 预审 + 遥测最小化 + 训练退出开关)

- 受限推理通道:cloud/chv/inference_channel.py(origin 解析、
  allowlist、上限、Sentinel 预审),执行器 _run_with_vm 起 VM 前
  必过 _inference_gate(allow 才继续,deny/ask 审计 + fail-closed,
  任务级 extra_env 合并进预审);host.py 第二道防线(_server_command
  的 origin 结构校验 + Server.request 超时/重试走 env)。
  origin 规则:https 公网网关(只 443);http 只接受本地中继
  (字面环回/私网 IP,如 http://172.17.0.1:28084,端口保留,
  无 DNS、无重绑定,allowlist 与单次能力照常);未知 provider
  标签走默认网关(与 _server_command 一致)。
- sentinel.py:从 P5(25bcd35)取的超集版本 + 推理连接器条目
  (POST /v1/responses、GET /v1/models;scheme/端口只 https/443,
  本地中继不走 evaluate,不把 http 加进表)。
- 遥测最小化:cloud/chv/telemetry.py(字段白名单、确定性采样、
  落盘失败不影响任务、token 未回传记 null)+ 训练退出开关
  (默认开,本项目决定;关后轨迹不再产生;损坏 fail-closed;变更审计)。
- 访问边界:docs/chv-access-boundary.md(运营访问口径 + 审计钩子,
  不冒充技术不可访问;Confidential VM 明确未做)。
- 测试:cloud/tests/test_chv_muse_p9.py 51 组全过;5 个旧文件
  的 make_exec 配假 origin + 假解析器(新 fail-closed 门要求的
  测试配置);全量 cloud 套件 1918 OK(skipped=8)。
  详见 docs/chv-muse-p9-gap.md(含自定清单与真机待验证清单)。
This commit is contained in:
host committed 2026-11-06 23:03:06 +00:00
1 parent 06c3e172fe
commit c06ba50983
13 files changed
+1922 -11

No files matched your search

+50
View File
@@ -2245,6 +2245,54 @@ class CloudHypervisorExecutor(Executor):
"interrupted_reason": reason,
}
def _inference_gate(self, task: dict,
model_provider: str | None,
extra_env: dict | None = None) -> None:
"""feat-chv-muse-p9:起 VM 前的推理出口预审。
模型调用只允许走受限推理通道(见 inference_channel):
allow → 审计放行;deny/ask → 审计 + ChvFailure 起 VMM
前 fail-closed(ask 在这里就是 deny:wake 等不了审批
UI)。解析器可注入(`sentinel_resolver` 属性,测试用
假解析器)。origin 取任务级 extra_env 覆盖执行器 env;
origin 非法同样记 deny,不抛裸 ValueError。审计 detail
只含 VM 名/主机/verdict,不含任何凭证值。
"""
from cloud.chv.inference_channel import check_inference_call
name = self.vm_name(task)
env = dict(self._env)
if extra_env:
env.update(extra_env)
try:
check = check_inference_call(
model_provider, env=env,
resolve=getattr(self, "sentinel_resolver", None))
except ValueError as exc:
self._emit("inference_egress_deny", task,
"vm=%s reasons=bad_origin" % name)
raise ChvFailure(
"inference_egress_denied",
"推理 origin 配置非法,拒绝启动:%s" % exc)
decision = check.decision
if decision.verdict == "allow":
capability = decision.capability
request = check.request
assert capability is not None # allow 恒带严格能力
assert request is not None # allow 恒带已解析请求
self._emit("inference_egress_allow", task,
"vm=%s host=%s capability=%s"
% (name, request.host, capability.id))
return
host = check.request.host if check.request is not None else ""
self._emit("inference_egress_" + decision.verdict, task,
"vm=%s host=%s reasons=%s"
% (name, host, ",".join(decision.reasons)))
raise ChvFailure(
"inference_egress_denied",
"推理出口预审未通过(%s),拒绝启动:请运维确认 "
"provider 与 CHV_INFERENCE_ORIGIN/CHV_INFERENCE_ALLOW_HOSTS"
% decision.verdict)
def _run_with_vm(self, task, inner_args, goal=False, extra_env=None,
**kwargs):
"""每任务 VM 生命周期(冷启动正式路径,feat-chv-arch95
@@ -2266,6 +2314,8 @@ class CloudHypervisorExecutor(Executor):
feat-chv-secfix(H2):extra_env 透传给 wake_vm(密钥
子集在 provisioned 模式下随 seed 投递),再透传给
_run_guest(远程命令 source 客内密钥文件)。"""
self._inference_gate(task, kwargs.get("model_provider"),
extra_env=extra_env)
self.wake_vm(task, extra_env=extra_env)
try:
try: