Repository navigation
Pin a vendored Maven patch in the modules that select its version - #2101
Mikola Lysenko (mikolalysenko) merged 4 commits into
Conversation
A vendored pin was only ever written in a local root pom, which every module of the reactor inherits. Where the modules select different versions of one artifact, a root pin moved the ones that select another version (5.1.0), or no pin was written at all and a module that selects the base version only through other artifacts stayed unpatched (the previous commit). The pin now goes in the highest pom whose modules all select the patch's base version or do not resolve the artifact: the local root when every module that inherits it agrees, else the poms below it that do, down to one module's own pom.xml. A module that resolves another version is never reached by a pin, and patches for two versions of one artifact are each pinned in the modules that select them. A pin an earlier run wrote in a pom that would move a module is taken out and written where it belongs. A pom that manages the artifact itself takes no pin, and a module whose selection is not certain gets no new pin and keeps the one it has. The fallback repository stays in each local root. A literal <base>-socket.<hex8> of another patch of the same artifact is no longer reported as conflicting_literal_version when a second patch is planned, and the version_not_selected degraded reason is gone: a sibling that selects another version is not a degradation. Reactors whose modules agree and single-module projects are planned byte for byte as before. Refs #595, #882. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Brings in the determinism rule (pins stay where they were committed, on every machine), the suffix update of a held pin, the undetermined skip, the removal of a pin the build no longer selects, and the model fixes. With per-module placement the rule reads: a patch the poms already wire keeps every pin in every pom and gets no new one, unless a pin is certain to move a module, in which case the pins are placed afresh. The test for a plan one undetermined module holds back now uses a parent that resolves the artifact itself, since a sibling that selects the base version gets a pin of its own here. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Review fixes for the per-module placement of vendored Maven pins. - A pom was held (its pin kept) whenever any module under it could not be told, even when another module under it was certain to resolve another version. A pin that moves a module now goes whatever its siblings are; only a pom with doubt and no dissent is held, and a root a declaration rules out is never held. - vex attested a patch as soon as any pom wired it. A pin can sit in one module's pom, so the patch is now attested only when every module that resolves the base version (or may: its selection cannot be told) is reached by a pin, by the project's own management at the patched version, or by a declaration at it. `vendor --check` does not ask this. - A pin moved out of a pom carries the record of the section the first run created for it, so the revert takes the empty shell out again and restores the pom byte for byte. - A parent pom that resolves the base version itself above a module that resolves another cannot be pinned without moving that module, and Maven has no management that reaches a parent and not its children. It takes no pin and the plan says so (pin_would_move_module); when it is the only pom that selects the base version the patch is the vendor_maven_pin_would_move_module skip instead of nothing_wired. - A sibling that declares another version itself is no conflicting_literal_version once the selection says it resolves that version. - Undetermined modules are reported in one line, naming the first and counting the rest. - A root a declaration rules out no longer keeps the modules below it from their pins: it is descended like a root with a dissenting module. - A plan made without a selection keeps the pins the poms already hold, in whichever pom they are, instead of pulling them up into the roots. - Each module is asked for its selection once per plan and the answer marked up its chain. - Tests: one manifest staging helper, one table for the reactor fixture. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryMedium Risk Overview New selection semantics: VEX now withholds Maven attestations unless every module that resolves (or may resolve) the base version is actually wired ( Docs ( Reviewed by Cursor Bugbot for commit 104f968. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 104f968. Configure here.
| }); | ||
| if reactor.wired_before(patch) && !moves { | ||
| // (A local root a declaration ruled out stays ruled out.) | ||
| held.extend(reactor.scope.iter().filter(|rel| !closed(rel)).cloned()); |
There was a problem hiding this comment.
Freeze path drops committed root pins
High Severity
When a patch is already wired and no pin is certain to move a module, every pom except those in unpinned or managed_roots is held, place() never runs, and a pin on a closed pom is deleted. management_unresolved closes a root from this machine's local repository, so a re-vendor of a uniform reactor can drop the committed root pin on a cold checkout and then treat the patch as unwired, which breaks the invariant that the same poms plan the same on every machine.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 104f968. Configure here.
…-module Brings in the selection kept by the content of every read it was made from (a pom rewritten to the same length within one tick of the file system's clock was taken for the old one), which fixes the Linux failure of `a_version_the_build_does_not_select_is_skipped_before_any_download` on this branch. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
a8d8045
into
fix/maven-pin-follows-mediation
|
Folded into #2100: that PR's branch was fast-forwarded to this branch's head (a8d8045), so the per-module placement, its review fixes and the selection-cache fix now land together with full CI. Nothing here has reached main yet; review #2100 instead. 🤖 Generated with Claude Code |


Stacked on #2100 (review that one first; this branch holds its commits plus one).
What was wrong
A vendored pin was only ever written in a local root pom, which every module of the reactor inherits. In a reactor whose modules select different versions of one artifact that left two bad choices:
scan --mode vendoredadeclaresjackson-databind2.7.9.2, modulebgets 2.9.10 through another artifact#2100 stops the downgrade by not pinning a root one of whose modules selects another version. That is safe but leaves a module unpatched when it selects the base version only through other artifacts and a sibling selects something else (refused as
nothing_wired), and a patch for the sibling's version cannot be wired either.What changed
The pin now goes in the highest pom whose modules all select the patch's base version or do not resolve the artifact:
pom.xml.So a module that resolves another version is never reached by a pin, and patches for two versions of one artifact are each pinned in the modules that select them. A pin an earlier run wrote in a pom that would move a module is taken out and written where it belongs. A pom that manages the artifact itself takes no pin (its own entry is rewritten when it names the base version). A module whose selection is not certain gets no new pin and keeps the one it has. The fallback
<repository>stays in each local root. Revert,vendor --checkandrepairalready read pins from every pom of the reactor. VEX liveness did need a change (review finding 2, below).A literal
<base>-socket.<hex8>that belongs to another patch of the same artifact is no longer reported asconflicting_literal_versionwhen a second patch is planned: it is that other patch's wiring.The
version_not_selectedreason #2100 added tovendor_jvm_degradedis gone again: there is nothing degraded about a sibling that selects another version.Outcomes that change
nothing_wiredin Pin a Maven patch only where Maven selects its base version #2100 becomes exit 0 with the pin in the modules that select the base version.vendor_jvm_degradedreasonpin_would_move_modulenaming both. When that parent is the only pom that selects the base version: the new benign skipvendor_maven_pin_would_move_module, exit 0, nothing written (it wasnothing_wired, exit 1).nothing_wired, exit 1, unless an unrelated module happened to select another version).conflicting_literal_versionwhen the selection says it resolves that version.selection_undeterminedis one event per plan, naming the first module and counting the rest.vex, lose the attestation, with the module named.vendor --checkis unchanged.Tests
vendor::jvm::maven_reactor): a root pinned when all agree; the pin in the module when a sibling selects another version, with its byte-exact revert; the pin in a shared intermediate parent; patches for two versions each pinned where they are selected and neither plan undoing the other; a misplaced root pin moved to its module; an undetermined module held.maven_vendored_reactor_pins_each_module_at_the_version_it_selectsine2e_vendor_maven_build(already in thee2eleg). A parent with three modules:areaches the base version two levels down,ba newer version through another artifact,cdeclares the base version itself. Maven resolves each module before and after. After the first patch a and c resolve the patched jar and b resolves the same bytes as before; after a second patch for b's version, b resolves its patched jar too. Then a no-op third run,vendor --check, and a revert that restores every pom.What I ran
Locally on macOS (arm64), Maven 3.9.16, JDK 26; every cargo command through the machine-wide lock with
CARGO_INCREMENTAL=0 CARGO_PROFILE_DEV_DEBUG=0 CARGO_PROFILE_TEST_DEBUG=0 -j4. With every code change of this head (104f968b0) in place:cargo fmt --all;cargo clippy --locked --workspace --all-features -- -D warnings: clean.cargo test -p socket-patch-core --lib: 7809 passed, 0 failed.cargo test -p socket-patch-cli --no-fail-fast --test vendor_jvm_cli --test contract_gradle_codes --test maven_sidecar_cli --test in_process_scan --test in_process_get_hosted_ecosystems --test in_process_remote_ecosystems_apply --test in_process_rollback_all_ecosystems --test e2e_maven --test scan --test rollback --test vendor --test in_process_vendor --test e2e_vex_vendor --test e2e_vex_redirect --test e2e_vex_lockfile --test cli_scan_silent --test ecosystem_dispatch_e2e: all passed.That run failed one new real-Maven test, on the test's own setup (the local repository did not yet hold the pom that makes module
b's new selection certain). After that test-only fix, on the committed head:cargo test -p socket-patch-cli --no-fail-fast --test e2e_redirect_maven_build --test e2e_vendor_maven_build --test contract_gradle_codes --test vendor_jvm_cli -- --include-ignored(real Maven): 2, 7, 1 and 32 passed.Not run: the whole workspace test suite, the docker suites, Windows and Linux, and Maven lines other than 3.9.16.
After the review of #2100
This branch merges #2100's review fixes (no rebase, nothing force-pushed). What they mean here:
vendor --checktakes the committed pins as they are. The placement above is what a first vendoring writes.a_pin_that_moves_a_module_goes_to_the_module_it_belongs_in).a_plan_held_back_by_one_undetermined_module_is_a_skip).Review of this PR (
/code-review high) and what was doneAll ten findings were confirmed against the code; all are fixed here.
a_pin_that_moves_a_module_is_not_held_for_an_undetermined_sibling, and the real-Mavenmaven_vendored_parent_pin_goes_when_a_module_moves_on_and_reverts_clean(Maven buildsbon the forced version before the run and on its own version after, whileacannot be told).unwired_modulesasks, per reactor module, whether the patch reaches it (a pin or the project's own management at the patched version on its chain, or a declaration at it); an unreached module that resolves the base version, or whose selection cannot be told, withholds the attestation and is named. This reads the local repository, sovexcan answer differently on a machine that never resolved the project (it withholds there);vendor --checkdeliberately does not ask. Not exempted: a pom-packaged parent that resolves the base version itself (finding 4) also withholds. Test:a_module_left_without_the_patch_withholds_attestation.vendor_maven_pin_would_move_modulewith nothing written. A parent pom ispom-packaged, so the modules that build artifacts are still each pinned. Test:a_parent_above_a_module_on_another_version_is_reported_not_pinned. Owner decision: whether to add the shielding entry.conflicting_literal_version: fixed. Test:a_sibling_declaring_another_version_is_no_conflict_under_a_selection.undetermined_modules_are_reported_in_one_line.a_closed_root_does_not_keep_its_modules_from_their_pins.a_plan_without_a_selection_keeps_module_pins_where_they_are.Reactor::under); placement and the "does a pin move a module" test read those flags.stageisstage_allfor one patch, the purl comes from the fixture, and the reactor fixture has one table.Two of these also exist in #2100 on its own (a root pin the planner removes leaves its section behind on revert; a declaration-only wiring can be attested while a sibling is unpatched). I fixed them here only, since the stack lands together and #2100's CI was running.
After CI: the Linux failure of
a_version_the_build_does_not_select_is_skipped_before_any_downloadwas #2100's kept selection, checked by length and modification time instead of content; fixed there in cf3353c (see its review notes) and merged here as a8d8045.Known gaps
${property}versions (the third PR of the stack; not started).Refs #595, #882.
🤖 Generated with Claude Code