Skip to content

Fix longest_run undercounting the final run#14

Open
nh13 wants to merge 1 commit into
learnedsystems:masterfrom
nh13:fix-longest-run-final-flush
Open

Fix longest_run undercounting the final run#14
nh13 wants to merge 1 commit into
learnedsystems:masterfrom
nh13:fix-longest-run-final-flush

Conversation

@nh13

@nh13 nh13 commented Jun 13, 2026

Copy link
Copy Markdown

LowerBoundCorrection::new only commits a run to max_run_length on a transition, so the final run is never recorded. longest_run then undercounts, and returns 0 for any leaf whose entries form a single run. This feeds the per-leaf error bound in two_layer.rs, so the undercount propagates into the reported model error. Flushing the in-progress run after the loop fixes it, with a regression test for the single-run case.

Small heads-up: I wasn't able to run this through cargo test — a couple of the #[cfg(test)] modules don't currently compile against the latest API (ModelData looks like it was renamed), and since CI runs the tests/ integration harness rather than cargo test, it hadn't surfaced. I verified this fix against the real code separately. I'll send a small follow-up PR to get the unit tests compiling again.

(Also noticed data.get_key(0) panics on empty input — happy to fold that into the follow-up.)

Made in collaboration with Claude.

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