Add find_parent_version tool for minimum upgrade-path lookup#13
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.
Summary
Adds a new
find_parent_versionMCP tool that answers a single hop of the "minimum upgrade path" question: given chainA -> B -> C -> Dand a targetD@x.y.z, what is the lowest version of C whose declared range for D includesx.y.z? Callers chain the tool to walk a full upgrade plan.The motivating use case is dependency systems that pin transitives via the lockfile (Deno, Go modules). In those ecosystems there is no
overrides/resolutionsescape hatch — updating a transitive D requires lifting every parent in the chain that brought it in. This tool computes the minimal lift one hop at a time, and downstream tooling owns the actual lockfile rewrite orinstallstep.What landed:
find_parent_versiontool (src/tools/find-parent-version.ts): input{ parent: {registry, name}, child: {registry, name}, childVersion, fromParentVersion?, includePrerelease? }. Walks parent versions ascending, returns the first one whose declared range coverschildVersion. Status field:found/none-compatible/child-never-declared/error. The algorithm itself is factored into a purescanForCompatibleParentVersionhelper so tests stay offline.getVersionDependencies(name, version)onRegistryClient. Implemented for npm (reads from the existing cached metadata response — zero extra HTTP calls) and JSR (calls the per-version/dependenciesendpoint, which already tags each dep withkind: "jsr"|"npm"). Both returnVersionDependency[]with{ name, registry, constraint, scope }. npm includes runtime, peer, and optional deps but skips dev — those don't ship.fetchWithRetryhelper insrc/utils/http.tsthat honors HTTP 429Retry-After(delta-seconds and HTTP-date forms) with exponential-backoff fallback, capped at 60s with 3 retries by default. Used only on the JSR per-version deps endpoint, since that is the only call site the scan loop can amplify — every other registry fetch in the codebase is one-shot and cached.parseRetryAfteris exported as a pure helper for testability.Supported registries: npm and JSR as parent. Child can live on either npm or JSR (since JSR packages can declare npm transitives).
Out of scope: multi-hop chain walks (callers chain the single-hop tool themselves), the actual lockfile rewrite or
installstep, and non-Deno/Go ecosystems where the question is moot becauseoverrides/resolutionsexists.Test plan
deno fmt --check && deno lint && deno check main.ts && deno test --allow-net --allow-read— all four CI gates pass (206 tests, 12 new).find_parent_versionwith a known JSR chain and confirm the result matches manual inspection of the dependency list on jsr.io.dependencies.foorange tightened in a known release) and confirm the minimum version reported matches the npm changelog.fromParentVersionto confirm it narrows the scan window and produces the expectedversionsConsideredcount.Retry-After.🤖 Generated with Claude Code