← Commit history
Merge PR #587: AI Flow 0.2.101: place verify names the failing field (#243) (release-0.2.101 -> main) merge
Showing changes introduced by the merge (against its first parent).
7 files changed
+52−15
Cargo.lock+10−10@@ -4,7 +4,7 @@ version = 4 [[package]] name = "adom-aiflow"-version = "0.2.100"+version = "0.2.101" dependencies = [ "aiflow-analyze", "aiflow-board",@@ -25,7 +25,7 @@ dependencies = [ [[package]] name = "aiflow-analyze"-version = "0.2.100"+version = "0.2.101" dependencies = [ "aiflow-board", "serde",@@ -35,7 +35,7 @@ dependencies = [ [[package]] name = "aiflow-board"-version = "0.2.100"+version = "0.2.101" dependencies = [ "roxmltree", "serde",@@ -44,7 +44,7 @@ dependencies = [ [[package]] name = "aiflow-bridge"-version = "0.2.100"+version = "0.2.101" dependencies = [ "aiflow-board", "serde",@@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "aiflow-copper"-version = "0.2.100"+version = "0.2.101" dependencies = [ "aiflow-board", "aiflow-grid",@@ -63,7 +63,7 @@ dependencies = [ [[package]] name = "aiflow-grid"-version = "0.2.100"+version = "0.2.101" dependencies = [ "aiflow-board", "serde",@@ -72,7 +72,7 @@ dependencies = [ [[package]] name = "aiflow-place"-version = "0.2.100"+version = "0.2.101" dependencies = [ "aiflow-board", "serde",@@ -81,7 +81,7 @@ dependencies = [ [[package]] name = "aiflow-pours"-version = "0.2.100"+version = "0.2.101" dependencies = [ "aiflow-board", "aiflow-copper",@@ -91,7 +91,7 @@ dependencies = [ [[package]] name = "aiflow-router"-version = "0.2.100"+version = "0.2.101" dependencies = [ "aiflow-board", "aiflow-grid",@@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "aiflow-run"-version = "0.2.100"+version = "0.2.101" dependencies = [ "serde", "serde_json",
Cargo.toml+1−1@@ -14,7 +14,7 @@ members = [ ] [workspace.package]-version = "0.2.100"+version = "0.2.101" edition = "2021" license = "MIT" repository = "https://wiki.adom.inc/adom/adom-aiflow"
bin/adom-aiflow⋯ 1 unchanged line ⋯
crates/adom-aiflow/src/placement_verify.rs+32−2@@ -104,12 +104,27 @@ pub fn edge_connector_why(board: &Board, p: &Value, spec: &Value) -> Result<(),S Ok(()) } +/// Issue #243: the same board file whatever the spelling: backslashes or slashes, and a Windows path's case.+pub fn same_board_path(a: &str, b: &str) -> bool {+ let norm = |p: &str| { let q = p.trim().replace('\\', "/"); if q.as_bytes().get(1) == Some(&b':') { q.to_ascii_lowercase() } else { q } };+ norm(a) == norm(b)+}+ pub fn check_with_spec(board: &Board, before: &Value, validation: &Value, after: &Value, remote: &str, spec: &Value) -> Result<Verified,String> { if board.footprints.is_empty() { return Err("no footprints to verify".into()); } let revision=before["revision"].as_str().filter(|s| !s.is_empty()).ok_or("missing native revision")?; for state in [before,after] {- if state["success"]!=true || state["source"]!="live-editor" || state["revision"]!=revision || state["stale"]==true || state["boardPath"]!=remote {- return Err("placement snapshot failed, stale, changed revision or belongs to another board".into());+ // issue #243: say which field failed, and compare the board path as Windows does (slashes, case)+ let which = if std::ptr::eq(state, before) { "before" } else { "after" };+ let failed: Vec<String> = [+ (state["success"]!=true, format!("success is {}", state["success"])),+ (state["source"]!="live-editor", format!("source is {} (not live-editor)", state["source"])),+ (state["revision"]!=revision, format!("revision {} is not {revision}", state["revision"])),+ (state["stale"]==true, "the bridge marks it stale".to_string()),+ (!same_board_path(state["boardPath"].as_str().unwrap_or(""), remote), format!("boardPath {} is not the run's board {remote}", state["boardPath"])),+ ].into_iter().filter(|(bad, _)| *bad).map(|(_, why)| why).collect();+ if !failed.is_empty() {+ return Err(format!("placement snapshot ({which} the check) does not qualify: {}", failed.join("; "))); } let parts=state["footprints"].as_array().ok_or("missing live footprints")?; if parts.len()!=board.footprints.len() || state["footprintCount"].as_u64()!=Some(parts.len() as u64) { return Err("live/saved footprint counts differ".into()); }@@ -229,6 +244,21 @@ mod tests { let mut other=s.clone();other["footprints"][0]["x"]=json!(5.01);assert!(check(&b,&other,&v,&other,"board").is_err()); assert!(check(&b,&s,&v,&s,"other").is_err()); }+ /// Issue #243: the same board spelled with backslashes or another case qualifies; a refusal names the field.+ #[test]+ fn the_board_path_is_compared_as_windows_does_and_a_refusal_names_the_field() {+ let (b,mut s,v)=fixture();+ s["boardPath"]=json!("C:/Users/Me/Boards/demo.kicad_pcb");+ assert_eq!(check(&b,&s,&v,&s,"C:\\Users\\me\\boards\\demo.kicad_pcb").unwrap(),1);+ assert!(!same_board_path("C:/a/b.kicad_pcb","C:/a/c.kicad_pcb"));+ // a POSIX path keeps its case+ assert!(!same_board_path("/home/A/b.kicad_pcb","/home/a/b.kicad_pcb"));+ let mut after=s.clone();after["stale"]=json!(true);+ let e=check(&b,&s,&v,&after,"C:/Users/Me/Boards/demo.kicad_pcb").unwrap_err();+ assert!(e.contains("after the check") && e.contains("stale"), "{e}");+ let e=check(&b,&s,&v,&s,"C:/Users/Me/Boards/other.kicad_pcb").unwrap_err();+ assert!(e.contains("boardPath") && e.contains("other.kicad_pcb"), "{e}");+ } #[test] fn refuses_stale_file_fallback_missing_refs_and_incomplete_drc() { let (b,s,v)=fixture();
docs/release-0.2.101.mdadded+7@@ -0,0 +1,7 @@+# AI Flow 0.2.101++- **`place verify`: a refusal names its reason** (#243, tunie2). The live snapshots before and after the check are+ compared field by field, and a refusal now says which snapshot and which field failed (success, source,+ revision, the bridge's stale mark, or the board path) instead of one generic line. The board path is compared as+ Windows compares it: backslashes and slashes alike, a drive path's case ignored, so a run started with+ `C:\...` (or another letter case) matches the bridge's `C:/...` for the same file.
package.json+1−1@@ -1,7 +1,7 @@ { "slug": "adom-aiflow", "type": "app",- "version": "0.2.100",+ "version": "0.2.101", "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.100",+ "version": "0.2.101", "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.",