← Commit history
Merge PR #691: 0.2.153: planeUnder as kicad_plan_route keepouts (KiCad Bridge 1.1.17) (aiflow-0.2.153 -> main) merge
Showing changes introduced by the merge (against its first parent).
8 files changed
+45−15
Cargo.lock+11−11@@ -4,7 +4,7 @@ version = 4 [[package]] name = "adom-aiflow"-version = "0.2.152"+version = "0.2.153" dependencies = [ "aiflow-analyze", "aiflow-board",@@ -28,7 +28,7 @@ dependencies = [ [[package]] name = "aiflow-analyze"-version = "0.2.152"+version = "0.2.153" dependencies = [ "aiflow-board", "aiflow-sys",@@ -39,7 +39,7 @@ dependencies = [ [[package]] name = "aiflow-board"-version = "0.2.152"+version = "0.2.153" dependencies = [ "aiflow-sys", "roxmltree",@@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "aiflow-bridge"-version = "0.2.152"+version = "0.2.153" dependencies = [ "aiflow-board", "aiflow-sys",@@ -59,7 +59,7 @@ dependencies = [ [[package]] name = "aiflow-copper"-version = "0.2.152"+version = "0.2.153" dependencies = [ "aiflow-board", "aiflow-grid",@@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "aiflow-grid"-version = "0.2.152"+version = "0.2.153" dependencies = [ "aiflow-board", "serde",@@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "aiflow-place"-version = "0.2.152"+version = "0.2.153" dependencies = [ "aiflow-board", "aiflow-sys",@@ -89,7 +89,7 @@ dependencies = [ [[package]] name = "aiflow-pours"-version = "0.2.152"+version = "0.2.153" dependencies = [ "aiflow-board", "aiflow-copper",@@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "aiflow-router"-version = "0.2.152"+version = "0.2.153" dependencies = [ "aiflow-board", "aiflow-grid",@@ -111,7 +111,7 @@ dependencies = [ [[package]] name = "aiflow-run"-version = "0.2.152"+version = "0.2.153" dependencies = [ "aiflow-sys", "serde",@@ -120,7 +120,7 @@ dependencies = [ [[package]] name = "aiflow-sys"-version = "0.2.152"+version = "0.2.153" dependencies = [ "serde_json", ]
Cargo.toml+1−1@@ -15,7 +15,7 @@ members = [ ] [workspace.package]-version = "0.2.152"+version = "0.2.153" edition = "2021" license = "MIT" repository = "https://wiki.adom.inc/adom/adom-aiflow"
crates/aiflow-router/src/lib.rs+2@@ -501,6 +501,8 @@ impl Router { let walled: Vec<String> = self.board.pads.iter().filter(|p| p.net != reg.net && !p.net.is_empty() && aiflow_board::geom::point_in_poly(p.x, p.y, ®.poly) && (p.thru || (reg.layer == aiflow_board::F_CU) == p.on_f)).map(|p| format!("{}.{} ({})", p.reference, p.name, p.net)).collect(); if !walled.is_empty() { self.log(format!(" planeUnder {}: walls in {} pad(s) of other nets: {}{}", reg.label, walled.len(), walled.iter().take(8).cloned().collect::<Vec<_>>().join(", "), if walled.len() > 8 { ", ..." } else { "" })); } }+ // KiCad Bridge 1.1.17: the same regions as kicad_plan_route's `keepouts`, ready to pass for a hand-planned route+ if !regions.is_empty() { self.log(format!(" kicad_plan_route keepouts (KiCad Bridge 1.1.17+, the board's own frame): {}", plane_under::plan_route_keepouts(®ions))); } self.keep = regions; }
crates/aiflow-router/src/plane_under.rs+19@@ -40,6 +40,14 @@ fn pad_box(board: &Board, keys: &[String]) -> Result<(f64, f64, f64, f64), Strin Ok(geom::bbox(&pts)) } +/// The regions as `kicad_plan_route`'s `keepouts` argument (KiCad Bridge 1.1.17): board coordinates, the call's own+/// frame, the owning net excepted, tracks and vias kept out (the bridge's defaults). A hand route the AI plans+/// with it keeps out of the planes `route` and the gate keep (issue #293, item 8).+pub fn plan_route_keepouts(regions: &[Region]) -> serde_json::Value {+ let r = |v: f64| (v * 1000.0).round() / 1000.0;+ serde_json::Value::Array(regions.iter().map(|g| serde_json::json!({"layers": [layer_name(g.layer)], "points": g.poly.iter().map(|(x, y)| [r(*x), r(*y)]).collect::<Vec<_>>(), "exceptNet": g.net})).collect())+}+ /// Every planeUnder entry as a polygon on its copper layer (F.Cu, B.Cu, In1.Cu, In2.Cu, ...). /// An entry naming a layer not present on the board, or an unknown part or shape, is an error, so /// a typo never silently disables the policy.@@ -292,3 +300,14 @@ mod tests { assert!(found[1].contains("A via at (10.00, 6.00)"), "{found:?}"); } }++#[cfg(test)]+mod keepout_arg_tests {+ use super::*;+ #[test]+ fn regions_become_plan_route_keepouts() {+ let g = Region { layer: B_CU, net: "GND".into(), poly: vec![(1.0, 2.0), (5.0, 2.0), (5.0, 6.00049)], label: "x".into() };+ let v = plan_route_keepouts(&[g]);+ assert_eq!(v, serde_json::json!([{"layers": ["B.Cu"], "points": [[1.0, 2.0], [5.0, 2.0], [5.0, 6.0]], "exceptNet": "GND"}]));+ }+}
docs/release-0.2.153.mdadded+9@@ -0,0 +1,9 @@+# adom-aiflow 0.2.153++Adopts KiCad Bridge 1.1.17: `kicad_plan_route` takes `keepouts` (adom/adom-aiflow#293 item 8, Mohit Singh).++- **`route` prints the planeUnder regions as that argument**, ready to pass: `kicad_plan_route keepouts (...): [{layers, points, exceptNet}]`, in the board's own coordinates (the call's default frame), with the region's own net excepted. A route the AI plans by hand then keeps out of the planes that `route` and the gate keep.+- Skill aiflow-power-layout:+ - Pass `keepouts` to `kicad_plan_route`.+ - Read `callerKeepouts` and `keepoutsInTheWay` in its reply.+ - On an older bridge, fall back to the layer-only workaround.
package.json+1−1@@ -1,7 +1,7 @@ { "slug": "adom-aiflow", "type": "app",- "version": "0.2.152",+ "version": "0.2.153", "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.152",+ "version": "0.2.153", "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.",
skills/aiflow-power-layout/SKILL.md+1−1@@ -52,7 +52,7 @@ Without a layer policy the grid router treats B.Cu as free space: on the buck it `around` is the pad box of the listed parts or pads grown by `margin` (default 1.0 mm); `"shape": "hull"` makes it their convex hull grown by the margin instead, which hugs a loop whose parts sit at the extremes; `polygon: [[x, y], ...]` gives the region exactly. `route` prints each region's extents and outline, and names other-net pads a region walls in. The same `"shape": "hull"` works on a `pours` entry with `around` (a tight switch-node patch); `pour` prints the outline it made and the other-net pads inside it. `planeUnder` accepts any copper layer on the board (`F.Cu`, `B.Cu`, `In1.Cu`, `In2.Cu`, ...): on outer layers it keeps foreign tracks and vias out, and on inner planes it keeps foreign inner tracks, zones, and piercing vias out so reference planes stay unbroken on 4+ layer boards. The gate fails on any other-net track, via or zone inside a region (`planeUnderIssues` in gate.json) and `finish` refuses until it is clear. -A region is a hard wall: a pin of another net inside it (the IC's EN or FB pin under U1) can only leave on the other layer, and a Kelvin sense may find no path. When `route` closes short with a region in place, shrink the margin, list fewer parts, or draw a polygon that leaves those pins a way out, before taking the nets by hand. If you do route by hand (`take route=ai`, `step routing --back --why "..."`): FB on F.Cu inside the quiet side, the VOUT sense along an edge, not across the plane. `kicad_plan_route` does not know `spec.planeUnder`: it plans straight through a region. `route` prints each region's outline (`planeUnder ...: x a..b, y c..d, polygon [...]`); for a net near one, pass the planner `layers` without the region's layer (and `allowVias: false` when the path would cross it), or draw the region as a KiCad rule area (no tracks, pours allowed) before planning; use `gridMm: 0.1` at fine pitch; and run `gate` after landing (its planeUnder check reads the regions). A hop to the other layer is one `kicad_route_net` call with the layer on each point (`[{F@a},{B@a},{B@b},{F@b}]` lands two vias; KiCad Bridge 1.1.16), not two calls. Land hand routes one at a time with a dry run first (`tools/route_live.py routes.json` calls `kicad_route_net` with `dryRun`, commits only on 0 DRC errors, and chains `expectedRevision` from each reply). After `adopt-board` of the reworked board, `route` keeps that copper and plans only what is still open (an empty plan when nothing is), and the gate checks the regions on it. Filled zones count as that copper: a net the board's pours already join is not tracked (refill unfilled zones first; `route` warns when it tracks a net that has one). A pad on its plane's own layer (`planes: {"GND": "F.Cu"}`, an F.Cu pad) gets no via.+A region is a hard wall: a pin of another net inside it (the IC's EN or FB pin under U1) can only leave on the other layer, and a Kelvin sense may find no path. When `route` closes short with a region in place, shrink the margin, list fewer parts, or draw a polygon that leaves those pins a way out, before taking the nets by hand. If you do route by hand (`take route=ai`, `step routing --back --why "..."`): FB on F.Cu inside the quiet side, the VOUT sense along an edge, not across the plane. `kicad_plan_route` keeps out of `spec.planeUnder` only when you pass the regions: `route` prints them ready to pass (`kicad_plan_route keepouts (...): [{layers, points, exceptNet}]`, in the board's own frame, so no `frame` argument); give that list as `keepouts` (KiCad Bridge 1.1.17 or newer). A region whose `exceptNet` is the net being planned is skipped, tracks and vias are kept out of the rest, and the reply says which were applied (`callerKeepouts`) and, when no path is left, which were in the way (`keepoutsInTheWay`). On an older bridge, pass `layers` without the region's layer (and `allowVias: false` when the path would cross it) instead. Use `gridMm: 0.1` at fine pitch, and run `gate` after landing (its planeUnder check reads the regions). A hop to the other layer is one `kicad_route_net` call with the layer on each point (`[{F@a},{B@a},{B@b},{F@b}]` lands two vias; KiCad Bridge 1.1.16), not two calls. Land hand routes one at a time with a dry run first (`tools/route_live.py routes.json` calls `kicad_route_net` with `dryRun`, commits only on 0 DRC errors, and chains `expectedRevision` from each reply). After `adopt-board` of the reworked board, `route` keeps that copper and plans only what is still open (an empty plan when nothing is), and the gate checks the regions on it. Filled zones count as that copper: a net the board's pours already join is not tracked (refill unfilled zones first; `route` warns when it tracks a net that has one). A pad on its plane's own layer (`planes: {"GND": "F.Cu"}`, an F.Cu pad) gets no via. Kelvin keepouts follow the tap's own layer (both layers only at its vias) and stop short of the power pin, so the IC GND pin keeps its pour (fixed in adom-aiflow 0.1.33; check older runs).