HANDOFF.md for Claude Code pickup

This commit is contained in:
2026-09-15 14:41:07 -06:00
parent b264cdd6d1
commit 53ee49e90a
+104
View File
@@ -0,0 +1,104 @@
# HANDOFF — alkane-toolkit
**For:** resuming this work in Claude Code (or any fresh agent session).
**Read order:** this file → `docs/IMPLEMENTATION-PLAN.md` → `docs/UI-SPEC.md` → `docs/adr/000{1,2,3}*.md` → `README.md`.
Parent project: `~/Ultron/projects/miner-firmware/` (its `HANDOFF.md`, `AGENTS.md` and `MEMORY-SNAPSHOT/` hold the bench context and standing orders — read them before touching real hardware).
## 1. What this repo is
`alkane-toolkit` = cross-platform desktop toolkit (pure-Rust GUI on wxWidgets)
to install **stock or alkaneOS** on ASIC miner control boards, whatever they
currently run. Sibling repo `~/Ultron/projects/miner-firmware/alkane-sdk/`
owns the board doctrine (`docs/install-methods.md` = the invariants) and the
board metadata (`boards/*/board.yml`); this toolkit mechanizes those recipes.
- Remote: `https://gitea.bluefla.re/blueflare/alkane-toolkit` (private, branch `main`, tip `b264cdd6`)
- GitHub is DEAD (account suspended): never touch github remotes; old ones are kept as `github-suspended` in sibling clones
- Gitea auth: token in `~/.config/gitea/token`, askpass helper `~/.config/gitea/askpass` (user `noah`, admin). For git: `export GIT_ASKPASS=~/.config/gitea/askpass GIT_TERMINAL_PROMPT=0`
## 2. Current state (2026-09-15)
**Ships today (M1 primary view):**
- Discovery via vendored **asic-rs 0.8.1** (MinerFactory::scan_stream over the configured CIDR list)
- UI-SPEC primary view: 6 KPIs (Total/Hashing/Slow/Not hashing/total hashrate/est. power), scan-ranges editor, Excel-style filter panel, columns panel, sortable + drag-reorderable table with row checkboxes, IP pinned first, default order hashrate → power → chip temp → cooling → firmware → pool worker → model/status
- Pure-Rust GUI on wxWidgets: vendored wx-rs 0.2.0 **extended by patches** (upstream stubs Linux and had no widgets) + vendored wxWidgets 3.3.3 (static monolithic GTK3)
- Built + smoke-tested on this machine (debug + release run clean under xvfb)
**Not done yet (open threads, in rough priority):**
1. Windows + macOS builds — `scripts/build-gui-{windows,macos}.sh` exist; Windows needs msys2/MSVC (wx-rs build.rs handles msys2 paths natively), macOS needs a Mac to link. Consider a gitea Actions CI runner. No CI config exists at all yet.
2. ARP/ICMP pre-pass for link-up-but-silent boards (M1 scope, spec'd in plan §5, not implemented)
3. Column order/visibility persistence (`ui.conf` — spec'd in UI-SPEC "Implementation notes", not implemented)
4. Sort-direction indicator in headers; per-model "Slow" bands (currently flat 80% of expected); model-derived power estimates for units that don't report wattage
5. M2: verify-image port (magic/min-size/integrity) + artifact registry expansion (`crates/alkane-artifacts/data/manifest-seed.csv` = 14 sha256'd bench artifacts; bulk archives 3.7GB/624MB not hashed)
6. M3+: first install pathway (zynq-7010 stock↔stock, proven on the bench S17), then per plan §7. Note **no alkaneOS build exists** (SDK boards all "bake"), so installs are stock↔stock only until the SDK produces artifacts.
## 3. How to build / run (this machine)
```sh
cd ~/Ultron/projects/miner-firmware/alkane-toolkit
scripts/build-wx-linux.sh # once: wx 3.3.3 → ~/.cache/wx-3.3.3-linux (out-of-tree)
scripts/build-gui-linux.sh # release build (needs WX_RS_WXCONFIG, script sets it)
/usr/local/bin/alkane-toolkit # installed binary; or ~/.cache/alkane-tk-target/release/alkane-toolkit
```
Needs a display (user's desktop session has DISPLAY=:0). Headless smoke test:
`timeout 15 xvfb-run -a /usr/local/bin/alkane-toolkit` — rc 124 = ran until killed (good), rc 139 = crash.
## 4. Machine quirks (these cost hours — don't re-learn them)
- **The synced project mount is noexec** for newly-written files: never build or execute anything inside the repo tree. wx builds go to `~/.cache/wxbuild`, cargo target to `~/.cache/alkane-tk-target` (set machine-locally via `~/.cargo/config.toml`, NOT committed).
- **`cargo vendor vendor` DELETES unmanaged directories under vendor/**. Hand-made trees live in `thirdparty/` (wxwidgets, wx-rs). Only cargo-managed crate sources are in `vendor/` (341 crates; offline builds via committed `.cargo/config.toml`).
- **/tmp tmpfs is 100% full** (bench artifacts live there — do not clean). Build outputs must not go to /tmp.
- The FS is very slow for many-file operations: `git add` of thirdparty/wxwidgets (~10k files) takes ~20 min; extraction of the wx tarball will blow a 120 s timeout. Run big FS operations as background jobs and poll.
- sudo: `sudo -S -p '' <cmd> < ~/.sudopass` (non-interactive).
- Rust 1.97.1, cargo, gdb, xvfb-run, mingw-w64, gtk3 dev, pcre2 dev all installed.
## 5. Architecture map
```
crates/
alkane-core/ domain types (stub — next milestone fills it)
alkane-discovery/ asic-rs dependency wired (engine lives in alkane-gui/scan.rs today)
alkane-access/ stub (SSH/foothold layer, M3+)
alkane-flash/ stub (write/verify engines, M3+)
alkane-artifacts/ manifest-seed.csv (14 artifacts w/ sha256)
alkane-cli/ stub bin
alkane-gui/ THE APP (bin "alkane-toolkit"): main.rs, model.rs, scan.rs, ui.rs
thirdparty/
wxwidgets/wxWidgets-3.3.3/ pristine dist tarball tree (+ VERSION sha256, patches/ empty)
wx-rs/wx-rs-0.2.0-patched/ the used crate (path dep) + VERSION + patches/:
0001 linux/GTK3 wx-config build path (build.rs; handles full-path .a in --libs!)
0002 Rust widget bindings (src/widgets.rs: Widget API + single event dispatcher)
0003 C++ widget bridge (cpp_src/widgets_bridge.cpp: panel/sizers/static text/
button/textctrl/checkbox/checklistbox/dialog/dvlc/timer/destroy)
0004 upstream fixes (Linux get_client_size branch; init render/handle_events —
upstream left them UNINITIALIZED: 5ms render timer calls garbage in release)
vendor/ cargo-managed ONLY (341 crates, offline)
scripts/ build-wx-linux.sh, build-gui-{linux,windows,macos}.sh
docs/ IMPLEMENTATION-PLAN.md, UI-SPEC.md, adr/0001-0003
```
Key implementation facts (don't re-derive):
- **Event model**: ONE C callback (`wxbr_set_widget_event_fn`) → Rust `set_event_handler(Handler)`; all events funnel through `ui::dispatch` (thread_local APP). Event kinds: ButtonClicked(id), DvlcValueChanged(row,col), DvlcHeaderClick(col), DvlcReordered, TimerTick(id).
- **Table semantics**: `view.order` = creation order = display order; toggle col is creation idx 0 (bool variants only); `dvlc_col_at_pos()` maps display→creation after a drag; store rows are appended in filtered+sorted view order, so store row == `view_idx[row]`. Header click sort cycles asc→desc→off and refills.
- **Scan thread**: std thread + own tokio runtime + std mpsc; a 1 s wx Timer drains it (`App::drain_scan`). Ranges: `~/.config/alkane-toolkit/scan-ranges.txt` (default 10.255.1.0/24), parse via `scan::parse_cidr`.
- **asic-rs API**: `MinerFactory::from_subnet("a.b.c.d/p")`, `.scan_stream()` → `Stream<Item=Box<dyn Miner>>`; `Miner::get_data().await -> MinerData` (trait at `asic_rs::core::traits::miner::Miner`); `HashRate.clone().as_unit(HashRateUnit::TeraHash).value`; `Power::as_watts()`, `Temperature::as_celsius()`, `AngularVelocity::as_rpm()`; pools: `MinerData.pools[].pools[]` with `.user/.active`.
- **wx 3.3 API gotchas hit**: `store->GetValueByRow(v,row,col)` (not GetValue), `GetColumnPosition()` (no GetColumnAt), `--enable-dataview` doesn't exist, `--disable-stc --without-catch2 --disable-tests` needed only if using the GitHub source export (the dist tarball in thirdparty/ is complete — just chmod +x configure).
## 6. Verification evidence
- `cargo build --workspace --offline` clean (network-independent; all sources vendored)
- Release binary smoke-tested twice under xvfb: runs until killed, no crash, no wx warnings
- Git: tip `b264cdd6` pushed to gitea (gitea repo `size` field updates lazily — the commit has 16k files/4.9M insertions incl. the wx tree)
- NOT yet verified: a human eyeballing the window on the real bench fleet (xvfb smoke ≠ visual check). First thing next session: run it, confirm the 9 bench boards render.
## 7. Bench fleet context (for the scan you'll see)
9 boards live on 10.255.1.0/24: S17 stock (.112, root+EMPTY password, legacy SSH algos), S19 xil OurOS (.166), S19j Pro bb OurOS (.152), S19k Pro cv OurOS (.167), S21 Pro aml stock (.149), WhatsMiner H3 (.126), H616 (.131), M50 CB4 (.148 — random MAC, address moves), WardenOS dev (.115). Scanning is read-only and routine; the `live-fleet-ops` rules (no auth bursts, gentle on prod 10.2.1.0/24) are standing orders in AGENTS.md. Never install/flash anything without the operator explicitly asking.
## 8. Conventions for this repo
- Confidence tags (CONFIRMED/DERIVED/EXTERNAL) on claims in docs; cite file paths.
- Commit style so far: single-line imperative summaries, no sign-off noise.
- The repo has no AGENTS.md/CLAUDE.md yet — if you establish repo-level rules, write them there and keep them short.
- When you change the vendored wx-rs: edit `thirdparty/wx-rs/wx-rs-0.2.0-patched/`, regenerate the matching `patches/NNNN-*.patch` via `diff -u /tmp/pristine ...` (pristine tarball URL+sha in `VERSION`), commit both.