Public: anyone can read this; the crew can change it.

Disk health rules: a spec catalog and alerts only on what the drive itself reports #10471

Parked opened this
Closed without merging

I added the spec catalog and the disk-health parser and alert rules as pure modules, with no route, page or I/O. test/disk-health.test.ts passes (15 tests), bun x tsc --noEmit is clean, and bun scripts/gate.ts printed nothing. I did not run the forge's full check.

Notes

stopped parked by the crew deploy dac67c1

opened this

I added the spec catalog and the disk-health parser and alert rules as pure modules, with no route, page or I/O. test/disk-health.test.ts passes (15 tests), bun x tsc --noEmit is clean, and bun scripts/gate.ts printed nothing. I did not run the forge's full check. The keep_plan tool wasn't available, so there is no plan on the issue.

What changed

  • src/machines/disk_catalog.ts: diskSpec(model) is an exact-match lookup. It currently holds Samsung SSD 980 PRO 1TB: 600 TBW, 5-year warranty, warning 82 °C, critical 85 °C. Any other model, or different casing, returns null.
  • src/machines/disk_health.ts, parsing: parseSmartJson(text) reads smartctl --json -a output into the reading fields from the issue.

- Extra fields: the reading also carries kind: "nvme", which the issue didn't list. - Bytes written: bytesWritten is data units × 512,000, as the NVMe spec defines a data unit. - PERC: a megaraid/PERC device with no NVMe log returns { kind: "behind-controller" }. - Refusals: bad input returns { kind: "refused", reason }. The reasons are not-json, not-smartctl-output, no-nvme-health-log, and bad-field with the field name.

  • src/machines/disk_health.ts, alerts: assessDisk(reading, previous?, spec) alerts on exactly the five rules from the issue and nothing else. Unsafe shutdowns, current temperature, minutes above the warning temperature, and written-vs-rated never raise an alert.
  • Fixtures: test/fixtures/smart/ has healthy (the 11-09 reading: 1,074,219 data units, about 550 GB, 39 °C, 2,575 h, 41 unsafe shutdowns), worn (82% used), hot (critical minutes at 57), failing (warning bits 0x05, spare 7% against a threshold of 10%, media errors 12) and perc. These are synthetic files modeled on smartctl's JSON, not captures from a real drive.
  • Tests: each rule has a boundary test (spare 9 vs 10, used 79 vs 80, errors rising vs equal vs no previous reading). 4,100 unsafe shutdowns on their own stay ok.

What I chose not to do

  • spec is accepted by assessDisk for the signature but changes no alert. Written vs rated TBW and the projection belong to #10465 and #10466.
  • No SATA or SAS SMART parsing. A non-NVMe device that isn't behind a controller is refused as no-nvme-health-log.

How to try it: bun test test/disk-health.test.ts.

Closes #10464

3 earlier comments
commented

I added the spec catalog and the disk-health parser and alert rules as pure modules, with no route, page or I/O. test/disk-health.test.ts passes (15 tests), bun x tsc --noEmit is clean, and bun scripts/gate.ts printed nothing. I did not run the forge's full check. The keep_plan tool wasn't available, so there is no plan on the issue.

What changed

  • src/machines/disk_catalog.ts: diskSpec(model) is an exact-match lookup. It currently holds Samsung SSD 980 PRO 1TB: 600 TBW, 5-year warranty, warning 82 °C, critical 85 °C. Any other model, or different casing, returns null.
  • src/machines/disk_health.ts, parsing: parseSmartJson(text) reads smartctl --json -a output into the reading fields from the issue.

- Extra fields: the reading also carries kind: "nvme", which the issue didn't list. - Bytes written: bytesWritten is data units × 512,000, as the NVMe spec defines a data unit. - PERC: a megaraid/PERC device with no NVMe log returns { kind: "behind-controller" }. - Refusals: bad input returns { kind: "refused", reason }. The reasons are not-json, not-smartctl-output, no-nvme-health-log, and bad-field with the field name.

  • src/machines/disk_health.ts, alerts: assessDisk(reading, previous?, spec) alerts on exactly the five rules from the issue and nothing else. Unsafe shutdowns, current temperature, minutes above the warning temperature, and written-vs-rated never raise an alert.
  • Fixtures: test/fixtures/smart/ has healthy (the 11-09 reading: 1,074,219 data units, about 550 GB, 39 °C, 2,575 h, 41 unsafe shutdowns), worn (82% used), hot (critical minutes at 57), failing (warning bits 0x05, spare 7% against a threshold of 10%, media errors 12) and perc. These are synthetic files modeled on smartctl's JSON, not captures from a real drive.
  • Tests: each rule has a boundary test (spare 9 vs 10, used 79 vs 80, errors rising vs equal vs no previous reading). 4,100 unsafe shutdowns on their own stay ok.

What I chose not to do

  • spec is accepted by assessDisk for the signature but changes no alert. Written vs rated TBW and the projection belong to #10465 and #10466.
  • No SATA or SAS SMART parsing. A non-NVMe device that isn't behind a controller is refused as no-nvme-health-log.

How to try it: bun test test/disk-health.test.ts.

commented

Disk health rules: a spec catalog, and alerts only on what the drive itself reports (#10464).

Changes

  • src/machines/disk_catalog.ts is a catalog of drive specs.
  • src/machines/disk_health.ts raises alerts only on what the drive itself reports in its SMART data. It never alerts on guesses.
  • test/disk-health.test.ts has 15 tests. Fixtures under test/fixtures/smart/ cover healthy, failing, worn, hot and PERC (RAID-controller) drives.

The preview deploy "failure" needed no code change

  • The summary "running at … · no tests declared, none run" is what the deploy writes for a successful deploy whose forge.json has no app.test (NO_TESTS_TAIL in src/apps/runtime.ts). It is not an error.
  • The log tail you sent ends in a SIGTERM drain from the environment being stopped. That is not a crash.
  • The preview answers /healthz with 200.
  • I did not add an app.test. The repository's check block already runs the gate, the type check and the sharded tests on every push.

Checks run locally

  • bun scripts/gate.ts passed.
  • bun scripts/fast.ts named 18 test files for the 8 changed files.
  • bun test test/disk-health.test.ts passed 15 of 15.
  • I did not re-run bun x tsc --noEmit this turn, and nothing changed since the last push, so there is nothing new to push.

To try it, run bun test test/disk-health.test.ts.

🤖 Generated with Claude Code

commented

Disk health rules: a spec catalog, and alerts only on what the drive itself reports.

What changed

  • src/machines/disk_catalog.ts is a catalog of drive specs, looked up by model.
  • src/machines/disk_health.ts parses smartctl --json -a output for NVMe drives and assesses it. Only what the drive reports as bad raises an alert. Unsafe shutdowns, temperature now, and written versus rated are plain numbers, never alerts.
  • Nothing in the app imports either module yet, so the "every module under src/ is imported by another, or allowed" check failed on both. I added the two files to scripts/unreached-allow.json, which is the repository's way to list staged work. The list can only shrink, so the next slice that uses them removes the entries.
  • I merged main into the branch. That also dropped src/kernel/why_now.ts from the allow list, because it is reached once main is merged in.

What I chose not to do I did not wire the modules into a page or the alert path. That is a larger change, and this pull is the pure, tested core.

How to try it

  • bun test test/disk-health.test.ts test/unreached.test.ts — 19 pass.
  • bun x tsc --noEmit and bun scripts/gate.ts are clean.
  • I did not run the full suite here; the forge's check runs it on the push.
commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs