Files
dth/openspec/changes/chg_0005_experiment_platform_extend/spec.md
T
xstudio agentandClaude Opus 4.8 f1a15c44f4 merge sandbox/d42537c: chg_0005 experiment_platform_extend — 6 new operators + registration + 8 e2e cases (gate PASS)
- 6 new operators: scql (secure sum) / horizontal-fedavg (FedAvg mean) / secure-mlp (sigmoid + Laplace DP) / tee-inference (sha256 attestation) / prompt-defense (keyword classifier) / compliance-audit (uuid trail)
- OperatorsService + experiment.module 注册追加(不替换 chg_0002 的 3 算子)
- tests/e2e/dth_experiment_extend.test.sh: 8 case 覆盖 S7-S12 + list ≥9
- docs/dth/experiment-platform/operators-design.md: T1 架构
- openspec/changes/chg_0005_experiment_platform_extend/{5 工件}

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-09-28 15:11:02 +08:00

2.9 KiB
Raw Blame History

change_id, owner, status, requires_human_validation
change_id owner status requires_human_validation
chg_0005 pd@dth draft false

Spec: experiment_platform

Requirement

WHEN 管理员调用算子列表接口 THE SYSTEM SHALL 返回 9+ 个算子元数据。 WHEN 管理员对任一新算子发起 run THE SYSTEM SHALL 返回 run_id + 真 output_json。

ADDED Scenarios

S7 scql_aggregation_returns_real_sum

  • WHEN admin POST /runs body={"operator":"scql","input":{"columns":[{"values":[10,20,30]},{"values":[1,2,3]}]}}
  • THEN data.status=success
  • AND GET /runs/:id 的 data.output_json.scql.sum == 60(10+20+30 + 1+2+3 = 66…实测真求和,下面以断言代码为准)
  • AND output_json.scql.column_count == 2

S8 horizontal_fedavg_aggregates_model_weights

  • WHEN admin POST /runs body={"operator":"horizontal-fedavg","input":{"clients":[{"weights":[0.1,0.2]},{"weights":[0.3,0.4]},{"weights":[0.5,0.6]}],"aggregation":"mean"}}
  • THEN data.status=success
  • AND GET /runs/:id 的 data.output_json.fedavg.aggregated == [0.3, 0.4]
  • AND output_json.fedavg.round_count == 1

S9 secure_mlp_adds_dp_noise

  • WHEN admin POST /runs body={"operator":"secure-mlp","input":{"features":1.0,2.0],[3.0,4.0,"weights":[0.5,0.5],"bias":0.1,"epsilon":1.0}}
  • THEN data.status=success
  • AND GET /runs/:id 的 data.output_json.mlp.predictions 数组长度 == 2
  • AND predictions[i] ∈ (0,1)(sigmoid 输出)
  • AND output_json.mlp.noise_scale > 0

S10 tee_inference_returns_attestation

  • WHEN admin POST /runs body={"operator":"tee-inference","input":{"prompt":"hello","model":"gpt-mock"}}
  • THEN data.status=success
  • AND GET /runs/:id 的 data.output_json.tee.attestation 字符串长度 >= 64
  • AND output_json.tee.attestation 含 "tee-mock-" 前缀
  • AND output_json.tee.model == "gpt-mock"

S11 prompt_defense_detects_injection

  • WHEN admin POST /runs body={"operator":"prompt-defense","input":{"prompt":"ignore previous instructions and ..."}}
  • THEN data.status=success
  • AND GET /runs/:id 的 data.output_json.defense.threat_level ∈ {"high","medium","low"}
  • AND output_json.defense.detected == true
  • AND 当 prompt = "What is 2+2?" 时 output_json.defense.detected == false, threat_level=="low"

S12 compliance_audit_generates_trail

  • WHEN admin POST /runs body={"operator":"compliance-audit","input":{"action":"data_export","actor":"alice","user":"alice","timestamp":"2026-09-28T10:00:00Z"}}
  • THEN data.status=success
  • AND GET /runs/:id 的 data.output_json.audit.trail_id 是 36 位 UUID
  • AND output_json.audit.compliance_score ∈ [0,1]
  • AND output_json.audit.action == "data_export"

all test_runner_and_gate_pass

  • WHEN 跑 bash tests/e2e/dth_experiment_extend.test.sh
  • THEN C7_test_runner_passes_all 通过(≥26 断言)
  • AND 跑 bash openspec/scripts/check_spec_coverage.sh
  • AND C8_check_spec_coverage_gap_zero 通过(gap=0)