aeat.adapters.persistence.storage.bucket._sealed_archive_reader module¶
Sealed bucket-export archive reader.
Validates the gzipped tar layout, strict-parses the header, and yields the encrypted payload bytes + optional recovery-wrap bytes for the caller to decrypt. Fast-fails on layout drift (extra, missing, out-of-order, or unknown members) before any decryption attempt so a tampered or wrong-version archive surfaces precisely.
Authority: 2026-06-03-bucket-sealed-archive-adr.
- class SealedArchiveContents(header, payload_envelope_bytes, recovery_wrap_bytes)[source]¶
Bases:
objectDecoded sealed-archive contents ready for downstream decryption.
The reader returns this aggregate so the caller composes its own decryption + validation pipeline without re-parsing the archive.
payload_envelope_bytesis opaque to this layer — the caller deserialises it via the existingEnvelopepipeline.- Parameters:
header (ExportArchiveHeader)
payload_envelope_bytes (bytes)
recovery_wrap_bytes (bytes | None)
-
header:
ExportArchiveHeader¶
- read_sealed_archive(source_path)[source]¶
Read and strict-validate a sealed bucket-export archive.
- Parameters:
source_path (
Path) – Operator-specified input path.- Return type:
- Returns:
A
SealedArchiveContentscarrying the parsed header, the encrypted payload bytes, and the optional recovery-wrap bytes whenheader.recovery_wrap_presentisTrue.- Raises:
SealedArchiveLayoutError – When the tar layout deviates from the ADR contract (extra / missing / out-of-order / unknown members, non-regular members).
SealedArchiveHeaderError – When
header.jsonfails strict validation asExportArchiveHeader.SealedArchivePayloadError – When the payload member cannot be read, or when a torn write truncated the gzip stream so the decompression layer raises
EOFError/gzip.BadGzipFile. Decryption failures surface from this same class when the caller’sEnvelopeparse fails.
Truncation-detection scope: a torn write that damages the gzip stream (the common case) is caught here at read time and surfaces as
SealedArchivePayloadError. A near-complete truncation that still decompresses to the expected two or three members passes this reader; it is caught downstream by the AEAD tag on the encrypted payload, which the importer verifies before it provisions any bucket store, so a torn archive never restores a partial bucket. Read-time detection of a near-complete truncation would require a trailing integrity marker in the archive format (writer + reader change); that hardening is a tracked follow-up recorded in the crash-window reference.