Files
alkane-toolkit/code-review-report.md
T
noahandClaude Opus 4.8 cdd605c189
build-test-release / release (push) Successful in 10m0s
GUI round 7: code-review remediation (flash safety, unknown-actual colour, credentials, coverage)
Fixes the Critical/High findings from the round-6 review (6 parallel dimension
reviewers + adversarial verify), plus the cheap high-value non-blocking ones.
Full write-up in code-review-report.md.

Firmware-flash safety (the one irreversible, hardware-destroying action):
- Critical: re-triggering an action no longer races the previous one. A flash
  now takes an exclusive lock (new App.flashing): it will not start while any
  scan / refresh / config action is running, and none of those (nor another
  flash) start while it runs. begin_scan, start_action, start_refresh and
  apply_flash_confirm all gate on it, and the context menu offers only the
  read-only "Open in browser" while flashing. This removes the two overlapping-
  network-operation paths that could interrupt/corrupt an upload and brick a
  miner (old.stop() never joined the in-flight upload).
- High: the flash confirm dialog now lists every target IP + model and warns
  loudly when the batch spans more than one model (a single image is rarely
  valid for all), instead of showing only a bare count.

Correctness:
- High: combined columns no longer paint the "-" placeholder solid red when the
  actual is unknown but the expected is known (an idle/paused/booting miner of a
  recognised model looked like a 0% catastrophic failure). fill_rows now gates
  the ratio on the actual being known; unknown-actual falls to the plain,
  uncoloured segment. Was masked by the all-zero-expected fixtures.
- compute_kpis buckets by status() instead of re-deriving the precedence from
  raw flags (KPI header can no longer disagree with a row's status; offline
  folds into not_hashing).

Security:
- credentials file is created at 0600 up front (OpenOptions::mode) and
  re-tightened while still empty, so the plaintext password is never on disk
  under a looser mode (was create-0644 then chmod-0600).
- the "Set scan credentials" dialog no longer pre-fills the saved password in
  plaintext; a blank Password field keeps the stored one.

Robustness / API:
- the fake-scan branches of the config-action / refresh / flash background
  threads now honour the cancel flag (were ignored, so stop() was a no-op).
- MinerRow.online -> offline (default false = online), removing the footgun
  where a struct-update literal that forgot `online: true` read back offline.

