git.lucas.co / cce-designer
graphic design tool
git clone https://git.lucas.co/cce-designer.git

commit6477d79933ce4e1993cf9b3cbf16b66e6c8acfcb
parenta7bb7607a6
authorLucas Galante <[email protected]>
date2026-09-23 12:14
fix: the grid tests run on a lattice of their own, not the machine's

`configured_grid_geometry` read `style.surface.graph.spacing_x` and friends
straight out of `~/.config/cce/config.kdl`. The grid tests press at pixel
coordinates derived from `cell_center` and assert which node the press landed
on, so the pitch installed on the machine decided whether they passed.

`dragging_a_selected_node_carries_the_selection` genuinely failed at cce-ui's
own defaults: 187.5 x 112.5 puts its row 11 at 1237 px in a 900 px test
window, so the press misses the node and the drag never arms. It had been
passing only because the author's config.kdl set 140 x 70. A fresh clone, a
second machine or CI would all have failed it, and the failure would have read
as a broken drag rather than a borrowed lattice.

Under `cfg(test)` the four values are fixed at those 140 / 70 / 80 / 40 — the
lattice the tests were written against, so pinning them changes no test's
meaning. Deliberately not cce-ui's defaults: matching those would mean
rewriting the cell arithmetic of a subtle drag test to fit a coarser grid,
which is a real change to what it checks, for the sake of a number that is
arbitrary either way. What matters is that the number is the suite's own.

`graph_grid_snap` is left alone — it is read inside cce-ui's Graph widget
rather than through this crate, so there is nothing here to intercept, and it
is off both by cce-ui default and in practice.

`the_suite_runs_on_a_lattice_of_its_own` asserts the constants back, which is
what fails if the pin is ever unwired to the config again, and checks the live
`State` alongside them so the pin has to reach the app and not just the
helper. Verified by running the suite under an empty `$XDG_CONFIG_HOME`, under
one setting 999 x 777 with 500 x 400 nodes, and under the real config: 305
passing, identically, all three.

Co-Authored-By: Claude Opus 5 <[email protected]>

 CLAUDE.md   | 33 ++++++++++++++++++++++++++++++---
 src/app.rs  | 29 +++++++++++++++++++++++++++++
 src/main.rs | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 92 insertions(+), 3 deletions(-)

diff --git a/CLAUDE.md b/CLAUDE.md
index ab15400..b4a2589 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -334,9 +334,36 @@ thing under test), runs the plate toggle, and asserts both that a settings
 file was actually written — or the check is vacuous — and that the real one
 did not move.
 
-What tests still READ is the real `~/.config/cce/config.kdl`, for grid pitch
-and the rest of the toolkit config. That is untouched and deliberate: it is
-read-only, and the suite's expectations are already calibrated against it.
+**The suite's LATTICE is pinned for the same reason**, one layer up:
+`configured_grid_geometry` read `style.surface.graph.spacing_x` and friends
+straight out of `~/.config/cce/config.kdl`, and the grid tests press at pixel
+coordinates derived from `cell_center` and assert which node the press landed
+on — so the pitch on the machine decided whether they passed.
+`dragging_a_selected_node_carries_the_selection` really did fail at cce-ui's
+own defaults (187.5 x 112.5 puts its row 11 at 1237 px in a 900 px test
+window, so the press misses the node and the drag never arms); it passed only
+because the author's config.kdl set 140 x 70. A fresh clone, a second machine
+or CI would all have failed it, reading as a broken drag rather than a
+borrowed lattice.
+
+Under `cfg(test)` the four values are fixed at those 140 / 70 / 80 / 40 — the
+lattice the grid tests were written against, so pinning them changed no test's
+meaning. Deliberately NOT cce-ui's defaults: matching those would mean
+rewriting the cell arithmetic of a subtle drag test to fit a coarser grid,
+a real change to what it checks for the sake of a number that is arbitrary
+either way. What matters is that the number is the suite's own.
+`the_suite_runs_on_a_lattice_of_its_own` asserts the constants back — not a
+tautology but the thing that fails if the pin is ever unwired to the config
+again — and checks the live `State` alongside them, so the pin has to reach
+the app and not just the helper. Verified by running the suite under an EMPTY
+`$XDG_CONFIG_HOME`, under one setting 999 x 777 with 500 x 400 nodes, and
+under the real config: 305 passing, identically, all three.
+
+`graph_grid_snap` is not pinned — it is read inside cce-ui's Graph widget
+rather than through this crate, so there is nothing here to intercept; it is
+off both by cce-ui default and in practice. Config the suite still reads is
+cosmetic in the same way (colors, fonts, plate radii), and no test asserts on
+it; the empty-`$XDG_CONFIG_HOME` run is how to check that claim again.
 
 ### Conditional parameter rows
 
