feat: expand PII scrubber regression benchmarks - #874
Open
Oluwatobi843 wants to merge 1 commit into
Open
Conversation
- Expand tests/fixtures/pii_inputs.json from 4 to 22 cases covering:
- Basic PII (email, phone, numeric ID, safe text)
- False-positive cases: years, ISO dates, software versions,
currency prices, port numbers, plain sentences
- False-negative cases: subdomain emails, plus-addressed emails,
local phone numbers, phones with parentheses, national IDs,
mixed PII in a single string
- Edge cases: multiple emails, punctuation-adjacent email,
safe short numbers, lone year, ID embedded in alphanumeric text
- Fix scrubber.py to eliminate false positives:
- Phone regex now requires >= 7 digit characters (rejects years/ports)
- ISO 8601 dates (YYYY-MM-DD) are explicitly preserved before phone pass
- Currency-prefixed numbers ($£€) are excluded from phone matching
- Slash-separated tokens (dates like 2024/07/28) are not matched
- Numeric ID redaction raised to 8+ digits (from 4+)
- Add tests/benchmark_pii.py:
- Reports accuracy %, per-category breakdown, and throughput
- Supports --output FILE for JSON report (CI artifact upload)
- Supports --min-accuracy PCT flag (exits 1 if below threshold)
- Update .github/workflows/ci-python-tests.yml:
- Extend path triggers to include scrubber.py and tests/**
- Add pii-scrubber job: runs pytest + benchmark with --min-accuracy 95
- Uploads benchmark_report.json as a retained CI artifact
Closes Pulsefy#767
|
@Oluwatobi843 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #767 — adds false-positive/false-negative regression fixtures, a reproducible benchmark script, scrubber bug fixes, and CI integration.
Problem
The original PII scrubber had two known bugs:
2024), dates (2024-07-28), prices ($4500), port numbers (8080)The original fixture set (4 cases) had no false-positive or false-negative coverage, so these bugs were invisible.
Changes
scrubber.pyYYYY-MM-DD) are stashed before phone matching and restored after$£€) and slash-separated numbers (date paths) are excludedtests/fixtures/pii_inputs.json+expected_outputs.jsonExpanded from 4 to 22 test cases across four categories:
tests/benchmark_pii.py(new)Reproducible benchmark script with:
--output FILEfor JSON report (CI artifact upload)--min-accuracy PCTflag — exits 1 if below threshold.github/workflows/ci-python-tests.ymlpathstriggers to includescrubber.pyandtests/**pii-scrubberjob: runspytest+ benchmark with--min-accuracy 95Test results
Acceptance criteria