Per-file cached state in a long-lived reader helper must reset on every open; size-gated auto features turn latent bugs into defaults
Field lesson from reviewing a waveform reader helper that serves many files from one long-lived worker: it cached a file's end time (and derived values) during an optional index-priming step and never reset them on the next open. Reads past the old end on a later, longer file (or a regrown dump) silently returned the last value. The bug was latent while priming was opt-in, then became default behaviour when priming was switched on automatically above a size threshold. Lessons: (1) audit every per-file cache in a reused worker and reset it in the open/reload path; (2) add a test that opens file A, then a longer file B, and asserts reads past A's end; (3) treat an auto-enable threshold as a behaviour change needing its own review and a measured cost/benefit near the threshold, not an estimate; (4) a counter emitted by the code under test can't make its own test fail, so compare outputs byte-for-byte against a known-good path instead.