diff --git a/src/app.rs b/src/app.rs
index 2747300..484f448 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -999,6 +999,7 @@ pub struct GridGeometry {
     pub node_h: f32,
 }
 
+#[cfg(not(test))]
 pub fn configured_grid_geometry() -> GridGeometry {
     GridGeometry {
         pitch_x: cce_ui::layout::graph_spacing_x(),
@@ -1008,6 +1009,34 @@ pub fn configured_grid_geometry() -> GridGeometry {
     }
 }
 
+/// The lattice the SUITE runs on, fixed rather than read from
+/// `~/.config/cce/config.kdl`.
+///
+/// The grid tests press at pixel coordinates derived from `cell_center` and
+/// assert which node the press landed on, so the pitch decides whether they
+/// pass — and it was coming from whichever config.kdl happened to be on the
+/// machine. `dragging_a_selected_node_carries_the_selection` is the one that
+/// showed it: at cce-ui's own defaults (187.5 x 112.5) its row 11 lands at
+/// 1237 px in a 900 px test window, so the press misses the node and the
+/// drag never arms. It passed only because the author's config set 140 x 70.
+/// A fresh clone, a second machine or CI would all have failed it, and the
+/// failure would have read as a broken drag rather than a borrowed lattice.
+///
+/// These ARE those numbers — the lattice the grid tests were written against,
+/// kept so that pinning them changes no test's meaning. They are deliberately
+/// not cce-ui's defaults: matching those would mean rewriting the cell
+/// arithmetic of a subtle drag test to fit a coarser grid, which is a real
+/// change to what it checks, made for the sake of a number that is arbitrary
+/// either way. What matters is that the number is the suite's own.
+///
+/// `graph_grid_snap` is NOT pinned here: it is read inside cce-ui's Graph
+/// widget rather than through this crate, so there is nothing to intercept —
+/// it is off both by cce-ui default and in practice.
+#[cfg(test)]
+pub fn configured_grid_geometry() -> GridGeometry {
+    GridGeometry { pitch_x: 140.0, pitch_y: 70.0, node_w: 80.0, node_h: 40.0 }
+}
+
 /// Zoom limits on the pitch — the old 30..500 x 15..250 limits on the node
 /// body, expressed on the pitch that body used to be a share of.
 pub const MIN_PITCH_X: f32 = 37.5;
diff --git a/src/main.rs b/src/main.rs
index 4aad3ac..28298b7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -5140,6 +5140,39 @@ mod tests {
         );
     }
 
+    /// The suite runs on a lattice of its own, not the machine's.
+    ///
+    /// `configured_grid_geometry` read `style.surface.graph.spacing_x` and
+    /// friends straight out of `~/.config/cce/config.kdl`, so the grid tests
+    /// — which press at pixel coordinates from `cell_center` and assert which
+    /// node was hit — passed or failed by whoever's config was installed.
+    /// `dragging_a_selected_node_carries_the_selection` genuinely failed at
+    /// cce-ui's own defaults: its row 11 lands at 1237 px in a 900 px test
+    /// window, so the press misses and the drag never arms. It had been
+    /// passing on the author's 140 x 70.
+    ///
+    /// Asserting the constants back is the point rather than a tautology: it
+    /// is what fails if the pin is ever unwired back to the config, and the
+    /// live `State` is checked alongside them so the pin has to reach the app
+    /// and not just the helper.
+    #[test]
+    fn the_suite_runs_on_a_lattice_of_its_own() {
+        let g = crate::app::configured_grid_geometry();
+        assert_eq!(
+            (g.pitch_x, g.pitch_y, g.node_w, g.node_h),
+            (140.0, 70.0, 80.0, 40.0),
+            "the suite's lattice moved — if this came from config.kdl, the grid \
+             tests now depend on the machine running them"
+        );
+
+        let state = State::new(false);
+        assert_eq!(
+            (state.grid_pitch_x, state.grid_pitch_y, state.node_w, state.node_h),
+            (140.0, 70.0, 80.0, 40.0),
+            "State::new did not start on the pinned lattice"
+        );
+    }
+
     /// The network plate is optional, and the option is reachable three ways
     /// that cannot disagree: the View settings node's toggle, the network
     /// pane's View menu, and the command palette.