diff --git a/proposals/render/2026-10-30/README.md b/proposals/render/2026-10-30/README.md index 5e9634e8b..d296eb8ea 100644 --- a/proposals/render/2026-10-30/README.md +++ b/proposals/render/2026-10-30/README.md @@ -74,3 +74,8 @@ The original 516-case core result remains bound to its exact unchanged core sour ## Exact19-path adopted Render composition [Actual19 cumulative source](actual19-reviewed-source/README.md) preserves the independently source-reviewed V2 that ROOT adopted by exact RAW copy, with3571 members checked. It combines manual-final feedback, progressive certified optics and both W2 suffixes, CPU material routing/bridge/caption, UI252 with its explicit supported-feature/DTO-stage corrections, both Photographic fixes and Raster perspective/directional-core source. Reconstruct the exact previous C14 post-format base; this is an alternative to overlapping increments, never another layer on top of them. LF hunks and eight CRLF endpoints are explicitly bound. New66 declarations and planned242-case/49-marker selection are **unrun**; formatting/build/actual gates/native acceptance are still pending. Historical C14 remains36PASS/1FAIL/108unrun and no pass transfers. + + +## C16 source: fixture defaults and Result navigation + +[C16 exact five-file source](c16-defaults-auto-result/README.md) is independently source-reviewed and adopted by RAW copy; the adjacent12-file C15 formatting bridge makes the Actual19→C15 post-format→C16 lineage explicit. It fixes the four invalid new-fixture calls and adds preference-compliant Result navigation after accepted GUI Start, retaining old behavior with `render_open_result_on_start=false`. Four new declarations remain unrun. C15 stays an actual four-E0599 build failure with0 test bodies/242 cases unrun; no build/test/native PASS transfers. Manifests record exact endpoint hashes/EOL and cumulative alternatives; no private execution files are published. diff --git a/proposals/render/2026-10-30/c16-defaults-auto-result/README.md b/proposals/render/2026-10-30/c16-defaults-auto-result/README.md new file mode 100644 index 000000000..26e758166 --- /dev/null +++ b/proposals/render/2026-10-30/c16-defaults-auto-result/README.md @@ -0,0 +1,25 @@ +# C16 — fixture defaults and preference-compliant Result navigation + +This exact five-file source successor has independent source review (`60695ce7`) and was adopted by verified RAW copy, with3572 source members checked and Git HEAD/index/unrelated WIP preserved. **No C16 runtime PASS is claimed.** At adoption the new source remained unformatted, uncompiled and unrun. Production draft #8938 is still not a ready implementation, installed fix or complete render parity. + +## Reconstruct the exact base, then this cumulative change once + +1. Reconstruct [Actual19](../actual19-reviewed-source/README.md) and its declared earlier protected27/C14 base. +2. Concatenate the numbered `c15-postformat-delta-*.patch` parts in order, using `c15-postformat-manifest.json`, to reach the exact actual C15 post-format source `2fe4f37371e7376e02ae89a080e51fad82e6f6c564bfe8b8a8075c2951fe1f31`. The manifest gives each part's SHA and the whole concatenated patch SHA; file boundaries are preserved. That bridge describes the12 actual formatter-changed endpoints; before and after payloads were read and checked against the sealed source dictionaries, never inferred from hashes. It is source formatting evidence, not a successful build or tests. +3. Apply `candidate.patch` once against that exact base. It is cumulative and is an **alternative** to separately applying the overlapping defaults252 and autoResultV2 patches. It is not a patch for production HEAD or arbitrary main. + +Both patch files use LF-normalized textual hunks. The curated manifests and bindings preserve exact RAW before/candidate hashes, lengths, EOL counts and BOM status. Reconstruct only physical line endings explicitly and verify every final RAW SHA. In the C16 endpoints, `prefs.rs`, `prefs/graphics.rs` and `render_workspace_ribbon.rs` remain CRLF; UI tests and the new pending JSON remain LF. No universal literal RAW patch replay or fuzzy application is claimed. Actual adoption copied verified RAW candidates rather than applying normalized text to an unknown tree. + +## Behavior and default change + +**Changes a default: yes — successful GUI Start opens Result once; the earlier behavior is kept behind `render_open_result_on_start=false`.** The persisted preference has a Graphics checkbox/help/reset path. A successful GUI Start with accepted JobId registration invokes the existing Result-view command once. False preserves either current view; direct API Start, Check, errors, QueueFull and cache repaint do not acquire an automatic view change. A subsequent explicit Model selection remains respected. This does not replace Nateaux's panels/results implementation or alter final/provisional image/export authority. + +The independent fixture correction replaces only four nonexistent `Stage`/`SurfaceBindings.clear` calls in two new tests with existing valid `Default` assignments and explicit empty-state preconditions. It does not change product contracts, original geometry, requests, branch assertions, tolerances or output oracles to fit the code. Corrected UI252 plus the unchanged original6879-byte AutoResult appendix yields UI255. Preferences116→117 and UI252→255 account for four new declarations; two new message IDs have all nine locale values. + +## Failed evidence stays failed; source review is not execution + +C15 completed formatting/check, then its own combined native-library test build failed with four `E0599` errors in those new fixture setups. **Zero tests and zero CPU markers executed; all242 selected cases remained unrun.** There was no complete qualified three-artifact set or real inventories. Independent terminal closure released the owned run; its raw failure is preserved. This successor does not relabel C15 as a pass, retry its unchanged source or inherit C14 test/build evidence. + +The bounded source review found no actionable defect in this exact cumulative five-file packet. Actual formatting, fresh source binding, the sole cached serial builder's own artifacts/inventories/regressions and applicable strict/wasm/repository/full gates are still required before qualification. Native mouse/keyboard Result navigation, genuine manual-final accumulation, long-scene cadence/quality, cancellation and export remain acceptance work. The cooperative Raster navigation cases are not CPU/GPU image-quality proof. No physical GPU execution, additional strict TIR or real Raster directional consumer is enabled here. + +Only source patches and curated relative-path bindings are in this folder. Private scripts, machine paths, admission/control/grant data, receipts and logs are excluded. Engineer owns canonical publication and later source-bound validation; this checkpoint grants no execution. diff --git a/proposals/render/2026-10-30/c16-defaults-auto-result/bindings.json b/proposals/render/2026-10-30/c16-defaults-auto-result/bindings.json new file mode 100644 index 000000000..9beb027fa --- /dev/null +++ b/proposals/render/2026-10-30/c16-defaults-auto-result/bindings.json @@ -0,0 +1,166 @@ +{ + "schema": 1, + "status": "ACTUALLY_ADOPTED_SOURCE_ONLY_UNFORMATTED_UNCOMPILED_UNRUN_AT_ADOPTION", + "base": { + "description": "Exact actual C15 post-format source, after the adjacent formatter-only bridge", + "manifest_sha256": "2fe4f37371e7376e02ae89a080e51fad82e6f6c564bfe8b8a8075c2951fe1f31", + "formatter_bridge": "c15-postformat-manifest.json" + }, + "files": [ + { + "path": "crates/ui-egui/src/prefs.rs", + "before_sha256": "c13838afa66969ab40de6825a252efd0436399a30d331f28724be4e1bfe11264", + "candidate_sha256": "b90ea63d6238bf41cb467a41efcd2b3888196e3be60f2453c635078d0933c97d", + "new_file": false, + "delta_sha256": "552aa58c46f5c737e7dc216822d64a442ad3450e667050509a631dc1a8ea7da0" + }, + { + "path": "crates/ui-egui/src/prefs/graphics.rs", + "before_sha256": "6168eff4e462477f57ab1ef496ff5917de0e21531f0acf9793c4798dcbcb9caf", + "candidate_sha256": "e48ddcdf0fb9e203133d1d67c7cbba249ee0082b37d07585e9e54146324a2f64", + "new_file": false, + "delta_sha256": "e9732cb7ea2b1c1a684aadc14402be0bc4f14b87732cafb1063f231a0d938d20" + }, + { + "path": "crates/ui-egui/src/render_workspace_ribbon.rs", + "before_sha256": "27fc255da6da75976edb4b37928b78ea034c6c579f258b3155f15d43e3237ffb", + "candidate_sha256": "1f69c036f5b7327eb19b2495c7f3f3a30d2cb90a7f37f6b44980efbb37f06cf3", + "new_file": false, + "delta_sha256": "793d1970a5924e745448a280186d2fea265467a1cd4ac59e9f3014aa71aa5efb" + }, + { + "path": "crates/ui-egui/src/render_workspace_tests.rs", + "before_sha256": "5eeb9bb333cad6936dae8bade8c3be0eece2cea7f52d274c6bd59b28c42625d9", + "candidate_sha256": "2acd261a36f2baa0acedad44eed6cf67ad7d6ee895e2197539735a266c36ed3e", + "new_file": false, + "delta_sha256": "d06f36553129868fcca5fb00e40cf1e14035e31d0d43b99c78ceeadcd2229d6c" + }, + { + "path": "assets/locales/pending/render-result-on-start.json", + "before_sha256": null, + "candidate_sha256": "5ec777e3517710910dbdff067fcf55739961e2023290a2d673744a96505aa5e5", + "new_file": true, + "delta_sha256": "f69b7c1acebfdd623752a5dc01d7503b642eb6ea96d678d7815e120f0a73409c" + } + ], + "raw_endpoints": [ + { + "path": "crates/ui-egui/src/prefs.rs", + "before": { + "sha256": "c13838afa66969ab40de6825a252efd0436399a30d331f28724be4e1bfe11264", + "bytes": 377352, + "eol": "CRLF", + "crlf": 6770, + "lf": 6770, + "utf8_bom": false + }, + "candidate": { + "sha256": "b90ea63d6238bf41cb467a41efcd2b3888196e3be60f2453c635078d0933c97d", + "bytes": 378635, + "eol": "CRLF", + "crlf": 6790, + "lf": 6790, + "utf8_bom": false + } + }, + { + "path": "crates/ui-egui/src/prefs/graphics.rs", + "before": { + "sha256": "6168eff4e462477f57ab1ef496ff5917de0e21531f0acf9793c4798dcbcb9caf", + "bytes": 11761, + "eol": "CRLF", + "crlf": 204, + "lf": 204, + "utf8_bom": false + }, + "candidate": { + "sha256": "e48ddcdf0fb9e203133d1d67c7cbba249ee0082b37d07585e9e54146324a2f64", + "bytes": 11877, + "eol": "CRLF", + "crlf": 205, + "lf": 205, + "utf8_bom": false + } + }, + { + "path": "crates/ui-egui/src/render_workspace_ribbon.rs", + "before": { + "sha256": "27fc255da6da75976edb4b37928b78ea034c6c579f258b3155f15d43e3237ffb", + "bytes": 13010, + "eol": "CRLF", + "crlf": 285, + "lf": 285, + "utf8_bom": false + }, + "candidate": { + "sha256": "1f69c036f5b7327eb19b2495c7f3f3a30d2cb90a7f37f6b44980efbb37f06cf3", + "bytes": 13161, + "eol": "CRLF", + "crlf": 288, + "lf": 288, + "utf8_bom": false + } + }, + { + "path": "crates/ui-egui/src/render_workspace_tests.rs", + "before": { + "sha256": "5eeb9bb333cad6936dae8bade8c3be0eece2cea7f52d274c6bd59b28c42625d9", + "bytes": 545234, + "eol": "LF", + "crlf": 0, + "lf": 10030, + "utf8_bom": false + }, + "candidate": { + "sha256": "2acd261a36f2baa0acedad44eed6cf67ad7d6ee895e2197539735a266c36ed3e", + "bytes": 552355, + "eol": "LF", + "crlf": 0, + "lf": 10169, + "utf8_bom": false + } + }, + { + "path": "assets/locales/pending/render-result-on-start.json", + "before": null, + "candidate": { + "sha256": "5ec777e3517710910dbdff067fcf55739961e2023290a2d673744a96505aa5e5", + "bytes": 2962, + "eol": "LF", + "crlf": 0, + "lf": 38, + "utf8_bom": false + } + } + ], + "ui_tests_before": 252, + "ui_tests_candidate": 255, + "prefs_tests_before": 116, + "prefs_tests_candidate": 117, + "added_test_declarations": 4, + "change_default_line": "Changes a default: yes - successful GUI Start opens Result once, old behaviour kept behind preference render_open_result_on_start=false", + "composition": { + "original_autov2_ui_before_sha256": "5eeb9bb333cad6936dae8bade8c3be0eece2cea7f52d274c6bd59b28c42625d9", + "original_autov2_ui_candidate_sha256": "d4338085adb86d040926d7df6e1b3b6188adffd22b0272a428732bc5a1320221", + "corrected_ui252_sha256": "afb3daa7b2663d5b9372fdea7ff83ea0ceb5c35da43af10177a5ea6a0abeaaab", + "auto_result_suffix_bytes": 6879, + "expected_ui255_sha256": "2acd261a36f2baa0acedad44eed6cf67ad7d6ee895e2197539735a266c36ed3e", + "other_candidates_identical": 4, + "default_true_and_opt_off_unchanged": true + }, + "predecessor_hashes": { + "defaults252": { + "manifest_sha256": "3c0d8e8d60276a054c48024badfa84ff78619f00ca70f0cb5753b97ff0d68d91", + "proposal_sha256": "68b1fe88bebcb64c72dbe5f1b357de10784db2361fa2add2b0c2ea8a2b9fd642", + "bindings_sha256": "0c8153845adb02dbf9f32d943631bc6e4efaee7960da95902c52d689ea515ad4" + }, + "autoResultV2": { + "manifest_sha256": "f993c9fb678565381838c96c54b1cf0a46989baebaaff32b36ddaced8867bb58", + "proposal_sha256": "e71efa5b57deb5869b549b2c2eae69f0b50f79c88b52ba3b351115ef2d5eac3d", + "bindings_sha256": "28bcd0455862a5eb321d1b713cd90fb6002cbe7b2ee2098a26908af5a2878615" + } + }, + "composition_policy": "Cumulative five-file successor after C15 formatting, not an additional application of the overlapping defaults252 or autoResultV2 patches. UI255 is corrected UI252 plus the same original6879-byte AutoResult appendix. Other four payloads are unchanged from their reviewed AutoResult predecessors.", + "patch_EOLayout": "candidate.patch contains LF-normalized hunks. prefs.rs, prefs/graphics.rs and render_workspace_ribbon.rs must end in CRLF; UI tests and new pending JSON in LF. Raw hashes/sizes/EOL/BOM metadata are authoritative. No universal literal RAW diff replay claim.", + "runtime_PASS_claimed": false +} diff --git a/proposals/render/2026-10-30/c16-defaults-auto-result/c15-postformat-delta-01.patch b/proposals/render/2026-10-30/c16-defaults-auto-result/c15-postformat-delta-01.patch new file mode 100644 index 000000000..9b6ffcd00 --- /dev/null +++ b/proposals/render/2026-10-30/c16-defaults-auto-result/c15-postformat-delta-01.patch @@ -0,0 +1,1144 @@ +--- a/crates/engine/src/cmd/render/jobs.rs ++++ b/crates/engine/src/cmd/render/jobs.rs +@@ -389,25 +389,34 @@ + fn nested_command_fixture() -> (Session, Value) { + let mut s = Session::default(); + for (name, length, width, height) in [("Outer", 20, 20, 4), ("Inner", 10, 10, 2)] { +- s.execute("solid.box", &json!({ +- "length":length,"width":width,"height":height,"center":[0,0,2], +- "operation":"new","body_name":name, +- })).unwrap(); ++ s.execute( ++ "solid.box", ++ &json!({ ++ "length":length,"width":width,"height":height,"center":[0,0,2], ++ "operation":"new","body_name":name, ++ }), ++ ) ++ .unwrap(); + } + s.execute("render.scene", &json!({})).unwrap(); + let scene = crate::product_scene::extract(&s).unwrap(); + assert_eq!(scene.meshes.len(), 2); +- let dielectrics: Vec<_> = scene.meshes.iter().enumerate().map(|(index, body)| { +- assert!(matches!(body.name.as_str(), "Outer" | "Inner")); +- json!({ +- "body_index":index,"body_name":body.name,"boundary":"closed_box","ior":1.0, +- "absorption_per_mm":if body.name == "Outer" { [0.1,0.2,0.0] } else { [0.3,0.4,0.0] }, +- "thickness_mm":0.0, ++ let dielectrics: Vec<_> = scene ++ .meshes ++ .iter() ++ .enumerate() ++ .map(|(index, body)| { ++ assert!(matches!(body.name.as_str(), "Outer" | "Inner")); ++ json!({ ++ "body_index":index,"body_name":body.name,"boundary":"closed_box","ior":1.0, ++ "absorption_per_mm":if body.name == "Outer" { [0.1,0.2,0.0] } else { [0.3,0.4,0.0] }, ++ "thickness_mm":0.0, ++ }) + }) +- }).collect(); +- let mut camera = solidcraft_render::Camera { distance:50.0, fov:0.0, ..Default::default() }; ++ .collect(); ++ let mut camera = solidcraft_render::Camera { distance: 50.0, fov: 0.0, ..Default::default() }; + camera.set_view(solidcraft_render::StandardView::Top); +- camera.target = solidcraft_geom::Vec3::new(0.0,0.0,2.0); ++ camera.target = solidcraft_geom::Vec3::new(0.0, 0.0, 2.0); + let host = solidcraft_render::job::CpuHost::for_platform().unwrap(); + assert_eq!(host.kind(), solidcraft_render::job::HostKind::NativeWorker); + assert!(host.is_available(), "this native test requires an available real CPU worker"); +@@ -448,14 +457,14 @@ + let handle = s.render_job_handle(id).unwrap(); + let status = handle.wait_timeout(std::time::Duration::from_secs(60)).unwrap(); + assert_eq!(status.progress.phase, Phase::Completed, "{:?}", status.error); +- assert_eq!(status.options, solidcraft_render::job::JobOptions { nested_media:true, ..Default::default() }); ++ assert_eq!(status.options, solidcraft_render::job::JobOptions { nested_media: true, ..Default::default() }); + let retained = s.execute("render.status", &json!({"job":id})).unwrap(); + assert_eq!(retained["options"]["nested_media"], true); + let frame = handle.frame().unwrap().unwrap(); + let image = image::load_from_memory(frame.png()).unwrap().to_rgba8(); + // Independent Beer oracle: outer2mm + inner2mm, replacing the parent + // interval, yields exp(-.8), exp(-1.2),1 -> Reinhard+sRGB [151,132,188]. +- assert_eq!(image.get_pixel(0,0).0, [151,132,188,255]); ++ assert_eq!(image.get_pixel(0, 0).0, [151, 132, 188, 255]); + assert!(std::sync::Arc::ptr_eq(&document, &s.doc)); + assert_eq!(before, (s.revision, s.undo.len(), s.redo.len(), s.evaluations, s.is_dirty())); + } +@@ -465,10 +474,7 @@ + fn command_nesting_keeps_default_false_rejects_gpu_controls_and_captures_progressive_glass() { + use solidcraft_render::job::{JobId, JobOptions, Phase}; + let (mut s, wire) = nested_command_fixture(); +- for (key, value) in [ +- ("samples", json!(2)), ("max_depth", json!(2)), ("seed", json!(7)), +- ("denoise", json!(true)), ("lens", json!({})), +- ] { ++ for (key, value) in [("samples", json!(2)), ("max_depth", json!(2)), ("seed", json!(7)), ("denoise", json!(true)), ("lens", json!({}))] { + let mut invalid = wire.clone(); + invalid[key] = value; + for command in ["render.preflight", "render.start"] { +@@ -499,7 +505,7 @@ + assert_eq!(serde_json::to_value(&captured.dielectrics).unwrap(), wire["raytrace"]["dielectrics"]); + let frame = handle.frame().unwrap().unwrap(); + let image = image::load_from_memory(frame.png()).unwrap().to_rgba8(); +- assert_eq!(image.dimensions(), (1,1)); ++ assert_eq!(image.dimensions(), (1, 1)); + // Camera is exterior at z52. At every box face its full jitter cone + // lies within52*tan(1e-6) < 0.000053mm of the axis, far inside the + // inner +/-5mm face. Even using twice the actual half-angle bounds, +@@ -509,7 +515,7 @@ + // integer thresholds of existing Reinhard/sRGB: [151,132,188]. + // Actual primary-background pixels would be255 and fail this oracle. + // This remains a command-route smoke, not a Fresnel/TIR quality case. +- assert_eq!(image.get_pixel(0,0).0, [151,132,188,255]); ++ assert_eq!(image.get_pixel(0, 0).0, [151, 132, 188, 255]); + let interactive = interactive_params(&wire).unwrap(); + assert_eq!(interactive["raytrace"]["dielectrics"], wire["raytrace"]["dielectrics"]); + assert_eq!(interactive["nested_media"], true); +@@ -529,7 +535,6 @@ + let retained = s.execute("render.status", &json!({"job":id})).unwrap(); + assert_eq!(retained["options"]["nested_media"], false); + } +- + } + + /// Resolve portable intent before choosing an executor. Legacy requests are left intact; +@@ -568,7 +573,8 @@ + } else { + return Ok(None); + }; +- if let Some(key) = object.keys().find(|key| !matches!(key.as_str(), "setup" | "settings" | "replace" | "studio_weights" | "progressive_feedback")) { ++ if let Some(key) = object.keys().find(|key| !matches!(key.as_str(), "setup" | "settings" | "replace" | "studio_weights" | "progressive_feedback")) ++ { + return Err(bad( + command, + format!( +@@ -652,8 +658,9 @@ + )); + } + let mut input: Start = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?; +- if input.progressive_feedback && (input.integrator != Integrator::Raytrace +- || input.raytrace.as_ref().and_then(|options| options.progressive).is_none()) { ++ if input.progressive_feedback ++ && (input.integrator != Integrator::Raytrace || input.raytrace.as_ref().and_then(|options| options.progressive).is_none()) ++ { + return Err(bad(command, "progressive_feedback requires CPU progressive raytracing")); + } + validate_studio_weights(input.studio_weights, command)?; +@@ -861,7 +868,16 @@ + Integrator::Raytrace => "opaque_only", + }; + let reply = json!({"ignored_controls":ignored,"stage_panels":settings.stage.len(),"stage_transport":"CPU direct/specular only; no diffuse interreflection", "cpu_budget":budget,"cpu_limits":budget.limits(),"environment":environment_info,"retained_request_bytes":retained_request_bytes,"resolved":resolved,"admission":admission,"request":request,"scene_generation":s.revision,"host":host.kind(),"transparency":transparency,"refraction":refraction,"dielectric_boundaries":if refraction {vec!["thin_sheet","closed_box"]} else {Vec::<&str>::new()}}); +- Ok(Prepared { progressive_feedback: input.progressive_feedback, replace: input.replace, scene, request, reply, environment, executor: resolved.executor, options }) ++ Ok(Prepared { ++ progressive_feedback: input.progressive_feedback, ++ replace: input.replace, ++ scene, ++ request, ++ reply, ++ environment, ++ executor: resolved.executor, ++ options, ++ }) + } + + fn prepare_progressive( +@@ -1068,7 +1084,16 @@ + "raw_linear_accumulator_preserved":true, "output_stage":"linear_before_tone_map" + }); + } +- Ok(Prepared { progressive_feedback: false, replace: input.replace, scene, request, reply, executor: resolved.executor, options, environment: None }) ++ Ok(Prepared { ++ progressive_feedback: false, ++ replace: input.replace, ++ scene, ++ request, ++ reply, ++ executor: resolved.executor, ++ options, ++ environment: None, ++ }) + } + + /// The setup's controls the raster image executor doesn't apply: those not at their neutral value. +@@ -1097,7 +1122,8 @@ + s.render_jobs.start_with_environment_and_feedback(s.revision, p.scene, p.request, p.replace, execution, true) + } else { + s.render_jobs.start_with_environment(s.revision, p.scene, p.request, p.replace, execution) +- }.map_err(job_error)?; ++ } ++ .map_err(job_error)?; + let mut status = json!(status); + if let (Some(out), Some(ignored)) = (status.as_object_mut(), p.reply.get("ignored_controls")) { + out.insert("ignored_controls".into(), ignored.clone()); +--- a/crates/engine/src/render_jobs.rs ++++ b/crates/engine/src/render_jobs.rs +@@ -195,8 +195,9 @@ + execution: Execution, + progressive_feedback: bool, + ) -> Result { +- if progressive_feedback && (request.integrator != Integrator::Raytrace +- || request.raytrace.as_ref().and_then(|options| options.progressive).is_none()) { ++ if progressive_feedback ++ && (request.integrator != Integrator::Raytrace || request.raytrace.as_ref().and_then(|options| options.progressive).is_none()) ++ { + return Err(JobError::new(ErrorCode::InvalidRequest, "progressive_feedback requires CPU progressive raytracing")); + } + let Execution { executor, options, environment } = execution; +@@ -718,11 +719,11 @@ + let checked = session.execute("render.preflight", ¶ms).unwrap(); + if feedback { + let captured: solidcraft_render::job::ImageRequest = serde_json::from_value(checked["request"].clone()).unwrap(); +- let scene = solidcraft_render::ProductScene { meshes:Vec::new(),bounds:solidcraft_geom::Aabb3::EMPTY }; +- let admitted = host.admit_cpu_protected_partial_with_environment_and_options( +- &scene,&captured,solidcraft_render::job::JobOptions::default(),None, +- ).unwrap(); +- assert_eq!(checked["admission"],serde_json::to_value(admitted).unwrap(), "Check uses the same authoritative protected admission"); ++ let scene = solidcraft_render::ProductScene { meshes: Vec::new(), bounds: solidcraft_geom::Aabb3::EMPTY }; ++ let admitted = host ++ .admit_cpu_protected_partial_with_environment_and_options(&scene, &captured, solidcraft_render::job::JobOptions::default(), None) ++ .unwrap(); ++ assert_eq!(checked["admission"], serde_json::to_value(admitted).unwrap(), "Check uses the same authoritative protected admission"); + } + let started = session.execute("render.start", ¶ms).unwrap(); + let job: JobId = serde_json::from_value(started["job"].clone()).unwrap(); +@@ -731,19 +732,22 @@ + assert_eq!(serde_json::to_value(handle.status().unwrap().request).unwrap(), checked["request"]); + assert_eq!(terminal(&handle).unwrap(), Phase::Completed); + let status = handle.status().unwrap(); +- assert_eq!((status.request.width,status.request.height), (13,7)); ++ assert_eq!((status.request.width, status.request.height), (13, 7)); + let options = status.request.raytrace.as_ref().unwrap().progressive.unwrap(); +- assert_eq!((options.samples_per_pixel,options.seed), (9,83)); ++ assert_eq!((options.samples_per_pixel, options.seed), (9, 83)); + let frame = handle.frame().unwrap().unwrap(); + let image = image::load_from_memory(frame.png()).unwrap().to_rgba8(); +- assert_eq!(image.dimensions(), (13,7)); +- assert!(image.pixels().all(|pixel| pixel.0 == [17,89,203,255]), "independent constant-background miss oracle"); +- if let Some(bytes) = &baseline { assert_eq!(frame.png(), bytes.as_slice()); } +- else { baseline = Some(frame.png().to_vec()); } ++ assert_eq!(image.dimensions(), (13, 7)); ++ assert!(image.pixels().all(|pixel| pixel.0 == [17, 89, 203, 255]), "independent constant-background miss oracle"); ++ if let Some(bytes) = &baseline { ++ assert_eq!(frame.png(), bytes.as_slice()); ++ } else { ++ baseline = Some(frame.png().to_vec()); ++ } + let report = handle.protected_preview_report().unwrap(); + assert_eq!(report.is_some(), feedback); + if let Some(report) = report { +- assert_eq!(report.quota_limit,64); ++ assert_eq!(report.quota_limit, 64); + assert!(report.ordinary_used <= report.ordinary_limit); + assert!(report.presentation_used <= report.presentation_limit); + assert_eq!(report.quota_exhausted, report.accepted_snapshots == report.quota_limit); +@@ -751,11 +755,11 @@ + assert!(!handle.request_partial_preview().unwrap(), "terminal demand cannot restart work"); + let foreign = JobId { session: job.session + 1, ..job }; + assert!(session.render_job_handle(foreign).is_err()); +- assert!(session.execute("render.result.pin",&json!({"job":foreign})).is_err()); +- session.execute("render.result.pin",&json!({"job":job})).unwrap(); +- } +- assert_eq!(before,session.doc.to_json()); +- assert_eq!(history,(session.revision,session.undo.len(),session.redo.len())); ++ assert!(session.execute("render.result.pin", &json!({"job":foreign})).is_err()); ++ session.execute("render.result.pin", &json!({"job":job})).unwrap(); ++ } ++ assert_eq!(before, session.doc.to_json()); ++ assert_eq!(history, (session.revision, session.undo.len(), session.redo.len())); + } + + #[test] +@@ -764,72 +768,89 @@ + let typed = json!({"settings":{"width":13,"height":7,"background":[17,89,203], + "job":{"method":"cpu_raytrace","options":{"primary_samples":1,"lights":[],"shadows":false, + "progressive":{"samples_per_pixel":9,"seed":83}}}}}); +- for feedback in [None,Some(false),Some(true)] { ++ for feedback in [None, Some(false), Some(true)] { + let mut params = typed.clone(); +- if let Some(feedback) = feedback { params["progressive_feedback"] = json!(feedback); } +- let checked = session.execute("render.preflight",¶ms).unwrap(); +- let started = session.execute("render.start",¶ms).unwrap(); ++ if let Some(feedback) = feedback { ++ params["progressive_feedback"] = json!(feedback); ++ } ++ let checked = session.execute("render.preflight", ¶ms).unwrap(); ++ let started = session.execute("render.start", ¶ms).unwrap(); + let job: JobId = serde_json::from_value(started["job"].clone()).unwrap(); + let handle = session.render_job_handle(job).unwrap(); +- assert_eq!(terminal(&handle).unwrap(),Phase::Completed); +- assert_eq!(serde_json::to_value(handle.status().unwrap().request).unwrap(),checked["request"]); +- assert_eq!(handle.protected_preview_report().unwrap().is_some(),feedback == Some(true)); +- } +- for mut invalid in [ +- json!({"settings":{"width":13,"height":7}}), +- wire([17,89,203]), +- json!({"progressive":true,"settings":{"width":13,"height":7}}), +- ] { ++ assert_eq!(terminal(&handle).unwrap(), Phase::Completed); ++ assert_eq!(serde_json::to_value(handle.status().unwrap().request).unwrap(), checked["request"]); ++ assert_eq!(handle.protected_preview_report().unwrap().is_some(), feedback == Some(true)); ++ } ++ for mut invalid in ++ [json!({"settings":{"width":13,"height":7}}), wire([17, 89, 203]), json!({"progressive":true,"settings":{"width":13,"height":7}})] ++ { + invalid["progressive_feedback"] = json!(true); +- for command in ["render.preflight","render.start"] { +- let error = session.execute(command,&invalid).unwrap_err().to_string(); +- assert!(error.contains("progressive_feedback"),"{error}"); ++ for command in ["render.preflight", "render.start"] { ++ let error = session.execute(command, &invalid).unwrap_err().to_string(); ++ assert!(error.contains("progressive_feedback"), "{error}"); + } + } + let mut malformed = typed; + malformed["progressive_feedback"] = json!("true"); +- assert!(session.execute("render.preflight",&malformed).is_err()); ++ assert!(session.execute("render.preflight", &malformed).is_err()); + } + + #[test] + fn final_cpu_protected_admission_accounts_captured_hdr_once_and_runs_real_host() { +- use solidcraft_render::job::{ImageRequest, JobOptions, RaytraceOptions, CpuProgressiveOptions}; ++ use solidcraft_render::job::{CpuProgressiveOptions, ImageRequest, JobOptions, RaytraceOptions}; + let (session, host) = native().unwrap(); + let request = ImageRequest { +- integrator: Integrator::Raytrace, width:13, height:7, background:[17,89,203], ++ integrator: Integrator::Raytrace, ++ width: 13, ++ height: 7, ++ background: [17, 89, 203], + raytrace: Some(RaytraceOptions { +- lights:Some(Vec::new()), shadows:false, primary_samples:1, +- progressive:Some(CpuProgressiveOptions {samples_per_pixel:9,seed:83}), ..Default::default() +- }), studio_weights:None, environment:None, textures:None, +- camera:Default::default(), transparent_background:false, ++ lights: Some(Vec::new()), ++ shadows: false, ++ primary_samples: 1, ++ progressive: Some(CpuProgressiveOptions { samples_per_pixel: 9, seed: 83 }), ++ ..Default::default() ++ }), ++ studio_weights: None, ++ environment: None, ++ textures: None, ++ camera: Default::default(), ++ transparent_background: false, + }; +- let scene = solidcraft_render::ProductScene { meshes:Vec::new(),bounds:solidcraft_geom::Aabb3::EMPTY }; ++ let scene = solidcraft_render::ProductScene { meshes: Vec::new(), bounds: solidcraft_geom::Aabb3::EMPTY }; + // Original equirectangular 2x1 RGBE source: two distinct texels, eight payload bytes. + let mut bytes = b"#?RADIANCE\nFORMAT=32-bit_rle_rgbe\nPRIMARIES=0.64 0.33 0.30 0.60 0.15 0.06 0.3127 0.3290\n\n-Y 1 +X 2\n".to_vec(); +- bytes.extend_from_slice(&[96,64,32,129, 32,64,96,129]); ++ bytes.extend_from_slice(&[96, 64, 32, 129, 32, 64, 96, 129]); + let encoded_capacity = bytes.capacity() as u64; + // Independent allocation contract: 2 RGB f32 texels = 24 bytes, one + // 2-pixel RGBE scanline = 8 bytes, plus the fixed 8192-byte task envelope. + let expected_hdr_bytes = encoded_capacity + 24 + 8 + 8192; + let source = solidcraft_render::lighting::HdrSource::new(bytes).unwrap(); +- assert_eq!((source.info().width, source.info().height), (2,1)); +- assert_eq!(source.retained_encoded_bytes(),encoded_capacity); +- assert_eq!(source.info().decoded_rgb_bytes,24); +- let environment = solidcraft_render::lighting::environment_input::EnvironmentInput::new(source,0.25,0.5,1).unwrap(); +- let plain = host.admit_cpu_protected_partial_with_environment_and_options(&scene,&request,JobOptions::default(),None).unwrap(); +- let lit = host.admit_cpu_protected_partial_with_environment_and_options(&scene,&request,JobOptions::default(),Some(&environment)).unwrap(); +- assert_eq!(environment.required_bytes().unwrap(),expected_hdr_bytes); +- assert_eq!(lit.preparation_bytes-plain.preparation_bytes,expected_hdr_bytes); +- assert_eq!(lit.estimated_total_bytes-plain.estimated_total_bytes, +- expected_hdr_bytes + std::mem::size_of::() as u64); +- let job = host.submit_cpu_protected_partial_with_environment_and_options( +- JobId {session:session.render_jobs.owner,serial:1,generation:1},session.revision,scene,request, +- JobOptions::default(),Some(environment), +- ).unwrap(); +- assert_eq!(terminal(&job).unwrap(),Phase::Completed); ++ assert_eq!((source.info().width, source.info().height), (2, 1)); ++ assert_eq!(source.retained_encoded_bytes(), encoded_capacity); ++ assert_eq!(source.info().decoded_rgb_bytes, 24); ++ let environment = solidcraft_render::lighting::environment_input::EnvironmentInput::new(source, 0.25, 0.5, 1).unwrap(); ++ let plain = host.admit_cpu_protected_partial_with_environment_and_options(&scene, &request, JobOptions::default(), None).unwrap(); ++ let lit = host.admit_cpu_protected_partial_with_environment_and_options(&scene, &request, JobOptions::default(), Some(&environment)).unwrap(); ++ assert_eq!(environment.required_bytes().unwrap(), expected_hdr_bytes); ++ assert_eq!(lit.preparation_bytes - plain.preparation_bytes, expected_hdr_bytes); ++ assert_eq!( ++ lit.estimated_total_bytes - plain.estimated_total_bytes, ++ expected_hdr_bytes + std::mem::size_of::() as u64 ++ ); ++ let job = host ++ .submit_cpu_protected_partial_with_environment_and_options( ++ JobId { session: session.render_jobs.owner, serial: 1, generation: 1 }, ++ session.revision, ++ scene, ++ request, ++ JobOptions::default(), ++ Some(environment), ++ ) ++ .unwrap(); ++ assert_eq!(terminal(&job).unwrap(), Phase::Completed); + assert!(job.status().unwrap().environment.is_some()); + assert!(job.protected_preview_report().unwrap().is_some()); +- assert_eq!(job.frame().unwrap().unwrap().info.width,13); +- } +- +-} ++ assert_eq!(job.frame().unwrap().unwrap().info.width, 13); ++ } ++} +--- a/crates/render/src/job/host.rs ++++ b/crates/render/src/job/host.rs +@@ -112,7 +112,10 @@ + if !Arc::ptr_eq(&self.budget, &donor.budget) { + return Err(JobError::new(ErrorCode::WrongOwner, "cannot merge different image admission pools")); + } +- let bytes = self.bytes.checked_add(donor.bytes).filter(|v| *v <= self.budget.limit) ++ let bytes = self ++ .bytes ++ .checked_add(donor.bytes) ++ .filter(|v| *v <= self.budget.limit) + .ok_or_else(|| JobError::new(ErrorCode::LimitExceeded, "image reservation merge overflow"))?; + self.bytes = bytes; + donor.bytes = 0; +@@ -438,7 +441,9 @@ + }) + } + pub fn cancel(&self) -> Result { +- if let Some(credits) = &self.0.partial { credits.close(); } ++ if let Some(credits) = &self.0.partial { ++ credits.close(); ++ } + let mut released_partial = None; + { + let mut data = self.0.data.lock().map_err(|_| JobError::new(ErrorCode::Internal, "render status lock poisoned"))?; +@@ -496,7 +501,10 @@ + } + impl CpuPreviewPolicy { + fn preview_plan(self) -> super::PartialPreviewPlan { +- match self { Self::Shared(plan) => plan, Self::Protected(plan) => plan.preview_plan() } ++ match self { ++ Self::Shared(plan) => plan, ++ Self::Protected(plan) => plan.preview_plan(), ++ } + } + } + struct Submission { +@@ -620,7 +628,12 @@ + + enum WorkPoll { + #[cfg(feature = "raytrace-cpu")] +- Partial { png: Vec, covered: Vec, completed_passes: u32, updated_prefix: u64 }, ++ Partial { ++ png: Vec, ++ covered: Vec, ++ completed_passes: u32, ++ updated_prefix: u64, ++ }, + Existing(TaskPoll), + #[cfg(feature = "raytrace-cpu")] + Preview { +@@ -663,7 +676,9 @@ + Self::Raytrace(task) => Ok(match task.get_mut()?.step_with_partial_previews(units)? { + crate::raytrace::image::PartialImagePoll::Pending(progress) => WorkPoll::Existing(TaskPoll::Pending(progress)), + crate::raytrace::image::PartialImagePoll::Complete(png) => WorkPoll::Existing(TaskPoll::Complete(png)), +- crate::raytrace::image::PartialImagePoll::Preview { png, covered, completed_passes, updated_prefix } => WorkPoll::Partial { png, covered, completed_passes, updated_prefix }, ++ crate::raytrace::image::PartialImagePoll::Preview { png, covered, completed_passes, updated_prefix } => { ++ WorkPoll::Partial { png, covered, completed_passes, updated_prefix } ++ } + }), + _ => Err(JobError::new(ErrorCode::InvalidRequest, "partial presentation requires the builtin CPU task")), + } +@@ -713,9 +728,34 @@ + { + let options = request.raytrace.clone().unwrap_or_default(); + let task = match partial { +- Some(CpuPreviewPolicy::Shared(plan)) => crate::raytrace::image::ImageTask::new_with_environment_and_nested_and_partial(scene, request, cancel, options, environment, job_options.nested_media, plan), +- Some(CpuPreviewPolicy::Protected(plan)) => crate::raytrace::image::ImageTask::new_with_environment_and_nested_and_protected_partial(scene, request, cancel, options, environment, job_options.nested_media, plan), +- None => crate::raytrace::image::ImageTask::new_with_environment_and_nested(scene, request, cancel, options, environment, job_options.nested_media), ++ Some(CpuPreviewPolicy::Shared(plan)) => crate::raytrace::image::ImageTask::new_with_environment_and_nested_and_partial( ++ scene, ++ request, ++ cancel, ++ options, ++ environment, ++ job_options.nested_media, ++ plan, ++ ), ++ Some(CpuPreviewPolicy::Protected(plan)) => { ++ crate::raytrace::image::ImageTask::new_with_environment_and_nested_and_protected_partial( ++ scene, ++ request, ++ cancel, ++ options, ++ environment, ++ job_options.nested_media, ++ plan, ++ ) ++ } ++ None => crate::raytrace::image::ImageTask::new_with_environment_and_nested( ++ scene, ++ request, ++ cancel, ++ options, ++ environment, ++ job_options.nested_media, ++ ), + }; + Self::raytrace_with_slot(task?, report_sink, TaskSlot::new) + } +@@ -743,7 +783,9 @@ + } + + fn terminal(handle: &JobHandle, error: JobError) { +- if let Some(credits) = &handle.0.partial { credits.close(); } ++ if let Some(credits) = &handle.0.partial { ++ credits.close(); ++ } + let mut released_partial = None; + if let Ok(mut data) = handle.0.data.lock() { + if data.progress.phase == Phase::Completed { +@@ -771,10 +813,7 @@ + + // The private factory keeps post-construction setup fallible without losing + // the real ledger. It runs only after report capture and outside every lock. +- fn begin_with_partial_factory( +- work: Work, +- make_partial: impl FnOnce(Arc) -> Result>, +- ) -> Option { ++ fn begin_with_partial_factory(work: Work, make_partial: impl FnOnce(Arc) -> Result>) -> Option { + if work.handle.0.cancel.is_cancelled() { + terminal(&work.handle, JobError::new(ErrorCode::Cancelled, "render cancelled")); + return None; +@@ -839,18 +878,20 @@ + let partial = partial.get_mut()?; + if partial.lease.is_none() && partial.credits.requested.load(Ordering::Acquire) && !partial.credits.exhausted.load(Ordering::Acquire) { + let task = self.task.as_mut().ok_or_else(|| JobError::new(ErrorCode::Internal, "missing partial CPU task"))?; +- if task.partial_ready(partial.credits.plan)? && let Some(lease) = partial.credits.acquire()? { +- // Keep the lease past any producer error until task buffers drop. +- partial.lease = Some(lease); +- let begin = task.begin_partial(partial.credits.plan); +- partial.credits.store_report(task.protected_report())?; +- if !begin? { +- if partial.credits.protected.is_some() && !partial.credits.exhausted.load(Ordering::Acquire) { +- return Err(JobError::new(ErrorCode::Internal, "protected feedback refused without real quota exhaustion")); +- } +- partial.credits.exhaust(); +- drop(partial.lease.take()); ++ if task.partial_ready(partial.credits.plan)? ++ && let Some(lease) = partial.credits.acquire()? ++ { ++ // Keep the lease past any producer error until task buffers drop. ++ partial.lease = Some(lease); ++ let begin = task.begin_partial(partial.credits.plan); ++ partial.credits.store_report(task.protected_report())?; ++ if !begin? { ++ if partial.credits.protected.is_some() && !partial.credits.exhausted.load(Ordering::Acquire) { ++ return Err(JobError::new(ErrorCode::Internal, "protected feedback refused without real quota exhaustion")); + } ++ partial.credits.exhaust(); ++ drop(partial.lease.take()); ++ } + } + } + } +@@ -869,7 +910,9 @@ + data.preview = None; + let released = data.partial_preview.take(); + drop(data); +- if let Some(credits) = &self.handle.0.partial { credits.close(); } ++ if let Some(credits) = &self.handle.0.partial { ++ credits.close(); ++ } + drop(released); + self.handle.0.notify(); + return Ok(false); +@@ -1020,7 +1063,9 @@ + let released = data.partial_preview.take(); + data.progress = Progress { phase: Phase::Completed, done: 1, total: 1 }; + drop(data); +- if let Some(credits) = &self.handle.0.partial { credits.close(); } ++ if let Some(credits) = &self.handle.0.partial { ++ credits.close(); ++ } + drop(released); + self.handle.0.notify(); + Ok(false) +@@ -1029,7 +1074,6 @@ + fn guarded_step(&mut self, units: usize) -> bool { + let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| self.advance(units))); + match result { +- + Ok(Ok(more)) => more, + Ok(Err(e)) => { + terminal(&self.handle, e); +@@ -1219,26 +1263,37 @@ + /// Same canonical policy and complete retained/HDR accounting as protected submit. + /// Non-reserving estimate: submission still admits against the live pool. + pub fn admit_cpu_protected_partial_with_environment_and_options( +- &self, scene: &ProductScene, request: &ImageRequest, options: JobOptions, ++ &self, ++ scene: &ProductScene, ++ request: &ImageRequest, ++ options: JobOptions, + environment: Option<&crate::lighting::environment_input::EnvironmentInput>, + ) -> Result { + self.validate_submission_environment(scene, request, environment)?; + let policy = Self::protected_preview_policy(request)?; + let (mut admission, request_bytes) = self.admit_submission(scene, request, options, environment, Some(policy))?; +- admission.estimated_total_bytes = admission.estimated_total_bytes.checked_add(request_bytes) ++ admission.estimated_total_bytes = admission ++ .estimated_total_bytes ++ .checked_add(request_bytes) + .ok_or_else(|| JobError::new(ErrorCode::LimitExceeded, "retained request admission overflow"))?; + Ok(admission) + } + + fn protected_preview_policy(request: &ImageRequest) -> Result { +- let samples = request.raytrace.as_ref().and_then(|v| v.progressive) +- .ok_or_else(|| JobError::new(ErrorCode::InvalidRequest, "protected previews require CPU progressive intent"))?.samples_per_pixel; ++ let samples = request ++ .raytrace ++ .as_ref() ++ .and_then(|v| v.progressive) ++ .ok_or_else(|| JobError::new(ErrorCode::InvalidRequest, "protected previews require CPU progressive intent"))? ++ .samples_per_pixel; + let plan = super::ProtectedPreviewPlan::new(request.width, request.height, samples, request.cpu_budget())?; + Ok(CpuPreviewPolicy::Protected(plan)) + } + + fn validate_submission_environment( +- &self, scene: &ProductScene, request: &ImageRequest, ++ &self, ++ scene: &ProductScene, ++ request: &ImageRequest, + environment: Option<&crate::lighting::environment_input::EnvironmentInput>, + ) -> Result<()> { + if self.0.executor.is_some() && environment.is_some() { +@@ -1255,38 +1310,60 @@ + } + + fn admit_submission( +- &self, scene: &ProductScene, request: &ImageRequest, options: JobOptions, ++ &self, ++ scene: &ProductScene, ++ request: &ImageRequest, ++ options: JobOptions, + environment: Option<&crate::lighting::environment_input::EnvironmentInput>, + partial: Option, + ) -> Result<(Admission, u64)> { +- let metadata_bytes = (if environment.is_some() { +- std::mem::size_of::() as u64 +- } else { 0 }) + request.retained_resource_metadata_bytes(); +- let request_bytes = retained_request_bytes(request)?.checked_add(metadata_bytes) ++ let metadata_bytes = ++ (if environment.is_some() { std::mem::size_of::() as u64 } else { 0 }) ++ + request.retained_resource_metadata_bytes(); ++ let request_bytes = retained_request_bytes(request)? ++ .checked_add(metadata_bytes) + .ok_or_else(|| JobError::new(ErrorCode::LimitExceeded, "environment metadata overflow"))?; + let mut admission = self.admit_with_policy(scene, request, options, partial)?; +- let environment_bytes = environment.map_or(Ok(0), |value| value.required_bytes()) +- .map_err(|error| JobError::new(ErrorCode::InvalidRequest, error.to_string()))?; +- admission.estimated_total_bytes = admission.estimated_total_bytes.checked_add(environment_bytes) ++ let environment_bytes = ++ environment.map_or(Ok(0), |value| value.required_bytes()).map_err(|error| JobError::new(ErrorCode::InvalidRequest, error.to_string()))?; ++ admission.estimated_total_bytes = admission ++ .estimated_total_bytes ++ .checked_add(environment_bytes) + .ok_or_else(|| JobError::new(ErrorCode::LimitExceeded, "environment admission overflow"))?; +- admission.preparation_bytes = admission.preparation_bytes.checked_add(environment_bytes) ++ admission.preparation_bytes = admission ++ .preparation_bytes ++ .checked_add(environment_bytes) + .ok_or_else(|| JobError::new(ErrorCode::LimitExceeded, "environment admission overflow"))?; + self.check_request_sum(admission.estimated_total_bytes, request_bytes, request.cpu_budget())?; + Ok((admission, request_bytes)) + } + +- fn admit_with_policy(&self, scene: &ProductScene, request: &ImageRequest, options: JobOptions, partial: Option) -> Result { ++ fn admit_with_policy( ++ &self, ++ scene: &ProductScene, ++ request: &ImageRequest, ++ options: JobOptions, ++ partial: Option, ++ ) -> Result { + if let Some(policy) = partial { + let plan = policy.preview_plan(); +- if self.0.executor.is_some() || request.integrator != Integrator::Raytrace || request.transparent_background +- || request.environment.is_some() || request.textures.is_some() ++ if self.0.executor.is_some() ++ || request.integrator != Integrator::Raytrace ++ || request.transparent_background ++ || request.environment.is_some() ++ || request.textures.is_some() + || request.raytrace.as_ref().and_then(|v| v.progressive).is_none() +- || plan != super::PartialPreviewPlan::new(request.width, request.height)? { ++ || plan != super::PartialPreviewPlan::new(request.width, request.height)? ++ { + return Err(JobError::new(ErrorCode::InvalidRequest, "partial previews require the canonical builtin CPU progressive request")); + } + if let CpuPreviewPolicy::Protected(protected) = policy { +- let samples = request.raytrace.as_ref().and_then(|v| v.progressive) +- .ok_or_else(|| JobError::new(ErrorCode::InvalidRequest, "protected previews require a progressive sample target"))?.samples_per_pixel; ++ let samples = request ++ .raytrace ++ .as_ref() ++ .and_then(|v| v.progressive) ++ .ok_or_else(|| JobError::new(ErrorCode::InvalidRequest, "protected previews require a progressive sample target"))? ++ .samples_per_pixel; + protected.validate()?; + if protected != super::ProtectedPreviewPlan::new(request.width, request.height, samples, request.cpu_budget())? { + return Err(JobError::new(ErrorCode::InvalidRequest, "protected feedback plan does not match its admitted request")); +@@ -1348,10 +1425,17 @@ + if let Some(policy) = partial { + #[cfg(feature = "raytrace-cpu")] + { +- let raytrace = request.raytrace.as_ref().ok_or_else(|| JobError::new(ErrorCode::InvalidRequest, "partial previews require CPU progressive options"))?; ++ let raytrace = request ++ .raytrace ++ .as_ref() ++ .ok_or_else(|| JobError::new(ErrorCode::InvalidRequest, "partial previews require CPU progressive options"))?; + return match policy { +- CpuPreviewPolicy::Shared(plan) => crate::raytrace::image::admit_with_partial_preview(scene, request, raytrace, options.nested_media, plan), +- CpuPreviewPolicy::Protected(plan) => crate::raytrace::image::admit_with_protected_partial_preview(scene, request, raytrace, options.nested_media, plan), ++ CpuPreviewPolicy::Shared(plan) => { ++ crate::raytrace::image::admit_with_partial_preview(scene, request, raytrace, options.nested_media, plan) ++ } ++ CpuPreviewPolicy::Protected(plan) => { ++ crate::raytrace::image::admit_with_protected_partial_preview(scene, request, raytrace, options.nested_media, plan) ++ } + }; + } + #[cfg(not(feature = "raytrace-cpu"))] +@@ -1502,14 +1586,24 @@ + } + + pub fn submit_with_environment_and_options( +- &self, id: JobId, scene_generation: u64, scene: ProductScene, request: ImageRequest, options: JobOptions, ++ &self, ++ id: JobId, ++ scene_generation: u64, ++ scene: ProductScene, ++ request: ImageRequest, ++ options: JobOptions, + environment: Option, + ) -> Result { + self.submit_with_policy(Submission { id, scene_generation, scene, request, options, environment }, None) + } + /// Transient CPU presentation policy. Final request and legacy observers are unchanged. + pub fn submit_cpu_partial_with_environment_and_options( +- &self, id: JobId, scene_generation: u64, scene: ProductScene, request: ImageRequest, options: JobOptions, ++ &self, ++ id: JobId, ++ scene_generation: u64, ++ scene: ProductScene, ++ request: ImageRequest, ++ options: JobOptions, + environment: Option, + ) -> Result { + let plan = super::PartialPreviewPlan::new(request.width, request.height)?; +@@ -1517,7 +1611,12 @@ + } + /// Opt-in protected feedback preserves ordinary work while admitting a finite extra quota. + pub fn submit_cpu_protected_partial_with_environment_and_options( +- &self, id: JobId, scene_generation: u64, scene: ProductScene, request: ImageRequest, options: JobOptions, ++ &self, ++ id: JobId, ++ scene_generation: u64, ++ scene: ProductScene, ++ request: ImageRequest, ++ options: JobOptions, + environment: Option, + ) -> Result { + let policy = Self::protected_preview_policy(&request)?; +@@ -1578,10 +1677,12 @@ + self.check_request_sum(estimated_total_bytes, request_bytes, request.cpu_budget())?; + let mut reservation = self.0.shared.budget.reserve(estimated_total_bytes)?; + let request_reservation = if request_bytes == 0 { None } else { Some(self.0.shared.budget.reserve(request_bytes)?) }; +- let partial_credits = partial_plan.map(|policy| match policy { +- CpuPreviewPolicy::Shared(plan) => PartialCredits::new(plan, &mut reservation), +- CpuPreviewPolicy::Protected(plan) => PartialCredits::new_protected(plan, &mut reservation), +- }).transpose()?; ++ let partial_credits = partial_plan ++ .map(|policy| match policy { ++ CpuPreviewPolicy::Shared(plan) => PartialCredits::new(plan, &mut reservation), ++ CpuPreviewPolicy::Protected(plan) => PartialCredits::new_protected(plan, &mut reservation), ++ }) ++ .transpose()?; + // Preserve the original CPU option capacities in the retained request and its lease. + // Registered executors instead move resource Arcs into work and keep a small public copy. + let (public_request, work_request) = if self.0.executor.is_some() { +@@ -2109,7 +2210,9 @@ + /// Provisional source-film observation, separate from complete-pass previews. + #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize)] + #[serde(rename_all = "snake_case")] +-pub enum PartialPreviewProjection { TopLeftRepresentativeV1 } ++pub enum PartialPreviewProjection { ++ TopLeftRepresentativeV1, ++} + #[derive(Clone, Debug, Serialize)] + pub struct PartialPreviewInfo { + pub frame: FrameInfo, +@@ -2129,8 +2232,12 @@ + } + const _: [(); 1] = [(); (std::mem::size_of::() + 2 * crate::MAX_RENDER_ID_BYTES + 256 <= 2048) as usize]; + impl RenderPartialPreview { +- pub fn png(&self) -> &[u8] { &self.png } +- pub fn covered(&self) -> &[u16] { &self.covered } ++ pub fn png(&self) -> &[u8] { ++ &self.png ++ } ++ pub fn covered(&self) -> &[u16] { ++ &self.covered ++ } + } + struct PartialCreditState { + report: Option, +@@ -2146,7 +2253,9 @@ + exhausted: AtomicBool, + _metadata: Reservation, + } +-const _: [(); 1] = [(); (std::mem::size_of::() + std::mem::size_of::() + std::mem::size_of::>() + 128 <= 1024) as usize]; ++const _: [(); 1] = ++ [(); (std::mem::size_of::() + std::mem::size_of::() + std::mem::size_of::>() + 128 ++ <= 1024) as usize]; + impl PartialCredits { + fn new(plan: super::PartialPreviewPlan, reservation: &mut Reservation) -> Result> { + Self::new_with_protection(plan, None, reservation) +@@ -2155,13 +2264,18 @@ + plan.validate()?; + Self::new_with_protection(plan.preview_plan(), Some(plan), reservation) + } +- fn new_with_protection(plan: super::PartialPreviewPlan, protected: Option, reservation: &mut Reservation) -> Result> { ++ fn new_with_protection( ++ plan: super::PartialPreviewPlan, ++ protected: Option, ++ reservation: &mut Reservation, ++ ) -> Result> { + plan.validate()?; + let metadata = reservation.split(1024)?; + let bytes = plan.slot_bytes()?.checked_mul(2).ok_or_else(|| JobError::new(ErrorCode::LimitExceeded, "partial credit overflow"))?; + let free = reservation.split(bytes)?; + Ok(Arc::new(Self { +- plan, protected, ++ plan, ++ protected, + state: Mutex::new(PartialCreditState { report: None, free, in_flight: false, closed: false }), + requested: AtomicBool::new(false), + exhausted: AtomicBool::new(false), +@@ -2170,15 +2284,23 @@ + } + fn request(&self) -> Result { + let state = self.state.lock().map_err(|_| JobError::new(ErrorCode::Internal, "partial credit lock poisoned"))?; +- if state.closed || self.exhausted.load(Ordering::Acquire) { return Ok(false); } ++ if state.closed || self.exhausted.load(Ordering::Acquire) { ++ return Ok(false); ++ } + self.requested.store(true, Ordering::Release); + Ok(true) + } + fn acquire(self: &Arc) -> Result> { + let mut state = self.state.lock().map_err(|_| JobError::new(ErrorCode::Internal, "partial credit lock poisoned"))?; + let bytes = self.plan.slot_bytes()?; +- if state.closed || state.in_flight || self.exhausted.load(Ordering::Acquire) +- || !self.requested.load(Ordering::Acquire) || state.free.bytes < bytes { return Ok(None); } ++ if state.closed ++ || state.in_flight ++ || self.exhausted.load(Ordering::Acquire) ++ || !self.requested.load(Ordering::Acquire) ++ || state.free.bytes < bytes ++ { ++ return Ok(None); ++ } + let reservation = state.free.split(bytes)?; + state.in_flight = true; + self.requested.store(false, Ordering::Release); +@@ -2189,7 +2311,10 @@ + self.requested.store(false, Ordering::Release); + } + fn close(&self) { +- let mut state = match self.state.lock() { Ok(state) => state, Err(error) => error.into_inner() }; ++ let mut state = match self.state.lock() { ++ Ok(state) => state, ++ Err(error) => error.into_inner(), ++ }; + state.closed = true; + state.in_flight = false; + self.requested.store(false, Ordering::Release); +@@ -2226,12 +2351,20 @@ + state + } + }; +- if self.in_flight { state.in_flight = false; } ++ if self.in_flight { ++ state.in_flight = false; ++ } + if !state.closed { + let limit = self.credits.plan.slot_bytes().ok().and_then(|v| v.checked_mul(2)); + if state.free.bytes.checked_add(reservation.bytes).zip(limit).is_some_and(|(total, limit)| total <= limit) { +- if state.free.merge_from(&mut reservation).is_err() { state.closed = true; let _ = state.free.shrink(0); } +- } else { state.closed = true; let _ = state.free.shrink(0); } ++ if state.free.merge_from(&mut reservation).is_err() { ++ state.closed = true; ++ let _ = state.free.shrink(0); ++ } ++ } else { ++ state.closed = true; ++ let _ = state.free.shrink(0); ++ } + } + drop(state); + // A closed sink releases this uniquely held reservation globally. +@@ -2255,7 +2388,9 @@ + next_sequence: u64, + } + impl PartialRunning { +- fn new(credits: Arc) -> Self { Self { pending: None, lease: None, credits, next_sequence: 1 } } ++ fn new(credits: Arc) -> Self { ++ Self { pending: None, lease: None, credits, next_sequence: 1 } ++ } + } + impl JobHandle { + /// Real producer usage, unavailable until a protected task was actually constructed. +@@ -2268,7 +2403,9 @@ + /// Request presentation only; this is not a visual-authority certificate. + pub fn request_partial_preview(&self) -> Result { + let terminal = self.0.data.lock().map_err(|_| JobError::new(ErrorCode::Internal, "render status lock poisoned"))?.progress.phase.terminal(); +- if terminal { return Ok(false); } ++ if terminal { ++ return Ok(false); ++ } + self.0.partial.as_ref().map_or(Ok(false), |credits| credits.request()) + } + pub fn partial_preview_exhausted(&self) -> Result { +@@ -2290,20 +2427,33 @@ + let partial = self.partial.as_mut().ok_or_else(|| JobError::new(ErrorCode::Internal, "partial output without its policy"))?.get_mut()?; + let plan = partial.credits.plan; + let source_pixels = u64::from(plan.source_width()) * u64::from(plan.source_height()); +- let target = self.handle.0.request.raytrace.as_ref().and_then(|v| v.progressive) +- .ok_or_else(|| JobError::new(ErrorCode::Internal, "partial output without progressive intent"))?.samples_per_pixel; ++ let target = self ++ .handle ++ .0 ++ .request ++ .raytrace ++ .as_ref() ++ .and_then(|v| v.progressive) ++ .ok_or_else(|| JobError::new(ErrorCode::Internal, "partial output without progressive intent"))? ++ .samples_per_pixel; + let covered_limit = plan.covered_bytes()?; +- if partial.lease.is_none() || partial.pending.is_some() || completed_passes >= target || updated_prefix >= source_pixels +- || (completed_passes == 0 && updated_prefix == 0) || covered.len() as u64 != plan.pixels() ++ if partial.lease.is_none() ++ || partial.pending.is_some() ++ || completed_passes >= target ++ || updated_prefix >= source_pixels ++ || (completed_passes == 0 && updated_prefix == 0) ++ || covered.len() as u64 != plan.pixels() + || (covered.capacity() as u64).checked_mul(2).is_none_or(|v| v > covered_limit) +- || png.capacity() as u64 > plan.encoded_limit()? { ++ || png.capacity() as u64 > plan.encoded_limit()? ++ { + return Err(JobError::new(ErrorCode::LimitExceeded, "partial payload exceeds its admitted frontier or capacities")); + } + // This sole sidecar verification scan was included in the producer's precharge. + for (index, count) in covered.iter().enumerate() { + self.handle.0.cancel.check()?; + let source = plan.source_index(index)? as u64; +- let samples = completed_passes.checked_add(u32::from(source < updated_prefix)) ++ let samples = completed_passes ++ .checked_add(u32::from(source < updated_prefix)) + .ok_or_else(|| JobError::new(ErrorCode::LimitExceeded, "partial sample count overflow"))?; + if u32::from(*count) > samples { + return Err(JobError::new(ErrorCode::Internal, "partial coverage exceeds committed source samples")); +@@ -2323,21 +2473,39 @@ + let next = sequence.checked_add(1).ok_or_else(|| JobError::new(ErrorCode::LimitExceeded, "partial preview sequence exhausted"))?; + let plan = partial.credits.plan; + let info = FrameInfo { +- job: self.handle.0.id, scene_generation: self.handle.0.scene_generation, +- backend: self.handle.0.resolved.backend.clone(), executor: self.handle.0.resolved.executor.clone(), +- width: plan.width(), height: plan.height(), encoding: ColourEncoding::Srgb, alpha: AlphaConvention::Straight, +- png_bytes: publication.png.len() as u64, png_sha256: format!("{:x}", digest.finalize()), ++ job: self.handle.0.id, ++ scene_generation: self.handle.0.scene_generation, ++ backend: self.handle.0.resolved.backend.clone(), ++ executor: self.handle.0.resolved.executor.clone(), ++ width: plan.width(), ++ height: plan.height(), ++ encoding: ColourEncoding::Srgb, ++ alpha: AlphaConvention::Straight, ++ png_bytes: publication.png.len() as u64, ++ png_sha256: format!("{:x}", digest.finalize()), + }; +- let metadata = std::mem::size_of::().checked_add(64 + 2 * crate::MAX_RENDER_ID_BYTES) ++ let metadata = std::mem::size_of::() ++ .checked_add(64 + 2 * crate::MAX_RENDER_ID_BYTES) + .and_then(|v| v.checked_add(info.png_sha256.capacity())); +- if metadata.is_none_or(|v| v > 2048) { return Err(JobError::new(ErrorCode::LimitExceeded, "partial payload metadata exceeds its slot")); } ++ if metadata.is_none_or(|v| v > 2048) { ++ return Err(JobError::new(ErrorCode::LimitExceeded, "partial payload metadata exceeds its slot")); ++ } + // No Data lock while touching the credit coordinator. + publication.lease.published()?; + let PartialPublication { png, pending, lease } = publication; + let preview = Arc::new(RenderPartialPreview { +- info: PartialPreviewInfo { frame: info, sequence, source_width: plan.source_width(), source_height: plan.source_height(), +- completed_passes: pending.completed_passes, updated_prefix: pending.updated_prefix, projection: PartialPreviewProjection::TopLeftRepresentativeV1 }, +- png, covered: pending.covered, _lease: lease, ++ info: PartialPreviewInfo { ++ frame: info, ++ sequence, ++ source_width: plan.source_width(), ++ source_height: plan.source_height(), ++ completed_passes: pending.completed_passes, ++ updated_prefix: pending.updated_prefix, ++ projection: PartialPreviewProjection::TopLeftRepresentativeV1, ++ }, ++ png, ++ covered: pending.covered, ++ _lease: lease, + }); + let mut data = self.handle.0.data.lock().map_err(|_| JobError::new(ErrorCode::Internal, "render partial publication lock poisoned"))?; + if self.handle.0.cancel.is_cancelled() || data.progress.phase.terminal() { +@@ -2369,25 +2537,36 @@ + let aggregate = plan.aggregate_limit()?; + let expected_v = plan.snapshot_work()?.checked_mul(u64::from(report.accepted_snapshots)); + let used = report.ordinary_used.checked_add(report.presentation_used); +- if report.policy_version != 1 || report.ordinary_limit != plan.ordinary_limit() +- || report.presentation_limit != presentation || report.aggregate_limit != aggregate +- || report.quota_limit != plan.quota_limit() || report.ordinary_used > report.ordinary_limit +- || report.presentation_used > presentation || used.is_none_or(|v| v > aggregate) +- || expected_v != Some(report.presentation_used) || report.accepted_snapshots > report.next_milestone_index ++ if report.policy_version != 1 ++ || report.ordinary_limit != plan.ordinary_limit() ++ || report.presentation_limit != presentation ++ || report.aggregate_limit != aggregate ++ || report.quota_limit != plan.quota_limit() ++ || report.ordinary_used > report.ordinary_limit ++ || report.presentation_used > presentation ++ || used.is_none_or(|v| v > aggregate) ++ || expected_v != Some(report.presentation_used) ++ || report.accepted_snapshots > report.next_milestone_index + || report.next_milestone_index > report.quota_limit + || report.quota_exhausted != (report.accepted_snapshots == report.quota_limit) +- || report.milestones_complete != (report.next_milestone_index == report.quota_limit) { ++ || report.milestones_complete != (report.next_milestone_index == report.quota_limit) ++ { + return Err(JobError::new(ErrorCode::Internal, "protected work report violates its actual admission")); + } + let mut state = self.state.lock().map_err(|_| JobError::new(ErrorCode::Internal, "protected report lock poisoned"))?; +- if state.report.is_some_and(|previous| previous.ordinary_used > report.ordinary_used +- || previous.presentation_used > report.presentation_used || previous.accepted_snapshots > report.accepted_snapshots +- || previous.next_milestone_index > report.next_milestone_index) { ++ if state.report.is_some_and(|previous| { ++ previous.ordinary_used > report.ordinary_used ++ || previous.presentation_used > report.presentation_used ++ || previous.accepted_snapshots > report.accepted_snapshots ++ || previous.next_milestone_index > report.next_milestone_index ++ }) { + drop(state); + return Err(JobError::new(ErrorCode::Internal, "protected work report counters moved backwards")); + } + state.report = Some(report); +- if report.quota_exhausted { self.exhaust(); } ++ if report.quota_exhausted { ++ self.exhaust(); ++ } + Ok(()) + } + } +@@ -2400,7 +2579,9 @@ + make_slot: impl FnOnce(crate::raytrace::image::ImageTask) -> Result>, + ) -> Result { + // ImageTask is already real, even if its host wrapper cannot be allocated. +- if let Some(credits) = report_sink { credits.store_report(task.protected_preview_report())?; } ++ if let Some(credits) = report_sink { ++ credits.store_report(task.protected_preview_report())?; ++ } + make_slot(task).map(Self::Raytrace) + } + } +--- a/crates/render/src/job/image_tests.rs ++++ b/crates/render/src/job/image_tests.rs +@@ -280,11 +280,7 @@ + // raster shading branch to interpolate world coordinates for the other. + #[test] + fn weighted_scalar_perspective_uses_closed_form_ray_plane_world_with_unequal_clip_w() { +- let vertices = [ +- Vec3::new(-7.0 / 4.0, -8.0, 7.0 / 4.0), +- Vec3::new(1.0 / 2.0, -6.0, 7.0 / 2.0), +- Vec3::new(-3.0, -2.0, -1.0), +- ]; ++ let vertices = [Vec3::new(-7.0 / 4.0, -8.0, 7.0 / 4.0), Vec3::new(1.0 / 2.0, -6.0, 7.0 / 2.0), Vec3::new(-3.0, -2.0, -1.0)]; + // The reversed winding faces the eye. This smooth normal is in the + // geometric hemisphere and deliberately separates the three view oracles. + let normal = Vec3::new(3.0, 1.0, 0.0) / 10.0_f64.sqrt(); +@@ -306,15 +302,8 @@ + let mut input = request(); + input.width = 4; + input.height = 4; +- input.camera = Camera { +- target: Vec3::ZERO, +- yaw: 0.0, +- pitch: 0.0, +- roll: 0.0, +- distance: 10.0, +- fov: std::f64::consts::FRAC_PI_2, +- up: crate::UpAxis::Z, +- }; ++ input.camera = ++ Camera { target: Vec3::ZERO, yaw: 0.0, pitch: 0.0, roll: 0.0, distance: 10.0, fov: std::f64::consts::FRAC_PI_2, up: crate::UpAxis::Z }; + input.transparent_background = false; + let light_weights = [1.0, 0.35, 0.8]; + input.studio_weights = Some(light_weights); +@@ -399,4 +388,3 @@ + assert_eq!((image.width(), image.height()), (4, 4)); + assert_eq!(image.get_pixel(3, 3).0, [20, 40, 60, 255]); + } +- +--- a/crates/render/src/job/mod.rs ++++ b/crates/render/src/job/mod.rs +@@ -896,10 +896,7 @@ + // sample before film accumulation. Anisotropic progressive transport + // remains unsupported; geometry/identity certificates run at capture. + if self.anisotropic_faces.iter().any(Option::is_some) { +- return Err(JobError::new( +- ErrorCode::InvalidRequest, +- "CPU progressive does not support anisotropic inputs; use fixed sampling", +- )); ++ return Err(JobError::new(ErrorCode::InvalidRequest, "CPU progressive does not support anisotropic inputs; use fixed sampling")); + } + } + if self.environment.is_some_and(|environment| { +--- a/crates/render/src/job/photographic.rs ++++ b/crates/render/src/job/photographic.rs +@@ -543,8 +543,7 @@ + let pre_cancelled = CancelToken::default(); + pre_cancelled.cancel(); + assert_eq!( +- PhotographicTask::new_with_limits(3, 2, rgba.clone(), linear.clone(), options, pre_cancelled, GPU_PATH_LIMITS) +- .err().unwrap().code, ++ PhotographicTask::new_with_limits(3, 2, rgba.clone(), linear.clone(), options, pre_cancelled, GPU_PATH_LIMITS).err().unwrap().code, + ErrorCode::Cancelled, + ); + let cancel = CancelToken::default(); +@@ -565,8 +564,7 @@ + let cancel = CancelToken::default(); + let options = Photographic { soft_focus: 0.5, ..Default::default() }; + let rgba = vec![64, 128, 192, 255]; +- let mut state = PhotographicState::new(1, 1, rgba.clone(), vec![[0.1, 0.5, 2.0, 1.0]], options, cancel.clone(), GPU_PATH_LIMITS) +- .unwrap(); ++ let mut state = PhotographicState::new(1, 1, rgba.clone(), vec![[0.1, 0.5, 2.0, 1.0]], options, cancel.clone(), GPU_PATH_LIMITS).unwrap(); + let before_commit = state.progress(); + assert_eq!(before_commit, (0, 1)); + // Local commit-seam unit: valid bytes stand for the completed final +@@ -585,9 +583,8 @@ + let cancel = CancelToken::default(); + let options = Photographic { soft_focus: 0.5, ..Default::default() }; + let rgba = vec![64, 128, 192, 255]; +- let mut task = PhotographicTask::new_with_limits( +- 1, 1, rgba.clone(), vec![[0.1, 0.5, 2.0, 1.0]], options, cancel.clone(), GPU_PATH_LIMITS, +- ).unwrap(); ++ let mut task = ++ PhotographicTask::new_with_limits(1, 1, rgba.clone(), vec![[0.1, 0.5, 2.0, 1.0]], options, cancel.clone(), GPU_PATH_LIMITS).unwrap(); + assert!(task.step(1).unwrap(), "the real step must acknowledge completion first"); + assert_eq!(task.progress(), (1, 1)); + cancel.cancel(); diff --git a/proposals/render/2026-10-30/c16-defaults-auto-result/c15-postformat-delta-02.patch b/proposals/render/2026-10-30/c16-defaults-auto-result/c15-postformat-delta-02.patch new file mode 100644 index 000000000..e66d00392 --- /dev/null +++ b/proposals/render/2026-10-30/c16-defaults-auto-result/c15-postformat-delta-02.patch @@ -0,0 +1,1444 @@ +--- a/crates/render/src/raytrace/image_tests.rs ++++ b/crates/render/src/raytrace/image_tests.rs +@@ -1671,7 +1671,6 @@ + } + } + +- + // Progressive smooth-optics unit: original tests WRITTEN, NOT COMPILED OR RUN. + pub(super) fn progressive_optics_source( + boundary: job::DielectricBoundary, +@@ -1718,10 +1717,14 @@ + let target = task.options.progressive.unwrap().samples_per_pixel; + for _ in 0..2_000_000 { + if let Some(progressive) = &task.progressive +- && progressive.film.ready() && progressive.film.samples() == target ++ && progressive.film.ready() ++ && progressive.film.samples() == target + { +- film.get_or_insert_with(|| (0..task.request.width as usize * task.request.height as usize) +- .map(|pixel| progressive.film.pixel(pixel).unwrap().0.map(f64::to_bits)).collect()); ++ film.get_or_insert_with(|| { ++ (0..task.request.width as usize * task.request.height as usize) ++ .map(|pixel| progressive.film.pixel(pixel).unwrap().0.map(f64::to_bits)) ++ .collect() ++ }); + } + let poll = task.step_with_previews(quantum).unwrap(); + if let Some(state) = task.optical.first().and_then(|o| o.pending.as_ref()) { +@@ -1734,8 +1737,11 @@ + assert_eq!(state.path.boundaries, 0); + let origin = state.path.ray.origin(); + let direction = state.path.ray.direction(); +- primaries.push((identity.0, identity.1, [origin.x.to_bits(), origin.y.to_bits(), origin.z.to_bits(), +- direction.x.to_bits(), direction.y.to_bits(), direction.z.to_bits()])); ++ primaries.push(( ++ identity.0, ++ identity.1, ++ [origin.x.to_bits(), origin.y.to_bits(), origin.z.to_bits(), direction.x.to_bits(), direction.y.to_bits(), direction.z.to_bits()], ++ )); + previous_sample = Some(identity); + } + } +@@ -1839,8 +1845,10 @@ + request.camera.distance = 6.0; + request.camera.fov = 0.0; + assert!(admit(&scene, &request, &options).is_err()); +- let run = finish_optical_progressive(ImageTask::new_with_environment_and_nested( +- scene, request, CancelToken::default(), options, None, true).unwrap(), 1); ++ let run = finish_optical_progressive( ++ ImageTask::new_with_environment_and_nested(scene, request, CancelToken::default(), options, None, true).unwrap(), ++ 1, ++ ); + for (actual, exponent) in run.film[0].into_iter().zip([-0.8_f64, -1.2, 0.0]) { + assert!((f64::from_bits(actual) - exponent.exp()).abs() < 1e-10); + } +@@ -1881,7 +1889,11 @@ + assert!(task.work.used() - before <= 1); + if task.optical.first().and_then(|o| o.pending.as_ref()).is_some_and(|s| s.path.medium.is_some()) { + let frontier = task.progressive.as_ref().unwrap().film.partial_frontier().unwrap(); +- if cancel { task.cancel.cancel(); } else { task.work.limit = task.work.used(); } ++ if cancel { ++ task.cancel.cancel(); ++ } else { ++ task.work.limit = task.work.used(); ++ } + assert_eq!(task.step_with_previews(1).err().unwrap().code, if cancel { ErrorCode::Cancelled } else { ErrorCode::LimitExceeded }); + assert_eq!(task.progressive.as_ref().unwrap().film.partial_frontier().unwrap(), frontier); + assert!(!task.done); +@@ -1951,17 +1963,19 @@ + for _ in 0..100_000 { + assert!(matches!(task.step_with_previews(1).unwrap(), ImagePoll::Pending(_))); + let Some(state) = task.optical.first().and_then(|o| o.pending.as_ref()) else { continue }; +- if state.path.boundaries == 0 { incident = Some(state.path.ray.direction()); } ++ if state.path.boundaries == 0 { ++ incident = Some(state.path.ray.direction()); ++ } + if state.path.boundaries == 1 && state.path.medium == Some(0) { + let d = incident.unwrap(); + let tx = d.x / 1.5; + let ty = d.y / 1.5; +- let tz = -(1.0 - tx*tx - ty*ty).sqrt(); +- assert!((state.path.ray.direction() - Vec3::new(tx,ty,tz)).len() < 1e-12); +- entry = Some((state.path.segment_start,state.path.throughput,tz)); ++ let tz = -(1.0 - tx * tx - ty * ty).sqrt(); ++ assert!((state.path.ray.direction() - Vec3::new(tx, ty, tz)).len() < 1e-12); ++ entry = Some((state.path.segment_start, state.path.throughput, tz)); + } + if state.path.boundaries == 2 && state.path.medium.is_none() { +- let (point,throughput,tz) = entry.unwrap(); ++ let (point, throughput, tz) = entry.unwrap(); + let distance = 2.0 / -tz; + assert!((state.path.segment_start.dist(point) - distance).abs() < 1e-10); + assert!((state.path.ray.direction() - incident.unwrap()).len() < 1e-12); +@@ -1978,20 +1992,22 @@ + #[test] + fn progressive_nested_optics_still_refuse_contacts_and_interior_cameras() { + let (mut scene, mut options) = dielectric::tests::nested_fixture(false); +- options.progressive = Some(job::CpuProgressiveOptions { samples_per_pixel:3, seed:19 }); ++ options.progressive = Some(job::CpuProgressiveOptions { samples_per_pixel: 3, seed: 19 }); + let request = dielectric::tests::request(options.clone()); +- for point in &mut std::sync::Arc::make_mut(&mut scene.meshes[1].mesh).positions { point.z += 1.0; } +- assert!(admit_with_nested(&scene,&request,&options,true).is_err(), "inner top touches outer top"); +- let (scene, mut request, options) = progressive_optics_source(job::DielectricBoundary::ClosedBox,2.0,1.5,3); +- request.camera.target = Vec3::new(0.0,0.0,1.0); ++ for point in &mut std::sync::Arc::make_mut(&mut scene.meshes[1].mesh).positions { ++ point.z += 1.0; ++ } ++ assert!(admit_with_nested(&scene, &request, &options, true).is_err(), "inner top touches outer top"); ++ let (scene, mut request, options) = progressive_optics_source(job::DielectricBoundary::ClosedBox, 2.0, 1.5, 3); ++ request.camera.target = Vec3::new(0.0, 0.0, 1.0); + request.camera.distance = 0.1; +- let mut task = ImageTask::new(scene,request,CancelToken::default(),options).unwrap(); ++ let mut task = ImageTask::new(scene, request, CancelToken::default(), options).unwrap(); + for _ in 0..100_000 { + match task.step_with_previews(1) { + Err(error) => { +- assert_eq!(error.code,ErrorCode::InvalidScene); ++ assert_eq!(error.code, ErrorCode::InvalidScene); + assert!(error.message.contains("inside a dielectric")); +- assert_eq!(task.progressive.as_ref().unwrap().film.samples(),0); ++ assert_eq!(task.progressive.as_ref().unwrap().film.samples(), 0); + assert!(!task.done); + return; + } +@@ -2001,216 +2017,234 @@ + } + panic!("interior progressive camera not refused"); + } +- + + // Original regression implementation guided by Kernel Specialist's analytic + // identity-shell counterexample (FINDING5282bf86 / proposal dae7f679). SOURCE + // ONLY, WRITTEN NOT RUN; expectations are physical, never recorded output. +-pub(super) fn straight_identity_shells_source(count:usize,progressive:bool,absorbing:bool) -> (ProductScene,ImageRequest,RaytraceOptions) { ++pub(super) fn straight_identity_shells_source(count: usize, progressive: bool, absorbing: bool) -> (ProductScene, ImageRequest, RaytraceOptions) { + assert!((1..=8).contains(&count)); +- let mut meshes=Vec::with_capacity(8); +- let mut dielectrics=Vec::with_capacity(8); ++ let mut meshes = Vec::with_capacity(8); ++ let mut dielectrics = Vec::with_capacity(8); + for index in 0..count { +- let h=(count-index) as f64; +- let mut body=dielectric::tests::box_body(2.0*h); +- body.name=format!("Straight identity shell {index}"); ++ let h = (count - index) as f64; ++ let mut body = dielectric::tests::box_body(2.0 * h); ++ body.name = format!("Straight identity shell {index}"); + for point in &mut std::sync::Arc::make_mut(&mut body.mesh).positions { +- *point=Vec3::new(if point.x<0.0 {-(16.0+h)} else {16.0+h}, +- if point.y<0.0 {-(16.0+h)} else {16.0+h},point.z-h); +- } +- let sigma=if absorbing {0.01*(index+1) as f64} else {0.0}; +- dielectrics.push(job::DielectricOptions {body_index:index,body_name:body.name.clone(), +- boundary:job::DielectricBoundary::ClosedBox,ior:1.0, +- absorption_per_mm:[sigma,2.0*sigma,0.0],thickness_mm:0.0}); ++ *point = Vec3::new(if point.x < 0.0 { -(16.0 + h) } else { 16.0 + h }, if point.y < 0.0 { -(16.0 + h) } else { 16.0 + h }, point.z - h); ++ } ++ let sigma = if absorbing { 0.01 * (index + 1) as f64 } else { 0.0 }; ++ dielectrics.push(job::DielectricOptions { ++ body_index: index, ++ body_name: body.name.clone(), ++ boundary: job::DielectricBoundary::ClosedBox, ++ ior: 1.0, ++ absorption_per_mm: [sigma, 2.0 * sigma, 0.0], ++ thickness_mm: 0.0, ++ }); + meshes.push(body); + } +- assert!(dielectrics.capacity()<=8); +- let bounds=meshes.iter().fold(Aabb3::EMPTY,|a,body|a.union(&body.mesh.bounds())); +- let options=RaytraceOptions { ++ assert!(dielectrics.capacity() <= 8); ++ let bounds = meshes.iter().fold(Aabb3::EMPTY, |a, body| a.union(&body.mesh.bounds())); ++ let options = RaytraceOptions { + dielectrics, +- progressive:progressive.then_some(job::CpuProgressiveOptions {samples_per_pixel:3,seed:71}), +- lights:Some(Vec::new()),shadows:false, +- environment:Some(job::RaytraceEnvironmentOptions {color:[1.0;3],intensity:1.0}), ++ progressive: progressive.then_some(job::CpuProgressiveOptions { samples_per_pixel: 3, seed: 71 }), ++ lights: Some(Vec::new()), ++ shadows: false, ++ environment: Some(job::RaytraceEnvironmentOptions { color: [1.0; 3], intensity: 1.0 }), + ..Default::default() + }; +- let mut request=dielectric::tests::request(options.clone()); +- request.background=[188;3]; +- request.camera.target=Vec3::ZERO; +- request.camera.distance=20.0; +- request.camera.yaw=0.0; +- request.camera.pitch=std::f64::consts::FRAC_PI_2; +- request.camera.fov=0.0; +- (ProductScene {meshes,bounds},request,options) +-} +- +-pub(super) fn straight_shells_expected_linear(count:usize,absorbing:bool) -> [f64;3] { ++ let mut request = dielectric::tests::request(options.clone()); ++ request.background = [188; 3]; ++ request.camera.target = Vec3::ZERO; ++ request.camera.distance = 20.0; ++ request.camera.yaw = 0.0; ++ request.camera.pitch = std::f64::consts::FRAC_PI_2; ++ request.camera.fov = 0.0; ++ (ProductScene { meshes, bounds }, request, options) ++} ++ ++pub(super) fn straight_shells_expected_linear(count: usize, absorbing: bool) -> [f64; 3] { + // Each shell's active parent interval totals2mm, including the innermost + // 2mm slab. Sum 2*.01*(1+...+N)=.01*N*(N+1); green doubles sigma. +- let tau=if absorbing {0.01*(count*(count+1)) as f64} else {0.0}; +- [(-tau).exp(),(-2.0*tau).exp(),1.0] +-} +- +-pub(super) fn straight_expected_pixel(linear:[f64;3]) -> [u8;4] { ++ let tau = if absorbing { 0.01 * (count * (count + 1)) as f64 } else { 0.0 }; ++ [(-tau).exp(), (-2.0 * tau).exp(), 1.0] ++} ++ ++pub(super) fn straight_expected_pixel(linear: [f64; 3]) -> [u8; 4] { + // Independent documented zero-EV Reinhard and IEC sRGB equations, not the + // renderer's compositor/map_to_display/encode8 or a prior output capture. +- let rgb=linear.map(|v| { +- let mapped=v/(1.0+v); +- let encoded=if mapped<=0.0031308 {12.92*mapped} else {1.055*mapped.powf(1.0/2.4)-0.055}; +- (encoded*255.0+0.5).floor() as u8 ++ let rgb = linear.map(|v| { ++ let mapped = v / (1.0 + v); ++ let encoded = if mapped <= 0.0031308 { 12.92 * mapped } else { 1.055 * mapped.powf(1.0 / 2.4) - 0.055 }; ++ (encoded * 255.0 + 0.5).floor() as u8 + }); +- [rgb[0],rgb[1],rgb[2],255] +-} +- +-fn complete_straight_shells(mut task:ImageTask,expected_crossings:u8,expected_linear:[f64;3]) -> Vec { +- let progressive=task.options.progressive; +- let mut final_linear=None; +- let mut maximum=0; +- let mut final_png=None; +- assert_eq!(task.optical.first().unwrap().straight_limit,Some(expected_crossings)); ++ [rgb[0], rgb[1], rgb[2], 255] ++} ++ ++fn complete_straight_shells(mut task: ImageTask, expected_crossings: u8, expected_linear: [f64; 3]) -> Vec { ++ let progressive = task.options.progressive; ++ let mut final_linear = None; ++ let mut maximum = 0; ++ let mut final_png = None; ++ assert_eq!(task.optical.first().unwrap().straight_limit, Some(expected_crossings)); + for _ in 0..1_000_000 { +- if let Some(p)=&task.progressive && p.film.ready() && p.film.samples()==progressive.unwrap().samples_per_pixel { +- let (rgb,covered,samples)=p.film.pixel(0).unwrap(); +- assert_eq!((covered,samples),(3,3)); +- final_linear=Some(rgb); +- } +- let before=task.work.used(); +- let poll=task.step_with_previews(1).unwrap(); ++ if let Some(p) = &task.progressive ++ && p.film.ready() ++ && p.film.samples() == progressive.unwrap().samples_per_pixel ++ { ++ let (rgb, covered, samples) = p.film.pixel(0).unwrap(); ++ assert_eq!((covered, samples), (3, 3)); ++ final_linear = Some(rgb); ++ } ++ let before = task.work.used(); ++ let poll = task.step_with_previews(1).unwrap(); + // PNG row/hash charges are the unchanged resolve contract. During + // optical traversal/interface stages one unit cannot overspend. +- if let Some(state)=task.optical.first().and_then(|o|o.pending.as_ref()) { +- assert!(task.work.used()-before<=1); +- assert_eq!(state.stack_len,0,"zero Fresnel reflection creates no pending branch"); +- assert_eq!(state.paths,u16::from(state.path.boundaries)+1); +- maximum=maximum.max(state.path.boundaries); ++ if let Some(state) = task.optical.first().and_then(|o| o.pending.as_ref()) { ++ assert!(task.work.used() - before <= 1); ++ assert_eq!(state.stack_len, 0, "zero Fresnel reflection creates no pending branch"); ++ assert_eq!(state.paths, u16::from(state.path.boundaries) + 1); ++ maximum = maximum.max(state.path.boundaries); + } + match poll { +- ImagePoll::Pending(_)=>{}, +- ImagePoll::Preview {png,..}=>{ +- assert_eq!(::image::load_from_memory(&png).unwrap().to_rgba8().get_pixel(0,0).0,straight_expected_pixel(expected_linear)); ++ ImagePoll::Pending(_) => {} ++ ImagePoll::Preview { png, .. } => { ++ assert_eq!(::image::load_from_memory(&png).unwrap().to_rgba8().get_pixel(0, 0).0, straight_expected_pixel(expected_linear)); + assert!(task.optical.first().unwrap().pending.is_none()); +- }, +- ImagePoll::Complete(png)=>{final_png=Some(png);break;} +- } +- } +- assert_eq!(maximum,expected_crossings,"every real geometric interface was traversed"); ++ } ++ ImagePoll::Complete(png) => { ++ final_png = Some(png); ++ break; ++ } ++ } ++ } ++ assert_eq!(maximum, expected_crossings, "every real geometric interface was traversed"); + if progressive.is_some() { +- for (actual,expected) in final_linear.unwrap().into_iter().zip(expected_linear) { +- assert!((actual-expected).abs()<1e-11,"physical parent-only Beer path length"); +- } +- } +- let png=final_png.expect("certified finite straight path must complete"); +- assert_eq!(::image::load_from_memory(&png).unwrap().to_rgba8().get_pixel(0,0).0,straight_expected_pixel(expected_linear)); ++ for (actual, expected) in final_linear.unwrap().into_iter().zip(expected_linear) { ++ assert!((actual - expected).abs() < 1e-11, "physical parent-only Beer path length"); ++ } ++ } ++ let png = final_png.expect("certified finite straight path must complete"); ++ assert_eq!(::image::load_from_memory(&png).unwrap().to_rgba8().get_pixel(0, 0).0, straight_expected_pixel(expected_linear)); + png + } + + #[test] + fn straight_identity_shells_four_control_five_minimum_and_eight_maximum_reach_environment() { +- for progressive in [false,true] { +- for count in [4,5,8] { +- let (scene,request,options)=straight_identity_shells_source(count,progressive,false); ++ for progressive in [false, true] { ++ for count in [4, 5, 8] { ++ let (scene, request, options) = straight_identity_shells_source(count, progressive, false); + options.validate().unwrap(); +- assert!(admit(&scene,&request,&options).is_err(),"nesting still requires explicit opt-in"); +- admit_with_nested(&scene,&request,&options,true).unwrap(); +- let task=ImageTask::new_with_environment_and_nested(scene,request,CancelToken::default(),options,None,true).unwrap(); +- let png=complete_straight_shells(task,(2*count) as u8,[1.0;3]); +- assert_eq!(::image::load_from_memory(&png).unwrap().to_rgba8().get_pixel(0,0).0,[188,188,188,255]); ++ assert!(admit(&scene, &request, &options).is_err(), "nesting still requires explicit opt-in"); ++ admit_with_nested(&scene, &request, &options, true).unwrap(); ++ let task = ImageTask::new_with_environment_and_nested(scene, request, CancelToken::default(), options, None, true).unwrap(); ++ let png = complete_straight_shells(task, (2 * count) as u8, [1.0; 3]); ++ assert_eq!(::image::load_from_memory(&png).unwrap().to_rgba8().get_pixel(0, 0).0, [188, 188, 188, 255]); + } + } + } + + #[test] + fn straight_identity_shells_keep_actual_beer_parent_intervals_past_eight_crossings() { +- for progressive in [false,true] { +- for count in [4,5,8] { +- let (scene,request,options)=straight_identity_shells_source(count,progressive,true); +- let task=ImageTask::new_with_environment_and_nested(scene,request,CancelToken::default(),options,None,true).unwrap(); +- let _=complete_straight_shells(task,(2*count) as u8,straight_shells_expected_linear(count,true)); ++ for progressive in [false, true] { ++ for count in [4, 5, 8] { ++ let (scene, request, options) = straight_identity_shells_source(count, progressive, true); ++ let task = ImageTask::new_with_environment_and_nested(scene, request, CancelToken::default(), options, None, true).unwrap(); ++ let _ = complete_straight_shells(task, (2 * count) as u8, straight_shells_expected_linear(count, true)); + } + } + } + + #[test] + fn straight_mixed_certificates_derive_two_per_box_and_one_per_sheet_without_extra_stack() { +- let (mut scene,mut request,mut options)=straight_identity_shells_source(5,true,false); ++ let (mut scene, mut request, mut options) = straight_identity_shells_source(5, true, false); + for index in 0..3 { +- let name=format!("Straight external sheet {index}"); +- let body_index=scene.meshes.len(); +- scene.meshes.push(optical_sheet(&name,0.0,6.0+index as f64)); +- options.dielectrics.push(optical_input(body_index,&name,1.0)); +- } +- assert_eq!(options.dielectrics.len(),8); +- assert!(options.dielectrics.capacity()<=8); +- scene.bounds=scene.meshes.iter().fold(Aabb3::EMPTY,|a,body|a.union(&body.mesh.bounds())); +- request.raytrace=Some(options.clone()); +- let task=ImageTask::new_with_environment_and_nested(scene,request,CancelToken::default(),options,None,true).unwrap(); +- let _=complete_straight_shells(task,13,[1.0;3]); ++ let name = format!("Straight external sheet {index}"); ++ let body_index = scene.meshes.len(); ++ scene.meshes.push(optical_sheet(&name, 0.0, 6.0 + index as f64)); ++ options.dielectrics.push(optical_input(body_index, &name, 1.0)); ++ } ++ assert_eq!(options.dielectrics.len(), 8); ++ assert!(options.dielectrics.capacity() <= 8); ++ scene.bounds = scene.meshes.iter().fold(Aabb3::EMPTY, |a, body| a.union(&body.mesh.bounds())); ++ request.raytrace = Some(options.clone()); ++ let task = ImageTask::new_with_environment_and_nested(scene, request, CancelToken::default(), options, None, true).unwrap(); ++ let _ = complete_straight_shells(task, 13, [1.0; 3]); + } + + #[test] + fn straight_policy_requires_exact_unit_indices_and_no_selected_opaque_reflector() { +- assert_eq!(MAX_BOUNDARIES,8); +- assert_eq!(MAX_PATHS,511); +- let (scene,request,options)=straight_identity_shells_source(5,false,false); +- for ior in [1.0_f64.next_up(),1.5] { +- let mut changed=options.clone(); +- changed.dielectrics[2].ior=ior; +- let request=ImageRequest {raytrace:Some(changed.clone()),..request.clone()}; +- let task=ImageTask::new_with_environment_and_nested(scene.clone(),request,CancelToken::default(),changed,None,true).unwrap(); +- assert_eq!(task.optical.first().unwrap().straight_limit,None,"no epsilon-index shortcut or new rejection of legacy refracting input"); +- } +- let mut scene=scene; +- let mut changed=options; +- scene.meshes.push(optical_sheet("Separate opaque reflector",100.0,0.0)); +- scene.bounds=scene.meshes.iter().fold(Aabb3::EMPTY,|a,body|a.union(&body.mesh.bounds())); +- changed.reflections=Some(job::ReflectionOptions {bodies:vec![job::ReflectionBody {body:"Separate opaque reflector".into(),mode:job::ReflectionMode::Mirror}],max_bounces:1,samples:1}); +- let request=ImageRequest {raytrace:Some(changed.clone()),..request}; +- let task=ImageTask::new_with_environment_and_nested(scene,request,CancelToken::default(),changed,None,true).unwrap(); +- assert_eq!(task.optical.first().unwrap().straight_limit,None); ++ assert_eq!(MAX_BOUNDARIES, 8); ++ assert_eq!(MAX_PATHS, 511); ++ let (scene, request, options) = straight_identity_shells_source(5, false, false); ++ for ior in [1.0_f64.next_up(), 1.5] { ++ let mut changed = options.clone(); ++ changed.dielectrics[2].ior = ior; ++ let request = ImageRequest { raytrace: Some(changed.clone()), ..request.clone() }; ++ let task = ImageTask::new_with_environment_and_nested(scene.clone(), request, CancelToken::default(), changed, None, true).unwrap(); ++ assert_eq!(task.optical.first().unwrap().straight_limit, None, "no epsilon-index shortcut or new rejection of legacy refracting input"); ++ } ++ let mut scene = scene; ++ let mut changed = options; ++ scene.meshes.push(optical_sheet("Separate opaque reflector", 100.0, 0.0)); ++ scene.bounds = scene.meshes.iter().fold(Aabb3::EMPTY, |a, body| a.union(&body.mesh.bounds())); ++ changed.reflections = Some(job::ReflectionOptions { ++ bodies: vec![job::ReflectionBody { body: "Separate opaque reflector".into(), mode: job::ReflectionMode::Mirror }], ++ max_bounces: 1, ++ samples: 1, ++ }); ++ let request = ImageRequest { raytrace: Some(changed.clone()), ..request }; ++ let task = ImageTask::new_with_environment_and_nested(scene, request, CancelToken::default(), changed, None, true).unwrap(); ++ assert_eq!(task.optical.first().unwrap().straight_limit, None); + assert!(task.optical.first().unwrap().pending.is_none()); + } + + #[test] + fn straight_identity_transport_still_charges_and_can_cancel_or_exhaust_inside_deep_chain() { +- for cancel in [false,true] { +- let (scene,request,options)=straight_identity_shells_source(8,true,true); +- let mut task=ImageTask::new_with_environment_and_nested(scene,request,CancelToken::default(),options,None,true).unwrap(); +- let mut observed=false; ++ for cancel in [false, true] { ++ let (scene, request, options) = straight_identity_shells_source(8, true, true); ++ let mut task = ImageTask::new_with_environment_and_nested(scene, request, CancelToken::default(), options, None, true).unwrap(); ++ let mut observed = false; + for _ in 0..200_000 { +- let before=task.work.used(); +- assert!(matches!(task.step_with_previews(1).unwrap(),ImagePoll::Pending(_))); +- assert!(task.work.used()-before<=1); +- if task.optical.first().and_then(|o|o.pending.as_ref()).is_some_and(|s|s.path.boundaries==9) { +- let frontier=task.progressive.as_ref().unwrap().film.partial_frontier().unwrap(); +- if cancel {task.cancel.cancel();} else {task.work.limit=task.work.used();} +- assert_eq!(task.step_with_previews(1).err().unwrap().code,if cancel {ErrorCode::Cancelled} else {ErrorCode::LimitExceeded}); +- assert_eq!(task.progressive.as_ref().unwrap().film.partial_frontier().unwrap(),frontier); ++ let before = task.work.used(); ++ assert!(matches!(task.step_with_previews(1).unwrap(), ImagePoll::Pending(_))); ++ assert!(task.work.used() - before <= 1); ++ if task.optical.first().and_then(|o| o.pending.as_ref()).is_some_and(|s| s.path.boundaries == 9) { ++ let frontier = task.progressive.as_ref().unwrap().film.partial_frontier().unwrap(); ++ if cancel { ++ task.cancel.cancel(); ++ } else { ++ task.work.limit = task.work.used(); ++ } ++ assert_eq!(task.step_with_previews(1).err().unwrap().code, if cancel { ErrorCode::Cancelled } else { ErrorCode::LimitExceeded }); ++ assert_eq!(task.progressive.as_ref().unwrap().film.partial_frontier().unwrap(), frontier); + assert!(!task.done); +- observed=true; ++ observed = true; + break; + } + } +- assert!(observed,"real ninth crossing must be reached before the stop"); ++ assert!(observed, "real ninth crossing must be reached before the stop"); + } + } + + #[test] + fn straight_crossing_bound_corruption_is_typed_error_not_a_successful_black_tail() { +- let (scene,request,options)=straight_identity_shells_source(5,true,false); +- let mut task=ImageTask::new_with_environment_and_nested(scene,request,CancelToken::default(),options,None,true).unwrap(); ++ let (scene, request, options) = straight_identity_shells_source(5, true, false); ++ let mut task = ImageTask::new_with_environment_and_nested(scene, request, CancelToken::default(), options, None, true).unwrap(); + // Controlled invariant unit, distinct from the unchanged valid E2E fixtures: + // an impossible internal policy must fail at a real subsequent interface. +- task.optical.first_mut().unwrap().straight_limit=Some(1); ++ task.optical.first_mut().unwrap().straight_limit = Some(1); + for _ in 0..200_000 { + match task.step_with_previews(1) { +- Err(error)=>{ +- assert_eq!(error.code,ErrorCode::InvalidScene); ++ Err(error) => { ++ assert_eq!(error.code, ErrorCode::InvalidScene); + assert!(error.message.contains("straight optical crossing bound exceeded")); +- assert_eq!(task.progressive.as_ref().unwrap().film.samples(),0); ++ assert_eq!(task.progressive.as_ref().unwrap().film.samples(), 0); + assert!(!task.done); + return; +- }, +- Ok(ImagePoll::Pending(_))=>{}, +- Ok(_)=>panic!("bound inconsistency cannot publish success"), ++ } ++ Ok(ImagePoll::Pending(_)) => {} ++ Ok(_) => panic!("bound inconsistency cannot publish success"), + } + } + panic!("unexpected extra crossing was not refused"); +@@ -2226,166 +2260,173 @@ + let options = RaytraceOptions { + progressive: samples.map(|samples_per_pixel| job::CpuProgressiveOptions { samples_per_pixel, seed }), + dielectrics: vec![dielectric::tests::input(job::DielectricBoundary::ClosedBox)], +- environment: Some(job::RaytraceEnvironmentOptions {color:[1.0;3],intensity}), +- lights: Some(Vec::new()), shadows:false, ++ environment: Some(job::RaytraceEnvironmentOptions { color: [1.0; 3], intensity }), ++ lights: Some(Vec::new()), ++ shadows: false, + ..Default::default() + }; + let mut request = dielectric::tests::request(options.clone()); + request.camera = crate::Camera { +- target:Vec3::new(0.9,0.37,2.0), yaw:std::f64::consts::FRAC_PI_2, +- pitch:0.8_f64.asin(), roll:0.0, distance:10.0, fov:1e-6, ++ target: Vec3::new(0.9, 0.37, 2.0), ++ yaw: std::f64::consts::FRAC_PI_2, ++ pitch: 0.8_f64.asin(), ++ roll: 0.0, ++ distance: 10.0, ++ fov: 1e-6, + ..Default::default() + }; +- (dielectric::tests::scene(body),request,options) +-} +- +-#[derive(Clone,Default)] ++ (dielectric::tests::scene(body), request, options) ++} ++ ++#[derive(Clone, Default)] + struct CameraTirEvidence { +- started:bool, +- first_entry:Option<(Vec3,Vec3,u16)>, +- tir:bool, +- transmitted_escape:bool, +- truncated_top_hit:bool, +- finite_scalar:f64, +- physical_tail_bound:f64, ++ started: bool, ++ first_entry: Option<(Vec3, Vec3, u16)>, ++ tir: bool, ++ transmitted_escape: bool, ++ truncated_top_hit: bool, ++ finite_scalar: f64, ++ physical_tail_bound: f64, + } + + /// Independent public-equation oracle, conditional on the REAL camera direction. + /// No dielectric::interface/attenuation/thin_sheet call or renderer state mutation. +-fn camera_tir_oracle(ray:Ray) -> (f64,f64) { +- let d=ray.direction(); +- assert!((d.x-0.6).abs()<2e-6 && (d.z+0.8).abs()<2e-6 && d.y.abs()<2e-6); +- let enter=ray.origin()+d*((2.0-ray.origin().z)/d.z); +- assert!((enter.x-0.9).abs()<2e-5 && (enter.y-0.37).abs()<2e-5); +- let cosine=-d.z; +- let tx=d.x/1.5; +- let ct=(1.0-(1.0-cosine*cosine)/2.25).sqrt(); +- assert!(2.25*(1.0-tx*tx)>1.0, "glass-to-air SIDE incidence is beyond critical"); ++fn camera_tir_oracle(ray: Ray) -> (f64, f64) { ++ let d = ray.direction(); ++ assert!((d.x - 0.6).abs() < 2e-6 && (d.z + 0.8).abs() < 2e-6 && d.y.abs() < 2e-6); ++ let enter = ray.origin() + d * ((2.0 - ray.origin().z) / d.z); ++ assert!((enter.x - 0.9).abs() < 2e-5 && (enter.y - 0.37).abs() < 2e-5); ++ let cosine = -d.z; ++ let tx = d.x / 1.5; ++ let ct = (1.0 - (1.0 - cosine * cosine) / 2.25).sqrt(); ++ assert!(2.25 * (1.0 - tx * tx) > 1.0, "glass-to-air SIDE incidence is beyond critical"); + // All possible jittered rays in this narrow public-camera cone retain one + // lateral TIR per horizontal crossing, with three escapes before depth8. +- let q=2.0*tx/ct; +- assert!((1.0..2.0).contains(&(enter.x+q))); +- let bottom1=2.0-enter.x-q; +- assert!((-1.0..0.0).contains(&(bottom1-q))); +- let top2=q-bottom1; +- assert!((1.0..2.0).contains(&(top2+q))); +- let bottom3=2.0-top2-q; +- assert!((-1.0..0.0).contains(&(bottom3-q))); ++ let q = 2.0 * tx / ct; ++ assert!((1.0..2.0).contains(&(enter.x + q))); ++ let bottom1 = 2.0 - enter.x - q; ++ assert!((-1.0..0.0).contains(&(bottom1 - q))); ++ let top2 = q - bottom1; ++ assert!((1.0..2.0).contains(&(top2 + q))); ++ let bottom3 = 2.0 - top2 - q; ++ assert!((-1.0..0.0).contains(&(bottom3 - q))); + // s/p Fresnel *power* from first principles, then the declared scalar + // unpolarized model's three-term geometric return series. Eta² cancels on + // each complete air/glass/air escape. Lossless unit exterior radiance has + // infinite-depth physical answer1; finite omission <=max(Rs,Rp)^3. +- let rs=((cosine-1.5*ct)/(cosine+1.5*ct)).powi(2); +- let rp=((1.5*cosine-ct)/(1.5*cosine+ct)).powi(2); +- let f=(rs+rp)*0.5; +- let finite=f+(1.0-f).powi(2)*(1.0+f+f*f); +- assert!((finite-(1.0-(1.0-f)*f.powi(3))).abs()<16.0*f64::EPSILON); +- (finite,rs.max(rp).powi(3)) +-} +- +-fn complete_camera_tir(scene:ProductScene,request:ImageRequest,options:RaytraceOptions) -> Vec { +- assert_eq!(MAX_BOUNDARIES,8,"this oracle is derived for the actual eight-event model"); +- let count=options.progressive.map_or(1,|p|p.samples_per_pixel) as usize; +- let intensity=options.environment.unwrap().intensity; +- let progressive=options.progressive.is_some(); +- let mut evidence=vec![CameraTirEvidence::default();count]; +- let mut final_linear=None; +- let mut checkpoints=0; +- let mut task=ImageTask::new(scene,request,CancelToken::default(),options).unwrap(); ++ let rs = ((cosine - 1.5 * ct) / (cosine + 1.5 * ct)).powi(2); ++ let rp = ((1.5 * cosine - ct) / (1.5 * cosine + ct)).powi(2); ++ let f = (rs + rp) * 0.5; ++ let finite = f + (1.0 - f).powi(2) * (1.0 + f + f * f); ++ assert!((finite - (1.0 - (1.0 - f) * f.powi(3))).abs() < 16.0 * f64::EPSILON); ++ (finite, rs.max(rp).powi(3)) ++} ++ ++fn complete_camera_tir(scene: ProductScene, request: ImageRequest, options: RaytraceOptions) -> Vec { ++ assert_eq!(MAX_BOUNDARIES, 8, "this oracle is derived for the actual eight-event model"); ++ let count = options.progressive.map_or(1, |p| p.samples_per_pixel) as usize; ++ let intensity = options.environment.unwrap().intensity; ++ let progressive = options.progressive.is_some(); ++ let mut evidence = vec![CameraTirEvidence::default(); count]; ++ let mut final_linear = None; ++ let mut checkpoints = 0; ++ let mut task = ImageTask::new(scene, request, CancelToken::default(), options).unwrap(); + // Deliberately use the public task poll to completion. The only writes to + // task state are its own API calls, never injected rays/paths/media/cursors. + for _ in 0..2_000_000 { +- if let Some(p)=&task.progressive +- && p.film.ready() && p.film.samples() as usize==count ++ if let Some(p) = &task.progressive ++ && p.film.ready() ++ && p.film.samples() as usize == count + { +- let (rgb,covered,samples)=p.film.pixel(0).unwrap(); +- assert_eq!((covered as usize,samples as usize),(count,count)); +- final_linear=Some(rgb); +- } +- let poll=if progressive { ++ let (rgb, covered, samples) = p.film.pixel(0).unwrap(); ++ assert_eq!((covered as usize, samples as usize), (count, count)); ++ final_linear = Some(rgb); ++ } ++ let poll = if progressive { + task.step_with_previews(1).unwrap() + } else { + match task.step(1).unwrap() { +- TaskPoll::Pending(p)=>ImagePoll::Pending(p), +- TaskPoll::Complete(png)=>ImagePoll::Complete(png), ++ TaskPoll::Pending(p) => ImagePoll::Pending(p), ++ TaskPoll::Complete(png) => ImagePoll::Complete(png), + } + }; +- if let Some(state)=task.optical.first().and_then(|o|o.pending.as_ref()) { +- let ordinal=state.camera_sample.map_or(0,|identity| { +- assert_eq!(identity.0,0); ++ if let Some(state) = task.optical.first().and_then(|o| o.pending.as_ref()) { ++ let ordinal = state.camera_sample.map_or(0, |identity| { ++ assert_eq!(identity.0, 0); + identity.1 as usize + }); +- let seen=&mut evidence[ordinal]; +- assert!(state.path.boundaries<=8); ++ let seen = &mut evidence[ordinal]; ++ assert!(state.path.boundaries <= 8); + if !seen.started { +- assert_eq!(state.path.boundaries,0); +- let (finite,tail)=camera_tir_oracle(state.path.ray); +- seen.finite_scalar=finite; +- seen.physical_tail_bound=tail; +- seen.started=true; +- } +- if state.path.boundaries==1 && state.path.medium==Some(0) && seen.first_entry.is_none() { +- let d=state.path.ray.direction(); +- assert!((d.x-0.4).abs()<2e-6 && (d.z+(0.84_f64).sqrt()).abs()<2e-6); +- assert!((state.path.segment_start.z-2.0).abs()<1e-12); +- seen.first_entry=Some((d,state.path.throughput,state.paths)); +- } +- if state.path.boundaries==2 && state.path.medium==Some(0) { +- let (before,throughput,paths)=seen.first_entry.unwrap(); +- let after=state.path.ray.direction(); +- assert!((state.path.segment_start.x-1.0).abs()<1e-12,"real ray hit lateral face"); +- assert!(2.25*(1.0-before.x*before.x)>1.0); +- assert!((after-Vec3::new(-before.x,before.y,before.z)).len()<1e-12); +- assert!((state.path.throughput-throughput).len()<1e-12,"TIR retains all current branch power"); +- assert_eq!(state.paths,paths+1,"only reflected path was created at TIR"); ++ assert_eq!(state.path.boundaries, 0); ++ let (finite, tail) = camera_tir_oracle(state.path.ray); ++ seen.finite_scalar = finite; ++ seen.physical_tail_bound = tail; ++ seen.started = true; ++ } ++ if state.path.boundaries == 1 && state.path.medium == Some(0) && seen.first_entry.is_none() { ++ let d = state.path.ray.direction(); ++ assert!((d.x - 0.4).abs() < 2e-6 && (d.z + (0.84_f64).sqrt()).abs() < 2e-6); ++ assert!((state.path.segment_start.z - 2.0).abs() < 1e-12); ++ seen.first_entry = Some((d, state.path.throughput, state.paths)); ++ } ++ if state.path.boundaries == 2 && state.path.medium == Some(0) { ++ let (before, throughput, paths) = seen.first_entry.unwrap(); ++ let after = state.path.ray.direction(); ++ assert!((state.path.segment_start.x - 1.0).abs() < 1e-12, "real ray hit lateral face"); ++ assert!(2.25 * (1.0 - before.x * before.x) > 1.0); ++ assert!((after - Vec3::new(-before.x, before.y, before.z)).len() < 1e-12); ++ assert!((state.path.throughput - throughput).len() < 1e-12, "TIR retains all current branch power"); ++ assert_eq!(state.paths, paths + 1, "only reflected path was created at TIR"); + // The primary reflection is still waiting; TIR itself leaves no + // transmitted child in addition to this resumed internal path. +- assert_eq!(state.stack_len,1); +- seen.tir=true; +- } +- if state.path.boundaries==3 && state.path.medium.is_none() { ++ assert_eq!(state.stack_len, 1); ++ seen.tir = true; ++ } ++ if state.path.boundaries == 3 && state.path.medium.is_none() { + assert!(seen.tir); +- assert!(state.path.segment_start.z.abs()<1e-12,"TIR branch really escaped through bottom"); +- assert!(state.path.ray.direction().z<0.0 && state.path.ray.direction().x<0.0); +- seen.transmitted_escape=true; +- } +- if state.path.boundaries==8 && state.path.medium==Some(0) +- && let Some(hit)=task.pending.as_ref().and_then(|p|p.hit) ++ assert!(state.path.segment_start.z.abs() < 1e-12, "TIR branch really escaped through bottom"); ++ assert!(state.path.ray.direction().z < 0.0 && state.path.ray.direction().x < 0.0); ++ seen.transmitted_escape = true; ++ } ++ if state.path.boundaries == 8 ++ && state.path.medium == Some(0) ++ && let Some(hit) = task.pending.as_ref().and_then(|p| p.hit) + { +- let vertices=task.looks[hit.primitive_index].vertices; +- if vertices.iter().all(|v|v.z==2.0) { +- seen.truncated_top_hit=true; ++ let vertices = task.looks[hit.primitive_index].vertices; ++ if vertices.iter().all(|v| v.z == 2.0) { ++ seen.truncated_top_hit = true; + } + } + } + match poll { +- ImagePoll::Pending(_)=>{}, +- ImagePoll::Preview { .. }=>{ ++ ImagePoll::Pending(_) => {} ++ ImagePoll::Preview { .. } => { + assert!(task.optical.first().unwrap().pending.is_none()); +- checkpoints+=1; +- }, +- ImagePoll::Complete(png)=>{ +- assert!(evidence.iter().all(|s|s.started && s.tir && s.transmitted_escape && s.truncated_top_hit)); ++ checkpoints += 1; ++ } ++ ImagePoll::Complete(png) => { ++ assert!(evidence.iter().all(|s| s.started && s.tir && s.transmitted_escape && s.truncated_top_hit)); + if progressive { +- assert!(checkpoints>0); +- let expected=intensity*evidence.iter().map(|s|s.finite_scalar).sum::()/count as f64; +- let omitted_bound=intensity*evidence.iter().map(|s|s.physical_tail_bound).sum::()/count as f64; ++ assert!(checkpoints > 0); ++ let expected = intensity * evidence.iter().map(|s| s.finite_scalar).sum::() / count as f64; ++ let omitted_bound = intensity * evidence.iter().map(|s| s.physical_tail_bound).sum::() / count as f64; + // Preselected absolute roundoff allowance, independent of + // product output. This is no numerical-certification claim. +- let roundoff=4096.0*f64::EPSILON; ++ let roundoff = 4096.0 * f64::EPSILON; + for actual in final_linear.unwrap() { +- assert!((actual-expected).abs()<=roundoff,"independent finite scalar Fresnel series"); +- assert!(actual<=intensity+roundoff); +- assert!(actual>=intensity-omitted_bound-roundoff,"physical lossless energy with explicit finite-depth omission bound"); ++ assert!((actual - expected).abs() <= roundoff, "independent finite scalar Fresnel series"); ++ assert!(actual <= intensity + roundoff); ++ assert!(actual >= intensity - omitted_bound - roundoff, "physical lossless energy with explicit finite-depth omission bound"); + } +- if intensity==1.0 { +- assert!(expected<1.0,"eight-event truncation is NOT perfect conservation"); +- assert!(omitted_bound>1e-5 && omitted_bound<1e-3); ++ if intensity == 1.0 { ++ assert!(expected < 1.0, "eight-event truncation is NOT perfect conservation"); ++ assert!(omitted_bound > 1e-5 && omitted_bound < 1e-3); + } + } +- let image=::image::load_from_memory(&png).unwrap().to_rgba8(); +- let expected=if intensity==0.0 {[0,0,0,255]} else {[188,188,188,255]}; +- assert_eq!(image.get_pixel(0,0).0,expected,"black/white secondary environment controls, covered pixel"); ++ let image = ::image::load_from_memory(&png).unwrap().to_rgba8(); ++ let expected = if intensity == 0.0 { [0, 0, 0, 255] } else { [188, 188, 188, 255] }; ++ assert_eq!(image.get_pixel(0, 0).0, expected, "black/white secondary environment controls, covered pixel"); + return png; + } + } +@@ -2395,20 +2436,20 @@ + + #[test] + fn camera_originated_tir_survives_fixed_render_to_final_png_with_environment_controls() { +- let mut outputs=Vec::new(); +- for intensity in [0.0,1.0] { +- let (scene,request,options)=camera_tir_source(None,0,intensity); +- outputs.push(complete_camera_tir(scene,request,options)); +- } +- assert_ne!(outputs[0],outputs[1]); ++ let mut outputs = Vec::new(); ++ for intensity in [0.0, 1.0] { ++ let (scene, request, options) = camera_tir_source(None, 0, intensity); ++ outputs.push(complete_camera_tir(scene, request, options)); ++ } ++ assert_ne!(outputs[0], outputs[1]); + } + + #[test] + fn camera_originated_tir_progressive_final_obeys_physical_energy_and_explicit_depth_tail() { +- for seed in [0,97] { +- for intensity in [0.0,1.0] { +- let (scene,request,options)=camera_tir_source(Some(5),seed,intensity); +- let _=complete_camera_tir(scene,request,options); +- } +- } +-} ++ for seed in [0, 97] { ++ for intensity in [0.0, 1.0] { ++ let (scene, request, options) = camera_tir_source(Some(5), seed, intensity); ++ let _ = complete_camera_tir(scene, request, options); ++ } ++ } ++} +--- a/crates/render/src/raytrace/primary_aa_tests.rs ++++ b/crates/render/src/raytrace/primary_aa_tests.rs +@@ -1580,7 +1580,6 @@ + } + } + +- + // Original progressive optics / presentation combinations. WRITTEN, NOT RUN. + fn optical_partial_source(samples: u32) -> (ProductScene, ImageRequest, RaytraceOptions) { + let (scene, mut request, options) = super::tests::progressive_optics_source(job::DielectricBoundary::ClosedBox, 2.0, 1.5, samples); +@@ -1593,9 +1592,18 @@ + let (scene, request, options) = optical_partial_source(3); + let plan = job::ProtectedPreviewPlan::new(2, 1, 3, options.budget).unwrap(); + let mut task = ImageTask::new_with_environment_and_nested_and_protected_partial( +- scene.clone(), request.clone(), CancelToken::default(), options.clone(), None, false, plan).unwrap(); +- let mut control = ImageTask::new_with_environment_and_nested_and_partial( +- scene, request, CancelToken::default(), options, None, false, plan.preview_plan()).unwrap(); ++ scene.clone(), ++ request.clone(), ++ CancelToken::default(), ++ options.clone(), ++ None, ++ false, ++ plan, ++ ) ++ .unwrap(); ++ let mut control = ++ ImageTask::new_with_environment_and_nested_and_partial(scene, request, CancelToken::default(), options, None, false, plan.preview_plan()) ++ .unwrap(); + let mut rays = Vec::new(); + let mut control_rays = Vec::new(); + let mut saw_interior = false; +@@ -1635,8 +1643,8 @@ + fn protected_optical_snapshot_cancellation_cannot_emit_or_commit_another_sample() { + let (scene, request, options) = optical_partial_source(3); + let plan = job::ProtectedPreviewPlan::new(2, 1, 3, options.budget).unwrap(); +- let mut task = ImageTask::new_with_environment_and_nested_and_protected_partial( +- scene, request, CancelToken::default(), options, None, false, plan).unwrap(); ++ let mut task = ++ ImageTask::new_with_environment_and_nested_and_protected_partial(scene, request, CancelToken::default(), options, None, false, plan).unwrap(); + reach_partial_frontier(&mut task, 0, 1, &mut Vec::new()); + assert!(matches!(task.begin_partial_preview(plan.preview_plan()).unwrap(), PartialBegin::Started)); + let frontier = task.progressive.as_ref().unwrap().film.partial_frontier().unwrap(); +@@ -1654,36 +1662,45 @@ + // Original two-triangle rectangle between camera and receiver. It is + // index-matched and lossless: the independent control has no sheet at all. + scene.meshes.push(ProductMesh { +- transmission: None, name: "Progressive optical sheet".into(), ++ transmission: None, ++ name: "Progressive optical sheet".into(), + mesh: Arc::new(Mesh { +- positions: vec![Vec3::new(-20.0,-20.0,2.0),Vec3::new(20.0,-20.0,2.0), +- Vec3::new(20.0,20.0,2.0),Vec3::new(-20.0,20.0,2.0)], +- normals: vec![Vec3::Z;4], triangles:vec![[0,1,2],[0,2,3]], ..Default::default() ++ positions: vec![Vec3::new(-20.0, -20.0, 2.0), Vec3::new(20.0, -20.0, 2.0), Vec3::new(20.0, 20.0, 2.0), Vec3::new(-20.0, 20.0, 2.0)], ++ normals: vec![Vec3::Z; 4], ++ triangles: vec![[0, 1, 2], [0, 2, 3]], ++ ..Default::default() + }), +- color:[255;3], opacity:1.0, surface:None, faces:Vec::new(), ++ color: [255; 3], ++ opacity: 1.0, ++ surface: None, ++ faces: Vec::new(), + }); + options.dielectrics.push(job::DielectricOptions { +- body_index:scene.meshes.len()-1, body_name:"Progressive optical sheet".into(), +- boundary:job::DielectricBoundary::ThinSheet, ior:1.0, absorption_per_mm:[0.0;3], thickness_mm:0.0, ++ body_index: scene.meshes.len() - 1, ++ body_name: "Progressive optical sheet".into(), ++ boundary: job::DielectricBoundary::ThinSheet, ++ ior: 1.0, ++ absorption_per_mm: [0.0; 3], ++ thickness_mm: 0.0, + }); + scene.bounds = scene.meshes.iter().fold(Aabb3::EMPTY, |bounds, body| bounds.union(&body.mesh.bounds())); +- let request = ImageRequest {raytrace:Some(options.clone()), ..source.request.clone()}; +- (scene,request,options) ++ let request = ImageRequest { raytrace: Some(options.clone()), ..source.request.clone() }; ++ (scene, request, options) + } + + #[test] + fn progressive_unit_optics_rejoin_real_area_consumers_at_every_admitted_sample_count() { +- for count in [1,4,16,64] { +- for seed in [0,23] { ++ for count in [1, 4, 16, 64] { ++ for seed in [0, 23] { + // Conservative opaque shadow visibility is deliberately off. This + // feature does not invent transmitted illumination or caustics. +- let source = progressive_area_fixture(count,3,seed,false); +- let (scene,request,options) = with_unit_optical_sheet(&source); +- let optical = ImageTask::new(scene,request,CancelToken::default(),options).unwrap(); +- let expected = progressive_complete(source,1); +- let actual = progressive_complete(optical,4); +- assert_eq!(actual.0,expected.0); +- assert_eq!(actual.1,expected.1, "unit transmission preserves independently lit receiver; count={count}, seed={seed}"); ++ let source = progressive_area_fixture(count, 3, seed, false); ++ let (scene, request, options) = with_unit_optical_sheet(&source); ++ let optical = ImageTask::new(scene, request, CancelToken::default(), options).unwrap(); ++ let expected = progressive_complete(source, 1); ++ let actual = progressive_complete(optical, 4); ++ assert_eq!(actual.0, expected.0); ++ assert_eq!(actual.1, expected.1, "unit transmission preserves independently lit receiver; count={count}, seed={seed}"); + assert!(actual.2 > expected.2, "real optical traversal is charged, never bypassed"); + } + } +@@ -1691,72 +1708,103 @@ + + #[test] + fn progressive_unit_optics_rejoin_hdr_receiver_and_preserve_feedback_film_and_seed() { +- let mut source = progressive_area_fixture(4,3,23,false); ++ let mut source = progressive_area_fixture(4, 3, 23, false); + source.options.area_lights = None; + source.options.area_samples = None; + source.options.seed = None; + source.request.raytrace = Some(source.options.clone()); +- let (scene,request,options) = with_unit_optical_sheet(&source); +- let plan = job::ProtectedPreviewPlan::new(1,1,3,options.budget).unwrap(); ++ let (scene, request, options) = with_unit_optical_sheet(&source); ++ let plan = job::ProtectedPreviewPlan::new(1, 1, 3, options.budget).unwrap(); + let mut observed = ImageTask::new_with_environment_and_nested_and_protected_partial( +- scene.clone(),request.clone(),CancelToken::default(),options.clone(),Some(partial_original_hdr()),false,plan).unwrap(); ++ scene.clone(), ++ request.clone(), ++ CancelToken::default(), ++ options.clone(), ++ Some(partial_original_hdr()), ++ false, ++ plan, ++ ) ++ .unwrap(); + let mut control = ImageTask::new_with_environment_and_nested_and_partial( +- scene,request,CancelToken::default(),options,Some(partial_original_hdr()),false,plan.preview_plan()).unwrap(); ++ scene, ++ request, ++ CancelToken::default(), ++ options, ++ Some(partial_original_hdr()), ++ false, ++ plan.preview_plan(), ++ ) ++ .unwrap(); + let mut rays = Vec::new(); + let mut control_rays = Vec::new(); +- reach_partial_frontier(&mut observed,1,0,&mut rays); +- assert!(matches!(observed.begin_partial_preview(plan.preview_plan()).unwrap(),PartialBegin::Started)); +- let (snapshot,covered,passes,prefix) = finish_partial_snapshot(&mut observed); +- assert_eq!((passes,prefix),(1,0)); +- assert_eq!(covered,[1]); +- let actual = finish_partial_final(&mut observed,true,&mut rays); +- assert_eq!(actual,finish_partial_final(&mut control,true,&mut control_rays)); +- assert_eq!(rays,control_rays); +- assert_eq!(observed.protected_preview_report().unwrap().ordinary_used,control.work.used()); +- let without_sheet = ImageTask::new_with_environment(source.scene.clone(),source.request.clone(),CancelToken::default(),source.options.clone(),Some(partial_original_hdr())).unwrap(); +- let expected = progressive_complete(without_sheet,1); +- assert_eq!(snapshot,expected.0[0].1); +- assert_eq!(actual.0,expected.1); +-} +- ++ reach_partial_frontier(&mut observed, 1, 0, &mut rays); ++ assert!(matches!(observed.begin_partial_preview(plan.preview_plan()).unwrap(), PartialBegin::Started)); ++ let (snapshot, covered, passes, prefix) = finish_partial_snapshot(&mut observed); ++ assert_eq!((passes, prefix), (1, 0)); ++ assert_eq!(covered, [1]); ++ let actual = finish_partial_final(&mut observed, true, &mut rays); ++ assert_eq!(actual, finish_partial_final(&mut control, true, &mut control_rays)); ++ assert_eq!(rays, control_rays); ++ assert_eq!(observed.protected_preview_report().unwrap().ordinary_used, control.work.used()); ++ let without_sheet = ImageTask::new_with_environment( ++ source.scene.clone(), ++ source.request.clone(), ++ CancelToken::default(), ++ source.options.clone(), ++ Some(partial_original_hdr()), ++ ) ++ .unwrap(); ++ let expected = progressive_complete(without_sheet, 1); ++ assert_eq!(snapshot, expected.0[0].1); ++ assert_eq!(actual.0, expected.1); ++} + + #[test] + fn protected_deep_identity_shells_preserve_partial_final_rays_film_and_real_work() { +- for absorbing in [false,true] { +- let (scene,mut request,options)=super::tests::straight_identity_shells_source(8,true,absorbing); +- request.width=2; // orthographic X range[-16,16] remains inside innermost[-17,17]. +- let plan=job::ProtectedPreviewPlan::new(2,1,3,options.budget).unwrap(); +- let mut task=ImageTask::new_with_environment_and_nested_and_protected_partial( +- scene.clone(),request.clone(),CancelToken::default(),options.clone(),None,true,plan).unwrap(); +- let mut control=ImageTask::new_with_environment_and_nested_and_partial( +- scene,request,CancelToken::default(),options,None,true,plan.preview_plan()).unwrap(); +- let mut rays=Vec::new(); +- let mut control_rays=Vec::new(); +- reach_partial_frontier(&mut task,0,1,&mut rays); ++ for absorbing in [false, true] { ++ let (scene, mut request, options) = super::tests::straight_identity_shells_source(8, true, absorbing); ++ request.width = 2; // orthographic X range[-16,16] remains inside innermost[-17,17]. ++ let plan = job::ProtectedPreviewPlan::new(2, 1, 3, options.budget).unwrap(); ++ let mut task = ImageTask::new_with_environment_and_nested_and_protected_partial( ++ scene.clone(), ++ request.clone(), ++ CancelToken::default(), ++ options.clone(), ++ None, ++ true, ++ plan, ++ ) ++ .unwrap(); ++ let mut control = ++ ImageTask::new_with_environment_and_nested_and_partial(scene, request, CancelToken::default(), options, None, true, plan.preview_plan()) ++ .unwrap(); ++ let mut rays = Vec::new(); ++ let mut control_rays = Vec::new(); ++ reach_partial_frontier(&mut task, 0, 1, &mut rays); + assert!(task.optical.first().unwrap().pending.is_none()); +- assert!(matches!(task.begin_partial_preview(plan.preview_plan()).unwrap(),PartialBegin::Started)); +- let ordinary=task.protected_preview_report().unwrap().ordinary_used; +- let (_,covered,passes,prefix)=finish_partial_snapshot(&mut task); +- assert_eq!((passes,prefix),(0,1)); +- assert_eq!(covered,[1,0]); +- assert_eq!(task.protected_preview_report().unwrap().ordinary_used,ordinary); +- let actual=finish_partial_final(&mut task,true,&mut rays); +- let expected=finish_partial_final(&mut control,true,&mut control_rays); +- assert_eq!(actual,expected,"exact final PNG and film bits with optional observation"); +- assert_eq!(rays,control_rays); +- assert_eq!(rays.len(),6); +- let linear=super::tests::straight_shells_expected_linear(8,absorbing); +- let expected_pixel=super::tests::straight_expected_pixel(linear); ++ assert!(matches!(task.begin_partial_preview(plan.preview_plan()).unwrap(), PartialBegin::Started)); ++ let ordinary = task.protected_preview_report().unwrap().ordinary_used; ++ let (_, covered, passes, prefix) = finish_partial_snapshot(&mut task); ++ assert_eq!((passes, prefix), (0, 1)); ++ assert_eq!(covered, [1, 0]); ++ assert_eq!(task.protected_preview_report().unwrap().ordinary_used, ordinary); ++ let actual = finish_partial_final(&mut task, true, &mut rays); ++ let expected = finish_partial_final(&mut control, true, &mut control_rays); ++ assert_eq!(actual, expected, "exact final PNG and film bits with optional observation"); ++ assert_eq!(rays, control_rays); ++ assert_eq!(rays.len(), 6); ++ let linear = super::tests::straight_shells_expected_linear(8, absorbing); ++ let expected_pixel = super::tests::straight_expected_pixel(linear); + for rgb in &actual.1 { +- for (value,physical) in rgb.iter().copied().map(f64::from_bits).zip(linear) { +- assert!((value-physical).abs()<1e-11); ++ for (value, physical) in rgb.iter().copied().map(f64::from_bits).zip(linear) { ++ assert!((value - physical).abs() < 1e-11); + } + } +- let image=::image::load_from_memory(&actual.0).unwrap().to_rgba8(); +- assert_eq!(image.get_pixel(0,0).0,expected_pixel); +- assert_eq!(image.get_pixel(1,0).0,expected_pixel); +- let report=task.protected_preview_report().unwrap(); +- assert_eq!(report.ordinary_used,control.work.used()); +- assert_eq!(report.presentation_used,plan.snapshot_work().unwrap()); +- } +-} ++ let image = ::image::load_from_memory(&actual.0).unwrap().to_rgba8(); ++ assert_eq!(image.get_pixel(0, 0).0, expected_pixel); ++ assert_eq!(image.get_pixel(1, 0).0, expected_pixel); ++ let report = task.protected_preview_report().unwrap(); ++ assert_eq!(report.ordinary_used, control.work.used()); ++ assert_eq!(report.presentation_used, plan.snapshot_work().unwrap()); ++ } ++} +--- a/crates/render/src/studio.rs ++++ b/crates/render/src/studio.rs +@@ -52,14 +52,13 @@ + // Validate every authored source, even if it is dark or behind the surface. + // Bounds match RaytraceOptions' directional inputs; no clamping/remapping. + for light in lights { +- if !light.intensity.is_finite() || !(0.0..=64.0).contains(&light.intensity) ++ if !light.intensity.is_finite() ++ || !(0.0..=64.0).contains(&light.intensity) + || !light.color.iter().all(|c| c.is_finite() && (0.0..=1.0).contains(c)) + { + return Err(SurfaceError::Radiance); + } +- if !light.direction.iter().all(|c| c.is_finite() && c.abs() <= 1e9) +- || !light.direction.iter().any(|c| *c != 0.0) +- { ++ if !light.direction.iter().all(|c| c.is_finite() && c.abs() <= 1e9) || !light.direction.iter().any(|c| *c != 0.0) { + return Err(SurfaceError::Direction); + } + } +@@ -69,8 +68,7 @@ + let direction = unit_direction(Vec3::new(x, y, z))?; + let brdf = surface.brdf(n, v, direction)?; + let [red, green, blue] = light.color; +- radiance += Vec3::new(brdf.x * red, brdf.y * green, brdf.z * blue) +- * (light.intensity * n.dot(direction).max(0.0)); ++ radiance += Vec3::new(brdf.x * red, brdf.y * green, brdf.z * blue) * (light.intensity * n.dot(direction).max(0.0)); + } + if !radiance.is_finite() || radiance.x < 0.0 || radiance.y < 0.0 || radiance.z < 0.0 { + return Err(SurfaceError::Radiance); +@@ -144,8 +142,7 @@ + let both = shade_directional(surface, Vec3::Z, Vec3::Z, &[red.clone(), blue.clone()]).unwrap(); + let expected = Vec3::new(1.6 / PI, 0.0, 1.0 / PI); + assert!((both - expected).len() < 1e-14); +- let separate = shade_directional(surface, Vec3::Z, Vec3::Z, &[red]).unwrap() +- + shade_directional(surface, Vec3::Z, Vec3::Z, &[blue]).unwrap(); ++ let separate = shade_directional(surface, Vec3::Z, Vec3::Z, &[red]).unwrap() + shade_directional(surface, Vec3::Z, Vec3::Z, &[blue]).unwrap(); + assert!((both - separate).len() < 1e-14); + } + +@@ -167,11 +164,9 @@ + fn schematic_directional_empty_dark_and_back_facing_sources_produce_no_ambient() { + let surface = OpaqueSurface::new(Vec3::new(0.8, 0.5, 0.25), 0.0, 1.0, 1.0).unwrap(); + assert_eq!(shade_directional(surface, Vec3::Z, Vec3::Z, &[]).unwrap(), Vec3::ZERO); +- for light in [ +- directional([0.0, 0.0, 1.0], [1.0; 3], 0.0), +- directional([0.0, 0.0, 1.0], [0.0; 3], 64.0), +- directional([0.0, 0.0, -1.0], [1.0; 3], 64.0), +- ] { ++ for light in ++ [directional([0.0, 0.0, 1.0], [1.0; 3], 0.0), directional([0.0, 0.0, 1.0], [0.0; 3], 64.0), directional([0.0, 0.0, -1.0], [1.0; 3], 64.0)] ++ { + assert_eq!(shade_directional(surface, Vec3::Z, Vec3::Z, &[light]).unwrap(), Vec3::ZERO); + } + let light = directional([0.0, 0.0, 1.0], [1.0; 3], 1.0); +--- a/crates/ui-egui/src/render_workspace.rs ++++ b/crates/ui-egui/src/render_workspace.rs +@@ -177,7 +177,9 @@ + } + + impl DisplayImage<'_> { +- fn provisional(&self) -> bool { self.preview.is_some() || self.partial.is_some() } ++ fn provisional(&self) -> bool { ++ self.preview.is_some() || self.partial.is_some() ++ } + } + + /// Application-wide setup, retained across document changes. The worker owns a +@@ -886,7 +888,9 @@ + } + let mut request = image_request(app)?; + if view.method == ImageMethod::CpuRaytrace && view.raytrace.progressive.is_some() { +- request.as_object_mut().ok_or_else(|| app.tr("render.error_provisional_identity").to_string())? ++ request ++ .as_object_mut() ++ .ok_or_else(|| app.tr("render.error_provisional_identity").to_string())? + .insert("progressive_feedback".into(), json!(true)); + } + Ok(request) +@@ -1352,7 +1356,9 @@ + // Equal source evidence prefers the established complete-pass image. + if preview.is_none_or(|image| u64::from(image.info.samples_per_pixel) * pixels < frontier) { + return Some(DisplayImage { +- info: &partial.info.frame, image: &partial.image, preview: None, ++ info: &partial.info.frame, ++ image: &partial.image, ++ preview: None, + partial: Some((&partial.info, partial.sampling)), + logical_size: [partial.info.source_width, partial.info.source_height], + }); +@@ -1360,7 +1366,10 @@ + } + if let Some(preview) = preview { + return Some(DisplayImage { +- info: &preview.info.frame, image: &preview.image, preview: Some(&preview.info), partial: None, ++ info: &preview.info.frame, ++ image: &preview.image, ++ preview: Some(&preview.info), ++ partial: None, + logical_size: [preview.info.frame.width, preview.info.frame.height], + }); + } +@@ -1369,24 +1378,36 @@ + } + + fn cache_final_partial( +- app: &mut SolveApp, ctx: &egui::Context, handle: &solidcraft_engine::render::job::JobHandle, ++ app: &mut SolveApp, ++ ctx: &egui::Context, ++ handle: &solidcraft_engine::render::job::JobHandle, + status: &solidcraft_engine::render::job::JobStatus, + partial: &solidcraft_engine::render::job::RenderPartialPreview, + ) -> Result<(), String> { + let job = handle.id(); +- if app.render_workspace.view.job != Some(job) { return Ok(()); } +- let previous = app.render_workspace.final_partial.as_ref() +- .filter(|cached| cached.info.frame.job == job).map(|cached| cached.sampling); ++ if app.render_workspace.view.job != Some(job) { ++ return Ok(()); ++ } ++ let previous = app.render_workspace.final_partial.as_ref().filter(|cached| cached.info.frame.job == job).map(|cached| cached.sampling); + let expected = interactive::PartialExpectation { +- job, scene_generation: status.scene_generation, request: &status.request, ++ job, ++ scene_generation: status.scene_generation, ++ request: &status.request, + final_dimensions: [status.request.width, status.request.height], + }; +- let Some(sampling) = interactive::validate_partial_metadata( +- &expected, &partial.info, partial.png().len(), partial.covered().len(), previous, +- )? else { return Ok(()); }; ++ let Some(sampling) = interactive::validate_partial_metadata(&expected, &partial.info, partial.png().len(), partial.covered().len(), previous)? ++ else { ++ return Ok(()); ++ }; + let image = interactive::decode_partial_image( +- &status.request, &partial.info, partial.png(), partial.covered(), sampling, ctx.input(|input| input.max_texture_side), +- ).map(|pixels| ctx.load_texture("sc_render_final_partial", pixels, egui::TextureOptions::NEAREST)); ++ &status.request, ++ &partial.info, ++ partial.png(), ++ partial.covered(), ++ sampling, ++ ctx.input(|input| input.max_texture_side), ++ ) ++ .map(|pixels| ctx.load_texture("sc_render_final_partial", pixels, egui::TextureOptions::NEAREST)); + if app.render_workspace.view.job == Some(job) { + app.render_workspace.final_partial = Some(FinalPartialImage { info: partial.info.clone(), sampling, image }); + } +@@ -1440,12 +1461,15 @@ + } + let now = interactive::monotonic(app.render_workspace.final_feedback_clock, ctx.input(|input| input.time)); + app.render_workspace.final_feedback_clock = now; +- if !status.progress.phase.terminal() && status.request.integrator == Integrator::Raytrace ++ if !status.progress.phase.terminal() ++ && status.request.integrator == Integrator::Raytrace + && status.request.raytrace.as_ref().and_then(|options| options.progressive).is_some() + && interactive::partial_request_due(app.render_workspace.final_partial_request, job, now) + { + app.render_workspace.final_partial_request = Some((job, now)); +- if let Err(error) = handle.request_partial_preview() { app.set_status(error.to_string(), true); } ++ if let Err(error) = handle.request_partial_preview() { ++ app.set_status(error.to_string(), true); ++ } + } + app.render_workspace.final_feedback_report = handle.protected_preview_report().ok().flatten().map(|report| (job, report)); + let preview = handle.preview().ok().flatten(); +@@ -1483,10 +1507,15 @@ + /// frame again before the caller clears provisional caches or falls back. + fn final_job_still_running(app: &mut SolveApp, handle: &solidcraft_engine::render::job::JobHandle) -> bool { + let job = handle.id(); +- if app.render_workspace.view.job != Some(job) { return false; } ++ if app.render_workspace.view.job != Some(job) { ++ return false; ++ } + let status = match handle.status() { + Ok(status) => status, +- Err(error) => { app.set_status(error.to_string(), true); return false; } ++ Err(error) => { ++ app.set_status(error.to_string(), true); ++ return false; ++ } + }; + if status.progress.phase == solidcraft_engine::render::job::Phase::Completed { + match handle.frame() { +@@ -1513,7 +1542,8 @@ + + fn cache_render_images(app: &mut SolveApp, ctx: &egui::Context) { + let preserve_view = displayed_image(app).is_some_and(|display| { +- display.provisional() && app.render_workspace.view.result_job == Some(display.info.job) ++ display.provisional() ++ && app.render_workspace.view.result_job == Some(display.info.job) + && app.render_workspace.view.job == Some(display.info.job) + }); + cache_preview_image(app, ctx); +@@ -1673,8 +1703,9 @@ + } + let mut content = ui.new_child(egui::UiBuilder::new().max_rect(free).id_salt("render_result_content")); + let ui = &mut content; +- let Some((info, preview, partial, logical_size)) = displayed_image(app) +- .map(|display| (display.info.clone(), display.preview.cloned(), display.partial.map(|(info, sampling)| (info.clone(), sampling)), display.logical_size)) else { ++ let Some((info, preview, partial, logical_size)) = displayed_image(app).map(|display| { ++ (display.info.clone(), display.preview.cloned(), display.partial.map(|(info, sampling)| (info.clone(), sampling)), display.logical_size) ++ }) else { + let message = match &app.render_workspace.image { + Some((_, Err(error))) => error.clone(), + _ if ribbon::busy(app) => app.tr("render.state_in_progress").to_string(), +@@ -1723,28 +1754,46 @@ + if let Some((info, sampling)) = &partial { + ui.colored_label(t.warning, app.tr("render.result_provisional")); + let (min, max) = sampling.sample_range(); +- ui.small(crate::i18n::format("render.interactive_partial_samples", &[ +- ("min", &min.to_string()), ("max", &max.to_string()), +- ("known", &sampling.sampled_source_pixels().to_string()), +- ("pixels", &(u64::from(info.source_width) * u64::from(info.source_height)).to_string()), +- ])); +- ui.small(crate::i18n::format("render.interactive_partial_dimensions", &[ +- ("display_width", &info.frame.width.to_string()), ("display_height", &info.frame.height.to_string()), +- ("source_width", &info.source_width.to_string()), ("source_height", &info.source_height.to_string()), +- ("final_width", &logical_size[0].to_string()), ("final_height", &logical_size[1].to_string()), +- ])); ++ ui.small(crate::i18n::format( ++ "render.interactive_partial_samples", ++ &[ ++ ("min", &min.to_string()), ++ ("max", &max.to_string()), ++ ("known", &sampling.sampled_source_pixels().to_string()), ++ ("pixels", &(u64::from(info.source_width) * u64::from(info.source_height)).to_string()), ++ ], ++ )); ++ ui.small(crate::i18n::format( ++ "render.interactive_partial_dimensions", ++ &[ ++ ("display_width", &info.frame.width.to_string()), ++ ("display_height", &info.frame.height.to_string()), ++ ("source_width", &info.source_width.to_string()), ++ ("source_height", &info.source_height.to_string()), ++ ("final_width", &logical_size[0].to_string()), ++ ("final_height", &logical_size[1].to_string()), ++ ], ++ )); + ui.small(app.tr("render.result_provisional_help")); + } + if let Some((job, report)) = app.render_workspace.final_feedback_report +- && job == info.job && (preview.is_some() || partial.is_some()) ++ && job == info.job ++ && (preview.is_some() || partial.is_some()) + { +- ui.small(crate::i18n::format("render.interactive_feedback_usage", &[ +- ("started", &report.accepted_snapshots.to_string()), ("limit", &report.quota_limit.to_string()), +- ])); +- let reason = if report.quota_exhausted { Some("render.interactive_feedback_quota_exhausted") } +- else if report.milestones_complete { Some("render.interactive_feedback_milestones_complete") } +- else { None }; +- if let Some(reason) = reason { ui.small(app.tr(reason)); } ++ ui.small(crate::i18n::format( ++ "render.interactive_feedback_usage", ++ &[("started", &report.accepted_snapshots.to_string()), ("limit", &report.quota_limit.to_string())], ++ )); ++ let reason = if report.quota_exhausted { ++ Some("render.interactive_feedback_quota_exhausted") ++ } else if report.milestones_complete { ++ Some("render.interactive_feedback_milestones_complete") ++ } else { ++ None ++ }; ++ if let Some(reason) = reason { ++ ui.small(app.tr(reason)); ++ } + } + if let Some(display) = displayed_image(app) + && let Err(error) = display.image +--- a/crates/ui-egui/src/render_workspace_materials.rs ++++ b/crates/ui-egui/src/render_workspace_materials.rs +@@ -336,9 +336,9 @@ + if !view.draft.optics.is_empty() { + return Err(app.tr("render.cpu_optics_saved").into()); + } +- let mut options: RaytraceOptions = serde_json::from_value( +- params.get("raytrace").cloned().ok_or_else(|| app.tr("render.cpu_optics_request").to_string())?, +- ).map_err(|error| error.to_string())?; ++ let mut options: RaytraceOptions = ++ serde_json::from_value(params.get("raytrace").cloned().ok_or_else(|| app.tr("render.cpu_optics_request").to_string())?) ++ .map_err(|error| error.to_string())?; + if !options.dielectrics.is_empty() { + return Err(app.tr("render.cpu_optics_conflict").into()); + } +@@ -365,15 +365,23 @@ + let target = &binding.target; + let stable = target.stable_target.as_ref().ok_or_else(|| app.tr("render.material_target_missing").to_string())?; + stable.validate().map_err(|error| error.to_string())?; +- let mut bodies = world.bodies.iter().filter(|body| app.session.body_visible(&body.name)).enumerate() +- .filter(|(_, body)| body.name == target.name); ++ let mut bodies = ++ world.bodies.iter().filter(|body| app.session.body_visible(&body.name)).enumerate().filter(|(_, body)| body.name == target.name); + let (ordinal, body) = bodies.next().ok_or_else(|| app.tr("render.material_target_missing").to_string())?; +- let matching_frames = frames.iter().filter(|(name, definition, component, path, _)| { +- name == &target.name && definition == &stable.definition && component == &stable.component && path == &stable.occurrence_path +- }).count(); +- if bodies.next().is_some() || ordinal != target.ordinal || body.feature != stable.feature +- || body.definition_name() != stable.definition || matching_frames != 1 +- || target.name.is_empty() || target.name.len() > 1024 || target.name.chars().any(char::is_control) ++ let matching_frames = frames ++ .iter() ++ .filter(|(name, definition, component, path, _)| { ++ name == &target.name && definition == &stable.definition && component == &stable.component && path == &stable.occurrence_path ++ }) ++ .count(); ++ if bodies.next().is_some() ++ || ordinal != target.ordinal ++ || body.feature != stable.feature ++ || body.definition_name() != stable.definition ++ || matching_frames != 1 ++ || target.name.is_empty() ++ || target.name.len() > 1024 ++ || target.name.chars().any(char::is_control) + { + return Err(app.tr("render.material_target_missing").into()); + } +@@ -386,8 +394,11 @@ + Boundary::Closed => return Err(app.tr("render.cpu_optics_boundary").into()), + }; + dielectrics.push(DielectricOptions { +- body_index: ordinal, body_name: target.name.clone(), boundary, +- ior: binding.glass.ior, absorption_per_mm: binding.glass.absorption, ++ body_index: ordinal, ++ body_name: target.name.clone(), ++ boundary, ++ ior: binding.glass.ior, ++ absorption_per_mm: binding.glass.absorption, + thickness_mm: if boundary == DielectricBoundary::ThinSheet { binding.glass.thickness } else { 0.0 }, + }); + } +@@ -552,11 +563,17 @@ + }; + ui_kit::row(ui, app.tr("render.appearance_editor.boundary"), |ui| { + let labels = ["render.appearance_editor.closed", "render.appearance_editor.thin", "render.appearance_editor.box"].map(|key| app.tr(key)); +- if ui_kit::segmented(ui, &mut boundary, &labels, ui_kit::Segments { +- compact: true, small: true, +- targets: &["render:optics-boundary-closed", "render:optics-boundary-thin", "render:optics-boundary-box"], +- ..Default::default() +- }) { ++ if ui_kit::segmented( ++ ui, ++ &mut boundary, ++ &labels, ++ ui_kit::Segments { ++ compact: true, ++ small: true, ++ targets: &["render:optics-boundary-closed", "render:optics-boundary-thin", "render:optics-boundary-box"], ++ ..Default::default() ++ }, ++ ) { + glass.boundary = match boundary { + 1 => Boundary::Thin, + 2 => Boundary::Box, diff --git a/proposals/render/2026-10-30/c16-defaults-auto-result/c15-postformat-delta-03.patch b/proposals/render/2026-10-30/c16-defaults-auto-result/c15-postformat-delta-03.patch new file mode 100644 index 000000000..7afd3b82a --- /dev/null +++ b/proposals/render/2026-10-30/c16-defaults-auto-result/c15-postformat-delta-03.patch @@ -0,0 +1,876 @@ +--- a/crates/ui-egui/src/render_workspace_tests.rs ++++ b/crates/ui-egui/src/render_workspace_tests.rs +@@ -8913,7 +8913,10 @@ + + #[test] + fn explicit_cpu_recipe_builds_typed_optics_with_independent_linear_units_and_no_design_edit() { +- use solidcraft_engine::render::{job::{DielectricBoundary, RaytraceOptions}, transmission::Transmission}; ++ use solidcraft_engine::render::{ ++ job::{DielectricBoundary, RaytraceOptions}, ++ transmission::Transmission, ++ }; + let h = fixture(); + let document = h.app.session.doc.clone(); + let before = (h.app.session.revision, h.app.session.undo.len(), h.app.session.redo.len(), h.app.session.is_dirty()); +@@ -8985,10 +8988,19 @@ + let binding = &mut h.app.render_workspace.view.materials.bindings[0]; + match case { + "coat" => binding.coat_enabled = true, +- "maps" => { binding.maps_enabled = true; binding.maps.normal = "authored-normal.png".into(); } ++ "maps" => { ++ binding.maps_enabled = true; ++ binding.maps.normal = "authored-normal.png".into(); ++ } + "shadows" => binding.glass.shadows = true, +- "subsurface" => binding.glass.subsurface = Some(solidcraft_engine::render::transmission::subsurface::Subsurface { scattering_per_mm: 0.1, anisotropy: 0.0 }), +- _ => { binding.glass_enabled = false; binding.coat_enabled = true; } ++ "subsurface" => { ++ binding.glass.subsurface = ++ Some(solidcraft_engine::render::transmission::subsurface::Subsurface { scattering_per_mm: 0.1, anisotropy: 0.0 }) ++ } ++ _ => { ++ binding.glass_enabled = false; ++ binding.coat_enabled = true; ++ } + } + let intent = format!("{:?}", h.app.render_workspace.view.materials); + let mut request = json!({"settings":{"exposure_ev":0},"sentinel":"retain"}); +@@ -9094,96 +9106,110 @@ + fn progressive_optics_preserves_identity_and_saved_gpu_conflicts_without_mutation() { + let mut h = fixture(); + let document = h.app.session.doc.clone(); +- let history = (h.app.session.revision,h.app.session.undo.len(),h.app.session.is_dirty()); +- let authored = format!("{:?}",h.app.render_workspace.view.materials.bindings[0]); ++ let history = (h.app.session.revision, h.app.session.undo.len(), h.app.session.is_dirty()); ++ let authored = format!("{:?}", h.app.render_workspace.view.materials.bindings[0]); + h.app.render_workspace.view.raytrace.progressive = Some(Default::default()); +- let progressive_final = runtime_image_request(&h.app,false).unwrap(); ++ let progressive_final = runtime_image_request(&h.app, false).unwrap(); + let final_options: RaytraceOptions = serde_json::from_value(progressive_final["raytrace"].clone()).unwrap(); + final_options.validate().unwrap(); +- assert_eq!(final_options.primary_samples,1); +- assert_eq!(final_options.progressive.unwrap().samples_per_pixel,16); +- assert_eq!(final_options.progressive.unwrap().seed,0); ++ assert_eq!(final_options.primary_samples, 1); ++ assert_eq!(final_options.progressive.unwrap().samples_per_pixel, 16); ++ assert_eq!(final_options.progressive.unwrap().seed, 0); + let optics = progressive_final["raytrace"]["dielectrics"].clone(); +- assert_eq!(optics.as_array().unwrap().len(),1); +- assert_eq!(optics[0]["body_name"],"Optics"); +- assert_eq!(optics[0]["boundary"],"closed_box"); +- assert_eq!(optics[0]["ior"],1.5); ++ assert_eq!(optics.as_array().unwrap().len(), 1); ++ assert_eq!(optics[0]["body_name"], "Optics"); ++ assert_eq!(optics[0]["boundary"], "closed_box"); ++ assert_eq!(optics[0]["ior"], 1.5); + assert!(h.app.render_workspace.view.materials.bindings[0].cpu_optics); + let from_progressive = interactive_request(&h.app).unwrap(); +- assert_eq!(from_progressive["raytrace"]["dielectrics"],optics,"preview conversion cannot erase or replace the authored optical material"); ++ assert_eq!(from_progressive["raytrace"]["dielectrics"], optics, "preview conversion cannot erase or replace the authored optical material"); + assert!(h.app.render_workspace.view.materials.bindings[0].glass_enabled); + h.app.render_workspace.view.raytrace.progressive = None; + let from_fixed = interactive_request(&h.app).unwrap(); +- assert_eq!(from_fixed["raytrace"]["dielectrics"],optics,"Fixed editor preview still carries certified optics"); ++ assert_eq!(from_fixed["raytrace"]["dielectrics"], optics, "Fixed editor preview still carries certified optics"); + let progressive_input: RaytraceOptions = serde_json::from_value(from_progressive["raytrace"].clone()).unwrap(); + progressive_input.validate().unwrap(); +- assert_eq!(progressive_input.primary_samples,1); +- assert_eq!(progressive_input.progressive.unwrap().samples_per_pixel,16); +- assert_eq!(progressive_input.progressive.unwrap().seed,0); ++ assert_eq!(progressive_input.primary_samples, 1); ++ assert_eq!(progressive_input.progressive.unwrap().samples_per_pixel, 16); ++ assert_eq!(progressive_input.progressive.unwrap().seed, 0); + let fixed_input: RaytraceOptions = serde_json::from_value(from_fixed["raytrace"].clone()).unwrap(); + fixed_input.validate().unwrap(); +- assert_eq!(fixed_input.primary_samples,1); +- assert!(fixed_input.progressive.is_none(),"the UI Fixed DTO stays Fixed until the engine preview conversion"); +- assert!(h.app.render_workspace.view.raytrace.progressive.is_none(),"constructing preview intent cannot change the manual-final editor"); ++ assert_eq!(fixed_input.primary_samples, 1); ++ assert!(fixed_input.progressive.is_none(), "the UI Fixed DTO stays Fixed until the engine preview conversion"); ++ assert!(h.app.render_workspace.view.raytrace.progressive.is_none(), "constructing preview intent cannot change the manual-final editor"); + #[cfg(not(target_arch = "wasm32"))] +- if native_host(&mut h,"progressive_bridge_obsolete_guard_adaptation") { +- use solidcraft_engine::render::job::{JobId,Phase,interactive::VisualRevision}; ++ if native_host(&mut h, "progressive_bridge_obsolete_guard_adaptation") { ++ use solidcraft_engine::render::job::{JobId, Phase, interactive::VisualRevision}; + use std::time::Duration; + // Same original20x20/one-pixel/50-distance inputs: this is actual + // capture/admission/completion, not a Beer pixel oracle (jitter may miss). + let mut final_params = progressive_final.clone(); + final_params["progressive_feedback"] = json!(true); +- let checked = h.app.run("render.preflight",final_params.clone()).unwrap(); +- let started = h.app.run("render.start",final_params).unwrap(); ++ let checked = h.app.run("render.preflight", final_params.clone()).unwrap(); ++ let started = h.app.run("render.start", final_params).unwrap(); + let final_id: JobId = serde_json::from_value(started["job"].clone()).unwrap(); + let final_job = h.app.session.render_job_handle(final_id).unwrap(); + let final_status = final_job.wait_timeout(Duration::from_secs(60)).unwrap(); +- assert_eq!(final_status.progress.phase,Phase::Completed,"{:?}",final_status.error); +- assert_eq!(serde_json::to_value(&final_status.request).unwrap(),checked["request"]); +- assert_eq!(json!(final_status.request.raytrace),progressive_final["raytrace"]); ++ assert_eq!(final_status.progress.phase, Phase::Completed, "{:?}", final_status.error); ++ assert_eq!(serde_json::to_value(&final_status.request).unwrap(), checked["request"]); ++ assert_eq!(json!(final_status.request.raytrace), progressive_final["raytrace"]); + assert!(!final_status.options.nested_media); + assert!(final_job.protected_preview_report().unwrap().is_some()); + let final_bytes = final_job.frame().unwrap().unwrap().png().to_vec(); +- for (index,params) in [&from_progressive,&from_fixed].into_iter().enumerate() { ++ for (index, params) in [&from_progressive, &from_fixed].into_iter().enumerate() { + let context = h.app.session.interactive_render().unwrap(); +- context.enable(VisualRevision { +- scene_generation:h.app.session.revision,visual_revision:index as u64+1, +- },Duration::ZERO).unwrap(); ++ context ++ .enable(VisualRevision { scene_generation: h.app.session.revision, visual_revision: index as u64 + 1 }, Duration::ZERO) ++ .unwrap(); + let ticket = context.capture(Duration::from_millis(200)).unwrap().unwrap(); +- let snapshot = context.snapshot(&h.app.session,ticket,params).unwrap(); +- assert!(snapshot.run().unwrap(),"real optical snapshot must be admitted/adopted"); ++ let snapshot = context.snapshot(&h.app.session, ticket, params).unwrap(); ++ assert!(snapshot.run().unwrap(), "real optical snapshot must be admitted/adopted"); + let job = context.current().unwrap().unwrap(); + let status = job.wait_timeout(Duration::from_secs(60)).unwrap(); +- assert_eq!(status.progress.phase,Phase::Completed,"{:?}",status.error); +- assert_eq!(status.resolved.executor.as_str(),"cpu-raytrace"); ++ assert_eq!(status.progress.phase, Phase::Completed, "{:?}", status.error); ++ assert_eq!(status.resolved.executor.as_str(), "cpu-raytrace"); + let options = status.request.raytrace.as_ref().unwrap(); +- assert_eq!(serde_json::to_value(&options.dielectrics).unwrap(),optics); +- assert_eq!(options.primary_samples,1); +- assert_eq!(options.progressive.unwrap().samples_per_pixel,16); +- assert_eq!(options.progressive.unwrap().seed,0); +- assert_eq!((status.request.width,status.request.height),(1,1)); ++ assert_eq!(serde_json::to_value(&options.dielectrics).unwrap(), optics); ++ assert_eq!(options.primary_samples, 1); ++ assert_eq!(options.progressive.unwrap().samples_per_pixel, 16); ++ assert_eq!(options.progressive.unwrap().seed, 0); ++ assert_eq!((status.request.width, status.request.height), (1, 1)); + assert!(!status.options.nested_media); +- assert_eq!(job.id(),ticket.job_id()); ++ assert_eq!(job.id(), ticket.job_id()); + assert!(job.frame().unwrap().is_some()); +- assert!(h.app.session.render_job_handle(job.id()).is_err(),"Interactive keeps a separate non-export owner"); ++ assert!(h.app.session.render_job_handle(job.id()).is_err(), "Interactive keeps a separate non-export owner"); + context.disable().unwrap(); +- assert_eq!(h.app.session.render_job_handle(final_id).unwrap().frame().unwrap().unwrap().png(),final_bytes.as_slice()); ++ assert_eq!(h.app.session.render_job_handle(final_id).unwrap().frame().unwrap().unwrap().png(), final_bytes.as_slice()); + } + } +- assert!(Arc::ptr_eq(&document,&h.app.session.doc)); +- assert_eq!(history,(h.app.session.revision,h.app.session.undo.len(),h.app.session.is_dirty())); +- assert_eq!(format!("{:?}",h.app.render_workspace.view.materials.bindings[0]),authored); ++ assert!(Arc::ptr_eq(&document, &h.app.session.doc)); ++ assert_eq!(history, (h.app.session.revision, h.app.session.undo.len(), h.app.session.is_dirty())); ++ assert_eq!(format!("{:?}", h.app.render_workspace.view.materials.bindings[0]), authored); + let mut request = wire(&h); + let before = request.clone(); + assert!(materials::params(&h.app, &mut request).unwrap_err().contains(h.app.tr("render.cpu_optics_conflict"))); + assert_eq!(request, before); + let target = h.app.render_workspace.view.materials.bindings[0].target.stable_target.clone().unwrap(); +- h.app.render_workspace.view.draft.optics.set(solidcraft_engine::doc::render_optics::SavedOptics { +- target, optics: solidcraft_engine::doc::render_optics::OpticalMaterial { +- ior: 1.5, absorption_per_mm: [0.0; 3], boundary: solidcraft_engine::doc::render_optics::OpticalBoundary::ClosedMesh, +- thickness_mm: 0.0, shadow_transmission: false, subsurface: None, +- }, +- }, false).unwrap(); ++ h.app ++ .render_workspace ++ .view ++ .draft ++ .optics ++ .set( ++ solidcraft_engine::doc::render_optics::SavedOptics { ++ target, ++ optics: solidcraft_engine::doc::render_optics::OpticalMaterial { ++ ior: 1.5, ++ absorption_per_mm: [0.0; 3], ++ boundary: solidcraft_engine::doc::render_optics::OpticalBoundary::ClosedMesh, ++ thickness_mm: 0.0, ++ shadow_transmission: false, ++ subsurface: None, ++ }, ++ }, ++ false, ++ ) ++ .unwrap(); + assert!(runtime_image_request(&h.app, false).is_err()); + assert_eq!(h.app.render_workspace.view.draft.optics.len(), 1); + } +@@ -9206,7 +9232,8 @@ + use solidcraft_engine::render::job::CpuHost; + let host = CpuHost::for_platform().unwrap(); + let available = host.kind() == solidcraft_engine::render::job::HostKind::NativeWorker +- && host.is_available() && host.validate_integrator(Integrator::Raytrace).is_ok(); ++ && host.is_available() ++ && host.validate_integrator(Integrator::Raytrace).is_ok(); + h.app.session.set_render_job_host(Some(host.clone())).unwrap(); + h.app.render_workspace.image_host = Some(host); + if !available { +@@ -9250,7 +9277,9 @@ + #[test] + fn native_library_box_reaches_same_cpu_check_start_and_real_beer_pixels() { + let mut h = fixture(); +- if !native_host(&mut h, "library_box") { return; } ++ if !native_host(&mut h, "library_box") { ++ return; ++ } + // Explicit author edit isolates Beer: index-matched boundaries have zero + // Fresnel reflection, 4 mm actual distance yields [.98,.99,1]. + let glass = &mut h.app.render_workspace.view.materials.bindings[0].glass; +@@ -9263,7 +9292,9 @@ + #[test] + fn native_cpu_optics_admission_preserves_opacity_and_refuses_false_thin_certificate() { + let mut h = fixture(); +- if !native_host(&mut h, "opacity_and_certificate") { return; } ++ if !native_host(&mut h, "opacity_and_certificate") { ++ return; ++ } + h.app.render_workspace.view.materials.bindings[0].glass.boundary = materials::Boundary::Thin; + let request = image_params(&h.app).unwrap(); + for command in ["render.preflight", "render.start"] { +@@ -9288,7 +9319,9 @@ + #[test] + fn native_thin_library_recipe_uses_actual_imported_planar_certificate_and_virtual_distance() { + let mut h = fixture(); +- if !native_host(&mut h, "library_thin") { return; } ++ if !native_host(&mut h, "library_thin") { ++ return; ++ } + let path = h.dir.join("original-optical-sheet.stl"); + // Original one-triangle geometry, not a box proxy or commercial fixture. + std::fs::write(&path, b"solid OriginalSheet\nfacet normal 0 0 1\nouter loop\nvertex -20 -20 2\nvertex 20 -20 2\nvertex 0 20 2\nendloop\nendfacet\nendsolid OriginalSheet\n").unwrap(); +@@ -9313,7 +9346,9 @@ + #[test] + fn native_library_nested_opt_in_preserves_real_child_medium_and_default_refusal() { + let mut h = fixture(); +- if !native_host(&mut h, "library_nested") { return; } ++ if !native_host(&mut h, "library_nested") { ++ return; ++ } + h.app.run("solid.box", json!({"length":10,"width":10,"height":2,"center":[0,0,2],"operation":"new","body_name":"Inner"})).unwrap(); + h.app.render_workspace.view.materials.bindings.clear(); + bind_recipe(&mut h, "Optics", "starter.glass.low-iron-clear", materials::Boundary::Box); +@@ -9340,7 +9375,9 @@ + #[test] + fn native_cpu_optics_refuses_face_alpha_and_general_closed_geometry_without_repairs() { + let mut h = fixture(); +- if !native_host(&mut h, "face_alpha_and_sphere") { return; } ++ if !native_host(&mut h, "face_alpha_and_sphere") { ++ return; ++ } + h.app.run("appearance.assign", json!({"body":"Optics","faces":[[0,0,4]],"color":"#abcdef","opacity":0.5})).unwrap(); + let mut binding = h.app.render_workspace.view.materials.bindings[0].clone(); + materials::revalidate(&mut h.app, &mut binding).unwrap(); +@@ -9399,7 +9436,9 @@ + fn native_original_library_ior_and_hdr_survive_check_start_and_captured_file_change() { + use solidcraft_engine::render::job::{JobId, Phase}; + let mut h = fixture(); +- if !native_host(&mut h, "library_ior_hdr") { return; } ++ if !native_host(&mut h, "library_ior_hdr") { ++ return; ++ } + let path = h.dir.join("original-optical-white.hdr"); + let bytes = original_hdr_bytes(128, true); + std::fs::write(&path, &bytes).unwrap(); +@@ -9432,9 +9471,16 @@ + #[test] + fn native_eight_optical_library_targets_admit_without_raising_the_ninth_target_limit() { + let mut h = fixture(); +- if !native_host(&mut h, "eight_library_targets") { return; } ++ if !native_host(&mut h, "eight_library_targets") { ++ return; ++ } + for index in 1..=8 { +- h.app.run("solid.box", json!({"length":2,"width":2,"height":2,"corner":[30*index,0,0],"body_name":format!("Optics{index}"),"operation":"new"})).unwrap(); ++ h.app ++ .run( ++ "solid.box", ++ json!({"length":2,"width":2,"height":2,"corner":[30*index,0,0],"body_name":format!("Optics{index}"),"operation":"new"}), ++ ) ++ .unwrap(); + } + h.app.render_workspace.view.materials.bindings.clear(); + bind_recipe(&mut h, "Optics", "starter.glass.low-iron-clear", materials::Boundary::Box); +@@ -9482,9 +9528,16 @@ + for language in ["en", "es", "de", "ko", "ar", "he", "ja", "vi", "zh"] { + let locale = crate::i18n::Locale::for_language(language); + for key in [ +- "render.cpu_optics_boundary", "render.cpu_optics_conflict", "render.cpu_optics_enable", +- "render.cpu_optics_explicit", "render.cpu_optics_fixed", "render.cpu_optics_help", +- "render.cpu_optics_limit", "render.cpu_optics_request", "render.cpu_optics_saved", "render.cpu_optics_unsupported", ++ "render.cpu_optics_boundary", ++ "render.cpu_optics_conflict", ++ "render.cpu_optics_enable", ++ "render.cpu_optics_explicit", ++ "render.cpu_optics_fixed", ++ "render.cpu_optics_help", ++ "render.cpu_optics_limit", ++ "render.cpu_optics_request", ++ "render.cpu_optics_saved", ++ "render.cpu_optics_unsupported", + ] { + assert_ne!(locale.text(key), key, "{language}: {key}"); + assert!(!locale.text(key).is_empty(), "{language}: {key}"); +@@ -9494,7 +9547,11 @@ + + fn editor_frame(h: &mut Harness, events: Vec) { + let mut output = h.ctx.run_ui( +- egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(480.0, 2400.0))), events, ..Default::default() }, ++ egui::RawInput { ++ screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(480.0, 2400.0))), ++ events, ++ ..Default::default() ++ }, + |ui| { + ui.set_width(420.0); + materials::selection_controls(&mut h.app, ui, Some("Optics")); +@@ -9506,9 +9563,13 @@ + fn editor_click(h: &mut Harness, id: &str) { + let at = crate::scenario::rect_of(id).unwrap().center(); + for pressed in [true, false] { +- editor_frame(h, vec![egui::Event::PointerMoved(at), egui::Event::PointerButton { +- pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE, +- }]); ++ editor_frame( ++ h, ++ vec![ ++ egui::Event::PointerMoved(at), ++ egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE }, ++ ], ++ ); + } + editor_frame(h, vec![]); + } +@@ -9568,16 +9629,12 @@ + #[cfg(not(target_arch = "wasm32"))] + mod manual_final_cpu_feedback_tests { + use super::*; +- use solidcraft_engine::render::job::{ +- CpuHost, CpuProgressiveOptions, HostKind, JobHandle, PartialPreviewPlan, +- PartialPreviewProjection, Phase, +- }; ++ use solidcraft_engine::render::job::{CpuHost, CpuProgressiveOptions, HostKind, JobHandle, PartialPreviewPlan, PartialPreviewProjection, Phase}; + + fn fixture(width: u32, height: u32, samples: u32, background: [u8; 3], case: &str) -> Option { + let mut h = Harness::new(); + let host = CpuHost::for_platform().unwrap(); +- let available = host.kind() == HostKind::NativeWorker && host.is_available() +- && host.validate_integrator(Integrator::Raytrace).is_ok(); ++ let available = host.kind() == HostKind::NativeWorker && host.is_available() && host.validate_integrator(Integrator::Raytrace).is_ok(); + h.app.session.set_render_job_host(Some(host.clone())).unwrap(); + h.app.render_workspace.image_host = Some(host); + h.app.ui.tab = "RENDER".into(); +@@ -9591,7 +9648,9 @@ + view.draft.exposure_ev = 0.0; + view.transparent = false; + view.raytrace = RaytraceOptions { +- primary_samples: 1, lights: Some(Vec::new()), shadows: false, ++ primary_samples: 1, ++ lights: Some(Vec::new()), ++ shadows: false, + progressive: Some(CpuProgressiveOptions { samples_per_pixel: samples, seed: 83 }), + ..Default::default() + }; +@@ -9602,8 +9661,8 @@ + "raytrace":{"primary_samples":1,"lights":[],"shadows":false, + "progressive":{"samples_per_pixel":samples,"seed":83}}}); + assert!(image_params(&h.app).is_err()); +- assert!(h.app.run("render.preflight",wire.clone()).is_err()); +- assert!(h.app.run("render.start",wire).is_err()); ++ assert!(h.app.run("render.preflight", wire.clone()).is_err()); ++ assert!(h.app.run("render.start", wire).is_err()); + assert!(h.app.render_workspace.view.job.is_none()); + assert!(h.app.render_workspace.final_partial.is_none()); + eprintln!("MANUAL_FINAL_CPU_BRANCH case={case} cpu_supported=false unsupported_refusal_asserted=true"); +@@ -9614,12 +9673,12 @@ + } + + fn actual_final(h: &mut Harness) -> JobHandle { +- ribbon::perform_job(&mut h.app,"render.start").unwrap(); ++ ribbon::perform_job(&mut h.app, "render.start").unwrap(); + let job = h.app.render_workspace.view.job.unwrap(); + let handle = h.app.session.render_job_handle(job).unwrap(); + let status = handle.wait_timeout(Duration::from_secs(60)).unwrap(); +- assert_eq!(status.progress.phase,Phase::Completed,"{:?}",status.error); +- assert_eq!(status.resolved.executor.as_str(),"cpu-raytrace"); ++ assert_eq!(status.progress.phase, Phase::Completed, "{:?}", status.error); ++ assert_eq!(status.resolved.executor.as_str(), "cpu-raytrace"); + assert!(handle.frame().unwrap().is_some()); + assert!(handle.protected_preview_report().unwrap().is_some()); + handle +@@ -9629,170 +9688,173 @@ + // Derive bounded display pixels from an actual completed native final, then + // author an explicit source-frontier descriptor to exercise the UI policy. + // No JobHandle, host status, PreviewInfo or GPU executor is fabricated. +- fn install_policy_partial( +- h: &mut Harness, handle: &JobHandle, passes: u32, prefix: u64, sequence: u64, +- ) -> interactive::PartialSampling { +- use sha2::{Digest,Sha256}; ++ fn install_policy_partial(h: &mut Harness, handle: &JobHandle, passes: u32, prefix: u64, sequence: u64) -> interactive::PartialSampling { ++ use sha2::{Digest, Sha256}; + let status = handle.status().unwrap(); +- assert_eq!(status.progress.phase,Phase::Completed); ++ assert_eq!(status.progress.phase, Phase::Completed); + let frame = handle.frame().unwrap().unwrap(); + let source = image::load_from_memory(frame.png()).unwrap().to_rgba8(); +- let plan = PartialPreviewPlan::new(status.request.width,status.request.height).unwrap(); ++ let plan = PartialPreviewPlan::new(status.request.width, status.request.height).unwrap(); + let mut pixels = Vec::new(); + for index in 0..usize::try_from(plan.pixels()).unwrap() { + let source_index = plan.source_index(index).unwrap(); + let count = passes + u32::from((source_index as u64) < prefix); + if count == 0 { +- pixels.extend_from_slice(&[0,0,0,0]); ++ pixels.extend_from_slice(&[0, 0, 0, 0]); + } else { + let x = source_index % status.request.width as usize; + let y = source_index / status.request.width as usize; +- pixels.extend_from_slice(&source.get_pixel(x as u32,y as u32).0); ++ pixels.extend_from_slice(&source.get_pixel(x as u32, y as u32).0); + } + } +- let png = super::partial_png_contract_encode(plan.width(),plan.height(),pixels); ++ let png = super::partial_png_contract_encode(plan.width(), plan.height(), pixels); + let mut frame_info = frame.info.clone(); + frame_info.width = plan.width(); + frame_info.height = plan.height(); + frame_info.png_bytes = png.len() as u64; +- frame_info.png_sha256 = format!("{:x}",Sha256::digest(&png)); ++ frame_info.png_sha256 = format!("{:x}", Sha256::digest(&png)); + let info = PartialPreviewInfo { +- frame:frame_info,sequence,source_width:status.request.width,source_height:status.request.height, +- completed_passes:passes,updated_prefix:prefix, +- projection:PartialPreviewProjection::TopLeftRepresentativeV1, ++ frame: frame_info, ++ sequence, ++ source_width: status.request.width, ++ source_height: status.request.height, ++ completed_passes: passes, ++ updated_prefix: prefix, ++ projection: PartialPreviewProjection::TopLeftRepresentativeV1, + }; +- let covered = vec![0;usize::try_from(plan.pixels()).unwrap()]; // committed misses have zero hit coverage ++ let covered = vec![0; usize::try_from(plan.pixels()).unwrap()]; // committed misses have zero hit coverage + let expected = interactive::PartialExpectation { +- job:handle.id(),scene_generation:status.scene_generation,request:&status.request, +- final_dimensions:[status.request.width,status.request.height], ++ job: handle.id(), ++ scene_generation: status.scene_generation, ++ request: &status.request, ++ final_dimensions: [status.request.width, status.request.height], + }; +- let sampling = interactive::validate_partial_metadata(&expected,&info,png.len(),covered.len(),None).unwrap().unwrap(); +- let image = interactive::decode_partial_image( +- &status.request,&info,&png,&covered,sampling,h.ctx.input(|input|input.max_texture_side), +- ).unwrap(); +- let texture = h.ctx.load_texture("manual_final_policy_partial",image,egui::TextureOptions::NEAREST); +- h.app.render_workspace.final_partial = Some(FinalPartialImage { info,sampling,image:Ok(texture) }); ++ let sampling = interactive::validate_partial_metadata(&expected, &info, png.len(), covered.len(), None).unwrap().unwrap(); ++ let image = ++ interactive::decode_partial_image(&status.request, &info, &png, &covered, sampling, h.ctx.input(|input| input.max_texture_side)).unwrap(); ++ let texture = h.ctx.load_texture("manual_final_policy_partial", image, egui::TextureOptions::NEAREST); ++ h.app.render_workspace.final_partial = Some(FinalPartialImage { info, sampling, image: Ok(texture) }); + sampling + } + + #[test] + fn native_manual_final_gui_opt_in_preserves_request_and_promotes_only_real_final() { +- let Some(mut h) = fixture(13,7,9,[17,89,203],"gui_opt_in") else { return }; ++ let Some(mut h) = fixture(13, 7, 9, [17, 89, 203], "gui_opt_in") else { return }; + let document = h.app.session.doc.clone(); +- let before = (h.app.session.revision,h.app.session.undo.len(),h.app.session.is_dirty()); ++ let before = (h.app.session.revision, h.app.session.undo.len(), h.app.session.is_dirty()); + let stored = setups::snapshot(&h.app).unwrap(); + assert!(serde_json::to_value(&stored).unwrap().get("progressive_feedback").is_none()); + let offline = image_request(&h.app).unwrap(); + assert!(offline.get("progressive_feedback").is_none()); + let request = image_params(&h.app).unwrap(); +- assert_eq!(request["progressive_feedback"],true); ++ assert_eq!(request["progressive_feedback"], true); + h.app.render_workspace.view.raytrace.progressive = None; + assert!(image_params(&h.app).unwrap().get("progressive_feedback").is_none()); +- h.app.render_workspace.view.raytrace.progressive = Some(CpuProgressiveOptions { samples_per_pixel:9,seed:83 }); +- let checked = h.app.session.execute("render.preflight",&request).unwrap(); +- ribbon::perform_job(&mut h.app,"render.preflight").unwrap(); +- assert_eq!(h.app.render_workspace.view.cpu.checked.as_ref().unwrap().request,request); ++ h.app.render_workspace.view.raytrace.progressive = Some(CpuProgressiveOptions { samples_per_pixel: 9, seed: 83 }); ++ let checked = h.app.session.execute("render.preflight", &request).unwrap(); ++ ribbon::perform_job(&mut h.app, "render.preflight").unwrap(); ++ assert_eq!(h.app.render_workspace.view.cpu.checked.as_ref().unwrap().request, request); + let handle = actual_final(&mut h); + let status = handle.status().unwrap(); +- assert_eq!(serde_json::to_value(&status.request).unwrap(),checked["request"]); +- assert_eq!((status.request.width,status.request.height),(13,7)); ++ assert_eq!(serde_json::to_value(&status.request).unwrap(), checked["request"]); ++ assert_eq!((status.request.width, status.request.height), (13, 7)); + let progressive = status.request.raytrace.as_ref().unwrap().progressive.unwrap(); +- assert_eq!((progressive.samples_per_pixel,progressive.seed),(9,83)); ++ assert_eq!((progressive.samples_per_pixel, progressive.seed), (9, 83)); + let image = image::load_from_memory(handle.frame().unwrap().unwrap().png()).unwrap().to_rgba8(); +- assert!(image.pixels().all(|pixel|pixel.0 == [17,89,203,255])); ++ assert!(image.pixels().all(|pixel| pixel.0 == [17, 89, 203, 255])); + let ctx = h.ctx.clone(); +- cache_render_images(&mut h.app,&ctx); +- assert_eq!(h.app.render_workspace.view.completed,Some(handle.id())); ++ cache_render_images(&mut h.app, &ctx); ++ assert_eq!(h.app.render_workspace.view.completed, Some(handle.id())); + assert!(h.app.render_workspace.final_partial.is_none()); + let display = displayed_image(&h.app).unwrap(); + assert!(!display.provisional()); + assert!(display.preview.is_none() && display.partial.is_none()); +- assert_eq!(display.logical_size,[13,7]); +- assert_eq!(display.info.job,handle.id()); +- assert_eq!(setups::snapshot(&h.app).unwrap(),stored); +- assert!(Arc::ptr_eq(&document,&h.app.session.doc)); +- assert_eq!(before,(h.app.session.revision,h.app.session.undo.len(),h.app.session.is_dirty())); ++ assert_eq!(display.logical_size, [13, 7]); ++ assert_eq!(display.info.job, handle.id()); ++ assert_eq!(setups::snapshot(&h.app).unwrap(), stored); ++ assert!(Arc::ptr_eq(&document, &h.app.session.doc)); ++ assert_eq!(before, (h.app.session.revision, h.app.session.undo.len(), h.app.session.is_dirty())); + } + + #[test] + fn native_final_partial_policy_keeps_global_unknown_full_framing_and_real_final_priority() { +- let Some(mut h) = fixture(1025,1,3,[17,89,203],"partial_policy") else { return }; ++ let Some(mut h) = fixture(1025, 1, 3, [17, 89, 203], "partial_policy") else { return }; + let handle = actual_final(&mut h); + assert!(h.app.render_workspace.view.completed.is_none()); + // The top-left 1024 representatives are known, but source pixel1024 is not. +- let sampling = install_policy_partial(&mut h,&handle,0,1024,1); ++ let sampling = install_policy_partial(&mut h, &handle, 0, 1024, 1); + assert!(sampling.source_unknown()); +- assert_eq!(sampling.sample_range(),(0,1)); +- assert_eq!(sampling.sampled_source_pixels(),1024); ++ assert_eq!(sampling.sample_range(), (0, 1)); ++ assert_eq!(sampling.sampled_source_pixels(), 1024); + let display = displayed_image(&h.app).unwrap(); + assert!(display.provisional() && display.partial.is_some() && display.preview.is_none()); +- assert_eq!(display.logical_size,[1025,1]); +- assert_eq!((display.info.width,display.info.height),(1024,1)); +- assert_eq!(display.image.as_ref().unwrap().size(),[1024,1]); ++ assert_eq!(display.logical_size, [1025, 1]); ++ assert_eq!((display.info.width, display.info.height), (1024, 1)); ++ assert_eq!(display.image.as_ref().unwrap().size(), [1024, 1]); + assert!(reduced_display(&h.app)); +- let camera = Camera { distance:37.0,..Default::default() }; ++ let camera = Camera { distance: 37.0, ..Default::default() }; + h.app.render_workspace.view.result_camera = camera; + h.app.render_workspace.view.result_scale = ResultScale::Free; + h.app.render_workspace.view.result_job = Some(handle.id()); + let report = handle.protected_preview_report().unwrap(); + let ctx = h.ctx.clone(); +- cache_render_images(&mut h.app,&ctx); +- assert_eq!(h.app.render_workspace.view.completed,Some(handle.id())); ++ cache_render_images(&mut h.app, &ctx); ++ assert_eq!(h.app.render_workspace.view.completed, Some(handle.id())); + assert!(h.app.render_workspace.final_partial.is_none()); + let display = displayed_image(&h.app).unwrap(); + assert!(!display.provisional()); +- assert_eq!(display.logical_size,[1025,1]); ++ assert_eq!(display.logical_size, [1025, 1]); + assert!(!reduced_display(&h.app)); +- assert_eq!(h.app.render_workspace.view.result_camera,camera); +- assert_eq!(h.app.render_workspace.view.result_scale,ResultScale::Free); ++ assert_eq!(h.app.render_workspace.view.result_camera, camera); ++ assert_eq!(h.app.render_workspace.view.result_scale, ResultScale::Free); + invalidate_images(&mut h.app); + assert!(h.app.render_workspace.final_partial.is_none()); +- assert_eq!(handle.protected_preview_report().unwrap(),report,"presentation invalidation cannot reset the actual ledger"); ++ assert_eq!(handle.protected_preview_report().unwrap(), report, "presentation invalidation cannot reset the actual ledger"); + } + + #[test] + fn native_late_complete_policy_preserves_retained_export_then_reconciles_actual_frame() { +- let Some(mut h) = fixture(13,7,9,[17,89,203],"late_complete") else { return }; ++ let Some(mut h) = fixture(13, 7, 9, [17, 89, 203], "late_complete") else { return }; + let first = actual_final(&mut h); + let ctx = h.ctx.clone(); +- cache_render_images(&mut h.app,&ctx); ++ cache_render_images(&mut h.app, &ctx); + let first_bytes = first.frame().unwrap().unwrap().png().to_vec(); +- h.app.render_workspace.view.draft.background = [91,33,187]; ++ h.app.render_workspace.view.draft.background = [91, 33, 187]; + let second = actual_final(&mut h); +- assert_eq!(h.app.render_workspace.view.completed,Some(first.id())); +- install_policy_partial(&mut h,&second,0,5,1); ++ assert_eq!(h.app.render_workspace.view.completed, Some(first.id())); ++ install_policy_partial(&mut h, &second, 0, 5, 1); + assert!(displayed_image(&h.app).unwrap().provisional()); + let old_path = h.dir.join("manual-final-retained.png"); + let export_job = h.app.render_workspace.view.completed.unwrap(); +- h.app.run("render.export",json!({"job":export_job,"path":old_path})).unwrap(); +- assert_eq!(std::fs::read(&old_path).unwrap(),first_bytes); ++ h.app.run("render.export", json!({"job":export_job,"path":old_path})).unwrap(); ++ assert_eq!(std::fs::read(&old_path).unwrap(), first_bytes); + // Regression oracle for the observed event order: + // frame read absent -> later real status Completed -> real frame promoted + // BEFORE provisional clear/fallback. This calls the production policy on + // an actual completed native handle; it does not fake the earlier read. +- assert!(!final_job_still_running(&mut h.app,&second)); +- assert_eq!(h.app.render_workspace.view.completed,Some(second.id())); +- cache_render_images(&mut h.app,&ctx); ++ assert!(!final_job_still_running(&mut h.app, &second)); ++ assert_eq!(h.app.render_workspace.view.completed, Some(second.id())); ++ cache_render_images(&mut h.app, &ctx); + assert!(!displayed_image(&h.app).unwrap().provisional()); + assert!(h.app.render_workspace.final_partial.is_none()); + let new_path = h.dir.join("manual-final-current.png"); + let export_job = h.app.render_workspace.view.completed.unwrap(); +- h.app.run("render.export",json!({"job":export_job,"path":new_path})).unwrap(); +- assert_eq!(std::fs::read(&new_path).unwrap(),second.frame().unwrap().unwrap().png()); ++ h.app.run("render.export", json!({"job":export_job,"path":new_path})).unwrap(); ++ assert_eq!(std::fs::read(&new_path).unwrap(), second.frame().unwrap().unwrap().png()); + let final_pixels = image::load_from_memory(&std::fs::read(&new_path).unwrap()).unwrap().to_rgba8(); +- assert!(final_pixels.pixels().all(|pixel|pixel.0 == [91,33,187,255])); +- assert!(!final_job_still_running(&mut h.app,&first),"a different selected final cannot be reconciled through an old handle"); +- assert_eq!(h.app.render_workspace.view.completed,Some(second.id())); ++ assert!(final_pixels.pixels().all(|pixel| pixel.0 == [91, 33, 187, 255])); ++ assert!(!final_job_still_running(&mut h.app, &first), "a different selected final cannot be reconciled through an old handle"); ++ assert_eq!(h.app.render_workspace.view.completed, Some(second.id())); + } + fn author_box_optics(h: &mut Harness) { +- h.app.run("solid.box",json!({"length":200,"width":200,"height":4,"center":[0,0,2],"body_name":"ManualOptics"})).unwrap(); +- h.app.run("render.scene",json!({})).unwrap(); ++ h.app.run("solid.box", json!({"length":200,"width":200,"height":4,"center":[0,0,2],"body_name":"ManualOptics"})).unwrap(); ++ h.app.run("render.scene", json!({})).unwrap(); + h.app.ui.tab = "RENDER".into(); + let view = &mut h.app.render_workspace.view; + view.method = ImageMethod::CpuRaytrace; + view.draft.width = 1; + view.draft.height = 1; +- view.draft.background = [255;3]; ++ view.draft.background = [255; 3]; + view.draft.stage.clear(); + view.draft.surfaces.clear(); + view.transparent = false; +@@ -9801,13 +9863,13 @@ + view.raytrace.lights = Some(Vec::new()); + view.raytrace.shadows = false; + view.cpu.environment = cpu::Environment::Constant; +- view.cpu.color = [1.0;3]; ++ view.cpu.color = [1.0; 3]; + view.cpu.intensity = 1.0; +- h.app.cam = Camera { distance:10.0,fov:0.0,..Default::default() }; ++ h.app.cam = Camera { distance: 10.0, fov: 0.0, ..Default::default() }; + h.app.cam.set_view(StandardView::Top); +- h.app.cam.target = solidcraft_engine::geom::Vec3::new(0.0,0.0,2.0); +- let target = materials::read_targets(&mut h.app).unwrap().into_iter().find(|target|target.name == "ManualOptics").unwrap(); +- let mut binding = materials::Binding::new(target,&h.app); ++ h.app.cam.target = solidcraft_engine::geom::Vec3::new(0.0, 0.0, 2.0); ++ let target = materials::read_targets(&mut h.app).unwrap().into_iter().find(|target| target.name == "ManualOptics").unwrap(); ++ let mut binding = materials::Binding::new(target, &h.app); + binding.glass_enabled = true; + binding.cpu_optics = true; + binding.glass = materials::Glass::recipe("starter.glass.low-iron-clear").unwrap(); +@@ -9820,32 +9882,45 @@ + fn editor_text(h: &mut Harness, events: Vec) -> String { + fn collect(shape: &egui::Shape, text: &mut String) { + match shape { +- egui::Shape::Text(shape) => { text.push_str(shape.galley.text()); text.push('\n'); } +- egui::Shape::Vec(shapes) => for shape in shapes { collect(shape,text); }, ++ egui::Shape::Text(shape) => { ++ text.push_str(shape.galley.text()); ++ text.push('\n'); ++ } ++ egui::Shape::Vec(shapes) => { ++ for shape in shapes { ++ collect(shape, text); ++ } ++ } + _ => {} + } + } + let mut output = h.ctx.run_ui( +- egui::RawInput { screen_rect:Some(egui::Rect::from_min_size(egui::Pos2::ZERO,egui::vec2(480.0,3200.0))),events,..Default::default() }, ++ egui::RawInput { ++ screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(480.0, 3200.0))), ++ events, ++ ..Default::default() ++ }, + |ui| { + ui.set_width(420.0); +- materials::selection_controls(&mut h.app,ui,Some("ManualOptics")); ++ materials::selection_controls(&mut h.app, ui, Some("ManualOptics")); + }, + ); + let mut text = String::new(); +- for clipped in &output.shapes { collect(&clipped.shape,&mut text); } ++ for clipped in &output.shapes { ++ collect(&clipped.shape, &mut text); ++ } + output.textures_delta.clear(); + text + } + + #[test] + fn certification_note_draws_cpu_check_guidance_in_both_sampling_modes_and_legacy_gpu_note() { +- let pending: Value = serde_json::from_str(include_str!(concat!( +- env!("CARGO_MANIFEST_DIR"),"/../../assets/locales/pending/cpu-optical-certification.json" +- ))).unwrap(); ++ let pending: Value = ++ serde_json::from_str(include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets/locales/pending/cpu-optical-certification.json"))) ++ .unwrap(); + let key = "render.cpu_optics_certification"; +- for locale in ["ar","de","en","es","he","ja","ko","vi","zh"] { +- assert_eq!(pending[locale].as_object().unwrap().len(),1); ++ for locale in ["ar", "de", "en", "es", "he", "ja", "ko", "vi", "zh"] { ++ assert_eq!(pending[locale].as_object().unwrap().len(), 1); + assert!(!pending[locale][key].as_str().unwrap().trim().is_empty()); + } + let mut h = Harness::new(); +@@ -9854,86 +9929,102 @@ + h.app.render_workspace.view.raytrace.progressive = None; + let cpu_note = h.app.tr(key).to_string(); + let gpu_note = h.app.tr("render.material_certification").to_string(); +- assert_ne!(cpu_note,key,"a missing catalog fallback is not a translated note"); +- assert_ne!(gpu_note,"render.material_certification"); ++ assert_ne!(cpu_note, key, "a missing catalog fallback is not a translated note"); ++ assert_ne!(gpu_note, "render.material_certification"); + let document = h.app.session.doc.clone(); +- let before = (h.app.session.revision,h.app.session.undo.len(),h.app.session.is_dirty(), +- h.app.render_workspace.view.job,h.app.render_workspace.view.completed); +- let binding_before = format!("{:?}",h.app.render_workspace.view.materials.bindings[0]); +- let initial = editor_text(&mut h,Vec::new()); ++ let before = ( ++ h.app.session.revision, ++ h.app.session.undo.len(), ++ h.app.session.is_dirty(), ++ h.app.render_workspace.view.job, ++ h.app.render_workspace.view.completed, ++ ); ++ let binding_before = format!("{:?}", h.app.render_workspace.view.materials.bindings[0]); ++ let initial = editor_text(&mut h, Vec::new()); + if !initial.contains(&cpu_note) { +- let heading = format!("dialog:section:{}",h.app.tr("render.appearance_editor.glass")); ++ let heading = format!("dialog:section:{}", h.app.tr("render.appearance_editor.glass")); + let at = crate::scenario::rect_of(&heading).unwrap().center(); +- for pressed in [true,false] { +- editor_text(&mut h,vec![egui::Event::PointerMoved(at),egui::Event::PointerButton { +- pos:at,button:egui::PointerButton::Primary,pressed,modifiers:egui::Modifiers::NONE, +- }]); ++ for pressed in [true, false] { ++ editor_text( ++ &mut h, ++ vec![ ++ egui::Event::PointerMoved(at), ++ egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE }, ++ ], ++ ); + } + } +- for progressive in [None,Some(CpuProgressiveOptions { samples_per_pixel:5,seed:13 })] { ++ for progressive in [None, Some(CpuProgressiveOptions { samples_per_pixel: 5, seed: 13 })] { + h.app.render_workspace.view.method = ImageMethod::CpuRaytrace; + h.app.render_workspace.view.raytrace.progressive = progressive; +- let text = editor_text(&mut h,Vec::new()); +- assert!(text.contains(&cpu_note),"{text}"); +- assert!(!text.contains(&gpu_note),"{text}"); ++ let text = editor_text(&mut h, Vec::new()); ++ assert!(text.contains(&cpu_note), "{text}"); ++ assert!(!text.contains(&gpu_note), "{text}"); + } + h.app.render_workspace.view.method = ImageMethod::GpuRaytrace; +- let text = editor_text(&mut h,Vec::new()); +- assert!(text.contains(&gpu_note),"{text}"); +- assert!(!text.contains(&cpu_note),"{text}"); +- assert_eq!(format!("{:?}",h.app.render_workspace.view.materials.bindings[0]),binding_before); +- assert!(Arc::ptr_eq(&document,&h.app.session.doc)); +- assert_eq!(before,(h.app.session.revision,h.app.session.undo.len(),h.app.session.is_dirty(), +- h.app.render_workspace.view.job,h.app.render_workspace.view.completed)); ++ let text = editor_text(&mut h, Vec::new()); ++ assert!(text.contains(&gpu_note), "{text}"); ++ assert!(!text.contains(&cpu_note), "{text}"); ++ assert_eq!(format!("{:?}", h.app.render_workspace.view.materials.bindings[0]), binding_before); ++ assert!(Arc::ptr_eq(&document, &h.app.session.doc)); ++ assert_eq!( ++ before, ++ ( ++ h.app.session.revision, ++ h.app.session.undo.len(), ++ h.app.session.is_dirty(), ++ h.app.render_workspace.view.job, ++ h.app.render_workspace.view.completed ++ ) ++ ); + // Text/layout evidence only: selecting a note never certifies a CPU/GPU render. + } + + #[test] + fn native_progressive_optical_recipe_keeps_authored_ior_certificate_and_final_capture() { +- let Some(mut h) = fixture(1,1,5,[255;3],"progressive_optics") else { return }; ++ let Some(mut h) = fixture(1, 1, 5, [255; 3], "progressive_optics") else { return }; + author_box_optics(&mut h); +- h.app.render_workspace.view.raytrace.progressive = Some(CpuProgressiveOptions { samples_per_pixel:5,seed:13 }); ++ h.app.render_workspace.view.raytrace.progressive = Some(CpuProgressiveOptions { samples_per_pixel: 5, seed: 13 }); + // The orthographic pixel's entire jitter support lies in +/-4mm, + // strictly inside the independently authored +/-100mm box footprint. +- assert_eq!(h.app.cam.half_height(),4.0); +- for (x,y) in [(0.0,0.0),(1.0,0.0),(0.0,1.0),(1.0,1.0)] { +- let (origin,direction) = h.app.cam.ray(x,y,1.0,1.0); ++ assert_eq!(h.app.cam.half_height(), 4.0); ++ for (x, y) in [(0.0, 0.0), (1.0, 0.0), (0.0, 1.0), (1.0, 1.0)] { ++ let (origin, direction) = h.app.cam.ray(x, y, 1.0, 1.0); + assert!(direction.x.abs() < 1e-12 && direction.y.abs() < 1e-12); +- assert!((direction.z.abs()-1.0).abs() < 1e-12); +- let point = origin + direction * ((4.0-origin.z)/direction.z); +- assert!(point.x.abs() <= 4.0+1e-9 && point.y.abs() <= 4.0+1e-9); ++ assert!((direction.z.abs() - 1.0).abs() < 1e-12); ++ let point = origin + direction * ((4.0 - origin.z) / direction.z); ++ assert!(point.x.abs() <= 4.0 + 1e-9 && point.y.abs() <= 4.0 + 1e-9); + assert!(point.x.abs() < 100.0 && point.y.abs() < 100.0); + } + let document = h.app.session.doc.clone(); +- let before = (h.app.session.revision,h.app.session.undo.len(),h.app.session.is_dirty()); +- let binding_before = format!("{:?}",h.app.render_workspace.view.materials.bindings[0]); ++ let before = (h.app.session.revision, h.app.session.undo.len(), h.app.session.is_dirty()); ++ let binding_before = format!("{:?}", h.app.render_workspace.view.materials.bindings[0]); + let request = image_params(&h.app).unwrap(); +- assert_eq!(request["progressive_feedback"],true); ++ assert_eq!(request["progressive_feedback"], true); + let optics = &request["raytrace"]["dielectrics"][0]; +- assert_eq!(optics["body_name"],"ManualOptics"); +- assert_eq!(optics["boundary"],"closed_box"); +- assert_eq!(optics["ior"],1.5,"the production recipe IOR is not reduced for this case"); +- for (index,transmission) in [0.98_f64,0.99,1.0].into_iter().enumerate() { +- let expected = -transmission.ln()/4.0; +- assert!((optics["absorption_per_mm"][index].as_f64().unwrap()-expected).abs() < 1e-15); +- } +- let checked = h.app.session.execute("render.preflight",&request).unwrap(); ++ assert_eq!(optics["body_name"], "ManualOptics"); ++ assert_eq!(optics["boundary"], "closed_box"); ++ assert_eq!(optics["ior"], 1.5, "the production recipe IOR is not reduced for this case"); ++ for (index, transmission) in [0.98_f64, 0.99, 1.0].into_iter().enumerate() { ++ let expected = -transmission.ln() / 4.0; ++ assert!((optics["absorption_per_mm"][index].as_f64().unwrap() - expected).abs() < 1e-15); ++ } ++ let checked = h.app.session.execute("render.preflight", &request).unwrap(); + let handle = actual_final(&mut h); + let status = handle.status().unwrap(); +- assert_eq!(serde_json::to_value(&status.request).unwrap(),checked["request"]); +- assert_eq!(json!(status.request.raytrace),request["raytrace"]); ++ assert_eq!(serde_json::to_value(&status.request).unwrap(), checked["request"]); ++ assert_eq!(json!(status.request.raytrace), request["raytrace"]); + assert!(!status.options.nested_media); + let frame = handle.frame().unwrap().unwrap(); + let pixels = image::load_from_memory(frame.png()).unwrap().to_rgba8(); +- assert_eq!(pixels.dimensions(),(1,1)); +- let pixel = pixels.get_pixel(0,0).0; +- assert_eq!(pixel[3],255); +- assert!(pixel[..3].iter().any(|value|*value > 0)); +- assert_eq!(format!("{:?}",h.app.render_workspace.view.materials.bindings[0]),binding_before); +- assert!(Arc::ptr_eq(&document,&h.app.session.doc)); +- assert_eq!(before,(h.app.session.revision,h.app.session.undo.len(),h.app.session.is_dirty())); ++ assert_eq!(pixels.dimensions(), (1, 1)); ++ let pixel = pixels.get_pixel(0, 0).0; ++ assert_eq!(pixel[3], 255); ++ assert!(pixel[..3].iter().any(|value| *value > 0)); ++ assert_eq!(format!("{:?}", h.app.render_workspace.view.materials.bindings[0]), binding_before); ++ assert!(Arc::ptr_eq(&document, &h.app.session.doc)); ++ assert_eq!(before, (h.app.session.revision, h.app.session.undo.len(), h.app.session.is_dirty())); + // Actual CPU capture/completion + nonblack optical smoke, not a full + // Fresnel/TIR oracle or a partial-optical-tree while-running receipt. + } +- +-} ++} diff --git a/proposals/render/2026-10-30/c16-defaults-auto-result/c15-postformat-manifest.json b/proposals/render/2026-10-30/c16-defaults-auto-result/c15-postformat-manifest.json new file mode 100644 index 000000000..03580b6a0 --- /dev/null +++ b/proposals/render/2026-10-30/c16-defaults-auto-result/c15-postformat-manifest.json @@ -0,0 +1,289 @@ +{ + "schema": 1, + "status": "EXACT_SOURCE_ONLY_FORMATTING_BRIDGE_NOT_A_TEST_PASS", + "base": "../actual19-reviewed-source/README.md", + "base_composition_sha256": "605292e1edb0ffaa2e1830cc3d277f006e6fc218f8ec6fe0dc2bc27b321ffe69", + "base_adopted_source_manifest_sha256": "5ec1e34bfc91f4e0dc5970191bc34199ad856d2cd998a96f605e01662bf439f8", + "C15_initial_source_manifest_sha256": "f9c2651977c95ee2120ae868c5ff4aeceeaae40e31f8a4cd3a6405d61299f57d", + "C15_post_format_source_manifest_sha256": "2fe4f37371e7376e02ae89a080e51fad82e6f6c564bfe8b8a8075c2951fe1f31", + "source_members": 3571, + "files_changed": 12, + "patch": { + "parts": [ + { + "path": "c15-postformat-delta-01.patch", + "bytes": 64030, + "sha256": "1fde9b825ed95b18929f3284c89140d6340026edd5314a797079a187571f19ab" + }, + { + "path": "c15-postformat-delta-02.patch", + "bytes": 78431, + "sha256": "d584c829f2325c9801433617366b8cc38dc4f681fecf2dd5fef2f5c105dd24ae" + }, + { + "path": "c15-postformat-delta-03.patch", + "bytes": 54381, + "sha256": "e1c151d97dce0ffdece14bbbf02ec551abc177145b739dce267d4bb0018ddf9a" + } + ], + "bytes": 196842, + "sha256": "e545a3323c50e0e5f0e55ccbe0260b7fa2d45b3cb1999a78328c1e6fdac21508", + "parts_preserve_source_file_boundaries": true + }, + "files": [ + { + "path": "crates/engine/src/cmd/render/jobs.rs", + "before": { + "sha256": "ff82cad9aae9f57c81c0da40bd4a7ebbfc390cbbc7fe70ef498eb21a5eb07eea", + "bytes": 63778, + "eol": "LF", + "crlf": 0, + "lf": 1229, + "utf8_bom": false + }, + "candidate": { + "sha256": "741caaaeb765853b6d89e0a69eaa8f425654689433a8eee48d3587d276144dd2", + "bytes": 64072, + "eol": "LF", + "crlf": 0, + "lf": 1255, + "utf8_bom": false + }, + "normalized_diff_hunks": 11, + "text_change": true + }, + { + "path": "crates/engine/src/render_jobs.rs", + "before": { + "sha256": "5655d5f5ae2c80560f9e067ca24424c0561cc5969260ff0343660e4d198909aa", + "bytes": 42740, + "eol": "CRLF", + "crlf": 835, + "lf": 835, + "utf8_bom": false + }, + "candidate": { + "sha256": "4a2d5c1886ca029d383874f9aece71b866390fad2b6651193e218b2c302c5f48", + "bytes": 42310, + "eol": "LF", + "crlf": 0, + "lf": 856, + "utf8_bom": false + }, + "normalized_diff_hunks": 5, + "text_change": true + }, + { + "path": "crates/render/src/job/host.rs", + "before": { + "sha256": "577295a655ab5a8f6204da2b9d2a6a18d3d2bfeb877993a0dfffdc58462a2551", + "bytes": 115822, + "eol": "CRLF", + "crlf": 2406, + "lf": 2406, + "utf8_bom": false + }, + "candidate": { + "sha256": "1884acfd018cb38683bd6ec92b171eff5a1b39eb5fd7e79bec0e31a3e76aa879", + "bytes": 115999, + "eol": "LF", + "crlf": 0, + "lf": 2587, + "utf8_bom": false + }, + "normalized_diff_hunks": 31, + "text_change": true + }, + { + "path": "crates/render/src/job/image_tests.rs", + "before": { + "sha256": "4878271823870137cddb4f7f96c61b7e7e17bbfe46488858fcaedd9448c505dd", + "bytes": 19561, + "eol": "CRLF", + "crlf": 402, + "lf": 402, + "utf8_bom": false + }, + "candidate": { + "sha256": "98dfbb281a16aea600a6cff86652b3c92e566eb1188c2942a873df5742183368", + "bytes": 19074, + "eol": "LF", + "crlf": 0, + "lf": 390, + "utf8_bom": false + }, + "normalized_diff_hunks": 3, + "text_change": true + }, + { + "path": "crates/render/src/job/mod.rs", + "before": { + "sha256": "601391ecc07447e6c65cb3b790c7fe83b839374fa600fc7f79a2668cdf7b3eb0", + "bytes": 62159, + "eol": "LF", + "crlf": 0, + "lf": 1477, + "utf8_bom": false + }, + "candidate": { + "sha256": "10b26a76921445cce0029a19e2c9e591663dc5b8876c055b2f07618a4ddeab74", + "bytes": 62100, + "eol": "LF", + "crlf": 0, + "lf": 1474, + "utf8_bom": false + }, + "normalized_diff_hunks": 1, + "text_change": true + }, + { + "path": "crates/render/src/job/photographic.rs", + "before": { + "sha256": "74756050d449a3333130e54d54b72aed9de2d54ca535d5b50803c30a9ec35c4b", + "bytes": 28171, + "eol": "LF", + "crlf": 0, + "lf": 596, + "utf8_bom": false + }, + "candidate": { + "sha256": "03973c7f40398fcd32e24df61678570f827da9e41944817f72dd21ae38e56243", + "bytes": 28130, + "eol": "LF", + "crlf": 0, + "lf": 593, + "utf8_bom": false + }, + "normalized_diff_hunks": 3, + "text_change": true + }, + { + "path": "crates/render/src/raytrace/image_tests.rs", + "before": { + "sha256": "08bbf206da1436f39c225a14529135b47f7381fc3c278ed2c1dd9564c5c5747c", + "bytes": 114405, + "eol": "LF", + "crlf": 0, + "lf": 2414, + "utf8_bom": false + }, + "candidate": { + "sha256": "4a4f46bc26e560fe4087a4fbf4439ea768d05fec2a414af7ad371f5a6897f62d", + "bytes": 115864, + "eol": "LF", + "crlf": 0, + "lf": 2455, + "utf8_bom": false + }, + "normalized_diff_hunks": 10, + "text_change": true + }, + { + "path": "crates/render/src/raytrace/primary_aa_tests.rs", + "before": { + "sha256": "37ac1993d703bb524d038ec061d621fe0facb44dbdd6d11861d830ae6123d916", + "bytes": 89108, + "eol": "LF", + "crlf": 0, + "lf": 1762, + "utf8_bom": false + }, + "candidate": { + "sha256": "66f4d53f8f544c8eeaad8ef7879b50163bcf64528d9aafd20f2c248b1e758e50", + "bytes": 89705, + "eol": "LF", + "crlf": 0, + "lf": 1810, + "utf8_bom": false + }, + "normalized_diff_hunks": 5, + "text_change": true + }, + { + "path": "crates/render/src/studio.rs", + "before": { + "sha256": "cf06738ea3c14638eb43ce5c05516a6a95d69ac1658464932bd13e54fb4fedf5", + "bytes": 11331, + "eol": "CRLF", + "crlf": 218, + "lf": 218, + "utf8_bom": false + }, + "candidate": { + "sha256": "39eec7cc41207f966994b980a2cec11661a89f7e7a019608616f584261764d26", + "bytes": 11054, + "eol": "LF", + "crlf": 0, + "lf": 213, + "utf8_bom": false + }, + "normalized_diff_hunks": 4, + "text_change": true + }, + { + "path": "crates/ui-egui/src/render_workspace.rs", + "before": { + "sha256": "dd3dc088fdc1080a493eb52f87978fbe8bd36abdfe844f7bbf47b56a986aa7ed", + "bytes": 109538, + "eol": "CRLF", + "crlf": 2395, + "lf": 2395, + "utf8_bom": false + }, + "candidate": { + "sha256": "e202f6006332d21942e6bd01a4889601c77f2f1ab84039c0bc5aea2fd0cc18f0", + "bytes": 107739, + "eol": "LF", + "crlf": 0, + "lf": 2444, + "utf8_bom": false + }, + "normalized_diff_hunks": 10, + "text_change": true + }, + { + "path": "crates/ui-egui/src/render_workspace_materials.rs", + "before": { + "sha256": "e290b9e2404d68524a6a6cb4355b3f11f8bb989e370c869b2a262b1faafa8519", + "bytes": 49558, + "eol": "CRLF", + "crlf": 1045, + "lf": 1045, + "utf8_bom": false + }, + "candidate": { + "sha256": "5f9efcda8d42627eea7b05a8ccea2006a265492325824885442c76b6ec07e85a", + "bytes": 48776, + "eol": "LF", + "crlf": 0, + "lf": 1062, + "utf8_bom": false + }, + "normalized_diff_hunks": 4, + "text_change": true + }, + { + "path": "crates/ui-egui/src/render_workspace_tests.rs", + "before": { + "sha256": "edc06b2999b190b85495db5496d68801f77f370a7c8e2763c25d7610841a085b", + "bytes": 543384, + "eol": "LF", + "crlf": 0, + "lf": 9939, + "utf8_bom": false + }, + "candidate": { + "sha256": "5eeb9bb333cad6936dae8bade8c3be0eece2cea7f52d274c6bd59b28c42625d9", + "bytes": 545234, + "eol": "LF", + "crlf": 0, + "lf": 10030, + "utf8_bom": false + }, + "normalized_diff_hunks": 22, + "text_change": true + } + ], + "patch_policy": "LF-normalized text hunks; verify exact RAW before hashes, apply only textual/EOL reconstruction, restore declared endpoint EOL and verify exact RAW candidate SHA. No universal literal RAW replay claim. All endpoints were read from actual candidate/stage payloads, not reconstructed from hashes.", + "C15_outcome": "Formatter/check completed; later combined test build failed with four E0599 in new UI fixture setup. Zero tests executed;242 selected cases unrun. This formatting bridge transfers no PASS to C16." +} diff --git a/proposals/render/2026-10-30/c16-defaults-auto-result/candidate.patch b/proposals/render/2026-10-30/c16-defaults-auto-result/candidate.patch new file mode 100644 index 000000000..4ee11f9ef --- /dev/null +++ b/proposals/render/2026-10-30/c16-defaults-auto-result/candidate.patch @@ -0,0 +1,273 @@ +diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs +--- a/crates/ui-egui/src/prefs.rs ++++ b/crates/ui-egui/src/prefs.rs +@@ -940,6 +940,8 @@ + vertex_markers: bool = false => check("Vertex markers", "Show a small dot at every vertex wherever edges are drawn"); + /// Restore the previous platform-specific fixed Render preview geometry budget. + render_previous_geometry_budget: bool = false, PAGE_GRAPHICS => check_id("prefs.render_previous_geometry_budget"); ++ /// Open Result once after a successful GUI Start; false preserves the selected view. ++ render_open_result_on_start: bool = true, PAGE_GRAPHICS => check_id("prefs.render_open_result_on_start"); + /// How finely the viewport tessellates curved faces and edges: `coarse`, `normal`, `fine` or + /// `ultra` (#1287). Only the display plan the viewport draws; never the design or exports. + display_quality: String = "normal".into(), PAGE_GRAPHICS; +@@ -3331,6 +3333,24 @@ + + #[cfg(test)] + mod tests { ++ #[test] ++ fn render_open_result_on_start_defaults_persists_validates_and_resets() { ++ assert!(Prefs::default().render_open_result_on_start); ++ assert!(serde_json::from_value::(json!({})).unwrap().render_open_result_on_start); ++ let mut app = SolveApp::new(Default::default(), Default::default()); ++ let reply = super::set(&mut app, &json!({"render_open_result_on_start":false})).unwrap(); ++ assert_eq!(reply["render_open_result_on_start"], false); ++ for invalid in [json!("false"), json!(0), json!(null)] { ++ assert!(super::set(&mut app, &json!({"render_open_result_on_start":invalid})).is_err()); ++ assert!(!app.preferences.render_open_result_on_start); ++ } ++ let mut restored = SolveApp::new(Default::default(), Default::default()); ++ restored.load_prefs(&app.prefs()); ++ assert!(!restored.preferences.render_open_result_on_start); ++ super::defaults(&mut restored, super::PAGE_GRAPHICS); ++ assert!(restored.preferences.render_open_result_on_start); ++ } ++ + #[test] + fn trackpad_zoom_modifier_roundtrips_and_validates_control_values() { + assert_eq!(Prefs::default().trackpad_zoom_modifier, TrackpadZoomModifier::Off); +diff --git a/crates/ui-egui/src/prefs/graphics.rs b/crates/ui-egui/src/prefs/graphics.rs +--- a/crates/ui-egui/src/prefs/graphics.rs ++++ b/crates/ui-egui/src/prefs/graphics.rs +@@ -189,6 +189,7 @@ + #[cfg(target_os = "linux")] + ui_kit::settings_section(ui, "window_system", app.tr("ui.window_system"), |ui| window_system_row(app, ui)); + setting::render_previous_geometry_budget(app, ui).on_hover_text(app.tr("prefs.render_previous_geometry_budget_help")); ++ setting::render_open_result_on_start(app, ui).on_hover_text(app.tr("prefs.render_open_result_on_start_help")); + ui.horizontal(|ui| { + ui_kit::text(ui, app.tr_label("Renderer"), ui_kit::Text::Inline); + let renderer = match (&app.viewport.gpu, &app.help.gpu) { +diff --git a/crates/ui-egui/src/render_workspace_ribbon.rs b/crates/ui-egui/src/render_workspace_ribbon.rs +--- a/crates/ui-egui/src/render_workspace_ribbon.rs ++++ b/crates/ui-egui/src/render_workspace_ribbon.rs +@@ -150,6 +150,9 @@ + .map_err(|e| crate::i18n::format("render.error_job_identity", &[("error", &e.to_string())]))?; + app.render_workspace.view.job = Some(job); + app.render_workspace.view.job_shot = Some(app.render_workspace.view.name.clone()); ++ if app.preferences.render_open_result_on_start { ++ app.run("render.result.view", json!({"view":"image"}))?; ++ } + } + "render.result.copy" => { + let job = app.render_workspace.view.completed.ok_or_else(|| app.tr("render.ribbon_no_result").to_string())?; +diff --git a/crates/ui-egui/src/render_workspace_tests.rs b/crates/ui-egui/src/render_workspace_tests.rs +--- a/crates/ui-egui/src/render_workspace_tests.rs ++++ b/crates/ui-egui/src/render_workspace_tests.rs +@@ -9643,8 +9643,10 @@ + view.draft.width = width; + view.draft.height = height; + view.draft.background = background; +- view.draft.stage.clear(); +- view.draft.surfaces.clear(); ++ view.draft.stage = Default::default(); ++ view.draft.surfaces = Default::default(); ++ assert!(view.draft.stage.is_empty()); ++ assert!(view.draft.surfaces.is_empty()); + view.draft.exposure_ev = 0.0; + view.transparent = false; + view.raytrace = RaytraceOptions { +@@ -9855,8 +9857,10 @@ + view.draft.width = 1; + view.draft.height = 1; + view.draft.background = [255; 3]; +- view.draft.stage.clear(); +- view.draft.surfaces.clear(); ++ view.draft.stage = Default::default(); ++ view.draft.surfaces = Default::default(); ++ assert!(view.draft.stage.is_empty()); ++ assert!(view.draft.surfaces.is_empty()); + view.transparent = false; + view.draft.exposure_ev = 0.0; + view.raytrace.primary_samples = 1; +@@ -10026,5 +10030,140 @@ + assert_eq!(before, (h.app.session.revision, h.app.session.undo.len(), h.app.session.is_dirty())); + // Actual CPU capture/completion + nonblack optical smoke, not a full + // Fresnel/TIR oracle or a partial-optical-tree while-running receipt. ++ } ++} ++ ++ ++// These exercise GUI navigation against the real cooperative Raster host. ++// They do not qualify CPU raytracing, progressive cadence or GPU rendering. ++fn auto_result_raster_fixture() -> Harness { ++ let mut h = Harness::new(); ++ h.app.run("solid.box", json!({"length":3,"width":4,"height":5})).unwrap(); ++ enter(&mut h.app, true).unwrap(); ++ let host = solidcraft_engine::render::job::CpuHost::cooperative(); ++ h.app.session.set_render_job_host(Some(host.clone())).unwrap(); ++ h.app.render_workspace.image_host = Some(host); ++ h.app.render_workspace.view.method = ImageMethod::Raster; ++ h.app.render_workspace.view.draft.width = 13; ++ h.app.render_workspace.view.draft.height = 7; ++ h.app.run("render.result.view", json!({"view":"model"})).unwrap(); ++ h ++} ++ ++#[test] ++fn auto_result_success_opens_once_and_explicit_model_survives_real_completion() { ++ use solidcraft_engine::render::job::Phase; ++ let mut h = auto_result_raster_fixture(); ++ assert!(h.app.preferences.render_open_result_on_start); ++ assert!(!h.app.render_workspace.view.result); ++ let document = h.app.session.doc.clone(); ++ let undo = h.app.session.undo.len(); ++ let camera = h.app.cam; ++ ribbon::perform_job(&mut h.app, "render.start").unwrap(); ++ let job = h.app.render_workspace.view.job.unwrap(); ++ let handle = h.app.session.render_job_handle(job).unwrap(); ++ assert!(h.app.render_workspace.view.result); ++ assert_eq!(handle.status().unwrap().progress.phase, Phase::Queued); ++ assert!(handle.frame().unwrap().is_none()); ++ assert!(h.app.render_workspace.view.completed.is_none()); ++ assert!(ribbon::action_ready(&h.app, "render.export").is_err()); ++ let request = handle.status().unwrap().request; ++ assert_eq!((request.width, request.height, request.integrator), (13, 7, Integrator::Raster)); ++ cache_render_images(&mut h.app, &h.ctx); ++ assert!(h.app.render_workspace.view.result); ++ h.app.run("render.result.view", json!({"view":"model"})).unwrap(); ++ assert!(!h.app.render_workspace.view.result); ++ let host = h.app.session.render_job_host().unwrap().clone(); ++ for _ in 0..128 { ++ host.pump(16_384).unwrap(); ++ cache_render_images(&mut h.app, &h.ctx); ++ assert!(!h.app.render_workspace.view.result, "publication/repaint must respect an explicit Model selection"); ++ if handle.frame().unwrap().is_some() { ++ break; ++ } ++ } ++ let frame = handle.frame().unwrap().expect("bounded cooperative Raster work must complete"); ++ assert_eq!((frame.info.width, frame.info.height), (13, 7)); ++ assert_eq!(h.app.render_workspace.view.completed, Some(job)); ++ assert!(ribbon::action_ready(&h.app, "render.export").is_ok()); ++ for _ in 0..3 { ++ cache_render_images(&mut h.app, &h.ctx); ++ assert!(!h.app.render_workspace.view.result); ++ } ++ assert!(Arc::ptr_eq(&document, &h.app.session.doc)); ++ assert_eq!(h.app.session.undo.len(), undo); ++ assert_eq!(h.app.cam, camera); ++} ++ ++#[test] ++fn auto_result_disabled_keeps_both_selected_views_through_start_and_completion() { ++ for selected in [false, true] { ++ let mut h = auto_result_raster_fixture(); ++ crate::prefs::set(&mut h.app, &json!({"render_open_result_on_start":false})).unwrap(); ++ h.app.run("render.result.view", json!({"view":if selected {"image"} else {"model"}})).unwrap(); ++ ribbon::perform_job(&mut h.app, "render.start").unwrap(); ++ assert_eq!(h.app.render_workspace.view.result, selected); ++ let job = h.app.render_workspace.view.job.unwrap(); ++ let handle = h.app.session.render_job_handle(job).unwrap(); ++ assert!(handle.frame().unwrap().is_none()); ++ let host = h.app.session.render_job_host().unwrap().clone(); ++ for _ in 0..128 { ++ host.pump(16_384).unwrap(); ++ cache_render_images(&mut h.app, &h.ctx); ++ assert_eq!(h.app.render_workspace.view.result, selected); ++ if handle.frame().unwrap().is_some() { ++ break; ++ } ++ } ++ assert!(handle.frame().unwrap().is_some(), "bounded cooperative Raster work must complete"); ++ assert_eq!(h.app.render_workspace.view.completed, Some(job)); ++ cache_render_images(&mut h.app, &h.ctx); ++ assert_eq!(h.app.render_workspace.view.result, selected); ++ } ++} ++ ++#[test] ++fn auto_result_check_invalid_start_and_real_queue_full_preserve_selected_view() { ++ use solidcraft_engine::render::job::Phase; ++ for selected in [false, true] { ++ let mut h = auto_result_raster_fixture(); ++ assert!(h.app.preferences.render_open_result_on_start); ++ h.app.run("render.result.view", json!({"view":if selected {"image"} else {"model"}})).unwrap(); ++ let document = h.app.session.doc.clone(); ++ let undo = h.app.session.undo.len(); ++ ribbon::perform_job(&mut h.app, "render.preflight").unwrap(); ++ assert_eq!(h.app.render_workspace.view.result, selected); ++ assert!(h.app.render_workspace.view.job.is_none()); ++ h.app.render_workspace.view.draft.width = 0; ++ assert!(ribbon::perform_job(&mut h.app, "render.preflight").is_err()); ++ assert_eq!(h.app.render_workspace.view.result, selected); ++ assert!(ribbon::perform_job(&mut h.app, "render.start").is_err()); ++ assert_eq!(h.app.render_workspace.view.result, selected); ++ h.app.render_workspace.view.draft.width = 13; ++ let request = image_params(&h.app).unwrap(); ++ let mut jobs = Vec::new(); ++ // Queue two real jobs without registering a GUI job. ++ // No pump or worker thread runs between admission and the third Start. ++ for _ in 0..2 { ++ let reply = h.app.session.execute("render.start", &request).unwrap(); ++ let job = serde_json::from_value(reply["job"].clone()).unwrap(); ++ let handle = h.app.session.render_job_handle(job).unwrap(); ++ assert_eq!(handle.status().unwrap().progress.phase, Phase::Queued); ++ jobs.push(handle); ++ } ++ ribbon::action_ready(&h.app, "render.start").unwrap(); ++ let error = ribbon::perform_job(&mut h.app, "render.start").unwrap_err(); ++ assert!(error.contains("this document already has an active and pending render"), "expected real document QueueFull: {error}"); ++ assert_eq!(h.app.render_workspace.view.result, selected); ++ assert!(h.app.render_workspace.view.job.is_none()); ++ assert!(h.app.render_workspace.view.completed.is_none()); ++ cache_render_images(&mut h.app, &h.ctx); ++ assert_eq!(h.app.render_workspace.view.result, selected); ++ for handle in jobs { ++ assert_eq!(handle.status().unwrap().progress.phase, Phase::Queued); ++ assert!(handle.frame().unwrap().is_none()); ++ } ++ assert!(Arc::ptr_eq(&document, &h.app.session.doc)); ++ assert_eq!(h.app.session.undo.len(), undo); + } + } +diff --git a/assets/locales/pending/render-result-on-start.json b/assets/locales/pending/render-result-on-start.json +--- /dev/null ++++ b/assets/locales/pending/render-result-on-start.json +@@ -1,0 +1,38 @@ ++{ ++ "ar": { ++ "prefs.render_open_result_on_start": "فتح النتيجة عند بدء التصيير", ++ "prefs.render_open_result_on_start_help": "افتح النتيجة مرة واحدة بعد بدء التصيير بنجاح. عطّل هذا الخيار للاحتفاظ بالعرض المحدد. يمكنك العودة إلى النموذج أثناء التصيير." ++ }, ++ "de": { ++ "prefs.render_open_result_on_start": "Ergebnis beim Renderstart öffnen", ++ "prefs.render_open_result_on_start_help": "Nach erfolgreichem Renderstart einmal das Ergebnis öffnen. Deaktivieren, um die gewählte Ansicht beizubehalten. Während des Renderns können Sie zum Modell zurückkehren." ++ }, ++ "en": { ++ "prefs.render_open_result_on_start": "Open Result when rendering starts", ++ "prefs.render_open_result_on_start_help": "After starting a render successfully, open Result once. Turn off to keep your selected view. You can return to Model while rendering." ++ }, ++ "es": { ++ "prefs.render_open_result_on_start": "Abrir Resultado al iniciar el renderizado", ++ "prefs.render_open_result_on_start_help": "Abre Resultado una vez tras iniciar correctamente el renderizado. Desactiva esta opción para conservar la vista seleccionada. Puedes volver a Modelo durante el renderizado." ++ }, ++ "he": { ++ "prefs.render_open_result_on_start": "פתיחת התוצאה עם תחילת הרינדור", ++ "prefs.render_open_result_on_start_help": "פתיחת התוצאה פעם אחת לאחר התחלת רינדור בהצלחה. יש לבטל אפשרות זו כדי לשמור על התצוגה שנבחרה. אפשר לחזור למודל בזמן הרינדור." ++ }, ++ "ja": { ++ "prefs.render_open_result_on_start": "レンダリング開始時に結果を開く", ++ "prefs.render_open_result_on_start_help": "レンダリングの開始に成功したら、結果を一度だけ開きます。無効にすると、選択中の表示を維持します。レンダリング中でもモデルに戻れます。" ++ }, ++ "ko": { ++ "prefs.render_open_result_on_start": "렌더링 시작 시 결과 열기", ++ "prefs.render_open_result_on_start_help": "렌더링이 성공적으로 시작되면 결과를 한 번 엽니다. 끄면 선택한 보기가 유지됩니다. 렌더링 중에도 모델로 돌아갈 수 있습니다." ++ }, ++ "vi": { ++ "prefs.render_open_result_on_start": "Mở Kết quả khi bắt đầu kết xuất", ++ "prefs.render_open_result_on_start_help": "Mở Kết quả một lần sau khi bắt đầu kết xuất thành công. Tắt để giữ chế độ xem đã chọn. Bạn có thể quay lại Mô hình trong khi kết xuất." ++ }, ++ "zh": { ++ "prefs.render_open_result_on_start": "开始渲染时打开结果", ++ "prefs.render_open_result_on_start_help": "成功开始渲染后打开结果一次。关闭此选项可保留当前选中的视图。渲染期间也可以返回模型视图。" ++ } ++} diff --git a/proposals/render/2026-10-30/c16-defaults-auto-result/manifest.json b/proposals/render/2026-10-30/c16-defaults-auto-result/manifest.json new file mode 100644 index 000000000..6e419b4d5 --- /dev/null +++ b/proposals/render/2026-10-30/c16-defaults-auto-result/manifest.json @@ -0,0 +1,46 @@ +{ + "schema": 1, + "status": "SOURCE_CHECKPOINT_ADOPTED_REVIEWED_NOT_RUNTIME_QUALIFIED", + "source_paths": 5, + "production_draft": 8938, + "production_head": "a077906234972dbbf11e80c54893f85ece97c8b7", + "authorship": "Worker #1, SolidCraft Render team under0xlillith; independent Designer source review and Engineer exact-source adoption retained.", + "original_source_manifest_sha256": "299b24a28d47411eb53ca322c5b1b01d74e0ac7ef690e9056927f06c12092727", + "original_private_binding_sha256": "1cef2da8c20c602e9e91c9b79105376881916594aac99d6e31a24b2e58e051d1", + "original_RAW_endpoint_manifest_sha256": "cfab0c69aef0731b1c4da4d39c5d967d7e8baea6a5f17052160baec5882d849c", + "independent_source_review_sha256": "60695ce7719bd6c8d83d732fd934c2169caf994f46b3fca9de2a37ecf61b0d5e", + "adopted_source_manifest_sha256": "7a30db715b0f342b37e4f5c53f7297cef1d56e22cf65a55278d6e14fd46cc852", + "source_members_checked_at_adoption": 3572, + "source_patch": { + "path": "candidate.patch", + "bytes": 15592, + "sha256": "254b8e72b7b4ff1f12b866501e10fa37274c8614fbb49e38ecbec2172884b201" + }, + "sanitized_bindings": { + "path": "bindings.json", + "sha256": "9f024a40545b2f0c7ff5cc002523ffa2386d1ca48d7cdd993c5b02c498304c67" + }, + "C15_format_bridge_manifest": { + "path": "c15-postformat-manifest.json", + "sha256": "e0a5bc8634e9f3e42d7f911b8ce740a5e4251563ab1a3ad27e7ed0361667e68f" + }, + "test_declarations": { + "new": 4, + "UI": 255, + "preferences": 117 + }, + "Changes a default": "yes - successful GUI Start opens Result once, old behaviour kept behind preference render_open_result_on_start=false", + "C15_historical": { + "compiler_errors": "four E0599 in two new UI fixture setups", + "test_bodies_executed": 0, + "selected_cases_unrun": 242, + "PASS_transferred_to_C16": false + }, + "new_source_execution_qualification": false, + "limits": [ + "Static/endpoint/source review is not Rust compilation, test execution, native layout/UX or image-quality acceptance.", + "Cooperative Raster cases test GUI navigation policy; they do not qualify CPU final streaming or physical GPU rendering.", + "Current protected feedback, glass/certified transport, finishing/export and cross-backend parity limitations remain.", + "Additional strict TIR acceptance and the actual Raster directional consumer are not enabled by these five files." + ] +}