aeat.adapters.persistence.storage.bucket._manifest_io module¶
Atomic read/write IO for the plaintext bucket manifest.
The manifest sits at <bucket-dir>/manifest.toml. Writes use the
write-then-rename pattern (tmp sibling, os.replace) so a crash mid-write
can never surface as a torn read; reads round-trip through the strict
pydantic v2 BucketManifest record so an unknown key or a torn
payload fails closed at the boundary.
- manifest_path(paths)[source]¶
Return the canonical manifest path for the bucket.
- Return type:
Path- Parameters:
paths (BucketPaths)
- manifest_validation_error(message)[source]¶
Build the typed, localized
StorageValidationErrorused by manifest I/O.- Return type:
- Parameters:
message (str)
- write_manifest(paths, manifest)[source]¶
Atomically write the manifest under
<bucket-dir>/manifest.toml.Uses a write-then-rename pattern: the payload is staged under a
.tmpsibling,fsync-ed, and renamed in place viaos.replace(), after which the parent directory isfsync-ed too. A crash mid-write leaves either the previous good manifest or the new good manifest, never a torn intermediate; thefsyncpair makes that guarantee survive a hard power loss (matching the rotation atomic-write path), so a half-flushed tmp file can no longer become a zero-length manifest on reboot.- Return type:
- Parameters:
paths (BucketPaths)
manifest (BucketManifest)
- read_manifest(paths)[source]¶
Read and strict-validate the manifest from
<bucket-dir>/manifest.toml.- Parameters:
paths (
BucketPaths) – The resolved bucket paths providing the manifest file location.- Return type:
- Returns:
A strict-validated
BucketManifest.- Raises:
StorageValidationError – When the manifest cannot be read, cannot be parsed, or is missing the lifecycle status key.