gating-deid-leakage
它能做什么
这项技能在构建流水线中添加自动检查,当去标识化模型漏掉过多标识符或泄露关键标识符时,构建即告失败。适合希望每次改动都在一组预留的合成患者信息上进行测试的团队。
适用场景
- ✓当你希望在去标识化召回率低于下限时让构建失败的时候。
- ✓当你需要阻止让个人标识符泄露的拉取请求的时候。
- ✓当你希望在 CI 流水线中自动执行发布关口的时候。
技能链接
https://github.com/maziyarpanahi/openmed/blob/master/skills/gating-deid-leakage/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请在我们的 CI 流水线中添加一项测试:如果合成 PHI 数据集上的召回率低于 99%,或任何社会安全号泄露,就让构建失败。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会编写一项测试,在已提交的合成数据集上运行评估,检查召回率下限和零关键泄露,只要其中一项不满足,就返回失败状态。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Gating De-id Leakage in CI
Logs, baselines, and models drift. The only durable defense is a gate that runs on every change and fails closed when de-identification regresses. This skill operationalizes OpenMed's leakage-first ethos into a CI check: recall must stay above the floor and critical leakage must be exactly zero, or the build goes red.
When to use this skill
- You want a pytest test or CLI step that exits nonzero on de-id regression.
- You need to block PRs that drop PHI recall or introduce a leak.
- You want OpenMed's release gates (
ReleaseGate, G1a–G8) enforced in CI. - You maintain a synthetic held-out PHI set and want it checked automatically.
For the full gate semantics see evaluating-with-leakage-gates; this skill is
about wiring it into CI so it fails the build.
Quick start — a pytest gate
# tests/eval/test_deid_leakage_gate.py
import pytest
from openmed.eval import run_suite, ReleaseGate, RELEASABLE
RECALL_FLOOR = 0.99 # direct-identifier recall floor
HELD_OUT = "eval/heldout/phi_synthetic.json" # SYNTHETIC, committed
@pytest.fixture(scope="module")
def gate_report():
report = run_suite(
HELD_OUT,
suite="golden",
model_name="OpenMed/Privacy-PII-Detection",
device="cpu",
metadata={"family": "PII", "tier": "base", "policy": "hipaa_safe_harbor"},
)
return ReleaseGate(milestone="v1.6", policy="hipaa_safe_harbor").evaluate(report)
def test_no_critical_leakage(gate_report):
# Hard zero: one leaked SSN/credit-card is a breach, full stop.
assert gate_report.critical_leakage_count == 0, "critical PHI leaked"
def test_recall_floor(gate_report):
low = {
label: r
for label, r in gate_report.per_label_recall.items()
if r < RECALL_FLOOR
}
assert not low, f"recall below floor: {low}"
def test_releasable(gate_report):
# The structural decision: any failed gate -> QUARANTINED -> red build.
failed = [c.gate for c in gate_report.gate_results if not c.passed]
assert gate_report.decision == RELEASABLE, f"quarantined; failed gates: {failed}"
pytest exits nonzero on any failure, so CI turns red automatically.
Quick start — a CLI gate
The harness ships a main() that fails closed (exit 1 on quarantine):
# Produce a candidate report, then gate it. Nonzero exit blocks the job.
python -m openmed.eval.release_gates \
--candidate eval/out/candidate_report.json \
--baseline-store eval/baselines/last_green.json \
--milestone v1.6 --policy hipaa_safe_harbor \
--output release-gate-report.json
Exit codes: 0 RELEASABLE, 1 QUARANTINED, 2 evaluation error before a
report. CI should treat 1 and 2 as failures.
Wire it into GitHub Actions
# .github/workflows/deid-gate.yml
name: de-id leakage gate
on: [pull_request]
jobs:
gate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- run: uv pip install --system -e ".[hf]"
- name: Run de-id leakage gate
run: uv run pytest tests/eval/test_deid_leakage_gate.py -q
# The job fails (red) automatically if pytest exits nonzero.
Workflow
- Curate a synthetic held-out PHI set and commit it (offsets + labels, no
real patient text). Use
building-gold-corpus. It must be disjoint from any calibration/training data. - Pick the floor from policy. Don't hardcode a magic number you invented —
align to the gate's published floors (
G1A_V16_RECALL_FLOORetc. inopenmed.eval.release_gates) and the active policy profile. - Run the suite → gate the report (pytest fixture above).
- Assert two invariants:
critical_leakage_count == 0and per-label recall ≥ floor. Optionally assertdecision == RELEASABLEfor the full G1a–G8 check. - Make it required. Mark the job a required status check so a red gate blocks merge — a passing-but-not-required gate protects nothing.
- On failure, the harness CLI can open/refresh a tracking issue
(
--issue-on-failure) so the regression is visible, not silently retried.
Hand-off to / from OpenMed
- From
evaluating-with-leakage-gates: this skill is the CI wrapper around the sameReleaseGate.evaluate(...)call — reuse its gate semantics. - From
building-gold-corpus: supplies the synthetic held-out fixtures the gate runs against. - To
authoring-model-cards: a green gate'sGateReportis the
常见问题
它使用真实患者数据吗?
不使用。检查使用已提交的合成预留数据集。
它和评估技能是同一个东西吗?
不是。评估技能负责解释关口,而这项技能把它们接入 CI,使构建失败。
它适用于哪些 CI 系统?
指引涵盖 pytest 测试和命令行步骤,包括 GitHub Actions。
详情
作者的原始描述
Add a CI gate that fails the build when an OpenMed de-identification model's recall on a held-out PHI set drops below threshold or any critical identifier leaks. Use when the user wants a pytest test or CLI step that exits nonzero on de-id regression, wants to wire OpenMed's leakage-first release gates into GitHub Actions / CI, needs a recall floor plus zero-leakage assertion against a synthetic held-out set, or wants to block merges that weaken de-identification. Trigger on \"CI gate\", \"fail the build\", \"regression test\", \"de-id recall threshold\", \"block the merge\", \"exit nonzero\",
repo: maziyarpanahi/openmed
热度
- GitHub 星标
- 5.8k
- 排名
- #14705
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
annotating-variants
5.8k帮你的智能体预测基因变异的作用,把 HGVS 名称转换为基因组位置,并使用免费的公共注释工具添加人群频率。
ask-openmed
5.8k帮你的智能体为临床文本请求选择合适的 OpenMed 工作流程,并在可能涉及患者数据时,先进行隐私检查。
assembling-fhir-bundles
5.8k把多份 FHIR 健康记录打包成一个事务 Bundle,可直接发送给 EHR 系统,并正确链接其中的内部引用。
auditing-deid-leakage
5.8k扫描已去标识化的临床文本,查找残留的标识符,例如社会安全号、银行卡号、电子邮件地址和日期,若仍有残留则阻止发布。