valentine

Terminal control panel for the Focusrite Scarlett 18i20 — a from-scratch replacement for Focusrite Control.
Log | Files | Refs | README | LICENSE

commit 3b1ff1bf89f035fd06526cc9de818e9d6e57a7f3
parent 40d126c571eef6210803e1c52e6b32e2bbbbe37d
Author: Matthew Gantenbein <ganten1998@gmail.com>
Date:   Mon,  1 Jun 2026 11:14:43 -0500

feat(spike): muxcheck --write-noop — verify write path with a no-op rewrite

Opt-in flag writes the current routing back unchanged via write_routing_tables,
then re-reads to confirm zero routes changed. Safest possible exercise of the
real SET_MUX path on hardware before enabling actual routing edits.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Diffstat:
Mspike/src/bin/muxcheck.rs | 29++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/spike/src/bin/muxcheck.rs b/spike/src/bin/muxcheck.rs @@ -83,6 +83,33 @@ fn run() -> Result<(), Box<dyn std::error::Error>> { } } let _ = MuxEntry { dest: 0, source: 0 }; // keep import meaningful - println!("\n(READ-ONLY — nothing was written.)"); + + // OPTIONAL no-op write test: only with `--write-noop`, and only if the + // re-encode matched (mism==0). Writes the CURRENT routing back unchanged, + // then re-reads to confirm nothing changed. This exercises the real write + // path on hardware with zero risk of altering the setup. + let do_write = std::env::args().any(|a| a == "--write-noop"); + if do_write && mism == 0 { + println!("\n--write-noop: writing current routing back UNCHANGED…"); + dev.write_routing_tables(&tables)?; + let after = dev.get_mux(count)?; + let mut after_map: HashMap<u16, u16> = HashMap::new(); + for e in &after { + after_map.insert(e.dest, e.source); + } + let changed = device_map + .iter() + .filter(|(d, s)| after_map.get(d).copied().unwrap_or(0) != **s) + .count(); + if changed == 0 { + println!("\x1b[32mNO-OP WRITE OK\x1b[0m — routing identical after write. Write path verified."); + } else { + println!("\x1b[31mNO-OP WRITE CHANGED {changed} routes!\x1b[0m — investigate before edits."); + } + } else if do_write { + println!("\n--write-noop skipped: re-encode had mismatches; not writing."); + } else { + println!("\n(READ-ONLY — nothing was written. Add --write-noop to test the write path.)"); + } Ok(()) }