Pin the schema-version derivation by its invariant - #7
Merged
ualtinok merged 1 commit intoAug 30, 2026
Merged
Conversation
The manifest-side assertion only checks that store_schema_version parses to a positive number, so a regressed derivation that still returns a positive value is invisible there. Verified by mutation: changing newest_schema_version to .min() left all 22 tests in the area green. The fix is not to restate the derivation in the test -- that would make the test agree with the code by construction and pass whatever the function did. It asserts the two bounds the result must satisfy: no migration exceeds it, and it is a version the list actually contains. .last() stays green while the list is sorted, because it then returns the same value as .max(). That is an equivalent mutant rather than a gap, and the first bound catches it as soon as the list is unsorted -- verified, not asserted, by reversing the iteration order. Reported by cubic on cortexkit#6. The finding was right; its stated reason was not -- the list holds 12 migrations, not one, and .min() survives because 1 is still greater than 0.
|
Merged. Verified your mutation claim independently (.max→.min: your test fails naming the reported value; the prior battery stayed green) and the full battery on the merged tree — 387 green. The two-sided bound is the right shape, and the equivalent-mutant note on .last() is the kind of honesty that makes a test trustworthy: it documents what the pin does NOT catch and why that is correct. |
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.
Follow-up to #6, closing the P3 cubic raised there. One test, no production change.
The finding was right; its stated reason was not
cubic's claim was that
store_schema_versionis only checked to parse as a number> 0, so a regressed derivation is unobserved. That is correct, and I confirmed it by mutation rather than by reading:But the reasoning given was wrong. It said "with the current single-migration list (version 1)"; the list holds 12 migrations, versions 1–12.
.min()survives not because there is one migration, but because it returns1, and1 > 0holds. Same verdict, different mechanism — worth separating, because a fix aimed at the stated reason would have been a fix for a condition that does not exist.Why the obvious fix is the wrong one
The tempting repair is to assert
store_schema_version == newest_schema_version(). That restates the derivation against itself: the test would agree with the code by construction and pass whatever the function did. #6 deliberately avoided that, and the manifest-side check can only honestly see shape.So this asserts the two bounds the result must satisfy, without restating how it is computed:
Mutation battery
Each with a positive control asserting the target existed exactly once before editing.
.max()→.min()1999.max()→.last()The
.last()result is not a gap. While the list is sorted,.last()returns the same value as.max()— an equivalent mutant, a program with identical behaviour, so no test can distinguish it and none should. It becomes a real regression only once the list is unsorted, and the first bound catches it exactly then. Verified rather than asserted, by applying.last()over a reversed view:The comment in the test says this, so the next reader is not left wondering why an obvious mutation survives.
Gate
At the pushed sha
f408eb0, network namespace, egress dead by name and raw IP, loopback control live before and after:Same scope caveat as #6: 4 crates locally, CI runs 6.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Adds a test that pins
newest_schema_version()to its invariant, catching regressions the existing manifest-side check misses.Written for commit f408eb0. Summary will update on new commits.