Gating Deid Leakage logo

Gating Deid Leakage

CommunityPopular
maziyarpanahi
gating-deid-leakage

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", or "leakage check in CI" for OpenMed.

Overview

Publishermaziyarpanahi
Repositoryopenmed
Skill namegating-deid-leakage
Stars
5.3K
Forks
677
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by maziyarpanahi on GitHub. Read the source before you install it.

Installation

Install the Gating Deid Leakage AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/maziyarpanahi/openmed.git /tmp/openmed
mkdir -p .claude/skills
cp -r /tmp/openmed/skills/gating-deid-leakage .claude/skills/gating-deid-leakage
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Gating Deid Leakage in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Gating Deid Leakage on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Gating Deid Leakage is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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

python
# 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):

bash
# 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

yaml
# .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

  1. 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.
  2. Pick the floor from policy. Don't hardcode a magic number you invented — align to the gate's published floors (G1A_V16_RECALL_FLOOR etc. in openmed.eval.release_gates) and the active policy profile.
  3. Run the suite → gate the report (pytest fixture above).
  4. Assert two invariants: critical_leakage_count == 0 and per-label recall ≥ floor. Optionally assert decision == RELEASABLE for the full G1a–G8 check.
  5. Make it required. Mark the job a required status check so a red gate blocks merge — a passing-but-not-required gate protects nothing.
  6. 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 same ReleaseGate.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's GateReport is the evidence the model card cites under "evaluation".
  • Pairs with enforcing-nophi-logging: the gate proves the model doesn't leak; the logging guard proves your runtime doesn't leak.

Edge cases & gotchas

  • Fail closed, never open. If the candidate report is missing or the eval errors, treat it as a failure. Don't || true the step.
  • A passing F1 is not a passing gate. Recall floor + zero critical leakage are the load-bearing assertions; assert them explicitly even if you also check decision.
  • Held-out must stay held-out. If the gate set leaks into calibration or training, the gate measures memorization, not generalization. Keep splits disjoint (see building-gold-corpus).
  • Pin the model and milestone. Floors change per milestone (v1.6 vs v2.0); pin both so a "passing" gate doesn't silently weaken.
  • No real PHI in CI artifacts or logs. The gate report is offsets/hashes only; don't print fixture text in CI output.
  • Baselines are inputs, not outputs of the gate. Promote last-green baselines in a separate, reviewed step — never auto-write them from the gate job.

Standards & references

Frequently asked questions

What does the Gating Deid Leakage AI skill do?

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", or "leak...

Why use Gating Deid Leakage on TypingMind?

Because you install it once and use it with any model. Gating Deid Leakage is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Gating Deid Leakage in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/maziyarpanahi/openmed/tree/master/skills/gating-deid-leakage. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Gating Deid Leakage?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Gating Deid Leakage?

As many as you like. As long as a model supports skills, you can use Gating Deid Leakage with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Gating Deid Leakage AI skill free?

Yes. It is published on GitHub by maziyarpanahi under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