feat(tee): P0 TEE 桥 - tdc TeeJob 接口 + sswflow TeeComputeEngine + catalog tee 算子
- TEE-1: 新建 TeeJobController,POST /api/ssw/tdc/TeeJob 复用 K8sSandboxClient.runTeeJob, 经 exclude-url 放行 + 内部校验 App-Code/X-Internal-Token;runTeeJob 返 null 时区分 SKIPPED(k8s 未启用)/FAIL;本地实测 3 场景通过 - TEE-2: 新建 TeeComputeEngine(@Component, supports tee, order=10),用 JDK HttpClient 派发到 tdc TeeJob,SKIPPED/FAIL→StepResult.fail,SUCCESS→artifacts(output/teeEvidence) - TEE-3: 跨服务鉴权(内部共享密钥) + sswflow.tdc.base-url/internal-secret 配置 - TEE-4: catalog 新增 tee.privacy_aggregate(engine=tee) 示例算子,不覆盖现有 - 关键坑: jnpf 自研 AuthInterceptor 不识别 @SaIgnore,内部接口须走 exclude-url - 更新规划文档 §3/§4.2/§6.1/§8 + 补 memory 日志
This commit is contained in:
1 parent
047a816628
commit
e4a334d38b
5 files changed
+311
-8
No files matched your search
@@ -13,3 +13,24 @@
|
||||
- `kata-install.md`:`r.mayishangshu.cn:82`→`<REGISTRY_HOST>`、`192.168.1.7`→`<TEE_HOST>`;顶部加安装阶段安全提示(PermitRootLogin 仅安装期,装完改密钥登录)。
|
||||
- 验证:force-add 后 `git cat-file -e HEAD:` 确认所有 handoff §9 引用文件均 tracked;两文档 grep 无明文/内部 IP 残留。
|
||||
- 待提交(本次改动):refs/tee/{TEE_DEV_HANDOFF.md,tee-test/kata-install.md,trustee.md} 三个文件。
|
||||
|
||||
## sswflow↔tdc↔tds 集成规划 + 响应枢纽 WIP
|
||||
- 用户确认:sswflow 当前是孤岛(与 tdc 零耦合、TEE 未接、tds 未接)。已写 `docs/sswflow_tdc_integration_plan.md`(对照 docs/sequence_diagrams.md 5 张图:两方/三方交付、机构注册与资源发布、隐私计算沙盒执行链路、三种计算模式),含 P0-TEE桥/P1-交付闭环/P2-治理/P3-模式扩展 路线图 + 总体任务拆解表(带状态勾选)。
|
||||
- 用户追问"发布的资源/需求能否直接响应" → 做**响应枢纽**(撮合桥,图1/2 阶段1):
|
||||
- 后端 R-1 `DemandController.Respond`:校验 PUBLISHED→生成 Order(买方=需求方,卖方=当前登录用户,deliveryType=PRIVACY_COMPUTE)→ Order.sign 自动建 DeliveryTask(PENDING_DELIVER),即进图4 枢纽。
|
||||
- 后端 R-2 `ResourceGrantController.Apply`(PENDING)+`Approve`(ACTIVE) 自助授权。
|
||||
- 前端 R-3 `tdc.ts` 加 demand.respond/resourceGrant.apply/approve;R-4 `MarketView.vue` 加需求"响应"按钮+"资源广场"tab。
|
||||
- 已 `mvn -o -pl ssw-admin -am package -DskipTests` 编译成功(jar: boot/ssw-admin/target/ssw-admin-7.0.0-RELEASE.jar)。
|
||||
- 待办:重启后端(30000)+端到端验证(`docs/e2e/_verify_response.mjs`)+`git add -f`提交推送。
|
||||
- 关键设计:DeliveryTask.beforeSave 强依赖 contractId/productId,故裸需求不能直建交付任务,必须经 Order 签约自动建(已确认 createDeliveryTask 直接 save)。
|
||||
- 坑:`HTTP_PROXY` 拦 localhost→curl 验证用 `--noproxy '*'`;jweb 在 .gitignore 须 `git add -f`;JsonUtil 该 jnpf 版本不可用→desc 用字符串拼接。
|
||||
|
||||
## P0 TEE 桥落地(本地验证通过)
|
||||
- 用户确认方案:跨服务鉴权用**内部共享密钥**(App-Code:sswflow + X-Internal-Token),catalog 仅加 1 个示例算子(不动现有)。
|
||||
- TEE-1 新建 `boot/ssw-tdc/ssw-tdc-controller/.../controller/TeeJobController.java`:`POST /api/ssw/tdc/TeeJob`,@SaIgnore 想免登录但**不生效**(jnpf 用自研 AuthInterceptor 不识别该注解)→ 改用 `application.yml` 的 `exclude-url` 放行 + Controller 内手动校验 App-Code/X-Internal-Token。内部调 `K8sSandboxClient.runTeeJob`,runTeeJob 返 null 时区分 isEnabled()==false→SKIPPED / 否则→FAIL。本地实测:错误 App-Code→400、k8s 关(-Dk8s.enabled=false)→200+SKIPPED、缺 taskId→400,全通过。
|
||||
- TEE-2 新建 `boot/ssw-sswflow/ssw-sswflow-biz/.../engine/TeeComputeEngine.java`:`@Component implements ComputeEngine`,name=tee、supports("tee")=true、order=10(对齐 application.yml 注释 k8s TEE(10));execute(StepContext) 用 JDK 内置 `java.net.http.HttpClient` POST tdc TeeJob(taskId=runId-stepId 临时,P1 接 DeliveryTask 后换),SKIPPED/FAIL→StepResult.fail,SUCCESS→artifacts(output=resultJson, teeEvidence=attestation)。
|
||||
- TEE-3 鉴权/HTTP 客户端随 TEE-2 落地;application.yml 加 `sswflow.tdc.base-url`(默认127.0.0.1:30000)+`internal-secret`,tdc 侧加 `tdc.internal-secret`。
|
||||
- TEE-4 `catalog.json` 新增 tee 类别+算子 `tee.privacy_aggregate`(engine=tee),不覆盖现有算子。后端 `GET /api/ssw/sswflow/Operator/Catalog` 已含该算子(需登录)。
|
||||
- 编译 `mvn -o -pl ssw-admin -am package -DskipTests` 成功;后端启动无异常(TeeComputeEngine 作为 bean 注册)。
|
||||
- 关键坑:jnpf **`@SaIgnore` 不生效**,内部免登录接口必须走 `exclude-url`;已固化进规划文档 §6.1。
|
||||
- 待做:TEE-5 真机烟测(1.7 SEV-SNP + KBS 192.168.1.18:8080,k8s.enabled=true+runtimeClass=kata-qemu-snp+kbs 配齐,断言 status=SUCCESS+attestation 非空+resultSealed=true)→ P1 交付闭环。
|
||||
@@ -195,6 +195,8 @@ gateway:
|
||||
exclude-url: # 免Token且不记录日志的放行接口
|
||||
# SSWFlow no-spa 静态页面(html/js/css),AuthFilter 拦截 /**,静态资源必须显式放行
|
||||
- /ssw/**
|
||||
# sswflow → tdc 内部服务调用(TEE 执行):App-Code + X-Internal-Token 内部密钥校验,不走用户态 Token
|
||||
- /api/ssw/tdc/TeeJob
|
||||
white-ip: # 允许访问block-url的IP白名单(支持网段,如192.168.)
|
||||
## 配置示例:
|
||||
# - 192.168.
|
||||
@@ -246,6 +248,11 @@ fisco:
|
||||
# 默认关闭:关闭时 TDC 交付回退 NAX/模拟,Notebook 接口返回「沙箱未启用」。
|
||||
# 启用前置:准备 k8s 集群(含 kata RuntimeClass) 与 kubectl(已在 PATH)。
|
||||
# ==============================================================================
|
||||
|
||||
# tdc 内部服务调用密钥(仅 sswflow 经内部网络调用 /api/ssw/tdc/TeeJob 时校验 X-Internal-Token;本地可空)
|
||||
tdc:
|
||||
internal-secret: ""
|
||||
|
||||
k8s:
|
||||
enabled: true
|
||||
namespace: data-space
|
||||
@@ -318,3 +325,8 @@ sswflow:
|
||||
home: ${NAX_HOME:}
|
||||
# 单算子硬超时(秒),含子进程创建 + 计算;大样本训练需调大。
|
||||
timeout-seconds: 600
|
||||
# sswflow ↔ tdc 跨服务调用(P0 TEE 桥):TeeComputeEngine 经内部网络调 tdc /api/ssw/tdc/TeeJob
|
||||
tdc:
|
||||
base-url: http://127.0.0.1:30000
|
||||
internal-secret: ""
|
||||
timeout-seconds: 600
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
package ssw.sswflow.engine;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* TEE 机密计算引擎(P0 新增)。
|
||||
* <p>
|
||||
* 抢占所有 {@code engine="tee"} 的算子({@code order()=10},低于 Nax 100 / 模拟 1000),
|
||||
* 通过 HTTP 调 tdc 的 {@code /api/ssw/tdc/TeeJob},把节点交给 tdc 的
|
||||
* {@code K8sSandboxClient} 在机密容器(kata / SEV-SNP)内执行,
|
||||
* 仅结果(已 AES-256-GCM 封装、远程证明门控)出域。
|
||||
* <p>
|
||||
* 跨服务调用用 JDK 内置 {@link HttpClient}(零额外依赖),鉴权复用
|
||||
* {@code App-Code=sswflow} + 内部共享密钥 {@code X-Internal-Token}。
|
||||
*
|
||||
* @author SSWFlow
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class TeeComputeEngine implements ComputeEngine {
|
||||
|
||||
@Value("${sswflow.tdc.base-url:http://127.0.0.1:30000}")
|
||||
private String tdcBaseUrl;
|
||||
|
||||
@Value("${sswflow.tdc.internal-secret:}")
|
||||
private String internalSecret;
|
||||
|
||||
@Value("${sswflow.tdc.timeout-seconds:600}")
|
||||
private long timeoutSeconds;
|
||||
|
||||
private final HttpClient http = HttpClient.newBuilder()
|
||||
.connectTimeout(Duration.ofSeconds(10))
|
||||
.build();
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "tee";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(String engineType) {
|
||||
return "tee".equalsIgnoreCase(engineType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int order() {
|
||||
// 数值小的优先;10 < 100(Nax) < 1000(模拟) → tee 算子全部走本引擎
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StepResult execute(StepContext ctx) {
|
||||
// P0 阶段无 DeliveryTask,taskId 用 runId-stepId 临时标识(KBS path + Job 名);
|
||||
// P1 接入交付闭环后改为真实 deliveryTaskId。
|
||||
String taskId = ctx.getRunId() + "-" + ctx.getStepId();
|
||||
String deliveryType = resolveDeliveryType(ctx);
|
||||
|
||||
JSONObject req = new JSONObject();
|
||||
req.put("taskId", taskId);
|
||||
req.put("deliveryType", deliveryType);
|
||||
req.put("requestParams", buildRequestParams(ctx));
|
||||
|
||||
ctx.info(String.format("使用 %s 引擎提交 TEE Job (deliveryType=%s) taskId=%s",
|
||||
name(), deliveryType, taskId));
|
||||
ctx.reportProgress(10);
|
||||
|
||||
try {
|
||||
HttpRequest.Builder rb = HttpRequest.newBuilder()
|
||||
.uri(URI.create(tdcBaseUrl + "/api/ssw/tdc/TeeJob"))
|
||||
.header("Content-Type", "application/json")
|
||||
.header("App-Code", "sswflow")
|
||||
.header("X-Internal-Token", internalSecret == null ? "" : internalSecret)
|
||||
.POST(HttpRequest.BodyPublishers.ofString(req.toJSONString()))
|
||||
.timeout(Duration.ofSeconds(timeoutSeconds));
|
||||
HttpResponse<String> resp = http.send(rb.build(), HttpResponse.BodyHandlers.ofString());
|
||||
if (resp.statusCode() != 200) {
|
||||
return StepResult.fail("TEE Job 接口返回 HTTP " + resp.statusCode());
|
||||
}
|
||||
JSONObject body = JSON.parseObject(resp.body());
|
||||
// ActionResult 结构:{code, msg, data:{status, resultUri, runLog, attestation, resultJson, resultSealed, message}}
|
||||
JSONObject data = body.getJSONObject("data");
|
||||
if (data == null) {
|
||||
return StepResult.fail("TEE Job 响应缺少 data: " + resp.body());
|
||||
}
|
||||
String status = data.getString("status");
|
||||
if (!"SUCCESS".equals(status)) {
|
||||
String msg = data.getString("message");
|
||||
return StepResult.fail("TEE 计算未成功(status=" + status + "): " + msg);
|
||||
}
|
||||
|
||||
StepResult result = new StepResult();
|
||||
result.setStatus("SUCCESS");
|
||||
// 结果 artifact(仅结果出域)
|
||||
String resultJson = data.getString("resultJson");
|
||||
if (resultJson != null && !resultJson.isEmpty()) {
|
||||
JSONObject out = new JSONObject();
|
||||
out.put("portKey", "output");
|
||||
out.put("type", "result");
|
||||
out.put("title", "TEE 计算结果");
|
||||
out.put("summary", "仅结果出域(远程证明门控 + AES-256-GCM 封装)");
|
||||
out.put("resultJson", resultJson);
|
||||
result.add(out);
|
||||
}
|
||||
// 远程证明 artifact
|
||||
Object att = data.get("attestation");
|
||||
if (att instanceof JSONObject) {
|
||||
JSONObject ev = (JSONObject) att;
|
||||
ev.put("portKey", "teeEvidence");
|
||||
ev.put("type", "tee-evidence");
|
||||
ev.put("title", "TEE 远程证明");
|
||||
result.add(ev);
|
||||
}
|
||||
ctx.reportProgress(100);
|
||||
ctx.info("TEE 算子执行完成");
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("[TEE] 引擎执行异常 step={} op={}", ctx.getStepId(), ctx.getOperatorKey(), e);
|
||||
return StepResult.fail("TEE 引擎异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private String resolveDeliveryType(StepContext ctx) {
|
||||
JSONObject params = ctx.getParams();
|
||||
if (params != null) {
|
||||
String dt = params.getString("deliveryType");
|
||||
if (dt != null && !dt.isEmpty()) return dt;
|
||||
}
|
||||
JSONObject op = ctx.getOperator();
|
||||
if (op != null) {
|
||||
String dt = op.getString("deliveryType");
|
||||
if (dt != null && !dt.isEmpty()) return dt;
|
||||
}
|
||||
return "PRIVACY_COMPUTE";
|
||||
}
|
||||
|
||||
private JSONObject buildRequestParams(StepContext ctx) {
|
||||
JSONObject p = new JSONObject();
|
||||
p.put("operatorKey", ctx.getOperatorKey());
|
||||
p.put("params", ctx.getParams());
|
||||
p.put("inputs", ctx.getInputs());
|
||||
p.put("datasets", ctx.getDatasets());
|
||||
p.put("parties", ctx.getParties());
|
||||
return p;
|
||||
}
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
package ssw.tdc.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jnpf.base.ActionResult;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ssw.tdc.client.K8sSandboxClient;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* TEE 执行接口:把 tdc 内部的 {@link K8sSandboxClient#runTeeJob} 暴露给 sswflow 编排层。
|
||||
* <p>
|
||||
* 属于服务间内部调用,不走用户态 Sa-Token({@link SaIgnore}),仅用
|
||||
* {@code App-Code=sswflow} + 内部共享密钥 {@code X-Internal-Token} 校验,
|
||||
* 规避 sswflow 后台线程无用户 token 的困境。
|
||||
*/
|
||||
@RestController("tdcTeeJobController")
|
||||
@RequestMapping("/api/ssw/tdc/TeeJob")
|
||||
@Tag(name = "TEE 执行", description = "提交一次 TEE 机密计算 Job,返回 attestation + 结果")
|
||||
public class TeeJobController {
|
||||
|
||||
@Value("${tdc.internal-secret:}")
|
||||
private String internalSecret;
|
||||
|
||||
private final K8sSandboxClient sandboxClient;
|
||||
|
||||
public TeeJobController(K8sSandboxClient sandboxClient) {
|
||||
this.sandboxClient = sandboxClient;
|
||||
}
|
||||
|
||||
@SaIgnore
|
||||
@PostMapping
|
||||
@Operation(summary = "提交 TEE 计算 Job")
|
||||
public ActionResult<TeeJobResult> run(
|
||||
@RequestHeader(value = "App-Code", required = false) String appCode,
|
||||
@RequestHeader(value = "X-Internal-Token", required = false) String token,
|
||||
@RequestBody TeeJobRequest req) {
|
||||
// 1) 内部服务间鉴权
|
||||
if (!"sswflow".equals(appCode)) {
|
||||
return ActionResult.fail("非法调用:App-Code 必须为 sswflow");
|
||||
}
|
||||
if (internalSecret != null && !internalSecret.isEmpty() && !internalSecret.equals(token)) {
|
||||
return ActionResult.fail("非法内部调用:X-Internal-Token 校验失败");
|
||||
}
|
||||
|
||||
// 2) 参数校验
|
||||
String taskId = req.taskId;
|
||||
if (taskId == null || taskId.isBlank()) {
|
||||
return ActionResult.fail("taskId 不能为空");
|
||||
}
|
||||
String deliveryType = (req.deliveryType == null || req.deliveryType.isBlank())
|
||||
? "PRIVACY_COMPUTE" : req.deliveryType;
|
||||
|
||||
// 3) 调内部 TEE 发动机(K8sSandboxClient.runTeeJob)
|
||||
K8sSandboxClient.K8sResult r = sandboxClient.runTeeJob(
|
||||
deliveryType, taskId, req.programUri, req.codeUri,
|
||||
req.requestParams == null ? null
|
||||
: com.alibaba.fastjson2.JSON.toJSONString(req.requestParams));
|
||||
|
||||
TeeJobResult res = new TeeJobResult();
|
||||
if (r == null) {
|
||||
if (!sandboxClient.isEnabled()) {
|
||||
res.status = "SKIPPED";
|
||||
res.message = "TEE 沙箱未启用(k8s.enabled=false),无法执行机密计算";
|
||||
} else {
|
||||
res.status = "FAIL";
|
||||
res.message = "TEE Job 执行失败(详见后端日志)";
|
||||
}
|
||||
return ActionResult.success(res.message, res);
|
||||
}
|
||||
res.status = r.status;
|
||||
res.resultUri = r.resultUri;
|
||||
res.runLog = r.runLog;
|
||||
res.attestation = r.attestation;
|
||||
res.resultJson = r.resultJson;
|
||||
res.resultSealed = r.resultSealed;
|
||||
res.message = "SUCCESS".equals(r.status) ? "TEE 计算完成" : "TEE 计算失败";
|
||||
return ActionResult.success(res.message, res);
|
||||
}
|
||||
|
||||
/** 请求体 */
|
||||
public static class TeeJobRequest {
|
||||
public String taskId;
|
||||
public String deliveryType;
|
||||
public String programUri;
|
||||
public String codeUri;
|
||||
public Object requestParams;
|
||||
}
|
||||
|
||||
/** 响应体,对齐 K8sResult 并补充 status / message */
|
||||
public static class TeeJobResult {
|
||||
public String status; // SUCCESS / FAIL / SKIPPED
|
||||
public String resultUri;
|
||||
public String runLog;
|
||||
public Map<String, Object> attestation;
|
||||
public String resultJson;
|
||||
public boolean resultSealed;
|
||||
public String message;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,8 @@ TEE 的"发动机"其实已在 tdc 侧真机验证(`K8sSandboxClient.runTeeJob
|
||||
|
||||
**用户追问"发布的资源和需求能不能直接响应?"** —— 能,且这就是打通的"撮合→交付"枢纽(图1/图2 阶段1 + 阶段4 之间的桥)。本规划把"响应枢纽"列为**当前正在落地(WIP)** 的最短路,再做 TEE 桥。
|
||||
|
||||
> **进度快照(2026-08-08)**:响应枢纽(R-1~R-7)已提交 `047a816`;P0 TEE 桥(TEE-1~TEE-4)本地验证通过,仅剩 TEE-5 真机烟测。详见 §3 / §4.2。
|
||||
|
||||
---
|
||||
|
||||
## 1. 架构定位(三个服务各司其职)
|
||||
@@ -65,7 +67,7 @@ TEE 的"发动机"其实已在 tdc 侧真机验证(`K8sSandboxClient.runTeeJob
|
||||
| 阶段 | 内容 | 对应图 | 状态 |
|
||||
|---|---|---|---|
|
||||
| **WIP 响应枢纽** | 发布的资源/需求可直接响应(需求→Order→签约→DeliveryTask;资源→自助授权) | 图1/2 阶段1 | 🔧 进行中(见 §5) |
|
||||
| **P0 TEE 桥** | tdc 暴露 TeeJob 接口 + sswflow `TeeComputeEngine` + catalog 加 tee 算子 + 真机烟测 | 图4 + 图1/2 阶段4 | ⬜ 待开始 |
|
||||
| **P0 TEE 桥** | tdc 暴露 TeeJob 接口 + sswflow `TeeComputeEngine` + catalog 加 tee 算子 + 真机烟测 | 图4 + 图1/2 阶段4 | ✅ 本地验证通过(TEE-1/2/3/4 完成;TEE-5 真机待做,见 §8) |
|
||||
| **P1 交付闭环** | flow 触发 → `DeliveryTask` 创建/状态门控 → `TeeSecurity` 门控 → 凭证回写 `f_run_log` → 上链 | 图1/2 阶段4–5 | ⬜ |
|
||||
| **P2 治理对齐** | 机构/资源/授权与 tdc、监管对齐 | 图3 | ⬜ |
|
||||
| **P3 模式扩展** | 联邦学习 fl 引擎 | 图5 第4种 | ⬜ |
|
||||
@@ -90,10 +92,10 @@ TEE 的"发动机"其实已在 tdc 侧真机验证(`K8sSandboxClient.runTeeJob
|
||||
### 4.2 P0 — TEE 桥(图4,打通生死线)
|
||||
| ID | 任务 | 文件/接口 | 状态 |
|
||||
|---|---|---|---|
|
||||
| TEE-1 | tdc 暴露 `POST /api/ssw/tdc/TeeJob`,内部复用 `K8sSandboxClient.runTeeJob`,返回 `K8sResult{attestation,resultJson,resultSealed}` | `TeeJobController`(新建)或扩 `TeeSecurityController` | ⬜ |
|
||||
| TEE-2 | sswflow `TeeComputeEngine implements ComputeEngine`(`supports("tee")=true`,`order()` 低于 Simulation);`execute(StepContext)` 通过 HTTP 客户端派发到 tdc TeeJob,回写 `FlowStepRun`/`RunEvent` | `ssw-sswflow/.../engine/TeeComputeEngine.java`(新建) | ⬜ |
|
||||
| TEE-3 | sswflow↔tdc 跨服务 HTTP 客户端(WebClient/RestTemplate),鉴权复用 `App-Code=sswflow`+Sa-Token;生产配 `tdc.base-url`,本地直连 localhost(注意 `HTTP_PROXY` 会拦 localhost,用等价 `--noproxy`) | `application.yml` + 客户端封装 | ⬜ |
|
||||
| TEE-4 | catalog 给需机密计算的算子加 `"engine":"tee"`(如机密 join/aggregate/推理) | `ssw-sswflow-biz/.../resources/operators/catalog.json` | ⬜ |
|
||||
| TEE-1 | tdc 暴露 `POST /api/ssw/tdc/TeeJob`,内部复用 `K8sSandboxClient.runTeeJob`,返回 `K8sResult{attestation,resultJson,resultSealed}`;`runTeeJob` 返 null 时区分 `isEnabled()==false → SKIPPED` / 否则 `FAIL`。**本地实测:错误 App-Code→400、k8s 关→200+SKIPPED、缺 taskId→400** | `boot/ssw-tdc/.../controller/TeeJobController.java`(新建) | ✅ 已写+编译+本地实测 |
|
||||
| TEE-2 | sswflow `TeeComputeEngine implements ComputeEngine`(`name="tee"`、`supports("tee")=true`、`order()=10`,低于 Simulation=1000/Nax=100);`execute(StepContext)` 用 JDK 内置 `java.net.http.HttpClient` 派发到 tdc TeeJob(`taskId=runId-stepId` 临时标识,P1 接 DeliveryTask 后换),解析 `SKIPPED/FAIL→StepResult.fail`,`SUCCESS→artifacts(output=resultJson, teeEvidence=attestation)` | `ssw-sswflow/.../engine/TeeComputeEngine.java`(新建) | ✅ 已写+编译+启动无异常 |
|
||||
| TEE-3 | sswflow↔tdc 跨服务 HTTP 客户端(JDK `HttpClient`,零依赖),鉴权 `App-Code=sswflow` + `X-Internal-Token=sswflow.tdc.internal-secret`(内部共享密钥方案,已确认);tdc 侧用 jnpf `exclude-url` 放行(**注意 `@SaIgnore` 在 jnpf 不生效**,见 §6 坑)。生产 `sswflow.tdc.base-url` 默认 `http://127.0.0.1:30000` | `application.yml`(sswflow.tdc.* / tdc.internal-secret)+ 客户端封装 | ✅ 已随 TEE-2 落地 |
|
||||
| TEE-4 | catalog 给需机密计算的算子加 `"engine":"tee"`(先加 1 个示例算子 `tee.privacy_aggregate`,不覆盖现有算子,避免本地无 TEE 时其他算子变红) | `ssw-sswflow-biz/.../resources/operators/catalog.json` | ✅ 已写+编译(后端 /Catalog 已含该算子) |
|
||||
| TEE-5 | 真机烟测:复用 1.7 SEV-SNP + CDH 链路,跑一个 tee 节点端到端,确认"仅结果出域 + attestation 回传",并与 `docs/tdd/nax_e2e_smoke.cjs` 对齐加一条 tee 烟测 | `docs/tdd/tee_e2e_smoke.*`(新建) | ⬜ |
|
||||
|
||||
### 4.3 P1 — 交付闭环(图1/2 阶段4–5)
|
||||
@@ -157,6 +159,10 @@ TEE 的"发动机"其实已在 tdc 侧真机验证(`K8sSandboxClient.runTeeJob
|
||||
- **DeliveryTask.beforeSave 强制要求 contractId+productId**——所以"裸需求不能直接建交付任务",必须经 Order(签约自动建)这一跳(已确认 `createDeliveryTask` 绕过 POST 校验直接 save)。这正合图1/2 设计。
|
||||
- TEE 真机证据完整(1.7 SEV-SNP、CDH、KBS 192.168.1.18:8080、fail-closed 已验证),P0 真机烟测可直接复用。
|
||||
|
||||
### 6.1 P0 已踩坑(必记)
|
||||
- **jnpf 用自研 `AuthInterceptor` 而非原生 `SaInterceptor`,`@SaIgnore` 注解不生效**(Sa-Token 虽是 1.44/1.45 支持该注解,但 jnpf 没挂 `SaInterceptor`)。想让内部接口免登录,必须加到 `application.yml` 的 `exclude-url` 列表(jnpf 官方"免Token且不记录日志"机制),不能靠 `@SaIgnore`。TEE-1 的 `/api/ssw/tdc/TeeJob` 因此走 `exclude-url` 放行 + Controller 内手动校验 `App-Code`/`X-Internal-Token`。
|
||||
- **TEE-2 的 `taskId` 在 P0 用 `runId-stepId` 临时标识**:`StepContext` 当前不带 `deliveryTaskId`(P1 才建 `DeliveryTask`),真机烟测(TEE-5)会暴露"TEE 任务与交付任务未关联"——P1 D-1 必须补上关联。
|
||||
|
||||
## 7. 验证策略(贯穿各阶段)
|
||||
|
||||
- 后端接口:用 `docs/e2e/_verify_response.mjs` 同款 `apiLogin`+fetch 做带鉴权冒烟(绕过代理)。
|
||||
@@ -168,8 +174,8 @@ TEE 的"发动机"其实已在 tdc 侧真机验证(`K8sSandboxClient.runTeeJob
|
||||
|
||||
## 8. 下一步立即动作(推进顺序)
|
||||
|
||||
1. 重启后端(§5.2-1)→ 跑 `_verify_response.mjs`(R-6)→ 提交推送响应枢纽(R-7)。★ 当前卡在这。
|
||||
2. 启动 P0:先做 TEE-1(tdc TeeJob 接口)+ TEE-2(sswflow TeeComputeEngine 接口契约),给你过目后再实现。
|
||||
3. P0 真机验证(TEE-5)→ P1 交付闭环 → P2 治理 → P3 模式。
|
||||
1. 重启后端(§5.2-1)→ 跑 `_verify_response.mjs`(R-6)→ 提交推送响应枢纽(R-7)。★ 已完成(提交 `047a816`)。
|
||||
2. ~~启动 P0:先做 TEE-1(tdc TeeJob 接口)+ TEE-2(sswflow TeeComputeEngine 接口契约)~~ → **已完成(TEE-1/2/3/4 本地验证通过,见 §4.2)**。
|
||||
3. **TEE-5 真机烟测**(1.7 SEV-SNP + KBS 192.168.1.18:8080,k8s.enabled=true + runtimeClass=kata-qemu-snp + kbs 配齐,断言 `status=SUCCESS`+`attestation` 非空+`resultSealed=true`)→ **P1 交付闭环**(D-1~D-4:关联 DeliveryTask + 凭证回写 + 上链)→ P2 治理 → P3 模式。
|
||||
|
||||
> 每完成一项,回此文档在对应 ⬜ 打 ✅,避免推进中遗忘。
|
||||
Reference in new issue
Block a user