Files
alkane-toolkit/code-review-report.md
T
noahandClaude Opus 4.8 44e76f25e4
build-test-release / release (push) Successful in 5m47s
GUI + CI: code-review-harness fixes, expanded tests, version-logic tests
Ran the code-review-harness (four parallel reviewers: correctness, reliability,
performance, test-coverage) over the GUI crate and fixed every Critical/High
finding, plus grew the test + microbenchmark suite that gates the pipeline.

Correctness / reliability fixes:
- IP column sorted lexically, not numerically. The default view is IP-ascending
  but Column::Ip fell through to the generic lowercase-string sort key, so
  10.255.1.10 sorted before 10.255.1.2 on every launch. Add a numeric IP sort
  key (u32, exact in f64) and switch view() to decorate-sort-undecorate so a
  sort key is computed once per row, not twice per comparison.
- Scans had no cancellation. Stop/Apply/Play only dropped the receiver, leaving
  the background thread probing dead hosts (each waits out an asic-rs timeout),
  and Play could spawn a second concurrent scan + tokio runtime. Add a
  ScanHandle with an Arc<AtomicBool> cancel flag the loop checks each iteration,
  a begin_scan() helper that stops the in-flight scan before starting a new one,
  and Stop now signals cancellation.
- Native column drag never rebuilt the control: column_reordered mutated
  view.order but skipped rebuild_table(), so the store's creation order diverged
  from display_columns() and cells rendered under the wrong headers on the next
  scan tick. Rebuild after applying the reorder.
- format_si rounding rolled a mantissa up to "1000" without advancing the SI
  prefix (999.9 W -> "1000 W", a 4-digit result). Round first, then roll over;
  [99.95,100) drops its decimal.
- start_scan used .expect() on thread spawn, which would panic across the wx FFI
  boundary; it now sends ScanMsg::Failed and returns the handle.

