From 4334dd739422b858a5ef78faa8b92cb0fe1578a9 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 16 Sep 2026 15:55:23 +0200 Subject: [PATCH] Compare lens sets by effective weight in the no-op check (L1 c2.s2.f1) `SetLensWeights` refused an identical set by comparing raw maps, but a lens a map does not name weighs zero. `{charter:3}` to `{patina:0, charter:3}` therefore committed, and changing back committed again, though both sets draw identically. Equality is now `LensWeights::weighs_the_same_as`, owned in `lens.rs`: every stock lens's effective weight is equal. The reducer's arm calls it; the stored spelling is whatever the last committed set said. Test, through the public mailbox in both directions: `a_lens_set_spelled_with_or_without_its_zero_weights_commits_nothing`. A sparse world set refuses a one-zero padded twin and an all-eight padded twin; a padded world set refuses two sparse twins; each refusal is `NoCanonicalChange` with revision, digests, operator log and stored spelling unchanged; real changes commit. Builds. Co-Authored-By: Claude Opus 5 --- crates/ghostlight/src/lens.rs | 10 +++ crates/ghostlight/src/lib.rs | 10 +-- crates/ghostlight/tests/external_admission.rs | 82 +++++++++++++++++++ 3 files changed, 97 insertions(+), 5 deletions(-) diff --git a/crates/ghostlight/src/lens.rs b/crates/ghostlight/src/lens.rs index ae2ae48..abe63b0 100644 --- a/crates/ghostlight/src/lens.rs +++ b/crates/ghostlight/src/lens.rs @@ -163,6 +163,16 @@ impl LensWeights { pub(crate) fn draws(&self) -> bool { self.0.values().any(|weight| *weight > 0) } + + /// Every stock lens weighs the same in both sets. A lens a map does not + /// name weighs zero, so `{charter: 3}` and `{patina: 0, charter: 3}` are + /// one set spelled two ways: they draw identically and neither replaces + /// the other. + pub(crate) fn weighs_the_same_as(&self, other: &LensWeights) -> bool { + Lens::ALL + .into_iter() + .all(|lens| self.get(lens) == other.get(lens)) + } } /// The draw's whole input: the world and the session's fixed identity. The diff --git a/crates/ghostlight/src/lib.rs b/crates/ghostlight/src/lib.rs index 98f458d..3c22493 100644 --- a/crates/ghostlight/src/lib.rs +++ b/crates/ghostlight/src/lib.rs @@ -680,10 +680,10 @@ pub enum CommandBody { }, /// Replaces the world's whole lens weight set. Owner only, in any phase, /// under genesis admission: a set that never draws is refused, and a zero - /// weight is admitted and never draws. A set equal to the current one - /// changes nothing canonical and is refused with `NoCanonicalChange` - /// after admission, so nothing commits. A session that already drew - /// keeps its recorded lens. + /// weight is admitted and never draws. A set that weighs every lens as + /// the current one does, however its map is spelled, changes nothing + /// canonical and is refused with `NoCanonicalChange` after admission, so + /// nothing commits. A session that already drew keeps its recorded lens. SetLensWeights { weights: LensWeights, }, @@ -1686,7 +1686,7 @@ fn reduce(state: &WorldState, command: &CommandEnvelope) -> Result