← Commit history
0.2.158: Altium lane placement steps (#297)
12 files changed
+181−28
Cargo.lock+11−11Cargo.toml+1−1bin/adom-aiflowcrates/adom-aiflow/src/altium_placement.rs+52crates/adom-aiflow/src/continuation.rs+15−1crates/adom-aiflow/src/main.rs+20−6crates/aiflow-copper/src/lib.rs+4−2crates/aiflow-place/src/lib.rs+64−3docs/release-0.2.158.md+10package.json+1−1page.json+1−1skills/adom-aiflow/SKILL.md+2−2Cargo.lock+11−11@@ -4,7 +4,7 @@ version = 4 [[package]] name = "adom-aiflow"-version = "0.2.157"+version = "0.2.158" dependencies = [ "aiflow-analyze", "aiflow-board",@@ -28,7 +28,7 @@ dependencies = [ [[package]] name = "aiflow-analyze"-version = "0.2.157"+version = "0.2.158" dependencies = [ "aiflow-board", "aiflow-sys",@@ -39,7 +39,7 @@ dependencies = [ [[package]] name = "aiflow-board"-version = "0.2.157"+version = "0.2.158" dependencies = [ "aiflow-sys", "roxmltree",@@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "aiflow-bridge"-version = "0.2.157"+version = "0.2.158" dependencies = [ "aiflow-board", "aiflow-sys",@@ -59,7 +59,7 @@ dependencies = [ [[package]] name = "aiflow-copper"-version = "0.2.157"+version = "0.2.158" dependencies = [ "aiflow-board", "aiflow-grid",@@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "aiflow-grid"-version = "0.2.157"+version = "0.2.158" dependencies = [ "aiflow-board", "serde",@@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "aiflow-place"-version = "0.2.157"+version = "0.2.158" dependencies = [ "aiflow-board", "aiflow-sys",@@ -89,7 +89,7 @@ dependencies = [ [[package]] name = "aiflow-pours"-version = "0.2.157"+version = "0.2.158" dependencies = [ "aiflow-board", "aiflow-copper",@@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "aiflow-router"-version = "0.2.157"+version = "0.2.158" dependencies = [ "aiflow-board", "aiflow-grid",@@ -111,7 +111,7 @@ dependencies = [ [[package]] name = "aiflow-run"-version = "0.2.157"+version = "0.2.158" dependencies = [ "aiflow-sys", "serde",@@ -120,7 +120,7 @@ dependencies = [ [[package]] name = "aiflow-sys"-version = "0.2.157"+version = "0.2.158" dependencies = [ "serde_json", ]
Cargo.toml+1−1@@ -15,7 +15,7 @@ members = [ ] [workspace.package]-version = "0.2.157"+version = "0.2.158" edition = "2021" license = "MIT" repository = "https://wiki.adom.inc/adom/adom-aiflow"
bin/adom-aiflow⋯ 1 unchanged line ⋯
crates/adom-aiflow/src/altium_placement.rs+52@@ -83,6 +83,42 @@ pub fn fuller(a: Value, b: Value) -> Value { if n(&b) > n(&a) { b } else { a } } +/// Issue #297 (idan gida): parts whose 3D body (`altium_bodies`, the read's frame, y up) reaches more than `tol` mm past+/// their courtyard on the plan board (y down): a library body offset from its footprint, which shows up as body overlaps+/// that no placement can fix. One line per part, naming the side and the distance.+pub fn body_offsets(plan: &Board, bodies: &Value, tol: f64) -> Vec<String> {+ let courtyards = aiflow_place::boxes(plan);+ let mut per: BTreeMap<String, (f64, f64, f64, f64)> = BTreeMap::new();+ for b in bodies["bodies"].as_array().into_iter().flatten() {+ let Some(r) = b["ref"].as_str() else { continue };+ let f = |k: &str| b[k].as_f64();+ let bx = match (f("x0"), f("y0"), f("x1"), f("y1")) {+ (Some(x0), Some(y0), Some(x1), Some(y1)) => (x0.min(x1), -y0.max(y1), x0.max(x1), -y0.min(y1)),+ _ => match (f("cx"), f("cy"), f("w"), f("h")) {+ (Some(cx), Some(cy), Some(w), Some(h)) => {+ let a = f("rotation").unwrap_or(0.0).to_radians();+ let (hw, hh) = ((w / 2.0 * a.cos()).abs() + (h / 2.0 * a.sin()).abs(), (w / 2.0 * a.sin()).abs() + (h / 2.0 * a.cos()).abs());+ (cx - hw, -cy - hh, cx + hw, -cy + hh)+ }+ _ => continue,+ },+ };+ let e = per.entry(r.to_string()).or_insert(bx);+ *e = (e.0.min(bx.0), e.1.min(bx.1), e.2.max(bx.2), e.3.max(bx.3));+ }+ let mut out = Vec::new();+ for (r, b) in &per {+ if aiflow_place::courtyard_local(plan, r).is_none() { continue; }+ let Some(c) = courtyards.get(r) else { continue };+ let past = [("left", c.0 - b.0), ("top", c.1 - b.1), ("right", b.2 - c.2), ("bottom", b.3 - c.3)];+ let (side, d) = past.iter().copied().fold(("", 0.0), |m, p| if p.1 > m.1 { p } else { m });+ if d > tol {+ out.push(format!("{r}'s 3D body reaches {d:.2} mm past its courtyard ({side} side, as the board is drawn): the library's 3D body is likely offset from the footprint. Body overlaps with {r} come from that, not from the placement: fix the body in the footprint library, update the board from it, then `place verify` again"));+ }+ }+ out+}+ /// kicad_placement_validate's reply for the plan board of one live read. pub fn validation(plan: &Board, revision: &str, full_drc: &Value, check: &Value) -> Value { let outside = refs_outside(plan);@@ -131,6 +167,22 @@ mod tests { fn pad(r: &str, x: f64, y: f64) -> Value { json!({"ref": r, "name": "1", "x": x, "y": y, "sizeX": 1.0, "sizeY": 1.0, "rotation": 0, "net": "A", "layer": "F.Cu", "shape": "rect"}) } fn plan(text: &str) -> Board { Board::from_text("plan.kicad_pcb", aiflow_board::altium::render_plan_board(text).unwrap()).unwrap() } + /// Issue #297: a module whose 3D body sits 3.5 mm off its pads is named as a library body offset; a body inside its+ /// courtyard is not.+ #[test]+ fn a_body_offset_from_its_footprint_is_named() {+ let t = "(kicad_pcb (version 20260206) (layers (0 \"F.Cu\" signal) (25 \"Edge.Cuts\" user)) (gr_rect (start 0 0) (end 30 20) (layer \"Edge.Cuts\"))\n\+ (footprint \"M\" (layer \"F.Cu\") (at 10 10) (property \"Reference\" \"U1\") (fp_rect (start -3 -3) (end 3 3) (layer \"F.CrtYd\")) (pad \"1\" smd rect (at 0 0) (size 1 1) (layers \"F.Cu\") (net \"A\")))\n\+ (footprint \"R\" (layer \"F.Cu\") (at 20 10) (property \"Reference\" \"R1\") (fp_rect (start -1 -1) (end 1 1) (layer \"F.CrtYd\")) (pad \"1\" smd rect (at 0 0) (size 1 1) (layers \"F.Cu\") (net \"A\"))))";+ let b = Board::from_text("t", t.to_string()).unwrap();+ // the read's frame is y up: U1's courtyard is y -13..-7 there; its body is 3.5 mm to the right+ let bodies = json!({"bodies": [{"ref": "U1", "x0": 7.5, "y0": -12.5, "x1": 16.5, "y1": -7.5, "z0": 0, "z1": 3},+ {"ref": "R1", "cx": 20.0, "cy": -10.0, "w": 1.6, "h": 0.8, "rotation": 30.0}]});+ let lines = body_offsets(&b, &bodies, 1.0);+ assert_eq!(lines.len(), 1, "{lines:?}");+ assert!(lines[0].starts_with("U1's 3D body reaches 3.50 mm past its courtyard (right side"), "{lines:?}");+ }+ #[test] fn the_live_read_is_a_placement_state_the_verifier_accepts() { let t = read(json!([{"ref": "R1", "x": 5.0, "y": 5.0, "rotation": 90.0, "side": "top", "pattern": "R0603"},
crates/adom-aiflow/src/continuation.rs+15−1@@ -134,7 +134,12 @@ pub fn assess(data: &Value, pending: &[String], stop: Option<Result<Value, Strin if data["outcomes"]["place-land"]["mode"]=="verified-existing" { let board=data["boards"].as_array().and_then(|a|a.last()).and_then(Value::as_str).unwrap_or(""); let spec=data["spec"].as_str().unwrap_or("");- if crate::copper_carry::placement_bound(data,&data["outcomes"]["place-land"],std::path::Path::new(board),std::path::Path::new(spec)).is_err() {+ let proof=&data["outcomes"]["place-land"];+ // issue #297 (idan gida): a verify that did not pass is said as such, not as a changed board or spec+ if proof["pass"]==false {+ let why=proof["error"].as_str().map(|e|format!(" ({})",e.lines().next().unwrap_or(e).chars().take(200).collect::<String>())).unwrap_or_default();+ remaining.push(format!("place verify: the last verify did not pass{why}; fix what it found and verify again"));+ } else if crate::copper_carry::placement_bound(data,proof,std::path::Path::new(board),std::path::Path::new(spec)).is_err() { remaining.push("place verify: board or spec binding changed; verify again".into()); } }@@ -213,6 +218,15 @@ mod tests { .iter() .any(|x| x.as_str().unwrap().contains("finish must be repeated"))); }+ /// Issue #297 (idan gida): a place verify that found body overlaps says so, not "binding changed".+ #[test]+ fn a_failed_place_verify_is_named_as_failed() {+ let d = json!({"outcomes":{"place-land":{"mode":"verified-existing","pass":false,"error":"3D bodies overlap: U1 and J2\nmore"}}});+ let r = assess(&d, &[], None);+ let a: Vec<&str> = r["remaining"].as_array().unwrap().iter().filter_map(|x| x.as_str()).collect();+ assert!(a.iter().any(|x| x.contains("did not pass (3D bodies overlap: U1 and J2)")), "{a:?}");+ assert!(!a.iter().any(|x| x.contains("binding changed")), "{a:?}");+ } #[test] fn partial_progress_is_not_completion() { let d = json!({"currentStep":"current"});
crates/adom-aiflow/src/main.rs+20−6@@ -5818,6 +5818,8 @@ fn main() { let before=altium_placement::state(&plan,&rev,&rb); let drc=altium_drc(&br,&rb,"place verify"); let check=br.raw_call("altium_placement_check",&json!({"marginMm":0.0}));+ // issue #297: a library 3D body offset from its footprint, named before its overlaps are read as placement+ for l in altium_placement::body_offsets(&plan,&br.raw_call("altium_bodies",&json!({})),1.0) { eprintln!("NOTE (library, not placement): {l}"); } let validation=altium_placement::validation(&plan,&rev,&drc,&check); let (plan2,rev2)=altium_live_read(&r,&cli,&dir); (before,validation,altium_placement::state(&plan2,&rev2,&rb))@@ -5847,7 +5849,9 @@ fn main() { let intent = placement_intent::of_spec(&spec); let (wishes, anchor_lines) = aiflow_place::intent::apply_anchors(&b, &wishes, &intent); let (wishes, chain_plans, chain_lines) = aiflow_place::apply_chains(&b, &wishes, &chains, 0.05);- let (mv, mut lines) = aiflow_place::pack(&b, &wishes, 0.05, courtyard_edge);+ // issue #297: a declared edge overhang packs as `place check` and `place land` accept it (pads inside)+ let overhang_refs = edge_overhang::allowed(&spec, allow_outside).map(|o| edge_overhang::refs(&o)).unwrap_or_default();+ let (mv, mut lines) = aiflow_place::pack_allowing(&b, &wishes, 0.05, courtyard_edge, &overhang_refs); lines.extend(anchor_lines); lines.extend(placement_intent::pack_lines(&b, &mv, &intent)); write_json(Path::new(out), &serde_json::to_value(&mv).unwrap());@@ -5858,7 +5862,6 @@ fn main() { let mut msg = format!("legal spots for {} of {} parts{}:\n{}", mv.len(), wishes.len(), if left.is_empty() { String::new() } else { format!(" (no spot for {}; left where {} now)", left.join(", "), if left.len() == 1 { "it is" } else { "they are" }) }, lines.join("\n")); // and every part the packed board would still have outside the outline let packed = aiflow_place::move_in_text(&b, &mv).ok().and_then(|(t, _)| Board::from_text(&b.path, t).ok());- let overhang_refs = edge_overhang::allowed(&spec, allow_outside).map(|o| edge_overhang::refs(&o)).unwrap_or_default(); let outside = aiflow_place::parts_outside(packed.as_ref().unwrap_or(&b), &overhang_refs); if !outside.is_empty() { msg.push_str(&format!("\nFINDING: {} part(s) outside the board outline after this pack:", outside.len()));@@ -5908,10 +5911,21 @@ fn main() { } let spec_i = spec_of(&r); if let Err(e) = placement_intent::check(&mut r, &dir, &spec_i, &nb, "place check") { r.save().ok(); note(&e, &[placement_intent::HINT.into(), format!("The run's current board is unchanged; the moved board is {}.", outp.display())]); }- let drc = run_drc_for(&r, &outp.display().to_string()).unwrap_or_else(|e| err(&format!("DRC on the moved board failed: {e}"), &[]));- let baseline = run_drc_for(&r, &r.current_board()).unwrap_or_else(|e| err(&format!("baseline DRC failed: {e}"), &[]));- let s = aiflow_copper::summarize_with(&drc, Some(&baseline), silk_policy::blocking(&spec_i, &r.current_board()));+ // issue #297 (idan gida): an Altium run may have no KiCad anywhere; its placement is judged by Altium's DRC+ // after landing (`place verify`), so a missing KiCad DRC is said, never a stop, and the checks below still run+ let altium = aiflow_bridge::eda::active().id() == "altium" || r.data["remoteBoard"].as_str().is_some_and(|rb| rb.starts_with(aiflow_bridge::eda::ALTIUM_PREFIX));+ let kicad_drc = |board: &str, what: &str| -> Option<Value> {+ match run_drc_for(&r, board) {+ Ok(v) => Some(v),+ Err(e) if altium => { eprintln!("WARNING: no KiCad DRC for the {what} ({e}). On the Altium lane that is not a stop: the courtyard and body check, the ranking and the board record below still run, and Altium's own DRC judges the placement after `place land` (`place verify`)."); None }+ Err(e) => err(&format!("DRC on the {what} failed: {e}"), &[]),+ }+ };+ let drc = kicad_drc(&outp.display().to_string(), "moved board");+ let baseline = if drc.is_some() { kicad_drc(&r.current_board(), "run's current board (baseline)") } else { None };+ let s = match (&drc, &baseline) { (Some(d), Some(bl)) => aiflow_copper::summarize_with(d, Some(bl), silk_policy::blocking(&spec_i, &r.current_board())), _ => json!({"newErrors": 0, "notRun": true}) }; let errors = s["errors"].as_u64().unwrap_or(0);+ let drc_line = if s["notRun"] == true { format!("moved board {} was not checked by KiCad DRC (no KiCad: Altium's DRC checks it after landing)", outp.display()) } else { format!("moved board {} is DRC-clean ({errors} errors, all inherited)", outp.display()) }; // Bounding boxes are conservative packing hints, not exact courtyard geometry. // Native KiCad DRC decides whether the actual courtyards overlap. if !problems.is_empty() { eprintln!("Hint: conservative bounding-box advisory: {}. Native courtyard DRC is authoritative.", problems.join("; ")); }@@ -5944,7 +5958,7 @@ fn main() { r.save().unwrap(); let lines: Vec<String> = lines.into_iter().chain(overhang_lines).chain(outside.iter().map(|(_, w)| format!("FINDING: {w}"))).chain(rank_lines).collect(); let outside_hint = if outside.is_empty() { String::new() } else { aiflow_place::OUTSIDE_HINT.to_string() };- ok(&format!("{}\nmoved board {} is DRC-clean ({errors} errors, all inherited){mech_line}{} and is now the run's current board", lines.join("\n"), outp.display(), if outside.is_empty() { String::new() } else { format!("; {} part(s) outside the outline (FINDING lines above)", outside.len()) }), &[outside_hint, if overhang.is_empty() { "Land the same moves live with `place land --moves ...`.".into() } else { "Land the same moves live with `place land --moves ...` (the edge overhang parts are sent with allowOutside, the others are not).".into() }]);+ ok(&format!("{}\n{drc_line}{mech_line}{} and is now the run's current board", lines.join("\n"), if outside.is_empty() { String::new() } else { format!("; {} part(s) outside the outline (FINDING lines above)", outside.len()) }), &[outside_hint, if overhang.is_empty() { "Land the same moves live with `place land --moves ...`.".into() } else { "Land the same moves live with `place land --moves ...` (the edge overhang parts are sent with allowOutside, the others are not).".into() }]); } "land" => { let m = moves.as_deref().unwrap_or_else(|| err("place land needs --moves moves.json", &[]));
crates/aiflow-copper/src/lib.rs+4−2@@ -641,10 +641,12 @@ pub fn native_kicad_cli() -> Option<String> { Command::new(cli).args(["pcb", "drc", "--help"]).output().ok() .map(|h| format!("{}{}", String::from_utf8_lossy(&h.stdout), String::from_utf8_lossy(&h.stderr)).contains("--refill-zones")).unwrap_or(false) };- if let Ok(cli) = std::env::var("ADOM_AIFLOW_KICAD_CLI") { return probe(&cli).then_some(cli); }+ // issue #297: the remote wrapper's own help answers with no KiCad on the desktop; its `version` runs the desktop's kicad-cli+ let usable = |cli: &str| probe(cli) && (!cli.ends_with("kicad-cli-remote") || Command::new(cli).arg("version").output().is_ok_and(|o| o.status.success()));+ if let Ok(cli) = std::env::var("ADOM_AIFLOW_KICAD_CLI") { return usable(&cli).then_some(cli); } if probe("kicad-cli") { return Some("kicad-cli".into()); } // no KiCad here (a container): the run's own desktop runs it through Adom Bridge- (std::env::var("KICAD_REMOTE_TARGET").is_ok() && probe("adom-aiflow-kicad-cli-remote")).then(|| "adom-aiflow-kicad-cli-remote".to_string())+ (std::env::var("KICAD_REMOTE_TARGET").is_ok() && usable("adom-aiflow-kicad-cli-remote")).then(|| "adom-aiflow-kicad-cli-remote".to_string()) }).clone() }
crates/aiflow-place/src/lib.rs+64−3@@ -190,6 +190,23 @@ impl PadMap { /// When a wish lists several rotations and more than one is legal at the nearest spot, the one that /// puts the part's pads nearest their net partners wins (ties keep the list order). pub fn pack(board: &Board, wishes: &[(String, Wish)], gap: f64, edge: f64) -> (BTreeMap<String, Move>, Vec<String>) {+ pack_allowing(board, wishes, gap, edge, &[])+}++/// Every pad's outline points of a part, in the part's own frame (its pad centres when a pad has no shape).+fn local_pad_pts(board: &Board, reference: &str) -> Vec<Pt> {+ let Some(fp) = board.footprints.get(reference) else { return Vec::new() };+ board.pads.iter().filter(|p| p.reference == reference).flat_map(|p| {+ let pts: Vec<Pt> = p.polys.iter().flatten().copied().collect();+ if pts.is_empty() { vec![(p.x, p.y)] } else { pts }+ }).map(|(x, y)| geom::rot_kicad(x - fp.x, y - fp.y, -fp.rot)).collect()+}++/// Issue #297 (idan gida): `pack`, with the parts in `overhang` (spec `placement.edgeOverhang` /+/// `edgeConnectors`, `--allow-outside`) allowed past the outline as `place check` and `place land` allow+/// them: their courtyard may cross it, every pad must stay inside. Parts the wish list will still move and+/// that sit parked off the board (their centre outside the outline) block no spot.+pub fn pack_allowing(board: &Board, wishes: &[(String, Wish)], gap: f64, edge: f64, overhang: &[String]) -> (BTreeMap<String, Move>, Vec<String>) { let mut boxes = boxes(board); let (x0, y0, x1, y1) = board.bbox; let mut out = BTreeMap::new();@@ -205,8 +222,11 @@ pub fn pack(board: &Board, wishes: &[(String, Wish)], gap: f64, edge: f64) -> (B continue; } let pts = local_pts(board, reference);+ let pad_pts = if overhang.contains(reference) { local_pad_pts(board, reference) } else { Vec::new() }; let mine = side[reference];- let others: Vec<Box4> = boxes.iter().filter(|(r, _)| *r != reference && side.get(*r).is_none_or(|s| share_side(*s, mine))).map(|(_, b)| *b).chain(drilled.iter().copied()).collect();+ // a part still to be packed and parked off the board now is not in anyone's way+ let parked = |r: &str, b: &Box4| { let (cx, cy) = ((b.0 + b.2) / 2.0, (b.1 + b.3) / 2.0); wished.contains(&r) && !out.contains_key(r) && (cx < x0 || cx > x1 || cy < y0 || cy > y1) };+ let others: Vec<Box4> = boxes.iter().filter(|(r, b)| *r != reference && side.get(*r).is_none_or(|s| share_side(*s, mine)) && !parked(r, b)).map(|(_, b)| *b).chain(drilled.iter().copied()).collect(); let g = w.gap.unwrap_or(gap); let n = (w.radius / 0.1) as i64; let mut cands: Vec<(f64, f64, f64)> = Vec::new();@@ -224,8 +244,16 @@ pub fn pack(board: &Board, wishes: &[(String, Wish)], gap: f64, edge: f64) -> (B let mut legal: Vec<(f64, Box4)> = Vec::new(); for &rot in &w.rot { let b = placed_box(&pts, x, y, rot);- if b.0 < x0 + edge || b.1 < y0 + edge || b.2 > x1 - edge || b.3 > y1 - edge {- continue;+ if pad_pts.is_empty() {+ if b.0 < x0 + edge || b.1 < y0 + edge || b.2 > x1 - edge || b.3 > y1 - edge {+ continue;+ }+ } else {+ // an allowed overhang: the courtyard may cross the outline, the pads may not+ let p = placed_box(&pad_pts, x, y, rot);+ if p.0 < x0 || p.1 < y0 || p.2 > x1 || p.3 > y1 {+ continue;+ } } if !clear(&b, &others, g) { continue;@@ -671,6 +699,39 @@ mod tests { assert_eq!(courtyard_only.iter().map(|(r, _)| r.as_str()).collect::<Vec<_>>(), vec!["J1"], "{courtyard_only:?}"); } + /// Issue #297 (idan gida): a right-angle header whose courtyard crosses the left edge by design packs at its+ /// exact spot when it is an allowed overhang (its pad inside), never with its pad past the edge; without+ /// the declaration it has no spot, as before.+ #[test]+ fn an_allowed_overhang_packs_with_its_pads_inside() {+ let t = "(kicad_pcb (version 20260206) (layers (0 \"F.Cu\" signal) (2 \"B.Cu\" signal) (25 \"Edge.Cuts\" user)) (gr_rect (start 0 0) (end 30 20) (layer \"Edge.Cuts\"))\n\+ (footprint \"J\" (layer \"F.Cu\") (at 15 10) (property \"Reference\" \"J1\") (fp_rect (start -3 -2) (end 2 2) (layer \"F.CrtYd\")) (pad \"1\" smd rect (at 0 0) (size 1 1) (layers \"F.Cu\") (net \"A\"))))";+ let b = Board::from_text("t", t.to_string()).unwrap();+ let at = |x: f64| vec![("J1".to_string(), Wish { x, y: 10.0, rot: vec![0.0], radius: 0.0, keepout: Vec::new(), gap: None })];+ let (m, lines) = pack(&b, &at(2.0), 0.05, 0.0);+ assert!(m.is_empty() && lines[0].contains("NO SPOT"), "{lines:?}");+ let (m, lines) = pack_allowing(&b, &at(2.0), 0.05, 0.0, &["J1".to_string()]);+ assert_eq!((m["J1"].x, m["J1"].y), (2.0, 10.0), "{lines:?}");+ let (m, lines) = pack_allowing(&b, &at(0.3), 0.05, 0.0, &["J1".to_string()]);+ assert!(m.is_empty() && lines[0].contains("NO SPOT"), "the pad would cross the edge: {lines:?}");+ }++ /// Issue #297: a large part parked below the board whose courtyard reaches 0.6 mm into it blocks no spot+ /// when the wish list will move it; a parked part the wishes leave alone still does.+ #[test]+ fn a_parked_part_the_wishes_will_move_blocks_no_spot() {+ let t = "(kicad_pcb (version 20260206) (layers (0 \"F.Cu\" signal) (2 \"B.Cu\" signal) (25 \"Edge.Cuts\" user)) (gr_rect (start 0 0) (end 30 20) (layer \"Edge.Cuts\"))\n\+ (footprint \"H\" (layer \"F.Cu\") (at 10 21) (property \"Reference\" \"J9\") (fp_rect (start -5 -1.6) (end 5 1.6) (layer \"F.CrtYd\")) (pad \"1\" smd rect (at 0 0) (size 1 1) (layers \"F.Cu\") (net \"A\")))\n\+ (footprint \"R\" (layer \"F.Cu\") (at 40 5) (property \"Reference\" \"R1\") (fp_rect (start -1 -1) (end 1 1) (layer \"F.CrtYd\")) (pad \"1\" smd rect (at 0 0) (size 1 1) (layers \"F.Cu\") (net \"A\"))))";+ let b = Board::from_text("t", t.to_string()).unwrap();+ let w = |r: &str, x: f64, y: f64| (r.to_string(), Wish { x, y, rot: vec![0.0], radius: 0.0, keepout: Vec::new(), gap: None });+ let (m, lines) = pack(&b, &[w("R1", 10.0, 18.5)], 0.05, 0.0);+ assert!(m.is_empty(), "J9 stays parked, so its courtyard still blocks: {lines:?}");+ let (m, lines) = pack(&b, &[w("R1", 10.0, 18.5), w("J9", 20.0, 5.0)], 0.05, 0.0);+ assert_eq!((m["R1"].x, m["R1"].y), (10.0, 18.5), "{lines:?}");+ assert!(m.contains_key("J9"), "{lines:?}");+ }+ /// A 30 x 20 mm board with two-pad parts: (reference, pad 1 net, pad 2 net, x, y); pads 1 mm apart on x. fn board(parts: &[(&str, &str, &str, f64, f64)]) -> Board { let mut t = String::from("(kicad_pcb\n\t(version 20260206)\n\t(generator \"test\")\n\t(layers\n\t\t(0 \"F.Cu\" signal)\n\t\t(2 \"B.Cu\" signal)\n\t\t(25 \"Edge.Cuts\" user)\n\t)\n");
docs/release-0.2.158.mdadded+10@@ -0,0 +1,10 @@+# adom-aiflow 0.2.158++Issue #297 (idan gida): the Altium lane's placement steps.++- **`place check` no longer stops an Altium run that has no KiCad.** The missing KiCad DRC is a WARNING. The courtyard and body check, the placement ranking and the DFA audit still run, and the moved board becomes the run's board. Altium's own DRC judges the placement after `place land`, at `place verify`. A KiCad run still stops when its DRC cannot run.+- **A desktop without KiCad is no longer taken for one.** Through Adom Bridge, the KiCad probe now also runs the desktop's `kicad-cli version`. Before, the wrapper's own `pcb drc --help` answered even with no KiCad installed.+- **`place pack` seats a declared edge overhang.** A part in `placement.edgeOverhang` / `edgeConnectors` (or `--allow-outside`) may have its courtyard past the outline, as `place check` and `place land` already allowed; every pad must stay inside.+- **A parked part blocks no spot.** A part the wish list will still move, sitting off the board (its centre outside the outline), no longer keeps others from a spot its courtyard reaches into.+- **`finish-guard` says a failed `place verify` plainly.** It now reads "the last verify did not pass (<what it found>)" instead of "board or spec binding changed".+- **A 3D body offset from its footprint is named.** On an Altium run, `place verify` reads `altium_bodies` and names any part whose body reaches more than 1 mm past its courtyard as a library problem, not a placement one.
package.json+1−1@@ -1,7 +1,7 @@ { "slug": "adom-aiflow", "type": "app",- "version": "0.2.157",+ "version": "0.2.158", "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.157",+ "version": "0.2.158", "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+2−2@@ -744,7 +744,7 @@ The plan needs provenance: the plan `pour` wrote (its hash is recorded in the ru ### Silk-only adoption keeps copper evidence -On an Altium run (issue #229) Altium is the board of record. `adopt-board --board live --evidence <what changed in Altium>` reads the open board fresh (altium_routing_state, altium_pour_state, altium_silk_state) and makes its plan board the run's board; a saved bridge read (`{"source":"altium-bridge",...}`) is accepted only while it is still the live revision. Altium's batch DRC runs twice (the fuller reply is kept) and its errors are counted per rule, connections left for routing not counted: the run's first Altium adoption is the baseline, and a later one refuses a rule whose count rose. `place verify` on an Altium run reads the live board first (a changed placement becomes a new board of the run, evidence carried when the copper is unchanged), builds the live placement state from that read (sides, rotations and courtyards as the plan board has them; a bottom part is drawn at angle 0 there), checks courtyard boxes and the outline itself, and takes the native placement check from Altium's batch DRC placement rules (ComponentClearance and the rest, when the board's DRC setup enables them) plus the bridge's read-only `altium_placement_check` (bodies or pads that meet, parts on a mounting hole). A second read after the check must carry the same revision. Altium free pads are drawn with `allow_missing_courtyard`.+On an Altium run (issue #229) Altium is the board of record. `adopt-board --board live --evidence <what changed in Altium>` reads the open board fresh (altium_routing_state, altium_pour_state, altium_silk_state) and makes its plan board the run's board; a saved bridge read (`{"source":"altium-bridge",...}`) is accepted only while it is still the live revision. Altium's batch DRC runs twice (the fuller reply is kept) and its errors are counted per rule, connections left for routing not counted: the run's first Altium adoption is the baseline, and a later one refuses a rule whose count rose. `place verify` on an Altium run reads the live board first (a changed placement becomes a new board of the run, evidence carried when the copper is unchanged), builds the live placement state from that read (sides, rotations and courtyards as the plan board has them; a bottom part is drawn at angle 0 there), checks courtyard boxes and the outline itself, and takes the native placement check from Altium's batch DRC placement rules (ComponentClearance and the rest, when the board's DRC setup enables them) plus the bridge's read-only `altium_placement_check` (bodies or pads that meet, parts on a mounting hole). A second read after the check must carry the same revision. Altium free pads are drawn with `allow_missing_courtyard`. A part whose 3D body (`altium_bodies`) reaches more than 1 mm past its courtyard is named as a library body offset (`NOTE (library, not placement)`): its body overlaps are fixed in the footprint library, not by moving parts. `place check` on an Altium run with no KiCad anywhere says so in a WARNING and goes on (courtyard and body checks, ranking, the moved board recorded); Altium's DRC judges the placement at `place verify`. In `place pack`, a part the wishes will still move that is parked off the board blocks no spot. Before `adopt-board` on a board your own scripts built, declare the step whose work it carries (`step placement` for placed parts, `step routing` for routed copper, `step pours` for zones), so the adoption and the commands after it are charged to that step. `adopt-board` compares the copper fingerprint of the current and adopted boards: tracks, vias, zones with settings, pads with geometry, net and drill, footprint placement, outline, stackup, nets and project rules, but not silkscreen, fab, courtyard, text or 3D models. When it is unchanged, gate, land, measure, the analyses, place verify and the Fields report are kept, with a carry record holding both board hashes and the fingerprint. Every board-hash check accepts the older board only through that record, re-verified from both snapshot files. Any copper change, an unreadable rule file or a non-KiCad board invalidates the evidence as before. The silkscreen and export proofs are always dropped; record them again. @@ -760,7 +760,7 @@ A drilled pad with no copper layer (an NPTH that lists only `*.Mask`, such as a - Via-to-via copper clearance and the hole-to-hole minimum come from the spec (`viaClearance`, else `clearance`; `holeToHole`); when the spec names neither, from the project's `.kicad_dru` beside the board (its unconditioned or via-only clearance and hole_to_hole rules, the last one winning as in KiCad); else 0.2 mm. This applies to `land vias`, `pour` and `thermal-vias plan`; zones keep `clearance`. - A pad number used twice on one footprint (a connector's two `MP` pads, a ring drawn as two custom pads) is ambiguous as a key. The router writes such a pad as its coordinates, and the gate and `land route` both replace an ambiguous key in any plan by the coordinates of the pad nearest the path's neighbouring point (a note says so), so they land on the same pad. `route` also keeps the two pads apart as clusters, joins existing copper that crosses a custom pad's polygon anywhere along a track, and treats overlapping pads of one net as one piece of copper. - `route` reads the board's own copper the way KiCad's connectivity does (issue #103): two items of one net join when their copper overlaps on a layer they share, so a track ending inside another track's width, a track end on a via's annulus off its centre, collinear overlapping pieces, overlapping zone fills of one net and a pad's real outline all count. It reads every copper layer for this (inner-layer tracks and plane fills joined through through-hole pads and vias; blind and buried vias only on the layers they span), stamps only F.Cu and B.Cu, and keeps the router's vias clear of inner-layer tracks of other nets (a long track counts along its whole length). A pad's angle in the board file is absolute and 0 when left out, also in a rotated footprint. On a fully routed board `route` writes an empty plan; the nets it still plans are the ones KiCad's DRC lists as unconnected.-- An edge connector may overhang the outline on purpose: spec `placement.edgeOverhang: [{"ref": "J13", "why": "USB-C mouth proud of the edge"}]` or `--allow-outside J13` on `place check`, `place land` and `land moves`. `place check` reports it and no longer lists the part as outside; `place land` and `land moves` send `allowOutside: true` to kicad_move_footprint for those parts only. Any pad or footprint copper outside the outline is still refused before anything lands; edge clearance stays a DRC matter. A refusal with no `offendingRefs` names the part being moved.+- An edge connector may overhang the outline on purpose: spec `placement.edgeOverhang: [{"ref": "J13", "why": "USB-C mouth proud of the edge"}]` or `--allow-outside J13` on `place check`, `place land` and `land moves`. `place pack` seats it the same way (its courtyard may cross the outline, every pad stays inside), `place check` reports it and no longer lists the part as outside; `place land` and `land moves` send `allowOutside: true` to kicad_move_footprint for those parts only. Any pad or footprint copper outside the outline is still refused before anything lands; edge clearance stays a DRC matter. A refusal with no `offendingRefs` names the part being moved. **Edge connectors, heatsink via count, lost zones, switch nodes and zones-only adoption (0.2.23).** - `placement.edgeConnectors` (what `place verify` accepts for a part whose courtyard crosses the edge) takes any footprint the board uses for that reference, a project-library `<lib>:<name>` as well as `Connector_*`; the declared footprint must equal the live and saved one. One `edgeConnectors` entry also allows the part's moves to land (as `placement.edgeOverhang` does), and both check pads and footprint copper with the same inside-the-outline test. `edgeOverhang` alone lets moves land but is not enough for `place verify`: the refusal names the `edgeConnectors` fields to add (docs/edge-connectors.md).