← Commit history
sourcing check: fiducials and mounting holes may have a BOM row
A footprint with no pad on a net is on the board but needs no row, so a row for it passes and leaving
it out passes.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2 files changed
+27−2
crates/adom-aiflow/src/preboard.rs+26−1@@ -50,13 +50,16 @@ pub fn parse_csv(text: &str) -> Vec<Vec<String>> { /// The references a board needs in its BOM: every footprint with a pad on a net (electrical), /// minus the ones the footprint itself excludes from the BOM (`attr exclude_from_bom` or /// `board_only`: contacts, test pads, machine pins drawn as pads). Returns (needed, excluded).+/// A footprint with no pad on a net (a fiducial, a mounting hole, a logo) is on the board but needs+/// no row: it is in `excluded`, so a BOM that lists it anyway ("no part", or a standoff it carries)+/// is not told it names a part the board does not have. pub fn board_refs(b: &Board) -> (BTreeSet<String>, BTreeSet<String>) { let (mut need, mut excluded) = (BTreeSet::new(), BTreeSet::new()); for fp in b.root.find_all("footprint") { let Some(reference) = aiflow_board::reference_of(fp) else { continue }; if reference.is_empty() || reference.starts_with('#') { continue; } let electrical = b.pads_of(&reference).iter().any(|p| !p.net.trim().is_empty());- if !electrical { continue; }+ if !electrical { excluded.insert(reference); continue; } let text = fp.find("attr").map(|a| (1..8).filter_map(|i| a.atom(i).map(str::to_string)).collect::<Vec<_>>().join(" ")).unwrap_or_default(); if text.contains("exclude_from_bom") || text.contains("board_only") { excluded.insert(reference); } else { need.insert(reference); } }@@ -609,6 +612,28 @@ mod tests { assert_eq!(rows, vec![vec!["a", "b"], vec!["C6 C7", "x, \"y\""]]); } + #[test]+ fn mechanical_footprints_may_have_a_row_and_need_none() {+ // fiducials and mounting holes (no pad on a net) are on the board: a "no part" row for them is+ // not an extra reference, and leaving them out is not a missing one+ let b = aiflow_board::Board::from_text("t", r#"(kicad_pcb (version 20241229) (layers (0 "F.Cu" signal) (2 "B.Cu" signal)) (net 0 "") (net 1 "A") (net 2 "B") (gr_rect (start 0 0) (end 10 10) (layer "Edge.Cuts"))+ (footprint "R" (layer "F.Cu") (at 5 5) (property "Reference" "R1") (pad "1" smd rect (at -0.5 0) (size 0.5 0.5) (layers "F.Cu") (net 1 "A")) (pad "2" smd rect (at 0.5 0) (size 0.5 0.5) (layers "F.Cu") (net 2 "B")))+ (footprint "Fiducial" (layer "F.Cu") (at 1 1) (property "Reference" "FID1") (pad "" smd circle (at 0 0) (size 1 1) (layers "F.Cu" "F.Mask")))+ (footprint "MountingHole" (layer "F.Cu") (at 9 9) (property "Reference" "H1") (pad "" np_thru_hole circle (at 0 0) (size 3.2 3.2) (drill 3.2) (layers "*.Cu" "*.Mask"))))"#.to_string()).unwrap();+ let refs = board_refs(&b);+ assert_eq!(refs.0.iter().cloned().collect::<Vec<_>>(), vec!["R1"]);+ assert!(refs.1.contains("FID1") && refs.1.contains("H1"), "{refs:?}");+ let with = format!("{HEAD}R1,10k,CR0402,Bourns,Adom stock,,,\nFID1,,no part,,,,,\nH1,,no part,,,,,\n");+ let out = sourcing_check(&with, Some(&refs), "fab", 10);+ assert_eq!(out["pass"], true, "{out}");+ let without = format!("{HEAD}R1,10k,CR0402,Bourns,Adom stock,,,\n");+ assert_eq!(sourcing_check(&without, Some(&refs), "fab", 10)["pass"], true);+ // a reference the board does not have at all is still an extra one+ let stray = format!("{HEAD}R1,10k,CR0402,Bourns,Adom stock,,,\nFID9,,no part,,,,,\n");+ let out = sourcing_check(&stray, Some(&refs), "fab", 10);+ assert!(out["errors"].to_string().contains("not an electrical part on the board: FID9"), "{out}");+ }+ #[test] fn off_board_rows_are_sourced_but_left_out_of_the_board_diff() { let bom = "ref,mpn,source,vendor_pn,stock_checked_2026-11-07,placement\nU1,TPS,Mouser,595-TPS,5000,\nBT1,1578,Mouser,485-1578,435,off-board\n";
skills/aiflow-sourcing/SKILL.md+1−1@@ -52,7 +52,7 @@ ref,value,function,mpn,manufacturer,package,source,vendor_pn,stock_checked_2026- U1,TPS54202DDCR,sync buck,TPS54202DDCR,Texas Instruments,SOT-23-6 (DDC),Mouser,595-TPS54202DDCR,160 (lead 140 d),thin stock; order early ``` -Every reference in the netlist must have a BOM row, including contacts, machine pins and test pads (as "no part" rows). Diff the two before the schematic is frozen.+Every reference in the netlist must have a BOM row, including contacts, machine pins and test pads (as "no part" rows). A footprint with no pad on a net (a fiducial, a mounting hole, a logo) needs no row; `sourcing check` accepts one if the BOM lists it. Diff the two before the schematic is frozen. The binary gates this: