test(ktuner): pin rollback keep-previous invariant#1338
Open
jfeng18 wants to merge 1 commit into
Open
Conversation
The rollback-merge keep-previous rule was an untested pure decision path in the tuner: across repeated tune/fix/import runs the ORIGINAL pre-ktuner value must survive so rollback restores pristine state. Extract merge_entries as a pure (no-I/O) fn with no behavior change, covered by a discriminating test — a merge that clobbered previous on re-tune fails the assert.
4fc026b to
4f21d77
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Extract
merge_entriesfrommerge_rollbackas a pure (no-I/O) fn with zero behavior change, and pin the rollback keep-previous invariant with a discriminating test: across repeated tune/fix/import runs the ORIGINAL pre-ktuner value must survive so rollback restores pristine state.Why discriminating
A merge that clobbered
previouson re-tune would silently make rollback restore to a post-tune value instead of the pristine one. The test fails ifand_modifyalso setsprevious(mutation-verified).Testing
cargo fmt --check,clippy --all-targets -- -D warnings,cargo test(192 pass).Note
Slimmed from an earlier version: dropped the
is_metric_degradedextraction and its test. That covered the benchmark degradation direction, butverify_and_report/auto_rollback_on_degradationhave zero callers in the shipped CLI (ktuner tuneverifies via staticeval.score()), so testing them hardened dead code. Kept only the live rollback-merge coverage.