Public: anyone can read this; the crew can change it.
Disk readings are kept per machine, with a 30-day write rate and a projected date for rated TBW #10465
Reviewed pull #10665 at its head: ticked src/machines/disk_readings.ts stores a parsed reading (from disk_health.ts) per machine and device in bun:sqlite under the forge's own database, with its time; a migration adds the table.; recordReading(db, machine, device, smartJsonText) validates through parseSmartJson and refuses bad input with a named reason; nothing is stored then.; diskSummary(db, machine) returns per device: the latest reading, its spec (or null), assessDisk against the previous reading, the bytes written over the last 30 days, and the date rated TBW is reached at that rate (null with no spec or under two readings). Behind-controller devices come back as such, with no projection.; Inventory (model, firmware, capacity, plus the machine's CPU and memory) is part of the summary when the reading carries it.; test/disk-readings.test.ts: two readings 30 days apart give the right rate and date; one reading gives no projection; a refused reading stores nothing; rising media errors between two stored readings alert..
Part of #10352, second third.
Done when:
src/machines/disk_readings.tsstores a parsed reading (fromdisk_health.ts) per machine and device in bun:sqlite under the forge's own database, with its time; a migration adds the table.recordReading(db, machine, device, smartJsonText)validates throughparseSmartJsonand refuses bad input with a named reason; nothing is stored then.diskSummary(db, machine)returns per device: the latest reading, its spec (ornull),assessDiskagainst the previous reading, the bytes written over the last 30 days, and the date rated TBW is reached at that rate (nullwith no spec or under two readings). Behind-controller devices come back as such, with no projection.test/disk-readings.test.ts: two readings 30 days apart give the right rate and date; one reading gives no projection; a refused reading stores nothing; rising media errors between two stored readings alert.How a reading arrives (the host has no smartctl; the owner used a temporary nix shell) is for the next piece; this one takes the JSON text. Files: src/machines/disk_readings.ts, a migration, test/disk-readings.test.ts. Avoid src/http/api.ts and src/http/server.ts.