From 5041dfdb3dfecac731384cd5dd70f0f51f76b610 Mon Sep 17 00:00:00 2001 From: xstudio agent Date: Fri, 2 Oct 2026 17:03:09 +0800 Subject: [PATCH] =?UTF-8?q?chg=5F0013(T5):=20CLAUDE.md=20F-2=20=E5=8A=A0?= =?UTF-8?q?=2019=20=E7=AE=97=E5=AD=90=20=E2=86=92=20schema=20v2=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=98=A0=E5=B0=84=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 影响:F-2 子模块索引新增"19 算子 → schema v2 字段映射表"段 (learnings §明日接力.2 候选 c 闭环)。后续 chg 引用算子时 能直接对位 input shape / 业务载荷 key / 复用 chg / 敏度,避免 再翻 19 个 .ts 文件。 改动: - CLAUDE.md:90-127 新增 §"19 算子 → schema v2 字段映射表"(38 行) - 19 行表格:算子 / 算法 / 关键 input / 业务载荷 key / 复用 chg / 业务场景 / 敏度 - 字段约定段:顶层成功三元组 + 业务载荷 key 命名规范 + schema-version 缺失兼容说明 + 敏度 L0-L3 分级(与可信数据空间 对齐) - 业务场景对位段:FRC(chg_0010 7 个)/ VC(chg_0011 9 个)/ MPQ(chg_0013 6 个) 复用算子清单 + MPQ独有项 设计: - 表格只列"载荷结构 + 业务语义",不写算法原理(chg_0009 算子 选型设计已有 docs/dth/sp1-more/design.md);CLAUDE.md 应保持 速查而非教学 - 敏度一栏直接写 L0/L1/L2/L3 而非 公开/内部/机密/PHI,与 dth 可信数据空间分级词汇对齐,方便跨 chg 引用 - tee-inference 的 `tee.verify_code/quote` 单独标出(HMAC 验签 副作用字段),与 chg_0013 S5/S6 不变性直接对应 - psi 标 L3(PHI)提示 chg_0010/0011/0013 三方求交都涉及患者 ID/ 客户 ID/车 ID,业务侧审查重点 Co-Authored-By: Claude Code --- CLAUDE.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index 7afa465..a2ff798 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -87,6 +87,44 @@ | `hello-mpc` / `pir` / `vertical-lr` / `scql` / `horizontal-fedavg` / `secure-mlp` / `tee-inference` / `prompt-defense` / `compliance-audit` | 9 既有(含 chg_0008 真算法改写) | chg_0002/0005/0008 | | `paillier-he` / `threshold-sig` / `mpc-beaver` / `psi` / `did-identity` / `tds-connector` / `data-masking` / `data-watermark` / `abac-policy` / `model-watermark` | 10 真算法算子(schema v2) | chg_0009 | +### 19 算子 → schema v2 字段映射表(chg_0013 · 闭环 learnings 候选 c) + +每个算子的成功输出均含顶层 `ok:true / schema_version:"v2" / computed_at`;业务载荷挂在算子键下(`tee.* / psi.* / paillier.* / audit.* ...`)。**PHI 约定**:除 did/tee/audit/psi 4 类算子外,其余算子载荷内不含业务明文,仅含派生统计量。 + +| 算子 | 算法(核心) | 关键 input | 业务载荷(顶层 key)| 复用 chg | 业务场景 | 敏度 | +|---|---|---|---|---|---|---| +| `hello-mpc` | shamir-3pc-mock | `numbers:[int]` | `mpc.{protocol,party_count,numeric_sum}` | chg_0002/0008 | MVP 演示 | L0 | +| `pir` | FNV-1a 32-bit 假名索引 | `keyword:string` | `query.{hash,length}` + `hits[]` + `hit_count` + `db_size` | chg_0002/0008 | 单点假名检索 | L1 | +| `vertical-lr` | mini-batch 梯度下降 | `features:number[][]` + `labels:number[]` | `weights/bias/loss_history[]/iterations/learning_rate/rows` | chg_0002/0008 | 纵向 LR(mock)| L1 | +| `scql` | secret-share 聚合 v2 | `columns/rows` | `scql.{sum,column_count,mean,per_column_sum[],share_count,part_sums[],protocol}` | chg_0002/0008 | 多方 SQL 聚合 | L2 | +| `horizontal-fedavg` | fedavg-gaussian-dp-v2 | `clients:[{label,w}]` + `[epsilon,aggregation,dim]` | `fedavg.{aggregated,client_count,round_count,aggregation,dimension,algorithm,noise_scale,noise_applied}` | chg_0002/0008 | 横向联邦(DP) | L2 | +| `secure-mlp` | Laplace-DP 推理 | `features:number[][]` + `[epsilon,weights,bias]` | `mlp.{predictions[],noise_scale,rows,weights_used,bias_used,epsilon,mechanism,deterministic}` | chg_0005/0008 | 神经网络推理(DP) | L2 | +| `tee-inference` | TEE-mock enclave | `prompt:string` + `model:string` + `[attestation_key,verify_key]` | `tee.{attestation,response,model,prompt_length,enclave,hash_full}` + `tee.verify_code/quote`(HMAC) | chg_0005/0008 | enclave 内推理 | L2 | +| `prompt-defense` | 关键词+pattern+z-score | `prompt:string` + `[signature,threshold]` | `defense.{detected,threat_level,matched_keywords[],score,pattern_hits,z_score,z_anomaly,signature_provided,signature_valid,reasons[],prompt_length,keywords_total}` | chg_0005/0008 | prompt 注入防护 | L1 | +| `compliance-audit` | HMAC-SHA256 链 append/verify | append: `action/actor/user/payload`;verify: `entries[]` | append: `audit.{trail_id,action,actor,user,timestamp,compliance_score,status,prev_hash,payload_hash,chain_index,mode}`;verify: `audit.{chainValid,entries_verified,first_bad_index,mode}` | chg_0005/0008 | 不可篡改日志链 | L0 | +| `paillier-he` | paillier-he-additive-v2 | `values:int[]` + `[seed]` | `paillier.{values[],ciphertexts[],sum_encrypted,sum_decrypted,plaintext_sum,homomorphic_invariant_ok,pubkey{n,g,n_squared}` | chg_0009 | 同态密文求和 | L0 | +| `threshold-sig` | 2-of-3 Shamir 门限签名 | `message:string` + `shares:[{x,y}]` | `threshold_sig.{message,shares_used,share_x[],share_y[],reconstructed_secret_hex,reconstructed_signature,original_signature,signature_match,with_one_share_fails,threshold,total_shares,field_prime_hex}` | chg_0009 | 门限签名重构 | L0 | +| `mpc-beaver` | beaver-mpc-triple-v2 | `x/y/a/b/c` | `mpc.{x,y,triple{a,b,c,triple_consistent},revealed_public{d,e},z,xy_ground_truth,invariant_ok,tolerance,algorithm}` | chg_0009 | Beaver 三元组验证 | L0 | +| `psi` | cuckoo-psi-v2 | `set_a/set_b[]` + `hash_key` | `psi.{set_a_size,set_b_size,intersection[],size,leaked_non_intersection,algorithm}` | chg_0009 | 两方求交 | L3(PHI) | +| `did-identity` | did-hmac-v2 | `method/identifier` + `[secret]` | `did.{did,method,identifier,doc,proof{type,verification_method,signature},verify_with_correct_secret,verify_with_wrong_secret,algorithm}` | chg_0009 | 身份 DID + HMAC 验签 | L1 | +| `tds-connector` | tds-hmac-jwt-v2 | `contract_hash_a/b` + `[subject,scope,ttl]` | `tds.{contract_hash_match,sha256_a,sha256_b,access_token,token_type,ttl_seconds,subject,scope,algorithm}` | chg_0009 | 可信数据空间合约 | L1 | +| `data-masking` | field-aware-masking-v2 | `field_type:string` + `value:string` + `[seed]` | `masking.{field_type,original_length,masked,masked_length,reversible_hash,algorithm}` | chg_0009 | 字段感知脱敏 | L2 | +| `data-watermark` | zero-width-watermark-v2 | action=embed/extract + `text/payload` | `watermark.{action,text,zero_width_chars_found,extracted_payload,algorithm}` | chg_0009 | 零宽字符水印 | L1 | +| `abac-policy` | abac-jsonlogic-v2 | `subject/object/action/env` + `policy` | `abac.{decision,reasons[],allow_matched_keys[],deny_matched_keys[],env_violations[],algorithm}` | chg_0009 | ABAC 策略判定 | L1 | +| `model-watermark` | lsb-model-watermark-v2 | action=embed/extract + `weights/payload` | `watermark.{action,byte_count,extracted_payload,weights_length,algorithm}` | chg_0009 | 模型权重水印 | L1 | + +**字段约定**: +- `ok:true` + `schema_version:"v2"` + `computed_at` = 顶层成功三元组(19 个算子一致) +- 业务载荷 key 与算子同名(`psi.*`、`paillier.*`、`audit.*`),便于 caller 按算子路由 +- `schema_version` 缺失 → 算子未升级到 v2(仅 chg_0008 之前的 9 算子起步版可能),按需 + 触发 `recompute_classification` / 走 schema v1 兼容路径 +- 敏度 L0=公开 / L1=内部 / L2=机密 / L3=PHI(含患者 ID 等),与可信数据空间分级对齐 + +**业务场景对位**(learnings §明日接力.2 闭环): +- 金融联合风控 chg_0010 → psi/paillier-he/threshold-sig/did-identity/mpc-beaver/compliance-audit/abac-policy(7) +- 车云合规 chg_0011 → tds-connector/data-masking/horizontal-fedavg/data-watermark/abac-policy/compliance-audit/did-identity/psi/paillier-he(9) +- 医疗隐私查询 chg_0013 → did-identity/tee-inference/psi/paillier-he/abac-policy/compliance-audit(6,含 MPQ独有 tee-inference) + ### 已落 chg 索引(12 归档 + 0 提案) | chg | 能力 | 主线 merge commit | e2e case 数 | 归档路径 |