← Commit history
Merge PR #601: AI Flow 0.2.109: follow-ups for adom-fields 0.10.12 (release-0.2.109 -> main) merge
Showing changes introduced by the merge (against its first parent).
8 files changed
+90−13
Cargo.lock+10−10@@ -4,7 +4,7 @@ version = 4 [[package]] name = "adom-aiflow"-version = "0.2.108"+version = "0.2.109" dependencies = [ "aiflow-analyze", "aiflow-board",@@ -25,7 +25,7 @@ dependencies = [ [[package]] name = "aiflow-analyze"-version = "0.2.108"+version = "0.2.109" dependencies = [ "aiflow-board", "serde",@@ -35,7 +35,7 @@ dependencies = [ [[package]] name = "aiflow-board"-version = "0.2.108"+version = "0.2.109" dependencies = [ "roxmltree", "serde",@@ -44,7 +44,7 @@ dependencies = [ [[package]] name = "aiflow-bridge"-version = "0.2.108"+version = "0.2.109" dependencies = [ "aiflow-board", "serde",@@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "aiflow-copper"-version = "0.2.108"+version = "0.2.109" dependencies = [ "aiflow-board", "aiflow-grid",@@ -63,7 +63,7 @@ dependencies = [ [[package]] name = "aiflow-grid"-version = "0.2.108"+version = "0.2.109" dependencies = [ "aiflow-board", "serde",@@ -72,7 +72,7 @@ dependencies = [ [[package]] name = "aiflow-place"-version = "0.2.108"+version = "0.2.109" dependencies = [ "aiflow-board", "serde",@@ -81,7 +81,7 @@ dependencies = [ [[package]] name = "aiflow-pours"-version = "0.2.108"+version = "0.2.109" dependencies = [ "aiflow-board", "aiflow-copper",@@ -91,7 +91,7 @@ dependencies = [ [[package]] name = "aiflow-router"-version = "0.2.108"+version = "0.2.109" dependencies = [ "aiflow-board", "aiflow-grid",@@ -102,7 +102,7 @@ dependencies = [ [[package]] name = "aiflow-run"-version = "0.2.108"+version = "0.2.109" dependencies = [ "serde", "serde_json",
Cargo.toml+1−1@@ -14,7 +14,7 @@ members = [ ] [workspace.package]-version = "0.2.108"+version = "0.2.109" edition = "2021" license = "MIT" repository = "https://wiki.adom.inc/adom/adom-aiflow"
bin/adom-aiflow⋯ 1 unchanged line ⋯
crates/adom-aiflow/src/fields_versions.rs+63@@ -6,6 +6,10 @@ //! - 0.10.9 (adom/adom-fields#32): a hot part with no tabNet put its watts, and read its rise, inside the //! drill of large through-hole pins (a pin whose 1.2 mm disk is mostly drill, e.g. MachineContactLarge). //! - 0.10.10 refused a spec with AI Flow's `decoupling` pairs; 0.10.11 reads them again.+//! - 0.10.12 (adom/adom-fields#36): a spec net name resolves as AI Flow's netname does (exact, else the one board+//! net that differs by a leading "/"). Before it, a hot part whose tabNet was written without the "/" of a+//! hierarchical board's net was dropped and the board solved cold. 0.10.12 also refuses a hot part that is not+//! on the board or whose tabNet is on none of its pads: `hot_spec_problems` says so before the solve. use serde_json::Value; use std::path::Path; @@ -29,6 +33,17 @@ pub fn stale_notes(fields: &Value, spec: &Value, board: &Path) -> Vec<String> { out.push(format!("this Fields solve is adom-fields {}, before 0.10.10, which swapped pads 1 and 2 of mirrored bottom parts at MR90/MR270 on a .brd ({}): their currents and heat landed on the wrong copper. Update adom-fields (adom-wiki pkg install adom/adom-fields) and solve again before you trust these numbers.", version_text(solver), mirrored.join(", "))); } }+ // 0.10.12: a hot tabNet written without the "/" of a hierarchical board's net was dropped before it+ if solver < (0, 10, 12) && text.contains("(kicad_pcb") {+ if let Ok(b) = aiflow_board::Board::from_text(&board.display().to_string(), text.clone()) {+ let parts: Vec<String> = spec["hot"].as_object().into_iter().flatten()+ .filter(|(_, h)| h["tabNet"].as_str().is_some_and(|t| !t.is_empty() && !b.nets.contains_key(t) && board_net(&b, t).is_some()))+ .map(|(n, _)| n.clone()).collect();+ if !parts.is_empty() {+ out.push(format!("this Fields solve is adom-fields {}, before 0.10.12, which dropped a hot part whose tabNet is written without the board net's \"/\" ({}): the board solved cold there. Update adom-fields (adom-wiki pkg install adom/adom-fields) and solve again.", version_text(solver), parts.join(", ")));+ }+ }+ } if solver < (0, 10, 9) && text.contains("(kicad_pcb") { if let Ok(b) = aiflow_board::Board::from_text(&board.display().to_string(), text) { let mut parts = Vec::new();@@ -44,6 +59,30 @@ pub fn stale_notes(fields: &Value, spec: &Value, board: &Path) -> Vec<String> { out } +/// The board net a spec name means, as Fields 0.10.12 reads it: the exact name, else the one net that differs only by+/// a leading "/". None when there is none (or more than one).+fn board_net<'a>(b: &'a aiflow_board::Board, name: &str) -> Option<&'a str> {+ if let Some((k, _)) = b.nets.get_key_value(name) { return Some(k.as_str()); }+ let bare = name.trim_start_matches('/');+ let m: Vec<&String> = b.nets.keys().filter(|n| n.trim_start_matches('/') == bare).collect();+ (m.len() == 1).then(|| m[0].as_str())+}++/// Issue: adom-fields 0.10.12 refuses a spec whose hot part is not on the board, or whose tabNet is on none of its+/// pads (before, it dropped the part and solved the board cold). The lines that would refuse, said before the solve.+pub fn hot_spec_problems(spec: &Value, b: &aiflow_board::Board) -> Vec<String> {+ let mut out = Vec::new();+ for (name, h) in spec["hot"].as_object().into_iter().flatten() {+ if !b.footprints.contains_key(name) { out.push(format!("hot.{name}: there is no part {name} on this board")); continue; }+ let Some(tab) = h["tabNet"].as_str().filter(|t| !t.is_empty()) else { continue };+ let nets: std::collections::BTreeSet<&str> = b.pads_of(name).iter().map(|p| p.net.as_str()).filter(|n| !n.is_empty()).collect();+ if !board_net(b, tab).is_some_and(|n| nets.contains(n)) {+ out.push(format!("hot.{name}.tabNet {tab} is not a net on any of {name}'s pads ({})", nets.into_iter().collect::<Vec<_>>().join(", ")));+ }+ }+ out+}+ /// The installed adom-fields when it is 0.10.10, which refuses AI Flow's `decoupling` pairs. pub fn installed_note(version_line: &str) -> Option<String> { let v = version_line.split_whitespace().last().and_then(parse)?;@@ -120,4 +159,28 @@ mod tests { assert!(installed_note("adom-fields 0.10.11").is_none()); assert!(installed_note("garbage").is_none()); }++ /// adom-fields 0.10.12: a missing hot part or a tabNet on none of its pads is named before the solve; "GND" finds+ /// "/GND"; a solve before 0.10.12 that dropped such a part is told to solve again.+ #[test]+ fn hot_parts_fields_would_refuse_are_named_and_an_old_solve_that_dropped_one_is_stale() {+ 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()));+ std::fs::create_dir_all(&d).unwrap();+ let p = d.join("b.kicad_pcb");+ std::fs::write(&p, t).unwrap();+ let b = aiflow_board::Board::from_text("b.kicad_pcb", t.to_string()).unwrap();+ let spec = json!({"hot": {"Q1": {"watts": 1.0, "tabNet": "GND"}, "U9": {"watts": 0.5}, "Q2": {"watts": 1}}});+ let mut probs = hot_spec_problems(&spec, &b);+ probs.sort();+ assert_eq!(probs, vec!["hot.Q2: there is no part Q2 on this board".to_string(), "hot.U9: there is no part U9 on this board".to_string()], "GND finds /GND on Q1's pads");+ let wrong = json!({"hot": {"Q1": {"watts": 1.0, "tabNet": "VIN"}}});+ assert!(hot_spec_problems(&wrong, &b)[0].contains("not a net on any of Q1's pads (/GND, /SW)"));+ let old = stale_notes(&json!({"inputIdentity": {"solverVersion": "0.10.11"}}), &json!({"hot": {"Q1": {"tabNet": "GND"}}}), &p);+ assert!(old.iter().any(|n| n.contains("before 0.10.12") && n.contains("Q1")), "{old:?}");+ assert!(stale_notes(&json!({"inputIdentity": {"solverVersion": "0.10.12"}}), &json!({"hot": {"Q1": {"tabNet": "GND"}}}), &p).is_empty());+ let _ = std::fs::remove_dir_all(&d);+ } }
crates/adom-aiflow/src/main.rs+3@@ -6382,6 +6382,9 @@ fn main() { 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, &[]); }+ // 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()]); } } let fields_mod_plan = fields_review::recommended_modules(&board_now, &spec); if aiflow_analyze::needs_field_screen(&spec,what) && fields_file.is_file() && !fields_observed(&r,&fields_file) {
docs/release-0.2.109.mdadded+11@@ -0,0 +1,11 @@+# AI Flow 0.2.109++Follow-ups for adom-fields 0.10.12 (adom/adom-fields#36).++- **Hot parts Fields will refuse are named first.** adom-fields 0.10.12 refuses a spec whose hot part is not on the+ board, or whose `tabNet` is on none of its pads (before, it dropped the part and solved the board cold, which a+ thermal screen could read as a pass). `analyze current` and `analyze thermal` now say so before the solve, naming+ each part and its pad nets. A tabNet written without the board net's leading "/" counts, as Fields reads it.+- **A solve that dropped a hot part is called stale.** A Fields solve from before 0.10.12 on a hierarchical board+ whose hot tabNet was written without the "/" (`GND` for `/GND`) had that part dropped: `analyze` now says to update+ adom-fields and solve again, as it does for the earlier fixes.
package.json+1−1@@ -1,7 +1,7 @@ { "slug": "adom-aiflow", "type": "app",- "version": "0.2.108",+ "version": "0.2.109", "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.108",+ "version": "0.2.109", "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.",