Repository navigation
Agents and scripts: Export describes its exact parameters and reply (#13315) - #13321
Conversation
…angency-labs#13315) file.export gets a typed contract (ExportParams) and an output schema (FileExportResult), so describe_command and engine.describe give its exact parameters and reply, and warn and strict can check its calls. The contract reads each key only for the format the handler reads it for (the URDF keys for URDF, quality and objects for the others), with the handler's own messages, so a call that works today is not refused. A format or mesh_prefix that is not text, which the handler reads as left out, is now reported in warn and refused in strict. Made with Claude Opus 5.5 in Claude Code (Ultra plan, default effort, fast mode off, Ultracode off).
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Tested this merged onto current No problems found:
I checked A heads-up: #13322 (New Design's contract) conflicts with this PR in |
Change
Agents and scripts drive SolidCraft through named commands. The MCP tool
describe_commandandengine.describegive a command's exact parameters and reply, but only for commands with schemas. This PR gives them to Export (file.export), the command behind File › Export that writes every format. The export command of each format (Export STEP, STL, 3MF, OBJ and URDF) already has them. With the parameter check at warn or strict, a misspelt or wrong-typed parameter is now reported or refused. Fixes #13315, part of #2829.The contract
ExportParamsand the reply typeFileExportResultextendschema/file.rs(tests infile_tests.rs).file.exportleavesschema/unconverted.txt.ExportParamshas a hand-writtenDeserializethat reads what the handler reads, in the same cases.pathcomes first; the other keys are read only once there is a path to write to andformat(or the path's extension) names a known format, as the handler refuses those first. For URDF it readsbodies,mesh_prefix,effortandvelocity, and notqualityorobjects. For the other formats it readsbodies,qualityandobjects, and not the URDF keys. So{"path": "robot.urdf", "quality": "rough"}, which works today, is not refused in strict.path,bodies(throughparams::string_listitself),quality(trimmed and case-blind, asMeshQuality::from_namereads it),objects(componentonly for 3MF) and a positiveeffortorvelocityfail with the handler's own message.pathis optional in the type and required in the schema, so a call without it keeps the handler's message.FileExportResultis the reply of the export command of the format:ExportResult(path, bytes, format, andfilesfor OBJ) orUrdfExportResult. The handler still builds the replies, as the per-format commands do; nothing in them changes.ExportResult'sformatdoc now also names StlAscii, ThreeMfTagged and Design, which onlyfile.exportwrites.Stricter than the handler: the handler reads
formatandmesh_prefixwithstr_, so a value that is not text is read as if it were left out (aformatof3falls back to the path's extension). Warn now reports such a value and strict refuses it.nullis still read as left out.Schemas for keys a format ignores: the published schema lists every key of every format, so a URDF key sent with an STL path is not an unknown key, and the contract does not check it, as the handler does not read it.
What changes for callers: nothing for a call that works today, apart from a
formatormesh_prefixthat is not text, in warn/strict mode.Changes a default: no
Tests
New tests in
crates/engine/src/schema/file_tests.rs:schemas_and_the_key_check_agree: now withExportParamsstrict_keeps_todays_errors: 21 failing calls (no path, a blank, wrong-typed or 4096-character path, an unknown format, badquality,objectsandbodies, design JSON and URDF withbodies, non-positiveeffort, wrongvelocity) give the same error in strict as with the check off, and write nothingthe_export_type_reads_each_key_only_for_its_formatthe_export_schema_takes_what_the_handler_readsexport_replies_match_the_output_schema: real exports of STL, ASCII STL, OBJ, STEP, 3MF with component parts, tagged 3MF, design JSON and URDF from a two-component design, in warn (noparam_warnings) and strict, each matching the output schemaa_misspelt_or_wrong_typed_export_key_is_reported: a misspelt key and a wrong-typedformatare reported in warn, and strict refuses the misspelt key before anything is writtenValidation
On Linux:
cargo fmt --check: pass.cargo clippy -p solidcraft-engine --all-targets -- -D warnings: clean.cargo test -p solidcraft-engine --lib -- schema:: hostile cmd::file: 595 passed, 1 failed (a case of the new schema test that the test helperconformscan't check, as it does not readoneOf; since removed). Rerun after that change,schema::file cmd::file(the URDF export tests included): 72 passed, 0 failed.cargo xtask listsandcargo xtask mesh-decisions: pass.web-offline-testand the wasm and UI builds.Made with Claude Opus 5.5 in Claude Code (Ultra plan, default effort, fast mode off, Ultracode off).
Summary by CodeRabbit
New Features
Bug Fixes