Skip to content

fix(cli): toolchain latest is the highest version, update keeps the pinned major - #921

Merged
Kamirus merged 5 commits into
mainfrom
kamil-claude/moc-v1-latest-release-63ee84
Nov 17, 2026
Merged

Kamirus merged 5 commits into
mainfrom
kamil-claude/moc-v1-latest-release-63ee84

Conversation

@Kamirus

@Kamirus Kamirus commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

mops toolchain use <tool> latest, mops toolchain update, and the latest line of mops toolchain info took the first release in GitHub's list, which is the most recently published one. Once the moc 1.x line ships a bugfix such as 1.16.2 after 2.x, every new project that runs mops toolchain use moc latest would pin 1.16.2 instead of the newest 2.x. The interactive picker had the same problem: it lists releases in that order and preselects the first row.

latest is now the release with the highest version, as Cargo resolves it, and the picker, --versions, and latest all share one order.

Before / after

With a moc release page where 1.16.2 was published after 2.2.2:

# before
$ mops toolchain use moc latest
Installed moc 1.16.2

# after
$ mops toolchain use moc latest
Installed moc 2.2.2

Actual output against live GitHub on this branch:

$ mops toolchain info moc
latest: 2.2.2
versions        2.2.2, 2.2.1, 2.2.0, 2.1.0, 2.0.0, 1.16.1, 1.16.0, 1.15.1, 1.15.0, 1.14.1 (+33 more)

$ mops toolchain info wasm-opt
latest: 133
versions        133, 132, 131, 130, 129, 128, 127, 126, 125, 124 (+72 more)

Non-version and prerelease tags

Sorting by version exposed three tag shapes that publish order used to hide:

  • A semver prerelease such as 2.3.0-rc.1 that GitHub doesn't flag as a prerelease would outrank a later 2.2.3 and stay latest until 2.3.0 ships. A prerelease suffix now counts as a prerelease, as in Cargo. Every hyphenated tag in the six repos is flagged today, so nothing changes on live data.

  • A tag that doesn't parse as semver, such as wasmtime's dev or another release line in the same repo, now always ranks below real versions, so it can't become latest. Among themselves, non-semver tags compare numerically.

  • Binaryen's first releases page also holds its old Emscripten-era 1.38.x and 1.39.1 tags. As semver, they would outrank version_133. wasm-opt now keeps only version_N tags through the existing tagPrefix option. mops could never install the old tags anyway, since it builds the download URL from version_<N>. This also fixes --versions, which listed 99 above 131.

mops toolchain update stays within the pin's caret range

Picking the highest version made a second problem visible: mops toolchain update moved every pin to the overall latest, across major versions, so a project on moc 1.16.1 would jump to 2.x instead of getting the 1.x bugfix. It now follows mops update for packages and Cargo: it stays within the caret range of the pin (same major, or same minor for 0.x.y) and names any newer release out of range. The new --major flag crosses the bound, matching mops update --major.

Actual output in a scratch project pinned to moc = "1.16.0", lintoko = "0.11.0", and wasm-opt = "132":

$ mops toolchain update
Installed moc 1.16.1
moc 2.2.3 is available. To update to it, run mops toolchain update moc --major
lintoko 0.11.0 is already the latest compatible version
lintoko 0.12.0 is available. To update to it, run mops toolchain update lintoko --major
wasm-opt 132 is already the latest compatible version
wasm-opt 133 is available. To update to it, run mops toolchain update wasm-opt --major

$ mops toolchain update lintoko --major
Installed lintoko 0.12.0

Before this PR, the same command pinned moc 2.2.3, lintoko 0.12.0, and wasm-opt 133.

A pin that isn't a semantic version, such as Binaryen's 133, has no caret range, so it changes only with --major. A pin to a local file is always skipped, --major included, as mops update skips path dependencies. Before, update replaced it with the latest release.

What is unchanged

  • Users on older mops versions keep the publish-order behavior until they upgrade, so the 1.x bugfix releases should stay marked as pre-releases on GitHub for now.

