Rust Phase 2 Native-Core Boundary And WASM Feasibility Review

Review Status

The native Phase 2 boundary is approved and Phase 3 KiCad-native PCB reader/writer work may proceed. The typed footprint and symbol-library reader/writer proofs and shared footprint/symbol plotter-IR proofs are implemented. WASM feasibility is demonstrated, but WASM packaging is not approved; the remaining adapter findings are deferred to Phase 7. Downstream pcb_a0 work remains outside this plan. The durable ordering and ownership decision is recorded in ADR-011.

Implemented Boundary

SurfaceNative coreWASMWrite/parity evidence
S-expression scan/build/patchYesYes Rack L0/L1 corpus, semantic reparse, stable second write
Standalone footprint view/editYesYes Unknown-byte preservation and focused-property writeback
Symbol-library iterator/editYesYes Python summary oracle, flag replacement/insertion, stable write
Footprint plotter IRYesYes Python vectors; graphics, strokes, pads, drills, point bounds
Library-symbol plotter IRYesYes Python vectors; body, pins, and inheritance

Architecture Audit

Copy And Artifact Evidence

WASM inputs are borrowed slices. Read operations serialize one result buffer. Edit and plot operations allocate the produced KiCad or JSON bytes plus a separate metadata buffer. Paired-output objects retain compatibility clone getters and also expose takeOutputBytes. Complete non-empty execution evidence for every paired result remains a deferred packaging gate.

Locked release wasm32 builds before JavaScript glue, compression, or wasm-opt measure 292,798 bytes for sexpr, 409,815 bytes for footprint, 556,646 bytes for symbol, and 787,825 bytes with every default feature. The three operation families compile independently under isolated feature checks; actual isolated artifact build/link evidence remains a deferred packaging gate. The default remains an all-operations development artifact.

Deferred WASM Packaging Gates

  1. Shared plotter DTO. Before adding PCB, graph, or other WASM plotter producers, generate one canonical Rust PlotterOperation type for footprint and symbol documents and remove the symbol adapter's per-operation JSON round-trip.
  2. Bounded symbol-library read. Add max_output_bytes to the read contract, serialize through a bounded writer, and return a structured resource-limit result without partial summaries.
  3. Take-once execution evidence. Add non-empty ownership tests for footprint edit, footprint plot, and symbol plot, including at least one direct invocation of the generated JavaScript method.
  4. Artifact build evidence. Replace the isolated cargo check feature test with actual build/link evidence when WASM packaging resumes. Until then, describe the current evidence as independent feature compilation.

Retained Native Gates

Recorded Review Decision

Approve the Phase 2 native boundary and authorize Phase 3 KiCad-native PCB reader/writer work. Record WASM as feasibility demonstrated and packaging not approved; the four findings above must close before future WASM expansion. No public Cargo compatibility promise is created by this decision; all crates remain publish = false during incubation.