← Commit history
AI Flow 0.2.82: stale Fields solve notes; decoupling spec example
Co-Authored-By: Claude Opus 5.5 <[email protected]>
9 files changed
+172−14
Cargo.lock+10−10@@ -4,7 +4,7 @@ version = 4 [[package]] name = "adom-aiflow"-version = "0.2.81"+version = "0.2.82" dependencies = [ "aiflow-analyze", "aiflow-board",@@ -25,7 +25,7 @@ dependencies = [ [[package]] name = "aiflow-analyze"-version = "0.2.81"+version = "0.2.82" dependencies = [ "aiflow-board", "serde",@@ -35,7 +35,7 @@ dependencies = [ [[package]] name = "aiflow-board"-version = "0.2.81"+version = "0.2.82" dependencies = [ "roxmltree", "serde",@@ -44,7 +44,7 @@ dependencies = [ [[package]] name = "aiflow-bridge"-version = "0.2.81"+version = "0.2.82" dependencies = [ "aiflow-board", "serde",@@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "aiflow-copper"-version = "0.2.81"+version = "0.2.82" dependencies = [ "aiflow-board", "aiflow-grid",@@ -63,7 +63,7 @@ dependencies = [ [[package]] name = "aiflow-grid"-version = "0.2.81"+version = "0.2.82" dependencies = [ "aiflow-board", "serde",@@ -72,7 +72,7 @@ dependencies = [ [[package]] name = "aiflow-place"-version = "0.2.81"+version = "0.2.82" dependencies = [ "aiflow-board", "serde",@@ -81,7 +81,7 @@ dependencies = [ [[package]] name = "aiflow-pours"-version = "0.2.81"+version = "0.2.82" dependencies = [ "aiflow-board", "aiflow-copper",@@ -91,7 +91,7 @@ dependencies = [ [[package]] name = "aiflow-router"-version = "0.2.81"+version = "0.2.82" dependencies = [ "aiflow-board", "aiflow-grid",@@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "aiflow-run"-version = "0.2.81"+version = "0.2.82" dependencies = [ "serde", "serde_json",
Cargo.toml+1−1@@ -14,7 +14,7 @@ members = [ ] [workspace.package]-version = "0.2.81"+version = "0.2.82" edition = "2021" license = "MIT" repository = "https://wiki.adom.inc/adom/adom-aiflow"
bin/adom-aiflow⋯ 1 unchanged line ⋯
crates/adom-aiflow/src/fields_versions.rsadded+123@@ -0,0 +1,123 @@+//! Adom Fields fixes that change evidence AI Flow binds (the Fields thread, 2026-11-17): a solve made by+//! an older adom-fields is still the same-input solve, but on these boards its numbers were wrong, so+//! analyze says so and suggests solving again. Suggestions only; the screen itself is unchanged.+//! - 0.10.10 (adom/adom-fields#35): a Fusion/EAGLE .brd's mirrored parts at MR90/MR270 had pads 1 and 2+//! swapped, so terminal currents and heat landed on the wrong copper.+//! - 0.10.9 (adom/adom-fields#32): a hot part with no tabNet put its watts, and read its rise, inside the+//! drill of large through-hole pins (a pin whose 1.2 mm disk is mostly drill, e.g. MachineContactLarge).+//! - 0.10.10 refused a spec with AI Flow's `decoupling` pairs; 0.10.11 reads them again.+use serde_json::Value;+use std::path::Path;++/// A version string "0.10.9" as (0, 10, 9); None when it does not read.+pub fn parse(v: &str) -> Option<(u64, u64, u64)> {+ let mut it = v.trim().trim_start_matches('v').split(['.', '-', '+']).map(|p| p.parse::<u64>().ok());+ Some((it.next()??, it.next()??, it.next().flatten().unwrap_or(0)))+}++/// A drill this large fills most of the 1.2 mm disk Fields 0.10.8 heated a leaded pin over.+const BIG_DRILL_MM: f64 = 0.85;++/// The suggestions for this solve, this spec and this board file (empty: nothing to say).+pub fn stale_notes(fields: &Value, spec: &Value, board: &Path) -> Vec<String> {+ let Some(solver) = fields["inputIdentity"]["solverVersion"].as_str().and_then(parse) else { return Vec::new() };+ let mut out = Vec::new();+ let text = std::fs::read_to_string(board).unwrap_or_default();+ if solver < (0, 10, 10) && board.extension().is_some_and(|e| e.eq_ignore_ascii_case("brd")) {+ let mirrored = mirrored_quarter_turns(&text);+ if !mirrored.is_empty() {+ out.push(format!("this Fields solve is adom-fields {}, before 0.10.10, which swapped pads 1 and 2 of mirrored bottom parts at MR90/MR270 on a .brd ({}): their currents and heat landed on the wrong copper. Update adom-fields (adom-wiki pkg install adom/adom-fields) and solve again before you trust these numbers.", version_text(solver), mirrored.join(", ")));+ }+ }+ if solver < (0, 10, 9) && text.contains("(kicad_pcb") {+ if let Ok(b) = aiflow_board::Board::from_text(&board.display().to_string(), text) {+ let mut parts = Vec::new();+ for (name, h) in spec["hot"].as_object().into_iter().flatten() {+ let leaded = h["tabNet"].as_str().map(str::is_empty).unwrap_or(true);+ if leaded && b.pads_of(name).iter().any(|p| p.thru && p.drill.is_some_and(|d| d >= BIG_DRILL_MM)) { parts.push(name.clone()); }+ }+ if !parts.is_empty() {+ out.push(format!("this Fields solve is adom-fields {}, before 0.10.9, which heated a part with no tabNet inside the drill of its large through-hole pins ({}): their rise read far too high. Update adom-fields (adom-wiki pkg install adom/adom-fields) and solve again.", version_text(solver), parts.join(", ")));+ }+ }+ }+ out+}++/// The installed adom-fields when it is 0.10.10, which refuses AI Flow's `decoupling` pairs.+pub fn installed_note(version_line: &str) -> Option<String> {+ let v = version_line.split_whitespace().last().and_then(parse)?;+ (v == (0, 10, 10)).then(|| "adom-fields 0.10.10 is installed: it refuses a spec with AI Flow's \"decoupling\" pairs (\"invalid type: map, expected a sequence\"). Update it (adom-wiki pkg install adom/adom-fields; 0.10.11 reads them again) and solve again.".to_string())+}++fn version_text(v: (u64, u64, u64)) -> String { format!("{}.{}.{}", v.0, v.1, v.2) }++/// Element names on a .brd placed mirrored at a quarter turn (rot="MR90", "SMR270", ...).+fn mirrored_quarter_turns(brd: &str) -> Vec<String> {+ let mut out = Vec::new();+ for tag in brd.split("<element ").skip(1) {+ let head = &tag[..tag.find('>').unwrap_or(tag.len())];+ let attr = |k: &str| head.split(&format!("{k}=\"")).nth(1).and_then(|s| s.split('"').next()).unwrap_or("");+ let rot = attr("rot").trim_start_matches('S');+ if rot == "MR90" || rot == "MR270" { out.push(attr("name").to_string()); }+ }+ out+}++#[cfg(test)]+mod tests {+ use super::*;+ use serde_json::json;++ fn tmp(name: &str, text: &str) -> std::path::PathBuf {+ let d = std::env::temp_dir().join(format!("aiflow-fields-versions-{}", std::process::id()));+ std::fs::create_dir_all(&d).unwrap();+ let p = d.join(name);+ std::fs::write(&p, text).unwrap();+ p+ }++ #[test]+ fn versions_parse() {+ assert_eq!(parse("0.10.9"), Some((0, 10, 9)));+ assert_eq!(parse("v0.7.20"), Some((0, 7, 20)));+ assert!(parse("0.10.9") < parse("0.10.10"));+ assert_eq!(parse("x"), None);+ }++ #[test]+ fn a_brd_with_mirrored_quarter_turns_solved_before_0_10_10_is_named() {+ let brd = tmp("t.brd", r#"<elements><element name="R1" rot="MR90"/><element name="C2" rot="MR180"/><element name="U3" rot="SMR270"/></elements>"#);+ let old = stale_notes(&json!({"inputIdentity": {"solverVersion": "0.10.9"}}), &json!({}), &brd);+ assert_eq!(old.len(), 1, "{old:?}");+ assert!(old[0].contains("R1, U3") && !old[0].contains("C2"), "{old:?}");+ assert!(stale_notes(&json!({"inputIdentity": {"solverVersion": "0.10.11"}}), &json!({}), &brd).is_empty());+ assert!(stale_notes(&json!({"inputIdentity": {}}), &json!({}), &brd).is_empty(), "no version: nothing to say");+ }++ #[test]+ fn a_leaded_hot_part_on_large_drills_solved_before_0_10_9_is_named() {+ let pcb = tmp("t.kicad_pcb", r#"(kicad_pcb (version 20240108) (generator "t")+ (layers (0 "F.Cu" signal) (2 "B.Cu" signal) (25 "Edge.Cuts" user))+ (net 0 "") (net 1 "VIN")+ (gr_rect (start 0 0) (end 30 20) (layer "Edge.Cuts") (stroke (width 0.1) (type default)))+ (footprint "Adom:MachineContactLarge" (layer "F.Cu") (at 10 10) (property "Reference" "MC1" (at 0 0) (layer "F.SilkS"))+ (pad "1" thru_hole circle (at 0 0) (size 4.4 4.4) (drill 2.62) (layers "*.Cu") (net 1 "VIN")))+ (footprint "Adom:MachineContactMedium" (layer "F.Cu") (at 20 10) (property "Reference" "MC2" (at 0 0) (layer "F.SilkS"))+ (pad "1" thru_hole circle (at 0 0) (size 1.3 1.3) (drill 0.78) (layers "*.Cu") (net 1 "VIN"))))"#);+ let spec = json!({"hot": {"MC1": {"watts": 1.0}, "MC2": {"watts": 0.5}}});+ let old = stale_notes(&json!({"inputIdentity": {"solverVersion": "0.10.8"}}), &spec, &pcb);+ assert_eq!(old.len(), 1, "{old:?}");+ assert!(old[0].contains("(MC1)"), "only the large drill: {old:?}");+ assert!(stale_notes(&json!({"inputIdentity": {"solverVersion": "0.10.9"}}), &spec, &pcb).is_empty());+ let tabbed = json!({"hot": {"MC1": {"watts": 1.0, "tabNet": "VIN"}}});+ assert!(stale_notes(&json!({"inputIdentity": {"solverVersion": "0.10.8"}}), &tabbed, &pcb).is_empty(), "a tabNet part was never leaded");+ }++ #[test]+ fn only_0_10_10_installed_is_named() {+ assert!(installed_note("adom-fields 0.10.10").is_some());+ assert!(installed_note("adom-fields 0.10.11").is_none());+ assert!(installed_note("garbage").is_none());+ }+}
crates/adom-aiflow/src/main.rs+6@@ -1,6 +1,7 @@ //! adom-aiflow: the board loop as one command, with the clock, the negotiation and the finish line. //! Every reply starts with OK: or ERROR: and carries Hint: lines that depend on this board and run. mod continuation;+mod fields_versions; mod supply; mod priorities; mod part_check;@@ -5574,6 +5575,9 @@ fn main() { // provenance: a fields.json is evidence only when it is the output of a solve aiflow ran or watched; // any other file (copied, edited, or written to look like one) is solved again here, same inputs let mut unobserved: Option<String> = None;+ if aiflow_analyze::needs_field_screen(&spec,what) {+ if let Some(n) = std::process::Command::new("adom-fields").arg("--version").output().ok().and_then(|o| fields_versions::installed_note(&String::from_utf8_lossy(&o.stdout))) { note(&n, &[]); }+ } if aiflow_analyze::needs_field_screen(&spec,what) && fields_file.is_file() && !fields_observed(&r,&fields_file) { let out_dir = dir.join("fields"); let args: Vec<String> = vec!["analyze".into(),"--board".into(),solved_board.clone(),"--spec".into(),r.data["spec"].as_str().unwrap_or("").to_string(),"--out".into(),out_dir.display().to_string()];@@ -5589,6 +5593,8 @@ fn main() { let mut sink_notes: Vec<String> = Vec::new(); let screen=if let Some(u)=unobserved.clone() { Err(u) } else if !aiflow_analyze::needs_field_screen(&spec,what) { Ok(Vec::new()) } else if fields_file.is_file() { let f=aiflow_analyze::fields_report::load(&fields_file).unwrap_or_else(|e| err(&e,&[]));+ // the Fields thread, 2026-11-17: a solve by an adom-fields with a fix that changes this board's numbers+ for n in fields_versions::stale_notes(&f, &spec, Path::new(&solved_board)) { note(&n, &[]); } if let Err(e)=std::fs::metadata(&solved_board) { err(&e.to_string(),&[]); } let spec_bytes=std::fs::read(r.data["spec"].as_str().unwrap_or("")).unwrap_or_else(|e|err(&e.to_string(),&[])); // issue #70: record reviewed part-limited peaks, then screen with the live ones
docs/release-0.2.82.mdadded+12@@ -0,0 +1,12 @@+# AI Flow 0.2.82++- **Fields evidence from an adom-fields with a fix that changes this board's numbers** (from the Adom Fields+ thread, adom-fields 0.10.9 to 0.10.11). `analyze current` and `analyze thermal` read the solve's+ `inputIdentity.solverVersion` and add a NOTE suggesting a fresh solve when:+ - the board is a Fusion/EAGLE .brd with parts placed mirrored at MR90/MR270 and the solve is older than 0.10.10+ (adom/adom-fields#35: pads 1 and 2 were swapped, so currents and heat landed on the wrong copper);+ - a hot part with no tabNet sits on large through-hole pins (drill 0.85 mm or more, such as MachineContactLarge)+ and the solve is older than 0.10.9 (adom/adom-fields#32: the heat went inside the drill);+ - adom-fields 0.10.10 is installed (it refused AI Flow's `decoupling` pairs; 0.10.11 reads them again).+ The screen itself is unchanged; these are suggestions. Tests added.+- **docs/spec-example.json** has a `decoupling` pairs example, so Adom Fields' own spec test parses one.
docs/spec-example.json+18−1@@ -575,6 +575,23 @@ "hotNote": "BSC016N06NS at 20 A phase current: I2R at 3 mOhm hot (Rds(on) 1.6 mOhm typ at 25 C) over one third of the electrical cycle (six-step) is 0.4 W, plus about 0.2 W of switching at 24 kHz: 0.6 W per FET. U1 is a linear regulator on the +VBAT tab: 0.5 W.", "hotMaxRiseC": 60, "hotMaxRiseNote": "the tab may sit 60 C above ambient at the stated dissipation (theta from the 40 C/W per square inch outer-copper heuristic of 0.1)",+ "decoupling": [+ {+ "cap": "C6",+ "pin": "U1.39",+ "returnPins": [+ "U1.38"+ ],+ "maxLengthMm": 3.0,+ "maxVias": 0,+ "severity": "warning"+ },+ {+ "cap": "C7",+ "pin": "U1.47"+ }+ ],+ "decouplingNote": "Each decoupling cap with the supply pin it serves (routed first, reviewed in route and gate). AI Flow's key, a list of pairs; Adom Fields ignores it (its own screen's exclusions are decouplingSkip).", "fabNote": "3rd party fab (copper ablation: keep as much copper as the electrical rules allow)", "fab": { "rules": "fab",@@ -596,4 +613,4 @@ "simulation" ], "requireEvidenceNote": "kinds `evidence add` must have recorded before finish: calcs (the design equations), simulation (a failing result is refused), vendor-model (a PSpice/LTspice run from adom/adom-spice-skillpack)."-}+}
package.json+1−1@@ -1,7 +1,7 @@ { "slug": "adom-aiflow", "type": "app",- "version": "0.2.81",+ "version": "0.2.82", "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.81",+ "version": "0.2.82", "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.",