Skip to content

Golden-value regression tests for the record layer (P2.5) - #5

Merged
remislp merged 1 commit into
masterfrom
golden
Sep 2, 2026
Merged

Golden-value regression tests for the record layer (P2.5)#5
remislp merged 1 commit into
masterfrom
golden

Conversation

@remislp

@remislp remislp commented Sep 2, 2026

Copy link
Copy Markdown
Member

Every package in the stack reads its records through this code, so a change
here reaches SCALCS, EKDIST and HJCFIT at once. Pinning it at the bottom rather
than in HJCFIT is the same work with three times the coverage.

What is pinned

Five cases over the two shipped records, each fixing resolved-interval counts,
period counts, burst counts and openings, mean burst length, mean Popen within
bursts, and the histogram binning.

record tres tcrit resolved bursts mean length
experimental 25 µs 4 ms 3232 63 98.629089 ms
experimental 100 µs 4 ms 2408 62 100.030402 ms
experimental 500 µs 10 ms 1812 56 111.190894 ms
simulated 500 µs 4 ms 33377 9270 111.686132 ms
simulated 1 ms 10 ms 23095 7021 149.705263 ms

The resolutions were chosen so the dead time actually bites. The simulated
record's shortest interval is 125 µs, so a golden case at 25 or 100 µs merges
nothing — it would pin the concatenation logic while exercising none of it.
One of the invariants asserts this, so a future case cannot quietly test
nothing.

Alongside the exact numbers, invariants that hold for any record at any
resolution: periods alternate strictly, every burst has an odd interval count,
burst openings account for every open period, no within-burst gap exceeds
tcrit, the histogram counts every interval, the sign of tcrit is ignored.
Those keep meaning something if the example files are ever replaced.

Two invariants were wrong, and the failures were worth following

I wrote both as obvious truths; both failed on the experimental record at
larger tres. Neither was a defect — but relaxing the tolerance would have
buried two real facts about the layer.

Total time is not conserved outright. impose_resolution starts at the
first interval that is both resolvable and usable, because anything earlier has
a start that cannot be located, and the time before it is dropped — 75.8 µs of
a 102.7 s record at 100 µs. Exactly the observed difference. The invariant now
accounts for that head explicitly.

Resolved intervals are not all at least tres long. Two documented
exceptions carry FLAG_UNUSABLE: the negative sentinel for an unfinished final
opening, and the short shut emitted when a record ends on a brief shutting that
terminates an open run. The invariant is now about usable intervals, which is
what a consumer relies on.

83 tests here; 345 passing overall.

🤖 Generated with Claude Code

Every package in the stack reads its records through this code, so a change
here reaches SCALCS, EKDIST and HJCFIT at once. Pinning it here rather than in
HJCFIT is the same work with three times the coverage.

Five cases over the two shipped records, each fixing resolved-interval counts,
period counts, burst counts and openings, mean burst length, mean Popen within
bursts, and the histogram binning.

Resolutions are chosen so the dead time actually bites. The simulated record's
shortest interval is 125 us, so a golden case at 25 or 100 us would merge
nothing and exercise the concatenation logic not at all -- one of the
invariants now asserts that, so a future case cannot quietly test nothing.

Alongside the exact numbers, invariants that hold for any record at any
resolution: periods alternate strictly, every burst has an odd interval count,
burst openings account for every open period, no within-burst gap exceeds
tcrit, the histogram counts every interval, the sign of tcrit is ignored.
Those keep meaning something if the example files are ever replaced.

Two of them were wrong when first written, and the failures were worth
following rather than relaxing:

Total time is not conserved outright. impose_resolution starts at the first
interval that is both resolvable and usable, because anything earlier has a
start that cannot be located, and the time before it is dropped -- 75.8 us of
a 102.7 s record on the experimental example at 100 us. The invariant now
accounts for that head explicitly rather than allowing a fudge factor that
would have hidden it.

Resolved intervals are not all at least tres long. Two documented exceptions
carry FLAG_UNUSABLE: the negative sentinel for an unfinished final opening,
and the short shut emitted when the record ends on a brief shutting that
terminates an open run. The invariant is now about usable intervals, which is
what a consumer relies on.

83 tests; 345 passing overall.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@remislp
remislp merged commit b77204f into master Sep 2, 2026
9 checks passed
@remislp
remislp deleted the golden branch September 2, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant