Check the mic-on multi-interval histogram decoder's byte order (LE read may be BE shifted one byte) #49

Closed
opened 2026-10-26 17:14:16 -04:00 by serversdown · 2 comments
Owner

Summary

Check whether the mic-on multi-interval histogram decoder reads its records one byte off, as little-endian when they are big-endian. This is a suspicion, not a finding.

histogram_codec.walk_multi_interval_blocks reads 20-byte records of "8 × uint16 little-endian" after a 6-byte block header. The mic-off variant, measured on 2026-10-26 (66/66 values exact, #47), is big-endian, starting one byte earlier (5-byte header).

Why it could have hidden

A little-endian read of a big-endian field shifted by one byte gives lo + 256 × next_hi. That equals the true value only while the field's own high byte and the next field's high byte are both zero. The two readings therefore agree on almost every interval, and diverge only when:

  • a peak ≥ 256 counts (≥ 1.28 in/s), or
  • a half-period ≥ 256 (below 4 Hz at 2048 sps).

When they diverge, the LE reading inflates the previous field. A T half-period ≥ 256 would make T's peak read huge.

The 2026-08-26 verification (K440L3AQ.T70H: 17,130 peaks and 22,840 frequencies exact) either contained no such intervals, or did, in which case LE is right and the two variants genuinely differ.

To settle

  • Across the archive's 15 s / 2 s histograms with ASCII pairs, compare only the intervals with a peak ≥ 1.28 in/s or a frequency < 4 Hz.
  • Today's 2.5-hour mic-on, 2-second BE9441 run, once it's downloaded with its ASCII export, gives a fresh pair too.
  • If it's real, it's a decoder change (TOOL_VERSION + backfill).
## Summary Check whether the **mic-on multi-interval histogram decoder reads its records one byte off**, as little-endian when they are big-endian. **This is a suspicion, not a finding.** `histogram_codec.walk_multi_interval_blocks` reads 20-byte records of "8 × uint16 **little**-endian" after a 6-byte block header. The mic-off variant, measured on 2026-10-26 (66/66 values exact, #47), is **big-endian, starting one byte earlier** (5-byte header). ## Why it could have hidden A little-endian read of a big-endian field shifted by one byte gives `lo + 256 × next_hi`. That equals the true value only while the field's own high byte **and** the next field's high byte are both zero. The two readings therefore agree on almost every interval, and diverge only when: - a **peak ≥ 256 counts** (≥ 1.28 in/s), or - a **half-period ≥ 256** (below 4 Hz at 2048 sps). When they diverge, the LE reading inflates the previous field. A T half-period ≥ 256 would make T's peak read huge. The 2026-08-26 verification (K440L3AQ.T70H: 17,130 peaks and 22,840 frequencies exact) either contained no such intervals, or did, in which case LE is right and the two variants genuinely differ. ## To settle - Across the archive's 15 s / 2 s histograms with ASCII pairs, compare only the intervals with a peak ≥ 1.28 in/s or a frequency < 4 Hz. - Today's 2.5-hour mic-on, 2-second BE9441 run, once it's downloaded with its ASCII export, gives a fresh pair too. - If it's real, it's a decoder change (`TOOL_VERSION` + backfill).
serversdown added the Kind/Testing
Priority
Medium
3
labels 2026-10-26 17:14:16 -04:00
Author
Owner

Confirmed and fixed, on fix/47-mic-off-histograms (dfc5aef, together with #47).

The records are big-endian from byte 5. Across all 13,089 archive histograms with an ASCII export, the old little-endian reading was wrong on exactly 2 intervals:

  • K440KZP4.560H #4764: the Long half-period of 1 read as 257, and the mic peak of 389 as 133;
  • M462KZUD.6R0H #145: the mic peak of 6 read as 262.

The new reader is exact on all 13,089 files. The old reader also required byte 5 to be zero, but byte 5 is the first record's Tran peak high byte, so a block whose first interval was over 1.275 in/s ended the walk.

**Confirmed and fixed**, on `fix/47-mic-off-histograms` (`dfc5aef`, together with #47). The records are big-endian from byte 5. Across all 13,089 archive histograms with an ASCII export, the old little-endian reading was wrong on exactly 2 intervals: - `K440KZP4.560H` #4764: the Long half-period of 1 read as 257, and the mic peak of 389 as 133; - `M462KZUD.6R0H` #145: the mic peak of 6 read as 262. The new reader is exact on all 13,089 files. The old reader also required byte 5 to be zero, but byte 5 is the first record's Tran peak high byte, so a block whose first interval was over 1.275 in/s ended the walk.
Author
Owner

Fixed on dev, merged in 6ed46dc (fix dfc5aef, changelog entry a0fd5fc). The suspicion was right: the mic-on multi-interval records are big-endian from byte 5, and the old little-endian read from byte 6 agreed only while every high byte was zero. Across the archive it misread 2 intervals (a mic peak and a Long half-period); with the new reader the archive histograms are 13,089 / 13,089 exact (was 13,087).

Verified: the full DL2 archive check (scratch/verify_against_ascii.py) is still 14,338 / 14,338 (13,089 histograms, 1,249 waveforms), the same bar as v0.27.0. On prod's 2026-09-30 store snapshot, 0 of 10,433 stored histograms change, so this fix moves no stored data; it matters for future imports.

Ships in v0.32.0. This issue stays open until that release reaches main. The dev → main PR will say Fixes #47, Fixes #49 so Gitea closes both on merge. The deploy's TOOL_VERSION bump and backfill_sidecars.py run (needed anyway for the release's other fixes) regenerate the stored histograms.

**Fixed on `dev`**, merged in `6ed46dc` (fix `dfc5aef`, changelog entry `a0fd5fc`). The suspicion was right: the mic-on multi-interval records are big-endian from byte 5, and the old little-endian read from byte 6 agreed only while every high byte was zero. Across the archive it misread **2 intervals** (a mic peak and a Long half-period); with the new reader the archive histograms are 13,089 / 13,089 exact (was 13,087). **Verified:** the full DL2 archive check (`scratch/verify_against_ascii.py`) is still **14,338 / 14,338** (13,089 histograms, 1,249 waveforms), the same bar as v0.27.0. On prod's 2026-09-30 store snapshot, **0 of 10,433** stored histograms change, so this fix moves no stored data; it matters for future imports. **Ships in v0.32.0.** This issue stays open until that release reaches `main`. The `dev` → `main` PR will say `Fixes #47, Fixes #49` so Gitea closes both on merge. The deploy's `TOOL_VERSION` bump and `backfill_sidecars.py` run (needed anyway for the release's other fixes) regenerate the stored histograms.
Sign in to join this conversation.