Tests (the review's primary focus -- these paths had zero coverage):
- scan.rs fake_mode_background_actions: start_scan offline-row emission,
  start_refresh (Row/Failed/Done), start_firmware_flash_action, and that a
  cancelled run still terminates with Done rather than hanging.
- model.rs: flash_confirmed (exact/case/prefix/whitespace), compute_kpis vs
  status() consistency, Default-is-online.
- new ui::tests: ratio_color/fan_color/tint_toward stops+clamping+blends, and
  the combined-cell unknown-actual and cooling-cell encodings.
- credentials.rs: configured_factory smoke (both branches) + pre-existing-0644
  re-tighten.
- self-test: offline row (.199) spot-check, KPI quick-filter toggle on/off, and
  a numeric (not lexical) IP-sort assertion via model::ip_to_u32.

Deferred (non-blocking, tracked in code-review-report.md): start_* boilerplate
extraction; per-model firmware image-compatibility check; scoping saved
credentials to a chosen backend; a masked password field (needs a wx-rs
TE_PASSWORD binding); flash-specific status text; a segment-encode microbench.

Verified: cargo check --release --tests is clean; unit tests + benches + the
headless self-test run in CI (local release link is OOM-blocked on this
desktop).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
2026-09-17 14:06:03 -06:00

6.3 KiB

Code review report -- alkane-gui round 6

Scope: the round-6 diff of our own source only (crates/alkane-gui/src/{model,scan,ui,credentials,fixtures,main}.rs), vs the round-5 release commit 8c3a410. Vendored thirdparty/ and vendor/ trees were excluded (CIFS fd-exhaustion hazard). Desktop wxWidgets app, so no Playwright/web UI.

Method: a 6-dimension parallel review (correctness, reliability/concurrency, security, test+microbench coverage, firmware-flash correctness, maintainability) with an adversarial verify pass on every Critical/High finding. 27 raw findings; 11 Critical/High, all confirmed; 16 non-blocking. The verify pass corrected several severities (recorded below).

Verdict

NOT READY at review time (1 Critical + multiple High). After the remediation in this round, all Critical/High correctness, reliability, security, and firmware findings are fixed and the flagged coverage gaps are closed. Re-ship pending CI (the release build + all unit tests + the headless self-test gate).

Blocking findings and remediation

# Sev (verified) File:line Finding Status
1 Critical ui.rs:951 Re-triggering an action did not wait for the previous to stop -> overlapping firmware flashes to one miner (brick risk). FIXED -- a flash now takes an exclusive flashing lock: it will not start while a scan/refresh/action runs, and nothing (scan/refresh/action/another flash) starts while it runs. begin_scan, start_action, start_refresh, apply_flash_confirm all gate on it; the context menu hides network actions while flashing.
2 High ui.rs:128 Unknown-actual rendered the "-" placeholder in solid red (idle/paused/booting miners of a known model looked like 0% catastrophic failures). Masked by the all-zero-expected fixtures. FIXED -- fill_rows now gates the ratio on the actual being known (hashrate_ths > 0 / hashboards.is_some() / total_chips.is_some()), so an unknown actual falls to the plain, uncoloured segment. Regression-tested (combined_cell_unknown_actual_is_not_coloured_red).
3 High ui.rs:910 Batch flash hid the target IPs/models and pushed one image onto a heterogeneous set. FIXED -- the confirm dialog now lists every target IP + model and warns loudly when the batch spans more than one model.
4 High scan.rs:746 No mutual exclusion between a flash and a concurrent scan/refresh on the same miner. FIXED -- same exclusive flashing lock as #1 (a flash blocks scans/refreshes and vice-versa).
5 High scan.rs:650 start_refresh had zero test coverage. FIXED -- fake_mode_background_actions drives it (Row / Failed / Done + cancellation).
6 High scan.rs:746 start_firmware_flash_action / flash_one had zero coverage. FIXED -- same test covers the fake-mode success path + cancellation; the typed-FLASH gate is extracted to model::flash_confirmed and unit-tested.
7 High scan.rs (start_scan) Offline-row emission (every probed IP yields a row) untested. FIXED -- the same test asserts the synthetic offline host comes back offline.
8 Critical->Medium credentials.rs:34 Credentials file created 0644 then chmod'd 0600 -> brief world-readable window with the plaintext already written. FIXED -- created via OpenOptions::mode(0o600) and re-tightened to 0600 while still empty, before any plaintext is written. Tested (create-mode + pre-existing-0644 cases).
9 High->Low ui.rs:1997 Typed-FLASH gate uncovered. FIXED -- extracted to model::flash_confirmed, unit-tested (exact / case / prefix / whitespace / empty).
10 High->Medium ui.rs:1405 ratio_color/fan_color/tint_toward colour contracts unasserted (the self-test decodes colours away). FIXED -- new ui::tests module asserts the stops, clamping, and blends without a wx display.
11 High->Medium scan.rs:554 Four start_* functions duplicate ~60 lines of thread/channel/cancel boilerplate. DEFERRED -- pure maintainability/DRY; no current defect. Tracked for a follow-up extraction.

Non-blocking findings addressed this round

  • Medium (scan.rs:560) fake-scan branches never checked the cancel flag -- FIXED (all three fake branches now honour it; covered by the cancellation test).
  • Medium (model.rs:272) MinerRow.online defaulted false (footgun) -- FIXED by inverting to offline: bool (default false = online); ..Default::default() now yields a reachable row and only offline() marks one unreachable.
  • Medium (model.rs:815) compute_kpis re-implemented status() precedence and ignored online -- FIXED (buckets by status(); offline folds into not_hashing). Regression-tested.
  • Medium (ui.rs:1759) KPI quick-filter toggle untested -- FIXED (self-test toggles "slow" on and off).
  • Medium (ui.rs:1868) offline row .199 had no spot-check -- FIXED (self-test asserts offline + blank hashrate).
  • Medium (credentials.rs:60) configured_factory untested -- FIXED (smoke test, both branches).
  • Low (ui.rs:981) creds dialog showed the saved password in plaintext -- MITIGATED (no longer pre-filled; blank keeps the stored password).
  • Low (ui.rs:1980) self-test IP sort was lexical -- FIXED (numeric via model::ip_to_u32).

Deferred (non-blocking, tracked)

  • Maintainability: extract the shared start_* background-thread skeleton (#11); fold the two fill_rows passes / re-parse into a single Column::cell_parts data path (ui.rs:550/542); route fixture paused through is_paused() (fixtures.rs:32); drop the ColorKind::Blue==Accent duplicate (ui.rs:193); name the colour magic numbers (ui.rs:105).
  • Security hardening (design): scope saved credentials to a chosen backend instead of fanning out to every firmware backend during a subnet scan (credentials.rs:58); a true masked password field needs a wx TE_PASSWORD binding (bridge work).
  • Firmware: per-tick status text should say "flashing" vs a generic action (ui.rs:1031); a real per-model image-compatibility check before batching (beyond the new dialog warning).
  • A segment-encode microbench to gate the new per-fill_rows cost (ui.rs:1699).

Human-review checklist (advisory)

  • Confirm the exclusive-flash UX is acceptable (a scan sweep briefly blocks starting a flash, and vice-versa) -- chosen for hardware safety.
  • Confirm "blank password keeps the saved one" is the desired credentials-dialog semantic.