# 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.