Skip to content

feat: add stdlib git/CI PHI scanner - #20

Merged
abrichr merged 1 commit into
mainfrom
feat/scan-git-gate
Sep 1, 2026
Merged

feat: add stdlib git/CI PHI scanner#20
abrichr merged 1 commit into
mainfrom
feat/scan-git-gate

Conversation

@abrichr

@abrichr abrichr commented Sep 1, 2026

Copy link
Copy Markdown
Member

The clinic git PHI scanner now lives here as openadapt_privacy.scan.

clinic-node and clinic-workflows each had a copy of scripts/scan_phi.py. Those copies were already identical. rg kirill is empty on both HEADs, and this change doesn't put kirill_ back. Clinic wrappers import scan_tree(root) -> list[str] (same hit lines as today) and self_test() -> int, which plants fixtures under /tmp and returns 1 if a rule stays silent.

I almost left the package __init__ importing base and loaders at import time. That would have made import openadapt_privacy.scan pull Pillow, which is the thing clinic is trying not to drag in when it writes pip install 'openadapt-privacy[scan]'. Existing re-exports are lazy now. from openadapt_privacy import scrub_dict still works. Scan is not in __all__.

[scan] is an empty extra. Clinic can write pip install 'openadapt-privacy[scan]' and mean the git gate. A second package for 200 lines of regex would have been the wrong split. The scanner is stdlib. Matching OHIP examples are concatenated at runtime so this tree doesn't itself fail the gate.

CLI is openadapt-privacy-scan and python -m openadapt_privacy.scan. Default scans cwd. Pass --root PATH or --self-test. Forbidden dirs are still recordings, captures, screenshots, retinology, .private. Suffixes still include .rdp, .db, and the media set. gitleaks.toml and phi-patterns.txt ship next to the module.

A git regex gate doesn't belong behind the Presidio caveat. That "synthetic, not clinical" note stays on the scrubber, where the evidence is still synthetic. This extra is a CI gate. If a rule goes blind, self_test is supposed to go red; the tests monkeypatch a rule to prove it.

Opened by an agent session, not the founder.

Move the clinic scan_phi.py gate into openadapt_privacy.scan. scan_tree and
self_test are the import surface; openadapt-privacy-scan is the CLI. The
[scan] extra is empty. Importing the module does not load Presidio, spaCy,
or Pillow.
@abrichr
abrichr merged commit 728b861 into main Sep 1, 2026
4 checks passed
@abrichr
abrichr deleted the feat/scan-git-gate branch September 1, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant