Skip to content

feat(pcb): export revision-bound Specctra DSN - #338

Merged
neusse merged 4 commits into
mixelpixx:mainfrom
neusse:codex/freerouting-dsn-export
Aug 29, 2026
Merged

feat(pcb): export revision-bound Specctra DSN#338
neusse merged 4 commits into
mixelpixx:mainfrom
neusse:codex/freerouting-dsn-export

Conversation

@neusse

@neusse neusse commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

User-visible outcome

Adds export_specctra_dsn to the pcb_export toolset. A supported board that is open in KiCad PCB Editor can now produce a deterministic Specctra DSN and a revision-bound reverse manifest without Python, SWIG, GUI automation, or direct board-file editing.

Part of #337. This is the first adapter in the agreed three-PR series; it does not advertise end-to-end autorouting or SES import.

Design

  • Proves the requested board through GetOpenDocuments.
  • Captures the exact live editor state through SaveDocumentToString before and after querying KiCad's effective netclass values.
  • Refuses the export if those snapshots differ.
  • Hashes the exact IPC snapshot and records board, layer, footprint, pad, net, class, transform, and padstack mappings in a deterministic JSON manifest.
  • Uses topola_specctra for the DSN AST/parser/serializer while retaining Konnect-owned KiCad lowering and fail-closed validation.
  • Writes both artifacts with create-new atomic writes; existing targets are structured conflicts and a failed second write removes only the DSN created by that call.

The deliberately narrow first profile supports two copper layers, front-side SMD or plated-through footprints, circle/rectangle pads, one closed straight-line outline, and no existing routing, zones, custom DRC rules, local clearance overrides, pad offsets, or removed-unused-layer pads. Unsupported input is refused rather than approximated.

Compatibility and migration

This adds one public MCP tool and updates the synchronized catalogue from 210 to 211 registered tools (217 including meta-tools). No existing tool, schema, config key, path, or behavior changes. There is no persisted migration.

The manifest schema starts at version 1 so the SES importer can reject incompatible artifacts explicitly in PR 2.

Tests

Passed locally:

  • cargo test --workspace --locked --lib --tests
  • cargo test --workspace --locked --doc
  • cargo clippy --workspace --locked --all-targets -- -D warnings
  • cargo fmt --all -- --check
  • FREEROUTING_JAR=/path/to/freerouting-2.3.0.jar cargo test -p konnect-core freerouting_accepts_exported_fixture -- --ignored

The opt-in engine parity test ran against the installed Freerouting 2.3.0 JAR. Freerouting loaded the generated DSN, completed routing, exited successfully, and produced a non-empty SES. IPC envelope and value conversion are covered with a mock KiCad server. A live-GUI test is intentionally not part of CI because it requires an open disposable board and KiCad API socket.

Risk and rollback

The main risk is incorrect interchange semantics. The first profile minimizes that surface, round-trips every generated DSN through the Specctra parser, and tests the artifact with Freerouting itself. The tool never mutates the live board and never replaces an output file.

Rollback is a straight revert of this commit; no board or config migration is required.

@neusse

neusse commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

Release-integration note: Konnect v0.10.0 added four placement tools while this branch was in review. That blind-side change conflicted with every generated tool-count surface, so the earlier green CI no longer represented the released registry. I rebased onto current main and synchronized this PR at 215 registered / 221 total tools. I also corrected the new public argument to manifest_output_path, added structured DSN/SES/bridge capability facts to the export result, and added a Freerouting v2.3.0-owned DSN corpus fixture alongside the real KiCad board fixture. The focused Specctra suite passes (10 passed, 1 live Java test intentionally ignored), and all six documentation/count contract tests pass. Fresh CI is now authoritative.

@neusse
neusse force-pushed the codex/freerouting-dsn-export branch from b260085 to 40cd690 Compare August 29, 2026 16:22
@neusse

neusse commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator Author

Post-guidance-stack refresh: merged current upstream/main (through #364) into this branch without changing the DSN export design. The complete local gate passes: formatting, Clippy with warnings denied, workspace lib/test targets, and workspace doc tests. Updated head: b7d8ebff6a7fdcb4813f9cf95373df526944439d.

@neusse
neusse merged commit 074743f into mixelpixx:main Aug 29, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant