phase: 09_disks_smartctl

**Phase 09 — final verification pass (all 4 task files already in `complete/`; nothing re-implemented)**

- Verified `GET /api/disks/snapshot` live: 3 hosts / 18 whole-`/sys/block` rows, `smartctl_available` three-way, per-row `severity`, API-summed `fleet`; 404 `{"configured": false}` proven *without dialling* (spies on `httpx.AsyncClient.get` + `collectors.fetch_snapshot`).
- Verified `/api/disks/history` live (`disk.temp_c@dev`, unknown names → empty series) + `test_store.py`'s 300 s rollup/prune buckets; `/api/metrics?source=disks` answers the `disks` family.
- Browser against live data: 18 drive cards (never a partition/mount), collapsed per-host `Charts` with `aria-label`, 3 `.stale` grids + one `.banner.info` why-line and **0 `.fail` classes / green `disks` dot** → criteria 3 and 4 hold; new shots `data/logs/09-verify-disks-live-dimmed.png`, `09-verify-overview-live.png` (13 total for the phase).
- Real-hardware criterion: read 4 driveripper drives through `ops`' `sudo -n smartctl -i -A -H` and ran the live output through `host_agent.parse_smart_output` → `sources/disks.parse_disks_snapshot`: `sda` 35 °C / 30 423 h, `nvme1n1` 58 % wear, `nvme5n1` 13 uncorrectable → `alarm_disks: 1`, temps graded `warn`; consistent with the 16 committed fixtures.
- `bash .agents/validate.sh` → **EXIT=0**; `uv run pytest --cov` → **769 passed, 11 skipped, coverage 98.33%** (floor 94); `ruff check src tests agent` clean; `pyright` 0 errors; `node --check` clean; hygiene + dependency advisories clean. `uv run pytest -m live --live` → 10 passed, 1 skipped (agents still predate the SMART pass). Dev server healthy: `/api/health` `ok`, 9/9 sources.
- Docs fixed: AGENTS.md test count 698→769 and coverage 98.2→98.33 %; `disks` added to the event dashboard-name list and to the "every feed renders `Dash.eventText`" sentence; README `POLL_MS_*` row now states `/disks`' deliberate fixed 30 s; new Known gap 4 records the dev-DB `database is locked` writes (reported/recovered per invariant 4, ~590 MB DB / ~70 MB WAL, not reproduced by a controlled 25 s external read txn).
- Deviations: **no live-infra change** — granting the agent user the `disk` group and redeploying `host_agent.py` on driveripper/deskwork stay the documented paired operator action (redeploying without the grant yields 16 permission-denied lines; a sudo-spawning agent would break the confirmed "direct read, no sudo" assumption). Store-lock issue left to its own phase rather than patched speculatively.
- Next pending phase: `10_dev_direct_dial`.
This commit is contained in:
2026-10-18 00:45:01 -04:00
parent 19cfedfddf
commit fefbeb8227
81 changed files with 5525 additions and 134 deletions
+34
View File
@@ -113,6 +113,40 @@ async def test_grace_allows_a_blip_without_an_event(store) -> None:
assert len(store.recent_events(limit=10)) == 1, "one event per outage, not per poll"
async def test_a_failed_disks_poll_ages_its_cards_instead_of_zeroing_them(store) -> None:
"""Invariant 4 on the phase-09 job: SMART goes quiet, the numbers stay and age.
The `/disks` page is the one a operator reads *because* something looks wrong, so a
failed poll must not turn "last read 12 minutes ago" into a page of zeros — and the
outage must be filed under the `disks` dashboard, which is where that page filters.
"""
payload = {"name": "driveripper", "smartctl_available": True,
"disks": [{"device": "nvme0n1", "health": "ok",
"smart": {"temp_c": 38.0, "power_on_hours": 8760.0}}],
"summary": {"disks": 1, "with_smart": 1, "health_failed": 0,
"alarm_disks": 0}}
async def good() -> Result:
return Result(payload=payload,
samples=[Sample("disks", "driveripper", "disk.temp_c@nvme0n1",
38.0, time.time())])
job = Job("disks:driveripper", "disks", "driveripper", 300.0, good)
assert job.interval == 300.0, "SMART is not a 10 s signal"
assert await job.run_once(store) is True
assert store.query("disks", "driveripper", "disk.temp_c@nvme0n1",
start=time.time() - 60), "the series is written under `disks`"
job.fn = failing
assert await job.run_once(store) is False
assert job.state.payload == payload, "the card keeps the last temperature it read"
assert job.state.ok is False
assert job.state.as_json()["age_seconds"] is not None
events = store.recent_events(limit=10)
assert [event.source for event in events] == ["disks"], (
"the outage must land where /disks filters its feed, not under the sample source")
async def test_a_slow_poll_never_overlaps_itself(store) -> None:
calls = 0
gate = asyncio.Event()