aeat.adapters.inbound.sanitizer._structtree module

StructTree drop for adapters.inbound.sanitizer.

The Tagged-PDF structure tree (Root.StructTreeRoot) carries accessibility text via /ActualText, /Alt, and /E entries. Scrubbing the body Tj operands does not automatically catch these — the structure tree is a parallel surface. The AstraZeneca contract redaction failure was rooted in this gap.

The sanitiser drops the entire StructTreeRoot rather than walking it. Drop > scrub: a missed key is a leak; lost accessibility metadata in a regression-test fixture is harmless. The SanitizationWarning structtree_dropped_lossy records the trade-off so callers know the fixture is no longer screen-reader-equivalent to the source.

drop_struct_tree(pdf)[source]

Removes Root.StructTreeRoot if present.

Parameters:

pdf (Pdf) – An open PDF whose StructTree should be wiped.

Return type:

tuple[ScrubbedSurface, tuple[SanitizationWarning, ...]]

Returns:

A 2-tuple of (counter, warnings). The counter is a ScrubbedSurface that is zero when the tree was absent and one when it was dropped. Warnings carry SanitizationWarning structtree_dropped_lossy when the tree was present so callers see the lossy step in the audit log.