Resolve versions by SemVer precedence instead of trusting index order - #1
Open
igorlamos wants to merge 1 commit into
Open
Resolve versions by SemVer precedence instead of trusting index order#1igorlamos wants to merge 1 commit into
igorlamos wants to merge 1 commit into
Conversation
`display_remote_versions` piped the index straight to grep and callers kept the first match, so resolution depended entirely on the order the index arrived in. Nothing promises that order. The GitHub Releases API sorts by created_at, and every beplus/cli release shares one β the tags all point at that repo's unchanged default-branch HEAD β so the list ties and comes back arbitrarily. `be 2` was resolving to a stage build published before the prod one, and `be --latest` could pick an older major once two full releases existed. Sort by SemVer Β§11 before filtering: major, minor, patch, then "has no pre-release" (a release outranks the pre-releases it was promoted from), then the pre-release identifiers β numeric ones compared numerically and ranked below alphanumeric ones, a longer run winning a shared prefix. A name that is not a version sorts last rather than aborting the pipeline. Note this is not `sort -V`: GNU version sort ranks 2.0.0-dev.40 above 2.0.0, which is backwards for a promotion pipeline. The new tests run against a deliberately scrambled index; five of the seven fail without the sort. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
display_remote_versionspiped the index straight togrep, andget_latest_resolved_versionkeeps the first match β so which versionbeinstalls depended entirely on the order the index arrived in. Nothing promises that order.The GitHub Releases API sorts by
created_at, and every release inbeplus/clishares one:gh release createruns without--target, so all the tags point at that repo's unchanged default-branch HEAD. The whole list ties and comes back arbitrarily. In practicebe 2was resolving to a stage build published before the prod one, andbe --latestwould pick between v1 and v2 arbitrarily once a second full release existed.What changed
Sort candidates by SemVer Β§11 before filtering:
A name that is not a version sorts last rather than aborting the pipeline.
This is not
sort -V: GNU version sort ranks2.0.0-dev.40above2.0.0, which is backwards for a promotion pipeline. The comparison is done injq, which the script already requires, so there is no new dependency.Verification
test/tests/ordering.batsruns against a deliberately scrambled index served overfile://. Five of the seven fail without the sort; the two that pass on both are the regression guards (an exact version still resolves to itself, a non-version name does not break the pipeline).The existing
lsr.batssuite still passes against the live index.BE_RELEASE_INDEX_URLis now unset inunset_n_envso a fixture cannot leak between tests.Sequencing
This is defence in depth. The index that
bereads is being fixed at the producer in beplus/cli_v2#28 β sorted, and built from the bucket it is written to rather than from a global GitHub dump β and that lands on everybealready installed with no rollout. Merge this after that one is live.π€ Generated with Claude Code