Skip to content

fix(disk-space): promote 1024 MiB to 1.0 GiB in disk warnings#90247

Merged
vincentkoc merged 1 commit into
openclaw:mainfrom
jbetala7:fix/disk-space-format-gib-boundary
Jun 13, 2026
Merged

fix(disk-space): promote 1024 MiB to 1.0 GiB in disk warnings#90247
vincentkoc merged 1 commit into
openclaw:mainfrom
jbetala7:fix/disk-space-format-gib-boundary

Conversation

@jbetala7

@jbetala7 jbetala7 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #90245

Summary

  • formatDiskSpaceBytes chose the unit on the unrounded mib < 1024 but then Math.round(mib)'d the MiB branch, so any value with mib ∈ [1023.5, 1024) printed the impossible "1024 MiB" instead of "1.0 GiB".
  • Round MiB first and branch on the rounded value, so a value that rounds up to 1024 MiB is promoted to GiB.
  • Added a regression test for the [1023.5, 1024) boundary.

This string is operator-facing: it appears in the low-disk warning from createLowDiskSpaceWarning during setup/update staging.

Real behavior proof

Behavior addressed: the low-disk warning should never render "1024 MiB"; values that round up to 1 GiB must read "1.0 GiB".

Real environment tested: local checkout on current main (ec3aa5def4), exercising the real exported formatDiskSpaceBytes and createLowDiskSpaceWarning via node --import tsx (the latter with fs.statfsSync stubbed to report boundary free space, which is the only external input that path reads).

Exact steps or command run after this patch:

node --import tsx -e 'import("./src/infra/disk-space.ts").then(m => {
  const b = Math.round(1023.7 * 1024 * 1024);
  console.log(m.formatDiskSpaceBytes(b));
})'

plus node scripts/run-vitest.mjs src/infra/disk-space.test.ts.

Evidence after fix:

formatDiskSpaceBytes(1023.7 MiB) => "1.0 GiB"
formatDiskSpaceBytes(1 GiB)      => "1.0 GiB"
low-disk warning => "Low disk space near <cwd>: 1.0 GiB available; the update may fail."

Before this patch the same input on main produced "1024 MiB" (warning: "... 1024 MiB available; ...").

Observed result after fix: boundary values render "1.0 GiB"; 1023.4 MiB still reads "1023 MiB"; existing 420 MiB / 1.5 GiB cases unchanged.

What was not tested: no real volume was driven to exactly the boundary free-space; the disk read (fs.statfsSync) is the single external dependency and was stubbed to the boundary value, while the formatting under test runs unmodified.

Verification

  • node scripts/run-vitest.mjs src/infra/disk-space.test.ts → 4 passed (incl. new boundary test)
  • oxfmt --check clean; oxlint clean; git diff --check clean

@openclaw-barnacle openclaw-barnacle Bot added the proof: supplied External PR includes structured after-fix real behavior proof. label Jun 4, 2026
@clawsweeper

clawsweeper Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 4, 2026, 4:31 AM ET / 08:31 UTC.

Summary
The PR changes formatDiskSpaceBytes to promote values that round to 1024 MiB into GiB output and adds boundary regression tests.

PR surface: Source +3, Tests +9. Total +12 across 2 files.

Reproducibility: yes. Current main's formatDiskSpaceBytes branches on unrounded MiB and then rounds in the MiB branch, so the 1023.5-1024 MiB range can be shown as 1024 MiB; the PR body also supplies before/after output.

Review metrics: none identified.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Next step before merge

  • No ClawSweeper repair lane is needed because the submitted PR is already a focused, correct fix; maintainer action is normal review and merge once checks satisfy policy.

Security
Cleared: The diff only changes a local formatting helper and colocated tests; it does not touch dependencies, scripts, credentials, workflows, or other security-sensitive surfaces.

Review details

Best possible solution:

Land the helper-level unit-selection fix with the boundary test, then close #90245 as fixed.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main's formatDiskSpaceBytes branches on unrounded MiB and then rounds in the MiB branch, so the 1023.5-1024 MiB range can be shown as 1024 MiB; the PR body also supplies before/after output.

Is this the best way to solve the issue?