🤖 Generated with Claude Code

…ublish

A bugfix on an older line, such as moc 1.16.2 published after 2.x, became
`latest` for `mops toolchain use <tool> latest`, `mops toolchain update`
and `mops toolchain info`. Pick the highest version instead, as Cargo does,
and list the picker rows in the same order.

Semver tags now outrank non-version tags, and wasm-opt keeps only Binaryen's
`version_N` tags, so the repo's old `1.38.x` tags can't win.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kamirus
Kamirus requested review from a team and automation-sa-sre as code owners November 17, 2026 14:36
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Cursor AI review

👍 APPROVE — looks safe to merge

Category Assessment Details
Summary ✅ latest / picker / --versions now pick the highest stable version instead of GitHub publish order, and mops toolchain update stays inside the pin's caret range (with --major to cross it), matching mops update.
Code Quality ✅ fetchReleasePage is shared; withExclusions is folded into filterReleases. latestCompatible uses semver.maxSatisfying rather than inventing a range parser. Package getHighestSemverBatch cannot be reused (GitHub tags, not the registry).
Consistency ✅ --major wording matches mops update in cli/cli.ts. Docs (04-mops-toolchain-update.md, use/info/overview), cli/CHANGELOG.md ## Next, and .agents/skills/mops-cli/SKILL.md all describe the new bound. update still runs on all pinned tools when no argument is given.
Security ✅ No identity/auth or lockfile changes. Traced use → getLatestReleaseTag, update → resolveUpdate/latestCompatible, and wasm-opt tagPrefix so 1.38.x cannot rank as latest; download URLs still use version_<N>.
Tests ✅ No snapshot hunks. Covering tests: release-tags.test.ts (order, unflagged prerelease, caret), toolchain-release-tags.test.ts (latest vs publish order), toolchain-binaryen-tags.test.ts (version_N only), toolchain-tag-prefix.test.ts. update() itself had no command tests at Base; new logic is tested at the helpers.
Maintainability ✅ Comments state the page-1 / caret invariants. publishedLatest renamed to latest at every call site (index.ts, wasm-opt.ts, tests).

Verdict

Decision: APPROVE
Risk: Low
Reason: Contained CLI toolchain-resolution fix with an explicit --major escape hatch, docs/changelog/skills in sync, and unit tests for the new order and caret rules. It does not touch registry, install, lockfile, or identity paths.


Generated for commit f77bd17

@automation-sa-sre automation-sa-sre left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval: the AI review verdict for 5e70ce2 is APPROVE. See the "Cursor AI review" comment for details.

…est version in help and docs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@automation-sa-sre automation-sa-sre left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval: the AI review verdict for ca144e2 is APPROVE. See the "Cursor AI review" comment for details.

Like `mops update` for packages, `mops toolchain update` now moves a pin
only within its caret range: same major, or same minor for 0.x. A project
on moc 1.16.1 gets the 1.x bugfix instead of 2.x. `--major` crosses the
bound, and the command names a newer out-of-range release when there is one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kamirus Kamirus changed the title fix(cli): toolchain latest is the highest version, not the newest publish fix(cli): toolchain latest is the highest version, update keeps the pinned major Nov 17, 2026
Kamirus and others added 2 commits November 17, 2026 16:04
…e fetch per tool

`--major` replaced a local-file pin with the latest release, which
`mops update --major` never does to path dependencies. `update` also fetched
the first releases page twice per tool. Fix docs and changelog that still
said `update` goes to the highest version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n every stable release

Also fix two doc spots that still tied `update` to the highest version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@caffeine-ci-ai-reviewer caffeine-ci-ai-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval: the AI review verdict for f77bd17 is APPROVE. See the "Cursor AI review" comment for details.

@Kamirus
Kamirus merged commit 0dc081c into main Nov 17, 2026
22 checks passed
@Kamirus
Kamirus deleted the kamil-claude/moc-v1-latest-release-63ee84 branch November 17, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants