← Commit history
Merge PR #595: AI Flow 0.2.105: side-entry connectors a plug cannot reach (#247) (release-0.2.105 -> main) merge
Showing changes introduced by the merge (against its first parent).
10 files changed
+179−15
Cargo.lock+10−10@@ -4,7 +4,7 @@ version = 4 [[package]] name = "adom-aiflow"-version = "0.2.104"+version = "0.2.105" dependencies = [ "aiflow-analyze", "aiflow-board",@@ -25,7 +25,7 @@ dependencies = [ [[package]] name = "aiflow-analyze"-version = "0.2.104"+version = "0.2.105" dependencies = [ "aiflow-board", "serde",@@ -35,7 +35,7 @@ dependencies = [ [[package]] name = "aiflow-board"-version = "0.2.104"+version = "0.2.105" dependencies = [ "roxmltree", "serde",@@ -44,7 +44,7 @@ dependencies = [ [[package]] name = "aiflow-bridge"-version = "0.2.104"+version = "0.2.105" dependencies = [ "aiflow-board", "serde",@@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "aiflow-copper"-version = "0.2.104"+version = "0.2.105" dependencies = [ "aiflow-board", "aiflow-grid",@@ -63,7 +63,7 @@ dependencies = [ [[package]] name = "aiflow-grid"-version = "0.2.104"+version = "0.2.105" dependencies = [ "aiflow-board", "serde",@@ -72,7 +72,7 @@ dependencies = [ [[package]] name = "aiflow-place"-version = "0.2.104"+version = "0.2.105" dependencies = [ "aiflow-board", "serde",@@ -81,7 +81,7 @@ dependencies = [ [[package]] name = "aiflow-pours"-version = "0.2.104"+version = "0.2.105" dependencies = [ "aiflow-board", "aiflow-copper",@@ -91,7 +91,7 @@ dependencies = [ [[package]] name = "aiflow-router"-version = "0.2.104"+version = "0.2.105" dependencies = [ "aiflow-board", "aiflow-grid",@@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "aiflow-run"-version = "0.2.104"+version = "0.2.105" dependencies = [ "serde", "serde_json",
Cargo.toml+1−1@@ -14,7 +14,7 @@ members = [ ] [workspace.package]-version = "0.2.104"+version = "0.2.105" edition = "2021" license = "MIT" repository = "https://wiki.adom.inc/adom/adom-aiflow"
SKILL.md+1−1@@ -75,7 +75,7 @@ The flow is a file, `flows/board.json`: the steps in order (intake, rules, test- 4. **`route [--passes N]`**: the grid router on the current board with the spec's rules (wide nets, planes, per-net vias, Kelvin taps). If it closes short, the ERROR names the pins and the blockers and the three levers: more passes, back to placement (`place pack` the parts it names or the test points and indicators in the escape band, `place check`, route again), or take the stage yourself. Every open connection is counted, also a net the router never got back to after a rip-up (reason "never routed"), so the summary and the variant ranking see it. 5. **`gate`**: KiCad's DRC offline on the plan, inherited errors separated. Nothing lands until it passes. 6. **`land route`**, then **`pour`**, **`land vias`**, **`land pours`**: live through the bridge as native undo steps, each DRC-checked before it lands. A refused pour's ERROR says why (starved thermal reliefs, intersecting zones, clearance) and what to change in the spec. Both landings converge the live board on the plan, so you change the spec, run `pour` and land again: a via or trace already on the live board (same net, same points) is not landed twice, so a rerun after a stop resumes where it stopped (`--from <n>` starts at trace n), a reply lost to the transport is answered by reading the board and sending that one trace once more only if it did not land, a zone with its planned name and outline is kept, and every zone the flow landed that the plan no longer describes (renamed, reshaped, dropped) is removed first. Zones the board started with are never touched. A via whose copper would touch another net's track, via or pad (planned or on the board) is refused before anything lands, and so is a via within the spec's hole-to-hole minimum (`holeToHole`, default 0.2 mm) of any via or hole, or within `clearance` of another via's copper, whatever its net (the ERROR names the clash), and every landed via is read back: one that came back on another net than planned is taken back and the command errors with both nets.-4. **`route [--passes N]`**: the grid router on the current board with the spec's rules (wide nets, planes, per-net vias, Kelvin taps, `planeUnder` regions that no other net may cross on their layer). The router also keeps every net out of keepout areas, the board's and those inside footprints (a sensor's no-copper body), on the layers each names: no track where tracks are forbidden, no via where vias are (issue #237). Castellated (half-hole) edge pads (`pad_prop_castellated`) sit on the outline by design: `place land`, `place verify` and the router accept them and the route lands on the pad's inner half (issue #236). It plans F.Cu and B.Cu only: on a 4- or 6-layer board it says so before routing and the inner layers are fixed copper; route inner-layer nets yourself (`take route=ai`). One net searches at most `AIFLOW_ROUTE_NET_SECONDS` (default 180) per pass, and the passes stop early when one leaves many connections open and barely improves (issue #235). Copper already on the board (an `adopt-board` of a partly or fully routed board) is kept: its tracks and vias are obstacles, and only the connections it leaves open are planned; with nothing open it writes an empty plan with a note, which gate, `land route` and `finish` accept. Filled zones are that copper too: a pad inside a fill of its net on its layer (a through-hole pad on either layer) is joined, so a net its pours already join is skipped and named in the note. A net with a zone that has no fill in the board file is still tracked, with a WARNING to refill the zones and route again. With `planes`, a pad on the plane's own outer layer (an F.Cu pad on an F.Cu plane) sits in the pour and gets no stub or via; through-hole pads reach any plane. If it closes short, the ERROR names the pins and the blockers and the three levers: more passes, back to placement (`place pack` the parts it names or the test points and indicators in the escape band, `place check`, route again), or take the stage yourself. Every open connection is counted, also a net the router never got back to after a rip-up (reason "never routed"), so the summary and the variant ranking see it.+4. **`route [--passes N]`**: the grid router on the current board with the spec's rules (wide nets, planes, per-net vias, Kelvin taps, `planeUnder` regions that no other net may cross on their layer). The router also keeps every net out of keepout areas, the board's and those inside footprints (a sensor's no-copper body), on the layers each names: no track where tracks are forbidden, no via where vias are (issue #237). `place check` and `place land` also note a side-entry connector (Horizontal, right angle, JST S..B, USB receptacle) whose mouth does not face out at a board edge, naming the parts in the plug's insertion space (issue #247): advisory; `placement.connectorMating.<REF>: "<why>"` silences one mated another way. Castellated (half-hole) edge pads (`pad_prop_castellated`) sit on the outline by design: `place land`, `place verify` and the router accept them and the route lands on the pad's inner half (issue #236). It plans F.Cu and B.Cu only: on a 4- or 6-layer board it says so before routing and the inner layers are fixed copper; route inner-layer nets yourself (`take route=ai`). One net searches at most `AIFLOW_ROUTE_NET_SECONDS` (default 180) per pass, and the passes stop early when one leaves many connections open and barely improves (issue #235). Copper already on the board (an `adopt-board` of a partly or fully routed board) is kept: its tracks and vias are obstacles, and only the connections it leaves open are planned; with nothing open it writes an empty plan with a note, which gate, `land route` and `finish` accept. Filled zones are that copper too: a pad inside a fill of its net on its layer (a through-hole pad on either layer) is joined, so a net its pours already join is skipped and named in the note. A net with a zone that has no fill in the board file is still tracked, with a WARNING to refill the zones and route again. With `planes`, a pad on the plane's own outer layer (an F.Cu pad on an F.Cu plane) sits in the pour and gets no stub or via; through-hole pads reach any plane. If it closes short, the ERROR names the pins and the blockers and the three levers: more passes, back to placement (`place pack` the parts it names or the test points and indicators in the escape band, `place check`, route again), or take the stage yourself. Every open connection is counted, also a net the router never got back to after a rip-up (reason "never routed"), so the summary and the variant ranking see it. **`route --variants N`** (issue #55, at most 8): route the same board N times with different levers and let the gates pick. The levers are the ones kicad-place-route-loop lists, in a fixed order so a rerun gives the same variants: v1 is a plain `route` (shortest nets first, the spec's vias, `--passes`), then longest first, signal vias at the spec's power via size (left out when the spec's two vias are the same), most pads first, seeded orders (seed 1, 2), shortest first with 4 more passes, longest first with power-size vias and 4 more passes; more than that are more seeds. Each variant writes `plan-route-v<k>.json`, `plan-route-v<k>-report.json` and `router-v<k>.log`, and is gated with the checks `gate` runs (the same function, routed board `board-routed-v<k>.kicad_pcb`). The ranking uses the gates alone, in order: unrouted connections; gate issues (new DRC errors, unconnected, planeUnder, switch node, courtyards and bodies, decoupling errors); copper length of the plan; via count; then the failed current and thermal screens, only when a Fields solve of that exact routed board is on the run (a Fields solve per variant is not run: it takes minutes per board, so in practice this column is empty and `analyze` runs on the winner as usual); the lower variant number breaks a full tie. Without kicad-cli the variants are ranked without the gate column and the table says so. The winner becomes `plan-route.json` exactly as a plain route would, and every variant (levers, scores, plan paths, rank) is on the route outcome under `variants`, in the ledger as `route-variants`, and in the run README as a table. **`route --pick K --why "..."`** makes variant K the route plan instead (the board must be unchanged); the reason, the thread and the gates' own pick stay on the record. Then `gate` as usual. A plain `route` is unchanged. **Single-face / no-via boards** (issue #183, a CNC-milled one-layer board of through-hole parts): spec `"routeLayers": ["B.Cu"]` (or `["F.Cu"]`, or both) limits the router's layers, and `"vias": false` forbids every via: a layer change is made only on a through-hole pad of the same net, where the lead joins both faces. With both layers and `"vias": false`, F.Cu copper is wire jumpers on the component side (the router takes one only when B.Cu has no way through). Both keys are optional; when the spec is silent, the project's `.kicad_dru` decides (`(constraint disallow via)` turns vias off, `disallow track` on one layer leaves the other) and a NOTE says so. The rules-used line shows the layers and vias; `route` says how many connections closed on the single face and lists every jumper (`singleFace` on the route outcome and in `plan-route-report.json`, `jumpers` in route quality). Plane nets are routed as tracks, and pours, `thermal-vias` and stitch vias plan no via. Paths are cut on the pad (one path per face), so `gate` and `land route` see no via; a hand-written plan with a via, or copper on a face the board does not route, is a gate finding and `land route` lands nothing. Connections that cannot close are findings with suggestions (allow F.Cu jumpers, move or rotate a part, widen the channel), never a refusal. 5. **`gate`**: KiCad's DRC offline on the plan, inherited errors separated, plus any other-net copper inside a `planeUnder` region. Pours (and their vias) that `pour` planned and that are not landed yet go into the gate copy, so a net only the planned pours join is not read as unconnected (`plannedPours` in gate.json). Nothing lands until it passes.
bin/adom-aiflow⋯ 1 unchanged line ⋯
crates/adom-aiflow/src/connector_mating.rsadded+150@@ -0,0 +1,150 @@+//! Issue #247: can each side-entry connector be mated? On john/self-mixing-interferometer a JST PH side-entry+//! (S2B-PH-SM4-TB) sat 30 mm from the nearest edge with its mouth facing other parts: no plug could go in, and+//! DRC, ERC, the gate, the molecule check and Fields all passed. This reads the placed board:+//!+//! - a side-entry connector is named by its footprint (Horizontal, right angle, side entry, a JST "S..B-" part,+//! a USB receptacle);+//! - its mouth is the side of its body farthest from its signal pin row (the solder tails sit at the back);+//! - the mouth must face out of the board within `EDGE_MM` of the outline, or the plug's insertion space in front+//! of it (the plug's length for its family) must be clear of other parts' courtyards and inside the board.+//!+//! Advisory: a note from `place check` and `place land`, never a stop. `placement.connectorMating.<REF>: "<why>"`+//! in the spec silences one connector (a board-to-board part mated from above, a cable soldered in place).+//! Top-entry connectors are not judged yet: a clear ring for fingers needs part heights.+use aiflow_board::{geom, Board, Pt};+use serde_json::Value;++/// How far inside the outline a side-entry mouth may sit and still count as at the edge (mm).+pub const EDGE_MM: f64 = 2.0;++/// The mating plug's insertion length for a connector family, from its footprint (mm): the plug body and the+/// room a hand or cable needs to bring it in.+fn plug_length(fp: &str) -> f64 {+ let f = fp.to_ascii_uppercase();+ if f.contains("USB_C") || f.contains("USB-C") || f.contains("TYPE-C") { 20.0 }+ else if f.contains("USB") { 18.0 }+ else if f.contains("_GH_") || f.contains("SM0") && f.contains("GH") { 8.0 }+ else if f.contains("_XH_") || f.contains("-XH") { 12.0 }+ else if f.contains("_PH_") || f.contains("-PH-") { 10.0 }+ else if f.contains("_SH_") || f.contains("-SH-") { 6.0 }+ else { 10.0 }+}++/// A side-entry connector's footprint: Horizontal, right angle, side entry, JST's "S<n>B-" (side) parts and+/// USB receptacles. Vertical and top-entry parts are not side-entry.+pub fn side_entry(reference: &str, fp: &str) -> bool {+ let r = reference.to_ascii_uppercase();+ let f = fp.to_ascii_uppercase();+ let connector = ["J", "P", "CN", "X", "USB"].iter().any(|p| r.starts_with(p) && r[p.len()..].chars().next().is_some_and(|c| c.is_ascii_digit()))+ || f.contains("CONNECTOR") || f.contains("JST") || f.contains("USB");+ if !connector || f.contains("VERTICAL") || f.contains("TOP_ENTRY") || f.contains("TOPENTRY") { return false; }+ let name = f.rsplit(':').next().unwrap_or(&f);+ f.contains("HORIZONTAL") || f.contains("RIGHT_ANGLE") || f.contains("RIGHTANGLE") || f.contains("_RA_") || f.ends_with("_RA")+ || f.contains("SIDE_ENTRY") || f.contains("SIDEENTRY")+ || name.contains("_S") && regex_lite::Regex::new(r"(^|_)S\d+B-").unwrap().is_match(name)+ || f.contains("RECEPTACLE") && f.contains("USB")+}++fn signal_pad(name: &str) -> bool {+ let n = name.to_ascii_uppercase();+ !n.is_empty() && !n.starts_with("MP") && !n.starts_with("SH") && n != "S1" && n != "S2" && !n.starts_with("SHIELD")+}++/// A unit direction on the board snapped to the nearest axis, and its name.+fn axis(d: Pt) -> (Pt, &'static str) {+ if d.0.abs() >= d.1.abs() { if d.0 >= 0.0 { ((1.0, 0.0), "+x (right)") } else { ((-1.0, 0.0), "-x (left)") } }+ else if d.1 >= 0.0 { ((0.0, 1.0), "+y (down)") } else { ((0.0, -1.0), "-y (up)") }+}++/// One note per side-entry connector a plug cannot reach. `skip` is `placement.connectorMating` from the spec.+pub fn notes(b: &Board, skip: &Value) -> Vec<String> {+ let boxes = aiflow_place::boxes(b);+ let outline: Vec<Pt> = if b.outline.len() >= 3 { b.outline.clone() } else { let (x0, y0, x1, y1) = b.bbox; vec![(x0, y0), (x1, y0), (x1, y1), (x0, y1)] };+ let mut out = Vec::new();+ for (r, fp) in &b.footprints {+ if skip.get(r).is_some() || !side_entry(r, &fp.lib) { continue; }+ let Some(&bx) = boxes.get(r) else { continue };+ let pins: Vec<Pt> = b.pads.iter().filter(|p| &p.reference == r && signal_pad(&p.name)).map(|p| (p.x, p.y)).collect();+ if pins.is_empty() { continue; }+ let pc = (pins.iter().map(|p| p.0).sum::<f64>() / pins.len() as f64, pins.iter().map(|p| p.1).sum::<f64>() / pins.len() as f64);+ let bc = ((bx.0 + bx.2) / 2.0, (bx.1 + bx.3) / 2.0);+ let d = (bc.0 - pc.0, bc.1 - pc.1);+ if d.0.hypot(d.1) < 0.2 { continue; } // pins in the middle of the body: no mouth to tell+ let ((ux, uy), dir) = axis(d);+ // the mouth face: the body side in that direction, as a segment+ let (m0, m1): (Pt, Pt) = match (ux as i32, uy as i32) {+ (1, _) => ((bx.2, bx.1), (bx.2, bx.3)), (-1, _) => ((bx.0, bx.1), (bx.0, bx.3)),+ (_, 1) => ((bx.0, bx.3), (bx.2, bx.3)), _ => ((bx.0, bx.1), (bx.2, bx.1)),+ };+ let mid = ((m0.0 + m1.0) / 2.0, (m0.1 + m1.1) / 2.0);+ // distance from the mouth to the outline straight ahead (sampled, 0.1 mm steps up to 200 mm)+ let mut ahead = None;+ for k in 0..=2000 {+ let t = k as f64 * 0.1;+ let p = (mid.0 + ux * t, mid.1 + uy * t);+ if !geom::point_in_poly(p.0, p.1, &outline) || b.outline_cutouts.iter().any(|c| geom::point_in_poly(p.0, p.1, c)) { ahead = Some(t); break; }+ }+ let to_edge = ahead.unwrap_or(f64::INFINITY);+ if to_edge <= EDGE_MM { continue; }+ // the plug's insertion space in front of the mouth: the mouth's width plus 0.5 mm a side, its length deep+ let len = plug_length(&fp.lib);+ let w = 0.5;+ let (ex0, ey0, ex1, ey1) = match (ux as i32, uy as i32) {+ (1, _) => (m0.0, m0.1 - w, m0.0 + len, m1.1 + w), (-1, _) => (m0.0 - len, m0.1 - w, m0.0, m1.1 + w),+ (_, 1) => (m0.0 - w, m0.1, m1.0 + w, m0.1 + len), _ => (m0.0 - w, m0.1 - len, m1.0 + w, m0.1),+ };+ let blockers: Vec<&String> = boxes.iter().filter(|(o, ob)| *o != r && ob.0 < ex1 && ex0 < ob.2 && ob.1 < ey1 && ey0 < ob.3).map(|(o, _)| o).collect();+ let where_ = if to_edge.is_finite() { format!("{to_edge:.1} mm from the board edge it faces") } else { "facing no board edge".to_string() };+ let in_the_way = if blockers.is_empty() { String::new() } else { format!(", and {} sit{} in the plug's {len:.0} mm insertion space", blockers.iter().map(|s| s.as_str()).collect::<Vec<_>>().join(", "), if blockers.len() == 1 { "s" } else { "" }) };+ out.push(format!("NOTE: {r} ({}) is a side-entry connector whose mouth faces {dir} {where_}{in_the_way}: a plug may not be able to go in. Turn it so the mouth faces out at a board edge (or clear the space in front of it); when it is mated another way, say so in spec placement.connectorMating.{r}", fp.lib.rsplit(':').next().unwrap_or(&fp.lib)));+ }+ out+}++#[cfg(test)]+mod tests {+ use super::*;+ use serde_json::json;++ /// A 2-pin JST PH side-entry (S2B-PH-SM4-TB): two signal pads at the back (y +1.5), mounting pads either+ /// side, the body and courtyard extending toward the mouth (y -4.5).+ fn ph(r: &str, x: f64, y: f64, rot: f64) -> String {+ format!(r#"(footprint "Connector_JST:JST_PH_S2B-PH-SM4-TB_1x02-1MP_P2.00mm_Horizontal" (layer "F.Cu") (at {x} {y} {rot}) (property "Reference" "{r}")+ (fp_rect (start -4 -4.5) (end 4 2.5) (layer "F.CrtYd") (stroke (width 0.05)))+ (pad "1" smd rect (at -1 1.5) (size 1 3) (layers "F.Cu")) (pad "2" smd rect (at 1 1.5) (size 1 3) (layers "F.Cu"))+ (pad "MP" smd rect (at -3.4 -2.9) (size 1.5 3.4) (layers "F.Cu")) (pad "MP" smd rect (at 3.4 -2.9) (size 1.5 3.4) (layers "F.Cu")))"#)+ }++ fn board(parts: &str) -> Board {+ Board::from_text("t.kicad_pcb", format!(r#"(kicad_pcb (layers (0 "F.Cu" signal) (31 "B.Cu" signal))+ (gr_rect (start 0 0) (end 100 100) (layer "Edge.Cuts"))+ {parts})"#)).unwrap()+ }++ #[test]+ fn a_mid_board_mouth_facing_parts_is_named_and_one_at_the_edge_is_not() {+ // John's case: J1 30 mm from the top edge, its mouth up, a part in front of it+ let u = r#"(footprint "R:R0603" (layer "F.Cu") (at 50 30) (property "Reference" "R7") (fp_rect (start -1 -1) (end 1 1) (layer "F.CrtYd") (stroke (width 0.05))) (pad "1" smd rect (at 0 0) (size 1 1) (layers "F.Cu")))"#;+ let n = notes(&board(&format!("{} {u}", ph("J1", 50.0, 36.0, 0.0))), &json!({}));+ assert_eq!(n.len(), 1, "{n:?}");+ assert!(n[0].contains("J1") && n[0].contains("-y (up)") && n[0].contains("31.") && n[0].contains("R7"), "{}", n[0]);+ // the same connector with its mouth at the top edge (courtyard 0.5 mm inside): no note+ assert!(notes(&board(&ph("J2", 50.0, 5.0, 0.0)), &json!({})).is_empty());+ // turned 180 at the bottom edge: its mouth faces down, out of the board: no note+ assert!(notes(&board(&ph("J3", 50.0, 95.0, 180.0)), &json!({})).is_empty());+ // silenced in the spec+ assert!(notes(&board(&ph("J1", 50.0, 36.0, 0.0)), &json!({"J1": "mated from above by a board-to-board cable"})).is_empty());+ }++ #[test]+ fn side_entry_is_read_from_the_footprint_name() {+ assert!(side_entry("J1", "Connector_JST:JST_PH_S2B-PH-SM4-TB_1x02-1MP_P2.00mm_Horizontal"));+ assert!(side_entry("J4", "Connector_JST:JST_PH_S4B-PH-K_1x04_P2.00mm_Horizontal"));+ assert!(side_entry("J2", "Connector_USB:USB_C_Receptacle_GCT_USB4105-xx-A_16P_TopMnt_Horizontal"));+ assert!(!side_entry("J3", "Connector_JST:JST_PH_B2B-PH-K_1x02_P2.00mm_Vertical"));+ assert!(!side_entry("R1", "Resistor_SMD:R_0603_1608Metric"));+ assert_eq!(plug_length("Connector_USB:USB_C_Receptacle_GCT_USB4105"), 20.0);+ assert_eq!(plug_length("Connector_JST:JST_PH_S2B-PH-SM4-TB"), 10.0);+ }+}+
crates/adom-aiflow/src/main.rs+4@@ -1,6 +1,7 @@ //! adom-aiflow: the board loop as one command, with the clock, the negotiation and the finish line. //! Every reply starts with OK: or ERROR: and carries Hint: lines that depend on this board and run. mod bare_lands;+mod connector_mating; mod continuation; mod model_fit; mod fields_versions;@@ -5453,6 +5454,8 @@ fn main() { let mut overhang_lines = edge_overhang::check_board(&nb, &overhang).unwrap_or_else(|e| { note(&e, &[format!("Suggested: move the part inward until every pad is inside; the run's current board is unchanged ({}).", outp.display())]); Vec::new() }); // AF115: a part only in edgeOverhang lands, but place verify (live) wants edgeConnectors: say it offline overhang_lines.extend(edge_overhang::verify_notes(&nb, &spec_of(&r), &overhang));+ // issue #247: a side-entry connector a plug cannot reach (advisory)+ overhang_lines.extend(connector_mating::notes(&nb, &spec_of(&r)["placement"]["connectorMating"])); let problems = aiflow_place::check_allowing(&nb, &moved, 0.05, &edge_overhang::refs(&overhang)); // issue #140: every part outside the outline, moved or not (a part pack found no spot for is not in the moves) let outside = aiflow_place::parts_outside(&nb, &edge_overhang::refs(&overhang));@@ -5507,6 +5510,7 @@ fn main() { // issue #140: parts that will still be outside the outline once these moves land (named, then landed anyway) let landed_board = aiflow_place::moves_from_json(&mv).ok().and_then(|m| aiflow_place::move_in_text(&b, &m).ok()).and_then(|(t, _)| Board::from_text(&b.path, t).ok()); for l in edge_overhang::verify_notes(landed_board.as_ref().unwrap_or(&b), &spec_of(&r), &overhang) { eprintln!("{l}"); }+ for l in connector_mating::notes(landed_board.as_ref().unwrap_or(&b), &spec_of(&r)["placement"]["connectorMating"]) { eprintln!("{l}"); } if let Some(after) = landed_board.as_ref() { land_moves::fill_rotations(&mut mv, after); // issue #142: a Fusion move must keep each part on its side; read from the live board, not the run's copy
docs/release-0.2.105.mdadded+10@@ -0,0 +1,10 @@+# AI Flow 0.2.105++- **A connector a plug cannot reach** (#247, John). `place check` and `place land` note each side-entry connector+ (a Horizontal, right-angle or side-entry footprint, JST's S..B parts, USB receptacles) whose mouth does not face+ out of the board within 2 mm of an edge: the direction it faces, how far that edge is, and the parts whose+ courtyards sit in the plug's insertion space (the plug's length for its family: JST PH 10 mm, GH 8, XH 12,+ USB-C 20, others 10). The mouth is the side of the body away from the signal pins. Advisory, never a stop;+ `placement.connectorMating.<REF>: "<why>"` silences a connector mated another way. On+ john/self-mixing-interferometer it names J1 (mouth down, ten parts in the way) and none of the board's other+ side-entry connectors. Top-entry connectors are not judged yet (a finger ring needs part heights).
package.json+1−1@@ -1,7 +1,7 @@ { "slug": "adom-aiflow", "type": "app",- "version": "0.2.104",+ "version": "0.2.105", "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.104",+ "version": "0.2.105", "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/adom-aiflow/SKILL.md+1−1@@ -65,7 +65,7 @@ The flow is a file, `flows/board.json`: the steps in order (intake, rules, test- 4. **`route [--passes N]`**: the grid router on the current board with the spec's rules (wide nets, planes, per-net vias, Kelvin taps). If it closes short, the ERROR names the pins and the blockers and the three levers: more passes, back to placement (`place pack` the parts it names or the test points and indicators in the escape band, `place check`, route again), or take the stage yourself. Every open connection is counted, also a net the router never got back to after a rip-up (reason "never routed"), so the summary and the variant ranking see it. 5. **`gate`**: KiCad's DRC offline on the plan, inherited errors separated. Nothing lands until it passes. 6. **`land route`**, then **`pour`**, **`land vias`**, **`land pours`**: live through the bridge as native undo steps, each DRC-checked before it lands. A refused pour's ERROR says why (starved thermal reliefs, intersecting zones, clearance) and what to change in the spec. Both landings converge the live board on the plan, so you change the spec, run `pour` and land again: a via or trace already on the live board (same net, same points) is not landed twice, so a rerun after a stop resumes where it stopped (`--from <n>` starts at trace n), a reply lost to the transport is answered by reading the board and sending that one trace once more only if it did not land, a zone with its planned name and outline is kept, and every zone the flow landed that the plan no longer describes (renamed, reshaped, dropped) is removed first. Zones the board started with are never touched. A via whose copper would touch another net's track, via or pad (planned or on the board) is refused before anything lands, and so is a via within the spec's hole-to-hole minimum (`holeToHole`, default 0.2 mm) of any via or hole, or within `clearance` of another via's copper, whatever its net (the ERROR names the clash), and every landed via is read back: one that came back on another net than planned is taken back and the command errors with both nets.-4. **`route [--passes N]`**: the grid router on the current board with the spec's rules (wide nets, planes, per-net vias, Kelvin taps, `planeUnder` regions that no other net may cross on their layer). The router also keeps every net out of keepout areas, the board's and those inside footprints (a sensor's no-copper body), on the layers each names: no track where tracks are forbidden, no via where vias are (issue #237). Castellated (half-hole) edge pads (`pad_prop_castellated`) sit on the outline by design: `place land`, `place verify` and the router accept them and the route lands on the pad's inner half (issue #236). It plans F.Cu and B.Cu only: on a 4- or 6-layer board it says so before routing and the inner layers are fixed copper; route inner-layer nets yourself (`take route=ai`). One net searches at most `AIFLOW_ROUTE_NET_SECONDS` (default 180) per pass, and the passes stop early when one leaves many connections open and barely improves (issue #235). Copper already on the board (an `adopt-board` of a partly or fully routed board) is kept: its tracks and vias are obstacles, and only the connections it leaves open are planned; with nothing open it writes an empty plan with a note, which gate, `land route` and `finish` accept. Filled zones are that copper too: a pad inside a fill of its net on its layer (a through-hole pad on either layer) is joined, so a net its pours already join is skipped and named in the note. A net with a zone that has no fill in the board file is still tracked, with a WARNING to refill the zones and route again. With `planes`, a pad on the plane's own outer layer (an F.Cu pad on an F.Cu plane) sits in the pour and gets no stub or via; through-hole pads reach any plane. If it closes short, the ERROR names the pins and the blockers and the three levers: more passes, back to placement (`place pack` the parts it names or the test points and indicators in the escape band, `place check`, route again), or take the stage yourself. Every open connection is counted, also a net the router never got back to after a rip-up (reason "never routed"), so the summary and the variant ranking see it.+4. **`route [--passes N]`**: the grid router on the current board with the spec's rules (wide nets, planes, per-net vias, Kelvin taps, `planeUnder` regions that no other net may cross on their layer). The router also keeps every net out of keepout areas, the board's and those inside footprints (a sensor's no-copper body), on the layers each names: no track where tracks are forbidden, no via where vias are (issue #237). `place check` and `place land` also note a side-entry connector (Horizontal, right angle, JST S..B, USB receptacle) whose mouth does not face out at a board edge, naming the parts in the plug's insertion space (issue #247): advisory; `placement.connectorMating.<REF>: "<why>"` silences one mated another way. Castellated (half-hole) edge pads (`pad_prop_castellated`) sit on the outline by design: `place land`, `place verify` and the router accept them and the route lands on the pad's inner half (issue #236). It plans F.Cu and B.Cu only: on a 4- or 6-layer board it says so before routing and the inner layers are fixed copper; route inner-layer nets yourself (`take route=ai`). One net searches at most `AIFLOW_ROUTE_NET_SECONDS` (default 180) per pass, and the passes stop early when one leaves many connections open and barely improves (issue #235). Copper already on the board (an `adopt-board` of a partly or fully routed board) is kept: its tracks and vias are obstacles, and only the connections it leaves open are planned; with nothing open it writes an empty plan with a note, which gate, `land route` and `finish` accept. Filled zones are that copper too: a pad inside a fill of its net on its layer (a through-hole pad on either layer) is joined, so a net its pours already join is skipped and named in the note. A net with a zone that has no fill in the board file is still tracked, with a WARNING to refill the zones and route again. With `planes`, a pad on the plane's own outer layer (an F.Cu pad on an F.Cu plane) sits in the pour and gets no stub or via; through-hole pads reach any plane. If it closes short, the ERROR names the pins and the blockers and the three levers: more passes, back to placement (`place pack` the parts it names or the test points and indicators in the escape band, `place check`, route again), or take the stage yourself. Every open connection is counted, also a net the router never got back to after a rip-up (reason "never routed"), so the summary and the variant ranking see it. **`route --variants N`** (issue #55, at most 8): route the same board N times with different levers and let the gates pick. The levers are the ones kicad-place-route-loop lists, in a fixed order so a rerun gives the same variants: v1 is a plain `route` (shortest nets first, the spec's vias, `--passes`), then longest first, signal vias at the spec's power via size (left out when the spec's two vias are the same), most pads first, seeded orders (seed 1, 2), shortest first with 4 more passes, longest first with power-size vias and 4 more passes; more than that are more seeds. Each variant writes `plan-route-v<k>.json`, `plan-route-v<k>-report.json` and `router-v<k>.log`, and is gated with the checks `gate` runs (the same function, routed board `board-routed-v<k>.kicad_pcb`). The ranking uses the gates alone, in order: unrouted connections; gate issues (new DRC errors, unconnected, planeUnder, switch node, courtyards and bodies, decoupling errors); copper length of the plan; via count; then the failed current and thermal screens, only when a Fields solve of that exact routed board is on the run (a Fields solve per variant is not run: it takes minutes per board, so in practice this column is empty and `analyze` runs on the winner as usual); the lower variant number breaks a full tie. Without kicad-cli the variants are ranked without the gate column and the table says so. The winner becomes `plan-route.json` exactly as a plain route would, and every variant (levers, scores, plan paths, rank) is on the route outcome under `variants`, in the ledger as `route-variants`, and in the run README as a table. **`route --pick K --why "..."`** makes variant K the route plan instead (the board must be unchanged); the reason, the thread and the gates' own pick stay on the record. Then `gate` as usual. A plain `route` is unchanged. **Single-face / no-via boards** (issue #183, a CNC-milled one-layer board of through-hole parts): spec `"routeLayers": ["B.Cu"]` (or `["F.Cu"]`, or both) limits the router's layers, and `"vias": false` forbids every via: a layer change is made only on a through-hole pad of the same net, where the lead joins both faces. With both layers and `"vias": false`, F.Cu copper is wire jumpers on the component side (the router takes one only when B.Cu has no way through). Both keys are optional; when the spec is silent, the project's `.kicad_dru` decides (`(constraint disallow via)` turns vias off, `disallow track` on one layer leaves the other) and a NOTE says so. The rules-used line shows the layers and vias; `route` says how many connections closed on the single face and lists every jumper (`singleFace` on the route outcome and in `plan-route-report.json`, `jumpers` in route quality). Plane nets are routed as tracks, and pours, `thermal-vias` and stitch vias plan no via. Paths are cut on the pad (one path per face), so `gate` and `land route` see no via; a hand-written plan with a via, or copper on a face the board does not route, is a gate finding and `land route` lands nothing. Connections that cannot close are findings with suggestions (allow F.Cu jumpers, move or rotate a part, widen the channel), never a refusal. 5. **`gate`**: KiCad's DRC offline on the plan, inherited errors separated, plus any other-net copper inside a `planeUnder` region. Pours (and their vias) that `pour` planned and that are not landed yet go into the gate copy, so a net only the planned pours join is not read as unconnected (`plannedPours` in gate.json). Nothing lands until it passes.