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

Hardware health: know each machine, its spec sheet, and real wear against the ratings #10400

Parked opened this in answer to
Closed without merging

This adds a hardware page at /admin/hardware, for site admins only. It shows each machine's disks with the vendor's ratings beside the drive's own SMART numbers. The earlier push failed on one test, test/attention.test.ts ("each page stays inside its first-view budget"), which is now fixed.

Notes

stopped parked by the crew deploy 9cbe939

opened this

This adds a hardware page at /admin/hardware, for site admins only. It shows each machine's disks with the vendor's ratings beside the drive's own SMART numbers. The earlier push failed on one test, test/attention.test.ts ("each page stays inside its first-view budget"), which is now fixed. bun scripts/gate.ts and bun x tsc --noEmit are clean, and test/attention.test.ts and test/hardware.test.ts pass here. I did not run the full suite or the fast-tier selection. I have not seen the page on a preview or against a real drive.

Why it was red: my "Hardware" link in the settings navigation added one word to /settings, and the first-view budget allowed 274 words, not 275. I raised the /settings word budget from 274 to 275 at both widths in docs/design/attention-budget.json. That test says a raise needs a note in the pull, and this is it. I did not look for another place to put the link, because /settings is the only page I found that links the admin pages.

What the page shows

  • Inventory: CPU and memory, then one line per disk. A healthy NVMe drive is one quiet "healthy" line, for example "550 GB of 600 TB (0.092%)". Opening it shows every figure from the issue with its rating beside it.
  • Problems: a drive that reports a problem is badged and opens by default. The page is reachable from Account settings → This forge → Hardware, and /admin/hardware.json returns the same data.
  • PERC virtual disks: they show as "behind a controller; SMART not visible" and are never counted as SSDs.

Alerts fire only on what the drive reports as bad:

  • any critical-warning bit set
  • spare below its threshold
  • percentage used of 80 or more
  • media errors rising
  • time above the critical temperature rising

"Rising" compares against the previous stored reading. Temperature, power-on hours and unsafe shutdowns are quiet numbers.

Catalog and projection: the checked-in catalog holds only the 980 PRO 1TB: 600 TBW, 5-year warranty, 82 °C warning, 85 °C critical. Any other model shows "no rating", never a guess. The projection uses the last 30 days of readings to give the date the rated TBW runs out. It says "needs a day of readings" until a day of history exists.

Where readings come from

  • Inventory: read from /sys and /proc.
  • SMART: once an hour (first run 30 seconds after boot) the forge runs smartctl -j -a on the kernel's own NVMe device list. The device name never comes from a request.
  • Storage: readings go into a new hardware_reading table and are kept for 90 days.
  • No smartctl: this host has none, so the page says so. An admin can paste smartctl -j -a output under "Add a reading", which is how today's 980 PRO numbers can go in.

Tests: test/hardware.test.ts runs the alert rules against recorded 980 PRO logs for healthy, warm-but-fine, worn, hot and failing drives. It also checks that a missing field is refused rather than read as zero.

Not done:

  • Catalog entries for other models. It will not guess.
  • Alerts that notify anyone. The page shows them and nothing sends them.
  • RAID-controller SMART passthrough.

To try it: sign in as a site admin, open /admin/hardware, and paste a smartctl -j -a reading under "Add a reading".

🤖 Generated with Claude Code

Closes #10352

4 earlier comments · 2 events
commented

This adds a hardware page at /admin/hardware, for site admins only. It shows each machine's disks with the vendor's ratings beside the drive's own SMART numbers. The earlier push failed on one test, test/attention.test.ts ("each page stays inside its first-view budget"), which is now fixed. bun scripts/gate.ts and bun x tsc --noEmit are clean, and test/attention.test.ts and test/hardware.test.ts pass here. I did not run the full suite or the fast-tier selection. I have not seen the page on a preview or against a real drive.

Why it was red: my "Hardware" link in the settings navigation added one word to /settings, and the first-view budget allowed 274 words, not 275. I raised the /settings word budget from 274 to 275 at both widths in docs/design/attention-budget.json. That test says a raise needs a note in the pull, and this is it. I did not look for another place to put the link, because /settings is the only page I found that links the admin pages.

What the page shows

  • Inventory: CPU and memory, then one line per disk. A healthy NVMe drive is one quiet "healthy" line, for example "550 GB of 600 TB (0.092%)". Opening it shows every figure from the issue with its rating beside it.
  • Problems: a drive that reports a problem is badged and opens by default. The page is reachable from Account settings → This forge → Hardware, and /admin/hardware.json returns the same data.
  • PERC virtual disks: they show as "behind a controller; SMART not visible" and are never counted as SSDs.

Alerts fire only on what the drive reports as bad:

  • any critical-warning bit set
  • spare below its threshold
  • percentage used of 80 or more
  • media errors rising
  • time above the critical temperature rising

"Rising" compares against the previous stored reading. Temperature, power-on hours and unsafe shutdowns are quiet numbers.

Catalog and projection: the checked-in catalog holds only the 980 PRO 1TB: 600 TBW, 5-year warranty, 82 °C warning, 85 °C critical. Any other model shows "no rating", never a guess. The projection uses the last 30 days of readings to give the date the rated TBW runs out. It says "needs a day of readings" until a day of history exists.

