← Commit history
Merge PR #677: 0.2.147: embedded models at board level, switch-node bodies by face, keepout precision (#288 #289 #290) (fix-288-290 -> main) merge
Showing changes introduced by the merge (against its first parent).
8 files changed
+96−23
Cargo.lock+11−11@@ -4,7 +4,7 @@ version = 4 [[package]] name = "adom-aiflow"-version = "0.2.146"+version = "0.2.147" dependencies = [ "aiflow-analyze", "aiflow-board",@@ -28,7 +28,7 @@ dependencies = [ [[package]] name = "aiflow-analyze"-version = "0.2.146"+version = "0.2.147" dependencies = [ "aiflow-board", "aiflow-sys",@@ -39,7 +39,7 @@ dependencies = [ [[package]] name = "aiflow-board"-version = "0.2.146"+version = "0.2.147" dependencies = [ "aiflow-sys", "roxmltree",@@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "aiflow-bridge"-version = "0.2.146"+version = "0.2.147" dependencies = [ "aiflow-board", "aiflow-sys",@@ -59,7 +59,7 @@ dependencies = [ [[package]] name = "aiflow-copper"-version = "0.2.146"+version = "0.2.147" dependencies = [ "aiflow-board", "aiflow-grid",@@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "aiflow-grid"-version = "0.2.146"+version = "0.2.147" dependencies = [ "aiflow-board", "serde",@@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "aiflow-place"-version = "0.2.146"+version = "0.2.147" dependencies = [ "aiflow-board", "aiflow-sys",@@ -89,7 +89,7 @@ dependencies = [ [[package]] name = "aiflow-pours"-version = "0.2.146"+version = "0.2.147" dependencies = [ "aiflow-board", "aiflow-copper",@@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "aiflow-router"-version = "0.2.146"+version = "0.2.147" dependencies = [ "aiflow-board", "aiflow-grid",@@ -111,7 +111,7 @@ dependencies = [ [[package]] name = "aiflow-run"-version = "0.2.146"+version = "0.2.147" dependencies = [ "aiflow-sys", "serde",@@ -120,7 +120,7 @@ dependencies = [ [[package]] name = "aiflow-sys"-version = "0.2.146"+version = "0.2.147" dependencies = [ "serde_json", ]
Cargo.toml+1−1@@ -15,7 +15,7 @@ members = [ ] [workspace.package]-version = "0.2.146"+version = "0.2.147" edition = "2021" license = "MIT" repository = "https://wiki.adom.inc/adom/adom-aiflow"
crates/adom-aiflow/src/embedded_models.rs+12−2@@ -46,10 +46,13 @@ impl Embedded { Embedded { by_ref, board: board_files } } - /// The base64 of `kicad-embed://name` for this reference, its footprint's first, then the board's.+ /// The base64 of `kicad-embed://name` for this reference, its footprint's first, then the board's. Issue #288 (King+ /// Silver): KiCad 10 leaves a stub in the footprint (name, type, checksum, no data) and keeps the data once in the+ /// board's own embedded_files: an empty stub falls through to the board. fn data(&self, reference: &str, path: &str) -> Option<&String> { let name = path.strip_prefix(PREFIX)?;- self.by_ref.get(reference).and_then(|f| f.get(name)).or_else(|| self.board.get(name)).filter(|d| !d.is_empty())+ self.by_ref.get(reference).and_then(|f| f.get(name)).filter(|d| !d.is_empty())+ .or_else(|| self.board.get(name).filter(|d| !d.is_empty())) } /// Whether this embedded model is in the board file.@@ -121,6 +124,10 @@ mod tests { (footprint "Imported:R" (layer "F.Cu") (at 9 5) (property "Reference" "R1") (pad "1" smd rect (at 0 0) (size 1 1) (layers "F.Cu")) (model "kicad-embed://board-level.step"))+ (footprint "Imported:C" (layer "F.Cu") (at 13 5) (property "Reference" "C1")+ (pad "1" smd rect (at 0 0) (size 1 1) (layers "F.Cu"))+ (model "kicad-embed://board-level.step")+ (embedded_files (file (name "board-level.step") (type model) (checksum "x")))) (embedded_files (file (name "board-level.step") (type model) (data |{}|))))"#, b64(b"ISO-10303-21; raw"))).unwrap() } @@ -132,6 +139,9 @@ mod tests { assert!(e.present("D1", "kicad-embed://led.step")); assert!(e.present("R1", "kicad-embed://board-level.step"), "the board's own embedded files"); assert!(!e.present("D1", "kicad-embed://other.step"));+ // issue #288: a data-less stub in the footprint, the data in the board's embedded_files+ assert!(e.present("C1", "kicad-embed://board-level.step"), "the footprint's stub falls through to the board's data");+ assert_eq!(e.extract("C1", "kicad-embed://board-level.step", &std::env::temp_dir().join(format!("emb288-{}", std::process::id()))).map(|f| std::fs::read(f).unwrap()).unwrap(), b"ISO-10303-21; raw"); assert!(!e.present("D1", "${KICAD9_3DMODEL_DIR}/x.step")); 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();
crates/adom-aiflow/src/pourverify.rs+20−2@@ -43,8 +43,10 @@ pub fn pts_points(pts: &Node) -> Vec<(f64, f64)> { } fn canonical(n: &Node) -> Value {- // issue #270: a zone outline compares as its points, arcs sampled, whichever way it is written- if n.tag == "pts" && n.nodes().any(|c| c.tag == "arc") {+ // issue #270: a zone outline compares as its points, arcs sampled, whichever way it is written; issue #290 (King+ // Silver): straight outlines too, each point rounded to 0.1 um as the plan writes it, so a vertex stored with five+ // decimals (113.70361) matches the plan written from that same board (113.7036)+ if n.tag == "pts" { return json!(["pts", [], pts_points(n).iter().map(|(x, y)| json!(["xy", [x, y], []])).collect::<Vec<_>>()]); } let mut children: Vec<Value> = n.nodes().map(canonical).collect();@@ -1589,6 +1591,22 @@ mod tests { assert_eq!(proof["groups"].as_array().unwrap().len(), 3); } + #[test]+ fn a_keepout_with_a_five_decimal_vertex_verifies_against_its_own_board() {+ // issue #290 (King Silver): a keepout rule area whose vertex the board stores with five decimals+ let text = r#"(kicad_pcb (version 20260101) (layers (0 "F.Cu" signal) (31 "B.Cu" signal)) (net 0 "") (net 1 "GND")+ (gr_rect (start 100 80) (end 140 110) (layer "Edge.Cuts"))+ (zone (net 0) (net_name "") (layers "F.Cu" "B.Cu") (uuid "ko-1") (hatch edge 0.5)+ (connect_pads (clearance 0)) (min_thickness 0.25) (filled_areas_thickness no)+ (keepout (tracks not_allowed) (vias not_allowed) (pads not_allowed) (copperpour not_allowed) (footprints allowed))+ (fill (thermal_gap 0.5) (thermal_bridge_width 0.5))+ (polygon (pts (xy 110 85) (xy 113.70361 85) (xy 113.70361 90.25) (xy 110 90.25)))))"#;+ let b = Board::from_text("test", text.to_string()).unwrap();+ let plan = plan_from_board(&b);+ let proof = check_with(&b, &plan, true).unwrap();+ assert_eq!(proof["pass"], true, "{proof}");+ }+ #[test] fn a_zone_outline_of_arcs_is_read_and_verifies() { // issue #270 (King Silver): a round board's zone is four arcs in its outline, no xy points
crates/adom-aiflow/src/switchnode.rs+34−5@@ -201,8 +201,16 @@ pub fn power_node_length(b: &Board, net: &str, pads: &[(String, String)]) -> (f6 pub fn findings(spec: &Value, b: &Board) -> Vec<String> { let max_len = spec["switchNodeMaxLengthMm"].as_f64().unwrap_or(12.0); let mut out = Vec::new();- let bodies = crate::testplan::bodies(b);+ // issue #289 (King Silver): only a part with pads or a 3D model is a body, named by its reference (else its+ // footprint name), and outer copper runs under it only on its own face: a bottom-side silkscreen logo is none+ let bodies: Vec<(String, bool, (f64, f64, f64, f64))> = crate::testplan::sided_bodies(b).into_iter().filter(|(r, _, _)| {+ b.pads.iter().any(|p| &p.reference == r) || b.footprints.get(r).is_some_and(|fp| b.text.get(fp.start..fp.end).is_some_and(|s| s.contains("(model ")))+ }).map(|(r, front, bb)| {+ let name = if r.trim().is_empty() { b.footprints.get(&r).map(|fp| fp.lib.rsplit(':').next().unwrap_or("").to_string()).filter(|s| !s.is_empty()).unwrap_or_else(|| "an unnamed footprint".into()) } else { r };+ (name, front, bb)+ }).collect(); let layer_name = |l: usize| b.copper_layers.get(l).cloned().unwrap_or_else(|| format!("layer {l}"));+ let faces = |l: usize, front: bool| match layer_name(l).as_str() { "F.Cu" => front, "B.Cu" => !front, _ => true }; for net in nets(spec, b) { // the parts that belong to the switch node may sit over it let own: Vec<String> = b.pads.iter().filter(|p| p.net == net).map(|p| p.reference.clone()).collect();@@ -215,8 +223,8 @@ pub fn findings(spec: &Value, b: &Board) -> Vec<String> { for i in 0..=n { let f = i as f64 / n as f64; let p = (t.a.0 + (t.b.0 - t.a.0) * f, t.a.1 + (t.b.1 - t.a.1) * f);- for (r, bb) in &bodies {- if own.contains(r) { continue; }+ for (r, front, bb) in &bodies {+ if own.contains(r) || !faces(t.layer, *front) { continue; } let tag = format!("{r} ({})", layer_name(t.layer)); if in_box(p, bb, t.width / 2.0) && !under.contains(&tag) { under.push(tag); } }@@ -225,8 +233,8 @@ pub fn findings(spec: &Value, b: &Board) -> Vec<String> { for z in b.zones().iter().filter(|z| z.net == net) { for (l, poly) in &z.fills { for p in poly {- for (r, bb) in &bodies {- if own.contains(r) { continue; }+ for (r, front, bb) in &bodies {+ if own.contains(r) || !faces(*l, *front) { continue; } let tag = format!("{r} ({} pour)", layer_name(*l)); if in_box(*p, bb, 0.0) && !under.contains(&tag) { under.push(tag); } }@@ -283,6 +291,27 @@ mod tests { Board::from_text("t.kicad_pcb", format!("(kicad_pcb {nets} (gr_rect (start 0 0) (end 40 20) (layer \"Edge.Cuts\")) {parts})")).unwrap() } + #[test]+ fn a_bottom_side_logo_is_not_a_part_over_front_copper() {+ // issue #289: an F.Cu SW track passes over a bottom-side, pad-less silkscreen logo (with a B.Fab box) and+ // under a front capacitor; only the capacitor is reported, by name+ let b = Board::from_text("fixture", r#"(kicad_pcb (layers (0 "F.Cu" signal) (2 "B.Cu" signal) (25 "Edge.Cuts" user)) (net 0 "") (net 1 "SW")+ (gr_rect (start 0 0) (end 60 20) (layer "Edge.Cuts"))+ (footprint "Resistor_SMD:R_0603" (layer "B.Cu") (at 30 10) (property "Reference" "R9")+ (fp_rect (start -0.8 -0.4) (end 0.8 0.4) (layer "B.Fab"))+ (pad "1" smd rect (at -0.8 0) (size 0.8 0.8) (layers "B.Cu") (net 0 "")))+ (footprint "Logos:Adom" (layer "B.Cu") (at 20 10) (property "Reference" "")+ (fp_rect (start -3 -3) (end 3 3) (layer "B.Fab")) (fp_poly (pts (xy -3 -3) (xy 3 -3) (xy 3 3)) (layer "B.SilkS")))+ (footprint "Capacitor_SMD:C_0805" (layer "F.Cu") (at 40 10) (property "Reference" "C7")+ (fp_rect (start -1 -0.6) (end 1 0.6) (layer "F.Fab"))+ (pad "1" smd rect (at -1 0) (size 1 1) (layers "F.Cu") (net 0 "")))+ (segment (start 10 10) (end 50 10) (width 0.5) (layer "F.Cu") (net 1)))"#.to_string()).unwrap();+ let f = findings(&json!({"switchNodes": ["SW"], "switchNodeMaxLengthMm": 100}), &b);+ let under: Vec<&String> = f.iter().filter(|x| x.contains("runs under")).collect();+ assert_eq!(under.len(), 1, "{f:?}");+ assert!(under[0].contains("C7 (F.Cu)") && !under[0].contains("under (") && !under[0].contains("Adom") && !under[0].contains("R9"), "{f:?}");+ }+ #[test] fn an_external_fet_controller_budgets_only_its_power_node() { // issue #287: Q1/Q2 and L1 join in 6 mm; the controller U1's SW pin is 30 mm away on the same net
docs/release-0.2.147.mdadded+16@@ -0,0 +1,16 @@+# adom-aiflow 0.2.147++Fixes adom/adom-aiflow#288 (King Silver): `models` reported a KiCad 10 board's embedded 3D models as unresolved.++- **A model embedded at board level is bound.** KiCad 10 writes `(model "kicad-embed://x.step")` in the footprint, a stub `(embedded_files (file (name "x.step") (type model) (checksum ...)))` with no data in the footprint, and the data once in the board's top-level `embedded_files`. The footprint's empty stub hid the board's data, so `models --offline` said "not embedded" and the live `models` counted every such model as unresolved. An empty stub now falls through to the board's data, for the live count, the offline check and the box and orientation check (the zstd data is decoded as before).++Fixes adom/adom-aiflow#289 (King Silver): the switch-node check counted a bottom-side silkscreen logo as a part ("SW copper runs under (F.Cu pour)").++- **Only a real part on the copper's face counts.** A footprint is a body for this check only when it has pads or a 3D model, and switch copper on F.Cu or B.Cu runs "under" it only on its own face (inner layers count either face, as before). A pad-less logo or a bottom-side part under a front pour is no longer reported.+- **Every reported part is named:** its reference, else its footprint name.++Fixes adom/adom-aiflow#290 (King Silver): `verify-pours --from-board --adopt` refused the board's own keepout rule area.++- **A plan written from a board verifies against that board.** The exact-match comparison read straight zone outlines at full precision, while the plan writes each point rounded to 0.1 µm, so a vertex stored with five decimals (113.70361) never matched its own plan (113.7036): "differs in: geometry (plan 4 vertices, board 4)". Every outline is now compared at the plan's precision, keepout rule areas included.++Also in this release: John Lauer's PR #203, `project-page-check` passes a page whose `readme_order` is `["md","html"]` (README.md first, readme.html below it) instead of calling the HTML a shadow.
package.json+1−1@@ -1,7 +1,7 @@ { "slug": "adom-aiflow", "type": "app",- "version": "0.2.146",+ "version": "0.2.147", "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.146",+ "version": "0.2.147", "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.",