← Commit history

Merge PR #603: AI Flow 0.2.110: Altium rules board-wide only, raised only (#228) (release-0.2.110 -> main) merge

Colby Knox ·780304df14 · ·parents 6d9553c, 3479deb

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

8 files changed +53−14
Cargo.lock+10−10
@@ -4,7 +4,7 @@ version = 4  [[package]] name = "adom-aiflow"-version = "0.2.109"+version = "0.2.110" dependencies = [  "aiflow-analyze",  "aiflow-board",@@ -25,7 +25,7 @@ dependencies = [  [[package]] name = "aiflow-analyze"-version = "0.2.109"+version = "0.2.110" dependencies = [  "aiflow-board",  "serde",@@ -35,7 +35,7 @@ dependencies = [  [[package]] name = "aiflow-board"-version = "0.2.109"+version = "0.2.110" dependencies = [  "roxmltree",  "serde",@@ -44,7 +44,7 @@ dependencies = [  [[package]] name = "aiflow-bridge"-version = "0.2.109"+version = "0.2.110" dependencies = [  "aiflow-board",  "serde",@@ -53,7 +53,7 @@ dependencies = [  [[package]] name = "aiflow-copper"-version = "0.2.109"+version = "0.2.110" dependencies = [  "aiflow-board",  "aiflow-grid",@@ -63,7 +63,7 @@ dependencies = [  [[package]] name = "aiflow-grid"-version = "0.2.109"+version = "0.2.110" dependencies = [  "aiflow-board",  "serde",@@ -72,7 +72,7 @@ dependencies = [  [[package]] name = "aiflow-place"-version = "0.2.109"+version = "0.2.110" dependencies = [  "aiflow-board",  "serde",@@ -81,7 +81,7 @@ dependencies = [  [[package]] name = "aiflow-pours"-version = "0.2.109"+version = "0.2.110" dependencies = [  "aiflow-board",  "aiflow-copper",@@ -91,7 +91,7 @@ dependencies = [  [[package]] name = "aiflow-router"-version = "0.2.109"+version = "0.2.110" dependencies = [  "aiflow-board",  "aiflow-grid",@@ -102,7 +102,7 @@ dependencies = [  [[package]] name = "aiflow-run"-version = "0.2.109"+version = "0.2.110" dependencies = [  "serde",  "serde_json",
Cargo.toml+1−1
@@ -14,7 +14,7 @@ members = [ ]  [workspace.package]-version = "0.2.109"+version = "0.2.110" edition = "2021" license = "MIT" repository = "https://wiki.adom.inc/adom/adom-aiflow"
bin/adom-aiflow
⋯ 1 unchanged line ⋯
crates/adom-aiflow/src/main.rs+7−1
@@ -7926,7 +7926,13 @@ fn main() {                 if let Some(rep) = eda.load_design_rules(&|v: &str, a: &Value| br.raw_call(v, a), &slug, layers, &text, &prefs_now) {                     let okk = Bridge::ok(&rep);                     fusion_loaded = json!(okk);-                    fusion_note = if okk { format!("; {}: {shown} {layers}-layer rules loaded into the open design", eda.name()) } else { format!("; {} did not load them ({}): open the design and run `rules use` again", eda.name(), rep["errorCode"].as_str().or(rep["error"].as_str()).unwrap_or("?")) };+                    // issue #228: what the Altium board kept (already at or above a floor; scoped rules; kinds with only+                    // scoped rules, which the bridge does not create a board-wide rule over)+                    let kept: Vec<String> = rep["kept"].as_array().into_iter().flatten().filter_map(|v| v.as_str().map(str::to_string)).collect();+                    let skipped: Vec<String> = rep["skipped"].as_array().into_iter().flatten().map(|v| format!("{} ({})", v["kind"].as_str().unwrap_or("?"), v["reason"].as_str().unwrap_or(""))).collect();+                    let kept_note = if kept.is_empty() && skipped.is_empty() { String::new() } else { format!("; kept as the board has them: {}{}", kept.join(", "), if skipped.is_empty() { String::new() } else { format!("; not written (only net-class or query rules of that kind): {}", skipped.join(", ")) }) };+                    fusion_note = if okk && rep["unchanged"] == true { format!("; {}: every board-wide rule is already at or above the {shown} floors, nothing written{kept_note}", eda.name()) }+                        else if okk { format!("; {}: {shown} {layers}-layer rules loaded into the open design{kept_note}", eda.name()) } else { format!("; {} did not load them ({}): open the design and run `rules use` again", eda.name(), rep["errorCode"].as_str().or(rep["error"].as_str()).unwrap_or("?")) };                 }             }             // the choice: in the spec when there is one, and in the run (an intake run has no spec yet).
crates/aiflow-bridge/src/altium.rs+26
@@ -340,6 +340,10 @@ impl Eda for AltiumEda {             return Some(json!({"success": true, "unchanged": true, "kept": kept, "note": "every board-wide rule is already at or above the fab's floors: nothing written"}));         }         send["expectPath"] = json!(self.path);+        // altium-bridge 0.2.107: write only each kind's board-wide rule (net-class and query rules left alone) and+        // only raise a minimum below the value given; an older bridge ignores both and writes as before+        send["scope"] = json!("board");+        send["raiseOnly"] = json!(true);         let mut r = t.send("altium_set_design_rules", &send);         if let Some(o) = r.as_object_mut() { o.insert("kept".into(), json!(kept)); }         Some(r)@@ -521,4 +525,26 @@ mod tests {         assert_eq!(bbox(&sq(1.0, 2.0, 3.0, 5.0)), [1.0, 2.0, 3.0, 5.0]);         assert_eq!(area(&sq(0.0, 0.0, 2.0, 3.0)), 6.0);     }++    /// Issue #228 with altium-bridge 0.2.107: a floor the board is below is written with scope "board" and+    /// raiseOnly; a board already at or above every floor gets no write at all.+    #[test]+    fn rules_go_to_the_board_wide_rule_and_only_raise() {+        use crate::eda::Eda;+        let a = AltiumEda { path: "C:/b.PcbDoc".into() };+        let dru = "(rule c (constraint clearance (min 0.2mm)))";+        let sent = std::cell::RefCell::new(Vec::<(String, Value)>::new());+        let below = |v: &str, args: &Value| -> Value { sent.borrow_mut().push((v.to_string(), args.clone()));+            if v == "altium_read_rules" { json!({"data": {"rules": [{"descriptor": "Clearance Constraint (Gap=0.15mm) (All),(All)", "enabled": true, "scope1": "All"}]}}) } else { json!({"success": true}) } };+        a.load_design_rules(&below, "f", 2, dru, &Value::Null).unwrap();+        let set = sent.borrow().iter().find(|(v, _)| v == "altium_set_design_rules").cloned().expect("a set call");+        assert_eq!((set.1["scope"].as_str(), set.1["raiseOnly"].as_bool(), set.1["clearance"].as_f64()), (Some("board"), Some(true), Some(0.2)));+        sent.borrow_mut().clear();+        let above = |v: &str, args: &Value| -> Value { sent.borrow_mut().push((v.to_string(), args.clone()));+            if v == "altium_read_rules" { json!({"data": {"rules": [{"descriptor": "Clearance Constraint (Gap=0.3mm) (All),(All)", "enabled": true, "scope1": "All"}, {"descriptor": "Hole To Hole Clearance (Gap=0.25mm) (All),(All)", "enabled": true, "scope1": "All"}]}}) } else { json!({"success": true}) } };+        let r = a.load_design_rules(&above, "f", 2, dru, &Value::Null).unwrap();+        assert_eq!(r["unchanged"], true);+        assert!(!sent.borrow().iter().any(|(v, _)| v == "altium_set_design_rules"));+    } }+
docs/release-0.2.110.mdadded+7
@@ -0,0 +1,7 @@+# AI Flow 0.2.110++- **Altium rules: the board-wide rule only, raised only** (#228, with altium-bridge 0.2.107). When `rules use` does+  need to raise a floor on an Altium board, it now asks the bridge to write only each kind's board-wide rule+  (`scope: "board"`) and only where the board is below the value (`raiseOnly`): net-class and query rules stay as+  they are, and a tighter value is never lowered. A kind the board has only scoped rules for is not created over+  them; `rules use` lists it with the rules the board kept. An older Altium bridge ignores both and writes as before.
package.json+1−1
@@ -1,7 +1,7 @@ {   "slug": "adom-aiflow",   "type": "app",-  "version": "0.2.109",+  "version": "0.2.110",   "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.109",+  "version": "0.2.110",   "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.",