pyveil

Evidence, not promises

A reproducible detector regression evaluation.

The public corpora test documented supported shapes, negative examples, labeled-value removal, and the no-raw-findings contract on every change.

Core corpus v1 & Optional KR corpus · pyveil 0.4.0 · Last run November 30, 2026

Current result

39 cases

33 positive and 6 negative synthetic regression cases.

Public corpus

36 expected findings

Across email, phone, card, JWT, credentials, URL, and key-value shapes.

Exact type counts

1.000 precision

Zero extra findings in this supported-shape corpus.

0 false positives

1.000 recall

Every labeled supported-shape finding was detected.

0 false negatives
Read this before quoting the numbers

This is a synthetic supported-shape regression corpus, not a representative real-world PII benchmark. It does not measure broad semantic names, addresses, languages, documents, images, or unknown provider formats.

What CI checks

python evaluation/evaluate.py --check exits non-zero if any case has:

  • a finding count or entity type different from the expected result
  • a labeled synthetic sensitive value left in redacted output
  • a non-empty Finding.raw
  • a negative input mutated unexpectedly

The gate runs alongside Ruff, mypy, the Python 3.8-3.14 test matrix, package build, and Twine metadata validation.

Reproduce it locally

git clone https://github.com/hyeonsangjeon/pyveil.git
cd pyveil
python -m pip install -e .

python evaluation/evaluate.py --check
python evaluation/evaluate.py --json
python evaluation/evaluate.py --benchmark
pyveil synthetic detector regression evaluation
cases: 39 (33 positive, 6 negative)
expected findings: 36
precision: 1.000
recall: 1.000
false positives: 0
false negatives: 0
mismatches: 0
scope: synthetic supported-shape regression only; not real-world PII recall

The optional benchmark reports a machine-dependent median for a fixed synthetic payload. It is diagnostic only and is not a latency service-level objective.

Built-in shapes covered by corpus v1

FindingCovered examplesImportant limit
EMAILCommon addresses, plus tags, subdomains, multiplesNot a full RFC mailbox parser
PHONEKorean, separated international, compact E.164Not a country-aware phone library
CREDIT_CARDSeparated Luhn-valid test numbersLuhn validation does not prove a real card
JWTCompact three-segment shapeNo signature or claims validation
AUTH_HEADERBearer, Basic, Token, ApiKeyNot every custom auth scheme
PRIVATE_KEYPEM private-key block shapeNo key validity check
API_KEYHigh-signal OpenAI, GitHub, Slack, Google, AWS shapesNot every provider format
URL_QUERY_SECRETToken, key, and secret query parametersKey-name driven
KV_SECRETPassword, cookie, secret, token pairsKey-name driven

Optional Korean PII corpus (evaluation/corpus_kr.json)

The opt-in clean-room Korean PII rulepack (--rulepack kr / rulepacks=("kr",)) has its own public synthetic regression corpus with citizen and foreigner RRNs, NTS-checksummed BRNs, context-anchored Korean bank accounts, context-anchored contiguous Korean mobile numbers, and negative controls.

45 cases

31 positive and 14 negative clean-room synthetic cases.

evaluation/corpus_kr.json

41 expected findings

Across KR_RRN, KR_BRN, KR_BANK_ACCOUNT, PHONE, and EMAIL.

Exact type counts

1.000 precision

Zero false positives on invalid checksums, unanchored numbers, dates, and versions.

0 false positives

1.000 recall

Every labeled supported-shape Korean PII finding was detected.

0 false negatives
python evaluation/evaluate.py --corpus evaluation/corpus_kr.json --rulepack kr --check
python evaluation/evaluate.py --corpus evaluation/corpus_kr.json --rulepack kr --json
pyveil synthetic detector regression evaluation
cases: 45 (31 positive, 14 negative)
expected findings: 41
precision: 1.000
recall: 1.000
false positives: 0
false negatives: 0
mismatches: 0
scope: synthetic supported-shape regression only; not real-world PII recall
FindingCovered examplesImportant limit
KR_RRNCitizen (1-4) & foreigner (5-8) hyphenated and keyword-anchored contiguous 13-digit RRNsEnforces century-aware date and legacy mod-11 check digit by default; pass korean_pii_rules(strict_checksum=False) for randomized post-October 2020 RRNs
KR_BRNHyphenated and keyword-anchored contiguous 10-digit business registration numbersValidates NTS checksum and rejects all-same-digit placeholders; unanchored 10-digit IDs are ignored
KR_BANK_ACCOUNT10-14 digit accounts near Korean bank names or account keywordsContext-anchored by design; unanchored tracking/order numbers are intentionally excluded
PHONE (KR context)Keyword-anchored contiguous 01[016789] mobile numbersRequires surrounding phone/mobile context keyword to avoid colliding with arbitrary 11-digit IDs

Reproducible local comparison benchmark

evaluation/benchmark_compare.py measures pyveil, presidio-analyzer, and guardrails-ai side by side in isolated uv virtual environments on the same Python runtime, writing verified JSON diagnostics to evaluation/benchmark-results.json.

python3 evaluation/benchmark_compare.py --python 3.12 --passes 50 --output evaluation/benchmark-results.json

Latest local measurement on Apple M6 (12 logical cores, arm64, Darwin 27.0.0) with Python 3.12.15 (2026-11-30T05:52:35Z, 50 warm passes / 1,950 documents on evaluation/corpus.json): pyveil 0.4.0 recorded 0 runtime dependencies, 262.19 KB (0.256 MB) installed footprint, 13.028 ms median cold import+init, 0.0125 ms warm median / 0.0202 ms p95 per document (73,212.6 docs/sec), and 1.000 precision / 1.000 recall on both the 20-case shared PII subset and the 39-case full corpus.

See the measured local comparison table for exact verbatim numbers for presidio-analyzer 2.2.366 and guardrails-ai 0.11.0, including air-gap status and fair NER scope disclosure.

Source and contribution policy

The corpus and evaluator are standard-library Python and ship in the source distribution. Detector changes must add focused synthetic positive and negative cases, preserve the no-raw-value contract, and document provenance.