Source code for cadrumo.application.storage_management.models
"""Typed reports the storage-management service returns.Every model here is an operator-facing projection of the core storage taxonomyplus what the filesystem currently holds.See Also: :data:`~cadrumo.core.STORAGE_TAXONOMY` The declaration these rows project."""from__future__importannotationsfromenumimportStrEnumfrompathlibimportPathfrompydanticimportBaseModel,Field,NonNegativeIntfrom...core.modelsimportSTRICT_FROZEN_CONFIGfrom...core.storage_taxonomyimport(StorageArea,)
[docs]classStorageAreaDisposition(StrEnum):"""Aggregate lifecycle character of an operator-facing storage area."""DURABLE="durable"RECLAIMABLE="reclaimable"MIXED="mixed"
class_StorageReport(BaseModel):"""Shared strict, frozen base for every report this package returns."""model_config=STRICT_FROZEN_CONFIG
[docs]classStorageOccupancy(StrEnum):"""What a declared location currently holds on disk. ``UNRESOLVED`` is a distinct outcome from ``ABSENT`` and the distinction is load-bearing: a bucket-scoped member with no active profile has no single path to look at, which is not the same fact as a path that was looked at and found missing. Collapsing the two would report every per-bucket member as absent on a machine that simply has no profile logged in. """UNRESOLVED="unresolved"ABSENT="absent"EMPTY="empty"POPULATED="populated"
[docs]classStorageAreaInventoryRow(_StorageReport):"""Aggregate disk use and lifecycle disposition for one public area."""area:StorageAreaoccupancy:StorageOccupancydisposition:StorageAreaDispositionreclaimable:boolresolved_paths:NonNegativeIntentry_count:NonNegativeIntfootprint_bytes:NonNegativeInt
[docs]classStorageAreaInventoryReport(_StorageReport):"""One aggregate row for each stable operator-facing storage area."""storage_root:Pathrows:tuple[StorageAreaInventoryRow,...]
[docs]classStorageTreeIssueKind(StrEnum):"""The ways the materialised tree can disagree with its declaration."""MISSING_DIRECTORY="missing_directory"FILE_WHERE_DIRECTORY_EXPECTED="file_where_directory_expected"DIRECTORY_WHERE_FILE_EXPECTED="directory_where_file_expected"ROOT_PERMISSIONS_DRIFTED="root_permissions_drifted"
[docs]classStorageTreeIssue(_StorageReport):"""One disagreement between the declared tree and the tree on disk."""kind:StorageTreeIssueKindpath:Patharea:StorageArea|None=Nonedetail:str=""
[docs]classStorageTreeCheckReport(_StorageReport):"""Read-only verdict on the materialised tree. ``root_mode_enforced`` records whether the host implements POSIX mode bits at all. A permission finding is only meaningful where it can be enforced, so the flag travels with the verdict instead of a silent absence of findings standing in for "checked and clean" on a platform that never checks. """storage_root:Pathhealthy:boolroot_mode_enforced:boolchecked_locations:NonNegativeIntissues:tuple[StorageTreeIssue,...]=()
[docs]classStorageInitReport(_StorageReport):"""Outcome of materialising the declared tree. ``created`` names only the directories this call brought into existence, so a repeat run reports an empty tuple rather than restating the whole tree. """storage_root:Pathcreated:tuple[Path,...]=()already_present:int=Field(default=0,ge=0)
[docs]classStorageReclaimReport(_StorageReport):"""Outcome of reclaiming every regenerable target in one public area."""area:StorageAreatarget_count:NonNegativeIntremoved_entries:NonNegativeIntretained_entries:int=Field(default=0,ge=0)retained_paths:tuple[Path,...]=()"""The entries that survived, so a caller can say why rather than only how many. Deliberately not on the wire payload. A count is what the operator needs in the result; the paths exist so the boundary can identify a benign, every-time retention -- an open log file -- and word its warning accordingly, instead of raising the same alarm for a locked file and a failed delete. """