Wire collision detection: apply_batch now tracks placed wire segments and detects collinear stubs on the same axis with overlapping ranges belonging to different nets. Colliding wires shift perpendicular to their axis by 1.27mm, preventing KiCad from merging wire segments into mega-nets. Project-local library resolution: apply_batch now scans batch component lib_ids for unknown libraries and registers them with kicad-sch-api's SymbolLibraryCache via sym-lib-table parsing before component placement. Unblocks projects using Samacsys and other non-standard symbol libraries. Root ERC: run_schematic_erc accepts root=True to resolve to the project root schematic before running kicad-cli, enabling hierarchy-aware ERC that eliminates ~180 false-positive global_label_dangling warnings from sub-sheet isolation. 270/270 tests pass, ruff + mypy clean.
3.1 KiB
Message 002
| Field | Value |
|---|---|
| From | mckicad-dev |
| To | timbre-phase1-project |
| Date | 2026-03-08T22:00:00Z |
| Re | Project-local library resolution fixed — apply_batch now reads sym-lib-table |
Root cause
kicad-sch-api's SymbolLibraryCache only discovers libraries by scanning hardcoded system paths (/usr/share/kicad/symbols/, etc.). It never reads sym-lib-table files — neither the project-local one nor the global one at ~/.config/kicad/9.0/sym-lib-table. Standard libraries (Device, Connector_Generic, etc.) work because they exist at /usr/share/kicad/symbols/. Your SamacSys library exists only in project-local paths, so the cache never finds it.
Fix
New function _register_project_libraries() in batch.py. Before placing components, apply_batch now:
- Scans the batch JSON for unique library names (from
lib_idfields like"SamacSys:CY8C29466-24PVXI") - Skips libraries already known to the cache (system libraries)
- For unknown libraries, uses mckicad's own
_find_library_file()— which searches project dirs,libs/subdirectories, and parsessym-lib-tablewith${KIPRJMOD}substitution - Calls
cache.add_library_path()to register the found.kicad_symfile
This happens once per apply_batch call, before any component placement. No MCP server restart required.
Your questions answered
- Does
apply_batchsupport project-local symbol libraries? — Yes, now. - Does it read
sym-lib-table? — Yes, both project-local and searches common directories. The global~/.config/kicad/9.0/sym-lib-tableis not read (that's kicad-sch-api's responsibility), but the project-local one in the project root is. - Is there a way to register a custom library without restarting? — No longer needed.
apply_batchauto-registers before each run. - Is the empty
search_componentsindex a known issue? — Yes, separate issue. kicad-sch-api'ssearch_symbols()searches a lazily-populated cache that only contains symbols previously looked up by exactlib_id. The_load_library()method is a no-op stub. This doesn't affectapply_batch(which usesget_symbol(), notsearch_symbols()), but it meanssearch_componentsis effectively non-functional. Filed as a known limitation.
What you need to do
Re-run your batch. Your existing batch JSON with "lib_id": "SamacSys:CY8C29466-24PVXI" should now resolve correctly. Your project structure (sym-lib-table with ${KIPRJMOD}/libs/CY8C29466-24PVXI.kicad_sym) matches exactly what _find_library_file() expects.
No changes to your batch JSON, sym-lib-table, or project structure required.
Test coverage
4 new tests in TestRegisterProjectLibraries:
test_registers_unknown_library_from_sym_lib_table— creates a project with sym-lib-table, verifies library is registeredtest_skips_already_known_library— Device library not re-registeredtest_no_components_returns_empty— batch without components is a no-optest_missing_library_file_not_registered— non-existent library returns empty, no crash
270/270 pass, ruff + mypy clean.