Files
dth/openspec/changes/chg_0011_vehicle_cloud_compliance/spec.md
T

4.4 KiB
Raw Blame History

Spec: experiment_platform

Requirement

THE SYSTEM SHALL provide a vehicle-to-cloud data compliance (VC) scenario that composes 6 existing operators (tds-connector / data-masking / data-watermark / horizontal-fedavg / abac-policy / compliance-audit) into a 6-step end-to-end compliant telemetry flow across 50 simulated vehicles, proving that out-of-domain PII is masked + watermarked + audit-traceable WITHOUT any new operator / endpoint / dependency, so that 业务方能用现有算子验证"数据出域可追溯" 的车云合规场景。

ADDED Scenarios

S1 车端 TDS 合约 hash 匹配

  • WHEN the vehicle's TDS client submits contract_hash matching the cloud platform's contract_hash
  • THEN tds-connector.match() returns {contract_hash_match: true, access_token: <3-part JWT>}
  • AND the JWT has 3 dot-separated parts (header.payload.signature)
  • AND output schema_version === "v2"

S2 TDS 合约 hash 不匹配 → 流程拒绝

  • WHEN tds-connector.match() is called with contract_hash_a !== contract_hash_b
  • THEN output {contract_hash_match: false, error: "contract-mismatch"}
  • AND the VC flow is aborted at step 1 (no data-masking / aggregation runs)

S3 字段感知脱敏(50 车 × 3 字段 = 150 次调用)

  • WHEN 50 vehicles submit telemetry with GPS / plate / owner_id PII fields + business fields (fault_code / battery_voltage / mileage)
  • THEN data-masking masks all 3 PII fields per vehicle (150 masked values total)
  • AND the original PII values (GPS coordinates / plate numbers / owner IDs) NEVER appear in any masked output
  • AND business fields (fault_code / battery_voltage / mileage) are NOT masked — they are passed through unchanged
  • AND schema_version = "v2"

S4 脱敏可逆性证明

  • WHEN the masked output from S3 is inspected
  • THEN each masked entry contains a reversible_hash field (SHA256 of the original value)
  • AND the SHA256 hash is stable — re-masking the same original value produces the same reversible_hash
  • AND the reversible_hash length is exactly 64 hex chars (SHA256)

S5 聚合报告零宽水印嵌入 + 提取 roundtrip

  • WHEN the fleet aggregator embeds payload = "VC|2026-09-29|fleet-50|v1" into a fleet report via data-watermark
  • THEN data-watermark.extract(watermarked_report) returns the exact payload string
  • AND the embedded payload survives a single roundtrip (embed → extract = payload)
  • AND schema_version = "v2"

S6 水印不可见

  • WHEN S5 embed is performed with text = "fleet report body..." and payload above
  • THEN the visible (printable) length of watermarked_text is unchanged from text (zero-width chars are not visible)
  • AND the byte length grows by exactly payload.length * 4 (4 zero-width chars per byte)

S7 50 车 fleet 聚合(horizontal-fedavg)

  • WHEN 50 vehicles submit their mean-fault-code (normalized to [0, 1])
  • THEN horizontal-fedavg outputs aggregated as the fleet-wide mean
  • AND client_count === 50
  • AND no Gaussian DP noise is applied (epsilon absent)
  • AND schema_version = "v2"

S8 ABAC 合规分析师通过 + 工程师拒绝

  • WHEN an ABAC policy requires subject.role === "compliance-analyst" AND env.ip in CIDR "10.0.0.0/24"
  • THEN request from {role: "compliance-analyst", ip: "10.0.0.5"} returns {decision: "allow"}
  • AND request from {role: "engineer", ip: "10.0.0.5"} returns {decision: "deny", reasons: [...allow_miss...]}
  • AND request from {role: "compliance-analyst", ip: "192.168.1.5"} returns {decision: "deny", reasons: [...env_violation: ip...]} (out of CIDR)

S9 审计链 HMAC 完整(6 步流程链)

  • WHEN the full VC flow runs through 6 audit entries (S1 tds + S3 masking + S5 watermark + S7 fedavg + S8 abac + S8-close = 6 entries)
  • THEN compliance-audit chain contains ≥ 6 entries (one per VC step)
  • AND each entry has HMAC-SHA256 chain linkage (prev_hash references the prior entry)
  • AND chainValid === true on full replay

S10 E2E 端到端 6 步不变性

  • WHEN a single shell run executes S1→S9 in order with the canonical 50-vehicle fixture
  • THEN every intermediate assertion in S1..S9 passes
  • AND the final output reports e2e dth_vc: pass=N fail=0 (N = total sub-assertions, expected 10+)
  • AND total wall-clock time for the e2e is < 60s (operators are local TS, no external I/O)