Conversation
… target
An agent guarding "keep 30 GB free" had no way to ask disky for that number:
`stats` answers what a past scan measured (and needs a ~3 min traversal to
answer at all), while `predict` returned a null fill date until the caller
shelled out to `df -k` and did the unit arithmetic by hand.
- new `volume` module: `probe(path)` + `free_bytes(path)` over `statvfs(2)`.
`f_bavail * f_frsize` — unprivileged-writable blocks, fragment size as the
multiplier (`f_bsize` is the preferred I/O size and the wrong unit here).
`free_bytes` returns None on failure, never 0: a failed probe reporting 0
would read as a full disk and could trigger a cleanup.
- `disky free [PATH]` emits {path, total_bytes, free_bytes, used_bytes,
used_pct} under kind="volume". No snapshot, no scan.
- `predict --free-bytes` and `growth --fill-target` now default to the probe.
The latter's --help already documented this default; the code never had it.
`used_pct` divides by total blocks, so it reads 1-2 points above df's Capacity
column, which divides by used+available and hides the root reserve. Documented
on the field rather than silently matching either one.
Verified against `df -k` at the same instant (27006492 KiB avail = 25.8 GB),
with a negative control for a nonexistent path (exit 3, RFC 9457 problem).
Closes #1
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X3Z3sDkDDSUHQRxSw7aDCV
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1.
What
disky free [PATH]— livestatvfs(2)on the volume holdingPATH(default$HOME). No snapshot, no scan.predict --free-bytesandgrowth --fill-targetnow default to the same probe, sodisky predictproduces a fill-by date on its own instead offill_at: null+ "provide --free-bytes".--fill-target's help already promised this default; the code never implemented it.Why this and not
dfThe loop that gates on free space is the one disky exists to serve, and it was the one number disky could not produce. Callers were pasting
df -k / | awk '{print $4*1024}'into agent prompts to feed disky its own input.Decisions worth reading
f_bavail, notf_bfree— unprivileged-writable blocks. The honest answer to "can I still write files".f_frsize, notf_bsize—f_bsizeis the preferred I/O size, the wrong multiplier for these block counts.free_bytes()returnsNoneon failure, never0— a failed probe reporting zero reads as a full disk and could trigger a cleanup. Callers must treat it as unknown.used_pctreads 1–2 points abovedf's Capacity — it divides by total blocks;dfdivides byused + available, hiding the root reserve. Documented on the field rather than silently picking either convention.Verification
cargo clippy --all-targetsclean;cargo test volume→ 3 passed.df -kat the same instant:27006492KiB available = 25.8 GB, matches.disky free /nope-xyz→ exit 3 with an RFC 9457 problem document, not0 free.🤖 Generated with Claude Code
https://claude.ai/code/session_01X3Z3sDkDDSUHQRxSw7aDCV