Skip to content

Commit dacc306

Browse files
committed
test(helix): PROBE-MANTISSA-FILL + PROBE-PHASE-1 — Wave-0 probes, 4/4 green
Two probes from OGAR/docs/INTEGRATION-TEST-PLAN.md Wave 0, run against SHIPPED code only (zero non-test changes): PROBE-MANTISSA-FILL (gate for the volumetric/field-edge proposal): does the shipped golden-mantissa generator (HemispherePoint::lift, azimuth n*phi, equal-area r=sqrt(u)) place k implicit centroids over a 256x256 tile more uniformly than seeded uniform-random on the same disk support? Metric: occupied in-disk bins (16x16) + max bin count; golden must beat ALL THREE independent baseline seeds on BOTH metrics at BOTH k=256 and k=1024 — no cherry-picking. RESULT — GREEN: k=256: golden occupied=192 max_bin=3 vs random 141-150 / 5-6 k=1024: golden occupied=208 max_bin=7 vs random 205-206 / 11 plus: zero empty interior bins (bin-center radius <= 0.9) at k=1024. PROBE-PHASE-1 (Wave-0 row 1; D-QUANTGATE integer phase walk): RESULT — GREEN: CurveRuler regeneration bit-exact across independent constructions (20 (path,depth) pairs incl. u64::MAX); the stride-4-over-17 arc is a full permutation from every one of the 17 start offsets. Kill-conditions were declared before running (per the probe-first plan): a red MANTISSA-FILL would have demoted the golden-placement leg to an explicit centroid grid. It is green; the leg is measured. Board hygiene: EPIPHANIES E-PROBE-MANTISSA-1 prepended in this commit (numbers + the three remaining gates before VolumetricField leaves [H]). https://claude.ai/code/session_01PBTGaPCSnnt6u3pjXpbLwY
1 parent 1def205 commit dacc306

2 files changed

Lines changed: 232 additions & 0 deletions

File tree

