consent-redaction-log-py
Record consent-aware redactions for privacy review trails. Zero runtime dependencies.
Python port of @mukundakatta/consent-redaction-log. The JS sibling has the broader rationale; this README sticks to the Python API.
Why
Compliance, evals, and incident review all want the same thing: an auditable trail of what was redacted, why, and under whose consent. Most apps redact in flight and throw the trail away. This library keeps the trail without keeping the secret.
Install
pip install consent-redaction-log-py
Usage
from consent_redaction_log import RedactionLog, redact_with_consent, summarize_redactions
# 1) Inline redaction with a one-shot helper.
text = "Contact me at alice@example.com or +1 555 123 4567"
result = redact_with_consent(text, allowed_types=["email"])
result.text # "Contact me at alice@example.com or [REDACTED:phone]"
result.log # [{"type": "phone", "length": 14}]
summarize_redactions(result.log)
# {"phone": 1}
# 2) Long-running log of structured field-level redactions.
log = RedactionLog()
log.record(
field="user.message",
original="alice@example.com",
redacted="[REDACTED:email]",
consent_basis="legitimate-interest:safety-review",
)
log.record(
field="user.message",
original="+1 555 123 4567",
redacted="[REDACTED:phone]",
consent_basis="explicit:opt-in-debug",
)
log.dump()
# [
# {"field": "user.message", "redacted": "[REDACTED:email]",
# "consent_basis": "legitimate-interest:safety-review",
# "original_length": 17, "ts": "2026-04-26T12:00:00Z"},
# ...
# ]
RedactionLog does not persist the raw original; it stores the original's
length so you can spot anomalies (e.g. truncated values) without keeping the
PII. Reach for original= only at record time so you can compute the length
in one place; the value never leaves the function.
API
| Symbol | What it does |
|---|---|
RedactionLog() |
Container for structured redaction events. |
RedactionLog.record(field, original, redacted, consent_basis) |
Append one event. Returns the appended record dict. |
RedactionLog.dump() |
Return a list copy of all records. Safe to mutate. |
RedactionLog.clear() |
Reset the log. |
redact_with_consent(text, allowed_types=...) |
Inline one-shot redaction + per-call log. Returns a RedactionResult dataclass. |
summarize_redactions(log) |
Count events by type. Returns a dict[str, int]. |
Pattern coverage
redact_with_consent ships with the same two patterns as the JS sibling:
email-- RFC 5322-ish address regex.phone-- international-friendly number regex (8+ digits with optional+, spaces, dots, parens).
Pass allowed_types=["email"] to keep emails verbatim.
API differences from the JS sibling
- Python keyword args (
allowed_types=,consent_basis=) instead of the JS options object. redact_with_consentreturns aRedactionResultdataclass instead of a plain object.RedactionLogadds a structuredrecord/dumpsurface that the JS module didn't ship; matches the spec for "consent-aware redactions for privacy review trails".
See the JS sibling's README for the broader design context.
Metadata
Release files for consent-redaction-log-py 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| consent_redaction_log_py-0.1.0.tar.gz | 6.9 kB | Without provenance | Details for consent_redaction_log_py-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| consent_redaction_log_py-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for consent_redaction_log_py-0.1.0-py3-none-any.whl |
Total release size: 14.0 kB
Release files / consent_redaction_log_py-0.1.0.tar.gz
| Download URL | consent_redaction_log_py-0.1.0.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9078f34ccf0cd0a4073251c5ea8e7d4dd95428065518eccedada97b4733e2974
|
|
BLAKE2b-256 checksum How to use checksums |
d8bfb724febf886d840797ce8d0c379a1bed342b10b72ced609d09c3beac0549
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / consent_redaction_log_py-0.1.0-py3-none-any.whl
| Download URL | consent_redaction_log_py-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5214fb72a5a5d0ae3d5de8f878d2b4138de2d670eb8ba28a8d1466a8e5249890
|
|
BLAKE2b-256 checksum How to use checksums |
dcfd8e66fffdff0bcc7753a161663f031a512167c20b917e01630a1dec903567
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Security for consent-redaction-log-py 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.