← Commit history

0.2.82: schematic_data's parameter budget (#28), simulate sweeps and no_model, engine 0.17.2, agent_start waits for reaped dialogs; the battery waits for other lanes' runs; batteries on the final build: Develop 256/0/1, AD26 256/0/1

Colby Knox ·1e4b54b75c · ·parent c7803cd
9 files changed +94−17
CHANGELOG.md+5−1
@@ -1,6 +1,6 @@ # Changelog -## 0.2.82 (unreleased)+## 0.2.82  - **The standard's shared engine at 0.17.2** (standard 0.20.2, vendored as published). For Altium that brings the   routing fixes: `plan_route` straightens its grid path into straight and 45-degree runs with the same clearance@@ -21,6 +21,10 @@   signal with its `step` (`R4 = 300`). Altium's run reads its sweep list (`ParamSweep_Custom...0`), not the keys its   dialog shows, and a number's `_UserValue` twin before the number: both are written. Checked against ngspice on the   example amplifier: 3.2735 dB at R4 = 300 and 12.8159 dB at 900 (10 MHz), the same to the last digit.+- **`schematic_data {params:true}` no longer times out on a slow sheet** (#28). Altium once took the whole 120 s over a+  6-part sheet's parameters on a user's machine (never reproduced; a database- or vault-linked parameter is the likely+  cause). Parameters and descriptions now get a budget (`paramBudgetSec`, 60 s); parts past it come back with their+  parameters read from the saved sheet (`paramsFromFile`), named in `paramsSkipped`, with `paramsComplete: false`. - **`altium_simulate` runs the analysis asked for on every sheet.** A sheet with no simulation settings of its own ran   on what Altium stored for it (sheet 1 of Altium's example ran its old AC sweep for an `op`): it now gets its own   settings, keyed by its id in the project (given one when it has none, as a bridge-made project's sheets do), and a new
bridge-rs/src/main.rs+1−1
@@ -68,7 +68,7 @@ use tiny_http::{Header, Method, Response, Server}; /// Attached to every failed reply (see the /command handler). const REPORT_ISSUES: &str = "If this looks like an altium-bridge BUG (not a refusal you expected), report it: check for a duplicate with `adom-wiki issue list adom/altium-bridge`, then `adom-wiki issue create adom/altium-bridge --title \"<verb>: <one-line symptom>\" --category bug-report --body \"<what you ran, what you expected, what happened, the VERBATIM response JSON (and errorShot if present), bridgeVersion, the Altium version from altium_status, the OS>\"`. A relay, routing, toast or lifecycle problem belongs on adom/adom-bridge instead. Reports from real machines are how this bridge gets correct: three different Altium builds behaved three different ways in one weekend."; -pub const BRIDGE_VERSION: &str = "0.2.81";+pub const BRIDGE_VERSION: &str = "0.2.82";  fn json_response(status: u16, body: &serde_json::Value) -> Response<std::io::Cursor<Vec<u8>>> {     let data = serde_json::to_vec(body).unwrap_or_else(|_| b"{}".to_vec());
bridge-rs/src/verbs.rs+22−2
@@ -534,7 +534,7 @@ fn describe() -> Value {             "Use it to verify an imported footprint on a altium_test_board: pad layerId 74 = multi-layer (plated through), which is what altium_plate_vias produces.",             &["component_pins", "plate_vias", "test_board", "pcb_report"], &["Needs a .PcbDoc current: it reads a placed component, not a PcbLib member (altium_pcb_report reads libraries).", "3D bodies, fills and regions only show up in otherPrimitives."], json!({"designator": "U1"})),         verb_doc("schematic_data", "Components on a schematic sheet (filePath, else the CURRENT sheet) with their pins (number, name, electrical type), position and orientation. designator filters to one part.",-            json!({"filePath": "path to the .SchDoc - optional, made current first (alias sheet)", "designator": "string - optional filter", "limit": "int, default 500", "pins": "bool, default true", "params": "bool, default false - include each component's parameters", "paramNamesOnly": "bool, default false - parameter names without values (a library with blob parameters reads fast)"}),+            json!({"filePath": "path to the .SchDoc - optional, made current first (alias sheet)", "designator": "string - optional filter", "limit": "int, default 500", "pins": "bool, default true", "params": "bool, default false - include each component's parameters", "paramNamesOnly": "bool, default false - parameter names without values (a library with blob parameters reads fast)", "paramBudgetSec": "number, default 60 (0-100): the time Altium gets for parameters and descriptions; parts past it come back with their parameters read from the saved file (paramsFromFile, paramsSkipped, paramsComplete false) instead of the call timing out"}),             json!({"data": "{document, count, components: [{designator, partId, libReference, comment, description (empty for a workspace-managed part), kind (ComponentKind: 0 Standard, 1 Mechanical, 2 Graphical, 3 Net Tie BOM, 4 Net Tie, 5 Standard no BOM, 6 Jumper), itemGuid, vaultGuid, sourceLibrary, xMil, yMil, orientation, pins: [{number, name, electrical (0 Input, 1 IO, 2 Output, 3 OpenCollector, 4 Passive, 5 HiZ, 6 OpenEmitter, 7 Power), xMil, yMil, orientation, lengthMil}], params: []}]}", "roundtripMs": "int"}), 120,             "Pin-level view of a sheet. params[] is empty unless you pass params:true; altium_read_schematic is the fuller parameter view.",             &["read_schematic", "cross_check", "show_schematic"], &["One sheet per call. Without filePath the current document must be a .SchDoc: a schematic library is refused (no_current_schematic), not read as an empty sheet.", "electrical is Altium's pin-type ordinal, not a name."], json!({"designator": "U1"})),@@ -1957,7 +1957,27 @@ pub fn dispatch(command: &str, args: &Value, _forwarded: &[(String, String)]) ->             // a sheet's parameters are bulky and most callers want pins.             let params = if args.get("params").and_then(|b| b.as_bool()) == Some(true) { "1" } else { "0" };             let names_only = if args.get("paramNamesOnly").and_then(|b| b.as_bool()) == Some(true) { "1" } else { "0" };-            let r = board_read("schematic_data", vec![("designator", s(args, "designator").unwrap_or_default()), ("limit", s(args, "limit").unwrap_or("500".into())), ("pins", pins.into()), ("params", params.into()), ("paramNamesOnly", names_only.into())], 120);+            let budget = args.get("paramBudgetSec").and_then(|v| v.as_f64()).unwrap_or(60.0).clamp(0.0, 100.0);+            let mut r = board_read("schematic_data", vec![("designator", s(args, "designator").unwrap_or_default()), ("limit", s(args, "limit").unwrap_or("500".into())), ("pins", pins.into()), ("params", params.into()), ("paramNamesOnly", names_only.into()), ("paramBudgetMs", format!("{}", (budget * 1000.0) as i64))], 120);+            // the parts whose parameters Altium had no time left for (#28): their parameters from the saved file+            let skipped: Vec<String> = r.get("data").and_then(|d| d["paramsSkipped"].as_array()).map(|a| a.iter().filter_map(|x| x.as_str().map(String::from)).collect()).unwrap_or_default();+            if !skipped.is_empty() {+                let file = s(args, "filePath").or_else(|| s(args, "sheet"));+                let saved = file.map(|p| crate::schdoc::read_sheet_file(&json!({"path": p, "pins": false, "params": true}))).unwrap_or(Value::Null);+                let from_file: std::collections::HashMap<String, Value> = saved["components"].as_array().cloned().unwrap_or_default().into_iter()+                    .filter_map(|c| c["designator"].as_str().map(|d| (d.to_ascii_uppercase(), c.clone()))).collect();+                if let Some(cs) = r.get_mut("data").and_then(|d| d.get_mut("components")).and_then(|c| c.as_array_mut()) {+                    for c in cs.iter_mut() {+                        let d = c["designator"].as_str().unwrap_or("").to_ascii_uppercase();+                        if !skipped.iter().any(|x| x.eq_ignore_ascii_case(&d)) { continue; }+                        if let Some(f) = from_file.get(&d) { c["params"] = f["params"].clone(); c["paramsFromFile"] = json!(true); }+                    }+                }+                if let Some(d) = r.get_mut("data") {+                    d["paramsComplete"] = json!(false);+                    d["_paramsHint"] = json!(format!("Altium took longer than {budget} s over the parameters (adom/altium-bridge#28), so {}'s came from the SAVED sheet where filePath was given (paramsFromFile): unsaved edits to them are not there. paramBudgetSec raises the budget (up to 100).", skipped.join(", ")));+                }+            }             // Altium did not answer in time (#28: a 6-part sheet with params ran out its 120 s): the saved file still             // has the parts, read without Altium             let timed_out = r.get("errorCode").and_then(|e| e.as_str()).map(|e| e.contains("timed_out") || e.contains("timeout")).unwrap_or(false);
dev-skills/altium-bridge-test/run_verb_tests.py+42−3
@@ -438,9 +438,12 @@ def matrix(w):     M["export_gencad"] = dict(phase=4, timeout=300, **ok(filePath=LB, outputDir=D + "/gencad", uniquePins=True),                               check=lambda d: str(d.get("file", "")).endswith(".cad") and (d.get("counts") or {}).get("components", 0) > 0)     SIM = D + "/sim/3_Reinforcing properties  Frequency characteristics.SchDoc"-    # 0.2.80 (EDA Bridge Standard #23): the amplifier's AC gain levels off at 9.27 dB (ngspice agrees to 0.0001 dB)-    M["simulate"] = dict(phase=4, timeout=900, **ok(schematic=SIM, analysis={"type": "ac", "sweep": "dec", "points": 10, "start": 10, "stop": 1e8}, probes=[{"net": "OUT"}], points=50),-                         check=lambda d: bool(d.get("signals")) and abs(d["signals"][0]["y"][-1] - 9.266) < 0.05 and d["signals"][0]["xUnit"] == "Hz")+    # 0.2.81 (EDA Bridge Standard #23), sweeps 0.2.82: the amplifier's AC gain at 10 MHz with R4 swept 300/600/900 ohm is+    # 3.2735 / 9.2941 / 12.8159 dB (ngspice agrees to the last digit), each run its own signal with its step+    M["simulate"] = dict(phase=4, timeout=900, **ok(schematic=SIM, analysis={"type": "ac", "sweep": "dec", "points": 5, "start": 1e3, "stop": 1e7},+                                                    sweep={"parameter": "R4", "start": 300, "stop": 900, "step": 300}, probes=[{"net": "OUT"}], points=50),+                         check=lambda d: len(d.get("signals") or []) == 3 and abs(d["signals"][2]["y"][-1] - 12.816) < 0.01+                                         and d["signals"][2].get("step") == "R4 = 900" and d["signals"][0]["xUnit"] == "Hz")     M["export_spice"] = dict(phase=4, timeout=900, **ok(schematic=SIM), check=lambda d: len(d.get("elements") or []) >= 8 and bool(d.get("analyses")))     M["generate_body"] = dict(phase=4, **ok(family="qfn", outputPath=D + "/bodies/QFN16.step", marking="STM32\nG031"),                               check=lambda d: abs(((d.get("bboxMm") or {}).get("x") or 0) - 4.0) < 0.01 and d.get("marking") and not d.get("notApplied"))@@ -504,6 +507,31 @@ def matrix(w):     return M  +def other_batteries(target):+    """Other lanes' (or another Altium) verb batteries running in this WSL against the same machine: KiCad brings its own+    windows to the front as they open (kicad-bridge #112), so two batteries on one laptop take each other's clicks and+    keys. kicad-lane's run waits for ours the same way. [(pid, script)]"""+    me, out = os.getpid(), []+    for d in os.listdir("/proc"):+        if not d.isdigit() or int(d) == me:+            continue+        try:+            argv = open(f"/proc/{d}/cmdline", "rb").read().split(b"\0")+        except OSError:+            continue+        argv = [x.decode("utf-8", "replace") for x in argv if x]+        # the python process itself, not a `timeout` or shell wrapping it+        if not argv or "python" not in os.path.basename(argv[0]):+            continue+        script = next((x for x in argv[1:] if x.endswith("run_verb_tests.py")), None)+        if not script:+            continue+        tgt = next((argv[i + 1] for i, x in enumerate(argv[:-1]) if x == "--target"), None)+        if tgt and tgt.lower() == target.lower():+            out.append((int(d), script))+    return out++ def main():     ap = argparse.ArgumentParser()     ap.add_argument("--target", required=True)@@ -515,8 +543,19 @@ def main():     ap.add_argument("--json", default="")     ap.add_argument("--min-idle", type=int, default=180, help="refuse to run unless the target has had no keyboard/mouse input for this many seconds")     ap.add_argument("--user-is-away", action="store_true", help="the human told you this machine is free: skip the idle check")+    ap.add_argument("--wait-for-others", type=int, default=1800, help="seconds to wait for another battery on the same machine before refusing")     a = ap.parse_args()     T, TH = a.target, a.thread+    waited, others = 0, other_batteries(T)+    while others and waited < a.wait_for_others:+        if waited == 0:+            print(f"waiting: another verb battery is running on {T}: {others}", flush=True)+        time.sleep(15)+        waited += 15+        others = other_batteries(T)+    if others:+        sys.exit(f"REFUSED: another verb battery is still running on {T} after {waited} s: {others}. Two at once take each other's "+                 "clicks and keys (kicad-bridge #112). Run again when it is done.")     # The battery launches Altium, opens documents and shows views: it WILL pull Altium in front of     # whoever is at the keyboard (it did, 2026-09-20, while the user was typing). Never run it on a     # machine somebody is using.
package.json+1−1
@@ -1,6 +1,6 @@ {   "slug": "altium-bridge",-  "version": "0.2.81",+  "version": "0.2.82",   "type": "app",   "description": "Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.",   "tags": [
page.json+1−1
@@ -4,7 +4,7 @@   "type": "app",   "title": "Altium Bridge: AI for Altium Designer",   "brief": "Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.",-  "version": "0.2.81",+  "version": "0.2.82",   "hero": {     "type": "image",     "path": "screenshots/hero.png"
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-0.2.81+0.2.82
src/agent/AdomAgent.pas.tmpl+20−6
@@ -5030,8 +5030,9 @@ Var     Prm  : ISch_Parameter;     QIt  : ISch_Iterator;     Want, S, PS, MS, PF, PV, Desc : String;-    N, Limit, PN : Integer;-    WantPins, WantParams : Boolean;+    N, Limit, PN, T0, Budget : Integer;+    WantPins, WantParams, Late : Boolean;+    Skipped : String; Begin     Doc := SchServer.GetCurrentSchDocument;     If Doc = Nil Then Begin Result := '{' + JRaw('ok','false') + ',' + JStr('errorCode','no_current_schematic') + ',' + JStr('error','no current schematic document (open a .SchDoc first)') + '}'; Exit; End;@@ -5042,6 +5043,12 @@ Begin     WantPins := Param(Lines, 'pins') <> '0';     WantParams := Param(Lines, 'params') = '1';     PF := UpperCase(Param(Lines, 'paramFilter'));+    { #28: a 6-part sheet's parameters ran out the whole 120 s on one machine and were never reproduced. A budget for+      parameters and descriptions: once spent, the remaining parts come back without them and are named in paramsSkipped,+      so the bridge fills them from the saved file instead of the call timing out }+    Budget := StrToIntDef(Param(Lines, 'paramBudgetMs'), 60000);+    T0 := GetTickCount;+    Skipped := '';     S := ''; N := 0;     Iter := Doc.SchIterator_Create;     Iter.AddFilter_ObjectSet(MkSet(eSchComponent));@@ -5074,13 +5081,19 @@ Begin                 Comp.SchIterator_Destroy(PIt);             End;             MS := '';-            If WantParams Then+            Late := GetTickCount - T0 > Budget;+            If WantParams And Late Then+            Begin+                If Skipped <> '' Then Skipped := Skipped + ',';+                Skipped := Skipped + '"' + JsonEsc(Comp.Designator.Text) + '"';+            End;+            If WantParams And (Not Late) Then             Begin                 PN := 0;                 QIt := Comp.SchIterator_Create;                 QIt.AddFilter_ObjectSet(MkSet(eParameter));                 Prm := QIt.FirstSchObject;-                While (Prm <> Nil) And (PN < 40) Do+                While (Prm <> Nil) And (PN < 40) And (GetTickCount - T0 <= Budget) Do                 Begin                     If MS <> '' Then MS := MS + ',';                     { paramFilter=|NAME|NAME| reads only those values: an example IC's three 'Available Preview Images'@@ -5103,7 +5116,7 @@ Begin             { a workspace-managed part's description is fetched from its vault: on the Bluetooth Sentinel               example's Altium Content Vault parts that call never returned (2026-10-21). Their item GUID says               where they live; the description of an unmanaged part is read as before. }-            If Comp.ItemGUID = '' Then Desc := Comp.ComponentDescription Else Desc := '';+            If (Comp.ItemGUID = '') And (Not Late) Then Desc := Comp.ComponentDescription Else Desc := '';             If S <> '' Then S := S + ',';             S := S + '{' + JRaw('params', '[' + MS + ']') + ',' + JStr('designator', Comp.Designator.Text) + ',' +                 JRaw('partId', IntToStr(Comp.CurrentPartID)) + ',' +@@ -5125,7 +5138,8 @@ Begin         Comp := Iter.NextSchObject;     End;     Doc.SchIterator_Destroy(Iter);-    Result := '{' + JRaw('ok','true') + ',' + JStr('document', Doc.DocumentName) + ',' + JRaw('count', IntToStr(N)) + ',' + JRaw('components', '[' + S + ']') + '}';+    Result := '{' + JRaw('ok','true') + ',' + JStr('document', Doc.DocumentName) + ',' + JRaw('count', IntToStr(N)) + ',' ++        JRaw('paramsSkipped', '[' + Skipped + ']') + ',' + JRaw('elapsedMs', IntToStr(GetTickCount - T0)) + ',' + JRaw('components', '[' + S + ']') + '}'; End;  { sheet_params: set parameters on PLACED components of the CURRENT schematic sheet (the BOM write-back).
src/bridge.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "altium",   "displayName": "Altium Designer",-  "version": "0.2.81",+  "version": "0.2.82",   "description": "Drive Altium Designer from Adom: a resident DelphiScript agent (eval + the 1,100-command process launcher), the X2 -R command line, UIA over the VCL shell, dialogs by PID, screenshots of every Altium window, and Altium 365.",   "homepage": "https://wiki.adom.inc/adom/altium-bridge",   "docs": "https://wiki.adom.inc/adom/altium-bridge",