From d1665f649943b6dce82bf7e85df1d183bb96f747 Mon Sep 17 00:00:00 2001 From: "Claude (adr009-zset)" Date: Sat, 10 Oct 2026 00:04:24 -0700 Subject: [PATCH] docs(zset): drop the withdrawn premise from the overflow paragraph (improvise-tk51) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze --- context/code/zset.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/context/code/zset.md b/context/code/zset.md index 46461e07..b3b551da 100644 --- a/context/code/zset.md +++ b/context/code/zset.md @@ -59,9 +59,8 @@ These are the readings this step takes. is required only where a result copies keys (`filter`, `distinct`, `scale`, the borrowed operators); `map` and the by-value operators need only `Ord`. 5. **Overflow.** Neither clause 1 nor clause 8 states a policy for weights (clause 8 is about - `f64` sums). A weight that wraps would turn a retraction into an insertion with nothing - to show it, which is the failure the ADR's exactness argument is against. So every weight - operation uses `checked_*` and **panics** with `zset: weight overflow in `, in debug + `f64` drift, which wrapping integers do not have). The crate currently uses `checked_*` + on every weight operation, for the reason given below, and **panics** with `zset: weight overflow in `, in debug and in release (`checked_*` does not depend on `overflow-checks`). The operations are `add` (including `insert`, `Extend`, `FromIterator`), `sub`, `neg` (so `i64::MIN` panics when it has to be negated) and `scale`. Scaling by zero cannot overflow and returns the @@ -79,7 +78,8 @@ These are the readings this step takes. under wrapping. (An earlier version of this paragraph said otherwise; that was wrong.) What wrapping breaks is the intermediate reads. `MAX + 1` stores `i64::MIN`, so `distinct` drops a key whose true weight is positive and `weight()` has the wrong sign. A true weight - of 2^64 stores as 0, so the key vanishes and `is_zero`, `len` and `==` report a set that + of 2^64 stores as 0 (by the add path; a `scale` product of 2^64 would store a zero too, which + breaks canonical form), so the key vanishes and `is_zero`, `len` and `==` report a set that does not exist. Those are wrong answers returned silently, which is why the crate panics instead. A wider weight (`i128`) moves the boundary and does not remove it. The ADR's "abelian group" wording needs amending whichever policy is chosen: checked-and-panic gives