forked from 1b-agent/opencadstudio-upstream
Automation's "open" op called io::load_bytes directly and installed the result as-is, skipping everything the canonical path-based loader (load_file_for_open / finalize_loaded_outcome) runs after parsing: block-origin normalization for legacy non-zero-origin blocks, relative raster/material path resolution, source_path assignment, and the corrupt-entity purge the UI open path always applies. The same file opened two ways behaved differently, and headless/automation use was more exposed to malformed geometry with no filter at all. Added io::load_bytes_finalized(path, bytes), which runs load_bytes plus that same normalization and purge using the real path (not just its basename, which the old code passed to load_bytes as the "name" parameter — losing the directory needed for raster-path resolution and source_path). automation.rs's "open" handler now uses it and reports the purge count as a "purged" field in the response. load_bytes itself is unchanged, since the byte round-trip tests (sketch_persist.rs, named_parameters_persist.rs) deliberately want the simpler byte-only path with no real filesystem path behind it. New test constructs a document with one normal and one corrupt (zero-radius) entity, saves it, opens it through automation, and checks the corrupt entity was purged and source_path was set — proving the automation path now matches the UI path. Co-Authored-By: Claude Sonnet 5 <[email protected]>