Rust native performance instrumentation

Status: accepted close-to-format diagnostic surface.

Decision and boundary

KiCad Monkey exposes opt-in timing companions for the source-bundle index, structured design facts and Design JSON, schematic Plotter-IR, and board facts/Plotter-IR. Cruncher uses those companions to attribute one complete native design-review transaction, but Monkey does not own the downstream command, artifact tree, benchmark policy, or performance target.

The public entry points are SchematicBundleIndex::build_profiled, build_kicad_design_facts_profiled, build_kicad_design_json_profiled, schematic_plot_document_with_sheets_profiled, and board_plot_facts_with_sidecars_profiled. Each returns the same bounded product as its ordinary companion plus an elapsed-nanosecond profile. Profile fields describe internal close-to-format stages; they do not alter a serialized KiCad, Plotter-IR, or SVG contract and do not establish a cross-host timing guarantee.

Shared implementation and source ownership

Profiled and ordinary entry points call one implementation. Detailed clocks are created only for the profiled Monkey path. Resource ceilings, parsing, validation, source identities, returned model ownership, and errors are otherwise identical.

SchematicDocument::parse_named_with_definition and from_named_reader_with_definition return the owned document together with the promoted typed definition validated during the same bounded source admission. The definition is an owned snapshot and cannot observe later document edits. Existing constructors delegate to that path and discard the snapshot; definition() remains available when a caller needs a fresh typed view after mutation. This avoids a redundant parse for consumers that immediately need both carriers without introducing a self-referential model.

Safety and evidence

No diagnostic entry point raises a source, item, point, text, nested, materialization, work, or output ceiling. The profiled builders preserve exact artifact ordering and fail-closed behavior. Focused Monkey tests compare profiled and ordinary products and assert exact timing inventories; same-change Cruncher tests consume every public companion, preserve source binding, and verify the complete transaction profile. The accepted downstream Speedy decision records the system benchmark and artifact parity; it does not broaden Monkey's close-to-format ownership.