← Commit history

Merge PR #643: 0.2.131: build for WebAssembly (John Lauer's port, #184, on 0.2.130) (wasm-port-0.2.131 -> main) merge

Colby Knox ·108120dc29 · ·parents 5d17de5, 52f2bae

Showing changes introduced by the merge (against its first parent).

65 files changed +639−292
Cargo.lock+25−10Cargo.toml+3−1crates/adom-aiflow/Cargo.toml+1crates/adom-aiflow/src/artifact_store.rs+2−2crates/adom-aiflow/src/checks.rs+4−4crates/adom-aiflow/src/clipwatch.rs+6−6crates/adom-aiflow/src/continuation.rs+2−2crates/adom-aiflow/src/copper_carry.rs+1−1crates/adom-aiflow/src/dashboard.rs+7−7crates/adom-aiflow/src/decoupling_check.rs+1−1crates/adom-aiflow/src/embedded_models.rs+1−1crates/adom-aiflow/src/export.rs+4−4crates/adom-aiflow/src/fields_review.rs+1−1crates/adom-aiflow/src/fields_versions.rs+4−4crates/adom-aiflow/src/giveback_policy.rs+1−1crates/adom-aiflow/src/handson.rs+2−2crates/adom-aiflow/src/led_states.rs+2−2crates/adom-aiflow/src/library_review.rs+1−1crates/adom-aiflow/src/main.rs+161−158crates/adom-aiflow/src/mechanical.rs+3−3crates/adom-aiflow/src/netclasses.rs+2−2crates/adom-aiflow/src/page_results.rs+2−2crates/adom-aiflow/src/placement_verify.rs+1−1crates/adom-aiflow/src/pourverify.rs+4−4crates/adom-aiflow/src/preboard.rs+4−4crates/adom-aiflow/src/project_lib.rs+2−2crates/adom-aiflow/src/remote_binding.rs+1−1crates/adom-aiflow/src/reviews.rs+9−9crates/adom-aiflow/src/rules_card.rs+1−1crates/adom-aiflow/src/schematic_check.rs+5−5crates/adom-aiflow/src/schematic_identity.rs+3−3crates/adom-aiflow/src/schematic_symbols.rs+1−1crates/adom-aiflow/src/sequence.rs+10−10crates/adom-aiflow/src/silk_policy.rs+1−1crates/adom-aiflow/src/skill_hints.rs+1−1crates/adom-aiflow/src/spec_nets.rs+1−1crates/adom-aiflow/src/stackup_presets.rs+1−1crates/adom-aiflow/src/step_export.rs+6−6crates/adom-aiflow/src/testplan.rs+1−1crates/adom-aiflow/src/timeline_server.rs+1−1crates/adom-aiflow/src/verified.rs+2−2crates/adom-aiflow/src/winpath.rs+1−1crates/adom-aiflow/src/zone_ownership.rs+1−1crates/aiflow-analyze/Cargo.toml+1crates/aiflow-analyze/src/fields_report.rs+1−1crates/aiflow-analyze/src/lib.rs+1−1crates/aiflow-board/Cargo.toml+1crates/aiflow-board/src/altium.rs+2−2crates/aiflow-bridge/Cargo.toml+1crates/aiflow-bridge/src/altium.rs+1−1crates/aiflow-bridge/src/lib.rs+10−3crates/aiflow-copper/Cargo.toml+1crates/aiflow-copper/src/lib.rs+3−3crates/aiflow-copper/tests/project_rules.rs+1−1crates/aiflow-place/Cargo.toml+1crates/aiflow-place/src/lib.rs+1−1crates/aiflow-pours/Cargo.toml+1crates/aiflow-pours/src/lib.rs+2−2crates/aiflow-run/Cargo.toml+1crates/aiflow-run/src/lib.rs+3−3crates/aiflow-sys/Cargo.toml+9crates/aiflow-sys/src/lib.rs+291docs/release-0.2.131.md+12package.json+1−1page.json+1−1
Cargo.lock+25−10
@@ -4,7 +4,7 @@ version = 4  [[package]] name = "adom-aiflow"-version = "0.2.130"+version = "0.2.131" dependencies = [  "aiflow-analyze",  "aiflow-board",@@ -15,6 +15,7 @@ dependencies = [  "aiflow-pours",  "aiflow-router",  "aiflow-run",+ "aiflow-sys",  "base64",  "clap",  "notify",@@ -27,9 +28,10 @@ dependencies = [  [[package]] name = "aiflow-analyze"-version = "0.2.130"+version = "0.2.131" dependencies = [  "aiflow-board",+ "aiflow-sys",  "serde",  "serde_json",  "sha2",@@ -37,8 +39,9 @@ dependencies = [  [[package]] name = "aiflow-board"-version = "0.2.130"+version = "0.2.131" dependencies = [+ "aiflow-sys",  "roxmltree",  "serde",  "serde_json",@@ -46,26 +49,28 @@ dependencies = [  [[package]] name = "aiflow-bridge"-version = "0.2.130"+version = "0.2.131" dependencies = [  "aiflow-board",+ "aiflow-sys",  "serde",  "serde_json", ]  [[package]] name = "aiflow-copper"-version = "0.2.130"+version = "0.2.131" dependencies = [  "aiflow-board",  "aiflow-grid",+ "aiflow-sys",  "serde",  "serde_json", ]  [[package]] name = "aiflow-grid"-version = "0.2.130"+version = "0.2.131" dependencies = [  "aiflow-board",  "serde",@@ -74,26 +79,28 @@ dependencies = [  [[package]] name = "aiflow-place"-version = "0.2.130"+version = "0.2.131" dependencies = [  "aiflow-board",+ "aiflow-sys",  "serde",  "serde_json", ]  [[package]] name = "aiflow-pours"-version = "0.2.130"+version = "0.2.131" dependencies = [  "aiflow-board",  "aiflow-copper",+ "aiflow-sys",  "serde",  "serde_json", ]  [[package]] name = "aiflow-router"-version = "0.2.130"+version = "0.2.131" dependencies = [  "aiflow-board",  "aiflow-grid",@@ -104,12 +111,20 @@ dependencies = [  [[package]] name = "aiflow-run"-version = "0.2.130"+version = "0.2.131" dependencies = [+ "aiflow-sys",  "serde",  "serde_json", ] +[[package]]+name = "aiflow-sys"+version = "0.2.131"+dependencies = [+ "serde_json",+]+ [[package]] name = "anstream" version = "1.0.0"
Cargo.toml+3−1
@@ -1,6 +1,7 @@ [workspace] resolver = "2" members = [+    "crates/aiflow-sys",     "crates/aiflow-board",     "crates/aiflow-grid",     "crates/aiflow-router",@@ -14,12 +15,13 @@ members = [ ]  [workspace.package]-version = "0.2.130"+version = "0.2.131" edition = "2021" license = "MIT" repository = "https://wiki.adom.inc/adom/adom-aiflow"  [workspace.dependencies]+aiflow-sys = { path = "crates/aiflow-sys" } serde = { version = "1", features = ["derive"] } serde_json = "1" clap = { version = "4", features = ["derive"] }
crates/adom-aiflow/Cargo.toml+1
@@ -10,6 +10,7 @@ name = "adom-aiflow" path = "src/main.rs"  [dependencies]+aiflow-sys = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } clap = { workspace = true }
crates/adom-aiflow/src/artifact_store.rs+2−2
@@ -10,7 +10,7 @@ pub fn snapshot(source: &Path, run_dir: &Path) -> Result<(PathBuf, String), Stri     let suffix = source.extension().and_then(|s| s.to_str())         .filter(|s| !s.is_empty() && s.len() <= 16 && s.bytes().all(|b| b.is_ascii_alphanumeric()))         .map(|s| format!(".{}", s.to_ascii_lowercase())).unwrap_or_default();-    let dir = std::fs::canonicalize(run_dir)+    let dir = aiflow_sys::canonicalize(run_dir)         .map_err(|e| format!("cannot open artifact run directory: {e}"))?;     let dest = dir.join(format!("artifact-{hash}{suffix}"));     match std::fs::OpenOptions::new().write(true).create_new(true).open(&dest) {@@ -39,7 +39,7 @@ pub fn snapshot(source: &Path, run_dir: &Path) -> Result<(PathBuf, String), Stri mod tests {     use super::*;     fn directory(name: &str) -> PathBuf {-        let p = std::env::temp_dir().join(format!("aiflow-artifact-{name}-{}", std::process::id()));+        let p = aiflow_sys::temp_dir().join(format!("aiflow-artifact-{name}-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&p).unwrap();         p     }
crates/adom-aiflow/src/checks.rs+4−4
@@ -1045,7 +1045,7 @@ pub fn model_bbox(file: &Path, service_calls: &mut usize) -> Option<(BBox, Strin         // pace the shared service: one call at a time, a short gap between them         if *service_calls > 0 { std::thread::sleep(std::time::Duration::from_millis(400)); }         *service_calls += 1;-        if let Ok(o) = std::process::Command::new(&cli).args(["features", "-o", "-"]).arg(file).stderr(std::process::Stdio::null()).output() {+        if let Ok(o) = aiflow_sys::process::Command::new(&cli).args(["features", "-o", "-"]).arg(file).stderr(aiflow_sys::process::Stdio::null()).output() {             if let Ok(v) = serde_json::from_slice::<Value>(&o.stdout) {                 let axis = |k: &str| -> Option<[f64; 2]> { let a = v["bbox_mm"][k].as_array()?; Some([a.first()?.as_f64()?, a.get(1)?.as_f64()?]) };                 if let (Some(x), Some(y), Some(z)) = (axis("x"), axis("y"), axis("z")) {@@ -1584,7 +1584,7 @@ mod tests {      #[test]     fn jlcpcb_pack_follows_board_layers() {-        let dir = std::env::temp_dir().join(format!("aiflow-rules6-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-rules6-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let b = dir.join("b6.kicad_pcb");         six_layer_board(&b);@@ -1635,7 +1635,7 @@ mod tests {      #[test]     fn rules_profiles() {-        let dir = std::env::temp_dir().join(format!("aiflow-rules-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-rules-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let b = dir.join("b.kicad_pcb");         let bs = b.to_str().unwrap();@@ -1718,7 +1718,7 @@ mod dru_syntax_tests {      #[test]     fn the_fab_profile_no_longer_passes_on_the_word_rule() {-        let dir = std::env::temp_dir().join(format!("aiflow-dru-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-dru-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let board = dir.join("b.kicad_pcb");         std::fs::write(&board, "(kicad_pcb (version 20241229))").unwrap();
crates/adom-aiflow/src/clipwatch.rs+6−6
@@ -199,7 +199,7 @@ pub fn watch(r: &mut aiflow_run::Run, br: &aiflow_bridge::Bridge, dir: &std::pat     let step = cap["step"].as_str().unwrap_or("").to_string();     let tag = format!("{}-{}", step, cap["visit"].as_u64().unwrap_or(1));     // collect what the dead take holds (it may be truncated: the stop's own check says so)-    let save_to = std::fs::canonicalize(dir).unwrap_or(dir.to_path_buf()).display().to_string();+    let save_to = aiflow_sys::canonicalize(dir).unwrap_or(dir.to_path_buf()).display().to_string();     let stop = br.record_stop(&rid, &save_to);     let local = crate::settle_clip_stop(r, pos, &stop, dir);     r.data["captures"][pos]["died"] = json!({"at": died_at, "why": why});@@ -249,7 +249,7 @@ pub fn truncation_verdict(ffprobe_ok: bool, stderr: &str, duration: Option<f64>)  /// Run ffprobe on a clip: Some(why) when it is truncated. A missing ffprobe is not a verdict. pub fn truncated(file: &str) -> Option<String> {-    let o = std::process::Command::new("ffprobe").args(["-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", file]).output().ok()?;+    let o = aiflow_sys::process::Command::new("ffprobe").args(["-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", file]).output().ok()?;     let d = String::from_utf8_lossy(&o.stdout).trim().parse::<f64>().ok();     truncation_verdict(o.status.success(), &String::from_utf8_lossy(&o.stderr), d) }@@ -378,11 +378,11 @@ mod tests {     #[cfg(unix)]     #[test]     fn ffprobe_reads_a_cut_off_mp4_as_truncated() {-        if std::process::Command::new("ffmpeg").arg("-version").output().is_err() { return; }-        let dir = std::env::temp_dir().join(format!("aiflow-trunc-{}", std::process::id()));+        if aiflow_sys::process::Command::new("ffmpeg").arg("-version").output().is_err() { return; }+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-trunc-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let f = dir.join("c.mp4");-        let ok = std::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-f", "lavfi", "-i", "testsrc=size=160x90:rate=10", "-t", "2", "-pix_fmt", "yuv420p", f.to_str().unwrap()]).status().map(|s| s.success()).unwrap_or(false);+        let ok = aiflow_sys::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-f", "lavfi", "-i", "testsrc=size=160x90:rate=10", "-t", "2", "-pix_fmt", "yuv420p", f.to_str().unwrap()]).status().map(|s| s.success()).unwrap_or(false);         if !ok { return; }         assert!(truncated(f.to_str().unwrap()).is_none());         // cut the file before its moov atom (written at the end by default): the shape of a take that died@@ -427,7 +427,7 @@ pub fn no_recorder_note(data: &Value) -> Option<String> { /// A step on a box with no recorder: the previous step's closing screenshot, this step's opening /// one, and a short note (the full notice is said once, by `recorder`). pub fn no_recorder_step(r: &mut aiflow_run::Run, br: &aiflow_bridge::Bridge, dir: &std::path::Path, step: &str, hwnd: Option<i64>) -> String {-    let save_to = std::fs::canonicalize(dir).unwrap_or(dir.to_path_buf()).display().to_string();+    let save_to = aiflow_sys::canonicalize(dir).unwrap_or(dir.to_path_buf()).display().to_string();     if let Some(prev) = r.data["stepShots"].as_array().and_then(|a| a.last()).filter(|p| p.get("end").is_none()).cloned() {         let n = r.data["stepShots"].as_array().map(|a| a.len() - 1).unwrap_or(0);         if let Some(h) = prev["hwnd"].as_i64() {
crates/adom-aiflow/src/continuation.rs+2−2
@@ -264,7 +264,7 @@ mod tests {     }     #[test]     fn genuine_external_dependency_requires_existing_evidence() {-        let p = std::env::temp_dir().join(format!("aiflow-dependency-{}.json", std::process::id()));+        let p = aiflow_sys::temp_dir().join(format!("aiflow-dependency-{}.json", aiflow_sys::process::id()));         std::fs::write(&p, b"hardware unavailable").unwrap();         let e = json!({"kind":"external-dependency","category":"hardware","reason":"assembly absent","dependency":"assembled board","resumeWhen":"board connected","attemptedRemedies":["inspected fixture"],"evidenceFiles":[p],"availableWork":[]});         let r = assess(&json!({}), &[], Some(Ok(e.clone())));@@ -275,7 +275,7 @@ mod tests {     }     #[test]     fn stale_delivery_and_returns_do_not_complete() {-        let p = std::env::temp_dir().join(format!("aiflow-guard-{}.mp4", std::process::id()));+        let p = aiflow_sys::temp_dir().join(format!("aiflow-guard-{}.mp4", aiflow_sys::process::id()));         std::fs::write(&p, b"fixture").unwrap();         let mut d = json!({"clock":{"finishTime":"2026-10-10T01:00:00Z","deliveredTime":"2026-10-10T02:00:00Z"},"delivery":{"at":"2026-10-10T02:00:00Z","video":p}});         assert_eq!(assess(&d, &[], None)["mayStop"], true);
crates/adom-aiflow/src/copper_carry.rs+1−1
@@ -531,7 +531,7 @@ mod tests {     }      fn tmp(name: &str) -> std::path::PathBuf {-        let d = std::env::temp_dir().join(format!("aiflow-copper-carry-{name}-{}", std::process::id()));+        let d = aiflow_sys::temp_dir().join(format!("aiflow-copper-carry-{name}-{}", aiflow_sys::process::id()));         let _ = std::fs::remove_dir_all(&d);         std::fs::create_dir_all(&d).unwrap();         d
crates/adom-aiflow/src/dashboard.rs+7−7
@@ -25,7 +25,7 @@ pub const DOCK_TAB: &str = "AI Flow"; const IDLE_REUSE_SECS: u64 = 12 * 3600;  pub fn run_id(dir: &Path) -> String {-    let path = fs::canonicalize(dir).unwrap_or_else(|_| dir.to_path_buf());+    let path = aiflow_sys::canonicalize(dir).unwrap_or_else(|_| dir.to_path_buf());     let mut hash = 0xcbf29ce484222325u64;     for b in path.to_string_lossy().bytes() {         hash = (hash ^ b as u64).wrapping_mul(0x100000001b3);@@ -36,9 +36,9 @@ pub fn run_id(dir: &Path) -> String { fn command(args: &[&str], seconds: u64) -> Result<Value, String> {     // Files avoid a full pipe deadlocking a bounded child. No shell interpolation.     static N: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);-    let path = std::env::temp_dir().join(format!(+    let path = aiflow_sys::temp_dir().join(format!(         "aiflow-dashboard-{}-{}.json",-        std::process::id(),+        aiflow_sys::process::id(),         N.fetch_add(1, std::sync::atomic::Ordering::Relaxed)     ));     let f = fs::File::create(&path).map_err(|e| e.to_string())?;@@ -259,7 +259,7 @@ pub fn load_registry(path: &Path) -> Vec<Value> {  fn save_registry(path: &Path, entries: &[Value]) -> Result<(), String> {     if let Some(d) = path.parent() { fs::create_dir_all(d).map_err(|e| e.to_string())?; }-    let tmp = path.with_extension(format!("tmp{}", std::process::id()));+    let tmp = path.with_extension(format!("tmp{}", aiflow_sys::process::id()));     fs::write(&tmp, serde_json::to_vec_pretty(&json!({"schemaVersion": 1, "dashboards": entries})).unwrap()).map_err(|e| e.to_string())?;     fs::rename(&tmp, path).map_err(|e| e.to_string()) }@@ -280,7 +280,7 @@ pub struct Facts { }  pub fn facts(dir: &Path) -> Option<Facts> {-    let dir = fs::canonicalize(dir).ok()?;+    let dir = aiflow_sys::canonicalize(dir).ok()?;     let r = aiflow_run::Run::open(&dir)?;     let d = &r.data;     Some(Facts {@@ -443,7 +443,7 @@ fn start_server(dir: &Path, tdir: &Path, id: &str, requested: Option<u16>, saved /// already has an unfinished run on screen, or for a board another thread is driving, without /// `--new-tab --why`; reuses a finished run's tab in place; renames an old `AI Flow ยท <hex>` tab. pub fn ensure(dir: &Path, ai_thread: &str, requested_port: Option<u16>, force_show: bool, opts: &OpenOpts) -> Result<Shown, String> {-    let dir = fs::canonicalize(dir).map_err(|e| e.to_string())?;+    let dir = aiflow_sys::canonicalize(dir).map_err(|e| e.to_string())?;     let tdir = dir.join("timeline");     fs::create_dir_all(&tdir).map_err(|e| e.to_string())?;     let lock = dir.join("dashboard.lock");@@ -715,7 +715,7 @@ pub fn close(sel: &Close) -> Result<(Vec<String>, Vec<String>), String> {                 // a tab this run recorded before the registry existed                 let cfg: Value = fs::read(d.join("dashboard.json")).ok().and_then(|b| serde_json::from_slice(&b).ok()).unwrap_or(Value::Null);                 if let Some(n) = cfg["name"].as_str() {-                    let dir = fs::canonicalize(d).unwrap_or_else(|_| d.clone());+                    let dir = aiflow_sys::canonicalize(d).unwrap_or_else(|_| d.clone());                     v.push(json!({"name": n, "runId": id, "runDir": dir.display().to_string(), "port": cfg["port"]}));                 }             }
crates/adom-aiflow/src/decoupling_check.rs+1−1
@@ -283,7 +283,7 @@ mod tests {      #[test]     fn a_planned_pour_ground_return_is_unverified() {-        let dir = std::env::temp_dir().join(format!("aiflow-dec-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-dec-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let pours = dir.join("plan-pours.json");         std::fs::write(&pours, r#"{"zones": [{"net": "GND"}]}"#).unwrap();
crates/adom-aiflow/src/embedded_models.rs+1−1
@@ -133,7 +133,7 @@ mod tests {         assert!(e.present("R1", "kicad-embed://board-level.step"), "the board's own embedded files");         assert!(!e.present("D1", "kicad-embed://other.step"));         assert!(!e.present("D1", "${KICAD9_3DMODEL_DIR}/x.step"));-        let dir = std::env::temp_dir().join(format!("aiflow-emb-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-emb-{}", aiflow_sys::process::id()));         let f = e.extract("D1", "kicad-embed://led.step", &dir).unwrap();         assert_eq!(std::fs::read_to_string(&f).unwrap(), step, "zstd frame decoded");         let raw = e.extract("R1", "kicad-embed://board-level.step", &dir).unwrap();
crates/adom-aiflow/src/export.rs+4−4
@@ -379,7 +379,7 @@ fn read_dir(dir: &Path, exts: &[&str]) -> Vec<(String, String)> { }  fn kicad(cli: &str, args: &[String]) -> Result<(), String> {-    let o = std::process::Command::new(cli).args(args).output().map_err(|e| format!("{cli} is not runnable: {e}"))?;+    let o = aiflow_sys::process::Command::new(cli).args(args).output().map_err(|e| format!("{cli} is not runnable: {e}"))?;     if o.status.success() { return Ok(()); }     let tail = |b: &[u8]| aiflow_run::clip_text(&String::from_utf8_lossy(b), 400);     Err(format!("{cli} {} failed: {} {}", args[..3.min(args.len())].join(" "), tail(&o.stdout), tail(&o.stderr)))@@ -457,8 +457,8 @@ pub fn order_files(board_path: &str, stem: &str, profile: Option<&str>, sourcing fn saved_drc(cli: &str, board_path: &str, out: &Path) -> Result<Value, String> {     let report = out.join("drc-saved-fills.json");     let _ = std::fs::remove_file(&report);-    let o = std::process::Command::new(cli).args(["pcb", "drc", "--format", "json", "--output"]).arg(&report).arg(board_path)-        .stdin(std::process::Stdio::null()).output().map_err(|e| format!("{cli} is not runnable: {e}"))?;+    let o = aiflow_sys::process::Command::new(cli).args(["pcb", "drc", "--format", "json", "--output"]).arg(&report).arg(board_path)+        .stdin(aiflow_sys::process::Stdio::null()).output().map_err(|e| format!("{cli} is not runnable: {e}"))?;     let text = std::fs::read_to_string(&report).map_err(|_| {         let tail = |b: &[u8]| aiflow_run::clip_text(&String::from_utf8_lossy(b), 300);         format!("{cli} pcb drc wrote no report: {} {}", tail(&o.stdout), tail(&o.stderr))@@ -725,7 +725,7 @@ mod tests {     #[test]     fn export_runs_kicad_cli_and_refuses_a_set_that_does_not_match() {         use std::os::unix::fs::PermissionsExt;-        let dir = std::env::temp_dir().join(format!("aiflow-export-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-export-{}", aiflow_sys::process::id()));         let _ = std::fs::remove_dir_all(&dir);         std::fs::create_dir_all(&dir).unwrap();         let board = dir.join("demo.kicad_pcb");
crates/adom-aiflow/src/fields_review.rs+1−1
@@ -419,7 +419,7 @@ pub fn run_fields_report(fields_dir: &Path, out_md: &Path) -> Result<(Value, Vec     if let Some(parent) = out_md.parent() {         let _ = std::fs::create_dir_all(parent);     }-    let st = std::process::Command::new("adom-fields")+    let st = aiflow_sys::process::Command::new("adom-fields")         .args(["report", "--fields", &fields_dir.display().to_string(), "--out", &out_md.display().to_string()])         .output()         .map_err(|e| format!("could not run adom-fields report: {e}"))?;
crates/adom-aiflow/src/fields_versions.rs+4−4
@@ -167,7 +167,7 @@ mod tests {     use serde_json::json;      fn tmp(name: &str, text: &str) -> std::path::PathBuf {-        let d = std::env::temp_dir().join(format!("aiflow-fields-versions-{}", std::process::id()));+        let d = aiflow_sys::temp_dir().join(format!("aiflow-fields-versions-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&d).unwrap();         let p = d.join(name);         std::fs::write(&p, text).unwrap();@@ -225,7 +225,7 @@ mod tests {         let t = r#"(kicad_pcb (layers (0 "F.Cu" signal) (31 "B.Cu" signal))   (footprint "Q" (layer "F.Cu") (at 5 5) (property "Reference" "Q1") (pad "1" smd rect (at 0 0) (size 1 1) (layers "F.Cu") (net "/SW")) (pad "2" smd rect (at 2 0) (size 3 3) (layers "F.Cu") (net "/GND")))   (gr_rect (start 0 0) (end 20 20) (layer "Edge.Cuts")))"#;-        let d = std::env::temp_dir().join(format!("aiflow-fv-{}", std::process::id()));+        let d = aiflow_sys::temp_dir().join(format!("aiflow-fv-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&d).unwrap();         let p = d.join("b.kicad_pcb");         std::fs::write(&p, t).unwrap();@@ -271,7 +271,7 @@ mod tests {      fn tempfile_dir() -> std::path::PathBuf {         // its own folder: the 0.10.12 test above writes into aiflow-fv-<pid>, and this one removes its folder at the end-        let d = std::env::temp_dir().join(format!("aiflow-fv-shaped-{}", std::process::id()));+        let d = aiflow_sys::temp_dir().join(format!("aiflow-fv-shaped-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&d).unwrap();         d     }@@ -280,7 +280,7 @@ mod tests {     /// adom-fields 0.10.15: a hot SMD part on the bottom side, solved before it, is told to solve again; one on top is not.     #[test]     fn a_bottom_hot_part_solved_before_0_10_15_is_told_to_solve_again() {-        let dir = std::env::temp_dir().join(format!("aiflow-fv-bottom-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-fv-bottom-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let p = dir.join("b.kicad_pcb");         std::fs::write(&p, r#"(kicad_pcb (layers (0 "F.Cu" signal) (2 "B.Cu" signal) (25 "Edge.Cuts" user)) (gr_rect (start 0 0) (end 20 20) (layer "Edge.Cuts"))
crates/adom-aiflow/src/giveback_policy.rs+1−1
@@ -36,7 +36,7 @@ mod tests {      #[test]     fn automatic_unless_the_user_says_otherwise() {-        let d = std::env::temp_dir().join(format!("aiflow-giveback-{}", std::process::id()));+        let d = aiflow_sys::temp_dir().join(format!("aiflow-giveback-{}", aiflow_sys::process::id()));         std::env::set_var("AIFLOW_HOME", &d);         std::env::remove_var("AIFLOW_GIVEBACK");         assert_eq!(mode(), Mode::Auto, "no choice saved: automatic");
crates/adom-aiflow/src/handson.rs+2−2
@@ -399,7 +399,7 @@ pub fn notify(data: &Value, ai_thread: &str, title: &str, body: &str) -> String     let how = hands(data)["notify"].as_str().unwrap_or("hydrogen");     let mut sent = Vec::new();     let run = |prog: &str, args: Vec<String>| -> bool {-        let Ok(mut c) = std::process::Command::new(prog).args(&args).stdin(std::process::Stdio::null()).stdout(std::process::Stdio::null()).stderr(std::process::Stdio::null()).spawn() else { return false };+        let Ok(mut c) = aiflow_sys::process::Command::new(prog).args(&args).stdin(aiflow_sys::process::Stdio::null()).stdout(aiflow_sys::process::Stdio::null()).stderr(aiflow_sys::process::Stdio::null()).spawn() else { return false };         let t = std::time::Instant::now();         while t.elapsed() < std::time::Duration::from_secs(8) { if let Ok(Some(s)) = c.try_wait() { return s.success(); } std::thread::sleep(std::time::Duration::from_millis(100)); }         true // still running: the notification is on its way@@ -492,7 +492,7 @@ mod tests {     }     #[test]     fn profiles_and_the_timeline_inbox() {-        let tmp = std::env::temp_dir().join(format!("aiflow-handson-{}", std::process::id()));+        let tmp = aiflow_sys::temp_dir().join(format!("aiflow-handson-{}", aiflow_sys::process::id()));         let _ = std::fs::remove_dir_all(&tmp);         std::env::set_var("AIFLOW_PREFS_DIR", tmp.join("prefs"));         let tl = tmp.join("timeline");
crates/adom-aiflow/src/led_states.rs+2−2
@@ -194,7 +194,7 @@ mod tests {      #[test]     fn leds_need_complete_states_beside_the_board() {-        let dir = std::env::temp_dir().join(format!("aiflow-led-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-led-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let bp = dir.join("b.kicad_pcb").display().to_string();         let b = Board::from_text(&bp, BOARD.to_string()).unwrap();@@ -239,7 +239,7 @@ mod tests {     #[test]     fn a_declared_rgb_part_is_checked_die_by_die() {         // issue #122: D1 on a project footprint named by its MPN, common anode, three cathodes-        let dir = std::env::temp_dir().join(format!("aiflow-rgb-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-rgb-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let bp = dir.join("b.kicad_pcb").display().to_string();         let b = Board::from_text(&bp, r#"(kicad_pcb (version 20241229)
crates/adom-aiflow/src/library_review.rs+1−1
@@ -30,7 +30,7 @@ mod tests {  use super::*;use serde_json::json;  #[test]  fn pending_or_changed_library_evidence_is_refused(){-  let d=std::env::temp_dir().join(format!("aiflow-library-review-{}",std::process::id()));std::fs::create_dir_all(&d).unwrap();+  let d=aiflow_sys::temp_dir().join(format!("aiflow-library-review-{}",aiflow_sys::process::id()));std::fs::create_dir_all(&d).unwrap();   for n in ["board","clip","readback","screenshot","step","glb"]{std::fs::write(d.join(n),n).unwrap();}   let item=|n:&str|json!({"file":n,"sha256":hash(&d.join(n)).unwrap()});   let selection=json!({"mpnMarking":"on","components":[{"mpn":"fixture","selectedModel":{"variant":"mpn","step":"step","stepSha256":hash(&d.join("step")).unwrap(),"glb":"glb","glbSha256":hash(&d.join("glb")).unwrap()}}]});
crates/adom-aiflow/src/main.rs+161−158
@@ -740,9 +740,9 @@ fn wiki_component_page(mpn: &str) -> Result<Option<(String, Value)>, String> {  /// Runs a program once (no retry, stdin closed) for at most `secs` seconds: (exited 0, stdout, stderr). fn command_once(program: &str, args: &[&str], secs: u64) -> Result<(bool, String, String), String> {-    use std::process::{Command, Stdio};+    use aiflow_sys::process::{Command, Stdio};     let tag: String = args.iter().flat_map(|a| a.chars()).filter(|c| c.is_ascii_alphanumeric()).take(40).collect();-    let tmp = std::env::temp_dir().join(format!("aiflow-{program}-{}-{tag}", std::process::id()));+    let tmp = aiflow_sys::temp_dir().join(format!("aiflow-{program}-{}-{tag}", aiflow_sys::process::id()));     let (out_p, err_p) = (tmp.with_extension("out"), tmp.with_extension("err"));     let f = std::fs::File::create(&out_p).map_err(|e| e.to_string())?;     let g = std::fs::File::create(&err_p).map_err(|e| e.to_string())?;@@ -1010,7 +1010,7 @@ fn publish_clips(r: &Run, dir: &Path, page: &str, page_dir: Option<&str>, push:     // so a second run never overwrites the first run's clips.     let id = r.data["reportId"].as_str().map(str::to_string).unwrap_or_else(|| report_id(r));     let marker = format!("<!-- aiflow-clips-run: {id} -->");-    let remote = std::process::Command::new("adom-wiki").args(["repo", "show", page, &index_doc]).output().ok()+    let remote = aiflow_sys::process::Command::new("adom-wiki").args(["repo", "show", page, &index_doc]).output().ok()         .filter(|o| o.status.success()).map(|o| String::from_utf8_lossy(&o.stdout).to_string()).filter(|t| t.trim_start().starts_with('#') || t.contains("aiflow-clips-run"));     let owner = match &remote { None => true, Some(t) => t.contains(&marker) };     let doc = if owner { index_doc.clone() } else { pagedir::join(page_dir, &format!("docs/clips-{id}.md")) };@@ -1062,7 +1062,7 @@ fn publish_clips(r: &Run, dir: &Path, page: &str, page_dir: Option<&str>, push:     }     let (mut pushed, mut failed) = (0usize, Vec::new());     for batch in batches.iter().filter(|b| !b.is_empty()) {-        let mut cmd = std::process::Command::new("adom-wiki");+        let mut cmd = aiflow_sys::process::Command::new("adom-wiki");         cmd.current_dir(&stage).args(["repo", "push", page, "-m", &format!("clips: {clips} clip(s), {}", r.data["currentStep"].as_str().unwrap_or("update")), "--files"]);         for f in batch { cmd.arg(&f.0); }         match cmd.output() {@@ -1095,7 +1095,7 @@ fn auto_capture_off() -> bool {  /// The user's primary machine (`adom-bridge targets` names it). fn primary_machine() -> Option<String> {-    let o = std::process::Command::new("adom-bridge").arg("targets").output().ok()?;+    let o = aiflow_sys::process::Command::new("adom-bridge").arg("targets").output().ok()?;     preboard::primary_from_targets(&serde_json::from_slice::<Value>(&o.stdout).ok()?) } @@ -1106,11 +1106,11 @@ fn primary_machine() -> Option<String> { fn container_host() -> Option<String> {     if std::env::var("ADOM_DESKTOP_MODE").ok().as_deref() != Some("local") { return None; }     let linux = std::fs::read_to_string("/proc/sys/kernel/hostname").ok().map(|h| h.trim().to_string()).filter(|h| !h.is_empty());-    let targets = std::process::Command::new("adom-bridge").arg("targets").output().ok().and_then(|o| serde_json::from_slice::<Value>(&o.stdout).ok());+    let targets = aiflow_sys::process::Command::new("adom-bridge").arg("targets").output().ok().and_then(|o| serde_json::from_slice::<Value>(&o.stdout).ok());     let Some(t) = targets.filter(|t| t["targets"].is_array()) else { return linux };     let mut cands: Vec<String> = linux.clone().into_iter().collect();     if let Some(h) = host_machine::pick(&cands, &t) { return Some(h); }-    if let Ok(o) = std::process::Command::new("timeout").args(["5", "/mnt/c/Windows/System32/hostname.exe"]).output() {+    if let Ok(o) = aiflow_sys::process::Command::new("timeout").args(["5", "/mnt/c/Windows/System32/hostname.exe"]).output() {         let w = String::from_utf8_lossy(&o.stdout).trim().to_string();         if !w.is_empty() { cands.push(w); }     }@@ -1128,7 +1128,7 @@ fn screen_mode(r: &mut Run) -> screen::Mode {     let own = prev["ownMachine"].as_bool().filter(|_| prev["target"].as_str() == Some(target.as_str())).unwrap_or_else(|| {         let local = std::env::var("ADOM_DESKTOP_MODE").ok().as_deref() == Some("local") || std::env::var("HOME").map(|h| Path::new(&h).join(".adom/hd-control-url").is_file()).unwrap_or(false);         let host = local.then(|| std::fs::read_to_string("/proc/sys/kernel/hostname").ok()).flatten().map(|h| h.trim().to_string());-        let targets = std::process::Command::new("adom-bridge").arg("targets").output().ok().and_then(|o| serde_json::from_slice::<Value>(&o.stdout).ok());+        let targets = aiflow_sys::process::Command::new("adom-bridge").arg("targets").output().ok().and_then(|o| serde_json::from_slice::<Value>(&o.stdout).ok());         screen::own_machine(&target, local, host.as_deref(), targets.as_ref())     });     let spec = r.data["spec"].as_str().and_then(|p| std::fs::read_to_string(p).ok()).and_then(|t| serde_json::from_str::<Value>(&t).ok()).unwrap_or(Value::Null);@@ -1244,7 +1244,7 @@ fn step_table(r: &Run) -> String {  /// Free megabytes on the drive holding the run directory. fn local_free_mb(dir: &Path) -> Option<u64> {-    let out = std::process::Command::new("df").args(["-Pk", dir.to_str().unwrap_or(".")]).output().ok()?;+    let out = aiflow_sys::process::Command::new("df").args(["-Pk", dir.to_str().unwrap_or(".")]).output().ok()?;     let text = String::from_utf8_lossy(&out.stdout);     let line = text.lines().last()?;     line.split_whitespace().nth(3)?.parse::<u64>().ok().map(|k| k / 1024)@@ -1307,7 +1307,7 @@ fn usage_snapshot(agy: Option<&Value>) -> Vec<Value> {     }     let home = std::env::var("HOME").unwrap_or_default();     let curl = |url: &str, headers: &[String]| -> Option<Value> {-        let mut c = std::process::Command::new("curl");+        let mut c = aiflow_sys::process::Command::new("curl");         c.args(["-s", "-m", "12", url]);         for h in headers { c.args(["-H", h]); }         let o = c.output().ok()?;@@ -1363,7 +1363,7 @@ fn usage_snapshot(agy: Option<&Value>) -> Vec<Value> { fn agy_usage() -> Option<Value> {     let home = std::env::var("HOME").unwrap_or_default();     if !Path::new(&format!("{home}/.gemini/antigravity")).is_dir() { return None; }-    let o = std::process::Command::new("python3").arg("-c").arg(include_str!("../../../tools/agy-usage.py")).output().ok()?;+    let o = aiflow_sys::process::Command::new("python3").arg("-c").arg(include_str!("../../../tools/agy-usage.py")).output().ok()?;     let v: Value = serde_json::from_slice(&o.stdout).ok()?;     if v["tokens"]["calls"].as_u64().unwrap_or(0) == 0 && v["quota"].as_array().map_or(true, |q| q.is_empty()) { return None; }     Some(v)@@ -1577,8 +1577,8 @@ fn tour_record_start(r: &mut Run, br: &Bridge, hwnd: i64, why: &str, max_ms: u64  /// Run a child to completion or kill it at `limit`: Ok(success) when it ended, Err(why) when it could not /// start or ran out of time (issue #180: every take a tour films has a stop condition of its own).-fn run_bounded(cmd: &mut std::process::Command, limit: std::time::Duration) -> Result<bool, String> {-    let mut child = cmd.stdin(std::process::Stdio::null()).stdout(std::process::Stdio::null()).stderr(std::process::Stdio::null()).spawn().map_err(|e| format!("could not start: {e}"))?;+fn run_bounded(cmd: &mut aiflow_sys::process::Command, limit: std::time::Duration) -> Result<bool, String> {+    let mut child = cmd.stdin(aiflow_sys::process::Stdio::null()).stdout(aiflow_sys::process::Stdio::null()).stderr(aiflow_sys::process::Stdio::null()).spawn().map_err(|e| format!("could not start: {e}"))?;     let t0 = std::time::Instant::now();     loop {         match child.try_wait() {@@ -1644,7 +1644,7 @@ fn clip_stop_event(mut ev: Value, stop: &ClipStop) -> Value { const RETRY_GIVE_UP_AFTER: usize = 3;  fn repull_failed_clips(r: &mut Run, br: &Bridge, dir: &Path) -> (usize, usize) {-    let save_to = std::fs::canonicalize(dir).unwrap_or(dir.to_path_buf()).display().to_string();+    let save_to = aiflow_sys::canonicalize(dir).unwrap_or(dir.to_path_buf()).display().to_string();     let mut by_rid: std::collections::HashMap<String, String> = Default::default();     for e in &r.ledger() {         if e["event"] == "clip-stop" {@@ -1732,7 +1732,7 @@ fn stop_running_clip(r: &mut Run, br: &Bridge, dir: &Path, why: &str) -> Option<     let caps = r.data["captures"].as_array().cloned().unwrap_or_default();     let pos = caps.iter().rposition(|c| c.get("recordingId").is_some() && c.get("file").is_none())?;     let rid = caps[pos]["recordingId"].as_str()?.to_string();-    let save_to = std::fs::canonicalize(dir).unwrap_or(dir.to_path_buf()).display().to_string();+    let save_to = aiflow_sys::canonicalize(dir).unwrap_or(dir.to_path_buf()).display().to_string();     let stop = br.record_stop(&rid, &save_to);     let local = settle_clip_stop(r, pos, &stop, dir);     let cap = &mut r.data["captures"][pos];@@ -1755,7 +1755,7 @@ const MEDIA_TOOLS: &[&str] = &["ffprobe", "ffmpeg"]; /// black unpainted canvas gives one or two; a rendered board gives dozens. fn screenshot_distinct_colors(path: &str) -> Option<u64> {     if path.is_empty() || !std::path::Path::new(path).exists() { return None; }-    let out = std::process::Command::new("ffmpeg").args(["-v", "error", "-i", path, "-frames:v", "1", "-vf", "crop=iw*0.6:ih*0.6,scale=96:54", "-f", "rawvideo", "-pix_fmt", "rgb24", "-"]).output().ok()?;+    let out = aiflow_sys::process::Command::new("ffmpeg").args(["-v", "error", "-i", path, "-frames:v", "1", "-vf", "crop=iw*0.6:ih*0.6,scale=96:54", "-f", "rawvideo", "-pix_fmt", "rgb24", "-"]).output().ok()?;     if !out.status.success() || out.stdout.len() < 3 { return None; }     let set: std::collections::BTreeSet<u16> = out.stdout.chunks(3).map(|p| ((p[0] as u16 >> 4) << 8) | ((p[1] as u16 >> 4) << 4) | (p[2] as u16 >> 4)).collect();     Some(set.len() as u64)@@ -1765,7 +1765,7 @@ fn screenshot_distinct_colors(path: &str) -> Option<u64> { /// Err names the first tool of `tools` that cannot be started. fn media_tools_missing(tools: &[&str]) -> Result<(), String> {     for t in tools {-        if let Err(e) = std::process::Command::new(t).arg("-version").stdout(std::process::Stdio::null()).stderr(std::process::Stdio::null()).status() {+        if let Err(e) = aiflow_sys::process::Command::new(t).arg("-version").stdout(aiflow_sys::process::Stdio::null()).stderr(aiflow_sys::process::Stdio::null()).status() {             return Err(format!("{t} is not installed or not runnable ({e}); the clips cannot be checked, cut or composed without it"));         }     }@@ -1834,12 +1834,12 @@ fn blank_check_verdict(why: &str) -> bool { /// head) still gives its painted frames, and a multi-GB clip is decoded once, not once per seek. fn sample_frames(file: &str, secs: f64, n: usize, w: usize, h: usize) -> Vec<Vec<u8>> {     let vf = format!("fps={:.6}:start_time={:.6}:round=down,crop=iw*0.6:ih*0.6,scale={w}:{h}", n as f64 / secs, secs / (2.0 * n as f64));-    let out = std::process::Command::new("ffmpeg").args(["-v", "error", "-i", file, "-an", "-vf", &vf, "-frames:v", &n.to_string(), "-f", "rawvideo", "-pix_fmt", "gray", "-"]).output();+    let out = aiflow_sys::process::Command::new("ffmpeg").args(["-v", "error", "-i", file, "-an", "-vf", &vf, "-frames:v", &n.to_string(), "-f", "rawvideo", "-pix_fmt", "gray", "-"]).output();     let px = out.map(|o| o.stdout).unwrap_or_default();     let mut frames: Vec<Vec<u8>> = px.chunks_exact(w * h).map(|c| c.to_vec()).collect();     // a clip shorter than the first sample point (its only frames at the head): decode it from its start     if frames.is_empty() {-        let out = std::process::Command::new("ffmpeg").args(["-v", "error", "-i", file, "-an", "-vf", &format!("crop=iw*0.6:ih*0.6,scale={w}:{h}"), "-frames:v", &n.to_string(), "-f", "rawvideo", "-pix_fmt", "gray", "-"]).output();+        let out = aiflow_sys::process::Command::new("ffmpeg").args(["-v", "error", "-i", file, "-an", "-vf", &format!("crop=iw*0.6:ih*0.6,scale={w}:{h}"), "-frames:v", &n.to_string(), "-f", "rawvideo", "-pix_fmt", "gray", "-"]).output();         frames = out.map(|o| o.stdout).unwrap_or_default().chunks_exact(w * h).map(|c| c.to_vec()).collect();     }     frames@@ -1933,12 +1933,12 @@ mod blank_check_tests {     /// The whole check on real video: a dark canvas with a thin band stays unflagged, a flat one is flagged.     #[test]     fn a_long_thin_board_clip_is_not_blank() {-        if std::process::Command::new("ffmpeg").arg("-version").output().is_err() { return; }-        let dir = std::env::temp_dir().join(format!("aiflow-blank-{}", std::process::id()));+        if aiflow_sys::process::Command::new("ffmpeg").arg("-version").output().is_err() { return; }+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-blank-{}", aiflow_sys::process::id()));         let _ = std::fs::create_dir_all(&dir);         let make = |name: &str, vf: &str| {             let f = dir.join(name).display().to_string();-            let ok = std::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-f", "lavfi", "-i", "color=c=0x001023:s=1280x720:d=4:r=5", "-vf", vf, "-pix_fmt", "yuv420p", &f]).status().map(|s| s.success()).unwrap_or(false);+            let ok = aiflow_sys::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-f", "lavfi", "-i", "color=c=0x001023:s=1280x720:d=4:r=5", "-vf", vf, "-pix_fmt", "yuv420p", &f]).status().map(|s| s.success()).unwrap_or(false);             ok.then_some(f)         };         let (Some(strip), Some(flat)) = (make("strip.mp4", "drawbox=x=20:y=350:w=1240:h=18:color=0xC83737:t=fill,drawbox=x=20:y=344:w=1240:h=2:color=0xD0D000:t=fill"), make("flat.mp4", "null")) else { return };@@ -1956,13 +1956,13 @@ fn contact_sheet(file: &str) -> Option<String> {     if secs <= 0.0 { return None; }     let out = format!("{}-sheet.png", file.trim_end_matches(".mp4"));     let fps = 9.0 / secs;-    let ok = std::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-i", file, "-vf", &format!("fps={fps:.6},scale=426:-2,tile=3x3:padding=4:margin=4:color=0x0B1420"), "-frames:v", "1", &out]).status().map(|s| s.success()).unwrap_or(false);+    let ok = aiflow_sys::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-i", file, "-vf", &format!("fps={fps:.6},scale=426:-2,tile=3x3:padding=4:margin=4:color=0x0B1420"), "-frames:v", "1", &out]).status().map(|s| s.success()).unwrap_or(false);     if ok && Path::new(&out).is_file() { Some(out) } else { None } }  /// Seconds of pure black at the head of a clip (the recorder started before the window painted), up to five. fn leading_black(file: &str) -> f64 {-    let out = std::process::Command::new("ffmpeg").args(["-v", "info", "-t", "6", "-i", file, "-an", "-vf", "blackdetect=d=0.05:pic_th=0.98:pix_th=0.10", "-f", "null", "-"]).output();+    let out = aiflow_sys::process::Command::new("ffmpeg").args(["-v", "info", "-t", "6", "-i", file, "-an", "-vf", "blackdetect=d=0.05:pic_th=0.98:pix_th=0.10", "-f", "null", "-"]).output();     let Ok(o) = out else { return 0.0 };     let text = String::from_utf8_lossy(&o.stderr);     for line in text.lines() {@@ -1979,7 +1979,7 @@ fn leading_black(file: &str) -> f64 {  /// The clip's seconds, from ffprobe (0.0 when unknown). fn media_seconds(path: &str) -> f64 {-    std::process::Command::new("ffprobe").args(["-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", path]).output().ok().and_then(|o| String::from_utf8_lossy(&o.stdout).trim().parse::<f64>().ok()).unwrap_or(0.0)+    aiflow_sys::process::Command::new("ffprobe").args(["-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", path]).output().ok().and_then(|o| String::from_utf8_lossy(&o.stdout).trim().parse::<f64>().ok()).unwrap_or(0.0) }  /// Cut a sped-up copy of a pulled clip next to it (`<name>-10x.mp4`) and record both as artifacts@@ -2038,9 +2038,9 @@ fn media_worker_spawn(dir: &Path) -> bool {     if media_worker_alive(dir) { return true; }     let Ok(exe) = std::env::current_exe() else { return false };     let log = std::fs::OpenOptions::new().create(true).append(true).open(media_dir(dir).join("worker.log")).ok();-    let mut c = std::process::Command::new(exe);-    c.arg("--run").arg(dir).arg("media-worker").env("AIFLOW_DASHBOARD", "off").stdin(std::process::Stdio::null()).stdout(std::process::Stdio::null());-    match log { Some(f) => { c.stderr(f); } None => { c.stderr(std::process::Stdio::null()); } }+    let mut c = aiflow_sys::process::Command::new(exe);+    c.arg("--run").arg(dir).arg("media-worker").env("AIFLOW_DASHBOARD", "off").stdin(aiflow_sys::process::Stdio::null()).stdout(aiflow_sys::process::Stdio::null());+    match log { Some(f) => { c.stderr(f); } None => { c.stderr(aiflow_sys::process::Stdio::null()); } }     c.spawn().is_ok() } @@ -2064,7 +2064,7 @@ fn media_worker_run(dir: &Path) {     let md = media_dir(dir);     for sub in ["queue", "work", "done"] { let _ = std::fs::create_dir_all(md.join(sub)); }     let lock = md.join("worker.lock");-    let take = || std::fs::OpenOptions::new().write(true).create_new(true).open(&lock).map(|mut f| { use std::io::Write; let _ = f.write_all(json!({"pid": std::process::id(), "at": now()}).to_string().as_bytes()); });+    let take = || std::fs::OpenOptions::new().write(true).create_new(true).open(&lock).map(|mut f| { use std::io::Write; let _ = f.write_all(json!({"pid": aiflow_sys::process::id(), "at": now()}).to_string().as_bytes()); });     if take().is_err() {         if media_worker_alive(dir) { return; }         let _ = std::fs::remove_file(&lock);@@ -2080,7 +2080,7 @@ fn media_worker_run(dir: &Path) {             let Some(name) = j.file_name().map(|n| n.to_owned()) else { continue };             let work = md.join("work").join(&name);             if std::fs::rename(&j, &work).is_err() { continue; }-            let _ = std::fs::write(&lock, json!({"pid": std::process::id(), "at": now(), "job": name.to_string_lossy()}).to_string());+            let _ = std::fs::write(&lock, json!({"pid": aiflow_sys::process::id(), "at": now(), "job": name.to_string_lossy()}).to_string());             let out = media_job(dir, &work);             let done = md.join("done").join(&name);             let tmp = done.with_extension("tmp");@@ -2263,7 +2263,7 @@ fn clip_artifacts_with(r: &mut Run, step: &Value, file: &str, speed: u32, tools:     // of both cuts (never more than five seconds; longer black is a real clip problem, kept)     let lead = leading_black(file);     let ss = format!("{lead:.3}");-    let cut = std::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-ss", &ss, "-i", file, "-an", "-vf", &format!("setpts=PTS/{speed},{CUT_SCALE}"), "-r", "30", "-c:v", "libx264", "-preset", "veryfast", "-crf", "20", &out]).status().map(|s| s.success()).unwrap_or(false);+    let cut = aiflow_sys::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-ss", &ss, "-i", file, "-an", "-vf", &format!("setpts=PTS/{speed},{CUT_SCALE}"), "-r", "30", "-c:v", "libx264", "-preset", "veryfast", "-crf", "20", &out]).status().map(|s| s.success()).unwrap_or(false);     if lead > 0.0 { r.log("marker", json!({"label": format!("clip {tag}: {lead:.2} s of black recorder startup cut off the head of its cuts")})); }     if cut {         let fast = media_seconds(&out);@@ -2276,7 +2276,7 @@ fn clip_artifacts_with(r: &mut Run, step: &Value, file: &str, speed: u32, tools:         // the action cut stays RAW (no captions): the final video draws its own overlays from the         // ledger, and a side-by-side of two runs must not paint overlays over overlays         let vf = format!("setpts=PTS*{speed},{DROP_BLACK},mpdecimate=hi=64*12:lo=64*5:frac=0.33,setpts=N/4/TB");-        let ok_action = std::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-i", &out, "-an", "-vf", &vf, "-r", "30", "-c:v", "libx264", "-preset", "veryfast", "-crf", "20", &action]).status().map(|s| s.success()).unwrap_or(false);+        let ok_action = aiflow_sys::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-i", &out, "-an", "-vf", &vf, "-r", "30", "-c:v", "libx264", "-preset", "veryfast", "-crf", "20", &action]).status().map(|s| s.success()).unwrap_or(false);         if ok_action {             let a = media_seconds(&action);             r.log("artifact", json!({"step": step, "kind": "clipAction", "file": action, "seconds": (a * 10.0).round() / 10.0, "realSeconds": (secs * 10.0).round() / 10.0}));@@ -2345,7 +2345,7 @@ fn narrate(workdir: &Path, idx: usize, tiers: &[String], vlen: f64, has_tts: boo         if n > vlen * 2.3 && !last { continue; }         let rate = if last && n > vlen * 2.3 { "+30%" } else { "+0%" };         let audio = workdir.join(format!("say-{idx}-{k}.mp3"));-        let ok = std::process::Command::new("adom-tts").args(["say", "--rate", rate, "--out", audio.to_str().unwrap(), words]).output().map(|o| o.status.success()).unwrap_or(false);+        let ok = aiflow_sys::process::Command::new("adom-tts").args(["say", "--rate", rate, "--out", audio.to_str().unwrap(), words]).output().map(|o| o.status.success()).unwrap_or(false);         if !ok { continue; }         let alen = media_seconds(audio.to_str().unwrap());         best = Some((audio, alen, words.clone()));@@ -2439,7 +2439,7 @@ fn compose_run(r: &mut Run, dir: &Path, outp: &Path, max_seconds: f64, still_sec     let workdir = dir.join("compose");     let _ = std::fs::remove_dir_all(&workdir);     let _ = std::fs::create_dir_all(&workdir);-    let has_tts = std::process::Command::new("adom-tts").arg("health").output().map(|o| o.status.success()).unwrap_or(false);+    let has_tts = aiflow_sys::process::Command::new("adom-tts").arg("health").output().map(|o| o.status.success()).unwrap_or(false);     let step_does = |step: &str| -> String { r.data["flow"]["steps"].as_array().and_then(|a| a.iter().find(|s| s["name"].as_str() == Some(step))).and_then(|s| s["does"].as_str()).unwrap_or("").to_string() };     let visit_start = |step: &str, visit: u64| -> u64 { caps.iter().find(|c| c["step"].as_str() == Some(step) && c["visit"].as_u64() == Some(visit)).and_then(|c| c["start"].as_str()).and_then(aiflow_run::parse).unwrap_or(0) };     let fit = "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:color=0x0B1420";@@ -2452,7 +2452,7 @@ fn compose_run(r: &mut Run, dir: &Path, outp: &Path, max_seconds: f64, still_sec             Piece::Library{file,caption,at,seconds}=>{                 let offset=r.active_offset(*at) as f64;                 let vf=format!("{},{fit}",overlay_filters(dir,"Component library",&engine_board,offset,0.0,run_has_hours));-                let good=ffmpeg_ok(std::process::Command::new("ffmpeg").args(["-v","error","-y","-i",file,"-t",&format!("{seconds:.3}"),"-vf",&vf,"-r","30","-an","-pix_fmt","yuv420p","-c:v","libx264","-preset","veryfast","-crf","20",seg.to_str().unwrap()]));+                let good=ffmpeg_ok(aiflow_sys::process::Command::new("ffmpeg").args(["-v","error","-y","-i",file,"-t",&format!("{seconds:.3}"),"-vf",&vf,"-r","30","-an","-pix_fmt","yuv420p","-c:v","libx264","-preset","veryfast","-crf","20",seg.to_str().unwrap()]));                 if !good{err("component overview failed to render", &["Check the reviewed clip, then compose again.".into()]);}                 n_clips+=1;(media_seconds(seg.to_str().unwrap()),vec![caption.clone(),"The reviewed component library.".into()])             }@@ -2465,7 +2465,7 @@ fn compose_run(r: &mut Run, dir: &Path, outp: &Path, max_seconds: f64, still_sec                 let offset = r.active_offset(cs) as f64;                 let title = format!("{}{}", step_shown(step), if visit > 1 { format!("   visit {visit}{}", if c["back"].as_bool() == Some(true) { "   rework" } else { "" }) } else { String::new() });                 let chain = format!("{},{fit}", overlay_chain(dir, &title, &engine_board, offset, run_has_hours, 10, rate));-                let okc = ffmpeg_ok(std::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-i", &fast, "-an", "-vf", &chain, "-r", "30", "-pix_fmt", "yuv420p", "-c:v", "libx264", "-preset", "veryfast", "-crf", "20", seg.to_str().unwrap()]));+                let okc = ffmpeg_ok(aiflow_sys::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-i", &fast, "-an", "-vf", &chain, "-r", "30", "-pix_fmt", "yuv420p", "-c:v", "libx264", "-preset", "veryfast", "-crf", "20", seg.to_str().unwrap()]));                 if !okc { eprintln!("segment {tag}: the overlay cut failed; skipped"); continue; }                 let vlen = media_seconds(seg.to_str().unwrap());                 if vlen < 0.5 { continue; }@@ -2488,7 +2488,7 @@ fn compose_run(r: &mut Run, dir: &Path, outp: &Path, max_seconds: f64, still_sec                 let title = format!("{}   ยท   the AI's drawing", step_shown(step));                 // the drawing is shown at the clips' scale so the overlays match, then fit to 1080p                 let vf = format!("{},{fit}", overlay_filters(dir, &title, &engine_board, offset, step_offset, run_has_hours));-                let oks = ffmpeg_ok(std::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-loop", "1", "-framerate", "4", "-t", &format!("{still_seconds:.2}"), "-i", file, "-vf", &vf, "-r", "30", "-pix_fmt", "yuv420p", "-an", "-c:v", "libx264", "-preset", "veryfast", "-crf", "20", seg.to_str().unwrap()]));+                let oks = ffmpeg_ok(aiflow_sys::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-loop", "1", "-framerate", "4", "-t", &format!("{still_seconds:.2}"), "-i", file, "-vf", &vf, "-r", "30", "-pix_fmt", "yuv420p", "-an", "-c:v", "libx264", "-preset", "veryfast", "-crf", "20", seg.to_str().unwrap()]));                 if !oks { eprintln!("still {file}: could not be rendered; skipped"); continue; }                 let vlen = media_seconds(seg.to_str().unwrap());                 n_stills_done += 1;@@ -2498,8 +2498,8 @@ fn compose_run(r: &mut Run, dir: &Path, outp: &Path, max_seconds: f64, still_sec         // the words are cut to the picture: the segment is exactly as long as its motion         let said = narrate(&workdir, k, &tiers, vlen, has_tts);         let oka = match &said {-            Some((audio, _, _)) => ffmpeg_ok(std::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-i", audio.to_str().unwrap(), "-af", &format!("apad,atrim=0:{vlen:.3}"), "-c:a", "aac", "-b:a", "128k", aseg.to_str().unwrap()])),-            None => ffmpeg_ok(std::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-f", "lavfi", "-i", "anullsrc=r=24000:cl=mono", "-t", &format!("{vlen:.3}"), "-c:a", "aac", "-b:a", "64k", aseg.to_str().unwrap()])),+            Some((audio, _, _)) => ffmpeg_ok(aiflow_sys::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-i", audio.to_str().unwrap(), "-af", &format!("apad,atrim=0:{vlen:.3}"), "-c:a", "aac", "-b:a", "128k", aseg.to_str().unwrap()])),+            None => ffmpeg_ok(aiflow_sys::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-f", "lavfi", "-i", "anullsrc=r=24000:cl=mono", "-t", &format!("{vlen:.3}"), "-c:a", "aac", "-b:a", "64k", aseg.to_str().unwrap()])),         };         if let Some((_, alen, words)) = &said { if *alen > vlen + 0.05 { eprintln!("segment {k}: the words ran {alen:.1} s for {vlen:.1} s of picture; cut at the picture: \"{words}\""); } }         if oka { parts.push((seg, aseg)); }@@ -2586,7 +2586,7 @@ fn drawings_by_step(r: &Run) -> std::collections::BTreeMap<String, Vec<(String, }  fn run_ffmpeg(args: &[&str]) -> bool {-    ffmpeg_ok(std::process::Command::new("ffmpeg").arg("-v").arg("error").arg("-y").args(args))+    ffmpeg_ok(aiflow_sys::process::Command::new("ffmpeg").arg("-v").arg("error").arg("-y").args(args)) }  thread_local! {@@ -2595,8 +2595,8 @@ thread_local! { }  /// Run an ffmpeg command with its stderr captured; on failure keep the stderr for `compose_error`.-fn ffmpeg_ok(cmd: &mut std::process::Command) -> bool {-    let failure = match cmd.stdout(std::process::Stdio::null()).output() {+fn ffmpeg_ok(cmd: &mut aiflow_sys::process::Command) -> bool {+    let failure = match cmd.stdout(aiflow_sys::process::Stdio::null()).output() {         Ok(o) if o.status.success() => return true,         Ok(o) => { let e = String::from_utf8_lossy(&o.stderr).trim().to_string(); if e.is_empty() { format!("ffmpeg exited with {}", o.status) } else { e } }         Err(e) => format!("ffmpeg could not start: {e}"),@@ -2638,7 +2638,7 @@ fn compose_pair(a: &mut Run, b: &Run, dir: &Path, outp: &Path, max_seconds: f64,     let workdir = dir.join("compose-pair");     let _ = std::fs::remove_dir_all(&workdir);     let _ = std::fs::create_dir_all(&workdir);-    let has_tts = std::process::Command::new("adom-tts").arg("health").output().map(|o| o.status.success()).unwrap_or(false);+    let has_tts = aiflow_sys::process::Command::new("adom-tts").arg("health").output().map(|o| o.status.success()).unwrap_or(false);     let (na, nb) = (a.data["engine"].as_str().unwrap_or("A").to_string(), b.data["engine"].as_str().unwrap_or("B").to_string());     let board = Path::new(a.data["sourceBoard"].as_str().or(a.data["boards"][0].as_str()).unwrap_or("board")).file_stem().and_then(|s| s.to_str()).unwrap_or("board").trim_end_matches("-0").to_string();     let (va, vb) = (visits_by_step(a), visits_by_step(b));@@ -2695,7 +2695,7 @@ fn compose_pair(a: &mut Run, b: &Run, dir: &Path, outp: &Path, max_seconds: f64,     let say_len = |k: usize, words: &str| -> Option<(PathBuf, f64)> {         if !has_tts || words.trim().is_empty() { return None; }         let audio = workdir.join(format!("script-{k}.mp3"));-        let okv = std::process::Command::new("adom-tts").args(["say", "--out", audio.to_str().unwrap(), words]).output().map(|o| o.status.success()).unwrap_or(false);+        let okv = aiflow_sys::process::Command::new("adom-tts").args(["say", "--out", audio.to_str().unwrap(), words]).output().map(|o| o.status.success()).unwrap_or(false);         if okv { Some((audio.clone(), media_seconds(audio.to_str().unwrap()))) } else { None }     };     for (si, step) in steps.iter().enumerate() {@@ -2721,7 +2721,7 @@ fn compose_pair(a: &mut Run, b: &Run, dir: &Path, outp: &Path, max_seconds: f64,                         if run_ffmpeg(&["-i", &v.tenx, "-an", "-vf", &chain, "-r", "30", "-pix_fmt", "yuv420p", "-c:v", "libx264", "-preset", "veryfast", "-crf", "20", piece.to_str().unwrap()]) { pieces.push(piece); }                     }                     let list = workdir.join(format!("col-{si}-{side}.txt"));-                    std::fs::write(&list, pieces.iter().map(|p| format!("file '{}'\n", std::fs::canonicalize(p).unwrap_or_else(|_| p.to_path_buf()).display())).collect::<String>()).unwrap();+                    std::fs::write(&list, pieces.iter().map(|p| format!("file '{}'\n", aiflow_sys::canonicalize(p).unwrap_or_else(|_| p.to_path_buf()).display())).collect::<String>()).unwrap();                     let cat = workdir.join(format!("cat-{si}-{side}.mp4"));                     let _ = run_ffmpeg(&["-f", "concat", "-safe", "0", "-i", list.to_str().unwrap(), "-c", "copy", cat.to_str().unwrap()]);                     // exactly t_step: the slower column holds its last frame for the rest (a side-by-side has to wait)@@ -2811,8 +2811,8 @@ fn audio_for(workdir: &Path, k: usize, tiers: &[String], vlen: f64, has_tts: boo fn assemble(workdir: &Path, parts: &[(PathBuf, PathBuf)], outp: &Path) {     let vlist = workdir.join("video.txt");     let alist = workdir.join("audio.txt");-    std::fs::write(&vlist, parts.iter().map(|(v, _)| format!("file '{}'\n", std::fs::canonicalize(v).unwrap_or_else(|_| v.clone()).display())).collect::<String>()).unwrap();-    std::fs::write(&alist, parts.iter().map(|(_, a)| format!("file '{}'\n", std::fs::canonicalize(a).unwrap_or_else(|_| a.clone()).display())).collect::<String>()).unwrap();+    std::fs::write(&vlist, parts.iter().map(|(v, _)| format!("file '{}'\n", aiflow_sys::canonicalize(v).unwrap_or_else(|_| v.clone()).display())).collect::<String>()).unwrap();+    std::fs::write(&alist, parts.iter().map(|(_, a)| format!("file '{}'\n", aiflow_sys::canonicalize(a).unwrap_or_else(|_| a.clone()).display())).collect::<String>()).unwrap();     let vcat = workdir.join("video.mp4");     let acat = workdir.join("audio.m4a");     let okv = run_ffmpeg(&["-f", "concat", "-safe", "0", "-i", vlist.to_str().unwrap(), "-c", "copy", vcat.to_str().unwrap()]);@@ -2991,13 +2991,13 @@ fn design_netlist(r: &Run, flag: Option<&str>) -> Option<String> {     }     c.push(r.dir.join("../../design/netlist.json"));     c.into_iter().find(|p| std::fs::read_to_string(p).ok().and_then(|t| serde_json::from_str::<Value>(&t).ok()).is_some_and(|v| v["components"].is_array()))-        .map(|p| std::fs::canonicalize(&p).unwrap_or(p).display().to_string())+        .map(|p| aiflow_sys::canonicalize(&p).unwrap_or(p).display().to_string()) }  fn abs_path(p: &str) -> String {     let pb = PathBuf::from(p);     let pb = if pb.is_absolute() { pb } else { std::env::current_dir().map(|d| d.join(&pb)).unwrap_or(pb) };-    std::fs::canonicalize(&pb).unwrap_or(pb).display().to_string()+    aiflow_sys::canonicalize(&pb).unwrap_or(pb).display().to_string() }  /// The page build's Python packages (board pictures, figures, part pictures), installed into AI Flow's own Python the@@ -3005,15 +3005,15 @@ fn abs_path(p: &str) -> String { /// A failure is a note: the build still runs and says which pictures it left out. fn ensure_page_packages(dir: &Path) {     let py = aiflow_python();-    let have = std::process::Command::new(&py).args(["-c", "import PIL, matplotlib, cairosvg"]).stdin(std::process::Stdio::null()).output().map(|o| o.status.success()).unwrap_or(false);+    let have = aiflow_sys::process::Command::new(&py).args(["-c", "import PIL, matplotlib, cairosvg"]).stdin(aiflow_sys::process::Stdio::null()).output().map(|o| o.status.success()).unwrap_or(false);     if have { return; }     let own = std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".local/share/adom-aiflow/python/bin/python3")).filter(|p| *p == py);     let Some(own) = own else { eprintln!("NOTE: the page build's packages (Pillow, matplotlib, cairosvg) are missing from {}: board pictures and figures are left out until they are installed", py.display()); return; };     let req = dir.join("project-page").join("requirements-page.txt");     let _ = std::fs::write(&req, include_str!("../../../tools/requirements-page.txt"));     eprintln!("installing the page build's packages (Pillow, matplotlib, cairosvg) once, into AI Flow's own Python");-    let ok = std::process::Command::new("python3").args(["-m", "pip", "--python"]).arg(&own).args(["install", "--disable-pip-version-check", "-q", "-r"]).arg(&req)-        .stdin(std::process::Stdio::null()).status().map(|s| s.success()).unwrap_or(false);+    let ok = aiflow_sys::process::Command::new("python3").args(["-m", "pip", "--python"]).arg(&own).args(["install", "--disable-pip-version-check", "-q", "-r"]).arg(&req)+        .stdin(aiflow_sys::process::Stdio::null()).status().map(|s| s.success()).unwrap_or(false);     if !ok { eprintln!("NOTE: the page build's packages could not be installed (see above): board pictures and figures are left out; `python3 -m pip --python {} install -r <adom-aiflow>/tools/requirements-page.txt` adds them", own.display()); } } @@ -3028,7 +3028,7 @@ fn run_page_build(cfg: &Value, dir: &Path) -> Value {     let sp = dir.join("project-page").join("page-build.py");     if let Err(e) = std::fs::write(&sp, &script) { return json!({"ok": false, "error": format!("{}: {e}", sp.display())}); }     ensure_page_packages(dir);-    match std::process::Command::new(aiflow_python()).arg(&sp).arg(&cfgp).stdin(std::process::Stdio::null()).output() {+    match aiflow_sys::process::Command::new(aiflow_python()).arg(&sp).arg(&cfgp).stdin(aiflow_sys::process::Stdio::null()).output() {         Err(e) => json!({"ok": false, "error": format!("python3: {e}")}),         Ok(o) => serde_json::from_slice(&o.stdout).unwrap_or_else(|_| json!({"ok": false, "error": aiflow_run::clip_text(&format!("{}{}", String::from_utf8_lossy(&o.stdout), String::from_utf8_lossy(&o.stderr)), 900)})),     }@@ -3391,7 +3391,7 @@ fn publish_report(r: &Run, dir: &Path, page: &str, push: bool, refresh: bool, th                 let name = e.file_name().to_string_lossy().to_string();                 if name.starts_with('.') { continue; }                 let size = e.metadata().map(|m| m.len()).unwrap_or(0);-                let sum = std::process::Command::new("sha256sum").arg(e.path()).output().ok().map(|o| String::from_utf8_lossy(&o.stdout).split_whitespace().next().unwrap_or("").to_string()).unwrap_or_default();+                let sum = aiflow_sys::process::Command::new("sha256sum").arg(e.path()).output().ok().map(|o| String::from_utf8_lossy(&o.stdout).split_whitespace().next().unwrap_or("").to_string()).unwrap_or_default();                 files.push((format!("{rel}/{name}"), size, sum));             }         }@@ -3405,7 +3405,7 @@ fn publish_report(r: &Run, dir: &Path, page: &str, push: bool, refresh: bool, th             batches.last_mut().unwrap().push(f); acc += f.1;         }         for batch in batches.iter().filter(|b| !b.is_empty()) {-            let mut cmd = std::process::Command::new("adom-wiki");+            let mut cmd = aiflow_sys::process::Command::new("adom-wiki");             cmd.current_dir(&stage).args(["repo", "push", page, "-m", &format!("aiflow run {}: {}", report_id(r), r.data["currentStep"].as_str().unwrap_or("update")), "--files"]);             for f in batch { cmd.arg(&f.0); }             match cmd.output() {@@ -3420,7 +3420,7 @@ fn publish_report(r: &Run, dir: &Path, page: &str, push: bool, refresh: bool, th     if refresh && r.data["reportSurface"].as_str() == Some("webview") {         // a tab in the Hydrogen workspace this AI runs in: the tab's name is the stable handle         let bust = format!("{url}?v={}", now().replace([':', '-'], ""));-        let ws = std::process::Command::new("adom-cli").args(["hydrogen", "workspace", "get"]).output().ok().and_then(|o| serde_json::from_slice::<Value>(&o.stdout).ok());+        let ws = aiflow_sys::process::Command::new("adom-cli").args(["hydrogen", "workspace", "get"]).output().ok().and_then(|o| serde_json::from_slice::<Value>(&o.stdout).ok());         fn leaves(n: &Value, out: &mut Vec<String>) { if let Some(o) = n.as_object() { if o.get("type").and_then(|t| t.as_str()) == Some("leaf") { if let Some(id) = o.get("id").and_then(|i| i.as_str()) { out.push(id.to_string()); } } for v in o.values() { leaves(v, out); } } else if let Some(a) = n.as_array() { for v in a { leaves(v, out); } } }         let mut ids = Vec::new();         if let Some(w) = &ws { leaves(&w["root"], &mut ids); }@@ -3428,7 +3428,7 @@ fn publish_report(r: &Run, dir: &Path, page: &str, push: bool, refresh: bool, th         let panel = ids.iter().find(|i| **i != focused).or(ids.first()).cloned();         match panel {             Some(pid) => {-                let o = std::process::Command::new("adom-cli").args(["hydrogen", "webview", "open-or-refresh", "--name", "AI Flow run", "--url", &bust, "--panel-id", &pid]).output();+                let o = aiflow_sys::process::Command::new("adom-cli").args(["hydrogen", "webview", "open-or-refresh", "--name", "AI Flow run", "--url", &bust, "--panel-id", &pid]).output();                 notes.push(match o { Ok(o) if o.status.success() => "refreshed in the Hydrogen webview tab \"AI Flow run\"".to_string(), Ok(o) => format!("webview: {}", String::from_utf8_lossy(&o.stderr).chars().take(160).collect::<String>()), Err(e) => format!("webview: {e}") });             }             None => notes.push("webview: no Hydrogen workspace panel found (is adom-cli hydrogen reachable?)".into()),@@ -3458,7 +3458,7 @@ fn board_of(r: &Run) -> Board { /// A single-use link that signs a browser surface (a Hydrogen webview tab, pup) into the wiki and lands on /// `page`: `adom-wiki auth login --page <owner/slug>`. A credential until redeemed: never print or log it. fn signed_in_wiki_url(page: &str) -> Option<String> {-    let o = std::process::Command::new("adom-wiki").args(["auth", "login", "--page", page, "--json"]).stdin(std::process::Stdio::null()).output().ok()?;+    let o = aiflow_sys::process::Command::new("adom-wiki").args(["auth", "login", "--page", page, "--json"]).stdin(aiflow_sys::process::Stdio::null()).output().ok()?;     let v: Value = serde_json::from_slice(&o.stdout).ok()?;     let d = if v["data"].is_object() { &v["data"] } else { &v };     d["logged_in_url"].as_str().filter(|u| u.starts_with("https://wiki.adom.inc/")).map(str::to_string)@@ -3661,7 +3661,7 @@ fn checked_remote_binding(r:&Run,br:&Bridge,remote:&str,dir:&Path)->Result<Value     let files=remote_binding::files(&local,remote)?;     let pull=dir.join(format!("native-binding-{}",std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map_err(|e|e.to_string())?.as_nanos()));     std::fs::create_dir_all(&pull).map_err(|e|e.to_string())?;-    let reply=br.call("pull_file",&json!({"filePaths":files.iter().map(|(_,p)|p).collect::<Vec<_>>(),"saveTo":std::fs::canonicalize(&pull).map_err(|e|e.to_string())?}));+    let reply=br.call("pull_file",&json!({"filePaths":files.iter().map(|(_,p)|p).collect::<Vec<_>>(),"saveTo":aiflow_sys::canonicalize(&pull).map_err(|e|e.to_string())?}));     if !Bridge::ok(&reply){return Err(format!("native binding download failed: {}",reply["error"]))}     remote_binding::verify(&local,remote,&pull) }@@ -3675,7 +3675,7 @@ fn sha256_file(p: &str) -> String { /// `kicad-cli`. In a container with no native KiCad, adom-aiflow-kicad-cli-remote runs a desktop's. fn export_sch_netlist(sch: &str, out: &Path) -> Result<String, String> {     let cli = std::env::var("ADOM_AIFLOW_KICAD_CLI").unwrap_or_else(|_| "kicad-cli".into());-    let o = std::process::Command::new(&cli).args(["sch", "export", "netlist", "--format", "kicadsexpr", "--output"]).arg(out).arg(sch).output()+    let o = aiflow_sys::process::Command::new(&cli).args(["sch", "export", "netlist", "--format", "kicadsexpr", "--output"]).arg(out).arg(sch).output()         .map_err(|e| format!("{cli} is not runnable: {e}"))?;     if !o.status.success() || !out.is_file() {         let tail = |b: &[u8]| aiflow_run::clip_text(&String::from_utf8_lossy(b), 500);@@ -3761,7 +3761,7 @@ fn model_orientation_fit(board: &Board, project_dir: &Path, cache_path: Option<&     let mut unresolved: BTreeMap<String, Vec<String>> = BTreeMap::new();     // issue #268: footprint-embedded models are read from the board file, written once into the run     let emb = embedded_models::Embedded::of(board);-    let emb_dir = cache_path.and_then(|p| p.parent()).map(|d| d.join("embedded-models")).unwrap_or_else(|| std::env::temp_dir().join("aiflow-embedded-models"));+    let emb_dir = cache_path.and_then(|p| p.parent()).map(|d| d.join("embedded-models")).unwrap_or_else(|| aiflow_sys::temp_dir().join("aiflow-embedded-models"));     for m in checks::model_refs(board) {         let embedded = m.path.starts_with(embedded_models::PREFIX).then(|| emb.extract(&m.reference, &m.path, &emb_dir));         if let Some(Err(e)) = &embedded { notes.push(format!("{} ({}): {e}", m.reference, m.path)); }@@ -3932,7 +3932,7 @@ fn supply_assessed(r: &Run, mpn: &str) -> Option<Value> { }  fn wiki_page_json(page: &str) -> Option<Value> {-    let o = std::process::Command::new("adom-wiki").args(["repo", "show", page, "page.json"]).stdin(std::process::Stdio::null()).output().ok().filter(|o| o.status.success())?;+    let o = aiflow_sys::process::Command::new("adom-wiki").args(["repo", "show", page, "page.json"]).stdin(aiflow_sys::process::Stdio::null()).output().ok().filter(|o| o.status.success())?;     let t = String::from_utf8_lossy(&o.stdout);     serde_json::from_str(t.get(t.find('{')?..=t.rfind('}')?)?).ok() }@@ -4188,11 +4188,11 @@ fn print_plan_notes(notes: &[String]) { /// argument at 128 KiB (MAX_ARG_STRLEN), so a lane past that never started ("Argument list too long", /// measured 2026-10-16 on the 151 KB Fusion lane). Written once per content (the name carries its hash). fn lane_script(lane: &str, script: &str) -> std::path::PathBuf {-    let dir = std::env::temp_dir().join("adom-aiflow-lanes");+    let dir = aiflow_sys::temp_dir().join("adom-aiflow-lanes");     let _ = std::fs::create_dir_all(&dir);     let path = dir.join(format!("{lane}-{}.py", &provenance::sha256_hex(script.as_bytes())[..16]));     if !path.is_file() {-        let tmp = path.with_extension(format!("tmp{}", std::process::id()));+        let tmp = path.with_extension(format!("tmp{}", aiflow_sys::process::id()));         std::fs::write(&tmp, script).unwrap_or_else(|e| err(&format!("could not write the {lane} lane script: {e}"), &[]));         let _ = std::fs::rename(&tmp, &path);     }@@ -4200,6 +4200,9 @@ fn lane_script(lane: &str, script: &str) -> std::path::PathBuf { }  fn main() {+    // WebAssembly starts in /: the host passes the real working folder as PWD+    #[cfg(target_os = "wasi")]+    if let Ok(d) = std::env::var("PWD") { let _ = std::env::set_current_dir(d); }     let (skill_home, skill_pkg) = skill_hints::here();     let input_hint = skill_hints::command_hint(&command_line(), &skill_home, skill_pkg.as_deref());     let cli = match Cli::try_parse() {@@ -4312,10 +4315,10 @@ fn main() {         Cmd::Exec { command } => {             thread(&cli); let mut r=load_run(&cli);             // an id and this process's pid: other commands see a running exec (the overdue warning waits for it)-            let exec_id=format!("{}-{}",std::process::id(),now());-            r.log("external-start",json!({"program":command[0],"args":&command[1..],"execId":exec_id,"pid":std::process::id()}));+            let exec_id=format!("{}-{}",aiflow_sys::process::id(),now());+            r.log("external-start",json!({"program":command[0],"args":&command[1..],"execId":exec_id,"pid":aiflow_sys::process::id()}));             r.save().unwrap();-            let status=std::process::Command::new(&command[0]).args(&command[1..]).status();+            let status=aiflow_sys::process::Command::new(&command[0]).args(&command[1..]).status();             let mut r=load_run(&cli);             match status {                 Ok(status)=>{@@ -4339,7 +4342,7 @@ fn main() {         }         Cmd::SilkscreenPreflight { input, out } => {             thread(&cli); let _r=load_run(&cli);-            let result=std::process::Command::new(aiflow_python()).arg("-c").arg(include_str!("../../../tools/silkscreen-preflight.py")).arg("--input").arg(input).arg("--out").arg(out).output().unwrap_or_else(|e|err(&format!("preflight could not run: {e}"), &[]));+            let result=aiflow_sys::process::Command::new(aiflow_python()).arg("-c").arg(include_str!("../../../tools/silkscreen-preflight.py")).arg("--input").arg(input).arg("--out").arg(out).output().unwrap_or_else(|e|err(&format!("preflight could not run: {e}"), &[]));             if !result.status.success(){err(&format!("{} {}",String::from_utf8_lossy(&result.stdout),String::from_utf8_lossy(&result.stderr)), &["Repack every reported collision before transferring to the EDA. Include full custom-pad mask geometry, fitted bodies, holes and footprint artwork.".into()]);}             ok(&String::from_utf8_lossy(&result.stdout), &["Preflight passed; confirm with native DRC and inspect both faces. Association quality remains a separate visual gate.".into()]);         }@@ -4354,7 +4357,7 @@ fn main() {             let board_path = board.clone().map(|b| b.display().to_string()).or_else(|| run.as_ref().map(|r| r.current_board())).unwrap_or_else(|| err("board-glb needs --board <file.kicad_pcb> outside a run", &["Pass the .kicad_pcb the STEP was exported from.".into()]));             let spec_finish = run.as_ref().map(spec_soft).and_then(|v| v["fab"]["finish"].as_str().map(String::from));             let finish = finish.clone().or(spec_finish).unwrap_or_else(|| "copper".into());-            let mut command = std::process::Command::new(aiflow_python());+            let mut command = aiflow_sys::process::Command::new(aiflow_python());             command.arg("-c").arg(include_str!("../../../tools/board-glb-copper.py")).arg(action).arg("--glb").arg(glb).arg("--board").arg(&board_path).arg("--finish").arg(&finish).arg("--paste").arg(paste);             if let Some(v) = out { command.arg("--out").arg(v); }             if let Some(v) = report { command.arg("--report").arg(v); }@@ -4373,13 +4376,13 @@ fn main() {         }         Cmd::SilkscreenMask { board, out } => {             thread(&cli); let _r=load_run(&cli);-            let result=std::process::Command::new(aiflow_python()).arg("-c").arg(include_str!("../../../tools/silkscreen-kicad-mask.py")).arg("--board").arg(board).arg("--out").arg(out).output().unwrap_or_else(|e|err(&format!("mask export could not run: {e}"), &[]));+            let result=aiflow_sys::process::Command::new(aiflow_python()).arg("-c").arg(include_str!("../../../tools/silkscreen-kicad-mask.py")).arg("--board").arg(board).arg("--out").arg(out).output().unwrap_or_else(|e|err(&format!("mask export could not run: {e}"), &[]));             if !result.status.success(){err(&String::from_utf8_lossy(&result.stderr), &["Unsupported mask geometry is a blocking preflight error, never an anchor-box fallback.".into()]);}             ok(&String::from_utf8_lossy(&result.stdout), &["Use these complete native mask polygons with fitted body, hole and artwork obstacles.".into()]);         }         Cmd::SilkscreenContactPolicy { input, geometry, out, no_contact_borders } => {             thread(&cli); let _r=load_run(&cli);-            let mut command=std::process::Command::new(aiflow_python());command.arg("-c").arg(include_str!("../../../tools/silkscreen-contact-policy.py")).arg("--input").arg(input).arg("--geometry").arg(geometry).arg("--out").arg(out);+            let mut command=aiflow_sys::process::Command::new(aiflow_python());command.arg("-c").arg(include_str!("../../../tools/silkscreen-contact-policy.py")).arg("--input").arg(input).arg("--geometry").arg(geometry).arg("--out").arg(out);             if *no_contact_borders{command.arg("--no-contact-borders");}             let result=command.output().unwrap_or_else(|e|err(&format!("contact policy could not run: {e}"), &[]));             if !result.status.success(){err(&String::from_utf8_lossy(&result.stderr), &[]);}@@ -4407,7 +4410,7 @@ fn main() {             });             let input = &input;             let _ = std::fs::remove_file(out); // a stale result must not stand in for this run's-            let result = std::process::Command::new(aiflow_python()).arg("-c").arg(include_str!("../../../tools/silkscreen-obstacle-check.py")).arg("--input").arg(input).arg("--out").arg(out).output().unwrap_or_else(|e| err(&format!("silkscreen audit needs python3: {e}"), &[]));+            let result = aiflow_sys::process::Command::new(aiflow_python()).arg("-c").arg(include_str!("../../../tools/silkscreen-obstacle-check.py")).arg("--input").arg(input).arg("--out").arg(out).output().unwrap_or_else(|e| err(&format!("silkscreen audit needs python3: {e}"), &[]));             let rect = "The audit is a rectangle check: each label box against each obstacle box. Built from the board (no --input), labels are their turned text rectangles and pads and bodies their outlines in 0.1 mm strips, so a 45 degree label or a round pad is not a false collision; a hand-built input with one box per item reports collisions in the empty corners.".to_string();             if !result.status.success() {                 let msg = silkproof::checker_failure(&String::from_utf8_lossy(&result.stdout), &String::from_utf8_lossy(&result.stderr));@@ -4660,7 +4663,7 @@ fn main() {         }         Cmd::SilkscreenDashboard { action, port, surface, url, target, json, reason } => {             let t = thread(&cli); let _r = load_run(&cli);-            let mut command = std::process::Command::new("adom-aiflow-silkscreen");+            let mut command = aiflow_sys::process::Command::new("adom-aiflow-silkscreen");             command.arg(action).arg("--run").arg(&dir).arg("--ai-thread").arg(t).arg("--port").arg(port).arg("--surface").arg(surface);             if let Some(v)=url { command.arg("--url").arg(v); }             if let Some(v)=target { command.arg("--target").arg(v); }@@ -4674,7 +4677,7 @@ fn main() {             thread(&cli);             let _r = load_run(&cli);             let source = include_str!("../../../tools/silkscreen-layout.py");-            let mut command = std::process::Command::new(aiflow_python());+            let mut command = aiflow_sys::process::Command::new(aiflow_python());             command.arg("-c").arg(source).arg("--input").arg(input).arg("--out").arg(out);             if let Some(v)=events {command.arg("--events").arg(v);}             let result = command.output().unwrap_or_else(|e| err(&format!("silkscreen planner needs python3: {e}"), &[]));@@ -4712,16 +4715,16 @@ fn main() {                 std::fs::copy(board, &copy).unwrap_or_else(|e| err(&format!("copy: {e}"), &[]));                 aiflow_copper::copy_project_rules(board, &copy.display().to_string()).unwrap_or_else(|e|err(&e,&[]));             }-            let specp = std::fs::canonicalize(spec).map(|p| p.display().to_string()).unwrap_or(spec.clone());+            let specp = aiflow_sys::canonicalize(spec).map(|p| p.display().to_string()).unwrap_or(spec.clone());             if let Some(mut r) = intake_run {                 let pt = r.data["clock"]["promptTime"].as_str().unwrap_or("").to_string();                 let differs = prompt_time.as_ref().filter(|p| **p != pt).map(|p| format!("--prompt-time {p} ignored: the intake run's clock started at {pt} and stays there. "));                 r.attach_board(&copy.display().to_string(), &specp, engine, target.as_deref(), remote_board.as_deref());                 let had = r.data["aiflowVersion"].as_str().map(str::to_string);                 if let Some(w) = binary_version_change(&mut r.data, VERSION, &now()) { r.log("binary-changed", json!({"from": had, "to": VERSION})); eprintln!("WARNING: {w}"); }-                r.data["sourceBoard"] = json!(std::fs::canonicalize(board).map(|p| p.display().to_string()).unwrap_or(board.clone()));+                r.data["sourceBoard"] = json!(aiflow_sys::canonicalize(board).map(|p| p.display().to_string()).unwrap_or(board.clone()));                 if let Err(e) = pagedir::set(&mut r.data, "page", "pageDir", page.as_deref(), page_dir.as_deref()) { err(&e, &[]); }-                if let Some(s) = sch { r.data["schematic"] = json!(std::fs::canonicalize(s).map(|p| p.display().to_string()).unwrap_or(s.clone())); }+                if let Some(s) = sch { r.data["schematic"] = json!(aiflow_sys::canonicalize(s).map(|p| p.display().to_string()).unwrap_or(s.clone())); }                 if r.data["target"].is_string() { screen_mode(&mut r); }                 let idx = r.turn_begin(&command_line());                 record_usage(&mut r, "start");@@ -4746,8 +4749,8 @@ fn main() {             let pt = prompt_time.clone().unwrap_or_else(now);             let mut r = Run::create(&dir, &copy.display().to_string(), &specp, engine, &pt, &t, target.as_deref(), remote_board.as_deref()).unwrap_or_else(|e| err(&e, &[]));             let _ = binary_version_change(&mut r.data, VERSION, &now());-            r.data["sourceBoard"] = json!(std::fs::canonicalize(board).map(|p| p.display().to_string()).unwrap_or(board.clone()));-            if let Some(s) = sch { r.data["schematic"] = json!(std::fs::canonicalize(s).map(|p| p.display().to_string()).unwrap_or(s.clone())); }+            r.data["sourceBoard"] = json!(aiflow_sys::canonicalize(board).map(|p| p.display().to_string()).unwrap_or(board.clone()));+            if let Some(s) = sch { r.data["schematic"] = json!(aiflow_sys::canonicalize(s).map(|p| p.display().to_string()).unwrap_or(s.clone())); }             if let Err(e) = pagedir::set(&mut r.data, "page", "pageDir", page.as_deref(), page_dir.as_deref()) { err(&e, &[]); }             let hands_line = handson::apply_default(&mut r.data, &now());             if target.is_some() { screen_mode(&mut r); }@@ -4779,7 +4782,7 @@ fn main() {             for f in brief.iter().chain(requirements.iter()) { if !Path::new(f).is_file() { err(&format!("not found: {f}"), &[]); } }             { let mut probe = json!({}); if let Err(e) = pagedir::set(&mut probe, "page", "pageDir", page.as_deref(), page_dir.as_deref()) { err(&e, &[]); } }             if kind.is_some() && eda.as_deref().is_some_and(|e| e != "kicad") { err("--kind pattern is a KiCad lane", &["Build the pattern board in KiCad (--eda kicad, or leave --eda out).".into()]); }-            let canon = |p: &String| std::fs::canonicalize(p).map(|x| x.display().to_string()).unwrap_or(p.clone());+            let canon = |p: &String| aiflow_sys::canonicalize(p).map(|x| x.display().to_string()).unwrap_or(p.clone());             // a brief that is already a requirements file (aiflow-intake's shape) is recorded as both             let req = requirements.as_ref().map(canon).or_else(|| brief.as_ref().filter(|b| std::fs::read_to_string(b).ok().and_then(|t| serde_json::from_str::<Value>(&t).ok()).map(|v| v.get("fab").is_some() || v.get("sourcing").is_some() || v.get("outputs").is_some()).unwrap_or(false)).map(canon));             let mut r = Run::create_intake(&dir, prompt_time, &t, engine.as_deref(), brief.as_ref().map(canon).as_deref(), req.as_deref(), target.as_deref()).unwrap_or_else(|e| err(&e, &[]));@@ -4822,7 +4825,7 @@ fn main() {             if what != "check" { err(&format!("sourcing {what}: use `sourcing check --bom <csv>`"), &[]); }             if let Some(q) = requirements {                 if !Path::new(q).is_file() { err(&format!("not found: {q}"), &[]); }-                r.data["requirements"] = json!(std::fs::canonicalize(q).map(|p| p.display().to_string()).unwrap_or(q.clone()));+                r.data["requirements"] = json!(aiflow_sys::canonicalize(q).map(|p| p.display().to_string()).unwrap_or(q.clone()));             }             let (spec, req) = (spec_soft(&r), requirements_of(&r));             let named = preboard::named_profile(&spec).map(|p| (p, "the spec")).or_else(|| preboard::named_profile(&req).map(|p| (p, "the requirements")));@@ -4834,7 +4837,7 @@ fn main() {             let refs = board_path.as_ref().map(|p| Board::load(p).map(|b| preboard::board_refs(&b)).unwrap_or_else(|e| err(&format!("board {p}: {e}"), &[])));             let mut out = preboard::sourcing_check(&text, refs.as_ref(), &prof, qty);             design_evidence::exact_mpn_evidence(&text, design_evidence::require_exact(&spec, &req), &mut out);-            let bomp = std::fs::canonicalize(bom).map(|p| p.display().to_string()).unwrap_or(bom.clone());+            let bomp = aiflow_sys::canonicalize(bom).map(|p| p.display().to_string()).unwrap_or(bom.clone());             out["bom"] = json!(bomp);             out["bomSha256"] = json!(library_review::hash(Path::new(bom)).unwrap_or_default());             out["board"] = json!(board_path);@@ -4881,7 +4884,7 @@ fn main() {             let sha = library_review::hash(&src).unwrap_or_else(|e| err(&e, &[]));             let (top, checks, failing) = preboard::evidence_checks(&text, is_json);             let pass = if top == Some(false) || !failing.is_empty() { Some(false) } else if top == Some(true) || !checks.is_empty() { Some(true) } else { None };-            let canon = std::fs::canonicalize(&src).unwrap_or(src.clone());+            let canon = aiflow_sys::canonicalize(&src).unwrap_or(src.clone());             let step = r.data["currentStep"].clone();             if kind == "simulation" && pass == Some(false) {                 r.log("evidence-refused", json!({"kind": kind, "file": canon.display().to_string(), "sha256": sha, "failing": failing, "pass": top}));@@ -4889,13 +4892,13 @@ fn main() {                 findings(&format!("simulation evidence refused: {} says it fails{}", file, if failing.is_empty() { " (top-level pass: false)".to_string() } else { format!(": {}", failing.iter().map(|c| format!("{} {} against {}", c["name"].as_str().unwrap_or("?"), c["value"], c["limit"])).collect::<Vec<_>>().join("; ")) }), &["A failing simulation is a design result, not evidence of a working design: change the values (aiflow-circuit-design), simulate again, and add the passing result. Obey a datasheet limit over a fitted model (aiflow-simulate).".into()]);             }             // a copy in the run keeps the record when the design folder moves on-            let rdir = std::fs::canonicalize(&dir).unwrap_or(dir.clone());+            let rdir = aiflow_sys::canonicalize(&dir).unwrap_or(dir.clone());             let copy = if canon.starts_with(&rdir) { canon.clone() } else {                 let d = dir.join("evidence");                 let _ = std::fs::create_dir_all(&d);                 let dest = d.join(format!("{kind}-{}", src.file_name().and_then(|n| n.to_str()).unwrap_or("file")));                 std::fs::copy(&src, &dest).unwrap_or_else(|e| err(&format!("copy into the run: {e}"), &[]));-                std::fs::canonicalize(&dest).unwrap_or(dest)+                aiflow_sys::canonicalize(&dest).unwrap_or(dest)             };             let review: Vec<String> = match (kind.as_str(), serde_json::from_str::<Value>(&text)) { ("calcs", Ok(v)) => design_evidence::calcs_warnings(&v), ("simulation", Ok(v)) => design_evidence::simulation_warnings(&requirements_of(&r), &v), _ => Vec::new() };             let entry = json!({"kind": kind, "file": canon.display().to_string(), "copy": copy.display().to_string(), "sha256": sha, "bytes": text.len(), "note": note, "step": step, "at": now(), "pass": pass, "checks": checks, "warnings": review});@@ -4937,7 +4940,7 @@ fn main() {         Cmd::Widget { action, file, label, step, progress } => {             let t = thread(&cli);             let _r = load_run(&cli);-            let mut cmd = std::process::Command::new("adom-aiflow-widget");+            let mut cmd = aiflow_sys::process::Command::new("adom-aiflow-widget");             cmd.arg(action).arg("--run").arg(&dir).arg("--ai-thread").arg(t);             if let Some(v) = file { cmd.arg("--file").arg(v); }             if let Some(v) = label { cmd.arg("--label").arg(v); }@@ -5004,7 +5007,7 @@ fn main() {                 // MCP73831T-2ACI/OT's factory page is adom/mcp73831t-2aci (issue #161): the MPN without its "/" suffix last                 if let Some(b) = preboard::mpn_base(&mpn) { queries.push(b); }                 for q in &queries {-                    let o = std::process::Command::new("adom-wiki").args(["search", q, "--json"]).stdin(std::process::Stdio::null()).output().ok();+                    let o = aiflow_sys::process::Command::new("adom-wiki").args(["search", q, "--json"]).stdin(aiflow_sys::process::Stdio::null()).output().ok();                     let v: Value = o.and_then(|o| serde_json::from_slice(&o.stdout).ok()).unwrap_or(Value::Null);                     let hits = v["data"]["results"].as_array().or(v["data"].as_array()).or(v["results"].as_array()).cloned().unwrap_or_default();                     page = preboard::part_page(&hits, &mpn);@@ -5051,7 +5054,7 @@ fn main() {                 let m = x["mpn"].as_str()?; let a = supply_assessed(&r, m)?;                 Some(format!("{}: supply risk {}{}", supply::decision(m, &refs_of(m), &[], None, None).split(':').next().unwrap_or(m), a["risk"].as_str().unwrap_or("?"), r.data["supplyChoices"].get(m).and_then(|c| c["pick"].as_str()).map(|p| format!(", chosen: {p}")).unwrap_or_default()))             }).collect();-            r.outcome("parts", json!({"pass": pass, "bom": std::fs::canonicalize(&bom).map(|p| p.display().to_string()).unwrap_or(bom.clone()), "parts": rows, "missing": missing, "decisions": decisions, "supplyRiskFile": r.data["outcomes"]["supplyRisk"]["file"].clone(), "projectLib": plib, "projectLibParts": from_lib, "projectLibGaps": why_missing.iter().map(|(m, w)| json!({"mpn": m, "why": w})).collect::<Vec<_>>(), "sourceNotes": source_notes}));+            r.outcome("parts", json!({"pass": pass, "bom": aiflow_sys::canonicalize(&bom).map(|p| p.display().to_string()).unwrap_or(bom.clone()), "parts": rows, "missing": missing, "decisions": decisions, "supplyRiskFile": r.data["outcomes"]["supplyRisk"]["file"].clone(), "projectLib": plib, "projectLibParts": from_lib, "projectLibGaps": why_missing.iter().map(|(m, w)| json!({"mpn": m, "why": w})).collect::<Vec<_>>(), "sourceNotes": source_notes}));             r.save().unwrap();             if *show {                 // one named tab walks through the pages (never a tab per part)@@ -5060,7 +5063,7 @@ fn main() {                 let name = format!("Parts - {}", &r.data["id"].as_str().unwrap_or("run")[..8.min(r.data["id"].as_str().unwrap_or("run").len())]);                 for row in rows.iter().filter(|x| x["wiki"].is_string()) {                     let url = format!("https://wiki.adom.inc/{}", row["wiki"].as_str().unwrap());-                    let _ = std::process::Command::new("adom-cli").args(["hydrogen", "webview", "open-or-refresh", "--name", &name, "--url", &url, "--ai-thread", &t, "--reason", "adom-aiflow: show the chosen parts"]).stdin(std::process::Stdio::null()).output();+                    let _ = aiflow_sys::process::Command::new("adom-cli").args(["hydrogen", "webview", "open-or-refresh", "--name", &name, "--url", &url, "--ai-thread", &t, "--reason", "adom-aiflow: show the chosen parts"]).stdin(aiflow_sys::process::Stdio::null()).output();                     std::thread::sleep(std::time::Duration::from_secs(*dwell));                 }             }@@ -5121,7 +5124,7 @@ fn main() {             let facts: Vec<Value> = doc["parts"].as_array().or(doc.as_array()).cloned().unwrap_or_default();             let rows: Vec<Value> = r.data["outcomes"]["parts"]["parts"].as_array().cloned().unwrap_or_default();             let wiki_file = |page: &str, path: &str| -> Option<String> {-                let o = std::process::Command::new("adom-wiki").args(["repo", "show", page, path]).stdin(std::process::Stdio::null()).output().ok().filter(|o| o.status.success())?;+                let o = aiflow_sys::process::Command::new("adom-wiki").args(["repo", "show", page, path]).stdin(aiflow_sys::process::Stdio::null()).output().ok().filter(|o| o.status.success())?;                 Some(String::from_utf8_lossy(&o.stdout).to_string())             };             let (mut results, mut lines) = (Vec::new(), Vec::new());@@ -5150,7 +5153,7 @@ fn main() {             }             let checked: Vec<String> = facts.iter().filter_map(|f| f["mpn"].as_str().map(|m| m.to_ascii_uppercase())).collect();             let unchecked: Vec<String> = rows.iter().filter(|x| x["wiki"].is_string() || x["projectLib"].is_object()).filter_map(|x| x["mpn"].as_str()).filter(|m| !checked.contains(&m.to_ascii_uppercase())).map(str::to_string).collect();-            r.outcome("part-check", json!({"file": std::fs::canonicalize(file).map(|p| p.display().to_string()).unwrap_or(file.clone()), "parts": results, "findings": lines, "unchecked": unchecked}));+            r.outcome("part-check", json!({"file": aiflow_sys::canonicalize(file).map(|p| p.display().to_string()).unwrap_or(file.clone()), "parts": results, "findings": lines, "unchecked": unchecked}));             r.save().unwrap();             let tail = if unchecked.is_empty() { String::new() } else { format!("\nnot checked yet ({}): {}", unchecked.len(), unchecked.iter().take(20).cloned().collect::<Vec<_>>().join(", ")) };             let hints = vec!["A page that is wrong: fix it when it is yours, or open an issue on it with what the datasheet says (never edit someone else's page); meanwhile give the part from the project library with \"prefer\": true (aiflow-sourcing).".to_string()];@@ -5161,7 +5164,7 @@ fn main() {             let t = thread(&cli);             let mut r = load_run(&cli);             if *refresh {-                let o = std::process::Command::new("adom-wiki").args(["part", "status", "--json"]).stdin(std::process::Stdio::null()).output()+                let o = aiflow_sys::process::Command::new("adom-wiki").args(["part", "status", "--json"]).stdin(aiflow_sys::process::Stdio::null()).output()                     .unwrap_or_else(|e| err(&format!("could not run adom-wiki part status: {e}"), &[]));                 let v: Value = serde_json::from_slice(&o.stdout).unwrap_or(Value::Null);                 let Some(list) = v["data"]["requests"].as_array().cloned() else {@@ -5195,7 +5198,7 @@ fn main() {             let mut args: Vec<String> = vec!["part".into(), "request".into(), sent.clone(), "--json".into(), if *later { "--later" } else { "--now" }.into(), "--source".into(), "bom".into()];             if let Some(m) = manufacturer { args.extend(["--manufacturer".into(), m.clone()]); }             if let Some(d) = datasheet { args.extend(["--datasheet".into(), d.clone()]); }-            let o = std::process::Command::new("adom-wiki").args(&args).stdin(std::process::Stdio::null()).output()+            let o = aiflow_sys::process::Command::new("adom-wiki").args(&args).stdin(aiflow_sys::process::Stdio::null()).output()                 .unwrap_or_else(|e| err(&format!("could not run adom-wiki part request: {e}"), &[]));             let v: Value = serde_json::from_slice(&o.stdout).unwrap_or(Value::Null);             let ans = supply::answer(&v);@@ -5234,7 +5237,7 @@ fn main() {             let text = std::fs::read_to_string(file).unwrap_or_else(|e| err(&format!("{file}: {e}"), &[format!("Write the assessment there (aiflow-sourcing skill, \"When a part cannot get a page\"), or pass --file.")]));             let v: Value = serde_json::from_str(&text).unwrap_or_else(|e| err(&format!("{file}: not JSON: {e}"), &[]));             let (parts, gaps) = supply::check(&v);-            let path = std::fs::canonicalize(file).map(|p| p.display().to_string()).unwrap_or(file.clone());+            let path = aiflow_sys::canonicalize(file).map(|p| p.display().to_string()).unwrap_or(file.clone());             let summary: Vec<Value> = parts.iter().map(|p| json!({"mpn": p["mpn"], "risk": p["risk"], "alternatives": p["alternatives"].as_array().map(|a| a.len()).unwrap_or(0)})).collect();             r.outcome("supplyRisk", json!({"file": path, "sha256": sha256_file(&path), "parts": summary, "findings": gaps}));             r.save().unwrap();@@ -5270,7 +5273,7 @@ fn main() {             if *sync {                 if let Err(e) = pagedir::set(&mut r.data, "projectPage", "projectPageDir", Some(page.as_str()), page_dir_arg.as_deref()) { err(&e, &[]); }                 r.save().unwrap();-                let o = std::process::Command::new("python3").arg("-c").arg(include_str!("../../../tools/project-steps.py")).arg(&dir).arg(page).env("AIFLOW_FLOW_FILE", flow_file(&dir)).stdin(std::process::Stdio::null()).output().unwrap_or_else(|e| err(&format!("python3: {e}"), &[]));+                let o = aiflow_sys::process::Command::new("python3").arg("-c").arg(include_str!("../../../tools/project-steps.py")).arg(&dir).arg(page).env("AIFLOW_FLOW_FILE", flow_file(&dir)).stdin(aiflow_sys::process::Stdio::null()).output().unwrap_or_else(|e| err(&format!("python3: {e}"), &[]));                 let v: Value = serde_json::from_slice(&o.stdout).unwrap_or(json!({"ok": false, "error": String::from_utf8_lossy(&o.stderr).to_string()}));                 if v["ok"] != true { err(&format!("step pages: {}", v["error"].as_str().unwrap_or("failed")), &[]); }                 // an explicit push of the step pages binds the page for the background pushes too@@ -5295,7 +5298,7 @@ fn main() {             let cfgp = dir.join("project-page").join("config.json");             let _ = std::fs::create_dir_all(cfgp.parent().unwrap());             std::fs::write(&cfgp, serde_json::to_string_pretty(&cfg).unwrap()).unwrap();-            let o = std::process::Command::new("python3").arg("-c").arg(include_str!("../../../tools/project-page.py")).arg(&cfgp).stdin(std::process::Stdio::null()).output().unwrap_or_else(|e| err(&format!("python3: {e}"), &[]));+            let o = aiflow_sys::process::Command::new("python3").arg("-c").arg(include_str!("../../../tools/project-page.py")).arg(&cfgp).stdin(aiflow_sys::process::Stdio::null()).output().unwrap_or_else(|e| err(&format!("python3: {e}"), &[]));             let v: Value = serde_json::from_slice(&o.stdout).unwrap_or_else(|_| json!({"ok": false, "error": aiflow_run::clip_text(&String::from_utf8_lossy(&o.stderr), 600)}));             if v["ok"] != true {                 if let Some(l) = v["cloudLibrary"].as_str().filter(|l| l.starts_with("lib_")) { r.data["cloudLibrary"] = json!(l); r.save().unwrap(); }@@ -5314,7 +5317,7 @@ fn main() {                 // through a single-use browser-session link (adom-wiki auth login; never printed)                 // (every time, not only with --private: an --existing page may be private too)                 let url = signed_in_wiki_url(page).unwrap_or_else(|| v["url"].as_str().unwrap_or("").to_string());-                let _ = std::process::Command::new("adom-cli").args(["hydrogen", "webview", "open-or-refresh", "--name", "Project page", "--url", &url, "--ai-thread", &t, "--reason", "adom-aiflow: the board's project page, revision 1"]).stdin(std::process::Stdio::null()).output();+                let _ = aiflow_sys::process::Command::new("adom-cli").args(["hydrogen", "webview", "open-or-refresh", "--name", "Project page", "--url", &url, "--ai-thread", &t, "--reason", "adom-aiflow: the board's project page, revision 1"]).stdin(aiflow_sys::process::Stdio::null()).output();             }             // --no-push builds everything locally: never claim the page was created or updated (issue #82)             let page_said = if *local_only { format!("project page built locally in {} (--local-only: no wiki call; {} was not created or updated)", dir.join("project-page").display(), v["url"].as_str().unwrap_or(page)) }@@ -5399,7 +5402,7 @@ fn main() {             // while it is one edit in the schematic; a hint, never a refusal             let pin_names = molecule_pins::names_from_footprints(&on_sheet.iter().map(|(rf, (_, fp))| (rf.clone(), fp.clone())).collect::<Vec<_>>());             let pin_hints: Vec<String> = pin_names.iter().map(|(finding, suggestion)| format!("Molecule names: {finding}. {suggestion}")).collect();-            let canon = std::fs::canonicalize(sch).map(|p| p.display().to_string()).unwrap_or(sch.clone());+            let canon = aiflow_sys::canonicalize(sch).map(|p| p.display().to_string()).unwrap_or(sch.clone());             r.outcome("erc", json!({"pass": erc_errors.is_empty(), "errors": erc_errors, "schematic": canon, "sha256": sha256_file(sch), "report": erc.display().to_string(), "source": "schematic check (kicad-cli sch erc)"}));             r.outcome("schematic", json!({"pass": pass, "schematic": canon, "sha256": sha256_file(sch), "ercErrors": erc_errors, "symbols": on_sheet.len(), "missingRefs": missing, "notFromProjectLibrary": foreign, "nativeBound": bound, "notInBom": extra, "library": lib, "moleculeNames": pin_names.iter().map(|(a, b)| json!({"finding": a, "suggestion": b})).collect::<Vec<_>>()}));             if pass { r.data["schematic"] = json!(canon); }@@ -5922,7 +5925,7 @@ fn main() {             let target = target.clone().or_else(|| run.as_ref().and_then(|r| r.data["target"].as_str().map(str::to_string))).or_else(|| std::env::var("AIFLOW_TARGET").ok()).unwrap_or_default();             // issue #143: where `fusion library` finds the test point when its private wiki page cannot be read             if args.first().is_some_and(|a| a == "library") { if let Err(e) = testplan::write_test_point_files(&dir) { eprintln!("WARNING the test point files could not be written: {e}"); } }-            let status = std::process::Command::new("python3").arg(lane_script("fusion", &format!("{}\n{}", include_str!("../../../tools/silkscreen-plan.py"), include_str!("../../../tools/fusion-project.py")))).args(args)+            let status = aiflow_sys::process::Command::new("python3").arg(lane_script("fusion", &format!("{}\n{}", include_str!("../../../tools/silkscreen-plan.py"), include_str!("../../../tools/fusion-project.py")))).args(args)                 .env("AIFLOW_RUN", &dir).env("AIFLOW_TARGET", &target).env("AIFLOW_THREAD", thread(&cli)).env("AIFLOW_EXE", std::env::current_exe().map(|p| p.display().to_string()).unwrap_or_default())                 .status().unwrap_or_else(|e| err(&format!("fusion steps need python3: {e}"), &[]));             std::process::exit(status.code().unwrap_or(1));@@ -5933,7 +5936,7 @@ fn main() {             let run = Run::open(&dir);             let target = target.clone().or_else(|| run.as_ref().and_then(|r| r.data["target"].as_str().map(str::to_string))).or_else(|| std::env::var("AIFLOW_TARGET").ok()).unwrap_or_default();             let script = format!("{}\n{}\n{}\n{}\n{}\n{}", include_str!("../../../tools/project-common.py"), include_str!("../../../tools/silkscreen-plan.py"), include_str!("../../../tools/altium-lane.py"), include_str!("../../../tools/altium-spice.py"), include_str!("../../../tools/altium-sim.py"), include_str!("../../../tools/altium-project.py"));-            let status = std::process::Command::new("python3").arg(lane_script("altium", &script)).args(args)+            let status = aiflow_sys::process::Command::new("python3").arg(lane_script("altium", &script)).args(args)                 .env("AIFLOW_RUN", &dir).env("AIFLOW_TARGET", &target).env("AIFLOW_THREAD", thread(&cli)).env("AIFLOW_EXE", std::env::current_exe().map(|p| p.display().to_string()).unwrap_or_default())                 .status().unwrap_or_else(|e| err(&format!("altium steps need python3: {e}"), &[]));             std::process::exit(status.code().unwrap_or(1));@@ -6125,7 +6128,7 @@ fn main() {                         // issue #250: a plan the gate found new DRC errors in (shorts, clearances) is not landed: that                         // copper would go onto the human's board. Open connections still land (a partial route is fine).                         let gate = r.outcomes().get("gate").cloned().unwrap_or(Value::Null);-                        let same_plan = |a: &str, b: &str| std::fs::canonicalize(a).ok().zip(std::fs::canonicalize(b).ok()).map(|(x, y)| x == y).unwrap_or(a == b);+                        let same_plan = |a: &str, b: &str| aiflow_sys::canonicalize(a).ok().zip(aiflow_sys::canonicalize(b).ok()).map(|(x, y)| x == y).unwrap_or(a == b);                         let gated = gate["plan"].as_str().is_some_and(|gp| same_plan(gp, &chosen));                         let new_errors = gate["newErrors"].as_u64().unwrap_or(0);                         if gate_refuses_landing(&gate, gated, accept_gate_errors.as_deref()) {@@ -6549,7 +6552,7 @@ fn main() {             // any other file (copied, edited, or written to look like one) is solved again here, same inputs             let mut unobserved: Option<String> = None;             if aiflow_analyze::needs_field_screen(&spec,what) {-                if let Some(n) = std::process::Command::new("adom-fields").arg("--version").output().ok().and_then(|o| fields_versions::installed_note(&String::from_utf8_lossy(&o.stdout))) { note(&n, &[]); }+                if let Some(n) = aiflow_sys::process::Command::new("adom-fields").arg("--version").output().ok().and_then(|o| fields_versions::installed_note(&String::from_utf8_lossy(&o.stdout))) { note(&n, &[]); }                 // adom-fields 0.10.12 refuses a hot part that is not on the board or whose tabNet is on none of its pads                 let hot = fields_versions::hot_spec_problems(&spec, &board_now);                 if !hot.is_empty() { note(&format!("adom-fields (0.10.12 and later) will refuse this spec's hot parts:\n  {}", hot.join("\n  ")), &["Fix spec.hot: name parts that are on this board, and a tabNet that is one of the part's pad nets (the tab's net). Earlier versions dropped such a part and solved the board cold.".into()]); }@@ -6567,7 +6570,7 @@ fn main() {                 args.extend(fields_pitch::args(&spec, None));                 eprintln!("{} was not produced by an Adom Fields solve this run watched; solving it now ({}): adom-fields {}", fields_file.display(), fields_mod_plan.describe(), args.join(" "));                 if let Some(n) = fields_pitch::large_board_note(&board_now, &spec) { eprintln!("WARNING: {n}. Stop it (Ctrl-C), set the cell and analyze {what} again; or solve it yourself through `adom-aiflow exec -- adom-fields {}`.", args.join(" ")); }-                match std::process::Command::new("adom-fields").args(&args).status() {+                match aiflow_sys::process::Command::new("adom-fields").args(&args).status() {                     Ok(st) if st.success() => { fields_file = out_dir.join("fields.json"); let mut full=vec!["adom-fields".to_string()]; full.extend(args.clone()); record_fields_solve(&mut r, &fields_file, "analyze", &full); r.save().unwrap(); }                     Ok(st) => { unobserved = Some(format!("the field solve aiflow started failed ({st}); fix what adom-fields printed, then `adom-aiflow exec -- adom-fields {}` and analyze {what} again", args.join(" "))); }                     Err(e) => { unobserved = Some(format!("{} was not produced by an Adom Fields solve this run watched, and adom-fields could not start ({e}): install adom-fields, then `adom-aiflow exec -- adom-fields {}`", fields_file.display(), args.join(" "))); }@@ -7269,7 +7272,7 @@ fn main() {                     let caps = r.data["captures"].as_array().cloned().unwrap_or_default();                     let Some(pos) = caps.iter().rposition(|c| c.get("recordingId").is_some() && c.get("file").is_none()) else { ok("no recording running: nothing to stop (a walkthrough stops its own clip)", &["Next: `done --message ...` when the answer is complete.".into()]); return; };                     let rid = caps[pos]["recordingId"].as_str().unwrap().to_string();-                    let save_to = std::fs::canonicalize(&dir).unwrap_or(dir.clone()).display().to_string();+                    let save_to = aiflow_sys::canonicalize(&dir).unwrap_or(dir.clone()).display().to_string();                     let stop = br.record_stop(&rid, &save_to);                     let local = settle_clip_stop(&mut r, pos, &stop, &dir);                     let cap = &r.data["captures"][pos];@@ -7502,9 +7505,9 @@ fn main() {                 library_review::verify(rp,Path::new(&r.current_board()),&dest).unwrap_or_else(|e|err(&e,&["Update the actual selection/native evidence, then re-register; do not mark pending evidence passed.".into()]));                 let seconds=media_seconds(dest.to_str().unwrap());                 if !(1.0..=6.0).contains(&seconds){err("library overview must be a moving clip between one and six seconds", &["Keep the full component tour separate; cut a roughly five-second overview.".into()]);}-                Some(std::fs::canonicalize(rp).unwrap_or(rp.clone()).display().to_string())+                Some(aiflow_sys::canonicalize(rp).unwrap_or(rp.clone()).display().to_string())             }else{None};-            let replaced = replaces.as_ref().map(|p| std::fs::canonicalize(p).unwrap_or(PathBuf::from(p)).display().to_string());+            let replaced = replaces.as_ref().map(|p| aiflow_sys::canonicalize(p).unwrap_or(PathBuf::from(p)).display().to_string());             r.log("artifact", json!({"step": step, "visit": visit, "kind": kind, "file": dest.display().to_string(), "caption": caption, "byAi": true, "replaces": replaced, "review":review_path, "sha256": artifact_hash, "sourceFile": src.display().to_string()}));             r.mark(&format!("artifact {kind} for {step}-{visit}: {caption}"));             r.save().unwrap();@@ -7519,7 +7522,7 @@ fn main() {             let mut notes = Vec::new();             if *push {                 let stage = dir.join("report");-                let mut cmd = std::process::Command::new("adom-wiki");+                let mut cmd = aiflow_sys::process::Command::new("adom-wiki");                 cmd.current_dir(&stage).args(["repo", "push", &page, "-m", &format!("aiflow comparison {}: {} versus {}", rel, r.data["engine"].as_str().unwrap_or(""), b.data["engine"].as_str().unwrap_or("")), "--files"]);                 for f in &files { cmd.arg(f); }                 match cmd.output() { Ok(o) if o.status.success() => notes.push(format!("pushed {} files", files.len())), Ok(o) => err(&format!("push failed: {}", aiflow_run::clip_text(&String::from_utf8_lossy(&o.stderr), 200)), &["Run it again: the files are still staged.".into()]), Err(e) => err(&format!("push failed: {e}"), &[]) }@@ -7546,7 +7549,7 @@ fn main() {                 // a copy in the run folder, so later edits to the board do not move the baseline                 let keep = dir.join(format!("interface-baseline-{n}.kicad_pcb"));                 if let Err(e) = std::fs::copy(b, &keep) { err(&format!("--rebaseline: copy {b} to {}: {e}", keep.display()), &[]); }-                let keep = std::fs::canonicalize(&keep).unwrap_or(keep);+                let keep = aiflow_sys::canonicalize(&keep).unwrap_or(keep);                 r.data["interfaceBaseline"] = json!({"board": keep.display().to_string(), "from": b, "prompt": n, "why": text, "at": at});                 r.log("interface-rebaseline", json!({"prompt": n, "board": keep, "from": b, "why": text}));                 note(&format!("the molecule interface baseline is now {b} (copied to {}): the fixed references are checked against it from here", keep.display()), &["The change is the human's, recorded with their words in this prompt; the run, its clock and its ledger carry on.".into()]);@@ -7573,7 +7576,7 @@ fn main() {             let t = now();             // issue #171: an accepted stop is kept, so the finish guard honours it on later calls without its path             if let (Some(p), true) = (stop_evidence, verdict["mayStop"] == true && verdict["stopEvidence"].is_object()) {-                r.data["stopEvidence"] = json!({"path": std::fs::canonicalize(p).unwrap_or(p.clone()).display().to_string(), "at": t, "decision": verdict["decision"]});+                r.data["stopEvidence"] = json!({"path": aiflow_sys::canonicalize(p).unwrap_or(p.clone()).display().to_string(), "at": t, "decision": verdict["decision"]});             }             r.log("done", json!({"n": cur.n, "message": message, "stopDecision": verdict}));             r.save().unwrap();@@ -7610,11 +7613,11 @@ fn main() {             let schematic_files = schematic_identity::capture(Path::new(&sch)).unwrap_or_else(|e| err(&format!("schematic hierarchy: {e}"), &[]));             let board_path = board.clone().or_else(|| run.as_ref().map(|r| r.current_board())).unwrap_or_else(|| err("netlist check needs --board <file.kicad_pcb> outside a run", &[]));             let b = Board::load(&board_path).unwrap_or_else(|e| err(&e, &[]));-            let out_dir = if run.is_some() { dir.clone() } else { std::env::temp_dir() };+            let out_dir = if run.is_some() { dir.clone() } else { aiflow_sys::temp_dir() };             let (netfile, via) = match net {                 Some(n) => (PathBuf::from(n), "given netlist".to_string()),                 None => {-                    let out = out_dir.join(if run.is_some() { "netlist-sch.net".to_string() } else { format!("aiflow-netlist-{}.net", std::process::id()) });+                    let out = out_dir.join(if run.is_some() { "netlist-sch.net".to_string() } else { format!("aiflow-netlist-{}.net", aiflow_sys::process::id()) });                     let _ = std::fs::remove_file(&out);                     let cli_used = export_sch_netlist(&sch, &out).unwrap_or_else(|e| err(&e, &["Export needs KiCad's own kicad-cli for the schematic's version (a KiCad 7 kicad-cli cannot read a KiCad 10 schematic). In a container with no native KiCad: ADOM_AIFLOW_KICAD_CLI=adom-aiflow-kicad-cli-remote KICAD_REMOTE_TARGET=<desktop> KICAD_REMOTE_THREAD=<your thread>. Or export it yourself (`kicad-cli sch export netlist --format kicadsexpr`) and pass --net <file>.".into()]));                     (out, format!("exported by {cli_used}"))@@ -7654,8 +7657,8 @@ fn main() {             if let Some(r) = run.as_mut() {                 let report = dir.join("netlist.json");                 write_json(&report, &rep);-                if r.data["schematic"].is_null() { r.data["schematic"] = json!(std::fs::canonicalize(&sch).map(|p| p.display().to_string()).unwrap_or(sch.clone())); }-                r.outcome("netlist", json!({"ok": passed, "schematic": sch, "sha256": sha256_file(&sch), "schematicFiles": schematic_files, "netlistSha256": netlist_hash, "netlist": std::fs::canonicalize(&netfile).map(|p| p.display().to_string()).unwrap_or_default(), "board": board_path, "report": report.display().to_string(), "matchedPins": rep["matchedPins"], "connectedPins": rep["connectedPins"], "mismatches": rep["mismatches"].as_array().map(|a| a.len()).unwrap_or(0), "missingRefs": rep["missingRefs"], "extraRefs": rep["extraRefs"]}));+                if r.data["schematic"].is_null() { r.data["schematic"] = json!(aiflow_sys::canonicalize(&sch).map(|p| p.display().to_string()).unwrap_or(sch.clone())); }+                r.outcome("netlist", json!({"ok": passed, "schematic": sch, "sha256": sha256_file(&sch), "schematicFiles": schematic_files, "netlistSha256": netlist_hash, "netlist": aiflow_sys::canonicalize(&netfile).map(|p| p.display().to_string()).unwrap_or_default(), "board": board_path, "report": report.display().to_string(), "matchedPins": rep["matchedPins"], "connectedPins": rep["connectedPins"], "mismatches": rep["mismatches"].as_array().map(|a| a.len()).unwrap_or(0), "missingRefs": rep["missingRefs"], "extraRefs": rep["extraRefs"]}));                 r.save().unwrap_or_else(|e| err(&e, &[]));             }             let fp_hint = if fpd.is_empty() { String::new() } else { format!("Footprints differ (not blocking, but check they are the parts you meant): {}", fpd.join("; ")) };@@ -7758,7 +7761,7 @@ fn main() {                 let n = to_land["nets"].as_array().map(|a| a.len()).unwrap_or(0);                 if n > 0 {                     let exe = std::env::current_exe().unwrap();-                    let st = std::process::Command::new(exe).args(["--run", &dir.display().to_string(), "--ai-thread", &thread(&cli), "land", "vias", "--plan", &pp, "--pause-ms", &pause_ms.to_string()]).status().unwrap_or_else(|e| err(&e.to_string(), &[]));+                    let st = aiflow_sys::process::Command::new(exe).args(["--run", &dir.display().to_string(), "--ai-thread", &thread(&cli), "land", "vias", "--plan", &pp, "--pause-ms", &pause_ms.to_string()]).status().unwrap_or_else(|e| err(&e.to_string(), &[]));                     if !st.success() { err("landing the heatsink vias stopped (see above)", &["Fix what it says, then `thermal-vias plan` again (the plan counts what landed) and land.".into()]); }                 }                 let r2 = load_run(&cli);@@ -7838,7 +7841,7 @@ fn main() {                 "serve" => {                     timeline_server::serve(&tdir,*port).unwrap_or_else(|e|{                         // issue #201: say who holds the port, so nobody has to hunt for it-                        let holder=std::process::Command::new("ss").args(["-ltnpH",&format!("sport = :{port}")]).output().ok().map(|o|String::from_utf8_lossy(&o.stdout).to_string()).and_then(|t|{let i=t.find("users:((\"")?+9;let rest=&t[i..];let name=&rest[..rest.find('"')?];let pid=rest.find("pid=").map(|j|rest[j+4..].chars().take_while(|c|c.is_ascii_digit()).collect::<String>()).unwrap_or_default();Some(format!("{name} (pid {pid})"))});+                        let holder=aiflow_sys::process::Command::new("ss").args(["-ltnpH",&format!("sport = :{port}")]).output().ok().map(|o|String::from_utf8_lossy(&o.stdout).to_string()).and_then(|t|{let i=t.find("users:((\"")?+9;let rest=&t[i..];let name=&rest[..rest.find('"')?];let pid=rest.find("pid=").map(|j|rest[j+4..].chars().take_while(|c|c.is_ascii_digit()).collect::<String>()).unwrap_or_default();Some(format!("{name} (pid {pid})"))});                         err(&format!("port {port}: {e}{}",holder.map(|h|format!("; it is held by {h}")).unwrap_or_default()),&[format!("Pass another port: `timeline serve --port <free port>` (AI Flow's own dashboards use {}..{}, clear of the 88xx ports Adom's dock apps take, such as Parts Search on 8893).",dashboard::PORTS.start,dashboard::PORTS.end),"Use the existing run server; do not create another dashboard.".into()])                     });                 }@@ -7898,7 +7901,7 @@ fn main() {             let req_v = requirements_of(&r);             let (list, fixture_cfg) = testplan::tests_of_with_fixture(&tv, &req_v);             if list.is_empty() { err(&format!("{tp} has no tests"), &["A board with nothing to measure has not been thought through: list the rails, the switch node, feedback, ripple, enable and every LED.".into()]); }-            let tp_abs = std::fs::canonicalize(&tp).map(|p| p.display().to_string()).unwrap_or(tp.clone());+            let tp_abs = aiflow_sys::canonicalize(&tp).map(|p| p.display().to_string()).unwrap_or(tp.clone());             r.data["testPlan"] = json!(tp_abs);             let has_board = r.data["boards"].as_array().map(|a| !a.is_empty()).unwrap_or(false);             let (rows, gaps, notes, added, mode) = if has_board {@@ -8040,7 +8043,7 @@ fn main() {             }             let page = "adom/pcb-design-rules";             let list = || -> Vec<String> {-                let o = std::process::Command::new("adom-wiki").args(["api", "/api/v1/pages/adom/pcb-design-rules/files?path=kicad"]).output().ok();+                let o = aiflow_sys::process::Command::new("adom-wiki").args(["api", "/api/v1/pages/adom/pcb-design-rules/files?path=kicad"]).output().ok();                 let v: Value = o.and_then(|o| serde_json::from_slice(&o.stdout).ok()).unwrap_or(Value::Null);                 let mut out: Vec<String> = v["files"].as_array().cloned().unwrap_or_default().iter().filter_map(|f| f["name"].as_str()).filter(|n| n.ends_with(".kicad_dru")).map(|n| n.trim_end_matches(".kicad_dru").to_string()).collect();                 out.sort(); out@@ -8065,7 +8068,7 @@ fn main() {             let shown = if slug == "adom-3rdpartyfab" { "3rdPartyFab".to_string() } else { slug.clone() };             let variant = variant.clone().map(|v| v.trim().to_ascii_lowercase()).filter(|v| !v.is_empty());             let file = match &variant { Some(v) => format!("{slug}-{layers}L-{v}.kicad_dru"), None => format!("{slug}-{layers}L.kicad_dru") };-            let o = std::process::Command::new("adom-wiki").args(["repo", "show", page, &format!("kicad/{file}")]).output();+            let o = aiflow_sys::process::Command::new("adom-wiki").args(["repo", "show", page, &format!("kicad/{file}")]).output();             let text = o.ok().filter(|o| o.status.success()).map(|o| String::from_utf8_lossy(&o.stdout).to_string()).filter(|t| t.contains("(rule")).unwrap_or_else(|| {                 let l = list();                 let near: Vec<&String> = l.iter().filter(|n| n.starts_with(&format!("{slug}-{layers}L"))).collect();@@ -8256,15 +8259,15 @@ fn main() {                     // A read-only check of this run's selected project rules is proof too.                     // Do not rewrite custom rules, or qualify a different board/profile.                     if let Some(mut r) = run {-                        let same_board = std::fs::canonicalize(&board_path).ok()-                            .zip(std::fs::canonicalize(r.current_board()).ok())+                        let same_board = aiflow_sys::canonicalize(&board_path).ok()+                            .zip(aiflow_sys::canonicalize(r.current_board()).ok())                             .is_some_and(|(a, b)| a == b);                         let same_profile = checks::rules_target(&spec_of(&r), &r.data["fabRules"])                             .is_some_and(|t| t.0 == profile);                         let dru = Path::new(&board_path).with_extension("kicad_dru");                         let selected_dru = Path::new(&r.current_board()).with_extension("kicad_dru");-                        let same_rules = dru == selected_dru || std::fs::canonicalize(&dru).ok()-                            .zip(std::fs::canonicalize(&selected_dru).ok())+                        let same_rules = dru == selected_dru || aiflow_sys::canonicalize(&dru).ok()+                            .zip(aiflow_sys::canonicalize(&selected_dru).ok())                             .is_some_and(|(a, b)| a == b);                         if same_board && same_profile && same_rules {                             let nc_ok = nc_check.as_ref().map(|v| v["pass"] != false).unwrap_or(true);@@ -8449,7 +8452,7 @@ fn main() {                             break;                         }                     }-                    let save_to = std::fs::canonicalize(&dir).unwrap_or(dir.clone()).display().to_string();+                    let save_to = aiflow_sys::canonicalize(&dir).unwrap_or(dir.clone()).display().to_string();                     // the editor clip of this step visit is not the walkthrough: discard it, the viewer is the camera                     let caps = r.data["captures"].as_array().cloned().unwrap_or_default();                     let (step, visit) = (r.data["currentStep"].as_str().unwrap_or("3d").to_string(), r.data["steps"][r.data["currentStep"].as_str().unwrap_or("3d")]["visits"].as_array().map(|a| a.len()).unwrap_or(1));@@ -8510,7 +8513,7 @@ fn main() {                     }                     if list.is_empty() { err("no nets to tour: the spec has no loads, wideNets or kelvin, and --nets was not given", &[]); }                     r.stage_start("tour-nets", Some("binary"), None);-                    let save_to = std::fs::canonicalize(&dir).unwrap_or(dir.clone()).display().to_string();+                    let save_to = aiflow_sys::canonicalize(&dir).unwrap_or(dir.clone()).display().to_string();                     let (step, visit) = (r.data["currentStep"].as_str().unwrap_or("nets").to_string(), r.data["steps"][r.data["currentStep"].as_str().unwrap_or("nets")]["visits"].as_array().map(|a| a.len()).unwrap_or(1));                     let mut toured: Vec<Value> = Vec::new();                     // PR #65 (Drew): frame with kicad_zoom_to where the bridge has it, the menu key otherwise, and keep the replies@@ -8546,14 +8549,14 @@ fn main() {                 "fields" => {                     // the fields step: adom-fields solved the board and serves it; a pup window on the test                     // box shows it, the recorder films that window while `adom-fields tour` drives it-                    let health = std::process::Command::new("adom-fields").args(["health", "--port", &port.to_string()]).output().map(|o| o.status.success()).unwrap_or(false);+                    let health = aiflow_sys::process::Command::new("adom-fields").args(["health", "--port", &port.to_string()]).output().map(|o| o.status.success()).unwrap_or(false);                     if !health { err(&format!("adom-fields is not serving on port {port}"), &["Solve and serve first: `adom-fields analyze --board <the current board> --spec <spec> --out fields` then `adom-fields serve --fields fields --port ".to_string() + &port.to_string() + " &` (adom-wiki pkg install adom/adom-fields if it is missing).".into()]); }                     // a server left up by an earlier run answers health just as well, and the walkthrough then                     // films that run's board (old models, missing parts): the solve served must be this run's-                    let served: Value = std::process::Command::new("curl").args(["-s", &format!("http://127.0.0.1:{port}/fields.json")]).output().ok().and_then(|o| serde_json::from_slice(&o.stdout).ok()).unwrap_or(Value::Null);+                    let served: Value = aiflow_sys::process::Command::new("curl").args(["-s", &format!("http://127.0.0.1:{port}/fields.json")]).output().ok().and_then(|o| serde_json::from_slice(&o.stdout).ok()).unwrap_or(Value::Null);                     if let Some(sb) = served["source"]["board"].as_str() {-                        let run_dir = std::fs::canonicalize(&dir).unwrap_or(dir.to_path_buf());-                        let board = std::fs::canonicalize(sb).unwrap_or_else(|_| PathBuf::from(sb));+                        let run_dir = aiflow_sys::canonicalize(&dir).unwrap_or(dir.to_path_buf());+                        let board = aiflow_sys::canonicalize(sb).unwrap_or_else(|_| PathBuf::from(sb));                         if !board.starts_with(&run_dir) {                             err(&format!("adom-fields on port {port} serves another run's solve ({sb}), not this run's board"), &[                                 format!("Stop that server (`pgrep -af \"adom-fields serve\"` names it; kill its pid), then solve this board and serve it: `adom-fields analyze --board <this run's board> --spec <spec> --out {}/fields` and `adom-fields serve --fields {}/fields --port {port} &`.", run_dir.display(), run_dir.display())]);@@ -8624,7 +8627,7 @@ fn main() {                     }                     // issue #209: target_not_found is the relay's answer for a machine name it does not know, not pup's                     if open_err.as_deref().is_some_and(|e| e.contains("target_not_found")) {-                        let known = std::process::Command::new("adom-bridge").arg("targets").output().ok().and_then(|o| serde_json::from_slice::<Value>(&o.stdout).ok()).map(|t| host_machine::names(&t)).unwrap_or_default();+                        let known = aiflow_sys::process::Command::new("adom-bridge").arg("targets").output().ok().and_then(|o| serde_json::from_slice::<Value>(&o.stdout).ok()).map(|t| host_machine::names(&t)).unwrap_or_default();                         err(&format!("Adom Bridge knows no machine named \"{}\", so the Fields window could not be opened there", br.target), &[format!("The machines it knows: {}. Film on the one running this workspace: `tour fields --port {port} --on <its name>`.", if known.is_empty() { "none listed (adom-bridge targets)".to_string() } else { known.join(", ") })]);                     }                     let Some(win) = hwnd else { let _ = br.call("pup_close_window", &json!({"sessionId": sid})); err(&format!("the app's window did not appear on {} (no window for this walkthrough session{})", br.target, open_err.map(|e| format!("; pup said {e}")).unwrap_or_default()), &["`adom-bridge --target <box> pup_readiness` says whether pup is ready there; a browser_gone means pup's browser died: `pup_close_window` the old sessions or restart pup on the box.".into(), match (preboard::proxy_is_local(&proxy), &host) {@@ -8632,7 +8635,7 @@ fn main() {                         (true, Some(h)) => format!("The URL {proxy} is a localhost proxy: only {h}, the machine running this container, can open it. `tour fields --port {port}` with no --on films there."),                         (true, None) => format!("The URL {proxy} is a localhost proxy: only the machine hosting this container can open it. `tour fields --on <that machine>`; ask the user which machine that is rather than guessing."),                         _ => String::new() }, on_note.clone()]); };-                    let save_to = std::fs::canonicalize(&dir).unwrap_or(dir.clone()).display().to_string();+                    let save_to = aiflow_sys::canonicalize(&dir).unwrap_or(dir.clone()).display().to_string();                     let (step, visit) = (r.data["currentStep"].as_str().unwrap_or("fields").to_string(), r.data["steps"][r.data["currentStep"].as_str().unwrap_or("fields")]["visits"].as_array().map(|a| a.len()).unwrap_or(1));                     // the editor clip of this visit is not the walkthrough: the app window is the camera                     let caps = r.data["captures"].as_array().cloned().unwrap_or_default();@@ -8671,13 +8674,13 @@ fn main() {                     // no pace of our own: the app holds each beat and drifts the board gently, because                     // this clip is played back at ten times speed                     // the app's tour runs about ten minutes; it is stopped before the take's own cap (issue #180)-                    let tour_ok = run_bounded(std::process::Command::new("adom-fields").args(["tour", "--port", &port.to_string()]), std::time::Duration::from_millis(FIELDS_TOUR_MAX_MS)).unwrap_or_else(|why| { note(&format!("the app's walkthrough {why}"), &[]); false });+                    let tour_ok = run_bounded(aiflow_sys::process::Command::new("adom-fields").args(["tour", "--port", &port.to_string()]), std::time::Duration::from_millis(FIELDS_TOUR_MAX_MS)).unwrap_or_else(|why| { note(&format!("the app's walkthrough {why}"), &[]); false });                     // the EMC beat after the app's own walkthrough: the hot loop, the return path under it and                     // the radiated estimate against FCC Part 15 class B, held long enough to read                     let ps = port.to_string();-                    let emc_ok = std::process::Command::new("adom-fields").args(["ui", "--port", &ps, "view", "--quantity", "emc", "--camera", "iso"]).output().map(|o| o.status.success()).unwrap_or(false);+                    let emc_ok = aiflow_sys::process::Command::new("adom-fields").args(["ui", "--port", &ps, "view", "--quantity", "emc", "--camera", "iso"]).output().map(|o| o.status.success()).unwrap_or(false);                     if emc_ok {-                        let _ = std::process::Command::new("adom-fields").args(["ui", "--port", &ps, "toast", "EMC: the switching loop, the ground under its return path, and the radiated estimate against FCC Part 15 class B"]).output();+                        let _ = aiflow_sys::process::Command::new("adom-fields").args(["ui", "--port", &ps, "toast", "EMC: the switching loop, the ground under its return path, and the radiated estimate against FCC Part 15 class B"]).output();                         std::thread::sleep(std::time::Duration::from_secs(20));                         r.log("fields-emc", json!({"step": step, "visit": visit}));                     }@@ -8702,7 +8705,7 @@ fn main() {                     let clips_note = auto_clips(&r, &dir);                     if !clips_note.is_empty() { eprintln!("{clips_note}"); }                     // the solved numbers ride the run: the issues are what the AI answers for-                    let fields: Value = std::process::Command::new("curl").args(["-s", &format!("http://127.0.0.1:{port}/fields.json")]).output().ok().and_then(|o| serde_json::from_slice(&o.stdout).ok()).unwrap_or(Value::Null);+                    let fields: Value = aiflow_sys::process::Command::new("curl").args(["-s", &format!("http://127.0.0.1:{port}/fields.json")]).output().ok().and_then(|o| serde_json::from_slice(&o.stdout).ok()).unwrap_or(Value::Null);                     let issues = fields["issues"].as_array().cloned().unwrap_or_default();                     r.stage_end("tour-fields", Some(json!({"issues": issues.len(), "tour": tour_ok})), None);                     if tour_ok {@@ -8784,7 +8787,7 @@ fn main() {                     if let Err(e) = fields_pitch::pitch(&spec_v) { err(&e, &[]); }                     args.extend(fields_pitch::args(&spec_v, fd["board"]["cellMm"].as_f64()));                     eprintln!("adom-fields {}", args.join(" "));-                    let st = std::process::Command::new("adom-fields").args(&args).status().unwrap_or_else(|e| err(&format!("adom-fields could not start: {e}"), &["Install adom-fields (adom-wiki pkg install adom/adom-fields).".into()]));+                    let st = aiflow_sys::process::Command::new("adom-fields").args(&args).status().unwrap_or_else(|e| err(&format!("adom-fields could not start: {e}"), &["Install adom-fields (adom-wiki pkg install adom/adom-fields).".into()]));                     if !st.success() { err(&format!("adom-fields verify failed ({st})"), &["Read what adom-fields printed above: KiCad's refill and DRC run through kicad-cli (service-kicad, or KiCad on the desktop through Adom Bridge).".into()]); }                     let vj = read_json(&out.join("verify.json").display().to_string());                     let o = fields_fix::read(&vj);@@ -9044,8 +9047,8 @@ fn main() {                     let helper = dir.join(".aiflow-project-steps.py");                     let _ = std::fs::write(&helper, include_str!("../../../tools/project-steps.py"));                     let log = std::fs::OpenOptions::new().create(true).append(true).open(dir.join("project-steps.log")).ok();-                    let mut c = std::process::Command::new("python3");-                    c.arg(&helper).arg(&dir).arg(pg).arg(pv).env("AIFLOW_FLOW_FILE", flow_file(&dir)).stdin(std::process::Stdio::null());+                    let mut c = aiflow_sys::process::Command::new("python3");+                    c.arg(&helper).arg(&dir).arg(pg).arg(pv).env("AIFLOW_FLOW_FILE", flow_file(&dir)).stdin(aiflow_sys::process::Stdio::null());                     if let Some(l) = log { if let Ok(l2) = l.try_clone() { c.stdout(l).stderr(l2); } }                     let _ = c.spawn();                 }@@ -9151,7 +9154,7 @@ fn main() {                 let caps = r.data["captures"].as_array().cloned().unwrap_or_default();                 if let Some(pos) = caps.iter().rposition(|c| c.get("recordingId").is_some() && c.get("file").is_none()) {                     let rid = caps[pos]["recordingId"].as_str().unwrap().to_string();-                    let save_to = std::fs::canonicalize(&dir).unwrap_or(dir.clone()).display().to_string();+                    let save_to = aiflow_sys::canonicalize(&dir).unwrap_or(dir.clone()).display().to_string();                     // the step's closing screenshot: what the board looked like when the step ended                     if let Some(h) = caps[pos]["hwnd"].as_i64() {                         let tag = format!("shot-{}-{}-end", caps[pos]["step"].as_str().unwrap_or("step"), caps[pos]["visit"].as_u64().unwrap_or(1));@@ -9239,7 +9242,7 @@ fn main() {                             // issue #155: a clip on a KiCad editor says which one, so a wrong window shows at once                             if pre_cam.is_none() && cam.id() == "kicad" { if let Some(t) = aiflow_bridge::editor_title(&br.raw_call("kicad_window_info", &json!({})), h) { if let Some(c) = r.data["captures"].as_array_mut().and_then(|a| a.last_mut()) { c["camera"] = json!(plain_title(&t)); } clip_note.push_str(&format!("filming KiCad's \"{t}\"; ")); } }                             r.mark(&format!("clip-start:{name}-{visit}"));-                            let save_to = std::fs::canonicalize(&dir).unwrap_or(dir.clone()).display().to_string();+                            let save_to = aiflow_sys::canonicalize(&dir).unwrap_or(dir.clone()).display().to_string();                             if let Some(pth) = br.screenshot_window(h, &save_to, &format!("shot-{name}-{visit}-start")) {                                 r.log("artifact", json!({"step": name, "visit": visit, "kind": "screenshot", "when": "start", "file": pth}));                             }@@ -9292,7 +9295,7 @@ fn main() {             print_next(&cli);         }         Cmd::ProjectPageCheck { project, live_json } => {-            let mut command = std::process::Command::new(aiflow_python());+            let mut command = aiflow_sys::process::Command::new(aiflow_python());             command.arg("-c").arg(include_str!("../../../tools/project-page-check.py")).arg("--project").arg(project);             if let Some(path) = live_json { command.arg("--live-json").arg(path); }             let output = command.output().unwrap_or_else(|e| err(&format!("project page check could not run: {e}"), &[]));@@ -9341,7 +9344,7 @@ fn main() {             record_usage(&mut r, "deliver");             r.data["summary"]["planUsage"] = json!(usage_delta(&r));             if let Some(a) = agy_report(&r) { r.data["summary"]["antigravity"] = a; }-            r.data["delivery"] = json!({"at": t, "video": std::fs::canonicalize(vp).map(|p| p.display().to_string()).unwrap_or(video.clone()), "videoBytes": bytes, "message": message});+            r.data["delivery"] = json!({"at": t, "video": aiflow_sys::canonicalize(vp).map(|p| p.display().to_string()).unwrap_or(video.clone()), "videoBytes": bytes, "message": message});             r.data["summary"]["promptToDeliveredMinutes"] = json!(r.delivered_minutes());             r.data["summary"]["verifiedAtDelivery"] = verified::snapshot(&checked, "deliver", &t);             r.data["summary"]["verified"] = r.data["summary"]["verifiedAtDelivery"].clone();@@ -9395,7 +9398,7 @@ mod netlist_freshness_tests {     use super::*;     #[test]     fn gate_rejects_child_only_edits_old_evidence_and_export_edits() {-        let dir=std::env::temp_dir().join(format!("aiflow-net-freshness-{}",std::process::id()));+        let dir=aiflow_sys::temp_dir().join(format!("aiflow-net-freshness-{}",aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let sch=dir.join("root.kicad_sch"); let child=dir.join("child.kicad_sch");         let net=dir.join("export.net"); let board=dir.join("board.kicad_pcb");@@ -9445,7 +9448,7 @@ mod clip_stop_tests {      #[test]     fn a_failed_pull_is_flagged_with_its_remote_path_not_a_local_file() {-        let dir = std::env::temp_dir().join(format!("aiflow-clipstop-a-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-clipstop-a-{}", aiflow_sys::process::id()));         let mut r = run_with_capture(&dir, json!({"recordingId": "rec-1", "step": "components", "visit": 1}));         let remote = "C:/Users/j/AppData/Local/Temp/adom-bridge-recordings/window-1.mp4";         assert_eq!(settle_clip_stop(&mut r, 0, &stop(Some(remote), false), &dir), None);@@ -9464,7 +9467,7 @@ mod clip_stop_tests {     #[test]     fn a_take_the_recorder_lost_is_flagged_pull_failed_with_the_reason() {         // issue #98: "No recording with id" ends the stop with a flag, not a wait-        let dir = std::env::temp_dir().join(format!("aiflow-clipstop-c-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-clipstop-c-{}", aiflow_sys::process::id()));         let mut r = run_with_capture(&dir, json!({"recordingId": "rec-3", "step": "fields", "visit": 1}));         let mut lost = stop(None, false);         lost.reply = json!({"aiflowStopError": "Adom Bridge no longer knows recording rec-3", "aiflowStopPending": false});@@ -9482,7 +9485,7 @@ mod clip_stop_tests {      #[test]     fn a_second_stop_never_blanks_the_first_stops_file() {-        let dir = std::env::temp_dir().join(format!("aiflow-clipstop-b-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-clipstop-b-{}", aiflow_sys::process::id()));         let local = dir.join("window-2.mp4").display().to_string();         let mut r = run_with_capture(&dir, json!({"recordingId": "rec-2", "step": "placement", "visit": 1, "stop": "2026-09-29T02:43:48Z", "file": local, "remoteFile": "C:/rec/window-2.mp4"}));         std::fs::write(&local, b"mp4").unwrap();@@ -9516,7 +9519,7 @@ mod media_tools_tests {      #[test]     fn a_clip_is_left_unjudged_when_the_tools_are_missing() {-        let dir = std::env::temp_dir().join(format!("aiflow-media-tools-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-media-tools-{}", aiflow_sys::process::id()));         let _ = std::fs::remove_dir_all(&dir);         std::fs::create_dir_all(&dir).unwrap();         let file = dir.join("placement-1.mp4").display().to_string();@@ -9531,8 +9534,8 @@ mod media_tools_tests {     }      fn media_fixture(tag: &str, name: &str, args: &[&str]) -> Option<(PathBuf, String)> {-        for t in MEDIA_TOOLS { if std::process::Command::new(t).arg("-version").output().is_err() { return None; } }-        let dir = std::env::temp_dir().join(format!("aiflow-{tag}-{}", std::process::id()));+        for t in MEDIA_TOOLS { if aiflow_sys::process::Command::new(t).arg("-version").output().is_err() { return None; } }+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-{tag}-{}", aiflow_sys::process::id()));         let _ = std::fs::remove_dir_all(&dir);         std::fs::create_dir_all(&dir).unwrap();         let f = dir.join(name);@@ -9540,7 +9543,7 @@ mod media_tools_tests {         a.extend_from_slice(args);         let fs = f.display().to_string();         a.push(&fs);-        assert!(std::process::Command::new("ffmpeg").args(&a).status().unwrap().success(), "fixture {name}");+        assert!(aiflow_sys::process::Command::new("ffmpeg").args(&a).status().unwrap().success(), "fixture {name}");         Some((dir, fs))     } @@ -9615,7 +9618,7 @@ mod media_tools_tests {     /// Issue #146: the Fields segment's narration is the viewer's own explanation, in the tour's view order.     #[test]     fn the_fields_segment_says_what_the_viewer_explained() {-        let dir = std::env::temp_dir().join(format!("aiflow-narr-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-narr-{}", aiflow_sys::process::id()));         let n = dir.join("fields").join("narration");         std::fs::create_dir_all(&n).unwrap();         std::fs::write(n.join("heat-bbb.json"), json!({"text": "This is temperature rise. U1 runs 31 degrees over ambient."}).to_string()).unwrap();@@ -9659,7 +9662,7 @@ mod media_tools_tests {     /// Issue #170/#180: a clip over the deferral size is not checked or cut inside an engineering command.     #[test]     fn a_big_clip_waits_for_recut_or_compose() {-        let dir = std::env::temp_dir().join(format!("aiflow-defer-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-defer-{}", aiflow_sys::process::id()));         let _ = std::fs::create_dir_all(&dir);         let f = dir.join("big.mp4");         std::fs::write(&f, vec![0u8; 2_500_000]).unwrap();@@ -9674,7 +9677,7 @@ mod media_tools_tests {     /// Issue #180: AIFLOW_AUTO_CAPTURE=off starts no tour recording (and asks no bridge anything).     #[test]     fn a_tour_records_nothing_when_auto_capture_is_off() {-        let dir = std::env::temp_dir().join(format!("aiflow-tour-off-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-tour-off-{}", aiflow_sys::process::id()));         let _ = std::fs::create_dir_all(&dir);         let mut r = Run { dir: dir.clone(), data: json!({"captures": [], "currentStep": "fields"}) };         let br = Bridge { ai_thread: "test".into(), target: "aiflow-no-such-box".into() };@@ -9690,11 +9693,11 @@ mod media_tools_tests {     /// Issue #180: every tour's child process has a stop condition.     #[test]     fn a_tour_child_is_stopped_at_its_limit() {-        assert_eq!(run_bounded(&mut std::process::Command::new("true"), std::time::Duration::from_secs(5)), Ok(true));+        assert_eq!(run_bounded(&mut aiflow_sys::process::Command::new("true"), std::time::Duration::from_secs(5)), Ok(true));         let t0 = std::time::Instant::now();-        let e = run_bounded(std::process::Command::new("sleep").arg("20"), std::time::Duration::from_millis(400)).unwrap_err();+        let e = run_bounded(aiflow_sys::process::Command::new("sleep").arg("20"), std::time::Duration::from_millis(400)).unwrap_err();         assert!(e.contains("stopped") && t0.elapsed().as_secs() < 5, "{e}");-        assert!(run_bounded(&mut std::process::Command::new("aiflow-no-such-tool"), std::time::Duration::from_secs(1)).is_err());+        assert!(run_bounded(&mut aiflow_sys::process::Command::new("aiflow-no-such-tool"), std::time::Duration::from_secs(1)).is_err());     } } @@ -9708,7 +9711,7 @@ mod compose_out_tests {     fn the_video_is_kept_at_1080p_and_its_overlays_keep_their_size() {         assert_eq!(CUT_SCALE, "scale='min(1920,iw)':-2", "a cut is never enlarged and never below the video's width");         assert!(VIDEO_CEILING_BYTES > 50_000_000 && VIDEO_CEILING_BYTES < 100_000_000, "under the wiki's limit, far over the old 10 MB");-        let d = std::env::temp_dir().join(format!("aiflow-146-{}", std::process::id()));+        let d = aiflow_sys::temp_dir().join(format!("aiflow-146-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&d).unwrap();         let f = overlay_filters(&d, "ROUTING", "claude   ยท   board", 0.0, 0.0, false);         assert!(f.starts_with("scale=1920:-2,"), "{}", &f[..40]);@@ -9744,10 +9747,10 @@ mod compose_out_tests {      #[test]     fn a_failed_ffmpeg_keeps_its_stderr() {-        assert!(!ffmpeg_ok(std::process::Command::new("sh").args(["-c", "echo first >&2; echo 'Error opening output file' >&2; exit 1"])));+        assert!(!ffmpeg_ok(aiflow_sys::process::Command::new("sh").args(["-c", "echo first >&2; echo 'Error opening output file' >&2; exit 1"])));         let kept = FFMPEG_LAST_ERROR.with(|l| l.borrow().clone());         assert!(kept.contains("Error opening output file"), "{kept}");-        assert!(ffmpeg_ok(std::process::Command::new("sh").args(["-c", "exit 0"])));+        assert!(ffmpeg_ok(aiflow_sys::process::Command::new("sh").args(["-c", "exit 0"])));     } } 
crates/adom-aiflow/src/mechanical.rs+3−3
@@ -516,7 +516,7 @@ pub fn declared_bodies(b: &Board, spec: &Value) -> (Vec<String>, Vec<String>) { pub(crate) mod tests {     #[test]     fn fusion_renderings_skip_the_courtyard_checks() {-        let dir = std::env::temp_dir().join(format!("aiflow-mech-fusion-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-mech-fusion-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let fusion = dir.join("board-0.kicad_pcb");         std::fs::write(&fusion, "(kicad_pcb (version 20241229) (generator \"adom-aiflow-fusion\") (generator_version \"1\")\n)").unwrap();@@ -721,7 +721,7 @@ pub(crate) mod tests {      #[test]     fn ignored_courtyard_severities_are_reported() {-        let dir = std::env::temp_dir().join(format!("aiflow-mech-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-mech-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         std::fs::write(dir.join("b.kicad_pro"), r#"{"board":{"design_settings":{"rule_severities":{"courtyards_overlap":"ignore","missing_courtyard":"ignore"}}}}"#).unwrap();         let notes = project_severities(&dir.join("b.kicad_pcb").display().to_string());@@ -741,7 +741,7 @@ mod altium_render_probe {         let mut v: serde_json::Value = serde_json::from_str(&std::fs::read_to_string(&read).unwrap()).unwrap();         if let Ok(p) = std::env::var("AIFLOW_PROBE_PROJECT") { v["projectDir"] = serde_json::json!(p); }         let text = aiflow_board::altium::render_plan_board(&v.to_string()).unwrap();-        let out = std::env::temp_dir().join("probe.kicad_pcb");+        let out = aiflow_sys::temp_dir().join("probe.kicad_pcb");         std::fs::write(&out, &text).unwrap();         let b = aiflow_board::Board::from_text(&out.display().to_string(), text).unwrap();         let rep = super::check(&b, &out.display().to_string(), &|_| None);
crates/adom-aiflow/src/netclasses.rs+2−2
@@ -846,7 +846,7 @@ mod tests {      #[test]     fn verify_kicad_catches_missing_and_drifted_netclasses_then_passes_after_sync() {-        let td = std::env::temp_dir().join(format!("aiflow-nc-test-{}", std::process::id()));+        let td = aiflow_sys::temp_dir().join(format!("aiflow-nc-test-{}", aiflow_sys::process::id()));         let _ = std::fs::create_dir_all(&td);         let bp = td.join("board.kicad_pcb");         std::fs::write(&bp, "(kicad_pcb)").unwrap();@@ -880,7 +880,7 @@ mod tests {         // Real-board regression (argon-aiflow / astra-aiflow / opus-aiflow):         // wideNets/midNets arrays like [1.2, 0.8, 0.5, 0.25] must enforce min 0.25 mm in DRU         // (preferred 1.2 mm in .kicad_pro), and must not inflate clearance above .kicad_pro Default.-        let td = std::env::temp_dir().join(format!("aiflow-nc-ladder-{}", std::process::id()));+        let td = aiflow_sys::temp_dir().join(format!("aiflow-nc-ladder-{}", aiflow_sys::process::id()));         let _ = std::fs::remove_dir_all(&td);         std::fs::create_dir_all(&td).unwrap();         let bp = td.join("opus.kicad_pcb");
crates/adom-aiflow/src/page_results.rs+2−2
@@ -283,7 +283,7 @@ mod tests {      #[test]     fn build_writes_numbers_figures_contacts_and_parts() {-        let tmp = std::env::temp_dir().join(format!("aiflow-page-results-{}", std::process::id()));+        let tmp = aiflow_sys::temp_dir().join(format!("aiflow-page-results-{}", aiflow_sys::process::id()));         let _ = std::fs::remove_dir_all(&tmp);         std::fs::create_dir_all(&tmp).unwrap();         let fig = tmp.join("density.png");@@ -337,7 +337,7 @@ mod tests {     /// Issue #211: the page says which steps were skipped or replaced, and who decided; or that every step ran.     #[test]     fn the_page_lists_skipped_and_replaced_steps() {-        let tmp = std::env::temp_dir().join(format!("aiflow-page-gaps-{}", std::process::id()));+        let tmp = aiflow_sys::temp_dir().join(format!("aiflow-page-gaps-{}", aiflow_sys::process::id()));         let read = |data: &serde_json::Value| { let b = build(data, &[], None, "", None, None, false, &tmp, None, "t").unwrap(); std::fs::read_to_string(tmp.join(&b.files[0])).unwrap() };         let gaps = serde_json::json!({"clock": {"finishTime": "t"}, "summary": {"open": [], "flowGaps": [{"step": "nets", "kind": "skipped", "decidedBy": "ai", "why": "a simple breakout board"}]}});         let md = read(&gaps);
crates/adom-aiflow/src/placement_verify.rs+1−1
@@ -499,7 +499,7 @@ mod tests {     }     #[test]     fn proof_is_invalid_after_board_or_spec_change_or_deletion() {-        let dir=std::env::temp_dir().join(format!("aiflow-place-binding-{}",std::process::id()));+        let dir=aiflow_sys::temp_dir().join(format!("aiflow-place-binding-{}",aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();let b=dir.join("b");let s=dir.join("s");         std::fs::write(&b,"board").unwrap();std::fs::write(&s,"spec").unwrap();         let proof=json!({"ok":true,"boardSha256":digest(&b).unwrap(),"specSha256":digest(&s).unwrap()});
crates/adom-aiflow/src/pourverify.rs+4−4
@@ -744,7 +744,7 @@ pub fn zones_changed_at(data: &Value) -> Result<(u64, String), String> { /// the zones it describes change (`verify-pours --record-plan`). pub fn record_plan(data: &mut Value, path: &Path, source: &str) -> Result<Value, String> {     let sha = hash(path).map_err(|e| format!("{}: {e}", path.display()))?;-    let canon = std::fs::canonicalize(path).map_err(|e| format!("{}: {e}", path.display()))?;+    let canon = aiflow_sys::canonicalize(path).map_err(|e| format!("{}: {e}", path.display()))?;     let mut entry = json!({"source": source, "sha256": sha, "path": canon, "at": aiflow_run::now()});     if source == "reviewed" {         if let Some(b) = data["boards"].as_array().and_then(|a| a.last()).and_then(Value::as_str) {@@ -1005,7 +1005,7 @@ pub fn command(r: &mut Run, dir: &Path, plan: Option<&str>, from_board: bool, ad     proof["boardSha256"] = json!(board_hash);     proof["specSha256"] = json!(hash(Path::new(r.data["spec"].as_str().unwrap_or(""))).map_err(e)?);     proof["planSha256"] = json!(plan_hash);-    proof["plan"] = json!(std::fs::canonicalize(plan).map_err(|x| e(x.to_string()))?);+    proof["plan"] = json!(aiflow_sys::canonicalize(plan).map_err(|x| e(x.to_string()))?);     if proof["pass"] == true && adopt_zones {         let ids = adopt(&mut r.data, &proof, why.unwrap_or("")).map_err(e)?;         proof["mode"] = json!("adopted-existing");@@ -1247,7 +1247,7 @@ mod tests {     }     #[test]     fn changed_file_invalidates_binding() {-        let dir = std::env::temp_dir().join(format!("aiflow-pour-binding-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-pour-binding-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let b = dir.join("board");         let p = dir.join("plan");@@ -1401,7 +1401,7 @@ mod tests {      // -- issue #57: plan provenance ---------------------------------------------------------------     fn tmpdir(name: &str) -> std::path::PathBuf {-        let d = std::env::temp_dir().join(format!("aiflow-pour-prov-{name}-{}", std::process::id()));+        let d = aiflow_sys::temp_dir().join(format!("aiflow-pour-prov-{name}-{}", aiflow_sys::process::id()));         let _ = std::fs::remove_dir_all(&d);         std::fs::create_dir_all(&d).unwrap();         d
crates/adom-aiflow/src/preboard.rs+4−4
@@ -596,9 +596,9 @@ pub fn primary_from_targets(v: &Value) -> Option<String> {  /// One still from a clip for its poster: a frame 40 percent in, 1280 wide, JPEG. fn make_poster(clip: &Path, out: &Path) {-    let dur = std::process::Command::new("ffprobe").args(["-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0"]).arg(clip).output().ok()+    let dur = aiflow_sys::process::Command::new("ffprobe").args(["-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0"]).arg(clip).output().ok()         .and_then(|o| String::from_utf8_lossy(&o.stdout).trim().parse::<f64>().ok()).unwrap_or(0.0);-    let _ = std::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-threads", "2", "-ss", &format!("{:.2}", dur * 0.4), "-i"]).arg(clip)+    let _ = aiflow_sys::process::Command::new("ffmpeg").args(["-v", "error", "-y", "-threads", "2", "-ss", &format!("{:.2}", dur * 0.4), "-i"]).arg(clip)         .args(["-frames:v", "1", "-vf", "scale=1280:-2", "-q:v", "3"]).arg(out).status(); } @@ -849,7 +849,7 @@ mod tests {      #[test]     fn clips_page_paths_and_states() {-        let dir = std::env::temp_dir().join(format!("aiflow-clips-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-clips-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         for f in ["window-1-20260929-010000.mp4", "window-1-20260929-010000-10x.mp4", "window-1-20260929-010000-sheet.png", "window-1-20260929-010000-action.mp4", "window-9-20260929-020000.mp4"] { std::fs::write(dir.join(f), b"x").unwrap(); }         let data = json!({"clock": {"promptTime": "2026-09-29T00:00:00Z"}, "captures": [@@ -1110,7 +1110,7 @@ mod bom_parts_tests {      #[test]     fn a_brief_that_names_a_file_is_read() {-        let f = std::env::temp_dir().join(format!("aiflow-brief-{}.md", std::process::id()));+        let f = aiflow_sys::temp_dir().join(format!("aiflow-brief-{}.md", aiflow_sys::process::id()));         std::fs::write(&f, "# Buck\n\nA 12 V to 5 V buck.\n").unwrap();         assert_eq!(brief_text(f.to_str().unwrap()), "# Buck\n\nA 12 V to 5 V buck.");         assert_eq!(brief_text("design/brief-that-does-not-exist.md"), "design/brief-that-does-not-exist.md");
crates/adom-aiflow/src/project_lib.rs+2−2
@@ -112,7 +112,7 @@ impl ProjectLib {             _ => {}         }         if !why.is_empty() { return Err(why); }-        let abs = |p: &Path| std::fs::canonicalize(p).unwrap_or_else(|_| p.to_path_buf()).display().to_string();+        let abs = |p: &Path| aiflow_sys::canonicalize(p).unwrap_or_else(|_| p.to_path_buf()).display().to_string();         Ok(json!({"dir": abs(&self.dir), "symbol": sym_name, "symbolFile": abs(&sym.unwrap().file), "footprint": fp_name, "footprintFile": abs(&fp.unwrap().file),                   "model": abs(model.as_ref().unwrap()), "source": source, "provenance": e}))     }@@ -246,7 +246,7 @@ mod tests {     }      fn tmp(name: &str) -> PathBuf {-        let d = std::env::temp_dir().join(format!("aiflow-projlib-{name}-{}", std::process::id()));+        let d = aiflow_sys::temp_dir().join(format!("aiflow-projlib-{name}-{}", aiflow_sys::process::id()));         let _ = std::fs::remove_dir_all(&d);         d     }
crates/adom-aiflow/src/remote_binding.rs+1−1
@@ -62,7 +62,7 @@ mod tests {     }     #[test]     fn mismatch_missing_rules_and_changed_snapshot_refuse() {-        let d = std::env::temp_dir().join(format!("remote-bind-{}", std::process::id()));+        let d = aiflow_sys::temp_dir().join(format!("remote-bind-{}", aiflow_sys::process::id()));         let _ = std::fs::remove_dir_all(&d);         std::fs::create_dir_all(d.join("pull")).unwrap();         let local = d.join("local.kicad_pcb");
crates/adom-aiflow/src/reviews.rs+9−9
@@ -102,7 +102,7 @@ fn geometry_binding(input: &Path, iv: &Value, board: &Path) -> Result<Value, Str     for key in ["request", "report"] {         let name = evidence[key].as_str().filter(|s| !s.trim().is_empty())             .ok_or_else(|| format!("geometryEvidence.{key} is missing"))?;-        let path = std::fs::canonicalize(resolve(input, name)).map_err(|e| e.to_string())?;+        let path = aiflow_sys::canonicalize(resolve(input, name)).map_err(|e| e.to_string())?;         let value: Value = serde_json::from_slice(&std::fs::read(&path).map_err(|e| e.to_string())?)             .map_err(|e| e.to_string())?;         binding.insert(key.into(), json!({"path": path, "sha256": sha256_file(&path)?}));@@ -118,7 +118,7 @@ fn geometry_binding(input: &Path, iv: &Value, board: &Path) -> Result<Value, Str     }     for key in ["board", "assembly"] {         let name = request[key]["path"].as_str().ok_or_else(|| format!("geometry request lacks {key} path"))?;-        let path = std::fs::canonicalize(resolve(request_path, name)).map_err(|e| e.to_string())?;+        let path = aiflow_sys::canonicalize(resolve(request_path, name)).map_err(|e| e.to_string())?;         let hash = sha256_file(&path)?;         if request[key]["sha256"].as_str() != Some(&hash)             || report["inputs"][key]["sha256"].as_str() != Some(&hash) {@@ -204,10 +204,10 @@ pub fn find_tool(k: &Kind) -> Result<Tool, String> { /// Run `tool <args>`: (exit code, stdout JSON or null, stderr). pub fn run_tool(tool: &Tool, args: &[&str]) -> Result<(i32, Value, String), String> {     let mut c = match tool {-        Tool::Exe(p) => std::process::Command::new(p),-        Tool::Cargo(d) => { let mut c = std::process::Command::new("cargo"); c.args(["run", "--release", "--quiet", "--manifest-path"]).arg(d.join("Cargo.toml")).arg("--"); c }+        Tool::Exe(p) => aiflow_sys::process::Command::new(p),+        Tool::Cargo(d) => { let mut c = aiflow_sys::process::Command::new("cargo"); c.args(["run", "--release", "--quiet", "--manifest-path"]).arg(d.join("Cargo.toml")).arg("--"); c }     };-    let o = c.args(args).stdin(std::process::Stdio::null()).output().map_err(|e| format!("could not run the review tool: {e}"))?;+    let o = c.args(args).stdin(aiflow_sys::process::Stdio::null()).output().map_err(|e| format!("could not run the review tool: {e}"))?;     let v = serde_json::from_slice(&o.stdout).unwrap_or(Value::Null);     Ok((o.status.code().unwrap_or(-1), v, String::from_utf8_lossy(&o.stderr).trim().to_string())) }@@ -247,7 +247,7 @@ pub fn run(r: &mut Run, name: &str, input: Option<&str>, glb: Option<&str>) -> R         (None, Some(d)) => resolve(&d.source, d.decl["input"].as_str().unwrap_or("")),         (None, None) => return Err((format!("review {name} needs --input <review.json> (the spec declares no {})", k.key), vec![contract_hint(k)])),     };-    let input = std::fs::canonicalize(&input).unwrap_or(input);+    let input = aiflow_sys::canonicalize(&input).unwrap_or(input);     let iv: Value = std::fs::read_to_string(&input).map_err(|e| format!("{}: {e}", input.display())).and_then(|t| serde_json::from_str(&t).map_err(|e| format!("{}: {e}", input.display())))         .map_err(|e| (e, vec![contract_hint(k)]))?;     if iv["schemaVersion"].as_u64() != Some(SCHEMA_VERSION) { return Err((format!("{} has schemaVersion {} (AI Flow review contract {SCHEMA_VERSION} needs \"schemaVersion\": {SCHEMA_VERSION} at the top level)", input.display(), iv["schemaVersion"]), vec![contract_hint(k)])); }@@ -332,7 +332,7 @@ pub fn binding_gaps(data: &Value, d: &Declared, board: &Path) -> Vec<String> {     if o["pass"] != true || o["schemaVersion"].as_u64() != Some(SCHEMA_VERSION) { return vec![format!("{} review did not pass ({again})", k.name)]; }     let mut out = Vec::new();     let input = resolve(&d.source, d.decl["input"].as_str().unwrap_or(""));-    let input = std::fs::canonicalize(&input).unwrap_or(input);+    let input = aiflow_sys::canonicalize(&input).unwrap_or(input);     if o["input"].as_str() != Some(input.display().to_string().as_str()) { out.push(format!("{} review was run on {} but the spec declares {} ({again})", k.name, o["input"].as_str().unwrap_or("?"), input.display())); }     else if o["inputSha256"].as_str() != sha256_file(&input).ok().as_deref() { out.push(format!("{} review file changed since the review ({again})", k.name)); }     if let Some(s) = data["spec"].as_str().filter(|s| !s.is_empty()) {@@ -418,7 +418,7 @@ mod tests {     }     struct T { dir: PathBuf }     impl T {-        fn new(name: &str) -> T { let dir = std::env::temp_dir().join(format!("aiflow-reviews-{name}-{}", std::process::id())); let _ = std::fs::remove_dir_all(&dir); std::fs::create_dir_all(&dir).unwrap(); T { dir } }+        fn new(name: &str) -> T { let dir = aiflow_sys::temp_dir().join(format!("aiflow-reviews-{name}-{}", aiflow_sys::process::id())); let _ = std::fs::remove_dir_all(&dir); std::fs::create_dir_all(&dir).unwrap(); T { dir } }         fn write(&self, n: &str, t: &str) -> PathBuf { let p = self.dir.join(n); std::fs::write(&p, t).unwrap(); p }     }     impl Drop for T { fn drop(&mut self) { let _ = std::fs::remove_dir_all(&self.dir); } }@@ -434,7 +434,7 @@ mod tests {     fn mech_input() -> String { json!({"schemaVersion": 1, "fasteners": [{"id": "s1", "ref": "H1"}]}).to_string() }      fn record_pass(r: &mut Run, t: &T) {-        let input = std::fs::canonicalize(t.dir.join("mech.json")).unwrap();+        let input = aiflow_sys::canonicalize(t.dir.join("mech.json")).unwrap();         let spec = r.data["spec"].as_str().unwrap().to_string();         let board = r.current_board();         r.outcome("mechanical-review", json!({"schemaVersion": 1, "pass": true, "input": input.display().to_string(), "inputSha256": sha256_file(&input).unwrap(),
crates/adom-aiflow/src/rules_card.rs+1−1
@@ -340,7 +340,7 @@ mod tests {      #[test]     fn the_card_merges_into_the_presentation() {-        let dir = std::env::temp_dir().join(format!("aiflow-rules-card-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-rules-card-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(dir.join("timeline")).unwrap();         std::fs::write(dir.join("timeline/presentation.json"), r#"{"caption":"kept"}"#).unwrap();         let (v, flags) = card(&json!({"track": 0.025}), None, &Lane::generic("fab"), None);
crates/adom-aiflow/src/schematic_check.rs+5−5
@@ -44,9 +44,9 @@ pub fn erc_errors(report: &Path) -> Result<(Value, Vec<String>), String> { /// `report` and read it. A report from an earlier run is removed first so it cannot stand in for this one. pub fn run_erc(cli: &str, sch: &str, report: &Path) -> Result<(Value, Vec<String>), String> {     let _ = std::fs::remove_file(report);-    let o = std::process::Command::new(cli)+    let o = aiflow_sys::process::Command::new(cli)         .args(["sch", "erc", "--format", "json", "--severity-all", "--output"]).arg(report).arg(sch)-        .stdin(std::process::Stdio::null()).output()+        .stdin(aiflow_sys::process::Stdio::null()).output()         .map_err(|e| format!("{cli} is not runnable: {e}"))?;     erc_errors(report).map_err(|e| {         let tail = |b: &[u8]| aiflow_run::clip_text(&String::from_utf8_lossy(b), 400);@@ -110,7 +110,7 @@ mod tests {      #[test]     fn missing_or_unreadable_erc_report_is_refused() {-        let dir = std::env::temp_dir().join(format!("aiflow-erc-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-erc-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let rep = dir.join("erc.json");         assert!(erc_errors(&rep).unwrap_err().contains("ERC did not run"));@@ -131,7 +131,7 @@ mod tests {     #[test]     fn erc_that_writes_no_report_fails() {         use std::os::unix::fs::PermissionsExt;-        let dir = std::env::temp_dir().join(format!("aiflow-erc-run-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-erc-run-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let cli = dir.join("kicad-cli");         std::fs::write(&cli, "#!/bin/sh\necho \"only 'pcb drc' is supported\" >&2\nexit 2\n").unwrap();@@ -147,7 +147,7 @@ mod tests {     /// instance reference too; power symbols (#PWR) and unannotated ones (R?) are not parts.     #[test]     fn off_board_symbols_are_read_from_the_sheet_files() {-        let d = std::env::temp_dir().join(format!("aiflow-sch-{}", std::process::id()));+        let d = aiflow_sys::temp_dir().join(format!("aiflow-sch-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(d.join("sub")).unwrap();         std::fs::write(d.join("root.kicad_sch"), r##"(kicad_sch (symbol (lib_id "Device:Battery") (exclude_from_board yes) (property "Reference" "BT1" (at 0 0 0)))   (symbol (lib_id "power:GND") (property "Reference" "#PWR01" (at 0 0 0))) (symbol (lib_id "Device:R") (property "Reference" "R?" (at 0 0 0))))"##).unwrap();
crates/adom-aiflow/src/schematic_identity.rs+3−3
@@ -5,7 +5,7 @@ use aiflow_board::sx; use sha2::{Digest, Sha256};  pub fn capture(root: &Path) -> Result<BTreeMap<String, String>, String> {-    let root = root.canonicalize().map_err(|e| format!("{}: {e}", root.display()))?;+    let root = aiflow_sys::canonicalize(root).map_err(|e| format!("{}: {e}", root.display()))?;     let project = root.parent().ok_or("schematic has no parent")?;     let mut result = BTreeMap::new();     visit(&root, project, &mut BTreeSet::new(), &mut result)?;@@ -13,7 +13,7 @@ pub fn capture(root: &Path) -> Result<BTreeMap<String, String>, String> { }  fn visit(path: &Path, project: &Path, active: &mut BTreeSet<PathBuf>, result: &mut BTreeMap<String, String>) -> Result<(), String> {-    let path = path.canonicalize().map_err(|e| format!("{}: {e}", path.display()))?;+    let path = aiflow_sys::canonicalize(path).map_err(|e| format!("{}: {e}", path.display()))?;     if active.contains(&path) { return Err(format!("cyclic schematic hierarchy: {}", path.display())); }     let key = path.to_str().ok_or("non-UTF8 schematic path")?.to_string();     if result.contains_key(&key) { return Ok(()); }@@ -43,7 +43,7 @@ mod tests {     impl Fixture {         fn new() -> Self {             static NEXT: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);-            let p = std::env::temp_dir().join(format!("aiflow-sch-{}-{}", std::process::id(), NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed)));+            let p = aiflow_sys::temp_dir().join(format!("aiflow-sch-{}-{}", aiflow_sys::process::id(), NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed)));             std::fs::create_dir_all(&p).unwrap(); Self(p)         }         fn write(&self, name: &str, text: &str) { let p=self.0.join(name); std::fs::create_dir_all(p.parent().unwrap()).unwrap(); std::fs::write(p,text).unwrap(); }
crates/adom-aiflow/src/schematic_symbols.rs+1−1
@@ -719,7 +719,7 @@ mod tests {     impl Fixture {         fn new() -> Self {             static NEXT: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);-            let p = std::env::temp_dir().join(format!("aiflow-schck-{}-{}", std::process::id(), NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed)));+            let p = aiflow_sys::temp_dir().join(format!("aiflow-schck-{}-{}", aiflow_sys::process::id(), NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed)));             std::fs::create_dir_all(&p).unwrap(); Self(p)         }         fn write(&self, name: &str, text: &str) -> std::path::PathBuf { let p = self.0.join(name); std::fs::write(&p, text).unwrap(); p }
crates/adom-aiflow/src/sequence.rs+10−10
@@ -108,7 +108,7 @@ pub fn label(dir: &Path, data: &Value) -> String {     }     if let Some(t) = original_board(data).and_then(|b| { let f = b.rsplit(['/', '\\']).next().unwrap_or(&b).to_string(); Path::new(&f).file_stem().and_then(|s| s.to_str()).map(str::to_string) }).and_then(|s| usable(&s)) { return t; }     if let Some(t) = brief_line(data).and_then(|s| usable(&s)) { return t; }-    let canon = std::fs::canonicalize(dir).unwrap_or_else(|_| dir.to_path_buf());+    let canon = aiflow_sys::canonicalize(dir).unwrap_or_else(|_| dir.to_path_buf());     canon.file_name().and_then(|n| n.to_str()).and_then(usable).unwrap_or_else(|| "unnamed run".into()) } @@ -460,8 +460,8 @@ pub fn timeline(dir: &Path, data: &Value, flow: &Value, seq: &[String], minutes:         "engine": lane_name(dir, data),         "board": board_file(data),         "aiThread": driver_thread(data),-        "runFolder": std::fs::canonicalize(dir).unwrap_or_else(|_| dir.to_path_buf()).file_name().and_then(|n| n.to_str()).unwrap_or(""),-        "runDir": std::fs::canonicalize(dir).unwrap_or_else(|_| dir.to_path_buf()).display().to_string(),+        "runFolder": aiflow_sys::canonicalize(dir).unwrap_or_else(|_| dir.to_path_buf()).file_name().and_then(|n| n.to_str()).unwrap_or(""),+        "runDir": aiflow_sys::canonicalize(dir).unwrap_or_else(|_| dir.to_path_buf()).display().to_string(),         "finish": flow["finishLine"][lane(dir, data)].as_str().unwrap_or("Gerbers, BOM and CPL exported"),         "updated": aiflow_run::now(),         "current": if current.is_empty() { Value::Null } else { json!(current) },@@ -493,7 +493,7 @@ mod lane_tests {     use super::*;     #[test]     fn the_board_reference_names_the_lane() {-        let d = std::env::temp_dir();+        let d = aiflow_sys::temp_dir();         assert_eq!(lane(&d, &serde_json::json!({"remoteBoard": "altium:C:/b/buck.PcbDoc"})), "altium");         assert_eq!(lane(&d, &serde_json::json!({"remoteBoard": "fusion:Buck-brd"})), "fusion");         assert_eq!(lane(&d, &serde_json::json!({"remoteBoard": "C:/b/buck.kicad_pcb"})), "kicad");@@ -591,7 +591,7 @@ mod tests {         assert!(open_exec(&[json!({"event": "external-start", "program": "x"})], &alive).is_none());         // two at once: the one still running counts         assert_eq!(open_exec(&[start("a", 7), start("c", 7), json!({"event": "external-end", "execId": "c"})], &alive).unwrap()["execId"], "a");-        assert!(pid_alive(std::process::id() as u64));+        assert!(pid_alive(aiflow_sys::process::id() as u64));     }      #[test]@@ -625,7 +625,7 @@ mod sequence_key_tests {     use super::*;     #[test]     fn a_kicad_run_without_a_board_follows_the_from_scratch_sequence() {-        let d = std::env::temp_dir();+        let d = aiflow_sys::temp_dir();         assert_eq!(sequence_key(&d, &serde_json::json!({"eda": "kicad"})), "kicad-new");         assert_eq!(sequence_key(&d, &serde_json::json!({"eda": "kicad", "boards": ["/x/b.kicad_pcb"]})), "kicad");         assert_eq!(sequence_key(&d, &serde_json::json!({"eda": "kicad", "scratch": false})), "kicad");@@ -638,10 +638,10 @@ mod sequence_key_tests {      #[test]     fn a_pattern_board_follows_the_pattern_sequence() {-        let d = std::env::temp_dir();+        let d = aiflow_sys::temp_dir();         assert_eq!(sequence_key(&d, &serde_json::json!({"eda": "kicad", "kind": "pattern"})), "pattern");         assert_eq!(sequence_key(&d, &serde_json::json!({"eda": "fusion", "kind": "pattern"})), "fusion");-        let req = d.join(format!("aiflow-pattern-req-{}.json", std::process::id()));+        let req = d.join(format!("aiflow-pattern-req-{}.json", aiflow_sys::process::id()));         std::fs::write(&req, r#"{"boardKind": "pattern"}"#).unwrap();         assert_eq!(sequence_key(&d, &serde_json::json!({"eda": "kicad", "requirements": req, "boards": ["/x.kicad_pcb"]})), "pattern");         let flow: Value = serde_json::from_str(include_str!("../../../flows/board.json")).unwrap();@@ -661,7 +661,7 @@ mod sequence_key_tests {      #[test]     fn an_altium_run_named_at_intake_puts_its_parts_and_project_page_before_its_library() {-        let d = std::env::temp_dir();+        let d = aiflow_sys::temp_dir();         // `intake --eda altium`: the brief need not say "Altium", and the run never falls into kicad-new         assert_eq!(sequence_key(&d, &serde_json::json!({"eda": "altium"})), "altium");         let flow: Value = serde_json::from_str(include_str!("../../../flows/board.json")).unwrap();@@ -678,7 +678,7 @@ mod label_tests {     use serde_json::json;     #[test]     fn the_label_falls_back_in_order_and_is_never_the_tool_or_a_hash() {-        let root = std::env::temp_dir().join(format!("aiflow-label-{}", std::process::id()));+        let root = aiflow_sys::temp_dir().join(format!("aiflow-label-{}", aiflow_sys::process::id()));         let run = root.join("buck-run-3");         std::fs::create_dir_all(&run).unwrap();         let req = root.join("req.json");
crates/adom-aiflow/src/silk_policy.rs+1−1
@@ -58,7 +58,7 @@ mod tests {      #[test]     fn opt_in_from_spec_or_rules_profile() {-        let dir = std::env::temp_dir().join(format!("aiflow-silk-policy-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-silk-policy-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let board = dir.join("b.kicad_pcb").display().to_string();         assert!(!blocking(&json!({}), &board));
crates/adom-aiflow/src/skill_hints.rs+1−1
@@ -168,7 +168,7 @@ mod tests {      #[test]     fn hints_name_absolute_paths_installed_and_packaged() {-        let tmp = std::env::temp_dir().join(format!("aiflow-skillhints-{}", std::process::id()));+        let tmp = aiflow_sys::temp_dir().join(format!("aiflow-skillhints-{}", aiflow_sys::process::id()));         let home = tmp.join("home");         let pkg = tmp.join("work").join("adom_modules").join("adom").join("adom-aiflow");         std::fs::create_dir_all(home.join(".claude/skills/aiflow-silkscreen")).unwrap();
crates/adom-aiflow/src/spec_nets.rs+1−1
@@ -20,7 +20,7 @@ pub fn align(mut spec: Value, board_path: &str) -> Value { mod tests {     #[test]     fn spec_gnd_reads_as_the_board_slash_gnd() {-        let dir = std::env::temp_dir().join(format!("aiflow-spec-nets-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-spec-nets-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let b = dir.join("b.kicad_pcb");         std::fs::write(&b, r#"(kicad_pcb (net 0 "") (net 1 "/GND") (net 2 "/VIN"))"#).unwrap();
crates/adom-aiflow/src/stackup_presets.rs+1−1
@@ -385,7 +385,7 @@ mod tests {      #[test]     fn write_export_table_writes_md_and_json_in_own_temp_dir() {-        let dir = std::env::temp_dir().join(format!("aiflow-stackup-export-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-stackup-export-{}", aiflow_sys::process::id()));         let _ = std::fs::remove_dir_all(&dir);         let p = find("JLC04161H-7628").unwrap();         let mut spec = json!({
crates/adom-aiflow/src/step_export.rs+6−6
@@ -116,11 +116,11 @@ pub struct Context { pub board: PathBuf, pub temp: Option<PathBuf>, pub env: Vec pub fn context(board_path: &str, project_dir: &Path) -> Context {     let mut c = Context { board: PathBuf::from(board_path), temp: None, env: Vec::new(), notes: Vec::new() };     let text = std::fs::read_to_string(board_path).unwrap_or_default();-    let canon = |p: &Path| std::fs::canonicalize(p).unwrap_or_else(|_| p.to_path_buf());+    let canon = |p: &Path| aiflow_sys::canonicalize(p).unwrap_or_else(|_| p.to_path_buf());     let here = Path::new(board_path).parent().map(canon).unwrap_or_default();     if project_dir.is_dir() && canon(project_dir) != here {         let stem = Path::new(board_path).file_stem().and_then(|s| s.to_str()).unwrap_or("board");-        let tmp = project_dir.join(format!(".aiflow-step-{stem}-{}.kicad_pcb", std::process::id()));+        let tmp = project_dir.join(format!(".aiflow-step-{stem}-{}.kicad_pcb", aiflow_sys::process::id()));         match std::fs::write(&tmp, &text) {             Ok(()) => { c.notes.push(format!("exported from the project folder {} (a temporary copy of {board_path}) so ${{KIPRJMOD}} resolves to it", project_dir.display())); c.board = tmp.clone(); c.temp = Some(tmp); }             Err(e) => c.notes.push(format!("could not place a copy in the project folder {} ({e}): exported from {}, where ${{KIPRJMOD}} paths may not resolve", project_dir.display(), here.display())),@@ -156,7 +156,7 @@ pub fn run(board_path: &str, out: &Path, cli: &str, project_dir: &Path) -> Value     args.extend(LAYER_FLAGS.iter().map(|s| s.to_string()));     args.extend(["--output".to_string(), out.display().to_string(), ctx.board.display().to_string()]);     let command = format!("{}{cli} {}", ctx.env.iter().map(|(k, v)| format!("{k}={v} ")).collect::<String>(), args.join(" "));-    let result = std::process::Command::new(cli).args(&args).envs(ctx.env.iter().map(|(k, v)| (k, v))).output();+    let result = aiflow_sys::process::Command::new(cli).args(&args).envs(ctx.env.iter().map(|(k, v)| (k, v))).output();     if let Some(t) = &ctx.temp { let _ = std::fs::remove_file(t); }     let mut rec = match result {         Ok(o) => {@@ -191,7 +191,7 @@ mod tests {      #[test]     fn geometry_warnings_need_an_ack_bound_to_the_step_file() {-        let dir = std::env::temp_dir().join(format!("aiflow-step-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-step-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let board = dir.join("b.kicad_pcb");         std::fs::write(&board, "(kicad_pcb (version 20240108) (generator \"t\") (layers (0 \"F.Cu\" signal) (31 \"B.Cu\" signal) (44 \"Edge.Cuts\" user))\n (footprint \"T:U\" (layer \"F.Cu\") (at 129.3 87) (property \"Reference\" \"U3\"))\n (gr_rect (start 100 60) (end 150 100) (layer \"Edge.Cuts\")))").unwrap();@@ -217,7 +217,7 @@ mod tests {     #[test]     fn run_keeps_the_full_layer_set_and_reads_both_streams() {         use std::os::unix::fs::PermissionsExt;-        let dir = std::env::temp_dir().join(format!("aiflow-step-run-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-step-run-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let board = dir.join("b.kicad_pcb");         std::fs::write(&board, "(kicad_pcb (version 20240108) (generator \"t\") (layers (0 \"F.Cu\" signal)))").unwrap();@@ -240,7 +240,7 @@ mod tests {     #[test]     fn the_run_copy_is_exported_from_the_project_folder() {         use std::os::unix::fs::PermissionsExt;-        let dir = std::env::temp_dir().join(format!("aiflow-step-proj-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-step-proj-{}", aiflow_sys::process::id()));         let (proj, run_dir) = (dir.join("proj"), dir.join("proj/aiflow/run"));         std::fs::create_dir_all(&run_dir).unwrap();         std::fs::create_dir_all(proj.join("kicad/3rdparty/3dmodels")).unwrap();
crates/adom-aiflow/src/testplan.rs+1−1
@@ -660,7 +660,7 @@ mod tests {      #[test]     fn the_test_point_files_are_carried_and_a_copy_already_there_stays() {-        let d = std::env::temp_dir().join(format!("aiflow-tp-{}", std::process::id()));+        let d = aiflow_sys::temp_dir().join(format!("aiflow-tp-{}", aiflow_sys::process::id()));         let to = write_test_point_files(&d).unwrap();         for (name, _) in TP_FILES { assert!(to.join(name).is_file(), "{name}"); }         let page: Value = serde_json::from_slice(&std::fs::read(to.join("page.json")).unwrap()).unwrap();
crates/adom-aiflow/src/timeline_server.rs+1−1
@@ -244,7 +244,7 @@ fn handle(mut stream: TcpStream, dir: &Path, live: &Live) {         response(             &mut stream,             200,-            json!({"ok":cached.watcher_error.is_none(),"stateSource":"native-filesystem-events","stateFileReads":cached.reads,"watcherError":cached.watcher_error,"version":env!("CARGO_PKG_VERSION"),"pid":std::process::id(),"runId":read_json(&dir.join("dashboard.json")).unwrap_or(Value::Null)["runId"],"liveChannel":"sse"}),+            json!({"ok":cached.watcher_error.is_none(),"stateSource":"native-filesystem-events","stateFileReads":cached.reads,"watcherError":cached.watcher_error,"version":env!("CARGO_PKG_VERSION"),"pid":aiflow_sys::process::id(),"runId":read_json(&dir.join("dashboard.json")).unwrap_or(Value::Null)["runId"],"liveChannel":"sse"}),         );         return;     }
crates/adom-aiflow/src/verified.rs+2−2
@@ -252,7 +252,7 @@ mod tests {     /// export's Gerber regions. A recorded outcome wins over a proof.     #[test]     fn tool_proofs_fill_in_parity_erc_and_gerber_fills() {-        let dir = std::env::temp_dir().join(format!("verified-proofs-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("verified-proofs-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(dir.join("proofs")).unwrap();         std::fs::write(dir.join("proofs/schematic.json"), r#"{"at":"t","data":{"parity":true,"erc":{"pass":true,"errors":[]}}}"#).unwrap();         std::fs::write(dir.join("proofs/export.json"), r#"{"at":"t","data":{"tool":"altium","fillsGerbers":{"pass":true,"regions":{"F.Cu":42}}}}"#).unwrap();@@ -324,7 +324,7 @@ mod tests {     /// a clean one with a passing export reads cleared, and nothing is assumed without the record.     #[test]     fn pattern_lane_reads_the_recorded_live_drc() {-        let dir = std::env::temp_dir().join(format!("verified-live-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("verified-live-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let board = dir.join("disc.kicad_pcb"); std::fs::write(&board, "(kicad_pcb)").unwrap();         let b = board.display().to_string();
crates/adom-aiflow/src/winpath.rs+1−1
@@ -26,7 +26,7 @@ mod tests {      #[test]     fn a_windows_path_is_the_mounted_drive() {-        let mnt = std::env::temp_dir().join(format!("aiflow-winpath-{}", std::process::id()));+        let mnt = aiflow_sys::temp_dir().join(format!("aiflow-winpath-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(mnt.join("c")).unwrap();         assert_eq!(local(Path::new("C:/Users/me/Documents/JLCPCB_X"), &mnt).unwrap(), mnt.join("c/Users/me/Documents/JLCPCB_X"));         assert_eq!(local(Path::new(r"C:\Users\me\out"), &mnt).unwrap(), mnt.join("c/Users/me/out"));
crates/adom-aiflow/src/zone_ownership.rs+1−1
@@ -73,7 +73,7 @@ pub fn saved_boards(run_board: &str, br: &aiflow_bridge::Bridge, rb: &str, dir:     out.push((format!("the run's snapshot {run_board}"), saved_ids(&text)?));     let pull = dir.join(format!("zone-ownership-{}", std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_nanos()).unwrap_or(0)));     std::fs::create_dir_all(&pull).map_err(|e| e.to_string())?;-    let save_to = std::fs::canonicalize(&pull).map_err(|e| e.to_string())?;+    let save_to = aiflow_sys::canonicalize(&pull).map_err(|e| e.to_string())?;     let reply = br.call("pull_file", &json!({"filePaths": [rb], "saveTo": save_to}));     let name = rb.rsplit(['/', '\\']).next().unwrap_or("board.kicad_pcb");     let local = save_to.join(name);
crates/aiflow-analyze/Cargo.toml+1
@@ -6,6 +6,7 @@ license.workspace = true description = "adom-aiflow: analyze"  [dependencies]+aiflow-sys = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } 
crates/aiflow-analyze/src/fields_report.rs+1−1
@@ -97,7 +97,7 @@ mod tests {         (lean, d)     }     fn dir(tag: &str) -> PathBuf {-        let d = std::env::temp_dir().join(format!("aiflow-fields-report-{tag}-{}", std::process::id()));+        let d = aiflow_sys::temp_dir().join(format!("aiflow-fields-report-{tag}-{}", aiflow_sys::process::id()));         let _ = std::fs::remove_dir_all(&d);         std::fs::create_dir_all(&d).unwrap();         d
crates/aiflow-analyze/src/lib.rs+1−1
@@ -664,7 +664,7 @@ mod field_screen_tests {         field_screen(&f,&spec,b"board",b"spec","current").unwrap();         let mut lean=f.clone();lean["nets"][0]["platedConnections"]=json!("detail.json");lean["detail"]=json!({"file":"detail.json"});         assert!(field_screen(&lean,&spec,b"board",b"spec","current").unwrap_err().contains("no plated-connection report"));-        let d=std::env::temp_dir().join(format!("aiflow-lean-screen-{}",std::process::id()));let _=std::fs::remove_dir_all(&d);std::fs::create_dir_all(&d).unwrap();+        let d=aiflow_sys::temp_dir().join(format!("aiflow-lean-screen-{}",aiflow_sys::process::id()));let _=std::fs::remove_dir_all(&d);std::fs::create_dir_all(&d).unwrap();         std::fs::write(d.join("fields.json"),lean.to_string()).unwrap();         std::fs::write(d.join("detail.json"),json!({"platedConnections":{"VCC":pc}}).to_string()).unwrap();         let merged=fields_report::load(&d.join("fields.json")).unwrap();
crates/aiflow-board/Cargo.toml+1
@@ -6,6 +6,7 @@ license.workspace = true description = "adom-aiflow: board"  [dependencies]+aiflow-sys = { workspace = true } roxmltree = "0.20" serde = { workspace = true } serde_json = { workspace = true }
crates/aiflow-board/src/altium.rs+2−2
@@ -310,7 +310,7 @@ mod tests {         let st: Value = serde_json::from_str(&std::fs::read_to_string(p).unwrap()).unwrap();         let src = serde_json::json!({"source": "altium-bridge", "state": st, "pours": null}).to_string();         let text = render_plan_board(&src).unwrap();-        std::fs::write(std::env::temp_dir().join("altium-real.kicad_pcb"), &text).unwrap();+        std::fs::write(aiflow_sys::temp_dir().join("altium-real.kicad_pcb"), &text).unwrap();         let b = crate::Board::from_text("real.kicad_pcb", text).unwrap();         let n_pads = st["pads"].as_array().unwrap().len();         eprintln!("pads {} (read {n_pads}), footprints {}, tracks {}, vias {}, zones {}, nets {}", b.pads.len(), b.footprints.len(), b.tracks().len(), b.vias().len(), b.zones().len(), b.nets.len());@@ -325,7 +325,7 @@ mod tests {     /// frame; a part whose source pads differ gets a courtyard around its pads instead.     #[test]     fn courtyards_come_from_the_source_footprint_or_around_the_pads() {-        let dir = std::env::temp_dir().join(format!("altium-mech-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("altium-mech-{}", aiflow_sys::process::id()));         let _ = std::fs::remove_dir_all(&dir);         std::fs::create_dir_all(dir.join("pages/R1MPN")).unwrap();         std::fs::create_dir_all(dir.join("pages/C1MPN")).unwrap();
crates/aiflow-bridge/Cargo.toml+1
@@ -6,6 +6,7 @@ license.workspace = true description = "adom-aiflow: bridge"  [dependencies]+aiflow-sys = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } aiflow-board = { workspace = true }
crates/aiflow-bridge/src/altium.rs+1−1
@@ -373,7 +373,7 @@ impl Eda for AltiumEda {         // projectDir: the run's Altium project, where each part's source KiCad footprint gives the         // plan board its courtyard and fab outline (the mechanical checks need them)         let project = dir.join("altium");-        let project = if project.join("project.json").is_file() { json!(std::fs::canonicalize(&project).unwrap_or(project).display().to_string()) } else { Value::Null };+        let project = if project.join("project.json").is_file() { json!(aiflow_sys::canonicalize(&project).unwrap_or(project).display().to_string()) } else { Value::Null };         // issue #229: the stack-up, so a board turned 4-layer is 4-layer here before anything is drawn inside         let stack = t.send("altium_layer_stack", &json!({"expectPath": self.path}));         let stack = if ok(&stack) { if stack["data"].is_object() { stack["data"].clone() } else { stack } } else { Value::Null };
crates/aiflow-bridge/src/lib.rs+10−3
@@ -3,7 +3,7 @@ //! gates and activity log apply as for any AI thread. Capture recipe, landing, measurement, //! validation. use std::path::{Path, PathBuf};-use std::process::Command;+use aiflow_sys::process::Command;  use serde_json::{json, Value}; @@ -462,11 +462,18 @@ impl Bridge {      /// One adom-bridge verb with a hard wall-clock limit on the CLI process (issue #98): past it the     /// process is killed and the reply is `errorCode: aiflow_timeout`.+    /// WASI has no threads: the host runs the call to completion (the host enforces its own timeout).+    #[cfg(target_os = "wasi")]+    pub fn raw_call_bounded(&self, verb: &str, args: &Value, _limit: std::time::Duration) -> Value {+        self.raw_call(verb, args)+    }++    #[cfg(not(target_os = "wasi"))]     pub fn raw_call_bounded(&self, verb: &str, args: &Value, limit: std::time::Duration) -> Value {         use std::io::Read;         let args = socket_args(verb, args);         let child = Command::new("adom-bridge").args(["--ai-thread", &self.ai_thread, "--target", &self.target, verb, &args.to_string()])-            .stdout(std::process::Stdio::piped()).stderr(std::process::Stdio::null()).spawn();+            .stdout(aiflow_sys::process::Stdio::piped()).stderr(aiflow_sys::process::Stdio::null()).spawn();         let mut child = match child { Ok(c) => c, Err(e) => return json!({"status": "error", "error": format!("adom-bridge not runnable: {e}")}) };         let mut out = child.stdout.take();         let reader = std::thread::spawn(move || { let mut t = String::new(); if let Some(o) = out.as_mut() { let _ = o.read_to_string(&mut t); } t });@@ -1018,7 +1025,7 @@ mod pull_tests {     }      fn scratch(name: &str) -> PathBuf {-        let d = std::env::temp_dir().join(format!("aiflow-pull-{name}-{}", std::process::id()));+        let d = aiflow_sys::temp_dir().join(format!("aiflow-pull-{name}-{}", aiflow_sys::process::id()));         let _ = std::fs::remove_dir_all(&d);         std::fs::create_dir_all(&d).unwrap();         d
crates/aiflow-copper/Cargo.toml+1
@@ -6,6 +6,7 @@ license.workspace = true description = "adom-aiflow: copper"  [dependencies]+aiflow-sys = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } aiflow-board = { workspace = true }
crates/aiflow-copper/src/lib.rs+3−3
@@ -8,7 +8,7 @@ //! `run_drc` and `summarize` give the gate its numbers: errors, new versus inherited against a //! baseline, unconnected items. use std::collections::{BTreeMap, HashMap};-use std::process::Command;+use aiflow_sys::process::Command;  pub mod single_face; @@ -656,7 +656,7 @@ pub fn parity_request(cli: &str, board: &str, schematic: Option<&str>) -> Option  /// `run_drc`, with schematic parity when the run records the schematic the board was made from. pub fn run_drc_with(path: &str, schematic: Option<&str>) -> Result<Value, String> {-    let dir = std::env::temp_dir().join(format!("aiflow-drc-{}", std::process::id()));+    let dir = aiflow_sys::temp_dir().join(format!("aiflow-drc-{}", aiflow_sys::process::id()));     std::fs::create_dir_all(&dir).map_err(|e| e.to_string())?;     let report = dir.join(format!("drc-{}.json", uuid()));     let native = native_kicad_cli();@@ -829,7 +829,7 @@ mod gate_tests {     }     #[test]     fn parity_is_requested_only_when_a_schematic_can_reach_kicad() {-        let dir = std::env::temp_dir().join(format!("aiflow-parity-{}", uuid()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-parity-{}", uuid()));         std::fs::create_dir_all(&dir).unwrap();         let sch = dir.join("design.kicad_sch"); std::fs::write(&sch, "(kicad_sch)").unwrap();         let board = dir.join("board-1.kicad_pcb"); let b = board.to_str().unwrap(); let s = sch.to_str().unwrap();
crates/aiflow-copper/tests/project_rules.rs+1−1
@@ -2,7 +2,7 @@ use std::path::Path; #[test] #[ignore = "requires a native KiCad CLI, optionally ADOM_AIFLOW_KICAD_CLI"] fn native_project_edge_rule_survives_snapshot_copy() {-    let dir=std::env::temp_dir().join(format!("aiflow-native-rules-{}",std::process::id()));std::fs::create_dir_all(&dir).unwrap();+    let dir=aiflow_sys::temp_dir().join(format!("aiflow-native-rules-{}",aiflow_sys::process::id()));std::fs::create_dir_all(&dir).unwrap();     let src=Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/project-rules.kicad_pcb");     let dst=dir.join("snapshot.kicad_pcb");std::fs::copy(&src,&dst).unwrap();     aiflow_copper::copy_project_rules(src.to_str().unwrap(),dst.to_str().unwrap()).unwrap();
crates/aiflow-place/Cargo.toml+1
@@ -6,6 +6,7 @@ license.workspace = true description = "adom-aiflow: place"  [dependencies]+aiflow-sys = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } aiflow-board = { workspace = true }
crates/aiflow-place/src/lib.rs+1−1
@@ -797,7 +797,7 @@ mod tests {         if !std::path::Path::new(&format!("{src}/run/board-0.kicad_pcb")).is_file() {             return;         }-        let tmp = std::env::temp_dir().join(format!("aiflow-place-chain-{}", std::process::id()));+        let tmp = aiflow_sys::temp_dir().join(format!("aiflow-place-chain-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&tmp).unwrap();         let bp = tmp.join("board-0.kicad_pcb");         std::fs::copy(format!("{src}/run/board-0.kicad_pcb"), &bp).unwrap();
crates/aiflow-pours/Cargo.toml+1
@@ -6,6 +6,7 @@ license.workspace = true description = "adom-aiflow: pours"  [dependencies]+aiflow-sys = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } aiflow-board = { workspace = true }
crates/aiflow-pours/src/lib.rs+2−2
@@ -627,7 +627,7 @@ pub fn zone_sexpr(board: &Board, z: &Value) -> Result<String, String> {         return Err("zone needs a polygon with three or more points".into());     }     let name = z.get("name").and_then(|n| n.as_str()).unwrap_or("zone");-    let uuid = format!("bf{:016x}-{:04x}-4000-8000-{:012x}", pts.len() as u64 * 7919 + name.len() as u64, layers.len(), std::process::id());+    let uuid = format!("bf{:016x}-{:04x}-4000-8000-{:012x}", pts.len() as u64 * 7919 + name.len() as u64, layers.len(), aiflow_sys::process::id());     let keepout = z.get("type").and_then(|t| t.as_str()) == Some("keepout") || z.get("keepout").is_some();     if keepout {         let k = z.get("keepout").cloned().unwrap_or(json!({"copperPour": true}));@@ -877,7 +877,7 @@ mod issue90_tests {         assert!((dru_via_min(dru, "clearance").unwrap() - 0.1016).abs() < 1e-9);         assert_eq!(dru_via_min(dru, "hole_to_hole"), Some(0.25));         assert_eq!(dru_via_min(dru, "edge_clearance"), None);-        let d = std::env::temp_dir().join(format!("aiflow-dru-{}", std::process::id()));+        let d = aiflow_sys::temp_dir().join(format!("aiflow-dru-{}", aiflow_sys::process::id()));         std::fs::create_dir_all(&d).unwrap();         let board = d.join("b.kicad_pcb");         let path = board.display().to_string();
crates/aiflow-run/Cargo.toml+1
@@ -6,5 +6,6 @@ license.workspace = true description = "adom-aiflow: run"  [dependencies]+aiflow-sys = { workspace = true } serde = { workspace = true } serde_json = { workspace = true }
crates/aiflow-run/src/lib.rs+3−3
@@ -736,7 +736,7 @@ mod tests {     use super::*;     #[test]     fn external_turn_covers_a_long_gap_without_inventing_idle_activity() {-        let dir=std::env::temp_dir().join(format!("aiflow-session-{}",std::process::id()));+        let dir=aiflow_sys::temp_dir().join(format!("aiflow-session-{}",aiflow_sys::process::id()));         std::fs::create_dir_all(&dir).unwrap();         let t=1_789_299_600;         let r=Run{dir:dir.clone(),data:json!({"clock":{"promptTime":iso(t)},"idleMinutes":15})};@@ -752,7 +752,7 @@ mod tests {     }     #[test]     fn intake_run_keeps_its_clock_and_ledger_when_the_board_arrives() {-        let dir = std::env::temp_dir().join(format!("aiflow-intake-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-intake-{}", aiflow_sys::process::id()));         let _ = std::fs::remove_dir_all(&dir);         let mut r = Run::create_intake(&dir, "2026-09-29T00:39:00Z", "t", Some("claude"), None, None, None).unwrap();         assert!(r.board_pending());@@ -786,7 +786,7 @@ mod tests {     /// Issue #219: a command that loaded the run before `step routing` saved must not take the step back.     #[test]     fn an_overlapping_save_keeps_the_newer_step() {-        let dir = std::env::temp_dir().join(format!("aiflow-run-219-{}", std::process::id()));+        let dir = aiflow_sys::temp_dir().join(format!("aiflow-run-219-{}", aiflow_sys::process::id()));         let _ = std::fs::remove_dir_all(&dir);         let mut r = Run::create(&dir, "b.kicad_pcb", "s.json", "test", "2026-11-19T00:00:00Z", "t", None, None).unwrap();         r.step_set("sourcing", false, None);
crates/aiflow-sys/Cargo.tomladded+9
@@ -0,0 +1,9 @@+[package]+name = "aiflow-sys"+description = "Operating-system shims for AI Flow: native builds use std directly; WebAssembly (WASI) builds ask the host (the Adom Desktop Extension) to run programs on the user's machine."+version.workspace = true+edition.workspace = true+license.workspace = true++[dependencies]+serde_json = { workspace = true }
crates/aiflow-sys/src/lib.rsadded+291
@@ -0,0 +1,291 @@+//! Operating-system shims for AI Flow.+//!+//! On native targets every item here is `std` itself, so native builds behave exactly as before.+//! On `wasm32-wasi*` the few calls WASI cannot do are answered differently:+//! - `canonicalize` normalises the path lexically against the working folder (WASI has no realpath),+//! - `temp_dir` is a `.tmp` folder inside the working folder,+//! - `process::Command` asks the host to run the program on the user's machine+//!   (import module `adom_host`), and `process::id` is a per-run number.++use std::path::{Path, PathBuf};++#[cfg(not(target_os = "wasi"))]+pub use std::env::temp_dir;+#[cfg(not(target_os = "wasi"))]+pub use std::fs::canonicalize;++#[cfg(not(target_os = "wasi"))]+pub mod process {+    pub use std::process::*;+}++/// The folder the run works in (WASI: `$PWD`, default `/work`).+#[cfg(target_os = "wasi")]+fn cwd() -> PathBuf {+    PathBuf::from(std::env::var("PWD").unwrap_or_else(|_| "/work".into()))+}++#[cfg(target_os = "wasi")]+pub fn temp_dir() -> PathBuf {+    let d = std::env::var("TMPDIR").map(PathBuf::from).unwrap_or_else(|_| cwd().join(".tmp"));+    let _ = std::fs::create_dir_all(&d);+    d+}++#[cfg(target_os = "wasi")]+pub fn canonicalize<P: AsRef<Path>>(p: P) -> std::io::Result<PathBuf> {+    let p = p.as_ref();+    std::fs::metadata(p)?; // same "not found" behaviour as realpath+    Ok(normalize(&if p.is_absolute() { p.to_path_buf() } else { cwd().join(p) }))+}++/// Lexical normalisation: drops `.`, resolves `..` (a WASI preopen has no symlinks to follow).+pub fn normalize(p: &Path) -> PathBuf {+    use std::path::Component::*;+    let mut out = PathBuf::new();+    for c in p.components() {+        match c {+            CurDir => {}+            ParentDir => {+                out.pop();+            }+            other => out.push(other.as_os_str()),+        }+    }+    out+}++#[cfg(target_os = "wasi")]+pub mod process {+    //! The subset of `std::process` AI Flow uses, carried out by the host.+    pub use std::process::{abort, exit, ExitCode};+    use std::collections::BTreeMap;+    use std::ffi::{OsStr, OsString};+    use std::io::{self, Write};+    use std::path::{Path, PathBuf};+    use std::sync::{Arc, Mutex};++    #[link(wasm_import_module = "adom_host")]+    extern "C" {+        /// Run a program. `req` is UTF-8 JSON; returns the length of the response the host holds.+        fn run(req_ptr: *const u8, req_len: usize) -> usize;+        /// Copy the held response into `buf` (exactly the length `run` returned).+        fn take(buf_ptr: *mut u8);+    }++    pub fn id() -> u32 {+        use std::sync::atomic::{AtomicU32, Ordering};+        static N: AtomicU32 = AtomicU32::new(0);+        let t = std::time::SystemTime::now()+            .duration_since(std::time::UNIX_EPOCH)+            .map(|d| d.subsec_nanos())+            .unwrap_or(0);+        (t & 0x7fff_0000) | (N.fetch_add(1, Ordering::Relaxed) & 0xffff)+    }++    #[derive(Clone, Copy, Debug, PartialEq, Eq)]+    enum Mode {+        Inherit,+        Piped,+        Null,+    }++    #[derive(Debug)]+    pub struct Stdio(Mode);+    impl Stdio {+        pub fn piped() -> Self { Stdio(Mode::Piped) }+        pub fn null() -> Self { Stdio(Mode::Null) }+        pub fn inherit() -> Self { Stdio(Mode::Inherit) }+    }+    impl From<std::fs::File> for Stdio {+        fn from(_: std::fs::File) -> Self { Stdio(Mode::Null) }+    }++    #[derive(Clone, Copy, Debug, PartialEq, Eq)]+    pub struct ExitStatus(Option<i32>);+    impl ExitStatus {+        pub fn success(&self) -> bool { self.0 == Some(0) }+        pub fn code(&self) -> Option<i32> { self.0 }+    }+    impl std::fmt::Display for ExitStatus {+        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+            match self.0 {+                Some(c) => write!(f, "exit status: {c}"),+                None => write!(f, "signal"),+            }+        }+    }++    #[derive(Debug, Clone)]+    pub struct Output {+        pub status: ExitStatus,+        pub stdout: Vec<u8>,+        pub stderr: Vec<u8>,+    }++    #[derive(Debug, Clone)]+    pub struct Command {+        program: OsString,+        args: Vec<OsString>,+        env: BTreeMap<OsString, Option<OsString>>,+        cwd: Option<PathBuf>,+        stdin: Mode,+        stdout: Mode,+        stderr: Mode,+    }++    impl Command {+        pub fn new<S: AsRef<OsStr>>(program: S) -> Self {+            Command {+                program: program.as_ref().into(),+                args: vec![],+                env: BTreeMap::new(),+                cwd: None,+                stdin: Mode::Inherit,+                stdout: Mode::Inherit,+                stderr: Mode::Inherit,+            }+        }+        pub fn arg<S: AsRef<OsStr>>(&mut self, a: S) -> &mut Self {+            self.args.push(a.as_ref().into());+            self+        }+        pub fn args<I: IntoIterator<Item = S>, S: AsRef<OsStr>>(&mut self, a: I) -> &mut Self {+            for x in a {+                self.args.push(x.as_ref().into());+            }+            self+        }+        pub fn env<K: AsRef<OsStr>, V: AsRef<OsStr>>(&mut self, k: K, v: V) -> &mut Self {+            self.env.insert(k.as_ref().into(), Some(v.as_ref().into()));+            self+        }+        pub fn envs<I: IntoIterator<Item = (K, V)>, K: AsRef<OsStr>, V: AsRef<OsStr>>(&mut self, vars: I) -> &mut Self {+            for (k, v) in vars {+                self.env(k, v);+            }+            self+        }+        pub fn env_remove<K: AsRef<OsStr>>(&mut self, k: K) -> &mut Self {+            self.env.insert(k.as_ref().into(), None);+            self+        }+        pub fn current_dir<P: AsRef<Path>>(&mut self, d: P) -> &mut Self {+            self.cwd = Some(d.as_ref().into());+            self+        }+        pub fn stdin<T: Into<Stdio>>(&mut self, s: T) -> &mut Self {+            self.stdin = s.into().0;+            self+        }+        pub fn stdout<T: Into<Stdio>>(&mut self, s: T) -> &mut Self {+            self.stdout = s.into().0;+            self+        }+        pub fn stderr<T: Into<Stdio>>(&mut self, s: T) -> &mut Self {+            self.stderr = s.into().0;+            self+        }+        pub fn get_program(&self) -> &OsStr { &self.program }+        pub fn get_args(&self) -> impl Iterator<Item = &OsStr> { self.args.iter().map(|a| a.as_os_str()) }++        fn exec(&self, input: &[u8]) -> io::Result<Output> {+            let s = |o: &OsStr| o.to_string_lossy().into_owned();+            let env: serde_json::Map<String, serde_json::Value> = self+                .env+                .iter()+                .map(|(k, v)| (s(k), v.as_ref().map(|v| serde_json::Value::String(s(v))).unwrap_or(serde_json::Value::Null)))+                .collect();+            let req = serde_json::json!({+                "program": s(&self.program),+                "args": self.args.iter().map(|a| s(a)).collect::<Vec<_>>(),+                "env": env,+                "cwd": self.cwd.as_ref().map(|c| c.display().to_string()),+                "stdin": String::from_utf8_lossy(input),+            })+            .to_string();+            let n = unsafe { run(req.as_ptr(), req.len()) };+            let mut buf = vec![0u8; n];+            unsafe { take(buf.as_mut_ptr()) };+            // response: i32 code (i32::MIN = could not start), u32 len + stdout, u32 len + stderr+            let rd = |b: &[u8], at: usize| u32::from_le_bytes([b[at], b[at + 1], b[at + 2], b[at + 3]]) as usize;+            let code = i32::from_le_bytes([buf[0], buf[1], buf[2], buf[3]]);+            let ol = rd(&buf, 4);+            let stdout = buf[8..8 + ol].to_vec();+            let el = rd(&buf, 8 + ol);+            let stderr = buf[12 + ol..12 + ol + el].to_vec();+            if code == i32::MIN {+                return Err(io::Error::new(io::ErrorKind::NotFound, String::from_utf8_lossy(&stderr).into_owned()));+            }+            Ok(Output { status: ExitStatus(if code < 0 { None } else { Some(code) }), stdout, stderr })+        }++        fn forward(&self, o: &Output) {+            if self.stdout == Mode::Inherit {+                let _ = io::stdout().write_all(&o.stdout);+            }+            if self.stderr == Mode::Inherit {+                let _ = io::stderr().write_all(&o.stderr);+            }+        }++        /// Like std: stdout and stderr are captured unless set otherwise.+        pub fn output(&mut self) -> io::Result<Output> {+            let o = self.exec(&[])?;+            Ok(Output {+                stdout: if self.stdout == Mode::Null { vec![] } else { o.stdout },+                stderr: if self.stderr == Mode::Null { vec![] } else { o.stderr },+                status: o.status,+            })+        }+        pub fn status(&mut self) -> io::Result<ExitStatus> {+            let o = self.exec(&[])?;+            self.forward(&o);+            Ok(o.status)+        }+        /// WASI cannot run a child concurrently: the program runs when the child is waited on,+        /// with whatever was written to its stdin first.+        pub fn spawn(&mut self) -> io::Result<Child> {+            let buf = Arc::new(Mutex::new(Vec::new()));+            Ok(Child { stdin: (self.stdin == Mode::Piped).then(|| ChildStdin(buf.clone())), cmd: self.clone(), input: buf, done: None })+        }+    }++    #[derive(Debug)]+    pub struct ChildStdin(Arc<Mutex<Vec<u8>>>);+    impl Write for ChildStdin {+        fn write(&mut self, b: &[u8]) -> io::Result<usize> {+            self.0.lock().unwrap().extend_from_slice(b);+            Ok(b.len())+        }+        fn flush(&mut self) -> io::Result<()> { Ok(()) }+    }++    #[derive(Debug)]+    pub struct Child {+        pub stdin: Option<ChildStdin>,+        cmd: Command,+        input: Arc<Mutex<Vec<u8>>>,+        done: Option<Output>,+    }+    impl Child {+        fn finish(&mut self) -> io::Result<&Output> {+            if self.done.is_none() {+                self.stdin.take();+                let input = std::mem::take(&mut *self.input.lock().unwrap());+                let o = self.cmd.exec(&input)?;+                self.cmd.forward(&o);+                self.done = Some(o);+            }+            Ok(self.done.as_ref().unwrap())+        }+        pub fn wait(&mut self) -> io::Result<ExitStatus> { Ok(self.finish()?.status) }+        pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> { Ok(Some(self.finish()?.status)) }+        pub fn wait_with_output(mut self) -> io::Result<Output> {+            self.finish()?;+            Ok(self.done.take().unwrap())+        }+        pub fn kill(&mut self) -> io::Result<()> { Ok(()) }+        pub fn id(&self) -> u32 { 0 }+    }+}
docs/release-0.2.131.mdadded+12
@@ -0,0 +1,12 @@+# adom-aiflow 0.2.131++## Builds for WebAssembly, so AI Flow can run inside Claude Desktop (PR #184, John Lauer)++adom-aiflow now also builds for `wasm32-wasip1`, which the Adom Claude Desktop Extension ([adom/adom-claude-extension](https://wiki.adom.inc/adom/adom-claude-extension)) runs on the user's own computer, on macOS, Windows and Linux.++- New crate `crates/aiflow-sys`. On native targets it is `std` itself (`process`, `temp_dir`, `canonicalize`), so the Linux binary behaves exactly as before. Under WASI it asks the host to run programs on the user's machine, keeps temporary files in `$TMPDIR` (or a `.tmp` folder in the working folder), and normalises paths lexically.+- Every call site that runs a program, takes a temporary folder or canonicalises a path goes through `aiflow_sys`.+- Under WASI, `raw_call_bounded` calls the bridge directly (no threads; the host enforces the time limit), and `main` starts in `$PWD`.+- Not yet in the WebAssembly build: the timeline dashboard; `measure` and `land` need Adom Bridge on the machine; the Fusion and Altium Python lanes need `python3` there.++Applied with John's port script (`docs/port-aiflow-to-wasm.py` on the extension page) to 0.2.130, not merged from the 0.2.129 snapshot, so nothing newer is reverted. Native: 880 tests pass; `cargo check --target wasm32-wasip1 -p adom-aiflow` passes.
package.json+1−1
@@ -1,7 +1,7 @@ {   "slug": "adom-aiflow",   "type": "app",-  "version": "0.2.130",+  "version": "0.2.131",   "title": "AI Flow",   "description": "Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board. One Rust binary with a crate per step (placement helpers, a grid router with Kelvin taps, pours with keepouts, KiCad's DRC gate, live landing through the KiCad Bridge, copper measurement, current and thermal analysis) and a finish line that refuses an unfinished board. Every command answers with hints for the AI; every turn, its thinking time and every rework loop go into run.jsonl, so Claude, Codex and any other engine are compared on the same flow. KiCad, Fusion 360 and Altium Designer today (the same steps and gates through each tool's bridge); Adom's own web apps next.",   "summary": "Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board. The AI thinks its way from placement through routing, pours, current and thermal analysis to a delivered video; the binary does the fast, deterministic parts of every step, hands back hints, and keeps a ledger of every turn, every return to an earlier step, and the clock from the prompt to done.",
page.json+1−1
@@ -1,7 +1,7 @@ {   "slug": "adom-aiflow",   "type": "app",-  "version": "0.2.130",+  "version": "0.2.131",   "title": "AI Flow",   "description": "Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board. One Rust binary with a crate per step (placement helpers, a grid router with Kelvin taps, pours with keepouts, KiCad's DRC gate, live landing through the KiCad Bridge, copper measurement, current and thermal analysis) and a finish line that refuses an unfinished board. Every command answers with hints for the AI; every turn, its thinking time and every rework loop go into run.jsonl, so Claude, Codex and any other engine are compared on the same flow. KiCad, Fusion 360 and Altium Designer today (the same steps and gates through each tool's bridge); Adom's own web apps next.",   "summary": "Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board. The AI thinks its way from placement through routing, pours, current and thermal analysis to a delivered video; the binary does the fast, deterministic parts of every step, hands back hints, and keeps a ledger of every turn, every return to an earlier step, and the clock from the prompt to done.",