.claude/board/EPIPHANIES.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
## 2026-06-10 — E-PROBE-MANTISSA-1 — golden-mantissa centroid placement measured: beats uniform-random on coverage AND pile-up; PHASE-1 bit-exactness green
2+
3+
**Status:** FINDING (probes run first-hand: `crates/helix/tests/probe_mantissa_fill.rs`, 4/4 green)
4+
**Confidence:** High — three independent baseline seeds, golden wins all, both metrics, both sample counts.
5+
6+
Wave-0 receipts (per `OGAR/docs/INTEGRATION-TEST-PLAN.md` §1; the
7+
volumetric-field-edge proposal's first gate):
8+
9+
- **PROBE-MANTISSA-FILL GREEN.** Shipped `HemispherePoint::lift` (azimuth
10+
`n·φ`, equal-area `r=√u`) placing k implicit centroids over a 256×256
11+
tile (16×16 in-disk bins) vs seeded uniform-random on the same disk
12+
support: k=256 → golden occupied **192** vs random 141–150, max-bin
13+
**3** vs 5–6 (≈half the pile-up); k=1024 → occupied **208** vs 205–206,
14+
max-bin **7** vs **11**; zero empty interior bins (r ≤ 0.9) at k=1024.
15+
The "golden mantissa places implicit centroids pairwise-uniformly" leg
16+
of the volumetric/field-edge proposal is now measured, not asserted.
17+
- **PROBE-PHASE-1 GREEN.** `CurveRuler` regeneration is bit-exact across
18+
independent constructions (20 (path,depth) pairs incl. `u64::MAX`), and
19+
the stride-4-over-17 arc is a full permutation from every one of the 17
20+
offsets — the D-QUANTGATE-mandated integer phase walk holds.
21+
22+
Remaining gates before the VolumetricField edge-layout leaves `[H]`:
23+
PROBE-ATTN-EDGE (LUT weight ↔ edge-strength ρ vs Pflug anchors),
24+
PROBE-SPLAT-PSD (EWA Σ composition), PROBE-CASCADE-SPARSITY (HHTL
25+
skip-ratio ≥90% on the volumetric workload). Canon pin: `OGAR/CLAUDE.md`
26+
schema-driven block (PR #51).
27+
128
## 2026-06-09 — E-MINT-TRACE-1 — the live mint is already global (registry.rs:476); the "namespace-local" doc is stale; dedup is net-new; the bijection IS the dedup
229

330
**Status:** FINDING (traced, ratified: `entity_type` = global shared template id)
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
//! PROBE-MANTISSA-FILL + PROBE-PHASE-1 — Wave-0 probes against shipped code.
2+
//!
3+
//! Per `OGAR/docs/INTEGRATION-TEST-PLAN.md` §1 (the probe-first rule: no
4+
//! integration brick lands before its probe is green) and the
5+
//! volumetric-field-edge proposal (implicit centroids placed by the golden
6+
//! mantissa, pairwise-weighted by the 256×256 attention LUT, splat-ranked).
7+
//!
8+
//! ## PROBE-MANTISSA-FILL
9+
//!
10+
//! Question: does the shipped golden-mantissa generator
11+
//! ([`HemispherePoint::lift`] — azimuth `n·φ`, equal-area `r = √u`) place k
12+
//! implicit centroids over a 256×256 tile MORE uniformly than seeded
13+
//! uniform-random placement on the same support (the unit disk)?
14+
//!
15+
//! Metric (discrepancy proxy, 16×16 binning over the tile, in-disk bins only):
16+
//! - `occupied`: distinct in-disk bins hit (higher = better coverage)
17+
//! - `max_bin`: worst-case pile-up (lower = better spread)
18+
//!
19+
//! PASS: at k ∈ {256, 1024}, golden beats EVERY one of three independently
20+
//! seeded uniform-random baselines on BOTH metrics (no cherry-picked seed).
21+
//!
22+
//! KILL (per the proposal's kill-condition): golden loses → the "golden
23+
//! mantissa places implicit centroids" leg falls back to an explicit grid.
24+
//!
25+
//! ## PROBE-PHASE-1 (regeneration determinism)
26+
//!
27+
//! Question: is the deterministic-phase generator bit-exact — same address ⟹
28+
//! same sequence, across independent constructions? ([`CurveRuler`] is the
29+
//! D-QUANTGATE-mandated coprime-integer walk; a float recurrence could drift,
30+
//! an integer walk must not.)
31+
//!
32+
//! PASS: two independent `CurveRuler`s from the same `(path, depth)` produce
33+
//! identical full arcs; the arc is a full permutation of 0..17; and the
34+
//! permutation property holds for every one of the 17 possible offsets.
35+
36+
use helix::{CurveRuler, HemispherePoint};
37+
38+
const TILE: usize = 256;
39+
const BINS: usize = 16; // 16×16 bins over the 256×256 tile
40+
const BIN_W: usize = TILE / BINS;
41+
42+
/// xorshift64 — the workspace's zero-dep seeded RNG test pattern.
43+
struct XorShift64(u64);
44+
impl XorShift64 {
45+
fn next(&mut self) -> u64 {
46+
let mut x = self.0;
47+
x ^= x << 13;
48+
x ^= x >> 7;
49+
x ^= x << 17;
50+
self.0 = x;
51+
x
52+
}
53+
/// Uniform f64 in [0, 1).
54+
fn unit(&mut self) -> f64 {
55+
(self.next() >> 11) as f64 / (1u64 << 53) as f64
56+
}
57+
}
58+
59+
/// Map a unit-disk point (x, z ∈ [-1, 1]) to a tile bin index, or None if the
60+
/// pixel falls outside the 256×256 tile after scaling.
61+
fn disk_to_bin(x: f64, z: f64) -> Option<usize> {
62+
let ux = (x + 1.0) / 2.0;
63+
let uz = (z + 1.0) / 2.0;
64+
if !(0.0..1.0).contains(&ux) || !(0.0..1.0).contains(&uz) {
65+
return None;
66+
}
67+
let px = (ux * TILE as f64) as usize;
68+
let pz = (uz * TILE as f64) as usize;
69+
Some((pz / BIN_W) * BINS + (px / BIN_W))
70+
}
71+
72+
/// Whether a bin's center lies inside the unit disk (both generators share
73+
/// the disk as support; corner bins are unreachable for both, so the metric
74+
/// only counts bins both COULD hit).
75+
fn bin_in_disk(bin: usize) -> bool {
76+
let bx = (bin % BINS) as f64;
77+
let bz = (bin / BINS) as f64;
78+
let cx = (bx + 0.5) / BINS as f64 * 2.0 - 1.0;
79+
let cz = (bz + 0.5) / BINS as f64 * 2.0 - 1.0;
80+
cx * cx + cz * cz <= 1.0
81+
}
82+
83+
/// (occupied in-disk bins, max single-bin count) for a set of disk points.
84+
fn fill_metrics(points: impl Iterator<Item = (f64, f64)>) -> (usize, usize) {
85+
let mut counts = [0usize; BINS * BINS];
86+
for (x, z) in points {
87+
if let Some(b) = disk_to_bin(x, z) {
88+
counts[b] += 1;
89+
}
90+
}
91+
let occupied = (0..BINS * BINS)
92+
.filter(|&b| bin_in_disk(b) && counts[b] > 0)
93+
.count();
94+
let max_bin = counts.iter().copied().max().unwrap_or(0);
95+
(occupied, max_bin)
96+
}
97+
98+
fn golden_points(k: usize) -> Vec<(f64, f64)> {
99+
(0..k)
100+
.map(|n| {
101+
let p = HemispherePoint::lift(n, k);
102+
let (x, z, _y) = p.cartesian();
103+
(x, z)
104+
})
105+
.collect()
106+
}
107+
108+
fn random_disk_points(k: usize, seed: u64) -> Vec<(f64, f64)> {
109+
// Rejection-sample uniform points in the unit disk (same support as the
110+
// golden generator) so the comparison is geometry-fair.
111+
let mut rng = XorShift64(seed);
112+
let mut out = Vec::with_capacity(k);
113+
while out.len() < k {
114+
let x = rng.unit() * 2.0 - 1.0;
115+
let z = rng.unit() * 2.0 - 1.0;
116+
if x * x + z * z < 1.0 {
117+
out.push((x, z));
118+
}
119+
}
120+
out
121+
}
122+
123+
#[test]
124+
fn probe_mantissa_fill_golden_beats_uniform_random() {
125+
// Three independent baseline seeds — golden must beat ALL of them on
126+
// BOTH metrics at BOTH sample counts; no cherry-picking.
127+
const SEEDS: [u64; 3] = [0x9E37_79B9_7F4A_7C15, 0xD1B5_4A32_D192_ED03, 0x2545_F491_4F6C_DD1D];
128+
129+
for &k in &[256usize, 1024] {
130+
let (g_occ, g_max) = fill_metrics(golden_points(k).into_iter());
131+
for &seed in &SEEDS {
132+
let (r_occ, r_max) = fill_metrics(random_disk_points(k, seed).into_iter());
133+
assert!(
134+
g_occ >= r_occ,
135+
"k={k} seed={seed:#x}: golden occupied {g_occ} < random {r_occ} — \
136+
MANTISSA-FILL RED: golden mantissa does not out-cover uniform random"
137+
);
138+
assert!(
139+
g_max <= r_max,
140+
"k={k} seed={seed:#x}: golden max-bin {g_max} > random {r_max} — \
141+
MANTISSA-FILL RED: golden mantissa piles up worse than uniform random"
142+
);
143+
}
144+
// Print the receipt numbers so the probe run is quotable.
145+
println!("MANTISSA-FILL k={k}: golden occupied={g_occ} max_bin={g_max}");
146+
for &seed in &SEEDS {
147+
let (r_occ, r_max) = fill_metrics(random_disk_points(k, seed).into_iter());
148+
println!(" random seed={seed:#x}: occupied={r_occ} max_bin={r_max}");
149+
}
150+
}
151+
}
152+
153+
#[test]
154+
fn probe_mantissa_fill_no_empty_inner_region_at_1024() {
155+
// Stronger coverage claim at k=1024: every in-disk bin whose center is
156+
// comfortably interior (radius ≤ 0.9) must be occupied by golden points.
157+
let mut counts = [0usize; BINS * BINS];
158+
for (x, z) in golden_points(1024) {
159+
if let Some(b) = disk_to_bin(x, z) {
160+
counts[b] += 1;
161+
}
162+
}
163+
for b in 0..BINS * BINS {
164+
let bx = (b % BINS) as f64;
165+
let bz = (b / BINS) as f64;
166+
let cx = (bx + 0.5) / BINS as f64 * 2.0 - 1.0;
167+
let cz = (bz + 0.5) / BINS as f64 * 2.0 - 1.0;
168+
if cx * cx + cz * cz <= 0.81 {
169+
assert!(
170+
counts[b] > 0,
171+
"interior bin {b} (center {cx:.2},{cz:.2}) EMPTY at k=1024 — \
172+
golden mantissa leaves interior holes"
173+
);
174+
}
175+
}
176+
}
177+
178+
#[test]
179+
fn probe_phase1_curve_ruler_regeneration_is_bit_exact() {
180+
// Same address ⟹ same sequence, across independent constructions.
181+
for path in [0u64, 1, 0x1234, u64::MAX, 0xDEAD_BEEF_CAFE_F00D] {
182+
for depth in [0u8, 1, 7, 16] {
183+
let a = CurveRuler::from_hhtl(path, depth);
184+
let b = CurveRuler::from_hhtl(path, depth);
185+
assert_eq!(a.arc(), b.arc(), "regeneration drift at ({path:#x},{depth})");
186+
}
187+
}
188+
}
189+
190+
#[test]
191+
fn probe_phase1_full_permutation_for_every_offset() {
192+
// The stride-4-over-17 arc must be a full permutation of 0..17 from every
193+
// possible start offset (coprimality must hold everywhere, not just at 0).
194+
for place in 0u64..17 {
195+
let ruler = CurveRuler::from_place(place);
196+
let arc = ruler.arc();
197+
let mut seen = [false; 17];
198+
for &v in &arc {
199+
assert!(v < 17, "residue {v} out of range");
200+
assert!(!seen[v as usize], "residue {v} repeated at place {place}");
201+
seen[v as usize] = true;
202+
}
203+
assert!(seen.iter().all(|&s| s), "incomplete permutation at place {place}");
204+
}
205+
}

0 commit comments

Comments
 (0)