← Commit history

Merge PR #505: AI Flow 0.2.80: thermal-vias not applicable for an empty spec.hot (aiflow-0.2.80 -> main) merge

Colby Knox ·5283343f11 · ·parents fa48b24, c87062c

Showing changes introduced by the merge (against its first parent).

10 files changed +99−14
Cargo.lock+10−10
@@ -4,7 +4,7 @@ version = 4  [[package]] name = "adom-aiflow"-version = "0.2.79"+version = "0.2.80" dependencies = [  "aiflow-analyze",  "aiflow-board",@@ -25,7 +25,7 @@ dependencies = [  [[package]] name = "aiflow-analyze"-version = "0.2.79"+version = "0.2.80" dependencies = [  "aiflow-board",  "serde",@@ -35,7 +35,7 @@ dependencies = [  [[package]] name = "aiflow-board"-version = "0.2.79"+version = "0.2.80" dependencies = [  "roxmltree",  "serde",@@ -44,7 +44,7 @@ dependencies = [  [[package]] name = "aiflow-bridge"-version = "0.2.79"+version = "0.2.80" dependencies = [  "aiflow-board",  "serde",@@ -53,7 +53,7 @@ dependencies = [  [[package]] name = "aiflow-copper"-version = "0.2.79"+version = "0.2.80" dependencies = [  "aiflow-board",  "aiflow-grid",@@ -63,7 +63,7 @@ dependencies = [  [[package]] name = "aiflow-grid"-version = "0.2.79"+version = "0.2.80" dependencies = [  "aiflow-board",  "serde",@@ -72,7 +72,7 @@ dependencies = [  [[package]] name = "aiflow-place"-version = "0.2.79"+version = "0.2.80" dependencies = [  "aiflow-board",  "serde",@@ -81,7 +81,7 @@ dependencies = [  [[package]] name = "aiflow-pours"-version = "0.2.79"+version = "0.2.80" dependencies = [  "aiflow-board",  "aiflow-copper",@@ -91,7 +91,7 @@ dependencies = [  [[package]] name = "aiflow-router"-version = "0.2.79"+version = "0.2.80" dependencies = [  "aiflow-board",  "aiflow-grid",@@ -101,7 +101,7 @@ dependencies = [  [[package]] name = "aiflow-run"-version = "0.2.79"+version = "0.2.80" dependencies = [  "serde",  "serde_json",
Cargo.toml+1−1
@@ -14,7 +14,7 @@ members = [ ]  [workspace.package]-version = "0.2.79"+version = "0.2.80" edition = "2021" license = "MIT" repository = "https://wiki.adom.inc/adom/adom-aiflow"
bin/adom-aiflow
⋯ 1 unchanged line ⋯
crates/adom-aiflow/src/boardkind.rs+20
@@ -34,6 +34,14 @@ pub const PATTERN: &str = "pattern"; /// The fields step's not-applicable reason. pub const FIELDS_NA: &str = "no loads, hot parts or signal checks in the spec"; +/// Issue #206 (Noah): the thermal-vias step on a board with nothing that dissipates (an empty `spec.hot`).+pub const THERMAL_VIAS_NA: &str = "no hot parts in the spec (spec.hot is empty)";++/// Why a thermal-vias record of "not applicable" no longer stands: spec.hot now names a part.+pub fn thermal_vias_na_refusal(spec: &Value) -> Option<String> {+    nonempty(&spec["hot"]).then(|| "spec.hot names hot parts".to_string())+}+ /// The electrical steps the pattern lane leaves out, each with its reason (finish reports them). pub const PATTERN_NA: &[(&str, &str)] = &[     ("design, sourcing, parts, project-page, library, schematic, simulation, components, libraries", "no parts, BOM or schematic: a passive copper pattern"),@@ -112,6 +120,8 @@ pub fn finish_lines(data: &Value) -> Vec<String> {     if pattern { for (steps, why) in PATTERN_NA { out.push(format!("{steps}: not applicable ({why})")); } }     let tf = &data["outcomes"]["tour-fields"];     if tf["notApplicable"] == true && !pattern { out.push(format!("fields: not applicable ({})", tf["reason"].as_str().unwrap_or(FIELDS_NA))); }+    let tv = &data["outcomes"]["thermal-vias"];+    if tv["notApplicable"] == true && !pattern { out.push(format!("thermal-vias: not applicable ({})", tv["reason"].as_str().unwrap_or(THERMAL_VIAS_NA))); }     out } @@ -197,4 +207,14 @@ mod tests {         assert_eq!(finish_lines(&d), vec![format!("fields: not applicable ({FIELDS_NA})")]);         assert!(finish_lines(&json!({"sequence": ["routing"]})).is_empty());     }+    /// Issue #206: an empty spec.hot is a thermal-vias record of "not applicable"; finish lists it and refuses it once a part is hot.+    #[test]+    fn thermal_vias_not_applicable_is_listed_and_refused_once_hot() {+        let data = json!({"sequence": ["placement", "routing", "thermal-vias"], "outcomes": {"thermal-vias": {"notApplicable": true, "reason": THERMAL_VIAS_NA, "landed": 0}}});+        assert!(finish_lines(&data).iter().any(|l| l.starts_with("thermal-vias: not applicable")), "{:?}", finish_lines(&data));+        assert!(thermal_vias_na_refusal(&json!({"hot": {}})).is_none());+        assert!(thermal_vias_na_refusal(&json!({})).is_none());+        assert!(thermal_vias_na_refusal(&json!({"hot": {"U1": {"watts": 0.25, "tabNet": "GND"}}})).is_some());+    }+ }
crates/adom-aiflow/src/main.rs+17−1
@@ -5733,6 +5733,9 @@ fn main() {                 if let Some(why) = boardkind::pattern_refusal(&board_of(&r)).or_else(|| boardkind::pattern_spec_refusal(&spec_soft(&r), converter::calcs_of_run(&r.data).as_ref())) { missing.push(format!("pattern lane: {why} (start a run on the electrical lane)")); }                 if r.data["target"].is_null() { missing.push("native DRC: a pattern board's DRC is finish's live full DRC with the fab rules; bind the board on a test box (start --target <box> --remote-board <path>, bind-remote-board) and finish again".into()); }             }+            if o.get("thermal-vias").is_some_and(|f| f["notApplicable"] == true) {+                if let Some(why) = boardkind::thermal_vias_na_refusal(&spec_soft(&r)) { missing.push(format!("thermal-vias: recorded as not applicable, but now {why} (`thermal-vias plan` and `land` again)")); }+            }             if o.get("tour-fields").is_some_and(|f| f["notApplicable"] == true) {                 let why = boardkind::fields_applies(&spec_soft(&r), converter::calcs_of_run(&r.data).as_ref());                 if !why.is_empty() { missing.push(format!("fields: recorded as not applicable, but now {} (solve with adom-fields, then `tour fields`)", why.join("; "))); }@@ -6529,7 +6532,20 @@ fn main() {                 lines.extend(freshness.iter().map(|f| format!("  {f}")));                 r.outcome("thermal-vias-plan", json!({"plan": pp, "parts": parts.iter().map(|p| json!({"ref": p.reference, "net": p.net, "target": p.target, "existing": p.existing, "planned": p.planned.len(), "note": p.note, "copper": p.copper})).collect::<Vec<_>>(), "pourFreshness": freshness, "boardZones": board_zones}));                 r.save().unwrap();-                if spec["hot"].as_object().map(|o| o.is_empty()).unwrap_or(true) { err("spec.hot names no hot parts", &["Add every part that dissipates real power: \"hot\": {\"U1\": {\"watts\": 0.25, \"tabNet\": \"GND\"}} (watts from the datasheet's efficiency or Rds(on), the inductor's DCR times I squared).".into()]); }+                if spec["hot"].as_object().map(|o| o.is_empty()).unwrap_or(true) {+                    // issue #206 (Noah): nothing dissipates (a coupon, a pattern, passive copper): the step's proof is 0 vias,+                    // recorded as not applicable the way `tour fields` records no solve; finish refuses it once spec.hot names a part+                    if let Some(c) = converter::detect(&spec, converter::calcs_of_run(&r.data).as_ref()) {+                        findings(&format!("spec.hot names no hot parts, so nothing is recorded: but the design is a switching converter ({c})"), &["Its switch, diode and inductor dissipate: add each to spec.hot with its watts and tabNet (from calcs.json, aiflow-circuit-design), then `thermal-vias plan` again.".into()]);+                    }+                    r.outcome("thermal-vias", json!({"notApplicable": true, "reason": boardkind::THERMAL_VIAS_NA, "landed": 0, "short": [], "acked": acked, "hotNote": spec["hotNote"].clone()}));+                    r.save().unwrap();+                    let mut hints = vec!["finish lists thermal-vias as not applicable, and refuses this record if spec.hot later names a part (then `thermal-vias plan` and `land` again). Never add a hot part only to get vias.".to_string()];+                    if spec["hotNote"].as_str().map(|n| n.trim().is_empty()).unwrap_or(true) { hints.push("Suggested: say why nothing dissipates in spec.hotNote (\"a via-resistance coupon: only the copper's own I2R, 112 mW\"), so the reader of the run sees the reason.".into()); }+                    hints.push("Next: `step pours`.".into());+                    ok(&format!("thermal-vias: not applicable ({}); recorded as the step's proof, 0 vias planned or landed\n{}", boardkind::THERMAL_VIAS_NA, lines.join("\n")), &hints);+                    return;+                }                 ok(&format!("heatsink via plan ({} vias): {}\n{}", plan["nets"].as_array().map(|a| a.len()).unwrap_or(0), pp.display(), lines.join("\n")), &["Review it with the human in one line per part, then `thermal-vias land`. A part with a note needs your call: pour its net on the other layer, move a neighbour, or `--ack REF --why`.".into(), "Copper here is spec.pours plus the saved board's filled zones (the human's zones count before the pours step adopts them); after the human redraws or refills a zone, save the board (adopt-board) and plan again.".into()]);             } else {                 let pp = r.outcomes().get("thermal-vias-plan").and_then(|o| o["plan"].as_str()).map(str::to_string).unwrap_or_else(|| err("no heatsink via plan; run `thermal-vias plan` first", &[]));
docs/release-0.2.80.mdadded+8
@@ -0,0 +1,8 @@+# AI Flow 0.2.80++- **thermal-vias on a board with nothing hot** (#206, Noah). With an empty `spec.hot`, `thermal-vias plan` used to+  stop with "spec.hot names no hot parts", so the step never got its proof and finish listed it until it was+  deviated. It now records the step as not applicable, 0 vias (the way `tour fields` records no solve), suggests+  a `hotNote` when there is none, and finish lists "thermal-vias: not applicable". finish refuses that record once+  spec.hot names a part. A switching converter with an empty spec.hot gets a finding instead (its switch and+  inductor dissipate), and nothing is recorded. Test added.
package.json+1−1
@@ -1,7 +1,7 @@ {   "slug": "adom-aiflow",   "type": "app",-  "version": "0.2.79",+  "version": "0.2.80",   "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.79",+  "version": "0.2.80",   "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
@@ -240,6 +240,8 @@ the library, simulation, current, thermal, fields and export, Fusion for everyth     budget, at least 6) and `thermal-vias land`. A hot part with no exposed tab (an LED, an     inductor, a small leaded IC) is listed with its watts and no tabNet: it is lead-cooled, gets no via     target, and the Fields solve judges it (docs/lead-cooled-parts.md).+    With nothing that dissipates (an empty `spec.hot`, the reason in `hotNote`), `thermal-vias plan` records+    the step as not applicable, 0 vias (0.2.80, issue #206); finish refuses that record once spec.hot names a part. 11. **Pours**, then **rounded corners**: `outline round` (1.0 mm default, spec outline.cornerRadius). 12. **Current, heat and fields, in Hydrogen.** `analyze current`, `analyze thermal`, adom-fields in the     right pane with every part ghosted (`ui view --parts ghost --camera iso`, `tour`). A problem here is
tests/empty-hot-workflow.pyadded+39
@@ -0,0 +1,39 @@+"""Issue #206 end to end, no CAD, bridge or dashboard: an empty spec.hot makes `thermal-vias plan` record the step+as not applicable (0 vias), finish lists it, and finish refuses that record once spec.hot names a part."""+import json, os, pathlib, subprocess, sys, tempfile++binary = str(pathlib.Path(sys.argv[1]).resolve())+BOARD = """(kicad_pcb (version 20241229) (generator "test") (general (thickness 1.6))+ (layers (0 "F.Cu" signal) (2 "B.Cu" signal) (25 "Edge.Cuts" user) (37 "F.SilkS" user))+ (net 0 "") (net 1 "A") (net 2 "B")+ (gr_rect (start 0 0) (end 30 20) (layer "Edge.Cuts"))+ (footprint "TestPoint:TestPoint_Pad_D1.5mm" (layer "F.Cu") (at 5 10) (property "Reference" "TP1" (at 0 -2) (layer "F.SilkS"))+  (pad "1" smd circle (at 0 0) (size 1.5 1.5) (layers "F.Cu") (net 1 "A")))+ (footprint "TestPoint:TestPoint_Pad_D1.5mm" (layer "F.Cu") (at 25 10) (property "Reference" "TP2" (at 0 -2) (layer "F.SilkS"))+  (pad "1" smd circle (at 0 0) (size 1.5 1.5) (layers "F.Cu") (net 2 "B"))))+"""+with tempfile.TemporaryDirectory(prefix="aiflow-empty-hot-") as td:+    p = pathlib.Path(td)+    env = dict(os.environ, AIFLOW_DASHBOARD="off", AIFLOW_NO_PART_SEARCH="1", AIFLOW_NO_PART_LOOKUP="1")+    (p / "board.kicad_pcb").write_text(BOARD)+    (p / "spec.json").write_text(json.dumps({"hot": {}, "hotNote": "a via-resistance coupon: only the copper's own I2R"}))++    def call(*args):+        return subprocess.run([binary, "--run", "run", "--ai-thread", "empty-hot-test", *args], cwd=p, env=env, capture_output=True, text=True, timeout=120)++    r = call("start", "--board", "board.kicad_pcb", "--spec", "spec.json", "--engine", "test")+    assert r.returncode == 0, r.stdout + r.stderr+    r = call("thermal-vias", "plan")+    assert r.returncode == 0 and "thermal-vias: not applicable" in r.stdout and "ERROR" not in r.stdout, r.stdout + r.stderr+    assert "hotNote" not in r.stdout, "a note was given, so no hotNote suggestion: " + r.stdout+    o = json.loads((p / "run" / "run.json").read_text())["outcomes"]["thermal-vias"]+    assert o["notApplicable"] is True and o["landed"] == 0, o+    r = call("finish")+    out = r.stdout + r.stderr+    assert "thermal-vias: not applicable" in out and "no thermal-vias recorded" not in out, out+    # the record no longer stands once a part is hot+    (p / "spec.json").write_text(json.dumps({"hot": {"TP1": {"watts": 0.5, "tabNet": "A"}}}))+    r = call("finish")+    out = r.stdout + r.stderr+    assert "thermal-vias: recorded as not applicable, but now spec.hot names hot parts" in out, out+print("ok empty-hot-workflow")