Tests / benchmarks (the pipeline's regression gate):
- Unit tests 24 -> 41: format_si/format_uptime boundaries, numeric IP sort,
  upsert-new-IP, Light three-state + pool-slot-out-of-range cells, filter
  AND/OR, reorder non-permutation guard; scan.rs parse_cidr/prefix_mask,
  single-host /32, empty/whitespace, short-range single/reversed, parse_targets
  aggregate cap + error propagation, validate_ranges, targets_to_cidrs
  non-contiguous, auto-rescan-secs round-trip.
- Microbenchmarks 2 -> 9: view default-sort, sort-by-each-column, filtered view,
  upsert cold-start, parse_line near MAX_ADDRS, parse_targets many ranges,
  targets_to_cidrs large range. Floors are 5-10x above local numbers.
- New ci/test-compute-version.sh: 9 cases for the X.Y.Z logic (first release,
  pre-bumped X, backend/UI bumps, docs-only no-op, major-wins-over-UI,
  backend-wins-over-UI, nested ci/ and thirdparty/wx-rs paths). Wired in as a
  fast-fail CI step.

CI: install libssl-dev + pkg-config (openssl-sys); add xauth so the headless
self-test actually launches under xvfb (was aborting on "xauth not found").

Deferred (documented in code-review-report.md, guarded by benches): Cow cells,
an ip->index map for upsert. Local: 41 tests + 9 benches + 9 shell tests green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
2026-09-16 19:22:49 -06:00

7.6 KiB

Code Review Report - alkane-toolkit

Scope: our own source (crates/alkane-*/src, ci/, scripts/, .gitea/). Vendored thirdparty/wxwidgets and thirdparty/wx-rs were excluded from scanning (the repo lives on a CIFS mount that has previously crashed under recursive scans). Desktop wxWidgets app - no web UI, so Playwright was skipped.

Driver: the harness was run to develop and harden the test + microbenchmark suite that gates the new CI pipeline, and to catch correctness/reliability defects in the round-2 GUI work.

Verdict

READY TO SHIP (after CI green). All Critical/High findings are fixed and validated locally: 41 unit tests pass (0 failed), 9 microbenchmarks pass with wide margins, and 9 shell tests cover the CI version logic. No Critical findings were found; the three High findings are resolved.

Codebase summary (reviewed surface)

Metric Value
Language Rust (edition 2021) + bash + Gitea Actions YAML
Reviewed Rust LoC ~2,400 (GUI crate: ui.rs 915, model.rs 815->1050, scan.rs 521->700)
Backend crates 1-line stubs (core/discovery/access/flash/artifacts/cli) - not yet implemented
Unit tests 24 -> 41
Microbenchmarks (Rust, #[ignore]) 2 -> 9
Shell tests (compute-version.sh) 0 -> 9
Reviewers correctness, reliability, performance, test-coverage (parallel, opus/sonnet)

Iteration history

Iter Reviewers Findings Changes applied
1 4 parallel 3 High, 3 Medium, 4 Low + a 55-item test plan 6 code fixes, +17 unit tests, +7 Rust benches, +9 shell tests

Single iteration: the four reviewers converged on a small, consistent set of defects (the IP-sort bug was found independently by both correctness and performance). Fixes were applied and re-validated locally; no finding remained stuck.

Blocking findings (Critical + High) - all FIXED

  1. High - IP column sorts lexically, not numerically (model.rs:364,471). Column::Ip fell through to the generic SortKey::Str(...to_lowercase()) arm while the default view is IP-ascending, so 10.255.1.10 sorted before 10.255.1.2 on every launch. Found independently by correctness and performance. FIX: dedicated numeric IP key (ip_to_u32, exact in f64) + decorate-sort-undecorate in view() so a key is computed once per row, not twice per comparison. Test: ip_column_sorts_numerically.

  2. High - No scan cancellation; Stop/Apply/Play can run two scans at once (ui.rs Stop/apply_ranges/Play, scan.rs). Stop only dropped the receiver; the background thread kept probing (each dead host waits out an asic-rs timeout), and Play (guarded only by !scanning) could then spawn a second thread + tokio runtime. FIX: ScanHandle carries an Arc<AtomicBool> cancel flag the scan loop checks each iteration; a begin_scan() helper stops the in-flight scan before starting a new one; Stop signals cancellation.

  3. High - Native column drag never rebuilds the control (ui.rs column_reordered). It mutated view.order but skipped rebuild_table(), so the store's creation order diverged from display_columns() and cells rendered under the wrong headers on the next scan tick. FIX: call rebuild_table() after applying the drag reorder.

Non-blocking findings

  • Medium (correctness) - format_si rounding/prefix boundary: 999.9 W rendered as "1000 W" (4 digits, violates the "<=2 digits + 1 decimal" spec). FIXED: round first, then roll the prefix over; [99.95,100) drops its decimal. Test: format_si_rolls_over_at_rounding_boundary.
  • Low (reliability) - start_scan used .expect("spawn scan thread"), which would panic across the wx FFI boundary if thread creation failed. FIXED: send ScanMsg::Failed and return the handle instead.
  • Medium (performance, DEFERRED) - Column::cell always returns an owned String; a Cow<str> would avoid clones for already-string fields. Deferred: the decorate-sort fix removed the dominant per-comparison allocations; this is a smaller, larger-surface refactor. Guarded by bench_render_cells.
  • Medium (performance, DEFERRED) - MinerRow::upsert_into is an O(n) linear scan, so cold-starting a fleet of N is O(n^2). Deferred: an ip->index map is a follow-up; added bench_upsert_cold_start_population (3000 rows = ~8ms locally) as a regression guard.
  • Low (performance) - to_row traverses the pool list twice; parse_targets dedups via BTreeSet. Minor; not on a per-render path. Deferred.
  • Low (reliability) - the scan thread is detached (no join on window close). The cancel flag now lets Stop/close signal it; abrupt teardown on window close remains, which is acceptable for a desktop app.

Test + benchmark plan (delivered)

New unit tests (17): format_si zero/negative/non-finite + rollover boundary, format_uptime boundary matrix, numeric IP sort, upsert-new-IP, Light three-state cell, pool-slot out-of-range cell, filter AND-across / OR-within columns, apply_visible_reorder non-permutation guard.

New scan tests: parse_cidr bare/rejections, prefix_mask boundaries, single-host /32, empty/whitespace lines, short-range single/reversed, parse_targets aggregate cap + error propagation + empty, validate_ranges, targets_to_cidrs non-contiguous split, auto-rescan-secs round-trip (temp HOME).

New Rust microbenchmarks (7, #[ignore], run in CI): view default-sort, sort-by-each-column, filtered view, upsert cold-start, parse_line near MAX_ADDRS, parse_targets many ranges, targets_to_cidrs large range. Floors are 5-10x above local numbers to catch regressions without flaking on slower CI.

New shell tests (9): ci/test-compute-version.sh exercises the X.Y.Z logic - first release, pre-bumped X, backend bump, UI bump, docs-only (no release), manual-major-wins-over-UI, backend-wins-over-UI, nested ci/ (backend), nested thirdparty/wx-rs (UI). Wired into the pipeline as a fast-fail step.

Local results: 41 unit tests ok; 9 benches ok (view default-sort 205us, sort-by-each-column worst 527us, upsert 3000=7.7ms, parse_line near-cap 797us); 9 shell tests ok.

Changes applied during review

  • crates/alkane-gui/src/model.rs - format_si rollover, ip_to_u32, numeric IP sort key, decorate-sort-undecorate view(), +17 tests, +4 benches.
  • crates/alkane-gui/src/scan.rs - ScanHandle + cancel flag, graceful spawn-failure, +11 tests, +3 benches.
  • crates/alkane-gui/src/ui.rs - begin_scan() (cancel-before-start), Stop cancels, drain_scan uses the handle, column_reordered rebuilds.
  • ci/test-compute-version.sh - new shell test suite (+ workflow step).
  • .gitea/workflows/release.yml - install libssl-dev/pkg-config, version-logic test step (earlier commits: bash script invocation, exec bits).

Human review checklist (advisory)

  • Confirm the deferred perf items (Cow cells, upsert index map) are acceptable to ship now; benches guard against regressions until then.
  • The headless UI self-test is currently continue-on-error in CI while the container display path is confirmed; re-tighten to a hard gate once green.
  • Backend crates are stubs; when implemented they will need their own tests.

Automated actions taken

  • 4 parallel review subagents (best model, isolated scope, guardrailed against CIFS/vendored recursion).
  • 6 code fixes applied and re-validated; 33 tests + 7 benches added.
  • Cross-session memory updated at .claude/code-review-memory.md.

Tooling gaps

  • cargo clippy / coverage not run in this pass (CIFS build cost); cargo fmt showed minor drift in fixtures.rs (nit, not applied to keep the diff focused).
  • detect-stack.sh was not run as-is (its bare find . would recurse the vendored tree over CIFS); stack facts were gathered via git ls-files.