Yes. The clean fix is in the shared src/infra/disk-space.ts formatter used by the low-disk warning, while call-site formatting or Doctor's separate threshold formatter would be the wrong layer.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 6082f01b971e.

Label changes

Label changes:

  • add P3: This is a narrow operator-facing formatting bug at a disk-space warning boundary with low blast radius.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides structured after-fix terminal proof for the exported formatter and warning path, plus the focused test command and observed output.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides structured after-fix terminal proof for the exported formatter and warning path, plus the focused test command and observed output.

Label justifications:

  • P3: This is a narrow operator-facing formatting bug at a disk-space warning boundary with low blast radius.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides structured after-fix terminal proof for the exported formatter and warning path, plus the focused test command and observed output.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides structured after-fix terminal proof for the exported formatter and warning path, plus the focused test command and observed output.
Evidence reviewed

PR surface:

Source +3, Tests +9. Total +12 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 5 2 +3
Tests 1 9 0 +9
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 14 2 +12

What I checked:

  • Repository policy read: Root AGENTS.md was read fully; no scoped AGENTS.md exists for src/infra, and the only maintainer note found was Telegram-specific and unrelated. (AGENTS.md:1, 6082f01b971e)
  • Current-main bug: Current main branches on unrounded mib < 1024 and then rounds inside the MiB branch, so values in the 1023.5-1024 MiB range can render as 1024 MiB. (src/infra/disk-space.ts:68, 6082f01b971e)
  • Operator-facing caller: createLowDiskSpaceWarning formats snapshot.availableBytes through formatDiskSpaceBytes, and the update command logs that warning during global package update staging. (src/cli/update-cli/update-command.ts:1462, 6082f01b971e)
  • Patch implementation: The PR head rounds MiB once before choosing the unit, keeping values below the rounded 1024 boundary in MiB and falling through to GiB otherwise. (src/infra/disk-space.ts:67, b8e2f0d75906)
  • Regression coverage: The PR adds tests for 1023.6 MiB, 1023.9 MiB, exactly 1 GiB, and the just-below-boundary 1023.4 MiB case. (src/infra/disk-space.test.ts:81, b8e2f0d75906)
  • Sibling formatter checked: Doctor disk-space warnings use a separate formatBytes helper that intentionally floors MB values around its own thresholds, so the PR's one-surface fix is not missing a sibling update. (src/commands/doctor-disk-space.ts:17, 6082f01b971e)

Likely related people:

  • vincentkoc: The available blame/history shows cce1a1479560ea6fd422eae513721ec6828caa78 introduced formatDiskSpaceBytes, its tests, and the update/doctor disk-space surfaces in current history. (role: introduced behavior; confidence: high; commits: cce1a1479560; files: src/infra/disk-space.ts, src/infra/disk-space.test.ts, src/cli/update-cli/update-command.ts)
  • steipete: Recent commits touched the disk-space helper/test documentation comments without changing the formatter behavior, making this a useful adjacent routing signal. (role: recent adjacent contributor; confidence: medium; commits: 2e8b444da875, cfe31ca3b299; files: src/infra/disk-space.ts, src/infra/disk-space.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jun 4, 2026
formatDiskSpaceBytes tested the unrounded mib < 1024 but then rounded,
so values in [1023.5, 1024) MiB printed the impossible "1024 MiB".
Round before choosing the unit so they render as "1.0 GiB".
@vincentkoc
vincentkoc force-pushed the fix/disk-space-format-gib-boundary branch from b8e2f0d to 1ce8d11 Compare June 13, 2026 13:41
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 13, 2026

@vincentkoc vincentkoc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking findings.

Best-fix verdict: best. The shared formatDiskSpaceBytes helper is the right layer because the operator-facing low-disk warning consumes that formatter directly; call-site string patching would leave the boundary bug in place.

Alternatives considered: changing the update warning only would miss future helper callers; changing Doctor's separate formatter would be wrong because it intentionally floors threshold warnings.

Proof: local git diff --check, oxfmt, oxlint, focused Vitest; autoreview clean; GitHub CI exact head 1ce8d11 green.

@vincentkoc
vincentkoc merged commit 89cc175 into openclaw:main Jun 13, 2026
163 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

formatDiskSpaceBytes emits "1024 MiB" instead of "1.0 GiB" at the GiB boundary

2 participants