第7章 质量门与完整性(QC Gates)


I. 目的与范围(Purpose & Scope)


II. 前置条件与输入(Prerequisites & Inputs)


III. 质量门定义(Gates G1–G8)


IV. 停止与回退(Stops & Fallbacks,S1–S5)


V. /validate 报告规范(Validation API & Report)


validate_report.json(示例)

JSON json
{
  "dataset_id": "ds-core",
  "timestamp": "2025-09-24T16:00:00Z",
  "global": {
    "G1": true,
    "G2": 0.94,
    "G3": true,
    "G4": true,
    "G5": true,
    "G6": true,
    "G7": true,
    "G8": true
  },
  "splits": {
    "train": { "G": { "G1": true, "G3": true, "G4": true, "G6": true, "G8": true }, "count": 120345 },
    "val": { "G": { "G1": true, "G3": true, "G4": true, "G6": true, "G8": true }, "count": 25780 },
    "test": { "G": { "G1": true, "G3": true, "G4": true, "G6": true, "G8": true }, "count": 25812 }
  },
  "stops_triggered": [  ],
  "links": { "check_dim_report": "reports/check_dim_report.json", "audit": "reports/audit.jsonl" }
}

VI. 机读规则(Machine-Readable Rules)
A. gate_rules.yaml

version: "1.0.0"

gates:

G1: { schema_required: true }

G2: { anchor_coverage_min: 0.90, forbid_external_links: true }

G3: { path_required: true, min_samples: 2, delta_form: ["general","factored"], delta_ell_guard: "c_ref/fs/max(n_eff)" }

G4: { require_dim_check: true, p_dim: 1.0 }

G5: { tau_calib_s_max: 86400, clock_state: "locked" }

G6: { coverage_allowed: ["k","alpha","quantile"] }

G7: { cov_pd: true, kernel_allowed: ["exp","matern","ar1","const"] }

G8: { unique_record_id: true, unique_checksum: true, lineage_acyclic: true }

stops:

S1: "dim_check_fail or p_dim<1"

S2: "freshness_expired or clock_state!=locked"

S3: "path_block_missing or delta_ell_violate"

S4: "covariance_not_pd or cov_model_mismatch"

S5: "anchor_coverage_below_min or external_link_found"

labels: { restricted: "[Restricted]" }


B. compliance_table.csv(发布表头)

split,G1,G2(G-coverage),G3,G4,G5,G6,G7,G8,stops

train,true,0.94,true,true,true,true,true,true,""

val,true,0.95,true,true,true,true,true,true,""

test,true,0.93,true,true,true,true,true,true,""


VII. 监控与告警(Monitoring & Alerts)


VIII. 反例与修正(Anti-Patterns & Fixes)


IX. 交叉引用(Cross-References)


X. 执行勾选清单(Checklist)