aeat.adapters.inbound.sanitizer package

Public API for the AEAT PDF sanitiser.

Strips PII from real AEAT PDFs so the sanitised output can be committed as a regression-test fixture. The sanitisation strategy is token replacement: every cleartext PII value listed in a TokenMap is rewritten in place, preserving layout, fonts, and page count. The deep-extractor contract requires this because blackout-style redaction would delete the text the extractor parses against.

This package is fixture-preparation infrastructure, not runtime filing import or general-purpose anonymisation. Cleartext mappings belong in operator-local scratch files; the committed artefact should be the sanitised PDF plus the cleartext-free audit output from SanitizationResult.

Callers outside adapters.inbound.sanitizer must import exclusively from this module — the private modules (_records, _errors, _pipeline, _streams, _metadata, _dynamic, _structtree, _determinism) are implementation details.

Examples

>>> from aeat.adapters.inbound.sanitizer import sanitize_pdf, TokenMap, NifReplacement
>>> mapping = TokenMap(
...     nif=(NifReplacement(real="Y1234567X", synthetic="Y0000001S", surface_label="taxpayer NIE"),),
... )
>>> result = sanitize_pdf(source_bytes, mapping)

Submodules