Repository navigation
fix(registry): keep pre-releases out of stable semver ranges - #3601
Daniel Meppiel (danielmeppiel) merged 8 commits into
Conversation
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]>
…istry-prerelease-stable-ranges
Refs #3466 Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the registry pre-release selection changes.
No open issues 🎉
What changed in this PR
Addresses the registry pre-release selection bug in #3466 by aligning pick_best with OpenAPM’s same-version-tuple eligibility rule, without expanding the accepted range grammar.
Changes:
- Excludes pre-releases unless the range names one on the same
major.minor.patch, and makes equal-precedence ties deterministic using bytewise version-string ordering. - Adds picker, install,
outdated, and conformance coverage; records three deferred grammar cases as strict expected failures. - Updates user documentation and generated conformance records.
| File | Description |
|---|---|
tests/unit/registry/test_semver.py |
Tests pre-release eligibility and order-independent build tie-breaking. |
tests/unit/registry/test_resolver.py |
Verifies stable-range installs skip published pre-releases. |
tests/unit/registry/test_outdated.py |
Verifies stable Wanted selection while Latest can report a pre-release. |
tests/spec_conformance/test_resolution_reqs.py |
Binds registry selection to oracle cases and tracks deferred grammar gaps. |
src/apm_cli/deps/registry/semver.py |
Filters pre-releases by named version tuple and adds deterministic tie-breaking. |
packages/apm-guide/.apm/skills/apm-usage/dependencies.md |
Documents registry range pre-release eligibility. |
docs/src/content/docs/reference/manifest-schema.md |
Explains pre-release range selection and exact-version behavior. |
docs/src/content/docs/reference/cli/outdated.md |
Clarifies pre-release eligibility for Wanted. |
docs/src/content/docs/guides/registries.md |
Updates the range-selector behavior description. |
CONFORMANCE.md |
Updates resolution requirement test counts. |
CONFORMANCE.json |
Records the added conformance test bindings. |
Review effort: Balanced
…istry-prerelease-stable-ranges
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]>
…istry-prerelease-stable-ranges
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 0 | 0 | pick_best pre-release filter and max() tiebreak correctly implement OpenAPM 7.3.1 and req-rs-014; no canonical-authority split; ship. |
| Test Coverage Expert | 0 | 1 -> 0 | 0 | Iteration 1: tier-floor gap at integration level. Delta: folded with mutation-break proof; resolved. |
| Doc Writer | 0 | 0 | 0 | Docs and CHANGELOG match pick_best at head; no stale pre-release mentions. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Recommendation
All iteration-1 follow-ups are resolved. The test-coverage tier floor is met with mutation-break evidence. CI is green across every check at the exact head 988fe1a; the later merges from main were merge-only and touched no PR file. The remaining grammar gaps are explicitly out of scope and tracked on #3466. Ready for maintainer merge at their discretion.
Folded in this run
- (panel: test-coverage-expert) Integration-tier trap
tests/integration/test_deps_registry_coverage.py::TestRegistryPackageResolverPickVersion::test_best_version_skips_prerelease-- resolved in 9d54fe6. - (orchestrator scope check) PR body: removed the accidental closing reference to [BUG] Registry resolver selects pre-releases for stable ranges, against OpenAPM §7.3.1 #3466 and added the
Partial:line -- PR body edit (no commit). - Merged current
main(clean, unrelated commits) -- 5bc2294, 0a09e7c, 90d9be9, 988fe1a.
Copilot signals reviewed
- Overview review on 90b07de -- NOT-LEGIT (no action): "Approval recommended", zero inline comments; nothing to fold.
Regression-trap evidence (mutation-break gate)
TestRegistryPackageResolverPickVersion::test_best_version_skips_prerelease-- deleted theif v.is_prerelease and (v.major, v.minor, v.patch) not in allowed_prerelease: continueguard insrc/apm_cli/deps/registry/semver.py; test FAILED as expected (1 failed); guard restored (1 passed).
Lint contract
ruff check and ruff format --check over src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py silent; pylint R0801 10.00/10; lint-auth-signals.sh clean; lint-architecture-boundaries.sh exit 0. Owner-touch gate: no canonical owner touched.
CI
All 26 checks green (23 pass, 3 skipped) at 988fe1a (also green at 0a09e7c and 90d9be9) (Lint, Build & Test shards, Lifecycle Smoke, Spec conformance gate, Windows gates, CodeQL, license/cla) after 0 CI fix iterations. Targeted local run: pytest tests/unit/registry/test_semver.py tests/unit/registry/test_resolver.py tests/unit/registry/test_outdated.py tests/spec_conformance/test_resolution_reqs.py tests/integration/test_deps_registry_coverage.py::TestRegistryPackageResolverPickVersion -> 232 passed, 3 xfailed (strict xfail grammar gaps).
Mergeability status
| PR | head SHA | CEO stance | iters | folds | defers | Copilot rounds | CI | mergeable | mergeStateStatus | notes |
|---|---|---|---|---|---|---|---|---|---|---|
| #3601 | 988fe1a |
ship_now | 1 | 2 | 0 | 1 | green | MERGEABLE | BLOCKED | Refs-only partial; pending required review |
Convergence
1 outer iteration(s); 1 Copilot round(s). Final panel stance: ship_now. Ready for maintainer review.
Full per-persona findings
Python Architect
No findings.
Test Coverage Expert
- [recommended] (iteration 1, now folded) Tier-floor gap: pre-release filtering covered at unit tier only; install-pipeline surface needs integration-with-fixtures. at
tests/integration/test_deps_registry_coverage.py:716
Proof (missing at):tests/integration/test_deps_registry_coverage.py::TestRegistryPackageResolverPickVersion::test_best_version_skips_prerelease-- proves: A stable semver range in apm install never resolves to a pre-release tag published alongside stable versions. [governed-by-policy,devx]
Delta: test added in 9d54fe6 with mutation-break proof; no findings.
Doc Writer
No findings.
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.
…istry-prerelease-stable-ranges
…istry-prerelease-stable-ranges
Description
TL;DR
Registry version selection (
pick_best) no longer picks a pre-release for a stable range:^1.2.3over[1.2.3, 1.3.0-beta.1]now resolves1.2.3. A pre-release is eligible only when the range itself names a pre-release on the samemajor.minor.patch, per OpenAPM v0.1 §7.3.1. Equal-precedence builds now tie-break on the bytewise-highest version string (req-rs-014) instead of registry list order.Important
Partial delivery of the scope record's Done when. Every pre-release clause is met, but three
prerelease_optin=falseoracle cases (tilde-0_x~0.2,comma-and>=1.0.0, <1.5.0,or-union1.x || ...) fail for range-grammar reasons, not pre-release reasons:is_semver_rangerejects those forms today (andtests/unit/registry/test_semver.py::TestIsSemverRange::test_rejects_invalid_refspins that rejection). That gate is shared with marketplace manifest validation, drift and ref classification, so widening it is outside this record (Out of scope: marketplace resolver changes). They are recorded as astrict=Truexfail test so a future grammar change flips them loudly. HenceRefs, notFixes.Credit: approach from #3469 by JohnnyXu (@xubenqiang) (closed for CLA). This PR is an independent implementation of the narrower approved scope: #3469's original commit admitted any pre-release once the range named one; this admits only the range's own
[major, minor, patch]tuple.Problem (WHY)
pick_bestkept pre-releases in the candidate set, so^1.2.3→1.3.0-beta.1,>=1.2.0 <2.0.0→2.0.0-rc.1,~1.2.0→1.2.5-alpha.1(reproduced on2cc5d809c).>=1.2.0-alpha <2.0.0selected1.5.0-beta, a pre-release on a tuple the range never named.GitSemverResolverand the marketplace resolver already drop pre-releases.1.2.3+zetavs1.2.3+build.42) resolved by registry response order, which is non-deterministic.Why these matter: OpenAPM v0.1 §7.3.1 says pre-release candidates "MUST be discarded from the candidate set before highest-match selection" unless the range "contains a pre-release identifier on the same
[major, minor, patch]tuple"; req-rs-014 requires selecting "the tag whose name compares highest under bytewise ASCII ordering" on equal precedence.Approach (WHAT)
[major, minor, patch]tuples of pre-release operands in the range; drop any pre-release candidate whose tuple is not in that set before matching.max((SemVer, raw))so equal precedence falls back to the raw string (req-rs-014).semver-dialect.json,prerelease_optin=false) underreq-rs-007/req-rs-014.Implementation (HOW)
src/apm_cli/deps/registry/semver.py— new_prerelease_tuples();pick_best()filters and tie-breaks.is_semver_range,match_versionand the shared marketplace matcher are untouched.tests/unit/registry/test_semver.py— issue cases, same-tuple admit/reject, upper-bound and caret pre-release operands, exact pre-release, order-independent tie-break.tests/unit/registry/test_resolver.py,test_outdated.py—download_package("^1.0.0")downloads1.5.3not1.6.0-rc.1;apm outdatedWantedexcludes the beta whileLateststill reports it.tests/spec_conformance/test_resolution_reqs.py— oracle-driven conformance test plus a separate strict-xfail test for the three grammar gaps (kept off the req markers soCONFORMANCE.jsonlists only passing evidence).guides/registries.md,reference/manifest-schema.md,reference/cli/outdated.mdandapm-usage/dependencies.md.CONFORMANCE.{json,md}regenerated.Diagrams
Legend: candidate flow inside
pick_best; the boxed step is new.flowchart LR A["registry /versions"] --> B["parse_semver"] B --> C{"pre-release?"} C -->|"no"| E["satisfies_range"] C -->|"yes"| D["NEW: tuple named by a pre-release operand in range?"] D -->|"yes"| E D -->|"no"| X["discard"] E -->|"match"| F["NEW: max by SemVer then raw string"]Trade-offs
pick_best, notresolver.py. The record namespick_best;apm outdatedWantedand thegit_reference_resolversemver-tag fallback (git_reference_resolver.py:545) share it, so those paths now agree withGitSemverResolver(req-rs-002). No code in the git-semver or marketplace resolvers changed.match_versionunchanged. Drift andoutdated"outside constraint" checks still treat a locked pre-release as in range, so this PR forces no re-resolution of existing lockfiles.prerelease: trueopt-in. Explicitly out of scope; theprerelease_optin=trueoracle case is not bound.Benefits
1.2.3,1.9.0and1.2.4.prerelease_optin=falseoracle cases are now bound to the registry picker (req-rs-0071 → 11 tests inCONFORMANCE.md).Issue and approved scope
Issue: Refs #3466
Partial: delivers every pre-release clause of the #3466 scope record and the req-rs-014 tie-break; remaining is the registry range grammar for oracle cases tilde-0_x (~0.2), comma-and and or-union (||), which needs a decision on the shared is_semver_range gate (out of this record's scope).
Human scope-approval comment: #3466 (comment) (
apm-scope:v1, review contact Daniel Meppiel (@danielmeppiel))Does this PR complete the issue, or what remains? It delivers the full pre-release scope and the req-rs-014 tie-break. Remaining Done when gap: the registry picker does not yet accept
~0.2, comma-AND and||ranges (oracle casestilde-0_x,comma-and,or-union). That needs a range-grammar decision on the sharedis_semver_rangegate, which the record puts out of scope. The maintainer decides whether the issue stays open for the grammar follow-up.Type of change
Testing
Validation evidence
Reproduction on HEAD
2cc5d809cbefore the fix:TDD and mutation-break (fix reverted with
git stash, then restored):Spec conformance (mirrors
.github/workflows/spec-conformance.yml):Lint contract on the merged tree (
ruff check,ruff format --check, pylint R0801,lint-auth-signals.sh, Mode B, orphan check): all clean. Targeted tests after mergingorigin/main:pytest tests/unit/registry/ tests/spec_conformance/test_resolution_reqs.py-> 384 passed, 5 xfailed.Local preflight skipped by maintainer instruction (2026-11-12); CI is the gate.
Scenario Evidence
owner/repo#^1.0.0through a registry installs the newest stable release, not a published RCtests/unit/registry/test_resolver.py::TestHappyPath::test_stable_range_skips_published_prerelease1.1.0-alphamay pick1.1.0-beta, but>=1.2.0-alpha <2.0.0never picks1.5.0-betatests/unit/registry/test_semver.py::TestPickBestPrereleaseOptInapm outdatedWantedmatches whatapm installwould picktests/unit/registry/test_outdated.py::TestCheckRegistryLockedDep::test_wanted_excludes_prerelease_from_stable_rangetests/spec_conformance/test_resolution_reqs.py::test_registry_picker_matches_semver_dialect_oracleHow to test
.venv/bin/python -c "from apm_cli.deps.registry.semver import pick_best as p; print(p('^1.2.3',['1.2.3','1.3.0-beta.1']), p('>=1.2.0 <2.0.0',['1.9.0','2.0.0-rc.1']), p('~1.2.0',['1.2.4','1.2.5-alpha.1']))"→1.2.3 1.9.0 1.2.4uv run --extra dev pytest tests/unit/registry/test_semver.py tests/spec_conformance/test_resolution_reqs.py -k "PickBest or registry_picker"→ passes, 3 xfailed (grammar gaps)test_prerelease_sorts_before_release(>=1.0.0-beta.1 <2.0.0) still selects1.0.0.Spec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended. (req-rs-007,req-rs-014; implementation now conforms to existing §7.3.1 text, no spec change.)CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.
Co-authored-by: Copilot [email protected]