Skip to content

Storage

storage

Filesystem storage queries for agent-owned directories.

Every task leaves a footprint on the host: a workspace, agent config files, and shared config mounts that survive across containers. This module measures those footprints so the orchestrator can report them.

TaskStorageInfo(task_id, workspace_bytes, agent_config_bytes) dataclass

Disk usage snapshot for a single task's host directories.

task_id instance-attribute

workspace_bytes instance-attribute

agent_config_bytes instance-attribute

total_bytes property

Combined footprint of workspace and agent config.

measure(task_dir) classmethod

Measure a single task's disk footprint.

Expects the standard layout: <task_dir>/workspace-dangerous/ for the agent-writable code, <task_dir>/agent-config/ for per-task configuration.

Source code in src/terok_executor/storage.py
@classmethod
def measure(cls, task_dir: Path) -> TaskStorageInfo:
    """Measure a single task's disk footprint.

    Expects the standard layout: ``<task_dir>/workspace-dangerous/``
    for the agent-writable code, ``<task_dir>/agent-config/`` for
    per-task configuration.
    """
    return cls(
        task_id=task_dir.name,
        workspace_bytes=_dir_bytes(task_dir / "workspace-dangerous"),
        agent_config_bytes=_dir_bytes(task_dir / "agent-config"),
    )

measure_all(tasks_root) classmethod

Measure every task under tasks_root, sorted by task ID.

Source code in src/terok_executor/storage.py
@classmethod
def measure_all(cls, tasks_root: Path) -> list[TaskStorageInfo]:
    """Measure every task under *tasks_root*, sorted by task ID."""
    if not tasks_root.is_dir():
        return []
    return sorted(
        (cls.measure(d) for d in tasks_root.iterdir() if d.is_dir()),
        key=lambda t: t.task_id,
    )

SharedMountStorageInfo(name, label, bytes) dataclass

Disk usage for one shared config mount directory.

name instance-attribute

label instance-attribute

bytes instance-attribute

measure_all(mounts_base=None) classmethod

Measure each shared config mount directory.

Labels come from the agent roster when available, falling back to a title-cased version of the directory name.

Source code in src/terok_executor/storage.py
@classmethod
def measure_all(cls, mounts_base: Path | None = None) -> list[SharedMountStorageInfo]:
    """Measure each shared config mount directory.

    Labels come from the agent roster when available, falling back to
    a title-cased version of the directory name.
    """
    base = mounts_base or mounts_dir()
    if not base.is_dir():
        return []

    return sorted(
        (cls.measure(d) for d in base.iterdir() if d.is_dir()),
        key=lambda m: m.name,
    )

measure(mount_dir) classmethod

Measure one shared config mount, returning zero bytes if absent.

Source code in src/terok_executor/storage.py
@classmethod
def measure(cls, mount_dir: Path) -> SharedMountStorageInfo:
    """Measure one shared config mount, returning zero bytes if absent."""
    return cls(
        name=mount_dir.name,
        label=cls.label_for(mount_dir.name),
        bytes=_dir_bytes(mount_dir),
    )

label_for(name) staticmethod

Describe a shared config mount without measuring its contents.

Labels come from the agent roster when available, falling back to a title-cased version of the directory name. Callers can display the label before starting a potentially slow measurement.

Source code in src/terok_executor/storage.py
@staticmethod
def label_for(name: str) -> str:
    """Describe a shared config mount without measuring its contents.

    Labels come from the agent roster when available, falling back to
    a title-cased version of the directory name.  Callers can display
    the label before starting a potentially slow measurement.
    """
    return _mount_label(name, AgentRoster.shared().mounts)