Skip to content

feat(volume): disky can't report its own free space #1

Description

@biliboss

Problem

An agent guarding "keep at least 30 GB free" cannot get that number out of disky.

  • disky stats reports what a past scan measured. Different question, and it needs a snapshot (~3 min traversal) to answer at all.
  • disky predict returns fill_at: null with reason provide --free-bytes unless the caller shells out to df -k / | awk '{print $4*1024}' and does the unit math by hand. The default-path output is inert.
  • disky growth --over-n's --fill-target help already claims "Default: free bytes on the volume that holds $HOME". The code never implemented it — the flag is a plain Option<u64> passed straight through as None.

So the tool that exists to answer "am I running out of disk" is the one tool in the loop that has to be told how much disk is left.

Proposal

  1. volume module — statvfs(2) probe: probe(path) -> VolumeRecord, free_bytes(path) -> Option<u64>.
  2. disky free [PATH] — live total / free / used / used_pct for the volume holding PATH (default $HOME), kind="volume", no snapshot required.
  3. Default predict --free-bytes and growth --fill-target to the probe, making the existing --help promise true.

Details that matter

  • free_bytes from f_bavail (unprivileged-writable), not the root-only figure — the honest answer to "can I still write files".
  • f_frsize is the multiplier, not f_bsize (preferred I/O size is the wrong unit for these block counts).
  • free_bytes() returns None on probe failure, never 0 — a failed statvfs reporting 0 would read as a full disk and could trigger a cleanup.

Verification

Positive control against df -k at the same instant, plus a negative control (bad path must error, not report 0 free).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions