gating-deid-leakage
Skill này làm gì
Skill này thêm một kiểm tra tự động vào pipeline build, làm thất bại khi mô hình khử nhận dạng bỏ sót quá nhiều định danh hoặc làm rò rỉ một định danh nghiêm trọng. Dành cho các nhóm muốn mọi thay đổi được kiểm tra trên một tập tổng hợp giữ lại về thông tin bệnh nhân.
Khi nào nên dùng
- ✓Khi bạn muốn một kiểm thử làm hỏng bản build nếu recall khử nhận dạng giảm dưới ngưỡng.
- ✓Khi bạn cần chặn các pull request để một định danh cá nhân không bị rò rỉ.
- ✓Khi bạn muốn các cổng phát hành được thực thi tự động trong pipeline CI.
Liên kết skill
https://github.com/maziyarpanahi/openmed/blob/master/skills/gating-deid-leakage/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy thêm một kiểm thử vào pipeline CI để làm hỏng bản build nếu recall trên bộ PHI tổng hợp giảm dưới 99 phần trăm hoặc có số SSN nào bị rò rỉ.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent viết một kiểm thử chạy đánh giá trên bộ dữ liệu tổng hợp đã commit, kiểm tra ngưỡng recall và không có rò rỉ nghiêm trọng, rồi trả về trạng thái thất bại khi một trong hai không đạt.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Nó có dùng dữ liệu bệnh nhân thật không?
Không. Kiểm tra dùng một bộ tổng hợp giữ lại đã được commit.
Nó có giống skill đánh giá không?
Không. Skill đánh giá giải thích các cổng, còn skill này gắn chúng vào CI để bản build thất bại.
Nó phù hợp với hệ thống CI nào?
Hướng dẫn bao quát các test pytest và các bước dòng lệnh, kể cả GitHub Actions.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 5.8k
- Vị trí xếp hạng
- #14705
- Giấy phép
- Apache-2.0
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
annotating-variants
5.8kGiúp agent dự đoán tác động của biến thể di truyền, đổi tên HGVS sang vị trí bộ gen và gắn tần suất quần thể bằng công cụ chú giải miễn phí.
ask-openmed
5.8kGiúp agent chọn đúng quy trình OpenMed cho yêu cầu về văn bản lâm sàng, luôn kiểm tra quyền riêng tư trước khi có thể có dữ liệu bệnh nhân.
assembling-fhir-bundles
5.8kGói nhiều bản ghi y tế FHIR thành một Bundle giao dịch để gửi tới EHR, với các tham chiếu nội bộ được liên kết đúng.
auditing-deid-leakage
5.8kQuét văn bản lâm sàng đã khử nhận dạng để tìm định danh còn sót như SSN, số thẻ, email và ngày tháng, và chặn phát hành nếu còn sót.
Skill tương tự
test-driven-development
311kDạy agent của bạn viết kiểm thử thất bại trước, xem nó thất bại, rồi viết đoạn mã ngắn nhất để vượt qua trước khi làm bất kỳ tính năng hay bản sửa nào.
verification-before-completion
311kDạy agent của bạn chạy kiểm tra thực tế và đọc kết quả đầu ra trước khi khẳng định một việc, bản sửa hoặc bản build đã hoàn thành hay vượt qua.
migrate-to-shoehorn
310kThay các ép kiểu rủi ro trong tệp kiểm thử bằng thư viện shoehorn, để các bài kiểm thử dùng dữ liệu một phần vẫn qua được kiểm tra kiểu.