Skip to content

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

Agents and scripts: the native studio and quality profile commands describe their exact parameters and reply (#11766) (#11768)

austin62jakeeb10552c61a7
diff --git a/crates/engine/src/cmd/render.rs b/crates/engine/src/cmd/render.rs
index acbacd72b9..b0b8f12b52 100644
--- a/crates/engine/src/cmd/render.rs
+++ b/crates/engine/src/cmd/render.rs
@@ -91,11 +91,17 @@ pub static COMMANDS: &[CommandSpec] = &[
.params("No parameters. Returns the explicitly defined current view camera, or null if the session has no camera override. No camera is fitted, no job is started and no saved setup or engineering document is changed."),
CommandSpec::new("render.camera.fit", "Frame Render Subject", fit_camera).icon("camera").noundo()
.params("aspect?: the picture's width over its height, 0.000001 to 1000000 (default 1). Fits the current camera to the visible product bounds through the shared Camera::fit contract, moving back for a picture taller than wide so its sides hold the product too; changes only view state, not a saved setup, rendering job, stage or engineering geometry."),
-CommandSpec::new("render.preset.resolve", "Review Native Studio", studio_presets::resolve).icon("render_scene").noundo()
+CommandSpec::new("render.preset.resolve", "Review Native Studio", crate::checked!("render.preset.resolve", studio_presets::resolve)).icon("render_scene").noundo()
+ .contract(&studio_presets::PRESET_CONTRACT)
+ .output(crate::schema::output_schema_for::<crate::schema::render_presets::StudioComposition>)
.params("id: NATIVE-STUDIO-001..025; name; set?: typed GPU setup patch; expected_revision?:u64. Resolves original built-in HDR/rig/passive ground with conservative geometry clearance, returns all replacements and preserved fields without mutation. Unbound SCENE-* concepts are not accepted."),
-CommandSpec::new("render.preset.apply", "Apply Native Studio", studio_presets::apply).icon("render_scene")
+CommandSpec::new("render.preset.apply", "Apply Native Studio", crate::checked!("render.preset.apply", studio_presets::apply)).icon("render_scene")
+ .contract(&studio_presets::PRESET_CONTRACT)
+ .output(crate::schema::output_schema_for::<crate::schema::render_presets::StudioComposition>)
.params("Same reviewed input as render.preset.resolve, expected_revision required, replace_lighting_and_environment:true and replace_stage:true when an existing stage would change. Re-resolves the complete candidate and publishes one undo or no mutation; camera, optical bindings, geometry and engineering materials are preserved."),
-CommandSpec::new("render.quality.prepare", "Review Fixed Sampling Budget", studio_presets::quality).icon("settings").noundo().doc_only()
+CommandSpec::new("render.quality.prepare", "Review Fixed Sampling Budget", crate::checked!("render.quality.prepare", studio_presets::quality)).icon("settings").noundo().doc_only()
+ .contract(&studio_presets::QUALITY_CONTRACT)
+ .output(crate::schema::output_schema_for::<crate::schema::render_presets::QualityPlan>)
.params("id: Q-*; variant:fixed_samples_png; acknowledge_omissions:true. Read-only bounded GPU still-budget projection, not full adaptive/convergence/linear-master quality acceptance. Returns dimensions/samples/depth/seed/denoise and explicit omissions. Never switches executor or mutates a shot."),
CommandSpec::new("render.shot.duplicate", "Duplicate Render Shot", crate::checked!("render.shot.duplicate", shots::duplicate)).icon("copy").doc_only()
.contract(&shots::CONTRACT)
diff --git a/crates/engine/src/cmd/render/studio_presets.rs b/crates/engine/src/cmd/render/studio_presets.rs
index 06ffd95f41..1995f94e34 100644
--- a/crates/engine/src/cmd/render/studio_presets.rs
+++ b/crates/engine/src/cmd/render/studio_presets.rs
@@ -1,11 +1,12 @@
//! Original native studio compositions. Independent of unbound SCENE-* concepts.
//! Resolution is read-only; publication validates a complete candidate before one undo.
+use crate::schema::TypedContract;
+use crate::schema::render_presets::{PresetParams, QualityOptions, QualityParams, QualityPlan, QualitySize, StudioComposition};
use crate::{Result, Session, params::bad};
-use serde::Deserialize;
use serde_json::{Value, json};
use solidcraft_doc::{
render_resources::GpuHdrEnvironment,
- render_settings::{RenderJob, RenderSettings, RenderSetup},
+ render_settings::{RenderJob, RenderSettings},
};
use solidcraft_render::{
job::{AreaLights, StudioLighting},
@@ -48,29 +49,16 @@ fn recipe(id: &str, command: &str) -> Result<Value> {
.and_then(|items| items.iter().find(|item| item["id"].as_str() == Some(id)).cloned())
.ok_or_else(|| bad(command, "unknown native studio identity; SCENE-* specifications are not executable compositions"))
}
-fn patch() -> Value {
- json!({})
-}
-#[derive(Deserialize)]
-#[serde(deny_unknown_fields)]
-struct Input {
- id: String,
- name: String,
- #[serde(default = "patch")]
- set: Value,
- #[serde(default)]
- expected_revision: Option<u64>,
- #[serde(default)]
- replace_lighting_and_environment: bool,
- #[serde(default)]
- replace_stage: bool,
-}
+pub(super) const PRESET_CONTRACT: TypedContract<PresetParams> = TypedContract::new();
+pub(super) const QUALITY_CONTRACT: TypedContract<QualityParams> = TypedContract::new();
+
+/// A fitted studio, checked whole but not yet saved: the settings `apply` would publish, and the
+/// report both commands return (its `setup` is the fitted setup).
struct Candidate {
settings: RenderSettings,
- setup: RenderSetup,
- report: Value,
+ report: StudioComposition,
}
-fn candidate(s: &Session, input: &Input, command: &str) -> Result<Candidate> {
+fn candidate(s: &Session, input: &PresetParams, command: &str) -> Result<Candidate> {
if input.expected_revision.is_some_and(|revision| revision != s.revision) {
return Err(bad(command, "scene or saved settings changed after review; resolve the composition again"));
}
@@ -150,49 +138,73 @@ fn candidate(s: &Session, input: &Input, command: &str) -> Result<Candidate> {
settings.resources.insert(resource).map_err(|e| bad(command, e.to_string()))?;
settings.setups.insert(input.name.clone(), setup.clone());
settings.validate().map_err(|e| bad(command, e.to_string()))?;
- let report = json!({"id":input.id,"name":input.name,"revision":s.revision,"source":source,"setup":setup,
- "resource_sha256":resource_id,"rig_projection":projection,"status":"resolved_native_projection",
- "document_changed":false,"executor":"gpu-path","requires_lighting_consent":true,"requires_stage_consent":stage_replacement,
- "replaces":["lighting","environment","passive_stage","exposure"],
- "preserves":["camera","output_dimensions","sampling","optical_bindings","geometry","engineering_materials","pose","visibility"],
- "clearance":"conservative subject/stage/emitter AABB separation; not exact contact certification",
- "limitations":["Authored relative RGB radiance, not measured photometric calibration.","No automatic material or semantic-role assignment.","This composition preserves existing sampling, master retention and medium intent; it does not certify convergence or add terrain, motion or nested-media support."]});
- Ok(Candidate { settings, setup, report })
+ let report = StudioComposition {
+ id: input.id.clone(),
+ name: input.name.clone(),
+ revision: s.revision,
+ source: source.as_object().cloned().unwrap_or_default(),
+ setup: serde_json::to_value(&setup).map_err(|e| bad(command, e.to_string()))?,
+ resource_sha256: resource_id.to_string(),
+ rig_projection: projection,
+ status: "resolved_native_projection".into(),
+ document_changed: false,
+ executor: "gpu-path".into(),
+ requires_lighting_consent: true,
+ requires_stage_consent: stage_replacement,
+ replaces: strings(&["lighting", "environment", "passive_stage", "exposure"]),
+ preserves: strings(&[
+ "camera",
+ "output_dimensions",
+ "sampling",
+ "optical_bindings",
+ "geometry",
+ "engineering_materials",
+ "pose",
+ "visibility",
+ ]),
+ clearance: "conservative subject/stage/emitter AABB separation; not exact contact certification".into(),
+ limitations: strings(&[
+ "Authored relative RGB radiance, not measured photometric calibration.",
+ "No automatic material or semantic-role assignment.",
+ "This composition preserves existing sampling, master retention and medium intent; it does not certify convergence or add terrain, motion or nested-media support.",
+ ]),
+ param_warnings: Vec::new(),
+ };
+ Ok(Candidate { settings, report })
+}
+/// The reply's fixed lists, as owned strings.
+fn strings(items: &[&str]) -> Vec<String> {
+ items.iter().map(|item| (*item).to_owned()).collect()
+}
+fn reply(command: &str, reply: impl serde::Serialize) -> Result<Value> {
+ serde_json::to_value(reply).map_err(|e| bad(command, e.to_string()))
}
pub(super) fn resolve(s: &mut Session, params: &Value) -> Result<Value> {
let command = "render.preset.resolve";
- let input: Input = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?;
- Ok(candidate(s, &input, command)?.report)
+ let input: PresetParams = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?;
+ reply(command, candidate(s, &input, command)?.report)
}
pub(super) fn apply(s: &mut Session, params: &Value) -> Result<Value> {
let command = "render.preset.apply";
- let input: Input = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?;
+ let input: PresetParams = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?;
if input.expected_revision.is_none() || !input.replace_lighting_and_environment {
return Err(bad(command, "resolve first, then supply expected_revision and explicit lighting/environment/exposure replacement consent"));
}
let mut ready = candidate(s, &input, command)?;
- if ready.report["requires_stage_consent"] == true && !input.replace_stage {
+ if ready.report.requires_stage_consent && !input.replace_stage {
return Err(bad(command, "existing stage requires explicit replace_stage consent"));
}
let changed = ready.settings != *s.doc.render;
if changed {
s.doc_mut().render = Arc::new(ready.settings);
}
- ready.report["document_changed"] = json!(changed);
- ready.report["setup"] = json!(ready.setup);
- Ok(ready.report)
+ ready.report.document_changed = changed;
+ reply(command, ready.report)
}
-#[derive(Deserialize)]
-#[serde(deny_unknown_fields)]
-struct Quality {
- id: String,
- variant: String,
- acknowledge_omissions: bool,
-}
pub(super) fn quality(s: &mut Session, params: &Value) -> Result<Value> {
let command = "render.quality.prepare";
- let input: Quality = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?;
+ let input: QualityParams = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?;
if input.variant != "fixed_samples_png" || !input.acknowledge_omissions {
return Err(bad(
command,
@@ -222,12 +234,29 @@ pub(super) fn quality(s: &mut Session, params: &Value) -> Result<Value> {
"this quality concept exceeds current fixed-sample still-image capabilities; no dimensions, samples or motion are silently reduced",
));
}
- Ok(json!({"id":input.id,"name":source["name"],"variant":input.variant,"status":"fixed_budget_projection_not_full_quality_profile",
- "revision":s.revision,"document_changed":false,"source_unchanged":true,
- "settings":{"width":width,"height":height},"gpu_options":{"samples":samples,"max_depth":depth,"seed":seed,"denoise":source["denoising"]["enabled"]},
- "preserves":["executor","camera","lighting","environment","stage","optical_bindings","exposure","tone_map"],
- "omitted":["adaptive_stopping_and_error_target","independent_transmission_depth","authored_russian_roulette_rule","preserved_raw_linear_output","EXR_master","convergence_certification"],
- "source":source}))
+ let plan = QualityPlan {
+ id: input.id,
+ name: source["name"].as_str().map(str::to_owned),
+ variant: input.variant,
+ status: "fixed_budget_projection_not_full_quality_profile".into(),
+ revision: s.revision,
+ document_changed: false,
+ source_unchanged: true,
+ settings: QualitySize { width, height },
+ gpu_options: QualityOptions { samples, max_depth: depth, seed, denoise: source["denoising"]["enabled"].as_bool() },
+ preserves: strings(&["executor", "camera", "lighting", "environment", "stage", "optical_bindings", "exposure", "tone_map"]),
+ omitted: strings(&[
+ "adaptive_stopping_and_error_target",
+ "independent_transmission_depth",
+ "authored_russian_roulette_rule",
+ "preserved_raw_linear_output",
+ "EXR_master",
+ "convergence_certification",
+ ]),
+ source: source.as_object().cloned().unwrap_or_default(),
+ param_warnings: Vec::new(),
+ };
+ reply(command, plan)
}
#[cfg(test)]
diff --git a/crates/engine/src/schema/mod.rs b/crates/engine/src/schema/mod.rs
index c62c165729..09494d6286 100644
--- a/crates/engine/src/schema/mod.rs
+++ b/crates/engine/src/schema/mod.rs
@@ -82,6 +82,7 @@ pub mod render;
pub mod render_hdr;
pub mod render_library;
pub mod render_lights;
+pub mod render_presets;
pub mod render_shots;
pub mod render_stage;
pub mod render_surface_resources;
diff --git a/crates/engine/src/schema/render_presets.rs b/crates/engine/src/schema/render_presets.rs
new file mode 100644
index 0000000000..1fa53e6960
--- /dev/null
+++ b/crates/engine/src/schema/render_presets.rs
@@ -0,0 +1,201 @@
+//! Contracts and result types for the native studio and quality profile commands in
+//! `cmd/render/studio_presets.rs` (#11766). The handlers read these same parameter types, so
+//! each contract is exactly what its handler takes; like the handlers, a contract refuses
+//! unknown keys.
+
+use schemars::{JsonSchema, Schema, SchemaGenerator, json_schema};
+use serde::{Deserialize, Serialize};
+use serde_json::{Map, Value};
+
+/// `set`'s default: no change to the setup.
+fn no_change() -> Value {
+ serde_json::json!({})
+}
+
+/// `set`: changes to the setup, as `render.settings.set` takes them. `patched_settings` in
+/// `cmd/render.rs` refuses anything but an object of at most 13 fields, with its own message.
+/// The fields of a render setup, as `render.settings.get` gives them. A `set` patch may give up
+/// to 13 of them; `patched_settings` reads the patched setup as a `RenderSetup`, which refuses any
+/// other key.
+const SETUP_FIELDS: &[&str] = &[
+ "backend",
+ "mode",
+ "camera",
+ "width",
+ "height",
+ "format",
+ "exposure_ev",
+ "environment_rotation",
+ "environment_intensity",
+ "background",
+ "job",
+ "surfaces",
+ "optics",
+ "stage",
+];
+
+/// Each setup field, without its own schema: `patched_settings` checks the values.
+fn setup_properties() -> serde_json::Map<String, Value> {
+ SETUP_FIELDS.iter().map(|field| (field.to_string(), Value::Object(serde_json::Map::new()))).collect()
+}
+
+fn set_schema(_: &mut SchemaGenerator) -> Schema {
+ json_schema!({
+ "description": "Changes to the setup before the studio is fitted, as `render.settings.set` takes them: at most 13 of the setup's fields. The setup they make must render with the GPU path tracer. Default: none.",
+ "type": "object",
+ "properties": setup_properties(),
+ "additionalProperties": false,
+ "maxProperties": 13,
+ "default": {}
+ })
+}
+
+/// Fit a native studio to the visible product: its HDR environment, a ground, its light rig
+/// when it has one, and its exposure. `render.preset.resolve` reports what would be saved,
+/// without changing the design. `render.preset.apply` saves it, in one undo step, after that
+/// review. The camera, the output size, sampling, optical bindings and the design itself are
+/// kept. Needs a build with the bundled render library.
+#[derive(Debug, Deserialize, JsonSchema)]
+#[serde(deny_unknown_fields)]
+pub struct PresetParams {
+ /// The native studio: `NATIVE-STUDIO-` and its number, as `render.library.list` with
+ /// `kind: native_scenes` gives it.
+ pub id: String,
+ /// The render setup to fit it into, saved or new.
+ pub name: String,
+ #[serde(default = "no_change")]
+ #[schemars(schema_with = "set_schema")]
+ pub set: Value,
+ /// The design's revision when the caller resolved the studio, as `render.preset.resolve`
+ /// gives it. If the design changed since, the call is refused: resolve it again. Apply needs
+ /// it; resolve takes it to check the same way. Default: no check.
+ #[serde(default)]
+ pub expected_revision: Option<u64>,
+ /// Apply only: agree that the studio replaces the setup's lighting, environment and exposure.
+ /// Apply refuses without it.
+ #[serde(default)]
+ pub replace_lighting_and_environment: bool,
+ /// Apply only: agree that the studio replaces a stage the setup already has. Apply refuses
+ /// without it when the resolved studio says `requires_stage_consent`.
+ #[serde(default)]
+ pub replace_stage: bool,
+}
+
+/// Work out the GPU path tracer's fixed sampling budget for a quality profile: the image size,
+/// samples, depth and seed it asks for. Nothing is saved, and the design doesn't change. A
+/// profile the GPU path tracer can't meet whole is refused, never silently reduced.
+#[derive(Debug, Deserialize, JsonSchema)]
+#[serde(deny_unknown_fields)]
+pub struct QualityParams {
+ /// The quality profile: `Q-` and its number, as `render.library.list` with `kind: quality`
+ /// gives it.
+ pub id: String,
+ /// How to use it: only `fixed_samples_png`, a fixed budget for a PNG still.
+ #[schemars(schema_with = "variant_schema")]
+ pub variant: String,
+ /// Agree that the budget leaves out what the profile asks for beyond a fixed budget (see
+ /// `omitted` in the reply). Required as true.
+ pub acknowledge_omissions: bool,
+}
+
+fn variant_schema(_: &mut SchemaGenerator) -> Schema {
+ json_schema!({"type": "string", "enum": ["fixed_samples_png"]})
+}
+
+/// What `render.preset.resolve` and `render.preset.apply` return: the fitted studio.
+#[derive(Debug, Serialize, JsonSchema)]
+pub struct StudioComposition {
+ /// The native studio.
+ pub id: String,
+ /// The render setup.
+ pub name: String,
+ /// The design's revision the studio was fitted at: give it to `render.preset.apply` as
+ /// `expected_revision`.
+ pub revision: u64,
+ /// The native studio's recipe, as `render.library.describe` gives it.
+ pub source: Map<String, Value>,
+ /// The setup with the studio fitted, as the render settings commands give it.
+ pub setup: Value,
+ /// The SHA-256 of the studio's HDR environment.
+ pub resource_sha256: String,
+ /// How the studio's light rig was fitted, as `render.library.studio.prepare` reports it;
+ /// `null` for a studio without a rig.
+ pub rig_projection: Value,
+ /// Always `resolved_native_projection`.
+ pub status: String,
+ /// Whether the design changed: always false for resolve; for apply, false when the setup
+ /// already was the studio.
+ pub document_changed: bool,
+ /// Always `gpu-path`: the studio renders with the GPU path tracer.
+ pub executor: String,
+ /// Always true: applying needs `replace_lighting_and_environment`.
+ pub requires_lighting_consent: bool,
+ /// Whether applying needs `replace_stage`: the setup has a stage, or the patch gives one.
+ pub requires_stage_consent: bool,
+ /// What the studio replaces in the setup.
+ pub replaces: Vec<String>,
+ /// What it keeps.
+ pub preserves: Vec<String>,
+ /// How the product's clearance from the stage and lights is checked.
+ pub clearance: String,
+ /// The studio's limits, in sentences.
+ pub limitations: Vec<String>,
+ /// In the warn parameter-check mode: what the call's parameters got wrong.
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
+ pub param_warnings: Vec<String>,
+}
+
+/// What `render.quality.prepare` returns: the fixed budget, to give to the render commands.
+#[derive(Debug, Serialize, JsonSchema)]
+pub struct QualityPlan {
+ /// The quality profile.
+ pub id: String,
+ /// Its name.
+ pub name: Option<String>,
+ /// Always `fixed_samples_png`.
+ pub variant: String,
+ /// Always `fixed_budget_projection_not_full_quality_profile`.
+ pub status: String,
+ /// The design's revision when the budget was prepared.
+ pub revision: u64,
+ /// Always false.
+ pub document_changed: bool,
+ /// Always true: the profile itself isn't changed.
+ pub source_unchanged: bool,
+ /// The render setup fields the budget sets.
+ pub settings: QualitySize,
+ /// The GPU path tracer's options the budget sets.
+ pub gpu_options: QualityOptions,
+ /// What the budget keeps as the setup has it.
+ pub preserves: Vec<String>,
+ /// What the profile asks for that a fixed budget leaves out.
+ pub omitted: Vec<String>,
+ /// The quality profile as its catalog holds it, unchanged.
+ pub source: Map<String, Value>,
+ /// In the warn parameter-check mode: what the call's parameters got wrong.
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
+ pub param_warnings: Vec<String>,
+}
+
+/// The image size of a quality budget (pixels).
+#[derive(Debug, Serialize, JsonSchema)]
+pub struct QualitySize {
+ pub width: u32,
+ pub height: u32,
+}
+
+/// The GPU path tracer's options of a quality budget.
+#[derive(Debug, Serialize, JsonSchema)]
+pub struct QualityOptions {
+ /// Samples per pixel: 1 to 4096.
+ pub samples: u32,
+ /// The most bounces a path takes: 1 to 16.
+ pub max_depth: u32,
+ pub seed: u32,
+ /// Whether the profile asks for denoising; `null` when it doesn't say.
+ pub denoise: Option<bool>,
+}
+
+#[cfg(test)]
+#[path = "render_presets_tests.rs"]
+mod tests;
diff --git a/crates/engine/src/schema/render_presets_tests.rs b/crates/engine/src/schema/render_presets_tests.rs
new file mode 100644
index 0000000000..166b515e9b
--- /dev/null
+++ b/crates/engine/src/schema/render_presets_tests.rs
@@ -0,0 +1,116 @@
+use serde_json::{Value, json};
+
+use super::{PresetParams, QualityParams, QualityPlan, StudioComposition};
+use crate::Session;
+use crate::schema::tests::{assert_keys, conforms};
+use crate::schema::{ParamCheck, input_schema_for, output_schema_for};
+
+/// A design with a box, `Subject`, and a saved render setup, `Shot`, that renders with the GPU
+/// path tracer, at the parameter-check level `level`.
+fn with_a_shot(level: ParamCheck) -> Session {
+ let mut s = Session { param_check: level, ..Session::default() };
+ for (id, p) in [
+ ("solid.box", json!({"length": 20, "width": 15, "height": 10, "body_name": "Subject"})),
+ ("render.settings.set", json!({"name": "Shot", "set": {"width": 96, "height": 64, "job": {"method": "gpu_path"}}})),
+ ] {
+ s.execute(id, &p).unwrap_or_else(|e| panic!("{id} {p}: {e}"));
+ }
+ s
+}
+
+/// `render.quality.prepare`'s call for the profile `id`.
+fn budget(id: &str) -> Value {
+ json!({"id": id, "variant": "fixed_samples_png", "acknowledge_omissions": true})
+}
+
+#[test]
+fn schemas_and_the_key_check_agree() {
+ assert_keys(input_schema_for::<PresetParams>(), &["expected_revision", "id", "name", "replace_lighting_and_environment", "replace_stage", "set"]);
+ assert_keys(input_schema_for::<QualityParams>(), &["acknowledge_omissions", "id", "variant"]);
+}
+
+/// The handlers refuse these calls after reading them; strict refuses them with their message.
+/// They need a body, a saved setup and the design's revision, so the shared helper, which has a
+/// sketch only, doesn't fit. None of them reaches the bundled render library.
+#[test]
+fn strict_keeps_todays_errors() {
+ let cases: Vec<(&str, Box<dyn Fn(u64) -> Value>)> = vec![
+ ("render.quality.prepare", Box::new(|_| json!({"id": "Q-002", "variant": "full", "acknowledge_omissions": true}))),
+ ("render.quality.prepare", Box::new(|_| json!({"id": "Q-002", "variant": "fixed_samples_png", "acknowledge_omissions": false}))),
+ ("render.quality.prepare", Box::new(|_| budget("Q-999"))),
+ ("render.quality.prepare", Box::new(|_| budget("not an id"))),
+ ("render.quality.prepare", Box::new(|_| budget("Q-004"))),
+ ("render.preset.resolve", Box::new(|_| json!({"id": "NATIVE-STUDIO-999", "name": "Shot"}))),
+ ("render.preset.resolve", Box::new(|_| json!({"id": "NATIVE-STUDIO-001", "name": "Shot", "expected_revision": 999_999}))),
+ ("render.preset.resolve", Box::new(|_| json!({"id": "NATIVE-STUDIO-001", "name": "Raster"}))),
+ ("render.preset.resolve", Box::new(|_| json!({"id": "NATIVE-STUDIO-001", "name": "Shot", "set": 5}))),
+ ("render.preset.resolve", Box::new(|_| json!({"id": "NATIVE-STUDIO-001", "name": " Shot"}))),
+ ("render.preset.apply", Box::new(|_| json!({"id": "NATIVE-STUDIO-001", "name": "Shot", "replace_lighting_and_environment": true}))),
+ ("render.preset.apply", Box::new(|r| json!({"id": "NATIVE-STUDIO-001", "name": "Shot", "expected_revision": r}))),
+ ];
+ for (id, p) in &cases {
+ let error = |level: ParamCheck| {
+ let mut s = with_a_shot(level);
+ let p = p(s.revision);
+ s.execute(id, &p).err().map(|e| e.to_string())
+ };
+ let off = error(ParamCheck::Off);
+ assert!(off.is_some(), "{id} {} should fail today", p(0));
+ assert_eq!(error(ParamCheck::Strict), off, "{id} {}", p(0));
+ }
+}
+
+/// #11766: the quality budgets the GPU path tracer meets reply as their schema says, in Warn
+/// without warnings; with the bundled render library, so do a native studio's review and its
+/// application. Like the handlers, warn and strict refuse a misspelt key.
+#[test]
+fn preset_commands_reply_with_their_schemas() {
+ let (composition, plan) = (output_schema_for::<StudioComposition>(), output_schema_for::<QualityPlan>());
+ let mut s = with_a_shot(ParamCheck::Warn);
+ let run = |s: &mut Session, schema: &schemars::Schema, id: &str, p: Value| {
+ let r = s.execute(id, &p).unwrap_or_else(|e| panic!("{id} {p}: {e}"));
+ let schema = schema.as_value();
+ assert!(conforms(schema, schema, &r), "{r} doesn't match {schema}");
+ assert!(r.get("param_warnings").is_none(), "{r}");
+ r
+ };
+ // The profiles a fixed budget can meet (`studio_presets_tests` checks the others refuse).
+ for id in ["Q-001", "Q-002", "Q-003"] {
+ let r = run(&mut s, &plan, "render.quality.prepare", budget(id));
+ assert!(r["name"].is_string() && r["gpu_options"]["denoise"].is_boolean(), "{r}");
+ }
+ if cfg!(feature = "bundled-render-library") {
+ let revision = s.revision;
+ let review = json!({"id": "NATIVE-STUDIO-004", "name": "Shot", "set": {}, "expected_revision": revision});
+ let r = run(&mut s, &composition, "render.preset.resolve", review);
+ assert!(r["document_changed"] == false && r["rig_projection"].is_object(), "a studio with a rig: {r}");
+ let request = json!({"id": "NATIVE-STUDIO-004", "name": "Shot", "expected_revision": revision,
+ "replace_lighting_and_environment": true, "replace_stage": false});
+ assert_eq!(run(&mut s, &composition, "render.preset.apply", request)["document_changed"], true);
+ let plain = json!({"id": "NATIVE-STUDIO-001", "name": "Plain", "set": {"job": {"method": "gpu_path"}}});
+ assert!(run(&mut s, &composition, "render.preset.resolve", plain)["rig_projection"].is_null(), "a studio without a rig");
+ }
+ for level in [ParamCheck::Warn, ParamCheck::Strict] {
+ let mut p = budget("Q-001");
+ p["acknowledge_omision"] = json!(true);
+ let error = with_a_shot(level).execute("render.quality.prepare", &p).err().map(|e| e.to_string()).unwrap_or_default();
+ assert!(error.contains("`acknowledge_omision`"), "{level:?}: {error}");
+ }
+}
+
+/// `set` names the render setup's fields: `patched_settings` reads the patched setup as a
+/// `RenderSetup`, which refuses any other key, so the schema refuses a misspelt one too (and
+/// more than 13 at once).
+#[test]
+fn the_set_schema_names_the_setup_fields() {
+ let root = input_schema_for::<PresetParams>();
+ let root = root.as_value();
+ let set = &root["properties"]["set"];
+ for (patch, takes) in
+ [(json!({}), true), (json!({"width": 640, "height": 480, "job": {"method": "gpu_path"}}), true), (json!({"widht": 640}), false)]
+ {
+ assert_eq!(conforms(root, set, &patch), takes, "{patch}");
+ }
+ // `conforms` doesn't read `maxProperties`, so the limit is pinned here.
+ assert_eq!((set["maxProperties"].as_u64(), set["properties"].as_object().map(|p| p.len())), (Some(13), Some(super::SETUP_FIELDS.len())), "{set}");
+}
diff --git a/crates/engine/src/schema/unconverted.txt b/crates/engine/src/schema/unconverted.txt
index fbcedc2d54..586c1ea937 100644
--- a/crates/engine/src/schema/unconverted.txt
+++ b/crates/engine/src/schema/unconverted.txt
@@ -142,9 +142,6 @@ render.library.surface.unbind
render.optics.bind
render.optics.unbind
render.preflight
-render.preset.apply
-render.preset.resolve
-render.quality.prepare
render.result.pin
render.result.regrade
render.scene