Skip to content

Commit 66d0ed4

Browse files
committed
fix(doctor): classify critical disk exhaustion as error
Doctor's human output labels less than 100 MB free as CRITICAL because config, session, and log writes may fail silently and lose data. The structured lint finding still used warning, so --severity-min error filtered it out, returned ok=true, and exited successfully. Share the threshold decision between the structured severity and requirement: critical is error, low space remains warning. Update the regression contract accordingly.
1 parent 122fc1c commit 66d0ed4

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎src/commands/doctor-disk-space.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ describe("collectDiskSpaceHealthFindings", () => {
181181
]);
182182
});
183183

184-
it("returns a critical-space warning finding", () => {
184+
it("returns a critical-space error finding", () => {
185185
const findings = collectDiskSpaceHealthFindings({ gateway: { mode: "local" } } as never, {
186186
env: { HOME: "/home/test" },
187187
readDiskSpace: () => ({ availableBytes: 50 * 1024 * 1024 }),
@@ -190,7 +190,7 @@ describe("collectDiskSpaceHealthFindings", () => {
190190
expect(findings).toEqual([
191191
expect.objectContaining({
192192
checkId: "core/doctor/disk-space",
193-
severity: "warning",
193+
severity: "error",
194194
message: "CRITICAL: only 50 MB free on the partition containing /home/test/.openclaw.",
195195
path: "/home/test/.openclaw",
196196
target: "50 MB",

‎src/commands/doctor-disk-space.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@ export function collectDiskSpaceHealthFindings(
112112
}
113113

114114
const [message, ...details] = result.warnings;
115+
const critical = result.availableBytes < CRITICAL_BYTES;
115116
return [
116117
{
117118
checkId: DISK_SPACE_CHECK_ID,
118-
severity: "warning",
119+
severity: critical ? "error" : "warning",
119120
message: expectDefined(message, "disk-space warning message").replace(/^- /, ""),
120121
path: result.stateDir,
121122
target: formatBytes(result.availableBytes),
122-
requirement:
123-
result.availableBytes < CRITICAL_BYTES ? "critical-free-space" : "low-free-space",
123+
requirement: critical ? "critical-free-space" : "low-free-space",
124124
fixHint: details.map((line) => line.replace(/^- /, "")).join(" "),
125125
},
126126
];

0 commit comments

Comments
 (0)