# Control Plane PII diagnostic — SYNTHETIC DATA

This is actual product code running on a manually annotated, fixed synthetic dataset.
It is not the browser sandbox, customer data, a production trial or a representative benchmark.
No network, API, LLM, production credential or external package is used by the evaluation.

## Reproduce

Install **CPython 3.14.6**, extract the ZIP, and replace the absolute path below.
`python3.14` must resolve to that exact interpreter version. No pip installation is needed.
`-I -S` isolates imports from user paths and site packages so optional Presidio cannot change the backend.

```sh
EVAL_DIR="/absolute/path/to/pii-evaluation"
python3.14 -I -S "$EVAL_DIR/run.py" --check
python3.14 -I -S "$EVAL_DIR/run.py" --quality-gate
python3.14 -I -S "$EVAL_DIR/test_evaluation.py"
```

Expected: reproduction PASS, exit 0; quality PASS, exit 0; fourteen evaluator tests PASS, exit 0.
A plain `run.py` invocation measures successfully with exit 0 even when quality fails.
`--check` compares every measured row to `results.json`, **including all per-case outputs**.
Reproduction alone is not a detector-quality pass. `--quality-gate` enforces the predeclared zero-error criteria.
Wrong runtime, source hash, dataset hash or invalid input is an evaluation error, exit 2.
Use `--output /absolute/path/report.json` to save a fresh full report outside the extracted bundle without modifying the baseline.
Outputs inside the bundle are refused so `--output` cannot overwrite the comparison baseline.

## Source and configuration

Product: ThePlus Control Plane.
Commit: `3399226ef8daabb4452f99538b5a72f5305d5ec6`.
Original path: `app/services/dataguard.py`.
Vendored unmodified as `vendor/dataguard.py`, SHA-256:
`b537d35d5a835034082ef6a86a80f580fe5dcefd606d4dd787719d3544e3280a`.

The runner calls `detect_pii`, `detect_pii_entities` and `redact_pii` directly.
It asserts the **regex fallback** is active. It does not substitute a reimplementation.
`config.json` pins runtime, backend, source, dataset digest and zero-error thresholds and gate version.
`results.json` records the source, dataset and configuration digests.
`provenance.json` hashes every downloadable input, tool and result. These are reproducibility
records, not signed attestation: someone replacing the entire bundle can replace its hashes too.
The source commit is the captured version, not a claim about current product HEAD.

## Observed results and exact scoring (repaired source)

40 cases: 25 sensitive, 15 benign, with 27 manually labelled sensitive spans.
Labels and thresholds were written before the first measurement. The author had inspected the
product source; this is an authored diagnostic set, not an independent or held-out evaluation.

- Full-span detection: **27/27 (100% on this set); 0 misses**.
- Benign cases flagged or changed: **0/15**.
- Exact redaction: **40/40**, with **0 failures**.
- Character precision: 445/445 predicted characters overlap gold spans (100% on this set).
- Case-level detection alone: TP 25, FN 0, FP 0, TN 15. A case-level hit alone does not prove complete masking.

Gold offsets are Python Unicode character offsets, start inclusive/end exclusive. Full coverage
requires every character in the labelled identifier, including its punctuation, to be covered by
predicted spans. Overlapping predictions are unioned, not counted twice. Entity type accuracy
and product confidence scores are not graded. Character precision is not entity precision.
Benign false positives include any boolean detection, entity prediction or changed output.

Exact redaction replaces each gold span with `[REDACTED]` and preserves all surrounding text.
Known product placeholder types are normalized to that marker. Partial masking, excess masking,
retained identifier characters and altered context fail. Searching only for disappearance of the
original full substring would incorrectly accept partial leakage; that approach is not used.

