by adom
Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.
← Commit history
0.2.101: altium_assembly_check on engine 0.25.0 (eda-bridge-standard#30): two-pad parts by their 3D body, ball grids apart, joined lands no pitch, thickness tolerance, PCBA Type rule
16 files changed
+332−144
CHANGELOG.md+9bridge-rs/Cargo.lock+1−1bridge-rs/src/assembly.rs+96−102bridge-rs/src/main.rs+1−1bridge-rs/src/verbs.rs+2−2bridge-rs/vendor/README.md+1−1bridge-rs/vendor/adom-eda-checks/Cargo.toml+1−1bridge-rs/vendor/adom-eda-checks/README.md+1−1bridge-rs/vendor/adom-eda-checks/src/assembly.rs+201−26bridge-rs/vendor/adom-eda-checks/tests/fixtures.rs+6−3dev-skills/altium-bridge-test/run_verb_tests.py+5−2package.json+1−1page.json+1−1skills/altium-outputs/SKILL.md+4src/BRIDGE_VERSION+1−1src/bridge.json+1−1CHANGELOG.md+9@@ -1,5 +1,14 @@ # Changelog +## 0.2.101++- **`altium_assembly_check` gives the right JLCPCB Economic answer for small two-pad parts, ball grids and power FETs** (eda-bridge-standard#30, the engine side of kicad-bridge#144). The check now runs the standard's shared engine (adom-eda-checks 0.25.0, vendored) instead of this bridge's own copy, which had the same faults.+- A two-pad part is sized by its 3D body: the bridge reads each part's bodies and passes `bodyMm`. Before, a 1.0 x 0.6 mm X1SON-2 failed Economic as "smaller than 0402" from its pad centres. A part with no body is sized by its copper, and an in-between size answers `ok:null` as an estimate.+- Ball grids (BGA/CSP footprints, or round lands in rows and columns) are held to 0.5 mm in Economic and 0.3 mm in Standard, reported as `board.finestBgaPitch`. Before, a 0.4 mm DSBGA passed Economic.+- Pins on the same net (a FET's joined source lands) no longer count as a pitch. Thickness allows 0.05 mm either side of the 0.8 to 1.6 mm range.+- Economic has a new rule, always `ok:null`: every part must be offered in Economic, which JLCPCB states per part (PCBA Type). With `projectPath`, the reply lists the BOM's LCSC numbers (`board.lcscNumbers`) to look up.+- Tested on Altium Designer 26.11.1 with the Bluetooth Sentinel example: its 0.796 mm stack now passes, and LED1 is sized by its body (1.0 x 0.5 mm, an 0402).+ ## 0.2.100 - **`altium_compile_intlib` reports success when the IntLib is written** (#34). Every compile showed Altium's error box "Could not create integrated library ." and answered `agent_script_error`, although the `.IntLib` was written correctly. Compiling a LibPkg already builds its IntLib; the verb then built it a second time with `CreateIntegratedLibrary`, whose second argument is the output file, and passed it an empty name. That second build now runs only when you name an output, and it writes to that file without installing it.
bridge-rs/Cargo.lock+1−1@@ -10,7 +10,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "adom-eda-checks"-version = "0.24.0"+version = "0.25.0" dependencies = [ "roxmltree", "serde_json",
bridge-rs/src/assembly.rs+96−102@@ -1,140 +1,134 @@-//! Ready for JLCPCB assembly? The board against both of JLCPCB's PCBA tiers as published-//! (jlcpcb.com/capabilities/pcb-assembly-capabilities, read 2026-10-26): size, thickness and layers, one or two sides,-//! the smallest package and the finest pin pitch, fiducials, and which parts have no LCSC number. It answers the tier-//! the board can be ordered in.+//! Ready for JLCPCB assembly? The standard's shared engine answers it (vendor/adom-eda-checks `assembly`, ported from+//! this file and fixed in engine 0.25.0 for eda-bridge-standard#30): size, thickness and layers, one or two sides, the+//! smallest package by its body, the finest pin pitch with ball grids held to their own, fiducials, and which parts have+//! no LCSC number. This module reads Altium: the board model, the stack, each part's 3D body (bodyMm) and the BOM. use serde_json::{json, Value}; use std::collections::BTreeMap; fn f(v: &Value) -> f64 { v.as_f64().unwrap_or(0.0) } fn r3(v: f64) -> f64 { (v * 1000.0).round() / 1000.0 } -/// What the board offers the assembly line, from routing_state. Pure.-pub fn facts(st: &Value) -> Value {- let pads = st["pads"].as_array().cloned().unwrap_or_default();- let comps = st["components"].as_array().cloned().unwrap_or_default();- let mut by: BTreeMap<String, Vec<(f64, f64)>> = BTreeMap::new();- for p in pads.iter().filter(|p| f(&p["drill"]) == 0.0) {- if let Some(r) = p["ref"].as_str().filter(|r| !r.is_empty()) { by.entry(r.to_string()).or_default().push((f(&p["x"]), f(&p["y"]))); }+/// Each part's body size [long, short] mm in its own frame, from the bodies companion rows (bodies::rows): a turned+/// part's own rectangle (w, h), else its box on the board; a part with several bodies takes their union. Pure.+pub fn body_sizes(rows: &[Value]) -> BTreeMap<String, (f64, f64)> {+ let mut boxes: BTreeMap<String, (f64, f64, f64, f64)> = BTreeMap::new();+ let mut turned: BTreeMap<String, (f64, f64)> = BTreeMap::new();+ for b in rows {+ let Some(r) = b["ref"].as_str() else { continue };+ if let (Some(w), Some(h)) = (b["w"].as_f64(), b["h"].as_f64()) {+ let e = turned.entry(r.to_string()).or_insert((0.0, 0.0));+ *e = (e.0.max(w.max(h)), e.1.max(w.min(h)));+ continue;+ }+ let (x0, y0, x1, y1) = (f(&b["x0"]), f(&b["y0"]), f(&b["x1"]), f(&b["y1"]));+ let e = boxes.entry(r.to_string()).or_insert((x0, y0, x1, y1));+ *e = (e.0.min(x0), e.1.min(y0), e.2.max(x1), e.3.max(y1)); }- // the finest pitch: the closest pad centres within one part with 3 or more SMD pads (an IC, a BGA, a connector)- let mut pitch: Option<(f64, String)> = None;- // the smallest two-pad part: its pad centres (an 0402 is about 1.0 mm apart, an 0201 0.5, an 01005 0.35)- let mut chip: Option<(f64, String)> = None;- for (r, ps) in &by {- let mut d = f64::MAX;- for i in 0..ps.len() { for j in i + 1..ps.len() { d = d.min(((ps[i].0 - ps[j].0).powi(2) + (ps[i].1 - ps[j].1).powi(2)).sqrt()); } }- if ps.len() >= 3 && pitch.as_ref().map(|p| d < p.0).unwrap_or(true) { pitch = Some((d, r.clone())); }- if ps.len() == 2 && chip.as_ref().map(|p| d < p.0).unwrap_or(true) { chip = Some((d, r.clone())); }+ let mut out: BTreeMap<String, (f64, f64)> = boxes.into_iter().map(|(r, (x0, y0, x1, y1))| {+ let (w, h) = (x1 - x0, y1 - y0);+ (r, (r3(w.max(h)), r3(w.min(h))))+ }).filter(|(_, (l, s))| *l > 0.0 && *s > 0.0).collect();+ for (r, (l, s)) in turned { if l > 0.0 && s > 0.0 { out.insert(r, (r3(l), r3(s))); } }+ out+}++/// The board model with bodyMm on every component that has a 3D body. Pure.+pub fn with_bodies(st: &Value, sizes: &BTreeMap<String, (f64, f64)>) -> Value {+ let mut st = st.clone();+ if let Some(cs) = st["components"].as_array_mut() {+ for c in cs.iter_mut() {+ if let Some((l, s)) = c["ref"].as_str().and_then(|r| sizes.get(r)) { c["bodyMm"] = json!([l, s]); }+ } }- let named = |c: &Value, pat: &[&str]| { let p = c["pattern"].as_str().unwrap_or("").to_ascii_uppercase(); pat.iter().any(|x| p.contains(x)) };- let tiny: Vec<Value> = comps.iter().filter(|c| named(c, &["0201", "01005", "0603M", "0402M"])).map(|c| json!({"ref": c["ref"], "footprint": c["pattern"]})).collect();- let fid = |s: &str| s.to_ascii_uppercase().starts_with("FID");- let fiducials = comps.iter().filter(|c| c["ref"].as_str().map(fid).unwrap_or(false) || named(c, &["FIDUCIAL"])).count()- + pads.iter().filter(|p| p["ref"].as_str().map(|r| r.is_empty()).unwrap_or(true) && p["name"].as_str().map(fid).unwrap_or(false)).count();- let bottom: Vec<Value> = comps.iter().filter(|c| c["side"] == "bottom").map(|c| c["ref"].clone()).collect();- let tht = pads.iter().filter(|p| f(&p["drill"]) > 0.0 && p["ref"].as_str().map(|r| !r.is_empty()).unwrap_or(false))- .filter_map(|p| p["ref"].as_str().map(String::from)).collect::<std::collections::BTreeSet<_>>();- json!({"parts": comps.len(), "bottomSideParts": bottom, "finestPitch": pitch.map(|(d, r)| json!({"mm": r3(d), "ref": r})),- "smallestChip": chip.map(|(d, r)| json!({"padCentresMm": r3(d), "ref": r})), "tinyFootprints": tiny, "fiducials": fiducials,- "throughHoleParts": tht.into_iter().collect::<Vec<_>>()})+ st } -fn rule(name: &str, ok: Option<bool>, detail: String) -> Value { json!({"rule": name, "ok": ok, "detail": detail}) }+/// The LCSC numbers on the BOM's purchased lines, once each. Pure.+pub fn lcsc_numbers(lines: &[Value]) -> Vec<String> {+ let mut v: Vec<String> = lines.iter().filter(|l| l["purchase"] != json!(false))+ .filter_map(|l| l["lcsc"].as_str().map(|s| s.trim().to_string())).filter(|s| !s.is_empty()).collect();+ v.sort();+ v.dedup();+ v+} -/// The board against one tier ("economic" or "standard"). `size` is [w, h] mm (the board, or the panel it ships in),-/// `lcsc_missing` the purchased lines with no LCSC number (None: not checked). Pure.-pub fn tier(name: &str, fa: &Value, size: (f64, f64), thick: Option<f64>, layers: Option<i64>, lcsc_missing: Option<usize>, panel: bool) -> Value {- let eco = name == "economic";- let mut rs = Vec::new();- let (w, h) = (size.0.min(size.1), size.0.max(size.1));- let (lo, hi): ((f64, f64), (f64, f64)) = match (eco, panel) { (true, false) => ((10.0, 10.0), (470.0, 500.0)), (true, true) => ((10.0, 10.0), (250.0, 250.0)), (false, false) => ((70.0, 70.0), (460.0, 500.0)), (false, true) => ((70.0, 70.0), (250.0, 250.0)) };- let ok = w >= lo.0 && h >= lo.1 && w <= hi.0.min(hi.1) && h <= hi.0.max(hi.1);- rs.push(rule(&format!("{} {} x {} to {} x {} mm", if panel { "panel" } else { "board" }, lo.0, lo.1, hi.0, hi.1), Some(ok), format!("{} x {} mm{}", r3(size.0), r3(size.1), if !ok && !eco && !panel { ": a panel (altium_panelize) can bring it to 70 x 70" } else { "" })));- if eco {- rs.push(match thick { Some(t) => rule("board 0.8 to 1.6 mm thick", Some((0.8 - 1e-6..=1.6 + 1e-6).contains(&t)), format!("{} mm", r3(t))), None => rule("board 0.8 to 1.6 mm thick", None, "thickness not read".into()) });- rs.push(match layers { Some(n) => rule("2, 4 or 6 layers", Some([2, 4, 6].contains(&n)), format!("{n} layers")), None => rule("2, 4 or 6 layers", None, "layers not read".into()) });- let bot = fa["bottomSideParts"].as_array().map(|a| a.len()).unwrap_or(0);- rs.push(rule("parts on one side only", Some(bot == 0), if bot == 0 { "all on top".into() } else { format!("{bot} part(s) on the bottom: {}", fa["bottomSideParts"]) }));+/// The engine names the standard's verbs; this bridge's panel verb has no underscore for prefix_verbs to catch.+fn altium_words(r: &mut Value) {+ match r {+ Value::String(s) => { if s.contains("(panelize") { *s = s.replace("(panelize", "(altium_panelize"); } }+ Value::Array(a) => a.iter_mut().for_each(altium_words),+ Value::Object(o) => o.values_mut().for_each(altium_words),+ _ => {} }- let (chip_min, pitch_min) = if eco { (0.8, 0.4) } else { (0.3, 0.35) };- let tiny = fa["tinyFootprints"].as_array().map(|a| a.len()).unwrap_or(0);- let chip = fa["smallestChip"]["padCentresMm"].as_f64();- let chip_ok = (eco && tiny == 0 || !eco) && chip.map(|c| c >= chip_min).unwrap_or(true);- rs.push(rule(if eco { "smallest package 0402" } else { "smallest package 01005" }, Some(chip_ok),- format!("smallest two-pad part {} (pad centres {} mm){}", fa["smallestChip"]["ref"].as_str().unwrap_or("-"), chip.map(r3).unwrap_or(0.0), if tiny > 0 { format!("; footprints named under 0402: {}", fa["tinyFootprints"]) } else { String::new() })));- let pitch = fa["finestPitch"]["mm"].as_f64();- rs.push(rule(&format!("IC pin pitch {pitch_min} mm or more (BGA {} mm)", if eco { 0.5 } else { 0.3 }), Some(pitch.map(|p| p + 1e-6 >= pitch_min).unwrap_or(true)),- format!("finest {} mm on {}", pitch.map(r3).unwrap_or(0.0), fa["finestPitch"]["ref"].as_str().unwrap_or("-"))));- if !eco {- let n = fa["fiducials"].as_u64().unwrap_or(0);- rs.push(rule("fiducials and edge rails", Some(n >= 2 || panel), if panel { "on the panel rails (altium_panelize adds three)".into() } else { format!("{n} fiducial(s) on the board: add 3 (altium_board_features fiducials) or ship it in a panel with rails") }));- }- rs.push(match lcsc_missing { Some(0) => rule("every purchased part has an LCSC number", Some(true), "all lines".into()),- Some(n) => rule("every purchased part has an LCSC number", Some(false), format!("{n} line(s) without one: find them (adom-parts-search, adom-jlcpcb) or consign them")),- None => rule("every purchased part has an LCSC number", None, "not checked: pass projectPath".into()) });- let ok = rs.iter().all(|r| r["ok"] != json!(false));- json!({"tier": name, "ok": ok, "rules": rs}) } /// altium_assembly_check {filePath?, projectPath?, panelMm?} pub fn assembly_check(args: &Value) -> Value { if let Some(g) = crate::support::need_licensed() { return g; }- let mut lcsc_missing = None;- let mut lcsc_lines = Value::Null;+ let mut eargs = json!({});+ if let Some(p) = args.get("panelMm").filter(|v| v.is_array()) { eargs["panelMm"] = p.clone(); }+ let mut bom_error = Value::Null; if let Some(prj) = crate::support::s(args, "projectPath") { let b = crate::bom::bom(&json!({"projectPath": prj, "write": false})); if b.get("success").and_then(|v| v.as_bool()) == Some(true) {- let l = b["checks"]["jlcpcb"]["linesWithoutLcsc"].clone();- lcsc_missing = Some(l.as_array().map(|a| a.len()).unwrap_or(0));- lcsc_lines = l;- } else { lcsc_lines = json!({"bomError": b.get("error").cloned().unwrap_or(Value::Null)}); }+ eargs["lcscMissing"] = b["checks"]["jlcpcb"]["linesWithoutLcsc"].clone();+ if !eargs["lcscMissing"].is_array() { eargs["lcscMissing"] = json!([]); }+ eargs["lcscNumbers"] = json!(lcsc_numbers(&b["lines"].as_array().cloned().unwrap_or_default()));+ } else { bom_error = b.get("error").cloned().unwrap_or(json!("the BOM could not be read")); } } if let Some(p) = crate::support::s(args, "filePath") { if let Some(e) = crate::support::must_open(&p, 60) { return e; } } let st = crate::routing::routing_state(&json!({})); if st.get("success").and_then(|b| b.as_bool()) != Some(true) { return st; }- let Some((x0, y0, x1, y1)) = crate::fab::outline_bbox(&st) else { return json!({"success": false, "errorCode": "no_outline", "error": "the board has no outline"}) };- let panel = args.get("panelMm").and_then(|v| v.as_array()).map(|a| (f(&a[0]), f(&a[1])));- let size = panel.unwrap_or((x1 - x0, y1 - y0));- let stack = crate::agent::call("layer_stack", &[], None, std::time::Duration::from_secs(60));- let thick = stack.get("data").and_then(|d| d["totalUm"].as_f64()).map(|u| u / 1000.0);- let layers = stack.get("data").and_then(|d| d["copperLayers"].as_i64());- let fa = facts(&st);- let eco = tier("economic", &fa, size, thick, layers, lcsc_missing, panel.is_some());- let std_ = tier("standard", &fa, size, thick, layers, lcsc_missing, panel.is_some());- let service = if eco["ok"] == json!(true) { json!("economic") } else if std_["ok"] == json!(true) { json!("standard") } else { Value::Null };- json!({"success": true, "fab": {"name": "JLCPCB", "source": "https://jlcpcb.com/capabilities/pcb-assembly-capabilities", "read": "2026-10-26"},- "service": service, "economic": eco, "standard": std_, "board": fa, "linesWithoutLcsc": lcsc_lines,- "_hint": "service is the cheapest JLCPCB assembly tier every rule allows (null: fix what the rules mark false). Rotation: JLCPCB's part orientation can differ from Altium's for some packages; check every part in JLCPCB's placement preview after uploading the BOM and pick-and-place (altium_export_manufacturing, altium_bom writes the JLCPCB BOM)."})+ // each part's body sizes the two-pad parts (#30); with no bodies read, the engine sizes them by their copper+ let bodies = crate::agent::call("bodies", &[], None, std::time::Duration::from_secs(120));+ let sizes = bodies.get("data").filter(|d| d["ok"] == json!(true))+ .map(|d| body_sizes(&crate::bodies::rows(&d["bodies"].as_array().cloned().unwrap_or_default()))).unwrap_or_default();+ let stack = crate::agent::call("layer_stack", &[], None, std::time::Duration::from_secs(60)).get("data").cloned().unwrap_or(Value::Null);+ let mut r = crate::checks::engine("assembly_check", &json!({"board": with_bodies(&st, &sizes), "stack": stack, "args": eargs}));+ altium_words(&mut r);+ if r["success"] == json!(true) {+ if !bom_error.is_null() { r["linesWithoutLcsc"] = json!({"bomError": bom_error}); }+ if let Some(h) = r["_hint"].as_str() {+ r["_hint"] = json!(format!("{h} Pass projectPath to check LCSC numbers and list them for the PCBA Type look-up; bodyMm comes from each part's 3D body (altium_add_body for a part without one). altium_bom writes the JLCPCB BOM, altium_export_manufacturing the pick-and-place."));+ }+ }+ r } #[cfg(test)] mod tests { use super::*; - fn board() -> Value {- json!({"components": [{"ref": "U1", "side": "top", "pattern": "QFN-20"}, {"ref": "C1", "side": "top", "pattern": "C0402"}, {"ref": "R9", "side": "bottom", "pattern": "R0603"}],- "pads": [{"ref": "U1", "name": "1", "x": 0.0, "y": 0.0, "drill": 0.0}, {"ref": "U1", "name": "2", "x": 0.5, "y": 0.0, "drill": 0.0}, {"ref": "U1", "name": "3", "x": 1.0, "y": 0.0, "drill": 0.0},- {"ref": "C1", "name": "1", "x": 5.0, "y": 0.0, "drill": 0.0}, {"ref": "C1", "name": "2", "x": 6.0, "y": 0.0, "drill": 0.0},- {"ref": "R9", "name": "1", "x": 9.0, "y": 0.0, "drill": 0.0}, {"ref": "R9", "name": "2", "x": 10.5, "y": 0.0, "drill": 0.0}]})+ #[test]+ fn body_sizes_take_the_union_and_a_turned_parts_own_rectangle() {+ let rows = vec![+ json!({"ref": "D1", "x0": 0.0, "y0": 0.0, "x1": 0.6, "y1": 1.0}),+ json!({"ref": "U1", "x0": 0.0, "y0": 0.0, "x1": 3.0, "y1": 3.0}), json!({"ref": "U1", "x0": 2.0, "y0": 0.0, "x1": 5.0, "y1": 1.0}),+ json!({"ref": "C2", "x0": 0.0, "y0": 0.0, "x1": 2.0, "y1": 2.0, "w": 1.0, "h": 0.5, "rotation": 45.0}),+ ];+ let s = body_sizes(&rows);+ assert_eq!(s["D1"], (1.0, 0.6));+ assert_eq!(s["U1"], (5.0, 3.0));+ assert_eq!(s["C2"], (1.0, 0.5)); } #[test]- fn facts_find_pitch_the_smallest_chip_and_the_bottom_side() {- let fa = facts(&board());- assert_eq!(fa["finestPitch"], json!({"mm": 0.5, "ref": "U1"}));- assert_eq!(fa["smallestChip"], json!({"padCentresMm": 1.0, "ref": "C1"}));- assert_eq!(fa["bottomSideParts"], json!(["R9"]));+ fn an_x1son_with_its_body_passes_economic() {+ // a 1.0 x 0.6 mm X1SON-2: pad centres 0.65 mm apart failed Economic as smaller than 0402 before engine 0.25.0+ let st = json!({"outline": [[0.0, 0.0], [30.0, 0.0], [30.0, 30.0], [0.0, 30.0]],+ "components": [{"ref": "D1", "side": "top", "pattern": "X1SON-2"}],+ "pads": [{"ref": "D1", "name": "1", "x": 10.0, "y": 10.0, "sizeX": 0.3, "sizeY": 0.5, "rotation": 0.0, "drill": 0.0, "net": "A", "shape": "rect"},+ {"ref": "D1", "name": "2", "x": 10.65, "y": 10.0, "sizeX": 0.3, "sizeY": 0.5, "rotation": 0.0, "drill": 0.0, "net": "K", "shape": "rect"}]});+ let sizes: BTreeMap<String, (f64, f64)> = [("D1".to_string(), (1.0, 0.6))].into_iter().collect();+ let r = adom_eda_checks::run("assembly_check", &json!({"board": with_bodies(&st, &sizes), "stack": {"totalUm": 1600.0, "copperLayers": 2}, "args": {"lcscMissing": 0}}));+ let rule = r["economic"]["rules"].as_array().unwrap().iter().find(|x| x["rule"] == "smallest package 0402").cloned().unwrap();+ assert_eq!(rule["ok"], json!(true), "{r}");+ assert_eq!(r["board"]["smallestChip"]["sizeFrom"], "body"); } #[test]- fn a_small_two_sided_board_needs_standard_in_a_panel() {- let fa = facts(&board());- let eco = tier("economic", &fa, (40.0, 20.0), Some(1.6), Some(2), Some(0), false);- assert_eq!(eco["ok"], json!(false)); // R9 on the bottom- let std_ = tier("standard", &fa, (40.0, 20.0), Some(1.6), Some(2), Some(0), false);- assert_eq!(std_["ok"], json!(false)); // under 70 x 70 and no fiducials- let std_panel = tier("standard", &fa, (90.0, 80.0), Some(1.6), Some(2), Some(0), true);- assert_eq!(std_panel["ok"], json!(true));- assert_eq!(tier("economic", &fa, (40.0, 20.0), Some(0.4), Some(2), None, false)["rules"][1]["ok"], json!(false));+ fn lcsc_numbers_are_the_purchased_lines_once_each() {+ let lines = vec![json!({"lcsc": "C2", "purchase": true}), json!({"lcsc": "C1"}), json!({"lcsc": "C2"}), json!({"lcsc": "C9", "purchase": false}), json!({"lcsc": ""})];+ assert_eq!(lcsc_numbers(&lines), vec!["C1", "C2"]); } }
bridge-rs/src/main.rs+1−1@@ -81,7 +81,7 @@ use tiny_http::{Header, Method, Response, Server}; /// Attached to every failed reply (see the /command handler). const REPORT_ISSUES: &str = "If this looks like an altium-bridge BUG (not a refusal you expected), report it: check for a duplicate with `adom-wiki issue list adom/altium-bridge`, then `adom-wiki issue create adom/altium-bridge --title \"<verb>: <one-line symptom>\" --category bug-report --body \"<what you ran, what you expected, what happened, the VERBATIM response JSON (and errorShot if present), bridgeVersion, the Altium version from altium_status, the OS>\"`. A relay, routing, toast or lifecycle problem belongs on adom/adom-bridge instead. Reports from real machines are how this bridge gets correct: three different Altium builds behaved three different ways in one weekend."; -pub const BRIDGE_VERSION: &str = "0.2.100";+pub const BRIDGE_VERSION: &str = "0.2.101"; fn json_response(status: u16, body: &serde_json::Value) -> Response<std::io::Cursor<Vec<u8>>> { let data = serde_json::to_vec(body).unwrap_or_else(|_| b"{}".to_vec());
bridge-rs/src/verbs.rs+2−2@@ -1112,10 +1112,10 @@ fn describe() -> Value { json!({"projectPath": "C:/proj/Board.PrjPcb", "pcbPath": "C:/proj/Board.PcbDoc"})), verb_doc("assembly_check", "Ready for JLCPCB assembly? The board against both JLCPCB PCBA tiers as published (Economic and Standard): board or panel size, thickness and layers, parts on one or both sides, the smallest package and the finest pin pitch, fiducials, and the parts with no LCSC number; answers the cheapest tier every rule allows.", json!({"filePath": "the .PcbDoc (opened first; else the current board)", "projectPath": "the .PrjPcb - checks every purchased BOM line has an LCSC number (altium_bom)", "panelMm": "[w, h] when it ships in a panel (altium_panelize's panelMm)"}),- json!({"service": "economic | standard | null", "economic": "{ok, rules:[{rule, ok, detail}]}", "standard": "{ok, rules}", "board": "{parts, bottomSideParts, finestPitch, smallestChip, tinyFootprints, fiducials, throughHoleParts}", "linesWithoutLcsc": "[..]"}), 300,+ json!({"service": "economic | standard | null", "economic": "{ok, rules:[{rule, ok, detail}]}", "standard": "{ok, rules}", "board": "{parts, bottomSideParts, finestPitch, finestBgaPitch, smallestChip:{ref, sizeMm, sizeFrom: body|copper, padCentresMm}, tinyFootprints, fiducials, throughHoleParts, lcscNumbers}", "linesWithoutLcsc": "[..]", "engine": "adom-eda-checks version"}), 300, "Fix what the rules mark false: panelize a small board (altium_panelize, then panelMm), add fiducials (altium_board_features), find LCSC numbers (adom-parts-search). Then altium_bom (JLCPCB BOM) and altium_export_manufacturing (pick and place), and check every part's rotation in JLCPCB's preview.", &["bom", "export_manufacturing", "panelize", "board_features", "fab_check"],- &["Pitch is the closest pad centres within one part of 3 or more SMD pads; package size is read from footprint names and two-pad parts' pad spacing.", "Rotations are not checked: JLCPCB's preview is the authority on orientation."],+ &["Pitch is the closest pin centres within one part of 3 or more SMD pins; pins on one net (a FET's joined source lands) are not a pitch. Ball grids (BGA/CSP names, or round lands in rows and columns) are held to 0.5 mm Economic, 0.3 mm Standard (finestBgaPitch).", "A two-pad part is sized by its 3D body (bodyMm, from altium_bodies); with no body, by its copper, and a size between 0201 and 0402 copper answers ok:null (an estimate). Give it a body with altium_add_body.", "Thickness allows 0.05 mm either side of 0.8 to 1.6 mm. Economic also needs every part offered in Economic (JLCPCB's per-part PCBA Type): always ok:null, listing the BOM's LCSC numbers to look up.", "Rotations are not checked: JLCPCB's preview is the authority on orientation."], json!({"projectPath": "C:/proj/Board.PrjPcb", "filePath": "C:/proj/Board.PcbDoc"})), verb_doc("via_fence", "A via fence for EMC: a row of ground vias on both sides of RF or fast nets' tracks, and/or round the board edge, at a pitch from the frequency (lambda/20) or given; each via clear of other copper and pads, the same net's vias and the edge.", json!({"filePath": "the .PcbDoc (opened first; else the current board)", "nets": "[net] - the tracks to fence (e.g. [ANT_RF])", "edge": "bool - a fence round the board edge too", "viaNet": "the net the vias tie to (usually GND), required", "freqGHz": "the highest frequency: pitch = lambda/20 in FR-4", "pitchMm": "pitch, default 2 (a cap when freqGHz is given)", "offsetMm": "track centreline to via centre (default half the widest track + clearance + via radius + 0.1)", "edgeInsetMm": "edge fence: distance in from the edge (default via radius + 0.5)", "size": "via diameter mm, default 0.6", "drill": "mm, default 0.3", "clearance": "to other copper, mm, default 0.2", "dryRun": "bool - plan only", "expectedRevision": "optional"}),
bridge-rs/vendor/README.md+1−1@@ -2,7 +2,7 @@ | Folder | From | Version | |---|---|---|-| `adom-eda-checks/` | adom/eda-bridge-standard `engine/` (the shared checks engine) | standard 0.23.0, engine 0.20.0 |+| `adom-eda-checks/` | adom/eda-bridge-standard `engine/` (the shared checks engine) | standard 0.33.0, engine 0.25.0 | | `pcb-design-rules/records/` | adom/pcb-design-rules `rules/records/` (each fab's published limits, with sources and dates) | head of 2026-10-27 | The wiki has no git protocol, so these are copied at a version: refresh both from their pages, then run the tests.
bridge-rs/vendor/adom-eda-checks/Cargo.toml+1−1@@ -1,6 +1,6 @@ [package] name = "adom-eda-checks"-version = "0.24.0"+version = "0.25.0" edition = "2021" description = "The EDA Bridge Standard's checks and board-file writers, computed from the board model JSON: no bridge calls, no tool." license = "MIT"
bridge-rs/vendor/adom-eda-checks/README.md+1−1@@ -11,7 +11,7 @@ boards the engine gives the same answers the Altium bridge 0.2.76 gives. | Check | Reads | What it answers | |---|---|---|-| `assembly_check` | board, stack? | the board against JLCPCB's two PCBA tiers as published (with the page and its read date): size (or `panelMm`), thickness and layers from the stack, one or two sides, the smallest two-pad part and the finest IC pitch, fiducials, and parts without an LCSC number (`lcscMissing` from the bridge's BOM). Pads sharing one centre are one land, and a component with no pads is no part. `service` is the cheaper tier every rule allows. Matches the Altium bridge's answers on its test boards. From its assembly.rs |+| `assembly_check` | board, stack? | the board against JLCPCB's two PCBA tiers as published (with the page and its read date): size (or `panelMm`), thickness and layers from the stack, one or two sides, the smallest two-pad part and the finest IC pitch, fiducials, and parts without an LCSC number (`lcscMissing` from the bridge's BOM). Pads sharing one centre are one land, and a component with no pads is no part. A two-pad part is sized by its body (`components[].bodyMm`) or else its copper, with a size between 0201 and 0402 marked an estimate (`ok: null`); ball grids (named BGA/CSP, or round lands in rows and columns) are held to their own pitch (`finestBgaPitch`); pins on one net and unnamed pads are no pitch; thickness allows 0.05 mm either side; Economic names the per-part PCBA Type rule with `args.lcscNumbers` (#30). `service` is the cheaper tier every rule allows. From the Altium bridge's assembly.rs, with kicad-bridge 1.0.109 and 1.0.111's fixes | | `auto_classes` | board | net classes from the names the nets already have (GND, Power, Clock, HighSpeed) and differential pairs from their suffixes (`_P`/`_N`, `DP`/`DN`, `+`/`-`), with `applyArgs`: the net_classes and diff_pairs calls that write them (Power with a `powerWidthMm` width rule). From the Altium bridge's autoclass.rs | | `board_report` | board, and every companion it can use | every check the engine has, run on this bundle, as one self-contained HTML page (`text`), dark by default: fab limits (with `fab`), JLCPCB assembly, schematic review and symbols against footprints (with `sheetParts` and `netlist`), impedance, return paths and copper balance (with `stack`), 3D heights (with `bodies`), the design review, and the tool's own DRC (`drc`) and a base64 PNG of the board (`picture`) when the bridge passes them; `args` carries `lcscMissing`, `panelMm`, `gridMm` and `alwaysChecked` to those checks. A section whose input is missing says which to pass. From the Altium bridge's report.rs | | `bom` | sheetParts, board? | the bill of materials: fitted parts grouped one line per manufacturer part number (natural designator order), a variant applied (`args.variant`: notFitted, alternates), checks for what an order needs (missing MPN, maker or Mouser/DigiKey/LCSC numbers, lines mixing values, JLCPCB lines without LCSC, DNP, excluded and not-purchased parts, sheet and board mismatches), and the order files as text (`files[]`: bom.csv, bom-jlcpcb.csv, cpl-jlcpcb.csv, bom-mouser.csv, bom-digikey.csv); from the Altium bridge's bom.rs |
bridge-rs/vendor/adom-eda-checks/src/assembly.rs+201−26@@ -1,32 +1,82 @@ //! Ready for JLCPCB assembly? The board against both of JLCPCB's PCBA tiers as published //! (jlcpcb.com/capabilities/pcb-assembly-capabilities, read 2026-10-26): size, thickness and layers, one or two sides, //! the smallest package and the finest pin pitch, fiducials, and which parts have no LCSC number. It answers the tier-//! the board can be ordered in. From the Altium bridge's assembly.rs.+//! the board can be ordered in. From the Altium bridge's assembly.rs, with kicad-bridge 1.0.109 and 1.0.111's fixes (#30):+//! a two-pad part sized by its body, ball grids held to their own pitch, a FET's joined lands no pitch, and the+//! per-part PCBA Type named. use serde_json::{json, Value}; use std::collections::BTreeMap; fn f(v: &Value) -> f64 { v.as_f64().unwrap_or(0.0) } fn r3(v: f64) -> f64 { (v * 1000.0).round() / 1000.0 } +/// One SMD pin of a part: centre, a round land (a ball), its net, and its copper (sizeX, sizeY, rotation in degrees).+struct Pin { x: f64, y: f64, round: bool, net: String, sx: f64, sy: f64, rot: f64 }++/// Half the copper of a pin along direction `phi` (radians), its land taken as a rectangle.+fn half_along(p: &Pin, phi: f64) -> f64 {+ let a = p.rot.to_radians() - phi;+ (p.sx / 2.0 * a.cos()).abs() + (p.sy / 2.0 * a.sin()).abs()+}++/// A two-pad part's copper, end to end along its pins and across: [long, short] mm. None without pad sizes.+fn copper(ps: &[Pin]) -> Option<(f64, f64)> {+ if ps.len() != 2 || ps.iter().any(|p| p.sx <= 0.0 || p.sy <= 0.0) { return None; }+ let (dx, dy) = (ps[1].x - ps[0].x, ps[1].y - ps[0].y);+ let phi = dy.atan2(dx);+ let long = (dx * dx + dy * dy).sqrt() + half_along(&ps[0], phi) + half_along(&ps[1], phi);+ let short = ps.iter().map(|p| 2.0 * half_along(p, phi + std::f64::consts::FRAC_PI_2)).fold(0.0, f64::max);+ Some((long.max(short), long.min(short)))+}+ /// What the board offers the assembly line, from the board model. Pure. pub fn facts(st: &Value) -> Value { let pads = st["pads"].as_array().cloned().unwrap_or_default(); let comps = st["components"].as_array().cloned().unwrap_or_default();- let mut by: BTreeMap<String, Vec<(f64, f64)>> = BTreeMap::new();- for p in pads.iter().filter(|p| f(&p["drill"]) == 0.0) {- if let Some(r) = p["ref"].as_str().filter(|r| !r.is_empty()) { by.entry(r.to_string()).or_default().push((f(&p["x"]), f(&p["y"]))); }+ let comp = |r: &str| comps.iter().find(|c| c["ref"].as_str() == Some(r));+ let pattern = |r: &str| comp(r).map(|c| c["pattern"].as_str().unwrap_or("").to_ascii_uppercase()).unwrap_or_default();+ // a part's pins: an unnamed pad is copper drawn beside a pin (a power FET's land), never a pin of its own (#30)+ let mut by: BTreeMap<String, Vec<Pin>> = BTreeMap::new();+ for p in pads.iter().filter(|p| f(&p["drill"]) == 0.0 && p["name"].as_str() != Some("")) {+ if let Some(r) = p["ref"].as_str().filter(|r| !r.is_empty()) {+ let (sx, sy) = (f(&p["sizeX"]), f(&p["sizeY"]));+ let round = p["shape"] == "circle" || (p["shape"] == "round" && sx > 0.0 && (sx - sy).abs() < 1e-6);+ by.entry(r.to_string()).or_default().push(Pin { x: f(&p["x"]), y: f(&p["y"]), round, net: p["net"].as_str().unwrap_or("").to_string(), sx, sy, rot: f(&p["rotation"]) });+ } }- // the finest pitch: the closest pad centres within one part with 3 or more SMD pads (an IC, a BGA, a connector)+ // a ball grid: named so (BGA, DSBGA, WLCSP, CSP), or four or more round lands in two or more rows and columns (#30)+ let is_bga = |r: &str, ps: &[Pin]| {+ let lines = |k: fn(&Pin) -> f64| { let mut v: Vec<i64> = ps.iter().map(|q| (k(q) * 100.0).round() as i64).collect(); v.sort(); v.dedup(); v.len() };+ ["BGA", "CSP"].iter().any(|x| pattern(r).contains(x)) || (ps.len() >= 4 && ps.iter().all(|q| q.round) && lines(|q| q.x) >= 2 && lines(|q| q.y) >= 2)+ };+ // the finest pitch: the closest pin centres within one part with 3 or more SMD pins, ball grids apart;+ // the smallest two-pad part: by its body (bodyMm, the bridge's package outline), else its copper, else its pad centres let mut pitch: Option<(f64, String)> = None;- // the smallest two-pad part: its pad centres (an 0402 is about 1.0 mm apart, an 0201 0.5, an 01005 0.35)- let mut chip: Option<(f64, String)> = None;+ let mut bga: Option<(f64, String)> = None;+ let mut chip: Option<(f64, String, Option<(f64, f64, &str)>)> = None; for (r, ps) in &by { let mut d = f64::MAX;- // pads with one centre are one land (a MOSFET's drain pads drawn as one polygon, fusion-lane #24), not a 0 mm pitch- for i in 0..ps.len() { for j in i + 1..ps.len() { let e = ((ps[i].0 - ps[j].0).powi(2) + (ps[i].1 - ps[j].1).powi(2)).sqrt(); if e > 0.01 { d = d.min(e); } } }+ for i in 0..ps.len() {+ for j in i + 1..ps.len() {+ // pins with one centre are one land drawn in pieces (fusion-lane #24); pins on one net (a FET's source+ // pins drawn as overlapping lands) cannot bridge (#30): neither is a pitch+ let e = ((ps[i].x - ps[j].x).powi(2) + (ps[i].y - ps[j].y).powi(2)).sqrt();+ if e > 0.01 && (ps[i].net.is_empty() || ps[i].net != ps[j].net) { d = d.min(e); }+ }+ } if d == f64::MAX { continue; }- if ps.len() >= 3 && pitch.as_ref().map(|p| d < p.0).unwrap_or(true) { pitch = Some((d, r.clone())); }- if ps.len() == 2 && chip.as_ref().map(|p| d < p.0).unwrap_or(true) { chip = Some((d, r.clone())); }+ if ps.len() >= 3 {+ let slot = if is_bga(r, ps) { &mut bga } else { &mut pitch };+ if slot.as_ref().map(|p| d < p.0).unwrap_or(true) { *slot = Some((d, r.clone())); }+ }+ if ps.len() == 2 {+ let body = comp(r).and_then(|c| Some((c["bodyMm"][0].as_f64()?, c["bodyMm"][1].as_f64()?))).filter(|b| b.0 > 0.0 && b.1 > 0.0);+ let sz = body.map(|(a, b)| (a.max(b), a.min(b), "body")).or_else(|| copper(ps).map(|(l, s)| (l, s, "copper")));+ // smaller: the shorter long side, else the closer pad centres+ let key = |c: &(f64, String, Option<(f64, f64, &str)>)| (c.2.map(|z| z.0).unwrap_or(f64::MAX), c.0);+ let cand = (d, r.clone(), sz);+ if chip.as_ref().map(|c| key(&cand) < key(c)).unwrap_or(true) { chip = Some(cand); }+ } } let named = |c: &Value, pat: &[&str]| { let p = c["pattern"].as_str().unwrap_or("").to_ascii_uppercase(); pat.iter().any(|x| p.contains(x)) }; let tiny: Vec<Value> = comps.iter().filter(|c| named(c, &["0201", "01005", "0603M", "0402M"])).map(|c| json!({"ref": c["ref"], "footprint": c["pattern"]})).collect();@@ -39,14 +89,16 @@ pub fn facts(st: &Value) -> Value { let tht = pads.iter().filter(|p| f(&p["drill"]) > 0.0 && p["ref"].as_str().map(|r| !r.is_empty()).unwrap_or(false)) .filter_map(|p| p["ref"].as_str().map(String::from)).collect::<std::collections::BTreeSet<_>>(); json!({"parts": comps.iter().filter(|c| placed(c)).count(), "bottomSideParts": bottom, "finestPitch": pitch.map(|(d, r)| json!({"mm": r3(d), "ref": r})),- "smallestChip": chip.map(|(d, r)| json!({"padCentresMm": r3(d), "ref": r})), "tinyFootprints": tiny, "fiducials": fiducials,- "throughHoleParts": tht.into_iter().collect::<Vec<_>>()})+ "finestBgaPitch": bga.map(|(d, r)| json!({"mm": r3(d), "ref": r})),+ "smallestChip": chip.map(|(d, r, sz)| json!({"padCentresMm": r3(d), "ref": r, "sizeMm": sz.map(|z| json!([r3(z.0), r3(z.1)])), "sizeFrom": sz.map(|z| z.2)})),+ "tinyFootprints": tiny, "fiducials": fiducials, "throughHoleParts": tht.into_iter().collect::<Vec<_>>()}) } fn rule(name: &str, ok: Option<bool>, detail: String) -> Value { json!({"rule": name, "ok": ok, "detail": detail}) } /// The board against one tier ("economic" or "standard"). `size` is [w, h] mm (the board, or the panel it ships in),-/// `lcsc_missing` the purchased lines with no LCSC number (None: not checked). Pure.+/// `lcsc_missing` the purchased lines with no LCSC number (None: not checked). `fa.lcscNumbers`, when the bridge passed+/// them, are listed for the per-part PCBA Type look-up. Pure. pub fn tier(name: &str, fa: &Value, size: (f64, f64), thick: Option<f64>, layers: Option<i64>, lcsc_missing: Option<usize>, panel: bool) -> Value { let eco = name == "economic"; let mut rs = Vec::new();@@ -55,20 +107,54 @@ pub fn tier(name: &str, fa: &Value, size: (f64, f64), thick: Option<f64>, layers let ok = w >= lo.0 && h >= lo.1 && w <= hi.0.min(hi.1) && h <= hi.0.max(hi.1); rs.push(rule(&format!("{} {} x {} to {} x {} mm", if panel { "panel" } else { "board" }, lo.0, lo.1, hi.0, hi.1), Some(ok), format!("{} x {} mm{}", r3(size.0), r3(size.1), if !ok && !eco && !panel { ": a panel (panelize) can bring it to 70 x 70" } else { "" }))); if eco {- rs.push(match thick { Some(t) => rule("board 0.8 to 1.6 mm thick", Some((0.8 - 1e-6..=1.6 + 1e-6).contains(&t)), format!("{} mm", r3(t))), None => rule("board 0.8 to 1.6 mm thick", None, "thickness not read: pass the stack".into()) });+ // a stack-up adds up to a little over or under JLCPCB's 1.6 mm option (KiCad's default 4 layers: 1.6166 mm), #30+ rs.push(match thick { Some(t) => rule("board 0.8 to 1.6 mm thick", Some((0.8 - 0.05..=1.6 + 0.05).contains(&t)),+ format!("{} mm{}", r3(t), if (t - 1.6).abs() > 1e-6 && (t - 1.6).abs() <= 0.05 { " (JLCPCB's 1.6 mm option, within 0.05 mm)" } else { "" })),+ None => rule("board 0.8 to 1.6 mm thick", None, "thickness not read: pass the stack".into()) }); rs.push(match layers { Some(n) => rule("2, 4 or 6 layers", Some([2, 4, 6].contains(&n)), format!("{n} layers")), None => rule("2, 4 or 6 layers", None, "layers not read: pass the stack".into()) }); let bot = fa["bottomSideParts"].as_array().map(|a| a.len()).unwrap_or(0); rs.push(rule("parts on one side only", Some(bot == 0), if bot == 0 { "all on top".into() } else { format!("{bot} part(s) on the bottom: {}", fa["bottomSideParts"]) })); }- let (chip_min, pitch_min) = if eco { (0.8, 0.4) } else { (0.3, 0.35) };+ let (chip_min, pitch_min, bga_min) = if eco { (0.8, 0.4, 0.5) } else { (0.3, 0.35, 0.3) }; let tiny = fa["tinyFootprints"].as_array().map(|a| a.len()).unwrap_or(0);- let chip = fa["smallestChip"]["padCentresMm"].as_f64();- let chip_ok = (eco && tiny == 0 || !eco) && chip.map(|c| c >= chip_min).unwrap_or(true);- rs.push(rule(if eco { "smallest package 0402" } else { "smallest package 01005" }, Some(chip_ok),- format!("smallest two-pad part {} (pad centres {} mm){}", fa["smallestChip"]["ref"].as_str().unwrap_or("-"), chip.map(r3).unwrap_or(0.0), if tiny > 0 { format!("; footprints named under 0402: {}", fa["tinyFootprints"]) } else { String::new() })));+ let sc = &fa["smallestChip"];+ let centres = sc["padCentresMm"].as_f64();+ let sz = sc["sizeMm"][0].as_f64().zip(sc["sizeMm"][1].as_f64());+ let from = sc["sizeFrom"].as_str().unwrap_or("");+ // the package by its body: 0402 is 1.0 x 0.5 mm, 01005 0.4 x 0.2, a tenth under allowed; with no body, its copper:+ // 0402 lands are about 1.5 mm end to end, 0201 about 1.1, 01005 about 0.65, so between is an estimate (#30)+ let (body, pkg) = if eco { ((1.0, 0.5), "0402 is 1.0 x 0.5 mm") } else { ((0.4, 0.2), "01005 is 0.4 x 0.2 mm") };+ let size_ok = match sz {+ Some((l, s)) if from == "body" => Some(l >= 0.9 * body.0 && s >= 0.9 * body.1),+ Some((l, _)) if eco => if l >= 1.3 { Some(true) } else if l < 0.95 { Some(false) } else { None },+ Some((l, _)) => if l >= 0.55 { Some(true) } else { None },+ None => centres.map(|c| c >= chip_min),+ };+ let chip_ok = if eco && tiny > 0 { Some(false) } else { size_ok.or(if sc.is_null() { Some(true) } else { None }) };+ let how = match sz {+ Some((l, s)) if from == "body" => format!("body {} x {} mm", r3(l), r3(s)),+ Some((l, s)) => format!("{} x {} mm of copper, no body size: an estimate, check the part's body ({pkg})", r3(l), r3(s)),+ None => "sized by its pad centres only".to_string(),+ };+ rs.push(rule(if eco { "smallest package 0402" } else { "smallest package 01005" }, chip_ok,+ if sc.is_null() { "no two-pad SMD part".into() } else {+ format!("smallest two-pad part {}: {how} (pad centres {} mm){}", sc["ref"].as_str().unwrap_or("-"), centres.map(r3).unwrap_or(0.0),+ if tiny > 0 { format!("; footprints named under 0402: {}", fa["tinyFootprints"]) } else { String::new() })+ })); let pitch = fa["finestPitch"]["mm"].as_f64();- rs.push(rule(&format!("IC pin pitch {pitch_min} mm or more (BGA {} mm)", if eco { 0.5 } else { 0.3 }), Some(pitch.map(|p| p + 1e-6 >= pitch_min).unwrap_or(true)),- format!("finest {} mm on {}", pitch.map(r3).unwrap_or(0.0), fa["finestPitch"]["ref"].as_str().unwrap_or("-"))));+ let bga = fa["finestBgaPitch"]["mm"].as_f64();+ let pitch_ok = pitch.map(|p| p + 1e-6 >= pitch_min).unwrap_or(true) && bga.map(|p| p + 1e-6 >= bga_min).unwrap_or(true);+ let mut detail = format!("finest {} mm on {}", pitch.map(r3).unwrap_or(0.0), fa["finestPitch"]["ref"].as_str().unwrap_or("-"));+ if let Some(b) = bga {+ detail += &format!("; ball grid {} mm on {}{}", r3(b), fa["finestBgaPitch"]["ref"].as_str().unwrap_or("-"), if b + 1e-6 < bga_min { format!(" (needs {bga_min} mm)") } else { String::new() });+ }+ rs.push(rule(&format!("IC pin pitch {pitch_min} mm or more (BGA {bga_min} mm)"), Some(pitch_ok), detail));+ if eco {+ // JLCPCB rates each part too: "PCBA Type: Standard Only" parts cannot go Economic, and no board file says which (#30)+ let nums: Vec<&str> = fa["lcscNumbers"].as_array().into_iter().flatten().filter_map(|v| v.as_str()).collect();+ rs.push(rule("every part offered in Economic (JLCPCB's PCBA Type)", None, format!("not checked: JLCPCB marks some parts Standard Only (fine-pitch BGAs, some LEDs and connectors); read PCBA Type on each part's page, jlcpcb.com/partdetail/<number>{}",+ if nums.is_empty() { String::new() } else { format!(": {}", nums.join(", ")) })));+ } if !eco { let n = fa["fiducials"].as_u64().unwrap_or(0); rs.push(rule("fiducials and edge rails", Some(n >= 2 || panel), if panel { "on the panel rails (panelize adds three)".into() } else { format!("{n} fiducial(s) on the board: add 3 (board_features fiducials) or ship it in a panel with rails") }));@@ -80,7 +166,7 @@ pub fn tier(name: &str, fa: &Value, size: (f64, f64), thick: Option<f64>, layers json!({"tier": name, "ok": ok, "rules": rs}) } -/// assembly_check: input {board, stack?, args: {panelMm?: [w, h], lcscMissing?: count or the BOM lines without one}}.+/// assembly_check: input {board, stack?, args: {panelMm?: [w, h], lcscMissing?: count or the BOM lines without one, lcscNumbers?: the BOM's LCSC numbers}}. pub fn assembly_check(input: &Value) -> Value { let st = match crate::input::board(input) { Ok(b) => b, Err(e) => return e }; let args = &input["args"];@@ -95,13 +181,14 @@ pub fn assembly_check(input: &Value) -> Value { v if v.as_u64().is_some() => (v.as_u64().map(|n| n as usize), Value::Null), _ => (None, Value::Null), };- let fa = facts(&st);+ let mut fa = facts(&st);+ if let Some(a) = args["lcscNumbers"].as_array() { fa["lcscNumbers"] = Value::Array(a.iter().filter(|v| v.is_string()).cloned().collect()); } let eco = tier("economic", &fa, size, thick, layers, lcsc_missing, panel.is_some()); let std_ = tier("standard", &fa, size, thick, layers, lcsc_missing, panel.is_some()); let service = if eco["ok"] == json!(true) { json!("economic") } else if std_["ok"] == json!(true) { json!("standard") } else { Value::Null }; json!({"success": true, "fab": {"name": "JLCPCB", "source": "https://jlcpcb.com/capabilities/pcb-assembly-capabilities", "read": "2026-10-26"}, "service": service, "economic": eco, "standard": std_, "board": fa, "linesWithoutLcsc": lcsc_lines,- "_hint": "service is the cheapest JLCPCB assembly tier every rule allows (null: fix what the rules mark false). Rotation: JLCPCB's part orientation can differ from the tool's for some packages; check every part in JLCPCB's placement preview after uploading the BOM and pick-and-place."})+ "_hint": "service is the cheapest JLCPCB assembly tier every rule allows (null: fix what the rules mark false). A rule marked null was not decided: Economic also needs every part offered in Economic, which JLCPCB states per part (PCBA Type), and a two-pad part without bodyMm is sized from its copper. Rotation: JLCPCB's part orientation can differ from the tool's for some packages; check every part in JLCPCB's placement preview after uploading the BOM and pick-and-place."}) } #[cfg(test)]@@ -120,7 +207,7 @@ mod tests { fn facts_find_pitch_the_smallest_chip_and_the_bottom_side() { let fa = facts(&board()); assert_eq!(fa["finestPitch"], json!({"mm": 0.5, "ref": "U1"}));- assert_eq!(fa["smallestChip"], json!({"padCentresMm": 1.0, "ref": "C1"}));+ assert_eq!(fa["smallestChip"], json!({"padCentresMm": 1.0, "ref": "C1", "sizeMm": null, "sizeFrom": null})); assert_eq!(fa["bottomSideParts"], json!(["R9"])); // fusion-lane #24: pads sharing one centre are one land, and a pad-less icon on the bottom is no part let mut b = board();@@ -155,4 +242,92 @@ mod tests { assert_eq!(assembly_check(&json!({"board": board(), "stack": {"totalUm": 1600, "copperLayers": 2}, "args": {"panelMm": [90, 80], "lcscMissing": 0}}))["service"], "standard"); assert_eq!(assembly_check(&json!({"board": {"pads": []}, "args": {}}))["errorCode"], "no_outline"); }++ fn pad(r: &str, n: &str, x: f64, y: f64, sx: f64, sy: f64, shape: &str, net: &str) -> Value {+ json!({"ref": r, "name": n, "x": x, "y": y, "sizeX": sx, "sizeY": sy, "rotation": 0.0, "shape": shape, "net": net, "drill": 0.0})+ }+ fn eco_rule(r: &Value, name: &str) -> Value { r["economic"]["rules"].as_array().unwrap().iter().find(|x| x["rule"].as_str().unwrap().starts_with(name)).cloned().unwrap() }+ fn run(comps: Value, pads: Value, args: Value) -> Value {+ assembly_check(&json!({"board": {"components": comps, "pads": pads, "outline": [[0, 0], [40, 0], [40, 40], [0, 40]]}, "stack": {"totalUm": 1600, "copperLayers": 2}, "args": args}))+ }++ #[test]+ fn a_two_pad_part_is_sized_by_its_body_not_its_pad_centres() {+ // #30: TI X1SON-2 (1.0 x 0.6 mm, pad centres 0.7 mm, LCSC C48260) is Economic at JLCPCB+ let pads = json!([pad("D1", "1", 0.0, 0.0, 0.4, 0.5, "rect", "A"), pad("D1", "2", 0.7, 0.0, 0.4, 0.5, "rect", "K")]);+ let with_body = run(json!([{"ref": "D1", "side": "top", "pattern": "X1SON-2", "bodyMm": [0.6, 1.0]}]), pads.clone(), json!({}));+ assert_eq!(with_body["board"]["smallestChip"]["sizeMm"], json!([1.0, 0.6]), "{with_body}");+ assert_eq!(eco_rule(&with_body, "smallest package")["ok"], json!(true));+ // no body: its copper, 1.1 mm end to end, sits between 0201 and 0402, so the rule says it is an estimate+ let copper = run(json!([{"ref": "D1", "side": "top", "pattern": "X1SON-2"}]), pads, json!({}));+ assert_eq!(copper["board"]["smallestChip"]["sizeFrom"], "copper");+ assert_eq!(copper["board"]["smallestChip"]["sizeMm"], json!([1.1, 0.5]));+ let r = eco_rule(&copper, "smallest package");+ assert_eq!(r["ok"], Value::Null, "{r}");+ assert!(r["detail"].as_str().unwrap().contains("an estimate"));+ // a real 0201 (0.6 x 0.3 mm body) still fails Economic+ let o201 = run(json!([{"ref": "C1", "side": "top", "pattern": "C_0201", "bodyMm": [0.6, 0.3]}]),+ json!([pad("C1", "1", 0.0, 0.0, 0.3, 0.3, "rect", "A"), pad("C1", "2", 0.5, 0.0, 0.3, 0.3, "rect", "B")]), json!({}));+ assert_eq!(eco_rule(&o201, "smallest package")["ok"], json!(false));+ // a rotated 0402's copper reads the same as an upright one+ let rot = run(json!([{"ref": "R1", "side": "top", "pattern": "R_0402"}]),+ json!([{"ref": "R1", "name": "1", "x": 0.0, "y": 0.0, "sizeX": 0.6, "sizeY": 0.5, "rotation": 90.0, "shape": "rect", "drill": 0.0},+ {"ref": "R1", "name": "2", "x": 0.0, "y": 0.96, "sizeX": 0.6, "sizeY": 0.5, "rotation": 90.0, "shape": "rect", "drill": 0.0}]), json!({}));+ assert_eq!(rot["board"]["smallestChip"]["sizeMm"], json!([1.56, 0.5]), "{rot}");+ assert_eq!(eco_rule(&rot, "smallest package")["ok"], json!(true));+ }++ #[test]+ fn a_ball_grid_is_held_to_its_own_pitch() {+ // #30: a 0.4 mm DSBGA-4 (TPS22916BYFPR, C2150095) is Standard Only+ let balls = |r: &str| json!([pad(r, "A1", 0.0, 0.0, 0.25, 0.25, "circle", "1"), pad(r, "A2", 0.4, 0.0, 0.25, 0.25, "circle", "2"),+ pad(r, "B1", 0.0, 0.4, 0.25, 0.25, "circle", "3"), pad(r, "B2", 0.4, 0.4, 0.25, 0.25, "circle", "4")]);+ let r = run(json!([{"ref": "U2", "side": "top", "pattern": "DSBGA-4"}]), balls("U2"), json!({}));+ assert_eq!(r["board"]["finestBgaPitch"], json!({"mm": 0.4, "ref": "U2"}), "{r}");+ assert_eq!(r["board"]["finestPitch"], Value::Null);+ let p = eco_rule(&r, "IC pin pitch");+ assert_eq!((p["ok"].clone(), p["detail"].as_str().unwrap().contains("needs 0.5 mm")), (json!(false), true), "{p}");+ assert_eq!(r["economic"]["ok"], json!(false));+ // found by its round lands in rows and columns when the footprint's name says nothing+ let unnamed = run(json!([{"ref": "U2", "side": "top", "pattern": "U2_PKG"}]), balls("U2"), json!({}));+ assert_eq!(unnamed["board"]["finestBgaPitch"]["mm"], json!(0.4));+ // a 0.4 mm QFN is not a ball grid and stays at the 0.4 mm IC limit+ let qfn = run(json!([{"ref": "U3", "side": "top", "pattern": "QFN-16"}]),+ json!([pad("U3", "1", 0.0, 0.0, 0.2, 0.6, "roundrect", "1"), pad("U3", "2", 0.4, 0.0, 0.2, 0.6, "roundrect", "2"), pad("U3", "3", 0.8, 0.0, 0.2, 0.6, "roundrect", "3")]), json!({}));+ assert_eq!((qfn["board"]["finestBgaPitch"].clone(), eco_rule(&qfn, "IC pin pitch")["ok"].clone()), (Value::Null, json!(true)));+ }++ #[test]+ fn a_fets_joined_lands_are_no_pitch() {+ // #30: TDSON-8, source pins 1 and 2 as overlapping lands on one net, plus unnamed copper beside them+ let pads = json!([pad("Q1", "1", 0.0, 0.0, 0.6, 0.7, "rect", "SRC"), pad("Q1", "2", 0.12, 0.0, 0.6, 0.7, "rect", "SRC"),+ pad("Q1", "", 0.3, 0.2, 0.5, 0.5, "rect", "SRC"), pad("Q1", "3", 1.27, 0.0, 0.6, 0.7, "rect", "SRC2"),+ pad("Q1", "4", 2.54, 0.0, 0.6, 0.7, "rect", "G"), pad("Q1", "5", 1.27, 3.0, 3.8, 3.0, "rect", "DRN")]);+ let r = run(json!([{"ref": "Q1", "side": "top", "pattern": "TDSON-8"}]), pads, json!({}));+ assert_eq!(r["board"]["finestPitch"], json!({"mm": 1.15, "ref": "Q1"}), "{r}");+ assert_eq!(eco_rule(&r, "IC pin pitch")["ok"], json!(true));+ // pins on different nets that close are still a pitch, and so are pins with no nets assigned yet+ let tight = run(json!([{"ref": "Q1", "side": "top", "pattern": "X"}]),+ json!([pad("Q1", "1", 0.0, 0.0, 0.2, 0.2, "rect", "A"), pad("Q1", "2", 0.12, 0.0, 0.2, 0.2, "rect", "B"), pad("Q1", "3", 1.0, 0.0, 0.2, 0.2, "rect", "C")]), json!({}));+ assert_eq!(tight["board"]["finestPitch"]["mm"], json!(0.12));+ let unrouted = run(json!([{"ref": "Q1", "side": "top", "pattern": "X"}]),+ json!([pad("Q1", "1", 0.0, 0.0, 0.2, 0.2, "rect", ""), pad("Q1", "2", 0.12, 0.0, 0.2, 0.2, "rect", ""), pad("Q1", "3", 1.0, 0.0, 0.2, 0.2, "rect", "")]), json!({}));+ assert_eq!(unrouted["board"]["finestPitch"]["mm"], json!(0.12));+ }++ #[test]+ fn a_stack_a_little_over_1_6_mm_passes_and_part_ratings_are_named() {+ // #30: KiCad's default 4-layer stack adds up to 1.6166 mm+ let r = assembly_check(&json!({"board": board(), "stack": {"totalUm": 1616.6, "copperLayers": 4}, "args": {"lcscNumbers": ["C48260", "C2150095"]}}));+ let th = eco_rule(&r, "board 0.8 to 1.6");+ assert_eq!(th["ok"], json!(true), "{th}");+ assert!(th["detail"].as_str().unwrap().contains("within 0.05 mm"));+ assert_eq!(eco_rule(&r, "board 0.8 to 1.6")["ok"], json!(true));+ let too = assembly_check(&json!({"board": board(), "stack": {"totalUm": 1700, "copperLayers": 4}, "args": {}}));+ assert_eq!(eco_rule(&too, "board 0.8 to 1.6")["ok"], json!(false));+ let pt = eco_rule(&r, "every part offered in Economic");+ assert_eq!(pt["ok"], Value::Null);+ assert!(pt["detail"].as_str().unwrap().ends_with(": C48260, C2150095"), "{pt}");+ assert!(r["standard"]["rules"].as_array().unwrap().iter().all(|x| !x["rule"].as_str().unwrap().starts_with("every part offered")));+ } }
bridge-rs/vendor/adom-eda-checks/tests/fixtures.rs+6−3@@ -67,7 +67,10 @@ fn placement_check_matches_altium() { #[test] fn assembly_check_matches_altium() {- // board.parts: the engine counts only components with pads (a logo is no part, fusion-lane #24), Altium all of them- same("assembly_check", &["service", "fab", "board.bottomSideParts", "board.finestPitch", "board.smallestChip", "board.tinyFootprints", "board.fiducials", "board.throughHoleParts", "economic.ok", "standard.ok", "economic.rules.0.ok", "economic.rules.1.ok", "economic.rules.2.ok",- "economic.rules.3.ok", "economic.rules.4.ok", "economic.rules.5.ok", "standard.rules.0.ok", "standard.rules.3.ok"]);+ // board.parts: the engine counts only components with pads (a logo is no part, fusion-lane #24), Altium all of them.+ // The engine has #30's fixes, Altium 0.2.76 doesn't: the smallest two-pad part carries sizeMm/sizeFrom and is judged+ // by its body or copper (economic.rules.4), the thickness allows 0.05 mm either side (economic.rules.1), and+ // Economic gains the per-part PCBA Type rule before the LCSC one.+ same("assembly_check", &["service", "fab", "board.bottomSideParts", "board.finestPitch", "board.smallestChip.ref", "board.smallestChip.padCentresMm", "board.tinyFootprints", "board.fiducials", "board.throughHoleParts", "economic.ok", "standard.ok", "economic.rules.0.ok", "economic.rules.2.ok",+ "economic.rules.3.ok", "economic.rules.5.ok", "standard.rules.0.ok", "standard.rules.3.ok"]); }
dev-skills/altium-bridge-test/run_verb_tests.py+5−2@@ -388,8 +388,11 @@ def matrix(w): M["via_fence"] = dict(phase=3.5, timeout=300, **ok(filePath=LB, nets=["N1"], edge=True, viaNet="GND", pitchMm=3, dryRun=True), check=lambda d: ((d.get("planned") or {}).get("vias") or 0) > 0) M["assembly_check"] = dict(phase=3.5, timeout=450, **ok(filePath=LB, projectPath=LP),- check=lambda d: d.get("service") in (None, "economic", "standard") and len((d.get("economic") or {}).get("rules") or []) >= 6- and len((d.get("standard") or {}).get("rules") or []) >= 5)+ check=lambda d: d.get("service") in (None, "economic", "standard") and len((d.get("economic") or {}).get("rules") or []) >= 7+ and len((d.get("standard") or {}).get("rules") or []) >= 5+ # 0.2.101: engine 0.25.0 (#30): the PCBA Type rule, ball grids apart, parts sized by their body+ and any("PCBA Type" in str(r.get("rule")) for r in (d.get("economic") or {}).get("rules") or [])+ and "finestBgaPitch" in (d.get("board") or {})) # 0.2.74: the whole JLCPCB order folder (zip, BOM, CPL, order form, every issue in one list) M["jlcpcb_order"] = dict(phase=3.5, timeout=950, **ok(projectPath=LP, pcbPath=LB), check=lambda d: ((d.get("gerberZip") or {}).get("files") or 0) >= 8 and any("cpl-jlcpcb" in str(f) for f in d.get("bomFiles") or [])
package.json+1−1@@ -1,6 +1,6 @@ { "slug": "altium-bridge",- "version": "0.2.100",+ "version": "0.2.101", "type": "app", "description": "Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.", "tags": [
page.json+1−1@@ -4,7 +4,7 @@ "type": "app", "title": "Altium Bridge: AI for Altium Designer", "brief": "Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.",- "version": "0.2.100",+ "version": "0.2.101", "hero": { "type": "image", "path": "screenshots/hero.png"
skills/altium-outputs/SKILL.md+4@@ -115,6 +115,10 @@ altium_assembly_check '{"projectPath":"C:\\work\\Board.PrjPcb"}' # 2/4/6 layers, one side, 0402 and 0.4 mm pitch) and Standard (70 x 70 mm, or a panel up to 250 x 250 mm, both sides, 01005 and 0.35 mm pitch, fiducials and rails), plus every purchased BOM line's LCSC number (`projectPath`). `service` is the cheapest tier that passes. Part rotation is not guessed: check it in JLCPCB's placement preview.+ A two-pad part is sized by its 3D body (`bodyMm`); without one it is sized by its copper, and an in-between size+ answers `ok:null` (an estimate): give it a body with `altium_add_body`. Ball grids are held to 0.5 mm (Economic) or+ 0.3 mm (Standard) as `board.finestBgaPitch`. Economic always carries one `ok:null` rule: JLCPCB rates each part+ Economic or Standard Only (its PCBA Type), so look up the listed `board.lcscNumbers` on jlcpcb.com/partdetail/<number>. ## Assembly and fabrication drawings (0.2.70)
src/BRIDGE_VERSION+1−1@@ -1 +1 @@-0.2.100+0.2.101
src/bridge.json+1−1@@ -2,7 +2,7 @@ "manifest_version": 1, "name": "altium", "displayName": "Altium Designer",- "version": "0.2.100",+ "version": "0.2.101", "description": "Drive Altium Designer from Adom: a resident DelphiScript agent (eval + the 1,100-command process launcher), the X2 -R command line, UIA over the VCL shell, dialogs by PID, screenshots of every Altium window, and Altium 365.", "homepage": "https://wiki.adom.inc/adom/altium-bridge", "docs": "https://wiki.adom.inc/adom/altium-bridge",