diff --git a/openspec/changes/archive/2026-10-02-chg_0010_federated_risk_control/testcases.map.yaml b/openspec/changes/archive/2026-10-02-chg_0010_federated_risk_control/testcases.map.yaml index a983afc..56d34d9 100644 --- a/openspec/changes/archive/2026-10-02-chg_0010_federated_risk_control/testcases.map.yaml +++ b/openspec/changes/archive/2026-10-02-chg_0010_federated_risk_control/testcases.map.yaml @@ -1,4 +1,4 @@ -# spec: experiment_platform@chg_0010 +# spec: experiment_platform@2026-10-02-chg_0010 scenarios: - id: S1 cases: [C1_3bank_did_setup_tds_match] diff --git a/openspec/changes/archive/2026-10-02-chg_0011_vehicle_cloud_compliance/testcases.map.yaml b/openspec/changes/archive/2026-10-02-chg_0011_vehicle_cloud_compliance/testcases.map.yaml index c3f772d..ba61904 100644 --- a/openspec/changes/archive/2026-10-02-chg_0011_vehicle_cloud_compliance/testcases.map.yaml +++ b/openspec/changes/archive/2026-10-02-chg_0011_vehicle_cloud_compliance/testcases.map.yaml @@ -1,4 +1,4 @@ -# spec: experiment_platform@chg_0011 +# spec: experiment_platform@2026-10-02-chg_0011 scenarios: - id: S1 cases: [C1_vc_tds_contract_match] diff --git a/openspec/changes/archive/2026-10-02-chg_0012_lms_multiscene_v2/testcases.map.yaml b/openspec/changes/archive/2026-10-02-chg_0012_lms_multiscene_v2/testcases.map.yaml index 3f4ca24..fe15196 100644 --- a/openspec/changes/archive/2026-10-02-chg_0012_lms_multiscene_v2/testcases.map.yaml +++ b/openspec/changes/archive/2026-10-02-chg_0012_lms_multiscene_v2/testcases.map.yaml @@ -1,4 +1,4 @@ -# spec: lms_v2@chg_0012 +# spec: lms_v2@2026-10-02-chg_0012 scenarios: - id: S1 cases: [C1_lms_v1_data_model_basic] diff --git a/openspec/changes/chg_0013_medical_privacy_query/proposal.md b/openspec/changes/chg_0013_medical_privacy_query/proposal.md new file mode 100644 index 0000000..161aa19 --- /dev/null +++ b/openspec/changes/chg_0013_medical_privacy_query/proposal.md @@ -0,0 +1,101 @@ +--- +change_id: chg_0013 +status: proposed +owner: pm@team +stakeholders: [pd, tm, qa, dev] +priority: P1 +target_release: v0.7 +created: 2026-10-02 +skip_coverage: false +--- + +# chg_0013 medical_privacy_query — 3 医院联合疾病查询 + 19 算子映射表 + +## Why + +chg_0010 / 0011 已落地金融联合风控(FRC)/ 车云合规(VC)两个真实业务场景,证明算子在多方不出域流程下能协同工作。 + +**缺口**:医疗垂直(learnings §明日接力.2 第三个候选)尚未覆盖,且 19 算子中 **tee-inference** 在前两个场景里都没用上——只在 chg_0002 mock + chg_0005 扩展中露过面。 + +需求 §5 要求"金融联合风控 / 医疗联合诊断 / 车云数据合规"三场景全证明。chg_0013 闭环医疗垂直,同时把 19 算子 → schema v2 字段映射表落到 F-2 子模块索引(learnings 候选 (c)),方便后续 chg 引用。 + +**约束**: +- 不改 backend 代码(19 算子已齐备,0 新依赖,0 新接口) +- 不加前端(场景测试目标是 backend e2e 协同 + 文档索引) +- 复用 chg_0010 / 0011 / 0012 的 e2e 套路:admin token + per-hospital 标签 + python heredoc + json_get helper + +**业务场景(医疗隐私查询 / MPQ)**: + +3 家医院(H_A / H_B / H_C,HIPAA 等价合规)联合查询"在某时间段内被诊断为某疾病(如 `D-101`)的患者"——三方都不暴露各自的患者 ID 列表,只输出交集。 + +业务流: +1. 各医院先用 DID 验证身份(避免伪装医院) +2. 三方 PSI 求患者 ID 交集(伪 ID 化后求交,不暴露原始 ID) +3. 交集过审后,TEE 内 enclave 跑 LLM 推理:"这类患者的治疗方案"(prompt 不出 enclave) +4. Paillier 同态加密求交集患者的"平均住院天数"(不暴露单个患者天数) +5. 全程审计链(HMAC 链 + verify) +6. ABAC:只有"医学研究员"角色 + 来源 IP 在医院网段内才允许访问最终报告 + +**算子映射(5 个)**: +- `did-identity` S1(身份验证) +- `psi` S3(三方求交) +- `tee-inference` S4(TEE 内推理) +- `paillier-he` S5(同态求和) +- `compliance-audit` S7(审计链) +- `abac-policy` S6(角色 + IP 访问控制)— 实际 6 个算子 + +**算子复用率**:6/19 = 32%;与 FRC/VC 互补: +- FRC 独占:psi / paillier-he / threshold-sig / did-identity / mpc-beaver(FRC 有 PSI/Paillier,MPQ 复用但 FRC 还多用 threshold-sig / mpc-beaver) +- VC 独占:data-masking / horizontal-fedavg(VC 用了,但 MPQ 不需要脱敏 — 医院内数据已合规;MPQ 也不需要 federated 平均) +- MPQ 独占:**tee-inference**(医疗推理场景独有,FRC/VC 都未用过) +- 共有:did-identity / psi / paillier-he / compliance-audit / abac-policy(与 FRC 共有 4 个,与 VC 共有 3 个) + +## Scope + +**做**: + +1. **场景设计文档** `docs/dth/mpq/scenario.md`:定义 MPQ 场景的 6 步流程图 + 数据流图 + + 不变性约束 + 与既有 19 算子的映射表(含 tee-inference 复用详情)。 + +2. **集成 e2e 测试** `tests/e2e/dth_mpq.test.sh`:10 case 串起 6 个算子,覆盖: + - C1: 3 医院 DID 建立 + HMAC 验证(did-identity) + - C2: DID 篡改检测(did-identity:篡改 identifier → verify failure) + - C3: PSI 三方交集 = [p01, p02, p03](psi:H_A ∩ H_B ∩ H_C) + - C4: PSI 不泄露非交集(psi:交集元素计数 ≤ min(|A|,|B|,|C|)) + - C5: tee-inference verify_code=0(attestation_key matches) + - C6: tee-inference verify_code=1(wrong verify_key → signature mismatch) + - C7: Paillier 跨院同态求和(paillier-he:Enc(d_A)·Enc(d_B)·Enc(d_C) = Enc(sum)) + - C8: ABAC 医学研究员通过 + 工程师拒绝(abac-policy) + - C9: 审计链 HMAC 完整(compliance-audit:6 步链 chainValid=true) + - C10: E2E 端到端(依次跑 C1→C9 全程,每步 invariant 通过) + +3. **算子映射表** `CLAUDE.md` F-2 加 §"19 算子 → schema v2 字段映射":表格化 19 个算子的 + - code / algorithm / input shape / output schema / 复用 chg / sensitivity + - 方便 chg_0014+ 选算子时直接对位 + +4. **门禁更新** `openspec/scripts/check_spec_coverage.sh`:无需改动(5 件套天然 cover)。 +5. **端口**:仍 30000(DTH_BASE 默认;不冲突 FRC/VC/LMS)。 + +**不做**: + +- ❌ 新建 MPQ 专属 endpoint(直接复用 `POST /experiment/runs`) +- ❌ 新加前端(backend-only e2e) +- ❌ 新加 operator(19 算子全够用) +- ❌ 新加依赖(纯 shell + python3 + curl) +- ❌ 改 abac / auth(admin token 全程够用) +- ❌ 把场景拆成 HIPAA 实际条款验证(这是 demo,不是生产医疗合规审计) + +## Acceptance + +- 10 case e2e 全 PASS(chg_0013 自身,含 sub-assertion ≥ 25) +- 9 回归 e2e 全 PASS(chg_0002/0005/0006/0007/0008/0009/0010/0011/0012) +- gate `PROJECT_ROOT=. bash openspec/scripts/check_spec_coverage.sh` gap=0 +- `tsc --noEmit` 0 新错(除预存 chg_0002 vertical-lr.ts:52) +- 文档 `docs/dth/mpq/scenario.md` 含:mermaid 流程图 + 数据流 + 6 算子映射 + 不变性清单 +- CLAUDE.md F-2 含 19 算子 → schema v2 字段映射表 + +## 与 handoff §2 / learnings 的对应 + +- handoff §2 优先级 2 = "chg_0010 真实业务场景测试设计" → 已闭环(chg_0010) +- handoff §2 优先级 3 = "医疗联合诊断" → 本 chg 闭环 +- learnings 候选 (c) = "F-2 算子映射表" → 本 chg 一并闭环 \ No newline at end of file diff --git a/openspec/changes/chg_0013_medical_privacy_query/spec.md b/openspec/changes/chg_0013_medical_privacy_query/spec.md new file mode 100644 index 0000000..369e0ae --- /dev/null +++ b/openspec/changes/chg_0013_medical_privacy_query/spec.md @@ -0,0 +1,93 @@ +# Spec: experiment_platform + +## Requirement + +THE SYSTEM SHALL provide a multi-hospital medical privacy query (MPQ) scenario that composes +6 existing operators (did-identity / psi / tee-inference / paillier-he / abac-policy / +compliance-audit) into a 6-step end-to-end disease-incidence intersection + treatment-Guidance +inference flow across 3 simulated hospitals (H_A / H_B / H_C), proving that **multi-party, +no-PHI-leak, audit-traceable** clinical queries can be made WITHOUT any new operator / +endpoint / dependency, so that 业务方能用现有算子验证"医疗数据不出域"的隐私查询场景。 + +## ADDED Scenarios + +### S1 3 医院 DID 建立 + HMAC 验证 + +- **WHEN** H_A / H_B / H_C each call did-identity.create() with their private keys +- **THEN** output 3 distinct DIDs (`did:mpq:hospitalA/...`, `did:mpq:hospitalB/...`, `did:mpq:hospitalC/...`) +- **AND** each DID's verify() with correct secret returns `{valid: true}` +- **AND** output `schema_version === "v2"` + +### S2 DID 篡改检测 + +- **WHEN** any DID document from S1 is tampered (e.g., swap `publicKey` field) OR verify is called with a wrong secret +- **THEN** did-identity.verify() returns `{valid: false}` (HMAC mismatch) +- **AND** error reflects "verify-failed" or HMAC code + +### S3 PSI 三方求交 = [p01, p02, p03] + +- **WHEN** 3 hospitals submit private patient ID lists: + - H_A = `[p01, p02, p04, p05, p06]` (5 patients) + - H_B = `[p01, p03, p02, p07]` (4 patients) + - H_C = `[p01, p02, p03, p08, p09]` (5 patients) +- **THEN** PSI intersection output = `[p01, p02, p03]` (3 shared patients with disease D-101) +- **AND** `intersection_size === 3` +- **AND** output `schema_version === "v2"` + +### S4 PSI 不泄露非交集(隐私不变性) + +- **WHEN** S3 PSI is run +- **THEN** the output NEVER contains elements outside `[p01, p02, p03]` +- **AND** the output size is **at most** `min(|A|, |B|, |C|) = 4` +- **AND** no per-hospital patient list sizes are revealed in the output +- **AND** no per-hospital disease diagnosis info is revealed + +### S5 tee-inference attestation_key matches → verify_code=0 + +- **WHEN** an authorized researcher queries "treatment recommendations for the 3 shared patients (D-101)" via tee-inference with `attestation_key = "mpq-attest-key-2026"` +- **THEN** output includes `tee.attestation`, `tee.response` +- **AND** `tee.quote` contains pcr0 + pcr1 + nonce + signature (HMAC-SHA256) +- **AND** `tee.verify_code === 0` (signature matches with attestation_key) +- **AND** `tee.verify_message === "signature matches"` +- **AND** output `schema_version === "v2"` + +### S6 tee-inference wrong verify_key → verify_code=1 + +- **WHEN** tee-inference is called with `attestation_key = "mpq-attest-key-2026"` but `verify_key = "wrong-key"` +- **THEN** `tee.verify_code === 1` (signature mismatch) +- **AND** `tee.verify_message === "signature mismatch"` +- **AND** response is still generated (enclave side effect), but tamper detected on caller side + +### S7 Paillier 同态求和 = Enc(d_A + d_B + d_C) + +- **WHEN** 3 hospitals submit encrypted hospitalization days for the 3 patients in the PSI intersection: + - H_A: Enc(7) for p01 + - H_B: Enc(10) for p02 + - H_C: Enc(5) for p03 +- **THEN** `sumProduct = Enc(7) · Enc(10) · Enc(5) mod n² === Enc(22)` +- **AND** Decrypt(Enc(22)) === 22 (mod n) +- **AND** no individual hospitalization day (7 / 10 / 5) is exposed in the API response +- **AND** output `schema_version === "v2"` + +### S8 ABAC 医学研究员通过 + 工程师拒绝 + +- **WHEN** an ABAC policy requires `subject.role === "medical-researcher"` AND `subject.dept in ["oncology","cardiology"]` AND `env.ip_range = "10.0.0.0/24"` (hospital network) +- **THEN** request from `{role: "medical-researcher", dept: "oncology", ip: "10.0.0.5"}` returns `{allow: true}` +- **AND** request from `{role: "engineer", dept: "none", ip: "10.0.0.5"}` returns `{allow: false, reason: "role-deny"}` +- **AND** request from `{role: "medical-researcher", dept: "oncology", ip: "192.168.1.5"}` returns `{allow: false, reason: "ip-range-deny"}` + +### S9 审计链 HMAC 完整 + +- **WHEN** the full MPQ flow runs through steps S1→S7 (DID / psi / tee / paillier / abac) and S1-S7 audit entries are recorded via compliance-audit +- **THEN** compliance-audit chain contains ≥ 5 entries (one per MPQ step) +- **AND** each entry has HMAC-SHA256 chain linkage (`prev_hash` references the prior entry's hash) +- **AND** chainValid === true on full replay +- **AND** no PHI (patient IDs / diagnosis / days) appears in audit entries — only operator name + step summary + +### S10 E2E 端到端 6 步不变性 + +- **WHEN** a single shell run executes S1→S9 in order with the canonical 3-hospital input fixture +- **THEN** every intermediate assertion in S1..S9 passes +- **AND** the final output reports `e2e dth_mpq: pass=N fail=0` (N = total sub-assertions, expected ≥ 25) +- **AND** total wall-clock time for the e2e is < 60s (operators are local Node, no external I/O) +- **AND** no PHI string (patient IDs / diagnosis codes / hospitalization days) appears anywhere in API responses \ No newline at end of file diff --git a/openspec/changes/chg_0013_medical_privacy_query/tasks.md b/openspec/changes/chg_0013_medical_privacy_query/tasks.md new file mode 100644 index 0000000..296b06d --- /dev/null +++ b/openspec/changes/chg_0013_medical_privacy_query/tasks.md @@ -0,0 +1,84 @@ +# Tasks (DAG) + +- id: T1 + type: architect + depends_on: [] + output: docs/dth/mpq/scenario.md + verification: + - 文档含 mermaid 流程图(6 步 + 6 算子映射) + - 数据流表(每步:输入 → 算子 → 输出 → 不变性) + - 算子映射表(每算子:何时被调用 / 输入 schema / 输出 schema) + - 不变性清单(S1-S10 → 对应算子 + 测试断言) + - 复用矩阵(19 算子复用率 ≥ 30%;与 FRC/VC 互补对照表) + - 医疗 PHI 不出域硬约束专项段落 + +- id: T2 + type: implementer + depends_on: [T1] + output: | + tests/e2e/dth_mpq.test.sh (10 case e2e shell 脚本) + verification: + - 脚本无 set -e(每条 assertion 独立计数) + - 使用 DTH_BASE=${DTH_BASE:-http://127.0.0.1:30000} + - 每条 assert 用 python3 json_get (与 chg_0010/0011/0012 一致) + - 包含 admin token login + - 10 case 覆盖 S1..S10 + - 总耗时 < 60s + - 复用既有 helpers(不要重写 json_get / assert / login) + +- id: T3 + type: tester + depends_on: [T2] + output: | + 1 次完整 e2e 跑通(bash tests/e2e/dth_mpq.test.sh 10/0) + verification: + - pass≥25 fail=0(10 case + sub-assertion) + - 含 4+ 不变性断言(DID 验证 / PSI 交集 / tee attestation / Paillier sum / 审计链) + - 含 1 篡改检测(did-identity 篡改 verify 失败 + tee-inference wrong verify_key) + - 含 1 拒绝路径(ABAC 非授权角色拒绝) + - 含 1 跨医院 E2E 串联(C10 = S1→S9 一气呵成) + +- id: T4 + type: qa + depends_on: [T3] + output: | + PROJECT_ROOT=. bash openspec/scripts/check_spec_coverage.sh + 10 e2e 套件全跑(chg_0002/0005/0006/0007/0008/0009/0010/0011/0012/0013) + verification: + - gate gap = 0 + - tsc --noEmit 0 新错(除预存 chg_0002 vertical-lr.ts:52) + - 9 回归 + 1 新 = 10 e2e 套件全 PASS + - 总断言数 ≥ 265(241 旧 + ≥25 新) + - 报告落 /tmp/chg_0013-qa.log + +- id: T5 + type: docs + depends_on: [T2] + output: | + CLAUDE.md F-2 加 §"19 算子 → schema v2 字段映射" + verification: + - 19 算子全列出(code / algorithm / input shape / output schema / 复用 chg / sensitivity) + - 与 chg_0013 提案中"6/19 复用"声明可对位(tee-inference / did-identity / psi / paillier-he / compliance-audit / abac-policy 标 ✅) + - 加在"已落 chg 索引"前,与既有 7 模块表连续 + - 单文件改动,commit 信息 `docs(F-2): 加 19 算子 schema v2 字段映射表` + +- id: T6 + type: pm + depends_on: [T4, T5] + output: | + openspec/changes/chg_0013_medical_privacy_query/.xstudio-report.md + chg_0013 实施说明(取舍 + 6/19 算子复用 + 算子映射表 + 后续 chg_0014 候选) + verification: + - 报告含 改动文件清单 + 门禁结果 + 算子复用率 + 是否建议合并 + - 报告大小 ≥ 50 行(比 chg_0010 多 1 行,因含算子映射表说明) + - chg_0013 任务全部完成 + +# Notes + +- 无 backend 代码改动(19 算子已齐备) +- 无 frontend 代码改动(业务场景 e2e + docs only) +- 无新依赖 +- 测试端口 30000(与既有 e2e 一致;DTH_BASE env 可覆盖) +- 提交顺序建议:T1 (scenario.md) → T2 (test script) → T3 (test PASS) → T4 (gate + regressions) || T5 (CLAUDE.md operator mapping) → T6 (report) +- 与 FRC/VC 的边界:不动 OperatorsService / ExperimentModule 注册(19 算子已注册),仅新增 test 脚本 + 1 个 docs 文件 +- T5 可与 T4 并行(无依赖) \ No newline at end of file diff --git a/openspec/changes/chg_0013_medical_privacy_query/testcases.map.yaml b/openspec/changes/chg_0013_medical_privacy_query/testcases.map.yaml new file mode 100644 index 0000000..b0c86d9 --- /dev/null +++ b/openspec/changes/chg_0013_medical_privacy_query/testcases.map.yaml @@ -0,0 +1,77 @@ +# spec: experiment_platform@chg_0013_medical_privacy_query +scenarios: + - id: S1 + cases: [C1_mpq_did_three_hospitals_establish] + - id: S2 + cases: [C2_mpq_did_tamper_detected] + - id: S3 + cases: [C3_mpq_psi_three_way_intersection] + - id: S4 + cases: [C4_mpq_psi_no_non_intersection_leak] + - id: S5 + cases: [C5_mpq_tee_attestation_matches] + - id: S6 + cases: [C6_mpq_tee_wrong_verify_key] + - id: S7 + cases: [C7_mpq_paillier_sum_invariant] + - id: S8 + cases: [C8_mpq_abac_researcher_one_role_deny] + - id: S9 + cases: [C9_mpq_audit_chain_hmac_valid] + - id: S10 + cases: [C10_mpq_e2e_full_flow_6_steps] +gate: + blocking_gap_tolerance: 0 + implementation_files: + - docs/dth/mpq/scenario.md + - tests/e2e/dth_mpq.test.sh + - CLAUDE.md # F-2 算子映射表(T5) + test_files: + - tests/e2e/dth_mpq.test.sh +notes: + reuses_operators_no_new_code: true + new_module_count: 0 + new_frontend_components: 0 + operator_coverage: "6 of 19 existing operators used" + operators_used: + - did-identity (S1 / S2) + - psi (S3 / S4) + - tee-inference (S5 / S6) # NEW usage not in FRC/VC + - paillier-he (S7) + - abac-policy (S8) + - compliance-audit (S9) + complements_chg_0010_frc: true + complements_chg_0011_vc: true + complements_chg_0012_lms: false + complementary_operators_vs_frc: + frc_only: [threshold-sig, mpc-beaver] # FRC 用但 MPQ 不用 + mpq_only: [tee-inference] # MPQ 用但 FRC 不用 + shared: [did-identity, psi, paillier-he, abac-policy, compliance-audit] # 5 个共有 + complementary_operators_vs_vc: + vc_only: [data-masking, horizontal-fedavg, data-watermark, tds-connector] # 4 个独有 + mpq_only: [tee-inference] + shared: [did-identity, psi, paillier-he, abac-policy, compliance-audit] # 5 个共有 + phi_invariant: "NO patient ID / diagnosis code / hospitalization day appears in any API response across C1-C10 (C4 / C7 / C9 显式断言)" + tee_invariant: "tee-inference signature must verify_code=0 with correct attestation_key (C5) AND verify_code=1 with wrong verify_key (C6)" + three_hospital_psi_changes: "psi operator only supports 2-way; MPQ composes (A∩B) ∩ C in 2 sequential calls (same as chg_0010)" + hospital_fixture: + h_a: [p01, p02, p04, p05, p06] # 5 patients + h_b: [p01, p03, p02, p07] # 4 patients + h_c: [p01, p02, p03, p08, p09] # 5 patients + expected_intersection: [p01, p02, p03] + no_new_dependency: true + claude_md_change: + file: CLAUDE.md + section: "F-2 子模块索引 → 19 算子 → schema v2 字段映射表" + placement: "已落 chg 索引前,与 7 模块表连续" + row_count: 19 + frc_template_reuse: "无(MPQ 自含,不依赖 LMS v2 / FRC 模板)" + new_frontend_components: [] + new_frontend_views: [] + bound_task_breakdown: + T1: [scenario.md] + T2: [testcases.md, testcases.map.yaml, dth_mpq.test.sh] + T3: [e2e PASS] + T4: [gate + 9 regressions] + T5: [CLAUDE.md operator mapping] + T6: [.xstudio-report.md] \ No newline at end of file diff --git a/openspec/changes/chg_0013_medical_privacy_query/testcases.md b/openspec/changes/chg_0013_medical_privacy_query/testcases.md new file mode 100644 index 0000000..f7f03f6 --- /dev/null +++ b/openspec/changes/chg_0013_medical_privacy_query/testcases.md @@ -0,0 +1,131 @@ +### C1_mpq_did_three_hospitals_establish +- Scenario: S1 +- Type: e2e +- Priority: P0 +- Given: backend running on 30000, admin token, 3 hospital private keys (H_A_secret / H_B_secret / H_C_secret) +- When: POST /experiment/runs with operator=did-identity 3 times (one per hospital) +- Then: each response contains a distinct DID (`did:mpq:hospitalA/...` / `hospitalB` / `hospitalC`) +- And: each output has `valid: true` when verified with correct secret (verify_code=0 or valid=true) +- And: schema_version=v2 +- Automated: true +- Bound Task: T2 + +### C2_mpq_did_tamper_detected +- Scenario: S2 +- Type: e2e +- Priority: P0 (compliance invariant) +- Given: 1 hospital DID established in C1 +- When: did-identity verify called with WRONG secret OR tampered identifier +- Then: response.valid=false OR verify_code=1 (HMAC mismatch) +- And: error reflects "verify-failed" / "signature-mismatch" / similar +- Automated: true +- Bound Task: T2 + +### C3_mpq_psi_three_way_intersection +- Scenario: S3 +- Type: e2e +- Priority: P0 +- Given: 3 hospital patient ID lists: + - H_A = [p01, p02, p04, p05, p06] (5 patients) + - H_B = [p01, p03, p02, p07] (4 patients) + - H_C = [p01, p02, p03, p08, p09] (5 patients) +- When: 2 sequential PSI calls (A∩B) then (A∩B ∩ C) +- Then: final intersection = [p01, p02, p03] (sorted, 3 elements) +- And: intersection_size === 3 +- And: schema_version=v2 +- Automated: true +- Bound Task: T2 + +### C4_mpq_psi_no_non_intersection_leak +- Scenario: S4 +- Type: e2e +- Priority: P0 (PHI invariant) +- Given: S3 PSI run completed +- When: e2e inspects full PSI output (all 2 calls' outputs) +- Then: NO patient id outside [p01, p02, p03] appears in any output +- And: total intersection size <= min(5, 4, 5) = 4 +- And: NO per-hospital patient list sizes exposed in output +- And: NO per-hospital disease diagnosis exposed +- Automated: true +- Bound Task: T2 + +### C5_mpq_tee_attestation_matches +- Scenario: S5 +- Type: e2e +- Priority: P0 +- Given: prompt="Recommend treatment for 3 patients with D-101 (intersection from MPQ PSI)", model="gpt-medical-v2", attestation_key="mpq-attest-key-2026" +- When: POST /experiment/runs with operator=tee-inference +- Then: response.tee.attestation starts with "tee-mock-" (chg_0005 back-compat) +- And: response.tee.response contains "echoes: ..." +- And: response.tee.quote contains pcr0 + pcr1 + nonce + signature +- And: response.tee.verify_code === 0 (HMAC matches with attestation_key) +- And: response.tee.verify_message === "signature matches" +- And: schema_version=v2 +- Automated: true +- Bound Task: T2 + +### C6_mpq_tee_wrong_verify_key +- Scenario: S6 +- Type: e2e +- Priority: P0 (compliance invariant) +- Given: attestation_key="mpq-attest-key-2026", verify_key="wrong-key-not-matching" +- When: POST tee-inference with both keys +- Then: response.tee.verify_code === 1 (HMAC mismatch) +- And: response.tee.verify_message === "signature mismatch" +- And: response.tee.response still generated (enclave side effect) +- And: schema_version=v2 +- Automated: true +- Bound Task: T2 + +### C7_mpq_paillier_sum_invariant +- Scenario: S7 +- Type: e2e +- Priority: P0 +- Given: 3 hospital encrypted hospitalization days for PSI intersection patients: + - H_A: Enc(7) for p01 + - H_B: Enc(10) for p02 + - H_C: Enc(5) for p03 +- When: POST paillier-he with 3 ciphertext inputs +- Then: homomorphic sum decrypts to 22 (7 + 10 + 5) +- And: schema_version=v2 +- And: NO individual hospitalization day (7 / 10 / 5) appears in API response +- Automated: true +- Bound Task: T2 + +### C8_mpq_abac_researcher_one_role_deny +- Scenario: S8 +- Type: e2e +- Priority: P0 +- Given: abac policy requiring role=medical-researcher AND dept in [oncology, cardiology] AND env.ip_range=10.0.0.0/24 +- When: 3 POST abac-policy calls with combinations (1 allow + 2 deny) +- Then: allow for {role: medical-researcher, dept: oncology, ip: 10.0.0.5} +- And: deny with role-deny for {role: engineer, dept: none, ip: 10.0.0.5} +- And: deny with env_violation:ip_range for {role: medical-researcher, dept: oncology, ip: 192.168.1.5} +- Automated: true +- Bound Task: T2 + +### C9_mpq_audit_chain_hmac_valid +- Scenario: S9 +- Type: e2e +- Priority: P0 +- Given: 5+ MPQ step audit entries (S1 did-A + S3 psi-summary + S5 tee-summary + S7 paillier-sum + S8 abac) +- When: POST compliance-audit with action=record (5 appends), then POST verify with entries=full chain +- Then: chain length >= 5 +- And: each entry has prev_hash linking prior entry's hash +- And: chainValid=true on verify replay +- And: NO patient ID / diagnosis code / hospitalization day appears in any audit entry +- Automated: true +- Bound Task: T2 + +### C10_mpq_e2e_full_flow_6_steps +- Scenario: S10 +- Type: e2e +- Priority: P0 +- Given: canonical 3-hospital fixture (DIDs, patient lists, attestation_key, hospitalization ciphertexts, ABAC policy, audit entries) +- When: 1 shell run executes all 9 steps in sequence (C1-C9 in order) +- Then: pass≥25 fail=0 (10 main cases + sub-assertions) +- And: total wall-clock < 60s +- And: no operator-not-found or 500 errors in any substep +- And: no PHI string appears anywhere in API responses +- Automated: true +- Bound Task: T3 (E2E orchestration test) \ No newline at end of file