Trusted AI Runtime 是一个用户态 Secure World runtime simulator。这个仓库聚焦一条已经落地的控制面路径:识别高风险请求,把批准动作绑定到当前 runtime 状态,暴露可复验的证据面,再按同一组 binding 完成回放。
┌──────────────────────────────────────────────────────────────────────┐
│ 调用方 / API 客户端 │
└───────────────────────────────┬──────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────────┐
│ FastAPI API (`backend/app/api`) │
│ 输入校验 │ /api/chat │ /api/confirmation/* │ /api/attestation 等 │
└───────────────────────────────┬──────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────────┐
│ 服务层与策略层 (`backend/app/service`, policy) │
│ classify │ action_intent │ prompt observation │ confirmation flow │
└───────────────────────────────┬──────────────────────────────────────┘
│ AF_UNIX
▼
┌──────────────────────────────────────────────────────────────────────┐
│ `mock_ta` (`secure_engine/`) │
│ trusted confirmation │ measurement │ protected artifacts │
│ prompt encoder + risk head │ session state │ attestation report │
└───────────────┬───────────────────────────────────────┬──────────────┘
│ │
│ 证据面 │ 允许过边界的 prompt
▼ ▼
┌──────────────────────────────┐ ┌──────────────────────────────┐
│ `/api/attestation` │ │ Ollama │
│ `/api/components` │ │ 输出再回到 output guard │
│ `/api/measurement-log` │ └──────────────┬───────────────┘
│ challenge / approve payload │ │
└───────────────┬──────────────┘ ▼
│ ┌────────────────────────────────┐
└──────────────────────▶│ output governance + audit log │
│ `logs/audit.jsonl` │
└────────────────────────────────┘
仓库主路径围绕 challenge -> approve -> replay 展开。
/api/chat先做规则分类,再处理可选的action_intent。- 高风险请求在
public_cloud配置下进入受信确认路径。 mock_ta返回 session、digest、runtime binding 和执行证据。/api/confirmation/approve发放带approval_generation的 token。- 回放阶段重新校验 binding,只有通过校验的 prompt 才会发给 Ollama。
公开证据面如下:
| 证据面 | 用途 |
|---|---|
/api/attestation |
看 attestation 和 binding |
/api/components |
看组件 measurement |
/api/measurement-log |
看有序 runtime 事件 |
logs/audit.jsonl |
看本地审计链 |
/api/confirmation/challenge 和 /api/confirmation/approve 属于 validation helper surface。默认配置下这两个接口关闭,只有打开 helper 开关、请求来自 loopback、并带共享 token 时才能访问。
- trusted side 运行在用户态 simulator 中;硬件 TEE 不在当前公开实现范围内。
- attestation 使用本地 verifier material;当前信任根是本地 simulator trust anchor。
classifier、redaction、output governance仍然是规则层。prompt observation是有限模式匹配,只看邮箱、手机号、公有云模型、外部收件人、外部系统这几类高置信信号。- secure inference 是一条窄路径:prompt-bound encoder 加小型 MLP risk head。
- 公开数据集是 curated dataset,当前规模是
96条 train、32条 eval。 - helper surfaces 默认关闭。验证脚本会临时打开它们,并限制在 loopback 上使用 shared token。
- 审计日志是本地 JSONL hash 链,当前用途是单机验证、回放和排查。
make install
cp backend/.env.example .env
set -a
. ./.env
set +a
make check
make validate-control-planemake check跑默认质量门:C build and test、Ruff、mypy、lint-imports、proof-path gate、pytest、code-size gate。make validate-control-plane复用现有标准验证运行时,或者按脚本的临时配置拉起一套运行环境。- 如果环境里没有设置
CONFIRMATION_API_AUTH_TOKEN,验证脚本会为本次运行生成一个随机 token。
Apache-2.0