aeat.application.bucket_maintenance._contracts module¶
Pydantic command + result records for BucketMaintenanceService.
Used by: _service to implement bucket operations.
The contract records sit at the package boundary so a programmatic
caller (the CLI handler, a future MCP surface) gets the same typed
input + output shape that the service consumes. Closed-value axes are
typed as their core enums per the architecture-boundaries discipline.
Every bucket selector is a BucketId.
- class RenameBucketCommand(**data)[source]¶
Bases:
BaseModelOperator request to relabel a bucket.
bucket_idis the stableBucketId; only the operator-visible label moves. The service forwards the relabel to the profile-rename single-writer primitive, which holds the cross-store atomicity (encrypted recorddisplay_nameand plaintext manifestlabelmove together).- Parameters:
- bucket_id: BucketId¶
- new_label: str¶
- class RenameBucketResult(**data)[source]¶
Bases:
BaseModelOutcome of a successful rename.
Carries the prior label so the operator-facing emitter can render the before / after pair without re-reading the manifest. The
occurred_atinstant is the same instant carried by theBUCKET_RENAMEDbucket event.- Parameters:
- bucket_id: BucketId¶
- previous_label: str¶
- new_label: str¶
- occurred_at: datetime¶
- class DeleteBucketCommand(**data)[source]¶
Bases:
BaseModelOperator request to destructively erase a bucket.
confirmed=Trueis required at the service boundary so a programmatic caller observes the same guarantee the CLI--yesflag provides. The active bucket cannot be deleted; the operator must switch profiles first.acknowledge_retention_overrideis the explicit legal-retention override: when a filed tax record is still inside its four-year LGT retention window (Ley 58/2003 art. 66/70) the erase is refused unless this flag isTrueANDretention_override_reasonis a non-empty justification the audit trail records.- Parameters:
- bucket_id: BucketId¶
- confirmed: bool¶
- acknowledge_retention_override: bool¶
- retention_override_reason: str | None¶
- class DeleteBucketResult(**data)[source]¶
Bases:
BaseModelOutcome of a successful bucket erasure.
Carries the deleted bucket’s prior label so the operator-facing emitter can render a confirming line without re-reading anything.
retention_override_usedrecords whether a still-retained record was erased under the explicit legal-retention override, andlatest_safe_erase_datenames the instant the erased set would otherwise have become safe to erase (Nonewhen nothing was inside its window).- Parameters:
- bucket_id: BucketId¶
- previous_label: str¶
- occurred_at: datetime¶
- retention_override_used: bool¶
- latest_safe_erase_date: datetime | None¶
- class ArchiveBucketCommand(**data)[source]¶
Bases:
BaseModelOperator request to move a bucket into reversible dormancy.
Unlike
DeleteBucketCommand,archiveis a soft-only tombstone: it never removes the bucket directory, soRestoreBucketCommandcan bring the same bucket back.confirmed=Truemirrorsdelete’s boundary contract so a programmatic caller observes the same guarantee the CLI--yesflag provides. The active bucket cannot be archived; the operator must switch profiles first.- Parameters:
- bucket_id: BucketId¶
- confirmed: bool¶
- class ArchiveBucketResult(**data)[source]¶
Bases:
BaseModelOutcome of a successful bucket archive.
Carries the archived bucket’s label so the operator-facing emitter can render a confirming line without re-reading the manifest.
- Parameters:
- bucket_id: BucketId¶
- label: str¶
- occurred_at: datetime¶
- class RestoreBucketCommand(**data)[source]¶
Bases:
BaseModelOperator request to bring an archived bucket back to active status.
Symmetric inverse of
ArchiveBucketCommand. Refuses when the target bucket is not currently archived (tombstoned), so a restore never silently no-ops against an already-live bucket.- Parameters:
bucket_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=128, pattern=None, ascii_only=None)])
- bucket_id: BucketId¶
- class RestoreBucketResult(**data)[source]¶
Bases:
BaseModelOutcome of a successful bucket restore.
- Parameters:
- bucket_id: BucketId¶
- label: str¶
- occurred_at: datetime¶
- class BrowseBucketCommand(**data)[source]¶
Bases:
BaseModelOperator request to enumerate a bucket’s namespace inventory.
The current shape is namespace-level only: it returns each namespace and its row count without decrypting payloads. Key-level browse requires decryption and a
SensitivityClassredaction policy, both deferred to a follow-up Step under the composition-pattern ADR.- Parameters:
- bucket_id: BucketId¶
- namespace_filter: str | None¶
- class BucketNamespaceInventoryRow(**data)[source]¶
Bases:
BaseModelOne row of the namespace-inventory browse result.
- namespace: str¶
- row_count: int¶
- class BrowseBucketResult(**data)[source]¶
Bases:
BaseModelNamespace-level browse outcome.
Returns one row per namespace present in the bucket (optionally substring-filtered by
namespace_filter), each carrying the stored-row count. Read-only; emits no bucket event.- Parameters:
bucket_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=128, pattern=None, ascii_only=None)])
rows (tuple[BucketNamespaceInventoryRow, ...])
- bucket_id: BucketId¶
- rows: tuple[BucketNamespaceInventoryRow, ...]¶
- class DiskUsageBucketCommand(**data)[source]¶
Bases:
BaseModelOperator request to measure a bucket’s on-disk footprint.
Reads only filesystem metadata (
os.statsizes) under<aeat_local_storage_root>/buckets/<bucket_id>/; it never opens the encrypted SQLite database or decrypts a secure-object payload, so no master key or active-bucket session is required. This makes the measurement safe to run against a non-active, even archived, bucket — the same non-active-safe posturepreview_discard_sandbox()already relies on for its namespace preview.- Parameters:
bucket_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=128, pattern=None, ascii_only=None)])
- bucket_id: BucketId¶
- class BucketDiskUsageSubdirRow(**data)[source]¶
Bases:
BaseModelOne on-disk subdirectory’s byte total in a disk-usage report.
subdirnames one of the bucket layout’s fixed subdirectories (db,blobs,audit); the row is emitted even when the subdirectory is empty (total_bytes=0,file_count=0) so a caller can rely on exactly the layout’s three rows always being present.- subdir: str¶
- total_bytes: int¶
- file_count: int¶
- class DiskUsageBucketResult(**data)[source]¶
Bases:
BaseModelBucket on-disk footprint outcome.
total_bytesis the sum of every regular file under the bucket’s directory tree (db+blobs+audit, plus the bucket’s own manifest file);subdirsbreaks that total down per fixed subdirectory. Read-only; emits no bucket event.- Parameters:
bucket_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=128, pattern=None, ascii_only=None)])
total_bytes (int)
subdirs (tuple[BucketDiskUsageSubdirRow, ...])
- bucket_id: BucketId¶
- total_bytes: int¶
- subdirs: tuple[BucketDiskUsageSubdirRow, ...]¶
- class ExportBucketCommand(**data)[source]¶
Bases:
BaseModelOperator request to export a bucket as a sealed archive.
The
output_pathis operator-specified; the service refuses to overwrite an existing target. Therecovery_wrap_passphrasefield is optional: when present the service derives a recovery-passphrase KEK and emits a 3-member archive (includingrecovery.wrap); when absent the service uses the bucket’s active KEK and emits a 2-member archive without recovery-wrap.- Parameters:
- bucket_id: BucketId¶
- output_path: Path¶
- recovery_wrap_passphrase: str | None¶
- class ExportBucketResult(**data)[source]¶
Bases:
BaseModelOutcome of a successful bucket export.
Carries the written archive path plus the manifest digest recorded in the sealed archive header. The digest is bound into the payload’s AEAD associated data, so import refuses a tampered header at decryption; operator emitters render the path so the operator can locate the file for backup or transfer.
- Parameters:
- bucket_id: BucketId¶
- output_path: Path¶
- manifest_digest: str¶
- recovery_wrap_present: bool¶
- occurred_at: datetime¶
- class ImportBucketCommand(**data)[source]¶
Bases:
BaseModelOperator request to import a sealed bucket archive.
The
source_pathis operator-specified. The service refuses when the archive’sbucket_idcollides with an existing live profile unlessforce_replaceisTrue; when the source archive carries a recovery-wrap member, the operator MUST supply the matchingrecovery_wrap_passphrase.- source_path: Path¶
- force_replace: bool¶
- recovery_wrap_passphrase: str | None¶
- class ImportBucketResult(**data)[source]¶
Bases:
BaseModelOutcome of a successful bucket import.
Carries the imported
BucketIdand the manifest digest the archive header declared. The digest is evidence of the sealed archive header that authenticated the payload; it is not recomputed against the freshly provisioned host manifest because import-host lifecycle timestamps legitimately differ.- Parameters:
- bucket_id: BucketId¶
- manifest_digest: str¶
- archive_schema_version: int¶
- occurred_at: datetime¶
- class InspectBucketArchiveCommand(**data)[source]¶
Bases:
BaseModelOperator request to inspect a sealed bucket archive without restoring it.
Read-only: the source archive is neither decrypted nor written to. This lets an operator confirm which bucket a backup file holds, when it was written, and whether it carries a recovery-wrap member, without needing the sealing key.
- Parameters:
source_path (Path)
- source_path: Path¶
- class InspectBucketArchiveResult(**data)[source]¶
Bases:
BaseModelOutcome of a successful sealed-archive inspection.
Every field is read from the archive’s plaintext header plus the on-disk file size; the AEAD-encrypted payload itself is never opened, so this result cannot report per-store row counts.
manifest_digestis the header’s integrity anchor (unverified here — verification only happens during a realimport, where it is authenticated as AEAD associated data at decryption).- Parameters:
- bucket_id: BucketId¶
- manifest_digest: str¶
- recovery_wrap_present: bool¶
- archive_schema_version: int¶
- created_at: datetime¶
- size_bytes: int¶