Repository navigation
fix(cli): the cold spawn path pins the MCP spec to a published version, not @latest (TASK-174) - #1973
Merged
Merged
Conversation
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.
TASK-174 second half, taken through Vera's HOLD (74938–74940). Head
588d64bb, cli0.1.79, one bump as before. The cold spawn path still pins the declared spec to a published version instead of@latest; what changed is that the version it pins from can no longer be a string with a suffix in it.The HOLD, reproduced
parseVersionis anchored at the start only (/^(\d+)\.(\d+)\.(\d+)/), so it is a prefix test being used as a validator. Measured on the previous head:Vera's value, kept literal in the tests as a control. The version arrives from
~/.commonly/mcp/.registry.json, thecurrentpointer, ornpm view, and the previous head put it into an argv entry we execute (the npx spec) and into a directory name — where#1970'sstartsWith(pkgDir)confinement is computed from that dir, so it confined to the wrong place. Reachability is honest: it needs a writer to the operator's own home. But this is the commit that first carries such a value into an executed command, so it is the right moment.The fix: producers normalise, builders refuse
One constructor, in
mcp-server-version.js:Every place a version becomes a value:
resolveRegistryLatest(all three returns — cache, registry, stale-cache — and what it writes back to the cache),readCurrentVersion,readRegistryCache,pinShippedSpec. Every place a version becomes a name:versionDirFor, andpackageDirFornow routes through it, so the install destination, the temp prefix, the in-use marker, the pruner and the bin reader share one chokepoint.Where I departed from the proposed fix, and why. Building the spec and the path from the parsed triple is right for
pinShippedSpecand wrong forversionDirFor: that result is what the warm renames into, what the pruner removes, and whatreadBinPathreads, so silently rewriting0.3.14-rc.1→0.3.14aims all three at a different build that may be sitting on disk. Measured — the mutation that implements exactly that rebuild (M2 below) makesreadBinPath(home, '0.3.14-rc.1')return0.3.14's bin, and the new arm reddens. So the builder refuses instead: anything that is not exactly a triple lands on.unusable-version, a name no version can have, inside the home — every read misses and the spawn falls back to the declaration, which is already this module's fallback. Normalising stays at the producers, where the choice is deliberate and visible.Anchoring the regex was rejected for the reason Vera gave — a real
0.3.13-rc.1would fall back to@latest. The cost is disclosed and pinned by an arm: a prerelease pins as0.3.13, the stable release of its triple.(c): she was right, and it is now armed
Removing the
index !== 2bound passed all 112, becauseisShippedCommonlyMcpCommandalready requires a 3-argnpx -y <package>with the package in slot 2 — so the bound is not reachable today and is redundant as an argument. It is now an arm rather than an argument: the same unpinned spec string placed in slot 0 and in slot 2 gets opposite answers.The skip is named:
cli/__tests__/adapters.claude.environment.test.mjs:314,(onLinux ? test : test.skip)— thesandbox.mode=bwraparm, skipped on darwin because the binary is Linux-only. The 112 baseline is 59 + 30 + 23 across the three suites this touches.Evidence
8faa6e32— verified in a clean worktree of the base (same two names, 1 suite / 3 tests), not assumed.eslint src --ext .js): exit 0. Explicitly linting the touched.jsand.mjsfiles (the gate's--ext .jsdoes not cover.mjs): exit 0.exactVersionreturns the raw string (the HOLD itself)versionDirForrebuilds a prerelease onto its triple (the proposed shape)versionDirForjoins the raw string (pre-fix)pinShippedSpecputs the raw version in the argv specnewestInstalledVersioncounts a prefix match as a namereadRegistryCachehands the pin the raw cached stringreadCurrentVersionhands the pointer on rawreadCurrentkeeps the raw pointerM6 is defence in depth, not a gap: loosening the name filter alone still yields nothing, because
versionDirForrefuses the name — M6b shows both guards must be loosened, and the arm that reddens is the reader arm. Same shape as #1971's compound operator-pin mutation: a guarantee the ledger cannot kill with one edit is the shape of the guarantee. M11 is disclosed as a tripwire: the warm child'sreadCurrentonly feedsparseVersioncomparisons, so its consumers normalise again and no edit to that line changes an outcome; it is kept so a version is a triple wherever it is produced, and it is named here rather than dressed up as load-bearing.Residuals
~/.commonly/mcp/files — hardening, not an open door (the pointer path already carried such a value before this PR). Disclosed because closing the class is the point of doing it here.x.y.z-rc.1alone) instead of deleting it — safer than removing a dir it would have to reinterpret, and a behaviour change from the previous head, which counted it..registry.json/currentoutside this cli are not covered by this PR; the fix is the cli path.