Skip to content

Commit 80b80e0

Browse files
committed
probe: wrong unit, an unsupported bound, and a checked ternlog claim
Three coderabbit findings on 5385ebf. Two are errors the PREVIOUS correction introduced, which is the third generation of one defect class in this PR and the thing worth recording. 1. The unit was OBSERVATIONS, not widths. The sweep visits 2 bases x 7 k = 14 distinct widths and repeats them 7 times, so the counter tops out at 98 samples of 14 widths. "7 of 98 widths" invents 84 widths that do not exist. The measured numbers are unchanged; what was wrong is what they counted. 2. "the gap is a LOWER BOUND on any true difference" is withdrawn. Truncation compresses the observed gap toward zero — but only from whichever side the truly cheaper arm sits on, and which arm that is is exactly what this sample cannot say. A bound needs the sign first. Replaced with: selection-biased, direction and magnitude unresolved. That is strictly more honest and costs nothing, because the decision never rested on the size of D - F, only on the absence of support for the expensive option. 3. Asked for a rustdoc example on `probe_fixed4_ternlog`. Declined as asked, and done better: this file is in `examples/`, where rustdoc never runs, so a ``` block would be an untested assertion dressed as a verified one — the exact thing this PR spent its time removing. `main` now asserts the semantics instead, so the claim is checked on every run. That assertion earned its place immediately: it rejected the expected value I had written from doing the arithmetic in my head. I had 0xF0F0 & 0x0F0F as 0x0F00 when the nibbles do not overlap at all, so it is 0x0000, and majority is 0x00FF rather than 0x0FFF. A truth table transcribed one bit off would still emit plausible `vpternlogq` and survive a read of the assembly — and so would a doc example nobody executes. Blackboard (17) corrects (16) on both counts and tabulates all five instances of the class, with the mechanical sweep that finds them faster than review does: for every printed line, name the accumulator behind it, its UNIT and its SCOPE, then check the words against all three. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DCfrD5y19cvFc4AoyydXYv
1 parent 5385ebf commit 80b80e0

3 files changed

Lines changed: 113 additions & 7 deletions

File tree

.claude/blackboard.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,68 @@
1+
## 2026-09-16 (17) — ⊘ CORRECTS (16) twice: the unit was OBSERVATIONS not widths, and "lower bound" was one claim too many
2+
3+
Both caught by coderabbit on the same PR (#315), both are errors (16) introduced
4+
while correcting (15), and both are the SAME defect class (15) and (16) already
5+
name — a label or a claim outrunning what the measurement supports. Third
6+
generation of one mistake in one session, which is the finding worth keeping.
7+
8+
### 1. "7 of 98 widths" — wrong unit, overstated the design 7×
9+
10+
The sweep visits `2 bases × 7 k = 14` **distinct widths** and repeats them
11+
`REPEATS = 7` times, so the counter tops out at **98 OBSERVATIONS of 14
12+
widths**. (16) reported "7 of 98 widths", which invents 84 widths that do not
13+
exist. Corrected in both the probe's labels and here:
14+
15+
```
16+
median ABSOLUTE tail cost, 7 qualified observations of 14 widths (ns):
17+
P 16.82 D 5.24 S 6.28 F 5.33
18+
observations where all four tails were measurable: 7 of 98
19+
(14 distinct widths × 7 passes)
20+
```
21+
22+
The measured numbers are unchanged; what was wrong is what they were counting.
23+
24+
### 2. "the gap is a LOWER BOUND" — not established, withdrawn
25+
26+
(16) said the censored D−F gap is "a **lower bound** on any true difference".
27+
That is one claim too many. Truncation does compress the gap toward zero — but
28+
only toward zero **from whichever side the truly cheaper arm sits on**, and
29+
which arm that is is precisely what this sample cannot say. A bound needs the
30+
sign first. So the honest statement, now in both places:
31+
32+
> **selection-biased; direction and magnitude unresolved.**
33+
34+
Note this is STRICTLY more honest than the claim it replaces, and it weakens
35+
nothing that mattered: the decision never rested on the size of D−F, only on
36+
the absence of support for the expensive option.
37+
38+
### Why this keeps happening, stated so the next session can shortcut it
39+
40+
Five instances, one class, three of them introduced *by the fix for the
41+
previous one*:
42+
43+
| # | the claim | what the code/design actually had |
44+
|---|---|---|
45+
| 1 | D/P ratio read as a tail result | arms with different bodies; `tail == 0` rows moved |
46+
| 2 | "widths where D beats S: N of 14" | a count thresholded by a floor that is itself a draw |
47+
| 3 | "pooled over all 7 passes" | the last pass alone |
48+
| 4 | "D removes 121.3% of the padded cost" | a fraction inflated by a negative numerator |
49+
| 5 | "7 of 98 **widths**" / "a **lower bound**" | 98 observations of 14 widths / no established sign |
50+
51+
**The generalizable rule: correcting one statistic does not audit the ones
52+
beside it, and the correction itself is a new claim needing the same check.**
53+
The cheap sweep is mechanical — for every printed line, name the accumulator
54+
behind it, its UNIT, and its SCOPE, then read whether the words match all
55+
three. That sweep found instance 5's siblings in one pass (all thirteen
56+
accumulators pool; none is cleared) where four rounds of review had found them
57+
one at a time.
58+
59+
Corollary for a verdict rather than a label: state only what the sample can
60+
support. "No measured support for the expensive option" survives every one of
61+
the five corrections above. "The cheap option is equal", "the gap is a lower
62+
bound", and every ratio drawn from a near-zero denominator did not.
63+
64+
---
65+
166
## 2026-09-16 (16) — ⊘ CORRECTS (15): its headline numbers came from a BUGGY binary, and the D-vs-F ordering is NOT established
267

368
Same PR (#315), same day, four codex findings later. Entry (15) stands on its

examples/mask_algebra_tail_probe.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,12 @@ mod imp {
418418
// so on some runs NOTHING qualifies and the only honest output is to
419419
// say the question was not answered.
420420
let mut qualified = 0usize;
421-
// Absolute tail cost in ns on the qualified widths, per arm. Ratios and
421+
// Absolute tail cost in ns on the qualified OBSERVATIONS, per arm.
422+
// "Observation", not "width": the sweep visits 2 bases x 7 k = 14
423+
// distinct widths and repeats them REPEATS times, so the counter tops
424+
// out at 98 samples of 14 widths. Calling 98 a width count overstates
425+
// the design by 7x (coderabbit, #315) — the same wrong-unit defect as
426+
// the pooled-vs-per-pass labels, one field over. Ratios and
422427
// shares can blow up when a denominator or numerator approaches zero;
423428
// a nanosecond cannot. These four numbers are the least-processed form
424429
// of the result and are what the verdict should be sanity-checked
@@ -580,7 +585,7 @@ mod imp {
580585
}
581586
};
582587
println!(
583-
"\nmedian ABSOLUTE tail cost on the {qualified} qualified widths (ns):\n\
588+
"\nmedian ABSOLUTE tail cost, {qualified} qualified observations of 14 widths (ns):\n\
584589
\x20 P {:.2} D {:.2} S {:.2} F {:.2}",
585590
median(&mut p_ns.clone()),
586591
median(&mut d_ns.clone()),
@@ -601,10 +606,19 @@ mod imp {
601606
// conditioning, it applies it to both arms.
602607
//
603608
// The filter stays because unfiltered is worse — negative tails gave
604-
// "D removes 121.3% of the padded cost" — but this is a CENSORED
605-
// sample and the D-F gap it yields is a lower bound on any true
606-
// difference. Resolving it properly needs precision, not filtering:
607-
// more iterations, a quiet machine, or modelling the censored points.
609+
// "D removes 121.3% of the padded cost" — but this is a CENSORED sample:
610+
// SELECTION-BIASED, with the direction and magnitude of the bias
611+
// UNRESOLVED.
612+
//
613+
// ⊘ An earlier version of this note called the observed D-F gap a
614+
// "lower bound on any true difference". That is one claim too many
615+
// (coderabbit, #315). Truncation does compress the gap toward zero —
616+
// but only toward zero FROM WHICHEVER SIDE the truly cheaper arm sits
617+
// on, and which arm that is is precisely what this sample cannot say.
618+
// Asserting a bound requires knowing the sign first, so neither the
619+
// sign nor the magnitude of the true difference is recoverable here.
620+
// Resolving it needs precision, not filtering: more iterations, a
621+
// quiet machine, or modelling the censored points.
608622
println!("\npooled over all {REPEATS} passes -- S {} D {} F {}", pc(s_all), pc(d_all), pc(f_all));
609623
println!("\nShare of the padded tail's cost removed, differenced per pass.");
610624
println!("Percentage-point gaps, pooled, with the per-pass spread beside them:");
@@ -632,7 +646,8 @@ mod imp {
632646
// adjudicate the finer D-vs-F question, and saying so is the result.
633647
let resolvable = qualified * 4 >= rows && ds_med.is_finite() && df_med.is_finite();
634648
println!(
635-
"widths where all four tails were measurable: {qualified} of {rows} ({}resolvable)",
649+
"observations where all four tails were measurable: {qualified} of {rows} \
650+
(14 distinct widths x {REPEATS} passes) ({}resolvable)",
636651
if resolvable { "" } else { "NOT " }
637652
);
638653
if !resolvable {

examples/narrow_bitop_codegen_probe.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,21 @@ pub extern "C" fn probe_scalar4_and(a: &[u64; 4], b: &[u64; 4], out: &mut [u64;
129129
/// `IMM` is the 8-bit truth table, matching `mask_ternlog`'s own convention:
130130
/// bit `(a<<2)|(b<<1)|c` of `IMM` is the output for that input triple. Written
131131
/// as the canonical sum-of-minterms so nothing but the truth table is assumed.
132+
///
133+
/// `IMM = 0xE8` is bitwise MAJORITY — a bit is set where at least two of the
134+
/// three inputs have it set:
135+
///
136+
/// ```text
137+
/// a = 0xF0F0, b = 0x00FF, c = 0x0F0F
138+
/// a&b = 0x00F0 a&c = 0x0000 b&c = 0x000F -> 0x00FF
139+
/// ```
140+
///
141+
/// This is deliberately NOT written as a rustdoc example. This file lives in
142+
/// `examples/`, where rustdoc never runs, so a ``` block here would be an
143+
/// untested assertion dressed as a verified one — the exact thing the rest of
144+
/// this PR spent its time removing (coderabbit asked for a usage example,
145+
/// #315). `main` asserts the triple above instead, so the claim is CHECKED on
146+
/// every run rather than decorated.
132147
#[inline(never)]
133148
#[unsafe(no_mangle)]
134149
pub extern "C" fn probe_fixed4_ternlog(a: &[u64; 4], b: &[u64; 4], c: &[u64; 4], out: &mut [u64; 4]) {
@@ -168,8 +183,19 @@ fn main() {
168183
let b8 = [0x00FFu64; 8];
169184
let mut o8 = [0u64; 8];
170185
probe_u64x8_and(&a8, &b8, &mut o8);
186+
// Pin the ternlog arm's SEMANTICS, not just that it runs: `IMM = 0xE8` is
187+
// bitwise majority, so a bit survives where at least two inputs set it.
188+
// 0xF0F0/0x00FF/0x0F0F pairwise-AND to 0x00F0 | 0x0000 | 0x000F = 0x00FF.
189+
//
190+
// This assertion earned its place on the first run: it rejected 0x0FFF,
191+
// which is what I had written from doing the arithmetic in my head (I had
192+
// 0xF0F0 & 0x0F0F as 0x0F00 when the nibbles do not overlap at all, so it
193+
// is 0x0000). A truth table transcribed one bit off would still emit
194+
// plausible `vpternlogq` and survive a read of the assembly — and so would
195+
// a doc example nobody executes. This fails instead.
171196
let c4 = [0x0F0Fu64; 4];
172197
probe_fixed4_ternlog(&a4, &b4, &c4, &mut o4);
198+
assert_eq!(o4, [0x00FFu64; 4], "IMM=0xE8 must be bitwise majority: 0xF0F0/0x00FF/0x0F0F -> 0x00FF");
173199
let mut o2 = [0u64; 2];
174200
probe_scalar2_and(&[1, 2], &[3, 3], &mut o2);
175201
println!("probe: {o4:?} {o8:?} {o2:?}");

0 commit comments

Comments
 (0)