Detect ASCII email patterns, valid IPv4 addresses and explicit literal identifiers. Merge overlapping spans, replace their union without exposing original values in receipts, and export redacted JSONL plus an inspectable HTML ledger.
Python 3.12 or later. No model credentials or third-party dependencies are required.
Build your version
From the repository root:
python3 scripts/project_test.py sensitive-text-redaction-gate --init learning-artifacts/sensitive-text-redaction-gate
python3 scripts/project_test.py sensitive-text-redaction-gate --stage 1 --path learning-artifacts/sensitive-text-redaction-gate --strictThe first run intentionally fails until you implement stage one. The supplied CLI and HTML renderer are scaffolding; they call your functions. Implement each stage without replacing your workspace with the reference.
python3 scripts/project_test.py sensitive-text-redaction-gate --all --path learning-artifacts/sensitive-text-redaction-gate --strict --report completion.json
cd learning-artifacts/sensitive-text-redaction-gate
python3 cli.py samples/input.jsonl --literals samples/literals.json --output demo-outputRun the reference
python3 scripts/project_test.py sensitive-text-redaction-gate --all --solution --strict
cd projects/sensitive-text-redaction-gate/solution
python3 cli.py samples/input.jsonl --literals samples/literals.json --output demo-outputOpen demo-output/review.html locally. Replace the sample input path with your own JSONL to use the tool beyond the demo. The API contract defines the accepted input and output shapes.
Expected result and integration
The three authored notes produce four replacement spans: two emails, one IPv4 address and one explicit case identifier. The third note survives unchanged. The exported JSONL can be read directly by a dataset or prompt preprocessing step; keep receipt.json beside it to show the exact supported scope.
The exported artifacts are redacted.jsonl, receipt.json and review.html. The supplied fixtures are authored examples. Test-level held-out cases use different values and malformed inputs; a successful demo alone does not qualify as completion.
Scope
This is a bounded pattern-based redactor, not a general PII detector or an anonymization guarantee. It recognizes ASCII email syntax, valid dotted IPv4 addresses and case-sensitive literal strings. Names, phone numbers, IPv6, obfuscated addresses and encoded secrets can remain. IDs must be non-sensitive. Review remaining text before sharing it. The HTML contains only redacted text and offset receipts, never the original values or the configured literal dictionary.
Stages
- Detect bounded sensitive spans
- Merge complete overlap unions
- Replace spans without leaking source values
- Export redacted records and bounded evidence