Repository navigation
fix(registry): keep pre-releases out of stable ranges - #3469
JohnnyXu (xubenqiang) wants to merge 6 commits into
Conversation
`pick_best()` kept every version that satisfied the range, including pre-releases, so a stable range selected `1.3.0-beta.1` over `1.2.3` whenever the registry listed a pre-release above the highest release. The git and marketplace resolvers already discard pre-releases, so the same range resolved differently depending on the source. Drop pre-release candidates unless the range itself names a pre-release or the caller opts in, per OpenAPM v0.1 §7.3.1. Fixes microsoft#3466
Co-authored-by: Copilot App <[email protected]>
OpenAPM v0.1 section 7.3.1 permits a pre-release candidate only when the range names a pre-release on the same major.minor.patch; the previous check admitted any pre-release once the range mentioned one, so ">=1.2.0-alpha <2.0.0" could select 1.5.0-beta. Also order equal precedence candidates by full version string (req-rs-014) so the registry picker agrees with the semver-dialect conformance oracle. Addresses the approved apm-scope:v1 tighten on microsoft#3466 and its Done-when oracle clause; tests cover both sides of the rule. Co-authored-by: Copilot App <[email protected]>
Document that a registry semver range selects a pre-release only when it names one on the same major.minor.patch, and add the CHANGELOG entry crediting the contributor. Co-authored-by: Copilot App <[email protected]>
Move the semver-dialect oracle check into tests/spec_conformance so the
registry picker is a marked conformance binding for the requirements it
implements (satisfies the Mode B silent-extension gate), regenerate
CONFORMANCE.{json,md}, and add pre-release regression traps on the two
registry consumers of pick_best: install resolution and outdated Wanted.
Document the req-rs-014 tiebreak at the sort site.
Addresses panel follow-ups from test-coverage-expert and python-architect.
Co-authored-by: Copilot App <[email protected]>
Note that stable git ref ranges never pick a pre-release tag, explain when registry outdated Wanted can be a pre-release, and word the CHANGELOG entry in user terms. Addresses panel follow-ups from doc-writer. Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 2 | 0 | Same-tuple pre-release rule and req-rs-014 tiebreak are correct; one consistency gap in match_version is pre-existing but now visible. |
| Test Coverage Expert | 0 | 2 | 0 | Core pick_best policy is well covered; two consumer call sites (outdated Wanted, registry resolver) lacked pre-release regression traps. |
| Doc Writer | 0 | 2 | 0 | New doc sentences and CHANGELOG entry match pick_best and OpenAPM 7.3.1; outdated Wanted docs and the git-tag claim needed follow-up. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 2 follow-ups
- [Python Architect] Align
match_versionwith the same-tuple pre-release rule, so outdatedoutside_constraintand drift detection treat pre-releases the same way -- it is a separate path that admits pre-releases unconditionally; fixing it touches lockfile drift detection, which is out of scope here. - [Python Architect] Extend the registry range grammar to accept
~0.2, comma AND and||OR ranges, then cover the remaining oracle cases -- these forms fail validation beforepick_bestruns; this is a separate grammar feature, not pre-release selection.
Recommendation
The fix stays within the scope record, follows the spec, and is mutation-proven, and all in-scope panel findings are folded. CI on head a0840bf is green. One precondition remains before merge: JohnnyXu (@xubenqiang) must sign the Microsoft CLA (license/cla is still pending), and the contribution cannot be accepted until it clears. After that, merging is at the maintainer's discretion.
Folded in this run
- (panel) Pre-release admitted only when the range names one on the same major.minor.patch (scope tighten); tests for both sides -- resolved in 055de49.
- (panel) req-rs-014 build-metadata tiebreak so the
prerelease_optin=falseoracle cases pass -- resolved in 055de49. - (panel) CHANGELOG Fixed entry crediting JohnnyXu (@xubenqiang); registry range sentence in manifest-schema.md and apm-guide dependencies.md -- resolved in 301fe2f.
- (panel) Oracle check bound under
tests/spec_conformancewith req-rs-007 / req-rs-014 markers, CONFORMANCE regenerated (clears the Mode B gate) -- resolved in 281d04a. - (panel) Tiebreak invariant comment at the sort site -- resolved in 281d04a.
- (panel) Regression traps: outdated Wanted and registry install skip a published pre-release for a stable range -- resolved in 281d04a.
- (panel) outdated.md Wanted clause; git ref range note; CHANGELOG reworded in user terms -- resolved in a0840bf.
Copilot signals reviewed
- review 5768931976 -- NOT-LEGIT: no review content (reviewer quota error); zero inline comments across 2 fetch rounds.
Deferred (out-of-scope follow-ups)
- (panel) Apply the same-tuple rule in registry
match_version-- scope boundary:match_versionalso drivesdrift.pylockfile drift detection, and the scope record excludes lockfile changes. - (panel) Registry picker does not parse oracle ranges
~0.2, comma AND and||OR -- scope boundary: needs a range-grammar extension in themarketplace.semvergrammar shared with the marketplace resolver, which is outside pre-release scope.
Regression-trap evidence (mutation-break gate)
test_semver.py::TestPickBestPrereleasePolicy::test_prerelease_range_rejects_other_tuple_prerelease-- deletedsame-tuple check; test FAILED as expected; guard restored.test_semver.py::TestPickBestPrereleasePolicy::test_stable_range_skips_prerelease_above_it-- deletedpre-release filter; test FAILED as expected; guard restored.test_resolver.py::TestHappyPath::test_stable_range_skips_published_prerelease-- deletedpre-release filter; test FAILED as expected; guard restored.test_outdated.py::TestCheckRegistryLockedDep::test_wanted_excludes_prerelease_from_stable_range-- deletedpre-release filter; test FAILED as expected; guard restored.test_resolution_reqs.py::test_registry_picker_matches_semver_dialect_oracle[build-metadata-tiebreak-ascii-highest]-- deleted(SemVer, raw) tiebreak; test FAILED as expected; guard restored.
Lint contract
ruff check and ruff format --check were silent, pylint R0801 rated 10.00/10, and lint-auth-signals.sh and lint-architecture-boundaries.sh passed. The run was on the head merged with current main. The owner-touch gate found no canonical owner touched.
CI
All CI checks on a0840bf passed (SUCCESS, NEUTRAL or SKIPPED). One fix iteration was needed: the Spec conformance Mode B detector failed on 301fe2f and was fixed in 281d04a. license/cla is still pending.
Mergeability status
| PR | head SHA | CEO stance | iters | folds | defers | Copilot rounds | CI | mergeable | mergeStateStatus | notes |
|---|---|---|---|---|---|---|---|---|---|---|
| #3469 | a0840bf |
ship_with_followups | 2 | 9 | 2 | 2 | yellow | MERGEABLE | BLOCKED | CLA unsigned; awaiting maintainer review |
Full per-persona findings
Python Architect
- [recommended]
match_versiondoes not apply the pre-release opt-in rule, which splits authority withpick_bestatsrc/apm_cli/deps/registry/semver.py:48
outdated.py usesmatch_versionforoutside_constraint. A pre-release Latest on another tuple is therefore not flagged as outside the constraint. This gap existed before the PR and the new filtering makes it visible; it is cosmetic for outdated only. Deferred (lockfile drift boundary). - [recommended] The
(SemVer, raw)sort tiebreak contract is implicit atsrc/apm_cli/deps/registry/semver.py:95
Suggested: comment the req-rs-014 invariant. Folded in 281d04a.
Doc Writer
- [recommended] The
apm outdatedreference did not say that Wanted skips pre-releases while Latest includes them, atdocs/src/content/docs/reference/cli/outdated.md
Folded in a0840bf. - [recommended] The CHANGELOG git-tag claim had no supporting docs and used internal wording, at
CHANGELOG.md:21
Verified thatgit_reference_resolver.py:541previously selected pre-releases. Folded in a0840bf.
Test Coverage Expert
- [recommended] Outdated Wanted had no pre-release regression trap, at
tests/unit/registry/test_outdated.py
Proof (missing at):tests/unit/registry/test_outdated.py-- proves: Wanted is never a pre-release for a stable range. Folded in 281d04a. - [recommended] Registry install resolution had no pre-release regression trap, at
tests/unit/registry/test_resolver.py
Proof (missing at):tests/unit/registry/test_resolver.py-- proves: a stable range never installs a pre-release. Folded in 281d04a.
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.
|
Thank you for this fix, JohnnyXu (@xubenqiang) -- the change itself is useful and matches the approved scope on #3466. We can only merge contributions once the Microsoft Contributor License Agreement (CLA) is signed, and this PR has been waiting on it for more than 7 days. Per our maintainer policy we are closing it for now so the queue reflects what can actually land. This is not a rejection. As soon as the CLA is signed (follow the Posted with AI assistance on behalf of Daniel Meppiel (@danielmeppiel) (APM maintainer backlog policy). |
* fix(registry): keep pre-releases out of stable semver ranges
Registry version selection (deps/registry/semver.pick_best) now discards
a pre-release candidate unless the range names a pre-release on the same
[major, minor, patch] tuple, per OpenAPM v0.1 section 7.3.1 (req-rs-007).
Equal-precedence candidates tie-break on the bytewise-highest version
string (req-rs-014) instead of registry list order.
Binds the registry picker to the semver-dialect.json oracle
(prerelease_optin=false) under req-rs-007 and req-rs-014; the three
range-grammar cases the registry gate does not accept yet are a strict
xfail. CONFORMANCE.{json,md} regenerated.
Refs #3466
Credit: approach from #3469 by @xubenqiang.
Co-authored-by: Copilot App <[email protected]>
* docs(changelog): note registry pre-release range fix (#3601)
Refs #3466
Co-authored-by: Copilot App <[email protected]>
* test(registry): integration-tier trap for stable-range pre-release skip
The panel test-coverage lens found pre-release filtering exercised only
at unit tier. Add a sibling to test_best_version_selected so the
RegistryPackageResolver._pick_version path proves a stable range skips a
published pre-release. Mutation-break verified: removing the pick_best
pre-release guard fails this test.
Addresses CEO follow-up from test-coverage-expert (#3601).
Co-authored-by: Copilot App <[email protected]>
---------
Co-authored-by: danielmeppiel <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Fixes #3466
Problem
deps/registry/semver.pick_best()filtered only bysatisfies_range(), so pre-release versions stayed in the candidate set:deps/git_semver_resolver.pydiscards pre-releases unlessinclude_prerelease=True, andmarketplace/version_resolver.pyskips them, so the same range resolved to a different version depending on the source. OpenAPM v0.1 §7.3.1 requires pre-release candidates to be discarded unless the range names a pre-release on the same tuple or the entry opts in.Fix
_range_mentions_prerelease()parses each space-separated comparator (after stripping>=,<=,^,~,=), so ranges such as>=1.3.0-beta.1 <2.0.0still allow pre-releases. The default is opt-out, matching the git and marketplace resolvers.Verification
After the change, the issue's three examples and the pre-release range:
Before the change, the same first three calls returned
1.3.0-beta.1,2.0.0-rc.1and1.2.5-alpha.1(the reported behaviour).Five tests are added to
tests/unit/registry/test_semver.py(TestPickBestPrereleasePolicy), covering the three reported cases, the pre-release-range allowance, and the explicit opt-in.ruff checkandruff format --checkpass on both changed files.Notes
prerelease: trueopt-in named by the spec is not implemented anywhere in the parser today;include_prereleaseis the resolver-level hook for whoever wires it up.deps/registry/resolver.py) needs no change: the default now drops pre-releases.