diff --git a/.cargo/audit.toml b/.cargo/audit.toml
new file mode 100644
index 00000000..341317ff
--- /dev/null
+++ b/.cargo/audit.toml
@@ -0,0 +1,20 @@
+# cargo-audit configuration (read by `cargo audit` from the project root).
+#
+# The two entries below are accepted, documented exceptions -- both live only in
+# the wx-rs BUILD-dependency tree (reqwest 0.11, used by wx-rs's build.rs to
+# download the wxWidgets source on Windows/macOS). On Linux download_dist()
+# returns before ever constructing an HTTP client, and none of this is linked
+# into the runtime binary, which talks to miners over asic-rs's reqwest 0.13
+# (hyper 1.x / h2 0.4). The build tree is fully vendored and offline, so these
+# cannot be upgraded without re-vendoring a newer reqwest.
+#
+# Re-review whenever the vendored dependency set is refreshed.
+
+[advisories]
+ignore = [
+ # h2 0.3 unbounded empty DATA frames (DoS). Build-time only; our build-time
+ # HTTP client only fetches a fixed HTTPS URL, and only on Windows/macOS.
+ "RUSTSEC-2026-0258",
+ # rustls-pemfile 1.0.4 unmaintained. Same build-only reqwest 0.11 subtree.
+ "RUSTSEC-2025-0134",
+]
diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml
index 366ce8ea..7b40471e 100644
--- a/.gitea/workflows/release.yml
+++ b/.gitea/workflows/release.yml
@@ -49,6 +49,12 @@ jobs:
echo "wx prefix restored from cache"
fi
+ - name: Clippy (our crate, warnings are errors)
+ if: steps.ver.outputs.release == 'true'
+ run: |
+ export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
+ cargo clippy -p alkane-gui --no-deps --release --bins --offline -- -D warnings
+
- name: Set crate version to ${{ steps.ver.outputs.version }}
if: steps.ver.outputs.release == 'true'
run: |
@@ -81,6 +87,43 @@ jobs:
BIN=target/release/alkane-toolkit
xvfb-run -a env GDK_BACKEND=x11 ALKANE_SELFTEST=1 "$BIN"
+ - name: Dependency audit (best-effort)
+ if: steps.ver.outputs.release == 'true'
+ continue-on-error: true
+ run: |
+ if command -v cargo-audit >/dev/null 2>&1; then
+ cargo audit || echo "cargo audit reported findings (accepted ones in .cargo/audit.toml)"
+ else
+ echo "cargo-audit not installed on this runner; skipping"
+ fi
+
+ # Refresh the committed README badges from live metrics and push any change
+ # back to main. Best-effort: a locked-down runner that can't push must not
+ # fail the release. A badges-only push does not bump the version (see
+ # compute-version.sh), so it does not loop back into another release.
+ - name: Refresh badges
+ if: steps.ver.outputs.release == 'true'
+ continue-on-error: true
+ env:
+ TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ export WX_RS_WXCONFIG="$WX_PREFIX/bin/wx-config"
+ PASS=$(cargo test -p alkane-gui --offline 2>&1 \
+ | grep -hoE '[0-9]+ passed' | grep -oE '[0-9]+' | awk '{s+=$1} END{print s+0}')
+ python3 ci/gen-badges.py --tests "${PASS:-0}" --bench "row-render + scan-parse"
+ if [ -n "$(git status --porcelain badges)" ]; then
+ git config user.name "alkane-ci"
+ git config user.email "ci@bluefla.re"
+ git add badges
+ git commit -m "ci: refresh README badges [skip release]"
+ API="${GITHUB_API_URL:-https://gitea.bluefla.re/api/v1}"
+ HOST="${API%/api/v1}"
+ git push "${HOST}/${GITHUB_REPOSITORY}.git" "HEAD:main" \
+ -c http.extraheader="Authorization: token ${TOKEN}" || echo "badge push skipped"
+ else
+ echo "badges unchanged"
+ fi
+
- name: Package artifact
if: steps.ver.outputs.release == 'true'
id: pkg
diff --git a/.gitea/workflows/verify.yml b/.gitea/workflows/verify.yml
new file mode 100644
index 00000000..7e1cf45e
--- /dev/null
+++ b/.gitea/workflows/verify.yml
@@ -0,0 +1,72 @@
+name: verify
+
+# Pre-merge quality gate: clippy + build + tests + microbenchmarks + the headless
+# UI self-test, plus a best-effort dependency audit. Runs on pull requests and on
+# pushes to any branch EXCEPT main (main is gated by release.yml, which repeats
+# these checks before it cuts a release -- so no work is duplicated on main).
+on:
+ pull_request:
+ push:
+ branches-ignore: [main]
+
+jobs:
+ verify:
+ runs-on: alkane-ci
+ env:
+ WX_PREFIX: /root/.cache/wx-3.3.3-linux
+ WX_RS_WXCONFIG: /root/.cache/wx-3.3.3-linux/bin/wx-config
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Install build dependencies
+ run: |
+ apt-get update -qq
+ apt-get install -y -qq --no-install-recommends \
+ libssl-dev pkg-config ca-certificates >/dev/null
+
+ - name: Cache vendored wxWidgets build
+ uses: actions/cache@v4
+ with:
+ path: /root/.cache/wx-3.3.3-linux
+ key: wx-3.3.3-${{ runner.os }}-${{ hashFiles('thirdparty/wx-rs/VERSION') }}
+
+ - name: Build wxWidgets (once, then cached)
+ run: |
+ if [ ! -x "$WX_PREFIX/bin/wx-config" ]; then
+ bash scripts/build-wx-linux.sh
+ else
+ echo "wx prefix restored from cache"
+ fi
+
+ - name: Clippy (our crate, warnings are errors)
+ run: cargo clippy -p alkane-gui --no-deps --release --bins --offline -- -D warnings
+
+ - name: Build
+ run: cargo build --release -p alkane-gui --offline
+
+ - name: Unit tests
+ run: cargo test -p alkane-gui --offline
+
+ - name: Microbenchmarks
+ run: cargo test -p alkane-gui --release --offline -- --ignored --nocapture bench_
+
+ - name: Headless UI self-test
+ run: |
+ apt-get update -qq && apt-get install -y -qq --no-install-recommends \
+ xvfb xauth dbus-x11 fonts-dejavu-core >/dev/null
+ BIN=target/release/alkane-toolkit
+ xvfb-run -a env GDK_BACKEND=x11 ALKANE_SELFTEST=1 "$BIN"
+
+ # Advisory audit is best-effort: it needs the RustSec DB over the network,
+ # which the vendored/offline build otherwise never touches, so a locked-down
+ # runner must not fail the gate on it. Accepted advisories live in
+ # .cargo/audit.toml.
+ - name: Dependency audit (best-effort)
+ continue-on-error: true
+ run: |
+ if command -v cargo-audit >/dev/null 2>&1; then
+ cargo audit || echo "cargo audit reported findings (see .cargo/audit.toml for accepted ones)"
+ else
+ echo "cargo-audit not installed on this runner; skipping"
+ fi
diff --git a/README.md b/README.md
index 942c7152..df38df6d 100644
--- a/README.md
+++ b/README.md
@@ -1,38 +1,116 @@
# alkane-toolkit
-Cross-platform desktop toolkit (Rust core, native GUI) to install **stock** or
-**alkaneOS** firmware on ASIC miner control boards, whatever they currently run
-(stock, Vnish/AnthillOS, Braiins OS+, LuxOS, ePIC, BixBit, WardenOS).
+[](https://gitea.bluefla.re/blueflare/alkane-toolkit/actions)
+
+
+
+
+
+
+
-Sibling to [alkane-sdk](https://gitea.bluefla.re/blueflare/alkane-sdk): the SDK
-owns board knowledge and build outputs; this toolkit is the orchestration
-engine and operator UI that executes its install recipes safely.
+A cross-platform desktop toolkit for discovering, monitoring, and re-flashing
+ASIC miners. It scans a fleet over the network, shows live health and hashrate
+in a sortable table, and installs **stock** or **alkaneOS** firmware onto a
+control board whatever it currently runs (stock, VNish/AnthillOS, Braiins OS+,
+LuxOS, ePIC, HiveOn, BixBit, WardenOS).
-## Status
+The core and UI are pure Rust; the native window is wxWidgets driven through a
+vendored, patched [wx-rs](thirdparty/wx-rs) bridge, so there is no Electron,
+no web view, and a single self-contained binary per platform.
-M1 primary view ships: discovery (vendored asic-rs 0.8.1) + the UI-SPEC
-table (6 KPIs, sortable/drag-reorderable columns, row checkboxes, scan-range
-editor, Excel-style filter, columns panel). Pure-Rust GUI on wxWidgets via
-vendored + patched wx-rs (docs/adr/0002, 0003).
+## What it does
-## Build + run (Debian)
+- **Discover** a fleet by CIDR or IP range and identify each miner's make,
+ model, control board, and firmware (via a vendored [asic-rs](vendor/asic-rs)).
+- **Monitor** hashrate vs. expected, per-board health, chip temperatures, fans,
+ PSU state, and pool workers, with an Excel-style filter and drag-reorderable
+ columns.
+- **Operate** miners from a right-click menu: flash the locate light, pause /
+ resume, restart, set a power or hashrate target, select a firmware profile
+ (LuxOS/VNish presets), configure pools, set the timezone, and change the
+ password -- each action offered only when every selected miner supports it.
+- **Install firmware**: push stock or aftermarket images, or revert an
+ aftermarket miner to stock, behind a typed confirmation.
+
+Discovery and telemetry are read-only and safe to run against any fleet; every
+mutating action is capability-gated and, where destructive, confirmed.
+
+## Build and run (Debian/Ubuntu)
```sh
-scripts/build-wx-linux.sh # once: builds vendored wx 3.3.3 to ~/.cache
+scripts/build-wx-linux.sh # once: builds the vendored wxWidgets 3.3.3 into ~/.cache
scripts/build-gui-linux.sh # cargo build --release -p alkane-gui
~/.cache/alkane-tk-target/release/alkane-toolkit
```
-Windows/macOS: `scripts/build-gui-windows.sh` (needs a Windows/msys2
-toolchain) and `scripts/build-gui-macos.sh` (needs a Mac) - the GUI code is
-shared; only the C++ bridge + wx differ per platform.
+Runtime needs GTK 3: `sudo apt install libgtk-3-0`. To explore the UI with no
+hardware, run the offline demo fleet:
-See `docs/IMPLEMENTATION-PLAN.md` for the roadmap.
+```sh
+ALKANE_FAKE_SCAN=1 alkane-toolkit
+```
-## Hard rules (from alkane-sdk `docs/install-methods.md`, encoded in code)
+Windows and macOS share all GUI code; only the C++ bridge and wx build differ
+(`scripts/build-gui-windows.sh` needs an msys2 toolchain, `-macos.sh` needs a
+Mac).
-1. Never write the bootloader/secure region.
+## Command-line probe
+
+`miner_probe` is a headless companion for hardware checks that should not go
+through the window event loop -- discovery, telemetry, and each write action:
+
+```sh
+miner_probe scan 10.0.0.0/24 # discover + telemetry (TSV)
+miner_probe presets 10.0.0.5 # list a firmware's selectable profiles
+miner_probe setpreset 10.0.0.5 540MHz
+```
+
+Run `miner_probe` with no arguments for the full verb list.
+
+## Development
+
+```sh
+export WX_RS_WXCONFIG="$HOME/.cache/wx-3.3.3-linux/bin/wx-config"
+export CARGO_TARGET_DIR="$HOME/.cache/alkane-tk-target" # keep the target tree off the source share
+
+cargo test -p alkane-gui # unit tests
+cargo test -p alkane-gui --release -- --ignored bench_ # microbenchmarks
+cargo clippy -p alkane-gui --no-deps --bins -- -D warnings # lint gate
+xvfb-run -a env ALKANE_SELFTEST=1 \
+ "$CARGO_TARGET_DIR/release/alkane-toolkit" # headless UI self-test
+```
+
+CI mirrors these: `verify.yml` runs the lint, tests, benchmarks, self-test, and
+a best-effort dependency audit on every pull request and branch push;
+`release.yml` repeats them on `main` and cuts an `X.Y.Z` release with the built
+binary attached when the change warrants it. Dependencies are vendored under
+`vendor/`, so builds never touch the network.
+
+## Architecture
+
+- `crates/alkane-gui` -- the application: scan engine, data model, wxWidgets UI,
+ and the `miner_probe` CLI (the other `crates/alkane-*` are early scaffolding).
+- `vendor/asic-rs` -- the miner-discovery and control library, vendored and
+ extended through numbered patches under `thirdparty/asic-rs/patches`.
+- `thirdparty/wx-rs` -- the patched wxWidgets bridge (see `docs/adr/0002`,
+ `0003`).
+
+See [`docs/IMPLEMENTATION-PLAN.md`](docs/IMPLEMENTATION-PLAN.md) for the roadmap
+and [`docs/aftermarket-parity-roadmap.md`](docs/aftermarket-parity-roadmap.md)
+for the firmware config/scan parity work.
+
+## Firmware safety rules
+
+Encoded in code, from alkane-sdk `docs/install-methods.md`:
+
+1. Never write the bootloader or secure region.
2. Verify on a channel the installer does not control.
-3. Reboot is root-only; a dropped SSH connection can be success.
-4. A packer is per board; never reuse across boards.
+3. Reboot is root-only; a dropped SSH connection can still be success.
+4. A packer is per board; never reuse one across boards.
5. Boot-switch handling is an explicit, verified step.
+
+## License
+
+Dual-licensed under either of [Apache-2.0](LICENSE-APACHE) or
+[MIT](LICENSE-MIT) at your option.
diff --git a/badges/bench.svg b/badges/bench.svg
new file mode 100644
index 00000000..8cfa8500
--- /dev/null
+++ b/badges/bench.svg
@@ -0,0 +1,19 @@
+
diff --git a/badges/coverage.svg b/badges/coverage.svg
new file mode 100644
index 00000000..8b702f5c
--- /dev/null
+++ b/badges/coverage.svg
@@ -0,0 +1,19 @@
+
diff --git a/badges/dependencies.svg b/badges/dependencies.svg
new file mode 100644
index 00000000..5f6df415
--- /dev/null
+++ b/badges/dependencies.svg
@@ -0,0 +1,19 @@
+
diff --git a/badges/license.svg b/badges/license.svg
new file mode 100644
index 00000000..11f00487
--- /dev/null
+++ b/badges/license.svg
@@ -0,0 +1,19 @@
+
diff --git a/badges/loc.svg b/badges/loc.svg
new file mode 100644
index 00000000..6bab57ad
--- /dev/null
+++ b/badges/loc.svg
@@ -0,0 +1,19 @@
+
diff --git a/badges/quality.svg b/badges/quality.svg
new file mode 100644
index 00000000..2a3aee2e
--- /dev/null
+++ b/badges/quality.svg
@@ -0,0 +1,19 @@
+
diff --git a/badges/tests.svg b/badges/tests.svg
new file mode 100644
index 00000000..acdd1c51
--- /dev/null
+++ b/badges/tests.svg
@@ -0,0 +1,19 @@
+
diff --git a/ci/gen-badges.py b/ci/gen-badges.py
new file mode 100644
index 00000000..02ee5e7a
--- /dev/null
+++ b/ci/gen-badges.py
@@ -0,0 +1,165 @@
+#!/usr/bin/env python3
+"""Generate self-contained shields-style SVG badges into badges/.
+
+Self-hosted Gitea renders a README's relative image links straight from the
+repo, so committing the SVGs (rather than depending on an external badge
+service that would have to reach a possibly-private Gitea) is the robust choice.
+CI regenerates them from live metrics and commits any changes back.
+
+Usage:
+ gen-badges.py --tests N --coverage PCT --bench "label" [--out badges]
+
+Metrics not passed on the command line are computed here (LOC from the source
+tree, dependency count from Cargo.lock, license from Cargo.toml).
+"""
+import argparse
+import os
+import re
+import sys
+
+# Approximate per-character width at 11px DejaVu Sans, in 1/10 px, matching the
+# shields "flat" look closely enough for a fixed-width monospace-ish render.
+CHAR_W = 6.5
+PAD = 6.0
+
+COLORS = {
+ "green": "#4c1",
+ "brightgreen": "#4c1",
+ "yellowgreen": "#a4a61d",
+ "yellow": "#dfb317",
+ "orange": "#fe7d37",
+ "red": "#e05d44",
+ "blue": "#007ec6",
+ "lightgrey": "#9f9f9f",
+ "grey": "#555",
+}
+
+
+def text_width(s: str) -> float:
+ return len(s) * CHAR_W + 2 * PAD
+
+
+def badge_svg(label: str, message: str, color: str) -> str:
+ color = COLORS.get(color, color)
+ lw = round(text_width(label), 1)
+ mw = round(text_width(message), 1)
+ total = round(lw + mw, 1)
+ lx = round(lw / 2, 1)
+ mx = round(lw + mw / 2, 1)
+ # Text is drawn twice (a dark shadow then the light glyphs) for the shields look.
+ return f'''
+'''
+
+
+def count_loc(root: str) -> int:
+ total = 0
+ for base in ("crates",):
+ for dirpath, _dirs, files in os.walk(os.path.join(root, base)):
+ for f in files:
+ if f.endswith(".rs"):
+ try:
+ with open(os.path.join(dirpath, f), encoding="utf-8", errors="ignore") as fh:
+ total += sum(1 for _ in fh)
+ except OSError:
+ pass
+ return total
+
+
+def count_deps(root: str) -> int:
+ lock = os.path.join(root, "Cargo.lock")
+ try:
+ with open(lock, encoding="utf-8") as fh:
+ return sum(1 for line in fh if line.startswith("name = "))
+ except OSError:
+ return 0
+
+
+def read_license(root: str) -> str:
+ try:
+ with open(os.path.join(root, "Cargo.toml"), encoding="utf-8") as fh:
+ for line in fh:
+ m = re.match(r'\s*license\s*=\s*"([^"]+)"', line)
+ if m:
+ return m.group(1)
+ except OSError:
+ pass
+ return "unknown"
+
+
+def loc_color(n: int) -> str:
+ return "blue"
+
+
+def cov_color(pct: float) -> str:
+ if pct >= 80:
+ return "brightgreen"
+ if pct >= 60:
+ return "yellowgreen"
+ if pct >= 40:
+ return "yellow"
+ if pct >= 20:
+ return "orange"
+ return "red"
+
+
+def human(n: int) -> str:
+ if n >= 1000:
+ return f"{n / 1000:.1f}k".replace(".0k", "k")
+ return str(n)
+
+
+def main() -> int:
+ ap = argparse.ArgumentParser()
+ ap.add_argument("--out", default="badges")
+ ap.add_argument("--root", default=".")
+ ap.add_argument("--tests", type=int, default=None)
+ ap.add_argument("--coverage", type=float, default=None)
+ ap.add_argument("--bench", default=None)
+ ap.add_argument("--clippy", default="clean")
+ args = ap.parse_args()
+
+ os.makedirs(os.path.join(args.root, args.out), exist_ok=True)
+
+ def write(name, label, message, color):
+ path = os.path.join(args.root, args.out, name + ".svg")
+ with open(path, "w", encoding="utf-8") as fh:
+ fh.write(badge_svg(label, message, color))
+ print(f"wrote {path}: {label}={message}")
+
+ loc = count_loc(args.root)
+ deps = count_deps(args.root)
+ lic = read_license(args.root)
+
+ write("loc", "lines of code", human(loc), loc_color(loc))
+ write("license", "license", lic, "blue")
+ write("dependencies", "dependencies", str(deps), "blue")
+ write("quality", "clippy", args.clippy, "brightgreen" if args.clippy == "clean" else "orange")
+ if args.tests is not None:
+ write("tests", "tests", f"{args.tests} passing", "brightgreen")
+ if args.coverage is not None:
+ write("coverage", "coverage", f"{args.coverage:.0f}%", cov_color(args.coverage))
+ if args.bench is not None:
+ write("bench", "bench", args.bench, "blue")
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/deny.toml b/deny.toml
new file mode 100644
index 00000000..7f2672f7
--- /dev/null
+++ b/deny.toml
@@ -0,0 +1,43 @@
+# cargo-deny configuration (https://embarkstudios.github.io/cargo-deny/).
+#
+# Run locally with `cargo deny check`. CI's security gate is cargo-audit (lighter,
+# already wired); this file documents the dependency policy and lets anyone run a
+# fuller license/advisory/source check. The whole dependency set is vendored under
+# ./vendor and resolved offline (see .cargo/config.toml).
+
+[advisories]
+version = 2
+# Accepted, documented advisories (build-time-only reqwest 0.11 subtree of the
+# wx-rs build script -- never linked into the runtime binary). Mirrors
+# .cargo/audit.toml; re-review when the vendored dependency set is refreshed.
+ignore = [
+ "RUSTSEC-2026-0258", # h2 0.3 DATA-frame DoS (build-time HTTP client only)
+ "RUSTSEC-2025-0134", # rustls-pemfile 1.0.4 unmaintained (same subtree)
+]
+
+[licenses]
+version = 2
+# The project is MIT OR Apache-2.0; only permissive licenses are allowed in the
+# dependency tree.
+allow = [
+ "MIT",
+ "Apache-2.0",
+ "Apache-2.0 WITH LLVM-exception",
+ "BSD-2-Clause",
+ "BSD-3-Clause",
+ "ISC",
+ "Zlib",
+ "Unicode-3.0",
+ "Unicode-DFS-2016",
+ "MPL-2.0",
+ "CC0-1.0",
+]
+confidence-threshold = 0.9
+
+[bans]
+multiple-versions = "warn"
+wildcards = "allow"
+
+[sources]
+unknown-registry = "warn"
+unknown-git = "warn"
diff --git a/thirdparty/wx-rs/wx-rs-0.2.0-patched/Cargo.toml b/thirdparty/wx-rs/wx-rs-0.2.0-patched/Cargo.toml
index 7907ac27..34d8ab13 100644
--- a/thirdparty/wx-rs/wx-rs-0.2.0-patched/Cargo.toml
+++ b/thirdparty/wx-rs/wx-rs-0.2.0-patched/Cargo.toml
@@ -39,6 +39,11 @@ version = "1.0"
[build-dependencies.embed-resource]
version = "1.3"
+# reqwest is only used by build.rs to download the wxWidgets source on
+# Windows/macOS; on Linux download_dist() returns before touching it, and it is
+# never linked into the runtime binary. Kept at the vendored 0.11 (the build tree
+# is fully vendored / offline); the h2 0.3 advisory it pulls is build-time only
+# and is documented as accepted in audit.toml (RUSTSEC-2026-0258).
[build-dependencies.reqwest]
version = "0.11"
features = ["blocking"]