Previously missed: `email-plus`, `email-apostrophe`, `phone-parens`, `phone-intl-parens`, `address-lower`.
Previous false positives: `amount-integer`, `uuid`, `dated-id`, `date`. These nine cases now pass.
`previous-results.json` preserves the original failures. The original complete bundle is
`history/pii-eval-v1.zip`. Dataset bytes, gold labels and the measurement functions are unchanged. Gate version 2 adds
`max_case_false_negatives: 0`; the original three thresholds remain zero. The earlier gate and
source are preserved in `history/pii-eval-v2.zip`, which passed the fixed corpus but failed the
subsequent contextual-bypass review. No historical gate has been rewritten. The prior v3 bundle is preserved in
`history/pii-eval-v3.zip`; it passed the fixed corpus but failed the later context-stability review.
The v4 bundle is preserved in `history/pii-eval-v4.zip`; its fixed corpus passed, but the later review demonstrated attached-extension misses. This update retains gate version 2 unchanged.
The case named `uuid` is a standalone reference fragment, **not a complete UUID**.
Every input, gold span, prediction, actual output and expected output is in `results.json`.
No labels or thresholds were relaxed to turn these results green. The extra gate criterion
closes the boolean-only gap; separate synthetic bypass cases and the four original-context/split-cue regressions are
also in the bundled tests. Separate synthetic phone-extension cases now assert that the entire base number and supported extension are masked.

## Broken-detector proof

```sh
python3.14 -I -S "$EVAL_DIR/run.py" --mutation never-detect --quality-gate
python3.14 -I -S "$EVAL_DIR/run.py" --mutation no-redaction --quality-gate
python3.14 -I -S "$EVAL_DIR/run.py" --mutation redact-everything --quality-gate
python3.14 -I -S "$EVAL_DIR/run.py" --mutation boolean-only --quality-gate
```

All must exit 1. These explicit, in-memory negative controls are **not product behavior**:
never-detect has 27 misses; no-redaction has 25 exact-output failures; redact-everything has
14 benign false-positive cases (the empty string stays empty). The boolean-only control
leaves spans and redaction intact but creates 25 case-level false negatives; gate version 2
rejects it. Each also fails `--check`.
The repaired baseline passes the fixed quality gate, and each broken variant fails.
The tests additionally assert worsening measurements,
and a separate, hand-constructed perfect scoring oracle passes while partial masking and
benign corruption fail. The perfect oracle is a scorer test, not a product score.

## Limits

Only the three raw-text functions of the pinned regex backend are exercised. No Presidio,
field-aware amount handling, gateway/API integration, authorization, persistence, concurrency,
production traffic, latency or customer outcome is tested. The number-like false positives are
for free text; they do not establish behavior of structured amount fields.
This small public English/identifier-format set has no unseen holdout, prevalence estimate,
coverage guarantee or generalization bound. Values were constructed as synthetic test strings;
they do not identify actual people and were never sent or used to transact.
Passing this dataset would not prove safe PII handling or regulatory compliance. The repaired
quality PASS covers only the fixed zero-error criteria on these cases. The product was repaired
using this public dataset, so these results are regression evidence, not held-out accuracy. Production and broader claims remain
unverified. The product source was repaired in the pinned commit; the original source and failures remain archived.
Explicit English contact cues anywhere in the input now veto the benign-format exemptions,
including across clauses/newlines. International separators and wrapped-number compatibility
are restored. This deliberately redacts ambiguous amounts/references in mixed contact text;
the new product tests assert that conservative behavior. Redaction now freezes span decisions on the original text, unions overlapping spans and
then applies masking without reclassification. Supported multiword contact cues accept
whitespace including line breaks; original text offsets remain unchanged. Overlap markers
retain pattern precedence, not a new entity-type accuracy guarantee. Phone candidates now include numeric `x`, `ext`, `ext.` and `extension` suffixes (case-insensitive, optionally spaced or hyphen-separated). This does not establish arbitrary suffix or obfuscation coverage. Contextual exclusions remain heuristics: a short local phone deliberately presented in an
exempt reference/amount shape may be ambiguous. Large amounts, other currencies and unsupported
identifier formats can still fail. This evaluation does not establish resistance to arbitrary
PII obfuscation or deceptive labels.
