gating-deid-leakage
できること
このスキルは、匿名化モデルが識別子を多く見逃したり、重大なものを漏らしたりすると失敗する、自動のチェックをビルドのパイプラインに追加します。保持された合成の患者情報に対して、すべての変更を確かめたいチーム向けです。
使う場面
- ✓匿名化の再現率が下限を下回ったら、ビルドを失敗させるテストがほしいとき。
- ✓個人識別子の漏洩があるプルリクエストを止める必要があるとき。
- ✓リリースのゲートを、CIのパイプラインで自動的に適用したいとき。
スキルのリンク
https://github.com/maziyarpanahi/openmed/blob/master/skills/gating-deid-leakage/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“合成のPHIセットでの再現率が99パーセントを下回るか、SSNが漏れた場合にビルドが失敗するテストを、CIに追加してください。”
毎週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エージェントが、匿名化済みの臨床テキストに残っている識別子(SSN、カード番号、メール、日付など)をスキャンし、残っていれば公開を止めます。
似ているスキル
test-driven-development
311k機能や修正を作る前に、まず失敗するテストを書き、それが失敗するのを確認してから、合格させる最小のコードを書くようエージェントに教えます。
verification-before-completion
311kタスク、修正、ビルドが完了した、または合格したと主張する前に、実際のチェックを実行し、その出力を読むようエージェントに教えます。
migrate-to-shoehorn
310kテストファイル内の危険な型キャストを、shoehornライブラリに置き換え、テストが部分的なデータを使いつつ型チェックを通るようにします。