← Commit history
Merge PR #610: 0.2.115: note a shaped board solved before adom-fields 0.10.14 (release-0.2.115 -> main) merge
Showing changes introduced by the merge (against its first parent).
7 files changed
+94−13
Cargo.lock+10−10@@ -4,7 +4,7 @@ version = 4 [[package]] name = "adom-aiflow"-version = "0.2.114"+version = "0.2.115" dependencies = [ "aiflow-analyze", "aiflow-board",@@ -25,7 +25,7 @@ dependencies = [ [[package]] name = "aiflow-analyze"-version = "0.2.114"+version = "0.2.115" dependencies = [ "aiflow-board", "serde",@@ -35,7 +35,7 @@ dependencies = [ [[package]] name = "aiflow-board"-version = "0.2.114"+version = "0.2.115" dependencies = [ "roxmltree", "serde",@@ -44,7 +44,7 @@ dependencies = [ [[package]] name = "aiflow-bridge"-version = "0.2.114"+version = "0.2.115" dependencies = [ "aiflow-board", "serde",@@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "aiflow-copper"-version = "0.2.114"+version = "0.2.115" dependencies = [ "aiflow-board", "aiflow-grid",@@ -63,7 +63,7 @@ dependencies = [ [[package]] name = "aiflow-grid"-version = "0.2.114"+version = "0.2.115" dependencies = [ "aiflow-board", "serde",@@ -72,7 +72,7 @@ dependencies = [ [[package]] name = "aiflow-place"-version = "0.2.114"+version = "0.2.115" dependencies = [ "aiflow-board", "serde",@@ -81,7 +81,7 @@ dependencies = [ [[package]] name = "aiflow-pours"-version = "0.2.114"+version = "0.2.115" dependencies = [ "aiflow-board", "aiflow-copper",@@ -91,7 +91,7 @@ dependencies = [ [[package]] name = "aiflow-router"-version = "0.2.114"+version = "0.2.115" dependencies = [ "aiflow-board", "aiflow-grid",@@ -102,7 +102,7 @@ dependencies = [ [[package]] name = "aiflow-run"-version = "0.2.114"+version = "0.2.115" dependencies = [ "serde", "serde_json",
Cargo.toml+1−1@@ -14,7 +14,7 @@ members = [ ] [workspace.package]-version = "0.2.114"+version = "0.2.115" 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+73@@ -10,6 +10,11 @@ //! 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.+//! - 0.10.14 (adom/adom-fields#37): before it every board was solved as its bounding rectangle. A board whose+//! edge is not one axis-aligned rectangle (an arc, a circle, a curve, a cutout, a slanted edge) had FR4 counted+//! where there is none: a round board's rise read about 15 % low, a T shape several %, rounded corners under+//! 1 %; its stitching fix plan could put vias off the board. Rectangles are byte-identical. (0.10.13 had the+//! fix but stamped 0.10.12; a note on such a solve is harmless.) use serde_json::Value; use std::path::Path; @@ -44,6 +49,12 @@ pub fn stale_notes(fields: &Value, spec: &Value, board: &Path) -> Vec<String> { } } }+ // 0.10.14: a board whose edge is not one axis-aligned rectangle was solved as its bounding rectangle+ if solver < (0, 10, 14) {+ if let Some(why) = plan_board(board, &text).as_ref().and_then(shaped_edge) {+ out.push(format!("this Fields solve is adom-fields {}, before 0.10.14, which solved every board as its bounding rectangle; this board's edge is not one ({why}), so FR4 was counted where there is none (a round board's rise read about 15 % low, a T shape several %, rounded corners under 1 %) and a stitching fix plan could put vias off the board. Update adom-fields (adom-wiki pkg install adom/adom-fields) and solve again.", version_text(solver)));+ }+ } 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();@@ -59,6 +70,34 @@ pub fn stale_notes(fields: &Value, spec: &Value, board: &Path) -> Vec<String> { out } +/// The board model of the solved board file: a KiCad board as it is, a Fusion/EAGLE .brd through AI Flow's own+/// rendering (its Dimension layer becomes Edge.Cuts).+fn plan_board(board: &Path, text: &str) -> Option<aiflow_board::Board> {+ let name = board.display().to_string();+ if text.contains("(kicad_pcb") { return aiflow_board::Board::from_text(&name, text.to_string()).ok(); }+ if aiflow_board::eagle::is_eagle(text) { return aiflow_board::eagle::to_kicad(text).ok().and_then(|t| aiflow_board::Board::from_text(&name, t).ok()); }+ None+}++/// Why a board's edge is not one axis-aligned rectangle (adom-fields 0.10.14's "shaped"), or None for a rectangle.+pub fn shaped_edge(b: &aiflow_board::Board) -> Option<String> {+ if !b.outline_cutouts.is_empty() { return Some(format!("{} cutout(s) inside the outline", b.outline_cutouts.len())); }+ // the outline's corners: drop repeated points and points on a straight run between their neighbours+ let mut pts: Vec<(f64, f64)> = Vec::new();+ for &p in &b.outline { if pts.last().map_or(true, |q: &(f64, f64)| (q.0 - p.0).abs() > 1e-6 || (q.1 - p.1).abs() > 1e-6) { pts.push(p); } }+ if pts.len() > 1 && (pts[0].0 - pts[pts.len() - 1].0).abs() < 1e-6 && (pts[0].1 - pts[pts.len() - 1].1).abs() < 1e-6 { pts.pop(); }+ let n = pts.len();+ if n < 3 { return None; }+ let corners: Vec<(f64, f64)> = (0..n).filter(|&i| {+ let (a, p, c) = (pts[(i + n - 1) % n], pts[i], pts[(i + 1) % n]);+ ((p.0 - a.0) * (c.1 - p.1) - (p.1 - a.1) * (c.0 - p.0)).abs() > 1e-6+ }).map(|i| pts[i]).collect();+ let axis = |a: (f64, f64), c: (f64, f64)| (a.0 - c.0).abs() < 1e-6 || (a.1 - c.1).abs() < 1e-6;+ let k = corners.len();+ if k == 4 && (0..4).all(|i| axis(corners[i], corners[(i + 1) % 4])) { return None; }+ Some(if (0..k).any(|i| !axis(corners[i], corners[(i + 1) % k])) { "a curved or slanted edge".to_string() } else { format!("a {k}-corner outline") })+}+ /// 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> {@@ -183,4 +222,38 @@ mod tests { assert!(stale_notes(&json!({"inputIdentity": {"solverVersion": "0.10.12"}}), &json!({"hot": {"Q1": {"tabNet": "GND"}}}), &p).is_empty()); let _ = std::fs::remove_dir_all(&d); }++ /// adom-fields 0.10.14: a board whose edge is not one axis-aligned rectangle is told to solve again; a+ /// rectangle (also drawn as four lines, or with a point mid-edge) is not.+ #[test]+ fn a_shaped_board_solved_before_0_10_14_is_told_to_solve_again() {+ let board = |edge: &str| aiflow_board::Board::from_text("t.kicad_pcb", format!("(kicad_pcb (layers (0 \"F.Cu\" signal) (25 \"Edge.Cuts\" user)) {edge})")).unwrap();+ let line = |a: (f64, f64), b: (f64, f64)| format!("(gr_line (start {} {}) (end {} {}) (layer \"Edge.Cuts\"))", a.0, a.1, b.0, b.1);+ assert_eq!(shaped_edge(&board("(gr_rect (start 0 0) (end 30 20) (layer \"Edge.Cuts\"))")), None);+ let four = [line((0.0, 0.0), (15.0, 0.0)), line((15.0, 0.0), (30.0, 0.0)), line((30.0, 0.0), (30.0, 20.0)), line((30.0, 20.0), (0.0, 20.0)), line((0.0, 20.0), (0.0, 0.0))].join(" ");+ assert_eq!(shaped_edge(&board(&four)), None, "a mid-edge point is still a rectangle");+ assert!(shaped_edge(&board("(gr_circle (center 15 15) (end 30 15) (layer \"Edge.Cuts\"))")).is_some(), "a round board");+ let tee = [line((0.0, 0.0), (30.0, 0.0)), line((30.0, 0.0), (30.0, 10.0)), line((30.0, 10.0), (20.0, 10.0)), line((20.0, 10.0), (20.0, 30.0)),+ line((20.0, 30.0), (10.0, 30.0)), line((10.0, 30.0), (10.0, 10.0)), line((10.0, 10.0), (0.0, 10.0)), line((0.0, 10.0), (0.0, 0.0))].join(" ");+ assert_eq!(shaped_edge(&board(&tee)).as_deref(), Some("a 8-corner outline"));+ let bore = "(gr_rect (start 0 0) (end 30 20) (layer \"Edge.Cuts\")) (gr_circle (center 15 10) (end 17 10) (layer \"Edge.Cuts\"))";+ assert!(shaped_edge(&board(bore)).is_some_and(|w| w.contains("cutout")));+ let dir = tempfile_dir();+ let round = dir.join("round.kicad_pcb");+ std::fs::write(&round, "(kicad_pcb (layers (0 \"F.Cu\" signal) (25 \"Edge.Cuts\" user)) (gr_circle (center 15 15) (end 30 15) (layer \"Edge.Cuts\")))").unwrap();+ let old = stale_notes(&json!({"inputIdentity": {"solverVersion": "0.10.12"}}), &json!({}), &round);+ assert!(old.iter().any(|n| n.contains("before 0.10.14")), "{old:?}");+ assert!(stale_notes(&json!({"inputIdentity": {"solverVersion": "0.10.14"}}), &json!({}), &round).is_empty());+ let rect = dir.join("rect.kicad_pcb");+ std::fs::write(&rect, "(kicad_pcb (layers (0 \"F.Cu\" signal) (25 \"Edge.Cuts\" user)) (gr_rect (start 0 0) (end 30 20) (layer \"Edge.Cuts\")))").unwrap();+ assert!(stale_notes(&json!({"inputIdentity": {"solverVersion": "0.10.12"}}), &json!({}), &rect).is_empty(), "a rectangle is byte-identical");+ let _ = std::fs::remove_dir_all(&dir);+ }++ fn tempfile_dir() -> std::path::PathBuf {+ let d = std::env::temp_dir().join(format!("aiflow-fv-{}", std::process::id()));+ std::fs::create_dir_all(&d).unwrap();+ d+ }+ }
docs/release-0.2.115.mdadded+8@@ -0,0 +1,8 @@+# adom-aiflow 0.2.115++## Fields: a shaped board solved before adom-fields 0.10.14++adom-fields 0.10.14 (adom/adom-fields#37) solves a board in its real shape. Before it, every board was solved as its bounding rectangle, so a board whose edge is not one axis-aligned rectangle had FR4 counted where there is none. A round board's rise read about 15 % low, a T shape several %, and rounded corners under 1 %. A stitching fix plan could also put vias off the board. Rectangles are unchanged.++- `analyze` now notes a Fields solve older than 0.10.14 on such a board and suggests updating adom-fields and solving again. A shaped board is one with an arc, a circle, a curve, a slanted edge or a cutout, on KiCad boards and Fusion/EAGLE .brd boards. The note names why the board counts as shaped.+- As with the earlier Fields notes, this is a suggestion; the screen itself is unchanged.
package.json+1−1@@ -1,7 +1,7 @@ { "slug": "adom-aiflow", "type": "app",- "version": "0.2.114",+ "version": "0.2.115", "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.114",+ "version": "0.2.115", "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.",