Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

STEP: corpus check

bherbruckd224fde7d40e
diff --git a/apps/solvecraft-cli/src/main.rs b/apps/solvecraft-cli/src/main.rs
index 47deabaccc..c8550d90b0 100644
--- a/apps/solvecraft-cli/src/main.rs
+++ b/apps/solvecraft-cli/src/main.rs
@@ -1,13 +1,14 @@
//! SolveCraft headless command line.
//!
//! ```text
-//! solvecraft-cli run <script.json|design.solvecraft> [--out FILE]... [--save FILE] [--quiet]
-//! solvecraft-cli eval <script.json|design.solvecraft> (alias: inspect) measurements as JSON
+//! solvecraft-cli run <script.json|design.solvecraft|part.step> [--in design|part.step] [--out FILE]... [--save FILE] [--quiet]
+//! solvecraft-cli eval <script.json|design.solvecraft|part.step> (alias: inspect) measurements as JSON
//! solvecraft-cli snapshot <script|design> --out shot.png [--width W] [--height H] [--view iso|front|top|…]
//! solvecraft-cli exec <command> [json-params] run one command on an empty design
//! solvecraft-cli commands the command registry as JSON
//! solvecraft-cli recipe <recipe.json> translate an oracle recipe to a script
//! solvecraft-cli oracle <case-dir>... replay recipes and compare with measure.json
+//! solvecraft-cli step-corpus <case-dir>... import part.step and compare with measure.json
//! solvecraft-cli mcp [--in design|script] [--connect HOST:PORT] MCP server on stdio (docs/mcp.md)
//! ```
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
@@ -23,13 +24,15 @@ use solvecraft_engine::Session;
use solvecraft_engine::render::{StandardView, render_png};
const USAGE: &str = "usage:
- solvecraft-cli run <script.json|design.solvecraft> [--out FILE]... [--save FILE] [--quiet] [--results]
- solvecraft-cli eval <script.json|design.solvecraft> (alias: inspect)
+ solvecraft-cli run <script.json|design.solvecraft|part.step> [--in design.solvecraft|part.step] [--out FILE]... [--save FILE] [--quiet] [--results]
+ solvecraft-cli run --in <design.solvecraft|part.step> [--out FILE]...
+ solvecraft-cli eval <script.json|design.solvecraft|part.step> (alias: inspect; or --in FILE)
solvecraft-cli snapshot <script|design> --out shot.png [--width W] [--height H] [--view iso|front|back|top|bottom|left|right]
solvecraft-cli exec <command> [json-params]
solvecraft-cli commands
solvecraft-cli recipe <recipe.json>
solvecraft-cli oracle <case-dir>... [--json]
+ solvecraft-cli step-corpus <case-dir>... [--json]
solvecraft-cli mcp [--in design.solvecraft|script.json] [--connect 127.0.0.1:PORT]
";
@@ -49,6 +52,7 @@ fn main() -> ExitCode {
recipe::to_script(&v).map(|s| println!("{}", pretty(&s)))
}),
Some("oracle") => oracle::run(&args[1..]),
+ Some("step-corpus") => oracle::step_corpus(&args[1..]),
Some("mcp") => cmd_mcp(&args[1..]),
Some("--version" | "-V") => {
println!("solvecraft-cli {}", env!("CARGO_PKG_VERSION"));
@@ -74,10 +78,14 @@ pub fn read_json(path: &str) -> Result<Value, String> {
serde_json::from_str(&s).map_err(|e| format!("{path}: {e}"))
}
-/// A session from a design file, a command script, or an oracle recipe.
+/// A session from a design file, a STEP file, a command script, or an oracle recipe.
pub fn load(path: &str) -> Result<Session, String> {
- let v = read_json(path)?;
let mut s = Session::default();
+ if solvecraft_engine::io::is_step_path(path) {
+ s.execute("doc.open", &json!({"path": path})).map_err(|e| e.to_string())?;
+ return Ok(s);
+ }
+ let v = read_json(path)?;
if v.get("format").and_then(Value::as_str).is_some_and(|f| f.starts_with("solvecraft")) {
s.execute("doc.open", &json!({"path": path})).map_err(|e| e.to_string())?;
} else if v.get("features").is_some() && v.get("commands").is_none() {
@@ -97,17 +105,45 @@ fn flags<'a>(args: &'a [String], name: &str) -> Vec<&'a str> {
args.windows(2).filter(|w| w[0] == name).map(|w| w[1].as_str()).collect()
}
+/// The first argument that is not an option or an option's value.
+fn positional(args: &[String]) -> Option<&String> {
+ let mut i = 0;
+ while let Some(a) = args.get(i) {
+ if a.starts_with("--") {
+ i += if matches!(a.as_str(), "--quiet" | "--results") { 1 } else { 2 };
+ continue;
+ }
+ return Some(a);
+ }
+ None
+}
+
fn cmd_run(args: &[String]) -> Result<(), String> {
- let path = args.first().ok_or_else(|| USAGE.to_string())?;
+ let base = flag(args, "--in");
+ let path = positional(args);
+ if path.is_none() && base.is_none() {
+ return Err(USAGE.to_string());
+ }
+ // `--in` starts from a design or STEP file; the positional script then runs on top of it.
+ let mut s = match base {
+ Some(b) => load(b)?,
+ None => Session::default(),
+ };
if args.iter().any(|a| a == "--results") {
// Print every command's result (scripts only).
- let v = read_json(path)?;
- let mut s = Session::default();
+ let v = read_json(path.ok_or("--results needs a script")?)?;
let r = s.run_script(&v).map_err(|e| e.to_string())?;
println!("{}", pretty(&Value::Array(r)));
return Ok(());
}
- let mut s = load(path)?;
+ match (base, path) {
+ (Some(_), Some(p)) => {
+ let v = read_json(p)?;
+ s.run_script(&v).map_err(|e| e.to_string())?;
+ }
+ (None, Some(p)) => s = load(p)?,
+ _ => {}
+ }
for out in flags(args, "--out") {
s.execute("ExportCommand", &json!({"path": out})).map_err(|e| e.to_string())?;
}
@@ -122,7 +158,7 @@ fn cmd_run(args: &[String]) -> Result<(), String> {
}
fn cmd_eval(args: &[String]) -> Result<(), String> {
- let path = args.first().ok_or_else(|| USAGE.to_string())?;
+ let path = flag(args, "--in").or_else(|| positional(args).map(String::as_str)).ok_or_else(|| USAGE.to_string())?;
let mut s = load(path)?;
let m = s.execute("MeasureCommand", &json!({})).map_err(|e| e.to_string())?;
let d = s.execute("document.inspect", &json!({})).map_err(|e| e.to_string())?;
diff --git a/apps/solvecraft-cli/src/oracle.rs b/apps/solvecraft-cli/src/oracle.rs
index f3c9a2e5ed..ceb9089f8e 100644
--- a/apps/solvecraft-cli/src/oracle.rs
+++ b/apps/solvecraft-cli/src/oracle.rs
@@ -1,4 +1,5 @@
-//! Replay oracle recipes and compare with Fusion's measurements.
+//! Replay oracle recipes and compare with Fusion's measurements; import oracle STEP files and
+//! compare them with the same measurements.
use serde_json::{Value, json};
@@ -46,38 +47,99 @@ fn check_case(dir: &str) -> Value {
json!({"case": name, "pass": pass, "checks": checks})
}
+/// Import a case's `part.step` (as File → Open does) and compare with Fusion's measurements:
+/// body count, volume and area (relative 1e-3) and the faces read from the file.
+fn check_step_case(dir: &str) -> Value {
+ let name = std::path::Path::new(dir).file_name().map(|x| x.to_string_lossy().to_string()).unwrap_or_default();
+ let sp = format!("{dir}/part.step");
+ let want = match read_json(&format!("{dir}/measure.json")) {
+ Ok(m) => m,
+ Err(e) => return json!({"case": name, "pass": false, "error": e}),
+ };
+ let t0 = std::time::Instant::now();
+ let mut s = solvecraft_engine::Session::default();
+ let opened = match s.execute("doc.open", &json!({"path": sp})) {
+ Ok(v) => v,
+ Err(e) => return json!({"case": name, "pass": false, "error": e.to_string()}),
+ };
+ let got = match s.execute("MeasureCommand", &json!({})) {
+ Ok(m) => m,
+ Err(e) => return json!({"case": name, "pass": false, "error": e.to_string()}),
+ };
+ let ms = t0.elapsed().as_secs_f64() * 1000.0;
+ // Faces read from the file (the kernel may split a face that wraps around a closed surface).
+ let file_faces = std::fs::read(&sp)
+ .ok()
+ .and_then(|b| solvecraft_engine::kernel::step_import_shared(&String::from_utf8_lossy(&b)).ok())
+ .map(|imp| imp.bodies.iter().map(|b| b.file_faces).sum::<usize>() as f64);
+ let mut checks = Vec::new();
+ let mut pass = true;
+ let mut num = |what: &str, g: Option<f64>, w: Option<f64>, rel: f64| {
+ let ok = match (g, w) {
+ (Some(g), Some(w)) => (g - w).abs() <= rel * w.abs().max(1.0),
+ _ => false,
+ };
+ pass &= ok;
+ checks.push(json!({"check": what, "got": g, "want": w, "ok": ok}));
+ };
+ num("body_count", got["body_count"].as_f64(), want["body_count"].as_f64(), 0.0);
+ num("volume_mm3", got["total"]["volume_mm3"].as_f64(), want["total"]["volume_mm3"].as_f64(), REL_TOL);
+ num("area_mm2", got["total"]["area_mm2"].as_f64(), want["total"]["area_mm2"].as_f64(), REL_TOL);
+ num("faces", file_faces, want["total"]["faces"].as_f64(), 0.0);
+ json!({
+ "case": name, "pass": pass, "checks": checks, "ms": ms,
+ "bodies": opened["bodies"], "warnings": opened["warnings"],
+ "info": {"kernel_faces_merged": got["total"]["faces"], "edges": got["total"]["edges"], "want_edges": want["total"]["edges"], "vertices": got["total"]["vertices"], "want_vertices": want["total"]["vertices"]},
+ })
+}
+
+pub fn step_corpus(args: &[String]) -> Result<(), String> {
+ let dirs: Vec<&String> = args.iter().filter(|a| !a.starts_with("--")).collect();
+ if dirs.is_empty() {
+ return Err("step-corpus: give one or more case directories (each with part.step and measure.json)".into());
+ }
+ let results: Vec<Value> = dirs.iter().map(|d| check_step_case(d)).collect();
+ report(args, &results);
+ let failed = results.iter().filter(|r| !r["pass"].as_bool().unwrap_or(false)).count();
+ if failed > 0 { Err(format!("{failed} STEP case(s) failed")) } else { Ok(()) }
+}
+
+fn report(args: &[String], results: &[Value]) {
+ if args.iter().any(|a| a == "--json") {
+ println!("{}", serde_json::to_string_pretty(&Value::Array(results.to_vec())).unwrap_or_default());
+ return;
+ }
+ for r in results {
+ let status = if r["pass"].as_bool().unwrap_or(false) {
+ "PASS"
+ } else if r["skipped"].as_bool().unwrap_or(false) {
+ "SKIP"
+ } else {
+ "FAIL"
+ };
+ let detail: Vec<String> = r["checks"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .filter(|c| !c["ok"].as_bool().unwrap_or(false))
+ .map(|c| format!("{} got {} want {}", c["check"].as_str().unwrap_or(""), c["got"], c["want"]))
+ .collect();
+ let err = r["error"].as_str().map(|e| format!(" ({e})")).unwrap_or_default();
+ println!(
+ "{status} {}{err}{}",
+ r["case"].as_str().unwrap_or(""),
+ if detail.is_empty() { String::new() } else { format!(": {}", detail.join("; ")) }
+ );
+ }
+}
+
pub fn run(args: &[String]) -> Result<(), String> {
let dirs: Vec<&String> = args.iter().filter(|a| !a.starts_with("--")).collect();
if dirs.is_empty() {
return Err("oracle: give one or more case directories".into());
}
let results: Vec<Value> = dirs.iter().map(|d| check_case(d)).collect();
- if args.iter().any(|a| a == "--json") {
- println!("{}", serde_json::to_string_pretty(&Value::Array(results.clone())).unwrap_or_default());
- } else {
- for r in &results {
- let status = if r["pass"].as_bool().unwrap_or(false) {
- "PASS"
- } else if r["skipped"].as_bool().unwrap_or(false) {
- "SKIP"
- } else {
- "FAIL"
- };
- let detail: Vec<String> = r["checks"]
- .as_array()
- .into_iter()
- .flatten()
- .filter(|c| !c["ok"].as_bool().unwrap_or(false))
- .map(|c| format!("{} got {} want {}", c["check"].as_str().unwrap_or(""), c["got"], c["want"]))
- .collect();
- let err = r["error"].as_str().map(|e| format!(" ({e})")).unwrap_or_default();
- println!(
- "{status} {}{err}{}",
- r["case"].as_str().unwrap_or(""),
- if detail.is_empty() { String::new() } else { format!(": {}", detail.join("; ")) }
- );
- }
- }
+ report(args, &results);
let failed = results.iter().filter(|r| !r["pass"].as_bool().unwrap_or(false) && !r["skipped"].as_bool().unwrap_or(false)).count();
if failed > 0 { Err(format!("{failed} oracle case(s) failed")) } else { Ok(()) }
}
diff --git a/docs/step-import.md b/docs/step-import.md
new file mode 100644
index 0000000000..43f1134d97
--- /dev/null
+++ b/docs/step-import.md
@@ -0,0 +1,47 @@
+# STEP import
+
+SolveCraft reads STEP (ISO 10303-21; AP203, AP214 and AP242 geometry) with its own reader in `crates/kernel/src/step_in` (written from the public standards; no third-party STEP code). A STEP file becomes an **Import** base feature on the timeline: it holds the file's B-rep (the STEP text is kept in the design, so the design reopens without the file) and later features — fillets, holes, cuts sketched on its faces, shells — build on its bodies.
+
+- **Open**: File → Open (`doc.open`) accepts `.step`/`.stp` in any case and starts a new design; `solvecraft part.step`; `solvecraft-cli eval part.step`, `solvecraft-cli run script.json --in part.step`; the MCP `open` tool.
+- **Insert** into the current design: File → Insert STEP… or SOLID → INSERT (`FusionImportCommandFromToolbar {path}`).
+- **Drag and drop** a STEP file on the window: inserted when the design has features, opened otherwise.
+
+Read: manifold solid breps (with voids), faceted breps, shell-based surface models; planes, cylinders, cones, spheres, tori, B-spline and rational B-spline surfaces (with knots, Bézier, uniform, quasi-uniform), surfaces of revolution and linear extrusion, trimmed surfaces; lines, circles, ellipses, B-spline curves, polylines, trimmed/surface/seam curves; length and angle units (SI prefixes, conversion-based units such as inches); product names (body names come from the solid's name, else the product's); surface colours; assemblies (next-assembly-usage occurrences placed by item-defined transformations, and mapped items) — the product tree is kept in the feature for the components milestone. Files are untrusted: sizes, entity counts and nesting are capped and every kernel call is guarded. What cannot be read becomes a warning on the feature (a face left out gives an open body); not read yet: offset surfaces, pcurve-only edges.
+
+## Fusion corpus
+
+Generated by `cargo xtask step-corpus`. Each case is a part exported from Fusion as STEP (AP214; kept locally in `plan/fusion/oracle/`, never committed). SolveCraft opens `part.step` exactly as File → Open does (an Import base feature) and compares with Fusion's own measurements: body count, volume and area (relative tolerance 1e-3) and the number of faces read from the file.
+
+**29 / 29 files pass.**
+
+| Case | Result | Bodies | Volume mm³ (got / Fusion) | Area mm² (got / Fusion) | Faces (got / Fusion) | ms | Notes |
+|---|---|---|---|---|---|---|---|
+| 01-box | pass | Box | 24000.000 / 24000.000 | 5200.000 / 5200.000 | 6 / 6 | 2 | |
+| 02-cylinder | pass | Cylinder | 35339.346 / 35342.917 | 6125.844 / 6126.106 | 3 / 3 | 7 | |
+| 03-box-through-hole | pass | Box | 45738.489 / 45738.053 | 9327.795 / 9327.788 | 7 / 7 | 4 | |
+| 04-revolve-vase | pass | Vase | 112487.028 / 112499.479 | 13156.053 / 13156.615 | 5 / 5 | 189 | |
+| 05-taper-extrude | pass | Frustum | 61814.826 / 61814.826 | 9676.915 / 9676.915 | 6 / 6 | 1 | |
+| 06-symmetric-extrude | pass | Block | 30000.000 / 30000.000 | 6200.000 / 6200.000 | 6 / 6 | 1 | |
+| 07-fillet-all-edges | pass | Box | 23340.395 / 23340.849 | 4726.169 / 4726.265 | 26 / 26 | 18 | |
+| 08-chamfer | pass | Box | 23730.667 / 23730.667 | 5029.352 / 5029.352 | 10 / 10 | 1 | |
+| 09-shell | pass | Box | 13632.000 / 13632.000 | 13992.000 / 13992.000 | 11 / 11 | 1 | |
+| 10-rect-pattern-holes | pass | Plate | 29803.869 / 29803.540 | 14652.467 / 14652.389 | 18 / 18 | 76 | |
+| 11-circular-pattern-flange | pass | Flange | 66758.484 / 66758.844 | 19320.589 / 19320.795 | 10 / 10 | 50 | |
+| 12-mirror-feature | pass | Base | 21392.261 / 21392.920 | 6530.917 / 6530.973 | 10 / 10 | 7 | |
+| 13-combine-join | pass | A | 45547.074 / 45571.680 | 8633.463 / 8634.336 | 9 / 9 | 5 | |
+| 14-combine-cut | pass | A | 42934.678 / 42931.417 | 9706.604 / 9706.858 | 7 / 7 | 61 | |
+| 15-combine-intersect | pass | A | 54442.787 / 54454.273 | 7381.985 / 7382.743 | 7 / 7 | 134 | |
+| 16-sweep | pass | Tube | 2584.167 / 2584.724 | 1779.580 / 1779.698 | 5 / 5 | 304 | |
+| 17-loft | pass | Loft | 35124.785 / 35125.498 | 6496.433 / 6495.000 | 6 / 6 | 148 | |
+| 18-hole-features | pass | Plate | 33890.986 / 33890.710 | 8568.685 / 8568.696 | 13 / 13 | 63 | |
+| 19-l-bracket-constrained | pass | LBracket | 14720.000 / 14720.000 | 5472.000 / 5472.000 | 8 / 8 | 1 | |
+| 20-slot-constrained | pass | Slot | 2965.374 / 2965.487 | 1774.635 / 1774.690 | 6 / 6 | 17 | |
+| 21-draft | pass | Box | 54574.737 / 54574.737 | 8781.998 / 8781.998 | 6 / 6 | 1 | |
+| 22-split-body | pass | Cyl, Cyl (1) | 75380.935 / 75398.224 | 12954.433 / 12955.175 | 6 / 6 | 31 | |
+| 23-bracket-multifeature | pass | Bracket | 59331.560 / 59331.129 | 18290.761 / 18290.737 | 19 / 19 | 74 | |
+| 24-user-parameters | pass | Block | 34822.124 / 34821.903 | 8114.167 / 8114.159 | 7 / 7 | 23 | |
+| 25-sketch-triangle | pass | Triangle | 4032.155 / 4032.155 | 2274.099 / 2274.099 | 5 / 5 | 1 | |
+| 26-sketch-belt | pass | Belt | 11326.051 / 11326.170 | 5637.346 / 5637.404 | 7 / 7 | 27 | |
+| 27-sketch-trapezoid | pass | Trapezoid | 5342.311 / 5342.257 | 3066.959 / 3066.946 | 8 / 8 | 23 | |
+| 28-blind-pocket-fillets | pass | Block | 84299.400 / 84299.249 | 16279.542 / 16279.572 | 23 / 23 | 72 | |
+| 29-two-sided-and-partial-revolve | pass | Block | 25731.359 / 25731.307 | 6312.589 / 6312.602 | 12 / 12 | 14 | |
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index 1e03cd3cbd..d1b190e8f6 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -21,6 +21,9 @@ commands:
xtask/data/fusion-catalog.tsv from plan/fusion/menu-tree.json)
oracle replay plan/fusion/oracle/*/recipe.json and compare with measure.json;
writes docs/oracle.md
+ step-corpus [DIR]
+ import every DIR/*/part.step (default plan/fusion/oracle) and compare
+ with measure.json; writes docs/step-import.md
wasm cargo check every library crate and the web app for wasm32-unknown-unknown
ci fmt --check, clippy -D warnings, test, assets, layers, wasm (stops at first failure)
";
@@ -33,6 +36,7 @@ fn main() -> ExitCode {
Some("assets") => assets::run(&root()),
Some("parity") => parity::run(&root(), rest.contains(&"--refresh")),
Some("oracle") => cmd_oracle(),
+ Some("step-corpus") => cmd_step_corpus(rest.first().copied()),
Some("ci") => cmd_ci(),
Some("wasm") => cmd_wasm(),
Some("-h" | "--help" | "help") | None => {
@@ -180,6 +184,81 @@ fn cmd_wasm() -> Result<(), String> {
Ok(())
}
+/// Import every oracle STEP file (exported by Fusion) and compare with Fusion's measurements;
+/// write docs/step-import.md.
+fn cmd_step_corpus(dir: Option<&str>) -> Result<(), String> {
+ let dir = dir.map(PathBuf::from).unwrap_or_else(|| root().join("plan/fusion/oracle"));
+ let mut cases: Vec<PathBuf> = std::fs::read_dir(&dir)
+ .map_err(|e| format!("{}: {e} (the oracle data is local, in plan/fusion/oracle)", dir.display()))?
+ .flatten()
+ .map(|e| e.path())
+ .filter(|p| p.join("part.step").is_file() && p.join("measure.json").is_file())
+ .collect();
+ cases.sort();
+ if cases.is_empty() {
+ return Err(format!("no cases with part.step and measure.json in {}", dir.display()));
+ }
+ let mut cmd = cargo();
+ cmd.args(["run", "-q", "--release", "-p", "solvecraft-cli", "--", "step-corpus", "--json"]);
+ for c in &cases {
+ cmd.arg(c);
+ }
+ let out = cmd.output().map_err(|e| format!("solvecraft-cli: {e}"))?;
+ let results: serde_json::Value =
+ serde_json::from_slice(&out.stdout).map_err(|e| format!("step-corpus JSON: {e}\n{}", String::from_utf8_lossy(&out.stderr)))?;
+ let list = results.as_array().cloned().unwrap_or_default();
+ let pass = list.iter().filter(|r| r["pass"].as_bool().unwrap_or(false)).count();
+ let check =
+ |r: &serde_json::Value, name: &str| r["checks"].as_array().and_then(|c| c.iter().find(|c| c["check"] == name).cloned()).unwrap_or_default();
+ let num = |v: &serde_json::Value| v.as_f64().map(|x| format!("{x:.3}")).unwrap_or_else(|| "–".into());
+ let mut md = format!(
+ "# STEP import\n\n\
+SolveCraft reads STEP (ISO 10303-21; AP203, AP214 and AP242 geometry) with its own reader in `crates/kernel/src/step_in` \
+(written from the public standards; no third-party STEP code). A STEP file becomes an **Import** base feature on the \
+timeline: it holds the file's B-rep (the STEP text is kept in the design, so the design reopens without the file) and \
+later features — fillets, holes, cuts sketched on its faces, shells — build on its bodies.\n\n\
+- **Open**: File → Open (`doc.open`) accepts `.step`/`.stp` in any case and starts a new design; `solvecraft part.step`; \
+`solvecraft-cli eval part.step`, `solvecraft-cli run script.json --in part.step`; the MCP `open` tool.\n\
+- **Insert** into the current design: File → Insert STEP… or SOLID → INSERT (`FusionImportCommandFromToolbar {{path}}`).\n\
+- **Drag and drop** a STEP file on the window: inserted when the design has features, opened otherwise.\n\n\
+Read: manifold solid breps (with voids), faceted breps, shell-based surface models; planes, cylinders, cones, spheres, \
+tori, B-spline and rational B-spline surfaces (with knots, Bézier, uniform, quasi-uniform), surfaces of revolution and \
+linear extrusion, trimmed surfaces; lines, circles, ellipses, B-spline curves, polylines, trimmed/surface/seam curves; \
+length and angle units (SI prefixes, conversion-based units such as inches); product names (body names come from the \
+solid's name, else the product's); surface colours; assemblies (next-assembly-usage occurrences placed by item-defined \
+transformations, and mapped items) — the product tree is kept in the feature for the components milestone. Files are \
+untrusted: sizes, entity counts and nesting are capped and every kernel call is guarded. What cannot be read becomes a \
+warning on the feature (a face left out gives an open body); not read yet: offset surfaces, pcurve-only edges.\n\n\
+## Fusion corpus\n\nGenerated by `cargo xtask step-corpus`. Each case is a part exported from Fusion as STEP (AP214; kept locally in `plan/fusion/oracle/`, never committed). SolveCraft opens `part.step` exactly as File → Open does (an Import base feature) and compares with Fusion's own measurements: body count, volume and area (relative tolerance 1e-3) and the number of faces read from the file.\n\n**{pass} / {} files pass.**\n\n| Case | Result | Bodies | Volume mm³ (got / Fusion) | Area mm² (got / Fusion) | Faces (got / Fusion) | ms | Notes |\n|---|---|---|---|---|---|---|---|\n",
+ list.len()
+ );
+ for r in &list {
+ let status = if r["pass"].as_bool().unwrap_or(false) { "pass" } else { "FAIL" };
+ let (v, a, f) = (check(r, "volume_mm3"), check(r, "area_mm2"), check(r, "faces"));
+ let bodies: Vec<String> = r["bodies"].as_array().into_iter().flatten().filter_map(|b| b.as_str().map(str::to_string)).collect();
+ let mut notes: Vec<String> = r["warnings"].as_array().into_iter().flatten().filter_map(|w| w.as_str().map(|w| w.replace('|', "/"))).collect();
+ if let Some(e) = r["error"].as_str() {
+ notes.push(e.replace('|', "/"));
+ }
+ md += &format!(
+ "| {} | {status} | {} | {} / {} | {} / {} | {} / {} | {:.0} | {} |\n",
+ r["case"].as_str().unwrap_or(""),
+ bodies.join(", "),
+ num(&v["got"]),
+ num(&v["want"]),
+ num(&a["got"]),
+ num(&a["want"]),
+ f["got"].as_f64().map(|x| format!("{x}")).unwrap_or_else(|| "–".into()),
+ f["want"].as_f64().map(|x| format!("{x}")).unwrap_or_else(|| "–".into()),
+ r["ms"].as_f64().unwrap_or(0.0),
+ notes.join("; ")
+ );
+ }
+ std::fs::write(root().join("docs/step-import.md"), md).map_err(|e| format!("docs/step-import.md: {e}"))?;
+ println!("step-corpus: {pass}/{} files pass → docs/step-import.md", list.len());
+ if pass == list.len() { Ok(()) } else { Err(format!("{} STEP file(s) failed", list.len() - pass)) }
+}
+
fn cmd_ci() -> Result<(), String> {
let mut c = cargo();
c.args(["fmt", "--all", "--", "--check"]);