Skip to content

fix(phi-hook): v1.5 recall-hardening — close 7 false-negatives + ship scan-history - #3

Merged
rdmgator12 merged 1 commit into
mainfrom
fix/phi-hook-v1.5-recall-hardening
Jun 22, 2026
Merged

fix(phi-hook): v1.5 recall-hardening — close 7 false-negatives + ship scan-history#3
rdmgator12 merged 1 commit into
mainfrom
fix/phi-hook-v1.5-recall-hardening

Conversation

@rdmgator12

Copy link
Copy Markdown
Owner

What & why

A review of hooks/phi_hook.py found it was clean code but weaker than it looked — a heuristic PHI gate with real false-negatives. This closes all seven, each confirmed empirically (the gap now catches, legit cases still pass) and covered by new tests.

Suite 61 → 86 · ruff clean · scan-history.py reports the repo clean across full history.

Fixes

# Gap (was a false-negative) Fix
1 patient_list.csv evaded both the binary gate and the label heuristics Pattern 5: .csv/.tsv/.psv gate outside allowlists
1b CSV rows carry values (Name,2015-03-01,00123…), not the literal words DOB/MRN Pattern 2 also matches value-shaped record rows
2 Pattern 1 only scanned diff content, never the staged file paths Pattern 1 now scans paths too (patient-named file under Maieutic/Themis/Nostos)
3 Any single disease word exempted a whole slug (johnson-asthma-r passed) Disease allowlist requires both slug tokens be clinical
4 [Jane Doe, DOB …] was stripped and immunized by the placeholder allowlist Strip narrowed to literal placeholder vocab only
5 Middle initials (John A. Smith) and apostrophes (O'Brien) evaded NAME_SHAPE Extended; all-caps acronyms (MRI) still excluded
6 config-secrets.yaml / *secrets.json slipped CRED_FILE broadened
7 Changelog claimed hooks/scan-history.py — it was never committed Shipped it: read-only retroactive full-history scanner reusing the same patterns

Verification

  • python -m unittest discover -s hooks/tests86 tests OK (25 new regression tests)
  • ruff check hooks/All checks passed!
  • python hooks/scan-history.pyclean (248 text blobs / 30 commits, no PHI)
  • No real PHI in the diff — all examples are synthetic/placeholder; doc/comment examples use <First>/<Last>/YYYY-MM-DD so the hook never flags its own source.

🤖 Generated with Claude Code

… scan-history

Review found the gate was clean code but weaker than it looked: a heuristic with
real false-negatives. Each fix was confirmed empirically (the gap now CATCHES, legit
cases still PASS) and is covered by new tests. Suite 61 -> 86, ruff clean.

1. Pattern 5: structured-data gate (.csv/.tsv/.psv) outside allowlists — a patient
   line-list is the likeliest clinician leak and evaded both the binary gate and the
   label heuristics.
2. Pattern 2 also matches value-shaped record rows (name + DOB-value + id, e.g. a CSV
   line), so the literal words DOB/MRN need not appear.
3. Pattern 1 now scans staged file PATHS, not just diff content.
4. Disease allowlist requires BOTH slug tokens be clinical (was: any single disease word
   exempted the whole slug, so johnson-asthma-r passed).
5. NAME_SHAPE catches middle initials and apostrophes; all-caps acronyms still excluded.
6. Bracket-placeholder strip narrowed to literal placeholder vocab.
7. CRED_FILE catches prefixed secrets (config-secrets.yaml) and *secrets.json.

Also: shipped hooks/scan-history.py (claimed in v1.4, was never committed) — a read-only
retroactive full-history scanner. All doc/comment examples use placeholders so the hook
never flags its own source.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rdmgator12
rdmgator12 merged commit 5d7b387 into main Jun 22, 2026
1 check passed
@rdmgator12
rdmgator12 deleted the fix/phi-hook-v1.5-recall-hardening branch June 22, 2026 15:24
rdmgator12 added a commit that referenced this pull request Jun 22, 2026
The hook code shipped in #3 but the repo-level docs didn't reflect it.

- CHANGELOG.md: add [1.2.1] entry (Security: 7 false-negatives closed; Added:
  scan-history.py + 86-test suite).
- CONTRIBUTING.md: wire the "don't include personal data" rule to the enforcing
  pre-commit hook + scan-history.py; add install/audit/test commands.
- README.md: list hooks/ in Project Structure; add a Privacy & Safety section.

Docs-only; no code change. Hook patterns/tests/ruff unchanged and still green.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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