← Commit history
AI Flow 0.2.79: inner-layer pours landed; analyze falls back after a failed measure
Co-Authored-By: Claude Opus 5.5 <[email protected]>
10 files changed
+68−18
Cargo.lock+10−10@@ -4,7 +4,7 @@ version = 4 [[package]] name = "adom-aiflow"-version = "0.2.78"+version = "0.2.79" dependencies = [ "aiflow-analyze", "aiflow-board",@@ -25,7 +25,7 @@ dependencies = [ [[package]] name = "aiflow-analyze"-version = "0.2.78"+version = "0.2.79" dependencies = [ "aiflow-board", "serde",@@ -35,7 +35,7 @@ dependencies = [ [[package]] name = "aiflow-board"-version = "0.2.78"+version = "0.2.79" dependencies = [ "roxmltree", "serde",@@ -44,7 +44,7 @@ dependencies = [ [[package]] name = "aiflow-bridge"-version = "0.2.78"+version = "0.2.79" dependencies = [ "aiflow-board", "serde",@@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "aiflow-copper"-version = "0.2.78"+version = "0.2.79" dependencies = [ "aiflow-board", "aiflow-grid",@@ -63,7 +63,7 @@ dependencies = [ [[package]] name = "aiflow-grid"-version = "0.2.78"+version = "0.2.79" dependencies = [ "aiflow-board", "serde",@@ -72,7 +72,7 @@ dependencies = [ [[package]] name = "aiflow-place"-version = "0.2.78"+version = "0.2.79" dependencies = [ "aiflow-board", "serde",@@ -81,7 +81,7 @@ dependencies = [ [[package]] name = "aiflow-pours"-version = "0.2.78"+version = "0.2.79" dependencies = [ "aiflow-board", "aiflow-copper",@@ -91,7 +91,7 @@ dependencies = [ [[package]] name = "aiflow-router"-version = "0.2.78"+version = "0.2.79" dependencies = [ "aiflow-board", "aiflow-grid",@@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "aiflow-run"-version = "0.2.78"+version = "0.2.79" dependencies = [ "serde", "serde_json",
Cargo.toml+1−1@@ -14,7 +14,7 @@ members = [ ] [workspace.package]-version = "0.2.78"+version = "0.2.79" edition = "2021" license = "MIT" repository = "https://wiki.adom.inc/adom/adom-aiflow"
bin/adom-aiflow⋯ 1 unchanged line ⋯
crates/adom-aiflow/src/gate_eval.rs+21−1@@ -32,7 +32,10 @@ pub fn with_planned_pours(b: &Board, plan_v: &Value, pours: Option<&Value>, vias let landed = |z: &Value| { let net = z["net"].as_str().unwrap_or(""); let layers: Vec<&str> = z["layers"].as_array().map(|a| a.iter().filter_map(|l| l.as_str()).collect()).unwrap_or_default();- have.iter().any(|h| h.net == net && h.layers.iter().any(|&l| layers.contains(&aiflow_board::LAYER_NAMES[l])))+ // issue #204 (elijahlo): a zone on an inner layer only (In1.Cu, In2.Cu) is landed too; the board's zone+ // layer list holds the outer layers, its fills every copper layer, so both are compared+ have.iter().any(|h| h.net == net && (h.layers.iter().any(|&l| layers.contains(&aiflow_board::LAYER_NAMES[l]))+ || layers.iter().any(|l| h.inner_layers.iter().any(|n| n == l)))) }; let zones: Vec<Value> = pours.and_then(|p| p["zones"].as_array()).map(|a| aiflow_pours::resolve_outline(b, a)).unwrap_or_default() .into_iter().filter(|z| z.get("keepout").is_none() && z["type"].as_str() != Some("keepout") && !landed(z)).collect();@@ -146,4 +149,21 @@ mod tests { let (n0, p0, s0) = with_planned_pours(&b, &plan, None, None).unwrap(); assert!(n0.is_none() && p0.is_none() && s0.is_null()); }+ /// Issue #204: a planned pour on an inner layer only is landed when the board has that zone; no duplicate.+ #[test]+ fn an_inner_layer_zone_on_the_board_is_not_planned_again() {+ let b = Board::from_text("t.kicad_pcb", r#"(kicad_pcb (version 20240108) (generator "t")+ (layers (0 "F.Cu" signal) (4 "In1.Cu" signal) (6 "In2.Cu" signal) (2 "B.Cu" signal) (25 "Edge.Cuts" user))+ (net 0 "") (net 1 "GND")+ (gr_rect (start 0 0) (end 20 20) (layer "Edge.Cuts") (stroke (width 0.1) (type default)))+ (zone (net 1) (net_name "GND") (layer "In1.Cu") (polygon (pts (xy 0 0) (xy 20 0) (xy 20 20) (xy 0 20)))+ (filled_polygon (layer "In1.Cu") (pts (xy 0 0) (xy 20 0) (xy 20 20) (xy 0 20))))+)"#.to_string()).unwrap();+ let pours = json!({"zones": [{"net": "GND", "layers": ["In1.Cu"], "polygon": [[0, 0], [20, 0], [20, 20], [0, 20]]}]});+ let (board, _, rep) = with_planned_pours(&b, &json!({"nets": []}), Some(&pours), None).unwrap();+ assert!(board.is_none(), "the inner GND plane is already on the board: {rep}");+ let pours2 = json!({"zones": [{"net": "GND", "layers": ["In2.Cu"], "polygon": [[0, 0], [20, 0], [20, 20], [0, 20]]}]});+ assert!(with_planned_pours(&b, &json!({"nets": []}), Some(&pours2), None).unwrap().0.is_some(), "a plane on another inner layer is still planned");+ }+ }
crates/adom-aiflow/src/main.rs+7−3@@ -5557,11 +5557,15 @@ fn main() { let plan_v = plan_with_board_copper(&read_json(&planp), &board_now); let spec = spec_of(&r); let zsp = dir.join("zone-state.json");- let zs = if zsp.is_file() { Some(read_json(&zsp.display().to_string())) } else {- // issue #202 (Noah): no live measurement on this run (offline pours, adopted): read the pours from the saved board's fills+ // issue #202 (Noah), #205 (elijahlo): the live measurement when it is a good one (a measure that did not+ // settle leaves its error in zone-state.json); otherwise the pours of the saved board's own fills+ let zlive = if zsp.is_file() { Some(read_json(&zsp.display().to_string())) } else { None };+ let live_ok = zlive.as_ref().is_some_and(aiflow_analyze::pour_cover::live_zone_state_usable);+ let zs = if live_ok { zlive } else { let z = aiflow_analyze::pour_cover::zone_state_from_board(&board_now); let n = z["zones"].as_array().map(|a| a.len()).unwrap_or(0);- if n > 0 { eprintln!("no live copper measurement on this run (no zone-state.json): the pours are read from the saved board's own fills ({n} filled zone(s))"); Some(z) } else { None }+ let why = match &zlive { None => "no zone-state.json", Some(z) if z["success"] == false => "the last measure did not settle", Some(_) => "the live measurement has no copper zones" };+ if n > 0 { eprintln!("no usable live copper measurement on this run ({why}): the pours are read from the saved board's own fills ({n} filled zone(s))"); Some(z) } else { zlive } }; let name = format!("analyze-{what}"); r.stage_start(&name, Some("binary"), None);
crates/aiflow-analyze/src/pour_cover.rs+14@@ -77,6 +77,12 @@ fn net_fills(board: &Board, net: &str) -> Vec<Fill> { /// --from-board`, no live editor): the zone state `measure` reads from the editor, built from the saved board's /// own filled polygons instead, so `analyze current|thermal` see the pours the board really carries. /// Only zones with saved fills count (an unfilled zone gives nothing); keepouts are skipped.+/// Issue #205 (elijahlo): a zone-state.json from a measure that did not settle holds the error, not the pours;+/// only a successful measurement with at least one copper zone stands in for the board.+pub fn live_zone_state_usable(z: &serde_json::Value) -> bool {+ z["success"] != false && z["zones"].as_array().is_some_and(|a| a.iter().any(|x| x["type"] == "copper"))+}+ pub fn zone_state_from_board(board: &Board) -> serde_json::Value { let mut zones = Vec::new(); for z in board.root.find_all("zone") {@@ -431,4 +437,12 @@ mod tests { assert_eq!(zones[0]["layers"], serde_json::json!(["F.Cu"])); } + /// Issue #205: a failed measure's zone-state.json is not used; a good one is.+ #[test]+ fn a_failed_measure_is_not_a_live_zone_state() {+ assert!(!live_zone_state_usable(&serde_json::json!({"success": false, "error": "native copper measurement did not settle"})));+ assert!(!live_zone_state_usable(&serde_json::json!({"success": true, "zones": [{"type": "keepout"}]})));+ assert!(live_zone_state_usable(&serde_json::json!({"success": true, "zones": [{"type": "copper", "net": "GND"}]})));+ }+ }
crates/aiflow-board/src/lib.rs+4−1@@ -122,6 +122,8 @@ impl Via { pub struct Zone { pub net: String, pub layers: Vec<usize>,+ /// the inner copper layers the zone names (In1.Cu ...): `layers` holds only F.Cu and B.Cu (issue #204)+ pub inner_layers: Vec<String>, pub outline: Vec<Pt>, pub fills: Vec<(usize, Vec<Pt>)>, }@@ -590,7 +592,8 @@ impl Board { let poly = pts_of(f); if poly.len() >= 3 { fills.push((layer, poly)); } }- out.push(Zone { net: self.item_net(z), layers, outline, fills });+ let inner_layers: Vec<String> = names.iter().filter(|n| n.starts_with("In") && n.ends_with(".Cu")).cloned().collect();+ out.push(Zone { net: self.item_net(z), layers, inner_layers, outline, fills }); } out }
docs/release-0.2.79.mdadded+9@@ -0,0 +1,9 @@+# AI Flow 0.2.79++- **An inner-layer pour on the board is not planned again** (#204, elijahlo). A zone on In1.Cu or In2.Cu only+ (a GND or power plane) now counts as landed when the planned pour names that layer, so `land pours` no longer+ adds a second zone over it. A plane on a different inner layer is still planned. Test added.+- **Analyze falls back to the saved board when the last measure failed** (#205, elijahlo). A measure that did not+ settle leaves its error in zone-state.json; analyze used to read that as "no pours" on an offline board. It now+ uses zone-state.json only when it is a successful measurement with copper zones, otherwise it reads the pours+ from the saved board's own fills and says why. Test added.
package.json+1−1@@ -1,7 +1,7 @@ { "slug": "adom-aiflow", "type": "app",- "version": "0.2.78",+ "version": "0.2.79", "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.78",+ "version": "0.2.79", "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.",