git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commit4d6eb5c02bd623a7fce584046533cbcd948d4a63
parent5ce83a50af
authorLucas Galante <lsgalante12@gmail.com>
date2026-09-28 22:40
fix: the frost test pins its radius, and its neighbour restores the globals it reloads

frost_from_style_and_flag failed one run in eight: it pinned compression
and refraction on its thread but read the frost radius off the process-
wide global, which the_frost_block_is_the_only_spelling_of_the_default_
recipe had reloaded to 3.0 — and an absent frost knob keeps its last
value by design, so that test's closing empty reload put nothing back.
The frost test now pins all three knobs, and the neighbour reloads the
defaults before its empty reload and asserts the globals are back.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

 CLAUDE.md             | 16 ++++++++++++++++
 src/scene/material.rs | 19 +++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/CLAUDE.md b/CLAUDE.md
index 729e080..e8c0767 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -925,3 +925,19 @@ snap-instead-of-ease path forces it for its thread; nothing sets
 This pins only cce-ui's own suite: a dependent's test binary links cce-ui
 without `cfg(test)`, so a dependent test that eases still follows the
 machine — none does today.
+
+### A colour test that reloads a knob puts it back
+
+`color::style_write` (every `set_*`) is a per-thread overlay under
+`cfg(test)`, but `reload_colors` writes the process-wide globals — and an
+absent frost knob KEEPS its last value by design, so `reload_colors("")`
+resets the named materials and bindings (replaced wholesale) and nothing
+else. A test that reloads `frost radius=3.0` and closes with the empty
+reload leaves radius 3 behind for every test after it; that is what had
+`frost_from_style_and_flag` fail one run in eight (2026-09-28, the radius
+read 3.0 for the default whenever its neighbour ran first). Two rules: a
+test that ASSERTS a knob pins it on its own thread through the setter, the
+radius included, not just the ones it is about; and a test that RELOADS a
+knob reloads its default back before the empty reload, and asserts the
+globals are back. `test_color_state_lock` orders the reloaders against
+each other; it cannot undo what one of them left behind.
diff --git a/src/scene/material.rs b/src/scene/material.rs
index f71ee70..9398af9 100644
--- a/src/scene/material.rs
+++ b/src/scene/material.rs
@@ -545,11 +545,19 @@ mod tests {
 
     /// The frost recipe reads the two plate-rung keys and carries the default
     /// kernel; the flag form is today's `blur: bool`.
+    ///
+    /// All THREE knobs are pinned on this thread, the radius included: the
+    /// setters write a per-thread overlay, but a `reload_colors` writes the
+    /// process-wide globals, and an absent frost knob keeps its last value
+    /// by design — so a neighbour's reload of `frost radius=3.0` outlived
+    /// its closing empty reload, and this test read 3.0 for the default
+    /// whenever that neighbour ran first (one run in eight, 2026-09-28).
     #[test]
     fn frost_from_style_and_flag() {
         let _lock = crate::color::test_color_state_lock();
         crate::color::set_plate_backdrop_compression(0.6);
         crate::color::set_plate_refraction(0.3);
+        crate::color::set_plate_frost_radius(Frost::DEFAULT_RADIUS);
         assert_eq!(Frost::from_style(), frosted());
         assert_eq!(Frost::from_flag(false), Frost::Unfrosted);
         assert!(Frost::from_flag(true).is_frosted());
@@ -726,7 +734,18 @@ mod tests {
         assert_eq!(load("blur (bool)true\n radius (f64)2.0"), (false, frosted(0.4, 0.1, 3.0)), "the retired spelling frosts nothing and moves nothing");
         assert_eq!(retired("blur (bool)true\n radius (f64)2.0"), vec!["style.surface.plate.blur", "style.surface.plate.radius"]);
         assert_eq!(load("blur (bool)false\n frost compression=(f64)0.7"), (true, frosted(0.7, 0.1, 3.0)), "the block is read, the retired key is not");
+        // Leave the globals as they were found. A reload writes them for
+        // the whole process, and an unset knob KEEPS its value (asserted
+        // above), so the empty reload alone left radius 3 / compression 0.7
+        // / refraction 0.1 behind for every test after this one.
+        crate::color::reload_colors(&doc(&format!(
+            "frost radius=(f64){} compression=(f64)0.0 refraction=(f64)0.0",
+            Frost::DEFAULT_RADIUS
+        )));
+        crate::color::reload_colors(&doc("frost (bool)false"));
         crate::color::reload_colors("");
+        assert_eq!(Frost::from_style(), frosted(0.0, 0.0, Frost::DEFAULT_RADIUS), "the globals are back at their defaults");
+        assert!(!crate::color::plate_blur());
     }
 
     /// `style.surface.plate.pane.color` is the pane tint WHOLE — its alpha is