storage
storage
¶
Storage usage aggregation across the package stack.
Orchestrates queries from three layers: - terok-sandbox — container overlay sizes (podman) - terok-executor — task workspace and shared mount sizes (filesystem) - terok itself — image knowledge (L0/L1/L2 classification)
Two entry points mirror two levels of detail:
get_storage_overview— fast global summary with per-project one-liners (no per-container podman--sizequeries)get_project_storage_detail— per-task breakdown for one project, including the expensive overlay size computation
ORPHAN_PROJECT_ID = '(orphans)'
module-attribute
¶
Synthetic project id for the overview row that collects L2 images whose project no longer exists in the config.
Parentheses are forbidden in real project ids (validated against
[a-z0-9][a-z0-9_-]* in project_model), so this value can never
collide with a configured project.
ProjectSummary(project_id, image_bytes, workspace_bytes, task_count)
dataclass
¶
StorageOverview(global_images, shared_mounts, projects)
dataclass
¶
Fast global summary: globals expanded, projects as one-liners.
global_images
instance-attribute
¶
shared_mounts
instance-attribute
¶
projects
instance-attribute
¶
global_images_bytes
property
¶
Total size of global images.
shared_mounts_bytes
property
¶
Total size of shared mount directories.
projects_bytes
property
¶
Total size across all projects.
grand_total
property
¶
Everything combined.
ProjectDetail(project_id, images, tasks, overlays)
dataclass
¶
Full per-task storage breakdown for a single project.
project_id
instance-attribute
¶
images
instance-attribute
¶
tasks
instance-attribute
¶
overlays
instance-attribute
¶
images_bytes
property
¶
Total size of project images.
workspace_bytes
property
¶
Total workspace size across all tasks.
overlay_bytes
property
¶
Total overlay size across all running containers.
total_bytes
property
¶
Everything for this project.
parse_image_size(text)
¶
Best-effort parse of podman's human-readable image size strings.
Returns 0 for unparseable input — storage reporting should never crash on a formatting surprise from podman.
Source code in src/terok/lib/domain/storage.py
format_bytes(n)
¶
Format bytes as a right-aligned human-readable string.
Uses SI units (1000-based) to match podman's output convention. Always returns a fixed-width string suitable for column alignment.
Source code in src/terok/lib/domain/storage.py
get_storage_overview()
¶
Gather global summary — fast, no per-container podman queries.
Iterates all projects, sums workspace sizes via terok-executor, and classifies images into global vs per-project.
Source code in src/terok/lib/domain/storage.py
get_project_storage_detail(project_id)
¶
Detailed view for one project, including overlay sizes.
This triggers podman ps --size for the project's containers —
expect a brief pause while podman computes overlay diffs.