Skip to content

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

Agents and scripts: Rib, Web, Remove and Boundary Fill describe their exact parameters and reply (#12655) (#12656)

austin62jake7f0ef575a22a
diff --git a/crates/engine/src/cmd/features_more.rs b/crates/engine/src/cmd/features_more.rs
index b23dae96cc..f300e0a2b6 100644
--- a/crates/engine/src/cmd/features_more.rs
+++ b/crates/engine/src/cmd/features_more.rs
@@ -13,25 +13,42 @@ use super::features::{
add_feature, axis_dir_param, check_expr, feature_sketch, length_operands, plane_param, point_param, profiles, typed_length_unit,
};
use crate::params::{bad, bool_, expr, req_expr, str_, string_list, vec3};
+use crate::schema::features::FeatureResult;
+use crate::schema::features_more::{BoundaryFillParams, RemoveParams, RibParams};
+use crate::schema::{TypedContract, output_schema_for};
use crate::{Result, Session};
+/// Rib and Web take the same keys.
+const RIB_CONTRACT: TypedContract<RibParams> = TypedContract::new();
+const REMOVE_CONTRACT: TypedContract<RemoveParams> = TypedContract::new();
+const BOUNDARY_FILL_CONTRACT: TypedContract<BoundaryFillParams> = TypedContract::new();
+
pub static COMMANDS: &[CommandSpec] = &[
- CommandSpec::new("solid.boundary_fill", "Boundary Fill", boundary_fill).at("SOLID", "CREATE").icon("boundary_fill").params(
- "tools: [bodies]; cells: [[x,y,z] a point inside each cell to fill (a cell: inside some tools, outside the rest)]; operation?: new|join|cut|intersect; remove_tools?: bool",
- ),
+ CommandSpec::new("solid.boundary_fill", "Boundary Fill", crate::checked!("solid.boundary_fill", boundary_fill))
+ .at("SOLID", "CREATE")
+ .icon("boundary_fill")
+ .contract(&BOUNDARY_FILL_CONTRACT)
+ .output(output_schema_for::<FeatureResult>)
+ .params(
+ "tools: [bodies]; cells: [[x,y,z] a point inside each cell to fill (a cell: inside some tools, outside the rest)]; operation?: new|join|cut|intersect; remove_tools?: bool",
+ ),
CommandSpec::new("solid.coil", "Coil", coil).at("SOLID", "CREATE").icon("coil").params(
"diameter; two of revolutions (or turns), height, pitch; section_size; section?: circular|square; section_position?: inside|center|outside; \
base?: [x,y,z] (numbers in mm or length expressions; default: the origin); axis?: X|Y|Z|[x,y,z] (default Z); start_angle?; clockwise?: bool; \
sketch? (a sketch; its plane is the section plane, so its placement sets the radius and start phase), profiles? (default: all; one closed profile without holes); \
operation?, targets?, name?, body_name?",
),
- CommandSpec::new("solid.rib", "Rib", rib)
+ CommandSpec::new("solid.rib", "Rib", crate::checked!("solid.rib", rib))
.at("SOLID", "CREATE")
.icon("rib")
+ .contract(&RIB_CONTRACT)
+ .output(output_schema_for::<FeatureResult>)
.params("sketch, curves: [open curve ids, in order]; thickness (across the sketch plane, or across the curves when normal); depth? (default: to the next face); flip?: bool (fill to the other side); direction?: in_plane|normal (grow across the sketch plane, the default, or along its normal)"),
- CommandSpec::new("solid.web", "Web", web)
+ CommandSpec::new("solid.web", "Web", crate::checked!("solid.web", web))
.at("SOLID", "CREATE")
.icon("web")
+ .contract(&RIB_CONTRACT)
+ .output(output_schema_for::<FeatureResult>)
.params("sketch, curves: [open curve ids] (one wall each); thickness; depth? (default: to the next face); flip?: bool; direction?: in_plane|normal"),
CommandSpec::new("solid.emboss", "Emboss", emboss)
.at("SOLID", "CREATE")
@@ -45,7 +62,12 @@ pub static COMMANDS: &[CommandSpec] = &[
.at("SOLID", "MODIFY")
.icon("align")
.params("bodies: [names]; from: [x,y,z] | \"origin\" | {snap: vertex|edge_mid|face_center|circle_center, at: [x,y,z]} | from_face: [x,y,z] | from_plane: XY|XZ|YZ|construction or offset plane name or id|{origin, normal}; to: (the same) | to_face: [x,y,z] | to_plane: (a plane as from_plane; the point or face goes onto it along its normal, and the plane may move later: the bodies follow); from_frame / to_frame: a frame found again whenever the design changes, so the bodies follow it, in place of that side's point, face or plane: a joint origin as joint.create takes one ({face|circle|edge|point: [x,y,z]}, a face's name, a named joint origin) or {sketch, point|curve} (a sketch point, or a circle's, arc's or ellipse's centre, z along the sketch's normal), on the bodies' own component; faces, planes and frames also turn to meet; flip?: bool; axes?: [x, y, z] (point-to-point only: which world axes the offset moves along; default all three, at least one true); angle?: expr (a turn about the target's direction after the move)"),
- CommandSpec::new("solid.remove", "Remove", remove).at("SOLID", "MODIFY").icon("delete").params("bodies: [names] (removed from here on in the timeline)"),
+ CommandSpec::new("solid.remove", "Remove", crate::checked!("solid.remove", remove))
+ .at("SOLID", "MODIFY")
+ .icon("delete")
+ .contract(&REMOVE_CONTRACT)
+ .output(output_schema_for::<FeatureResult>)
+ .params("bodies: [names] (removed from here on in the timeline)"),
];
fn coil(s: &mut Session, p: &Value) -> Result<Value> {
diff --git a/crates/engine/src/schema/features_more.rs b/crates/engine/src/schema/features_more.rs
new file mode 100644
index 0000000000..23312cc7e1
--- /dev/null
+++ b/crates/engine/src/schema/features_more.rs
@@ -0,0 +1,201 @@
+//! Contracts for four commands in `cmd/features_more.rs` (#12655): Rib, Web, Remove and Boundary
+//! Fill. Each adds a feature and returns `add_feature`'s reply, a
+//! [`super::features::FeatureResult`].
+//!
+//! The handlers read their parameters from the raw JSON, so each key here reads as its handler
+//! reads it and fails with the handler's message. Whether a sketch, a curve or a body exists, and
+//! whether a value evaluates and fits the part, stay the handlers' to check. Where a handler
+//! ignores a key of the wrong type (a `flip` that isn't true or false, an item of `cells` that
+//! isn't a point, which Boundary Fill skips), the contract refuses it.
+
+use std::borrow::Cow;
+
+use schemars::{JsonSchema, Schema, SchemaGenerator, json_schema};
+use serde::de::Error as _;
+use serde::{Deserialize, Deserializer};
+use serde_json::Value;
+
+use super::check::whole;
+use super::config::NameList;
+use super::motion::require;
+use super::types::{FeatureCommon, IdOrName, LengthExpr, OperationParam, Point3, RibDirectionParam, TouchingParam, feature_common, present};
+use crate::params::{self, MAX_STRING_LIST};
+
+/// The most curves a rib or web follows, and the most cells Boundary Fill fills, as
+/// `cmd/features_more.rs` reads them.
+const MAX_CURVES: usize = 1000;
+const MAX_CELLS: usize = 1000;
+/// The most tool bodies Boundary Fill takes.
+const MAX_TOOLS: usize = 64;
+
+/// A list of names read as `params::string_list` reads it (through [`NameList`], with its
+/// messages), then held to `range` items with the handler's whole `message` for any other count.
+/// `string_list` reads `null` as no names, so `null` gets that message too.
+fn names_in<'de, D: Deserializer<'de>>(d: D, range: std::ops::RangeInclusive<usize>, message: &str) -> Result<Option<NameList>, D::Error> {
+ let v = Value::deserialize(d)?;
+ let names = if v.is_null() { NameList::default() } else { NameList::deserialize(v).map_err(D::Error::custom)? };
+ if range.contains(&names.0.len()) { Ok(Some(names)) } else { Err(D::Error::custom(whole(message))) }
+}
+
+/// A list of 1 to `max` names: one name as text, or a list.
+fn names_schema(description: &str, max: usize) -> Schema {
+ json_schema!({
+ "description": description,
+ "anyOf": [{"type": "string"}, {"type": "array", "items": {"type": "string"}, "minItems": 1, "maxItems": max}]
+ })
+}
+
+/// Rib's and Web's `curves`: 1 to 1000 sketch curve ids.
+fn rib_curves<'de, D: Deserializer<'de>>(d: D) -> Result<Option<NameList>, D::Error> {
+ names_in(d, 1..=MAX_CURVES, "`curves` must list 1…1000 sketch curve ids")
+}
+
+fn rib_curves_schema(_: &mut SchemaGenerator) -> Schema {
+ names_schema("The sketch's open curves, by id: 1 to 1000.", MAX_CURVES)
+}
+
+fn curves_required(schema: &mut Schema) {
+ require(schema, "curves");
+}
+
+/// Add a rib or a web, thin walls from open sketch curves grown until they meet the part. A rib
+/// (`solid.rib`) is one wall along a chain of curves, in order; a web (`solid.web`) is one wall
+/// along each curve. It joins the part. One undo step.
+#[derive(Debug, Deserialize, JsonSchema)]
+#[schemars(deny_unknown_fields, transform = curves_required)]
+pub struct RibParams {
+ /// The sketch, by id or name. Default: the active sketch, else the last one.
+ #[serde(default, deserialize_with = "present")]
+ #[schemars(with = "IdOrName")]
+ pub sketch: Option<IdOrName>,
+ // Optional in the type, required in the schema: left out, `null` or empty, the handler
+ // refuses the call with its own message.
+ #[serde(default, deserialize_with = "rib_curves")]
+ #[schemars(schema_with = "rib_curves_schema")]
+ pub curves: Option<NameList>,
+ /// The wall's thickness: across the sketch plane, or across the curves with `direction:
+ /// normal`.
+ pub thickness: LengthExpr,
+ /// How far the wall grows. Default: until it meets the part.
+ #[serde(default)]
+ pub depth: Option<LengthExpr>,
+ /// True: the wall grows to the other side of the curves. Default: false.
+ #[serde(default)]
+ pub flip: Option<bool>,
+ #[serde(default)]
+ pub direction: Option<RibDirectionParam>,
+ /// What the join makes of pieces that share no face. Default: separate.
+ #[serde(default)]
+ pub touching: Option<TouchingParam>,
+ #[serde(flatten, deserialize_with = "feature_common")]
+ pub common: FeatureCommon,
+}
+
+/// Remove's `bodies`: 1 to 10 000 names.
+fn remove_bodies<'de, D: Deserializer<'de>>(d: D) -> Result<Option<NameList>, D::Error> {
+ names_in(d, 1..=MAX_STRING_LIST, "`bodies` must list bodies")
+}
+
+fn remove_bodies_schema(_: &mut SchemaGenerator) -> Schema {
+ names_schema("The bodies, by name: one, or a list of 1 to 10 000.", MAX_STRING_LIST)
+}
+
+fn bodies_required(schema: &mut Schema) {
+ require(schema, "bodies");
+}
+
+/// Remove bodies from the design, from this point in the timeline on. One undo step.
+#[derive(Debug, Deserialize, JsonSchema)]
+#[schemars(deny_unknown_fields, transform = bodies_required)]
+pub struct RemoveParams {
+ // Required in the schema (`bodies_required`), optional in the type, as Rib's `curves`.
+ #[serde(default, deserialize_with = "remove_bodies")]
+ #[schemars(schema_with = "remove_bodies_schema")]
+ pub bodies: Option<NameList>,
+ #[serde(flatten, deserialize_with = "feature_common")]
+ pub common: FeatureCommon,
+}
+
+/// The handler's messages for Boundary Fill's `tools` and `cells`.
+const TOOLS_MESSAGE: &str = "`tools` must list 1…64 bodies";
+const CELLS_MESSAGE: &str = "`cells` must list 1…1000 points [x, y, z], one inside each cell";
+
+/// Boundary Fill's `tools`: 1 to 64 body names.
+fn fill_tools<'de, D: Deserializer<'de>>(d: D) -> Result<Option<NameList>, D::Error> {
+ names_in(d, 1..=MAX_TOOLS, TOOLS_MESSAGE)
+}
+
+fn fill_tools_schema(_: &mut SchemaGenerator) -> Schema {
+ names_schema("The tool bodies whose surfaces bound the cells, by name: 1 to 64.", MAX_TOOLS)
+}
+
+/// Boundary Fill's `cells`: 1 to 1000 points, each inside one cell to fill. The handler skips an
+/// item that isn't a point and refuses the call only when none is left; the contract refuses
+/// any such item.
+#[derive(Clone, Debug, PartialEq)]
+pub struct FillCells(pub Vec<Value>);
+
+impl<'de> Deserialize<'de> for FillCells {
+ fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
+ match Value::deserialize(d)? {
+ Value::Array(points) if (1..=MAX_CELLS).contains(&points.len()) && points.iter().all(|p| params::vec3(p).is_some()) => {
+ Ok(FillCells(points))
+ }
+ _ => Err(D::Error::custom(whole(CELLS_MESSAGE))),
+ }
+ }
+}
+
+impl JsonSchema for FillCells {
+ fn schema_name() -> Cow<'static, str> {
+ "FillCells".into()
+ }
+ fn inline_schema() -> bool {
+ true
+ }
+ fn json_schema(generator: &mut SchemaGenerator) -> Schema {
+ json_schema!({
+ "description": "A point inside each cell to fill, 1 to 1000. A cell is a region inside some of the tools and outside the rest.",
+ "type": "array",
+ "items": generator.subschema_for::<Point3>(),
+ "minItems": 1,
+ "maxItems": MAX_CELLS
+ })
+ }
+}
+
+fn tools_and_cells_required(schema: &mut Schema) {
+ require(schema, "tools");
+ require(schema, "cells");
+}
+
+/// Add a solid made of the cells that tool bodies enclose, each picked by a point inside it, and
+/// combine it with the design's bodies. One undo step.
+#[derive(Debug, Deserialize, JsonSchema)]
+#[schemars(deny_unknown_fields, transform = tools_and_cells_required)]
+pub struct BoundaryFillParams {
+ // Required in the schema (`tools_and_cells_required`), optional in the type: left out, the
+ // handler refuses the call with its own message, which the contract gives `null` and an
+ // empty list (`present`: a `null` goes to `FillCells`, which refuses it).
+ #[serde(default, deserialize_with = "fill_tools")]
+ #[schemars(schema_with = "fill_tools_schema")]
+ pub tools: Option<NameList>,
+ #[serde(default, deserialize_with = "present")]
+ #[schemars(with = "FillCells")]
+ pub cells: Option<FillCells>,
+ /// How the filled solid combines with the design's bodies. Default: new.
+ #[serde(default)]
+ pub operation: Option<OperationParam>,
+ /// True: the tool bodies are removed once the cells are filled. Default: false.
+ #[serde(default)]
+ pub remove_tools: Option<bool>,
+ /// What a join makes of pieces that share no face. Default: separate.
+ #[serde(default)]
+ pub touching: Option<TouchingParam>,
+ #[serde(flatten, deserialize_with = "feature_common")]
+ pub common: FeatureCommon,
+}
+
+#[cfg(test)]
+#[path = "features_more_tests.rs"]
+mod tests;
diff --git a/crates/engine/src/schema/features_more_tests.rs b/crates/engine/src/schema/features_more_tests.rs
new file mode 100644
index 0000000000..0b60e2526c
--- /dev/null
+++ b/crates/engine/src/schema/features_more_tests.rs
@@ -0,0 +1,251 @@
+use serde_json::{Value, json};
+
+use super::{BoundaryFillParams, RemoveParams, RibParams};
+use crate::Session;
+use crate::schema::features::FeatureResult;
+use crate::schema::tests::{assert_keys, assert_strict_keeps_todays_errors, conforms};
+use crate::schema::{ParamCheck, input_schema_for, output_schema_for};
+
+fn session(level: ParamCheck, calls: &[(&str, Value)]) -> Session {
+ let mut s = Session { param_check: level, ..Session::default() };
+ for (id, p) in calls {
+ s.execute(id, p).unwrap_or_else(|e| panic!("{id} {p}: {e}"));
+ }
+ s
+}
+
+/// An L bracket, `L` (a 40 × 20 × 5 base and a 5 × 20 × 40 wall), and `RibSketch` on its middle
+/// plane with one line, `l1`, across the inside corner: a rib or web there fills a triangle.
+fn bracket(level: ParamCheck) -> Session {
+ session(
+ level,
+ &[
+ ("solid.box", json!({"length": 40, "width": 20, "height": 5, "corner": [0, 0, 0], "body_name": "L"})),
+ ("solid.box", json!({"length": 5, "width": 20, "height": 40, "corner": [0, 0, 0], "operation": "join"})),
+ ("sketch.create", json!({"plane": {"origin": [0, 10, 0], "x_dir": [1, 0, 0], "y_dir": [0, 0, 1]}, "name": "RibSketch"})),
+ ("sketch.line", json!({"points": [[5, 25], [25, 5]], "ids": ["l1"]})),
+ ("sketch.finish", json!({})),
+ ],
+ )
+}
+
+/// Two 20 mm cubes, `A` and `B`, overlapping where 10 ≤ x ≤ 20.
+fn boxes(level: ParamCheck) -> Session {
+ session(
+ level,
+ &[
+ ("solid.box", json!({"length": 20, "width": 20, "height": 20, "body_name": "A"})),
+ ("solid.box", json!({"corner": [10, 0, 0], "length": 20, "width": 20, "height": 20, "body_name": "B"})),
+ ],
+ )
+}
+
+fn rib() -> Value {
+ json!({"sketch": "RibSketch", "curves": ["l1"], "thickness": 4})
+}
+
+/// `base` with `key` set to `value`.
+fn with(base: &Value, key: &str, value: Value) -> Value {
+ let mut p = base.clone();
+ p[key] = value;
+ p
+}
+
+#[test]
+fn schemas_and_the_key_check_agree() {
+ assert_keys(
+ input_schema_for::<RibParams>(),
+ &["body_name", "body_names", "curves", "depth", "direction", "flip", "name", "participants", "sketch", "thickness", "touching"],
+ );
+ assert_keys(input_schema_for::<RemoveParams>(), &["bodies", "body_name", "body_names", "name", "participants"]);
+ assert_keys(
+ input_schema_for::<BoundaryFillParams>(),
+ &["body_name", "body_names", "cells", "name", "operation", "participants", "remove_tools", "tools", "touching"],
+ );
+}
+
+/// As `assert_strict_keeps_todays_errors`, on the design `fixture` makes: for the calls that need
+/// the sketch's curve or the bodies to get past the handler's first checks.
+fn assert_strict_keeps_errors_on(fixture: fn(ParamCheck) -> Session, cases: &[(&str, Value)]) {
+ for (id, p) in cases {
+ let off = fixture(ParamCheck::Off).execute(id, p).err().map(|e| e.to_string());
+ assert!(off.is_some(), "{id} {p} should fail today");
+ assert_eq!(fixture(ParamCheck::Strict).execute(id, p).err().map(|e| e.to_string()), off, "{id} {p}");
+ }
+}
+
+/// #12655: a `null` or empty `curves`, `bodies`, `tools` or `cells`, which the handlers refuse,
+/// is refused by the contracts too, with the handlers' messages. So the check (warn, strict, MCP
+/// validation, batch preflight) catches it before the handler runs. Only a key left out goes on
+/// to the handler, for its own message.
+#[test]
+fn the_contracts_refuse_null_and_empty_where_the_handlers_do() {
+ let curves = "`curves` must list 1…1000 sketch curve ids";
+ let cells = "`cells` must list 1…1000 points [x, y, z], one inside each cell";
+ for (id, p, message) in [
+ ("solid.rib", json!({"curves": null, "thickness": 1}), curves),
+ ("solid.web", json!({"curves": [], "thickness": 1}), curves),
+ ("solid.remove", json!({"bodies": null}), "`bodies` must list bodies"),
+ ("solid.remove", json!({"bodies": []}), "`bodies` must list bodies"),
+ ("solid.boundary_fill", json!({"tools": null, "cells": [[1, 2, 3]]}), "`tools` must list 1…64 bodies"),
+ ("solid.boundary_fill", json!({"tools": ["A"], "cells": null}), cells),
+ ("solid.boundary_fill", json!({"tools": ["A"], "cells": []}), cells),
+ ] {
+ let messages: Vec<String> = crate::schema::issues(id, &p).into_iter().map(|i| i.message).collect();
+ assert_eq!(messages, [message], "{id} {p}");
+ }
+ for (id, p) in [("solid.rib", json!({"thickness": 1})), ("solid.remove", json!({})), ("solid.boundary_fill", json!({}))] {
+ assert!(crate::schema::issues(id, &p).is_empty(), "{id} {p}: left out, the handler refuses it");
+ }
+}
+
+/// #12655: calls that fail today get the same message in strict. The first ones fail on the
+/// shared helper's sketch; the rest need the bracket's curve or the two boxes.
+#[test]
+fn strict_keeps_todays_errors() {
+ let many_curves = vec!["l1"; 1001];
+ let many_tools: Vec<String> = (0..65).map(|i| format!("T{i}")).collect();
+ assert_strict_keeps_todays_errors(&[
+ ("solid.rib", json!({"curves": null, "thickness": 1})),
+ ("solid.rib", json!({"curves": [], "thickness": 1})),
+ ("solid.rib", json!({"curves": 5, "thickness": 1})),
+ ("solid.rib", json!({"curves": ["l1", 5], "thickness": 1})),
+ ("solid.rib", json!({"curves": many_curves, "thickness": 1})),
+ ("solid.rib", json!({"curves": ["nope"], "thickness": 1})),
+ ("solid.rib", json!({"sketch": true, "curves": ["l1"], "thickness": 1})),
+ ("solid.rib", json!({"sketch": "Nope", "curves": ["l1"], "thickness": 1})),
+ ("solid.web", json!({"curves": [], "thickness": 1})),
+ ("solid.remove", json!({})),
+ ("solid.remove", json!({"bodies": null})),
+ ("solid.remove", json!({"bodies": []})),
+ ("solid.remove", json!({"bodies": 5})),
+ ("solid.remove", json!({"bodies": ["Nope"]})),
+ ("solid.boundary_fill", json!({})),
+ ("solid.boundary_fill", json!({"tools": null, "cells": [[5, 5, 5]]})),
+ ("solid.boundary_fill", json!({"tools": [], "cells": [[5, 5, 5]]})),
+ ("solid.boundary_fill", json!({"tools": many_tools, "cells": [[5, 5, 5]]})),
+ ("solid.boundary_fill", json!({"tools": ["A"], "cells": [[5, 5, 5]]})),
+ ]);
+ assert_strict_keeps_errors_on(
+ bracket,
+ &[
+ ("solid.rib", with(&rib(), "thickness", json!(null))),
+ ("solid.rib", with(&rib(), "thickness", json!("nope"))),
+ ("solid.rib", with(&rib(), "depth", json!("2 deg"))),
+ ("solid.rib", with(&rib(), "direction", json!("sideways"))),
+ ("solid.web", with(&rib(), "direction", json!("SIDEWAYS"))),
+ ],
+ );
+ let many_cells = vec![[5, 5, 5]; 1001];
+ assert_strict_keeps_errors_on(
+ boxes,
+ &[
+ ("solid.boundary_fill", json!({"tools": ["A"]})),
+ ("solid.boundary_fill", json!({"tools": ["A"], "cells": null})),
+ ("solid.boundary_fill", json!({"tools": ["A"], "cells": []})),
+ ("solid.boundary_fill", json!({"tools": ["A"], "cells": ["x"]})),
+ ("solid.boundary_fill", json!({"tools": ["A"], "cells": many_cells})),
+ ("solid.boundary_fill", json!({"tools": ["A"], "cells": [[5, 5, 5]], "operation": "glue"})),
+ ],
+ );
+}
+
+/// #12655: keys of the wrong type that the handlers ignore today (an item of `cells` that isn't a
+/// point is skipped; a `flip` or `remove_tools` that isn't true or false is read as false) are
+/// refused by the contracts: in Warn the call still works, with a warning naming the key.
+#[test]
+fn the_contracts_refuse_what_the_handlers_ignore() {
+ let fill = json!({"tools": ["A", "B"], "cells": [[15, 10, 10]]});
+ let cases: Vec<(fn(ParamCheck) -> Session, &str, Value, &str)> = vec![
+ (bracket, "solid.rib", with(&rib(), "flip", json!("yes")), "flip"),
+ (bracket, "solid.rib", with(&rib(), "depth", json!(true)), "depth"),
+ (bracket, "solid.web", with(&rib(), "direction", json!(5)), "direction"),
+ (boxes, "solid.boundary_fill", with(&fill, "cells", json!([[15, 10, 10], "x"])), "cells"),
+ (boxes, "solid.boundary_fill", with(&fill, "remove_tools", json!("yes")), "remove_tools"),
+ (boxes, "solid.boundary_fill", with(&fill, "operation", json!(5)), "operation"),
+ ];
+ for (fixture, id, p, key) in cases {
+ assert!(fixture(ParamCheck::Off).execute(id, &p).is_ok(), "{id} {p} works today");
+ let warned = fixture(ParamCheck::Warn).execute(id, &p).unwrap_or_else(|e| panic!("{id} {p}: {e}"));
+ assert!(warned["param_warnings"].to_string().contains(key), "{warned}");
+ let error = fixture(ParamCheck::Strict).execute(id, &p).err().map(|e| e.to_string()).unwrap_or_default();
+ assert!(error.contains(&format!("`{key}`")), "{id} {p}: {error}");
+ }
+}
+
+/// #12655: the schemas take what the handlers take. Each call is checked against both the schema
+/// and the handler, with the check off, so the two can't drift apart.
+#[test]
+fn the_schemas_take_what_the_handlers_take() {
+ let agree = |fixture: fn(ParamCheck) -> Session, id: &str, schema: schemars::Schema, calls: &[Value]| {
+ let schema = schema.as_value();
+ for p in calls {
+ let takes = fixture(ParamCheck::Off).execute(id, p).is_ok();
+ assert_eq!(conforms(schema, schema, p), takes, "{id} {p}");
+ }
+ };
+ agree(
+ bracket,
+ "solid.rib",
+ input_schema_for::<RibParams>(),
+ &[
+ rib(),
+ with(&rib(), "curves", json!("l1")),
+ with(&rib(), "thickness", json!("4 mm")),
+ with(&rib(), "depth", json!(2)),
+ with(&with(&rib(), "flip", json!(false)), "direction", json!("in_plane")),
+ with(&rib(), "curves", json!([])),
+ with(&rib(), "thickness", json!("")),
+ with(&rib(), "sketch", json!([1])),
+ ],
+ );
+ agree(
+ boxes,
+ "solid.boundary_fill",
+ input_schema_for::<BoundaryFillParams>(),
+ &[
+ json!({"tools": ["A", "B"], "cells": [[15, 10, 10]]}),
+ json!({"tools": ["A", "B"], "cells": [{"x": 5, "y": 10, "z": 10}, [25, 10, 10]], "remove_tools": true}),
+ json!({"tools": "A", "cells": [[5, 10, 10]], "operation": "new", "body_name": "Fill"}),
+ json!({"tools": [], "cells": [[15, 10, 10]]}),
+ json!({"tools": ["A", "B"], "cells": []}),
+ json!({"tools": ["A", "B"], "cells": [[15, 10]]}),
+ json!({"tools": ["A", "B"], "cells": [[15, 10, 10]], "operation": "glue"}),
+ ],
+ );
+ agree(
+ boxes,
+ "solid.remove",
+ input_schema_for::<RemoveParams>(),
+ &[json!({"bodies": "B"}), json!({"bodies": ["A", "B"], "name": "Gone"}), json!({"bodies": []}), json!({"bodies": [5]}), json!({})],
+ );
+}
+
+/// #12655: each command replies as a feature command does, in Warn without warnings: a rib and a
+/// web on the bracket, the two boxes' shared lens filled, and a box removed. A misspelt key is
+/// ignored today: Warn says so, and strict refuses it.
+#[test]
+fn the_features_reply_with_their_schemas() {
+ let schema = output_schema_for::<FeatureResult>();
+ let schema = schema.as_value();
+ let check = |s: &mut Session, id: &str, p: Value| {
+ let r = s.execute(id, &p).unwrap_or_else(|e| panic!("{id} {p}: {e}"));
+ assert!(conforms(schema, schema, &r), "{r} doesn't match {schema}");
+ assert!(r.get("param_warnings").is_none(), "{r}");
+ r
+ };
+ let r = check(&mut bracket(ParamCheck::Warn), "solid.rib", with(&rib(), "name", json!("Brace")));
+ assert_eq!((&r["name"], &r["changed_bodies"]), (&json!("Brace"), &json!(["L"])), "{r}");
+ check(&mut bracket(ParamCheck::Warn), "solid.web", rib());
+ let mut s = boxes(ParamCheck::Warn);
+ let r = check(&mut s, "solid.boundary_fill", json!({"tools": ["A", "B"], "cells": [[15, 10, 10]], "body_name": "Lens"}));
+ assert_eq!(r["created_bodies"], json!(["Lens"]), "{r}");
+ let r = check(&mut s, "solid.remove", json!({"bodies": "Lens"}));
+ assert_eq!(r["removed_bodies"], json!(["Lens"]), "{r}");
+ // A misspelt key.
+ let p = with(&rib(), "flp", json!(true));
+ let r = bracket(ParamCheck::Warn).execute("solid.rib", &p).unwrap_or_else(|e| panic!("{p}: {e}"));
+ assert!(r["param_warnings"].to_string().contains("flp"), "{r}");
+ let error = bracket(ParamCheck::Strict).execute("solid.rib", &p).err().map(|e| e.to_string()).unwrap_or_default();
+ assert!(error.contains("`flp`"), "{error}");
+}
diff --git a/crates/engine/src/schema/mod.rs b/crates/engine/src/schema/mod.rs
index 300bcbee5e..91339b480d 100644
--- a/crates/engine/src/schema/mod.rs
+++ b/crates/engine/src/schema/mod.rs
@@ -67,6 +67,7 @@ pub mod construct;
pub mod diagnostics;
pub mod edit;
pub mod features;
+pub mod features_more;
pub mod file;
pub mod inspect;
pub mod joints;
diff --git a/crates/engine/src/schema/types.rs b/crates/engine/src/schema/types.rs
index b0c50cad40..6abb3bf331 100644
--- a/crates/engine/src/schema/types.rs
+++ b/crates/engine/src/schema/types.rs
@@ -491,6 +491,14 @@ macro_rules! keyword_param {
};
}
+keyword_param!(
+ /// `solid.rib`'s and `solid.web`'s `direction`.
+ RibDirectionParam,
+ "direction",
+ &["in_plane", "plane", "normal"],
+ "in_plane or normal",
+ "Which way the wall grows from the curves: in_plane (the default; plane is an alias), across the sketch plane, or normal, along the sketch plane's normal. Matching ignores case."
+);
keyword_param!(
/// `solid.fillet`'s `type`.
FilletTypeParam,
diff --git a/crates/engine/src/schema/unconverted.txt b/crates/engine/src/schema/unconverted.txt
index f88ee6f1f3..220047baf2 100644
--- a/crates/engine/src/schema/unconverted.txt
+++ b/crates/engine/src/schema/unconverted.txt
@@ -213,7 +213,6 @@ sketch.toggle_driven
sketch.trim
sketch.trim.path
solid.align
-solid.boundary_fill
solid.chamfer
solid.coil
solid.combine
@@ -228,16 +227,13 @@ solid.pattern.circular
solid.pattern.path
solid.pattern.rectangular
solid.press_pull
-solid.remove
solid.replace_face
solid.revolve
-solid.rib
solid.shell
solid.split_body
solid.split_face
solid.sweep
solid.thread
-solid.web
surface.blend
surface.extend
surface.extrude