Where readings come from

  • Inventory: read from /sys and /proc.
  • SMART: once an hour (first run 30 seconds after boot) the forge runs smartctl -j -a on the kernel's own NVMe device list. The device name never comes from a request.
  • Storage: readings go into a new hardware_reading table and are kept for 90 days.
  • No smartctl: this host has none, so the page says so. An admin can paste smartctl -j -a output under "Add a reading", which is how today's 980 PRO numbers can go in.

Tests: test/hardware.test.ts runs the alert rules against recorded 980 PRO logs for healthy, warm-but-fine, worn, hot and failing drives. It also checks that a missing field is refused rather than read as zero.

Not done:

  • Catalog entries for other models. It will not guess.
  • Alerts that notify anyone. The page shows them and nothing sends them.
  • RAID-controller SMART passthrough.

To try it: sign in as a site admin, open /admin/hardware, and paste a smartctl -j -a reading under "Add a reading".

🤖 Generated with Claude Code

commented

I merged main into the branch and pushed. The only conflict was docs/design/attention-budget.json.

  • Conflict: main had lowered the /settings first-view budget to 137 words, while my side had raised it to 275. I took main's figures and added one word, so /settings is at 138 words at both widths. That one word is the new admin "Hardware" link in the settings navigation. The attention-budget test says a raise needs a note in the pull, and this is it.
  • Checks: test/attention.test.ts and test/hardware.test.ts pass, and bun scripts/gate.ts and bun x tsc --noEmit are clean. I did not run the full suite; the forge runs it on this push.

Everything else in the pull is as described before: /admin/hardware with the vendor ratings beside the drive's own SMART numbers, and alerts only on what the drive reports as bad.

🤖 Generated with Claude Code

Changes requested — before the latest push

Changes needed, all in one round. First, the biggest: there is no terminal door. Everything in this pull is web-only (/admin/hardware, the JSON, the import). AGENTS.md wants a screen in src/tui/ with its entry, gated exactly as the page is (admin sees it, a guest sees nothing). The import, which is a write, must exist there too. Second: the page is hand-rolled markup against docs/DESIGN.md (see the comments). Third: the import write and the collector/sweep are untested. Also remove the dead import hack in the test. Separately, the direction is PIPELINE FIRST and this is a feature outside that list; if the issue was explicitly scheduled, say so in the pull description.

commented

All the review points are addressed and pushed. The hardware, attention, design-audit, security-floor, spawn-pipes, migrate and TUI-limits tests pass, and so do bun x tsc --noEmit, bun scripts/gate.ts and bun scripts/design-lint.ts. I did not run the full suite: scripts/fast.ts found the diff too broad to name tests, so I picked the files above.

What changed

  • Terminal door. New src/tui/screens/hardware.ts and a palette entry, offered only to admins who are not agents, same as the page. It lists the disks with wear against the rating and each alert under its row. i asks for a device, then a pasted smartctl -j -a, and stores it. A guest is not offered the command.
  • One action behind both. src/actions/hardware.ts (readHardware, importReading) is used by the page, the JSON and the terminal, and does the gating.
  • Import hardening (the security comment):

- The device must be an NVMe controller this machine lists, or one that already has readings. - A paste's model and serial must match what is already stored for that device. - The paste is capped at 64 KB, with maxlength on the textarea and a body cap on the form. - The importer's name is stored with the reading, in a new hardware_reading.by column. That needed a new pinned migration, 20261109220000-hardware-reading-by. - I stored the name on the row instead of writing an audit event, because the existing audit table is the cloud-egress one. Say if you want a separate event too.

  • Page.

- The sub is one sentence. - Readings are status-rows dl rows with the rating muted beside the value; the table is gone. - Alerts are row() items. - The import hint is shorter.

  • Store. Reads now run a shape check (readLog), and a corrupt row is skipped instead of crashing the page. The comment now says so.
  • Tests.

- Removed the dead mkdtemp as _m import and void _m. - POST import: a non-admin and a cross-origin post are refused (403), a bad paste flashes its error, and a good paste stores. - /admin/hardware.json returns the view for an admin and is refused to a non-admin. - sweep() and the hourly guard in record. - Model/serial mismatch, size cap, corrupt-row skip and the stored by name. - The terminal door for an admin and for a guest. - To make sweep testable, it now takes the inventory and the command runner as optional arguments.

Pipeline first. Issue #10352 is the owner's explicit request, so this was scheduled work rather than a pick from outside the list.

Not done: no separate audit event, and no per-device cap on how many readings an admin can force in.

Try it: open /admin/hardware as an admin and paste a reading, or in the SSH terminal open the palette and choose Hardware, then press i.

the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

Pull #10400 adds a Hardware page that lists each machine's disks and compares their wear against the vendor's ratings. It also adds a Hardware entry in the palette and the terminal UI, and a form to add a reading.

I merged current main into the branch and pushed. I did not change any code or tests this turn. The type check is clean. I didn't run scripts/gate.ts or the wider suite this turn.

The two failures from the check:

  • Palette roster ("a site-admin person is offered the whole roster"): this passes here, both before and after the merge. It was most likely checked against a main that had since moved. Commit a21325350 already lists the Hardware entry in that test.
  • Sweep timing ("the two passes' request loops together take under 5 s"): it fails on a checkout of origin/main too, at 5.9 s here. This sandbox has no git binary, so the sweep logs posix_spawn 'git' errors, and the loop times are not meaningful here. I couldn't confirm it passes in the forge's own check.

If the check fails again on the timing test, it needs a person: the 5 s ceiling is too tight for that sweep, or the new routes added slowness I can't measure from here.

Try it by signing in as a site admin and opening /hardware, or by choosing Hardware in the palette.

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