Repository navigation
Stop attesting a Maven module whose own version range keeps the unpatched jar - #2393
Mikola Lysenko (mikolalysenko) wants to merge 6 commits into
Conversation
Refs #2378. Assisted-by: Claude Code
Maven reads the version a module declares for a dependency before any <dependencyManagement>, so a pin does not reach a module that declares the patched artifact with a version of its own. The reactor planner counted such a module as wired by the pin all the same. For a module that requires the base version as the hard range [1.0], vendor reported the patch applied, vendor --check verified it, and vex attested not_affected while the build kept the upstream jar. A range added under a pinned root after vendoring was attested the same way, in vendored and in hosted mode. One rule now, in the three places that asked: - covers: the version a module declares, or inherits, decides whether the patch is wired there; the nearest management decides only when no entry carries a version. vex then asks the selection what such a module resolves, as for a module no pin reaches. - A hard requirement on the base version is recorded as a declaration that may still build the base, as an unresolved property is: vex withholds the statement and vendor --check names the declaration. - under: a module that requires the base version itself has no say in where a pin goes. With nothing else to wire the plan names the suffixed version nowhere, and vendor refuses it (nothing_wired) as it already refuses the same range written in <dependencyManagement>. Hosted mode leaves such a reactor alone, as it does a single pom. A pin an earlier run wrote stays where it is. Refs #2378. Assisted-by: Claude Code
Five projects through vendor, vendor --check and vex: a module that requires the base version as [1.0] alone and beside a rewritten sibling, and a module added after vendoring that declares [1.0], the open range [1.0,2.0) or another version. Against main's binary the first case fails: vendor exits 0 where it must refuse. Refs #2378. Assisted-by: Claude Code
Review of the last two commits, checked against a real Maven 3.9.11: a module that declares the artifact with no version replaces the entry it would inherit, and reads the management. The helper walked past that entry to the parent's versioned one, so such a module was counted as unwired under a pin it does read, and as having no say in where a pin goes. It now stops at the nearest pom that declares the artifact at all. The same review found a pin nothing reads one step further: a module whose own <dependencyManagement> requires the base version as [1.0] overrides any pin above it, yet the root was pinned for it and vendor reported the patch applied. Such a module has no say either; with nothing else to wire the plan is refused, as it is when the root's own management carries that range. Refs #2378. Assisted-by: Claude Code
A second review found that the new reading of a module's own version asked the selection too much: a module that declares another plain version under an existing pin (1.11.0 beside a patch of 1.10.0) builds that version, and vex attested the patch before. With the reading of the last commits it asked what the module resolves, and withheld the statement wherever that cannot be read: no Maven local repository, a Maven 4 build, a project that is not on disk. Such a module is wired as the management says again, as on main. Only a version that may be the base is asked of the selection: a range, the base version itself, or one that cannot be read. Refs #2378. Assisted-by: Claude Code
A third review pass found no defect in the change, and two loose ends. A module that declares the suffixed version as a hard range by hand, [1.10.0-socket.<hex8>], builds the vendored jar; the new reading took it for a range that may be the base, where main counted the module wired by its pin. It is wired by its own declaration. The design note said vendor --check names "the declaration"; it names a <dependencies> entry. A requirement in a module's own <dependencyManagement> takes no pin, and vex withholds it by what the module resolves. Refs #2378. Assisted-by: Claude Code
|
bugbot run Generated by Claude Code |
PR SummaryMedium Risk Overview Core changes in Behavior: Reviewed by Cursor Bugbot for commit 24df7b5. Configure here. |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 24df7b5. Configure here.
|
[agent] PR shepherd: review brief for the approver What it does Risk: medium. It is one production file (+90 −31), but the planner is shared by vendored and hosted Maven. Look here
Verified
Changes I made: none. Open questions
Generated by Claude Code |
Three routine PRs are open, so this run verified the five leads left to verify. L113 is confirmed and filed as #2401. L114 was already #2337. L115 holds on main and is closed by #2393, whose body now carries the hosted rows. L116 and L117 are true and safe: out of charter. Assisted-by: Claude Code:claude-fable-5-2
LLM Description written by Claude Code
Fixes #2378.
Problem
Maven reads the version a module declares for a dependency before any
<dependencyManagement>. A pin therefore never reaches a module that declares the patched artifact with a version of its own. The reactor planner counted such a module as wired by the pin anyway. Who it hurts: anyone who ships the VEX document.[1.0]:vendorreportsapplied,vendor --checksays "verified", andvexattestsnot_affectedwhile the build keeps the upstream jar.[1.0]or an open range such as[1.0,2.0): same false statement.Evidence on
main(1b3f422)The built binary over the reactor fixture of
tests/vendor_jvm_cli.rs, then a real Maven 3.9.11 (dependency:build-classpath, offline) over the same directories.vendorvendor --checkvexadeclares[1.0]rangenotenot_affecteda:foo-1.0.jara[1.0],b1.0rangenotenot_affecteda:foo-1.0.jar,b: patched[1.0]rangenotenot_affectedfoo-1.0.jara1.0;b[1.0]added afternot_affectedb:foo-1.0.jarb[1.0,2.0)not_affectedb:foo-1.0.jarmainalready refuses the same requirement when it is written in<dependencyManagement>with a version-less dependency:The five new unit tests fail with
main's behavior at the three call sites, and the new CLI test fails againstmain's binary:Fix
One helper in core
vendor/jvm/maven_reactor.rs,own_versions: the versions a module declares itself, from the nearest pom on its chain that declares the artifact. Three places ask it:covers(whatvexasks, vendored and hosted): a declared range, the base version, or a version that cannot be read may be the base whatever the management says, so the selection is asked what the module resolves. A declared suffixed version wires the module; another plain version is wired as the management says, as before.rewrite_declarations: a<dependencies>entry that requires exactly the base version is recorded as a declaration that may still build the base, as an unresolved${property}already is.vendor --checkthen warnsvendor_jvm_unattestedandvexwithholds without reading a local repository.under(where pins go, both modes): a module that requires the base version itself has no say, since no pin reaches it. With nothing else to wire, no pom names the suffixed version, and the existing Vendored Maven reactor reports applied and VEX attests not_affected when a ${property} version is left unresolved, so the build keeps Central's unpatched jar (also triggered by Maven 4 <parent/> inference) #513 refusal applies.With this branch, same projects:
vendorvendor --checkvexa[1.0]nothing_wired(rangereason), nothing writtena[1.0],b1.0rangenotevendor_jvm_unattestednaminga/pom.xml:6[1.0]nothing_wiredb[1.0]added afterb/pom.xml:6b[1.0,2.0)added afterb/pom.xmlmay resolve it unpatched"Unchanged: a plain
1.0, a module that requires another version ([2.0]), and a range at first vendoring (already withheld).What was deleted
The old body of
covers, which accepted a pin for any module and any suffixed declaration anywhere on the chain.Behavior change
vexwithholds the statement for the shapes above, in vendored mode and for a hosted pin in a reactor.vendor --checkadds avendor_jvm_unattestedwarning for a hard requirement on the base. It still exits 0.vendor(andscan/get --mode vendored) exits 1 withnothing_wiredwhere it exited 0 over a pin nothing reads. That only happens when no module can be wired at all, and it is the refusalmainalready gives the same range in<dependencyManagement>.mainalready vendored that way keeps its pin: a re-run exits 0 and writes nothing, the check warns,vexwithholds, andvendor --revertrestores the poms (run with both binaries).rangewarning, as a single pom already is. A hosted re-scan can now add theselection_undeterminedwarning for an open-range module under an existing pin (read from the code, not run).Risk
The planner is shared by vendored and hosted Maven. Hosted mode was first run through unit tests only (the planner and VEX discovery). A later run of this routine (2026-12-01, 07:10Z) ran it end to end: the benchmark harness's hosted Maven project against its stand-in patch API, reshaped into each reactor below, with
main's binary (1b3f422) and this branch's (24df7b5).vexran with--no-verify, because the stand-in's packages are on no registry for a real Maven to install.vis the patched version)main: hostedscanmain:vexscanvexarequires[v]not_affectedredirect_unconfirmed), no pinarequires[v],bdeclaresvbrewritten, a pin in the rootnot_affectedbrewritten, no pina/pom.xml:11adeclares[3.0,4.0),bdeclaresvbrewrittenadeclaresv;badded after the scan with[v]arewrittenb/pom.xml:11bwith[3.0,4.0)arewritten[v]A tree
mainscanned into the first two rows keeps its root pin under this branch:vexwithholds, and a re-scan exits 0, writes nothing and still counts the package as patched ("1 package is already on hosted patches") beside therangewarning, asmaindoes. Not changed here.The real-Maven suites were not run here. This PR's CI ran
e2e_redirect_maven_buildande2e_vendor_maven_buildon Maven 3.9.16 and passed; the Maven version matrix ofe2e_vendor_jvm_build(3.6.3 to 4.0.0-rc-7, Windows) is not in a PR's scope. Nocfg(windows)orcfg(unix)code changed.Verified here on the final commit: CI's clippy command; core lib (8669 passed); the CLI suites
vendor_jvm_cli,cli,in_process_vendor,hosted_memory_engine; and on the commit before it alsomaven_sidecar_cli,in_process_scan,in_process_get_hosted_ecosystems.Review
CI passed on 24df7b5 (126 checks) and Cursor Bugbot found no issues. Three passes of
/code-review high. The first two each found a real defect in the new helper, both fixed and tested: a version-less entry replaces the one a module would inherit and does read the pin (checked against Maven 3.9.11), and a plain other version under a pin must stay wired when the selection cannot be read. The third found no defect. Left as they are:[1.0,1.0]is not read as[1.0]. That belongs in the shared range parser, which the selection also reads. The outcome is safe:vexwithholds and nothing is pinned.vendor --checkdoes not name a[1.0]that only an inheriting module's property produces, or one in a module's own<dependencyManagement>.vexwithholds both through the selection, which the check does not read by design.main: a declaration passed over for a reason of its own is not "selection alone".scan, which cannot clear a declared version. It says the same for the reasons it already carried.CLI_CONTRACT.mdlists the causes ofvendor_jvm_unattestedin two places and neither names a hard requirement. I left the file alone because two open agent PRs (#2390, #2392) change it; the phrase to add in both is "a hard requirement on the base version ([1.0])".docs/design/maven-vendoring.mdhas the rule.For a maintainer, from the issue:
[1.0]names one version, so it could instead be rewritten to[1.0-socket.<hex8>], which would patch the module. This PR does not need that answer.Diff
5 files, +561 −32: production +90 −31 (one file), tests +461, docs +10 −1.
https://claude.ai/code/session_011f9aeQdEz2ykd1n9rvemSh
Generated by Claude Code