Skip to content

Patch Maven reactors and ${property} versions in hosted mode - #2114

Open
Mikola Lysenko (mikolalysenko) wants to merge 9 commits into
fix/maven-pin-follows-mediationfrom
fix/maven-hosted-reactors-and-properties
Open

Mikola Lysenko (mikolalysenko) wants to merge 9 commits into
fix/maven-pin-follows-mediationfrom
fix/maven-hosted-reactors-and-properties

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #2100 (base fix/maven-pin-follows-mediation). /code-review high ran once; its ten findings are answered below.

What was wrong

scan --mode hosted (the default mode) read only the root pom.xml. It refused a multi-module reactor whole (redirect_maven_multimodule_unsupported, exit 0, nothing patched) and refused any declaration whose version is a ${property} (redirect_maven_dep_unpinned). Vendored mode patches both. With the Maven extension ruled out, pom edits have to cover them.

What each shape does now

Hosted mode hands a reactor root, and a single pom with a ${property} version, to the reactor planner vendored mode uses (maven_reactor::plan_hosted), with the same selection model and the same placement. The invariant holds: every module resolves what it resolved before, except that a resolved base version with a patch becomes its patched build.

Shape Before Now
Reactor, module declares the base version refused that declaration is rewritten where it stands
Reactor, module reaches the base version through another artifact refused a <dependencyManagement> pin in the highest pom whose modules all select the base version (or do not resolve the artifact), down to that module's own pom
Reactor, module resolves another version refused not touched, resolves what it did
${property} only the patched artifact reads refused the property's value takes the patched version; declarations keep their text
${property} a sibling artifact reads too refused the one declaration takes the literal patched version, its text recorded beside it; property and sibling untouched
${property} a parent pom outside the checkout defines refused same as the shared case, when Maven is certain to select the base version for every module that reads the declaration; else left as is with the reason
Version-less declaration a parent or BOM manages pinned unchanged: the pin overrides the management, no declaration edited
Reactor one of whose poms cannot be read (missing, not a pom, not UTF-8, a symbolic link); same-GAV grant in a reactor refused still refused, redirect_maven_multimodule_unsupported with the reason, nothing written, exit 0
The only declaration sits inside <profiles> refused (reactor) nothing written, redirect_maven_profile_dependency_unpatched
Single pom whose property a parent pom of the checkout defines refused the property and the repository are written in that parent; list, vex, rollback read both poms

The <repository> goes in the local root each wired pom inherits from (a module whose parent is not in the checkout gets its own). It is an absolute URL, so it resolves the same from the root, from a module directory and with -f. The Trusted Checksums stay in the project root's .mvn/, which Maven finds by walking up from the pom it is started on. A module with a .mvn of its own is reported (redirect_maven_trusted_checksums_unenforced): a Maven started there reads that directory, so the checksum pin is not enforced for that build (the version suffix still is). Vendored mode refuses such a reactor; hosted mode has no path under the root to protect, so it does not.

The invariant, and how it is enforced

Once a plan is written, no pom names a -socket.<hex8> version unless the repository that serves it is declared in that pom's local root, its checksum lines are in place, and a declaration Maven always reads resolves to it, so discovery finds the patch and every pom that carries part of it. A rollback returns every pom the plan first wired to its bytes. When no pom names the version any more, its repository and checksum lines go too; an earlier patch's go only once no pom of the reactor names it.

It is enforced in one place, HostedReactor::plan. The planner plans declarations, properties, pins and the <repository> together over a reactor it read once, then checks the result: discovery's own reading (sites) must find the patch in every pom that names it, each such pom's local root must declare the repository, and the rollback's own restore (restore_pom, a pure function now), run over each pom about to be written, must give back the text the pom has. The plan is returned whole, or as a refusal that leaves every pom as it was read. The rewriter only writes what a plan returns and derives the checksum edits from it. rollback and remove read the reactor themselves and restore a pin in every pom that carries part of it, or in none.

reactor_wiring_keeps_the_invariant_through_its_life and single_pom_wiring_keeps_the_invariant_through_its_life run eleven fixtures through scan, re-scan, a superseding patch, pins taken out and rollback, asserting the invariant on the tree after every step with the real discovery and restore.

Restoring a ${property} version without a ledger (design question 1)

In the order asked for:

  1. The property's value. When the reactor's poms define the property once, at top level, as the base version, no profile, .mvn/maven.config or model reference defines the name too, and every ${name} in every pom of the reactor is the whole <version> of a declaration of the patched artifact, the value takes the suffixed version. Restore strips the suffix.
  2. No declaration. A version-less declaration is covered by the pin.
  3. The declaration, with its text recorded. Otherwise the declaration takes the literal suffixed version and a comment directly after the element records what it replaced: <version>1.10.0-socket.6f708192</version><!-- socket-patch:version ${fixture.version} -->. Restore puts the recorded text back and removes the comment.

Why restore is exact: no ledger records these edits, so each says what it replaced by its own text. The base version is the suffix's prefix; a pin is the entry vendored mode writes, with its <!-- socket-patch <uuid>: g:a:v --> comment, removed by its lines together with the section it created; a recorded declaration carries its comment. The planner runs the restore over every pom it would change before returning (see the invariant above), so no edit is written that the pom alone cannot undo byte for byte. A pin in a <dependencyManagement> that holds no entry is the one case handled pom by pom: that pom is left alone (redirect_maven_edit_not_reversible) and the rest of the plan stands.

VEX and restore (design questions 2 and 3)

  • Discovery reads a reactor whole, through the reader the rewriter and restore use, and a single pom together with the parent poms it inherits from inside the checkout. A pin's comment names its patch; any other suffixed version is tied to its socket-patch-<uuid> repository by the 8-hex suffix as before; a ${property} version is read through the properties of the declaring pom's chain. Every pom that carries part of the wiring is a file of the ref. A reactor one of whose poms cannot be read is read for the pins of the others (listed, never attested).
  • Attestation follows the vendored rule: no declaration may still build the base version, and every module that resolves it, or may, is reached by a pin or a declaration. Otherwise the statement is withheld and the module named (vex_maven_reactor_root). What Maven selects is read from the local Maven repository of the machine that runs vex.
  • Restore reads the reactor itself and walks every pom that carries part of the pin, whatever discovery listed: the planner's edits, the <repository> wherever it is declared, and the .mvn lines and files at the project root. A pom that still names the version and cannot be read refuses the pin with nothing changed. Removing the last hosted patch returns every file to its bytes and removes the files hosted mode created.

Pins written by 5.1.0

They carry no comment. In a single pom nothing changes: found, kept, rolled back and removed as before. When such a pom has since come to head a reactor, the pin is kept as it is (the patch counts as wired, no pin is added), vex weighs it module by module, and rollback restores its version. An entry 5.1.0 added to <dependencyManagement> is then left at the base version instead of removed, because in a reactor it cannot be told from the project's own management, and removing the project's own entry would break the build. A 5.1.0 pin that holds a module at a version Maven would not select is not detected (the model reads it as the project's management).

Reason codes

Added (all warnings[], exit 0):

  • redirect_maven_pin_would_move_module: a parent pom resolves the base version above a module that resolves another, so the parent takes no pin; also when a pin an earlier run wrote is taken out because a module it reaches now resolves another version.
  • redirect_maven_edit_not_reversible: a pom is left alone because an edit there could not be undone exactly.
  • Edit kind redirect_maven_property (a property's value rewritten). redirect_maven_dep_version now carries the ${...} text as original for a recorded declaration, redirect_maven_dep_management gains the actions rewritten and removed, and redirect_maven_repository gains removed (the last pin of the patch went).

Reused for a refused plan, same exit status: redirect_maven_profile_dependency_unpatched (the only declaration is inside <profiles>), redirect_maven_pom_unreadable (the pom that must declare the repository cannot take it).

Changed meaning, same code and exit status:

  • redirect_maven_multimodule_unsupported: no longer every reactor, only one that cannot be planned (a module pom missing or unreadable, a property or out-of-root <module> path, a same-GAV grant).
  • redirect_maven_dep_unpinned: no longer every ${property} version, only one whose value cannot be told.
  • redirect_maven_selection_undetermined: in a reactor it names the first module that cannot be told and counts the rest; the dep may be counted as redirected beside it.
  • vex_maven_reactor_root: no longer every pin in a reactor root, only a reactor with a module that may build the unpatched version (or that cannot be read).

Removed: none. No exit status changes on purpose. Natural outcome changes: a hosted scan of a reactor or of a ${property} version now reports applied and writes module poms (they appear in rewrittenFiles); vex now attests a hosted patch in a reactor when every module is wired.

Tests

  • Real Maven (3.9.16), the hosted suite's harness and fake registry, e2e_redirect_maven_build, each asserting the invariant on what Maven resolves (GAVs before == after with the suffix stripped, every other jar byte-identical):
    • maven_hosted_patches_a_reactor_module_by_module_and_rolls_back_clean: the V3 reactor, a module-directory build, vex attested then withheld naming b/pom.xml, rollback byte for byte.
    • maven_hosted_patches_a_property_version_and_rolls_back_clean: a property only the victim reads, one a sibling reads too, one a parent pom from the repository defines.
    • maven_hosted_leaves_a_declaration_only_a_profile_holds (finding 2), maven_hosted_patches_through_a_parent_pom_of_the_checkout (finding 3), maven_hosted_keeps_an_earlier_patch_served_while_a_module_names_it (finding 6).
  • Golden: seven redirect/maven/pom cases (listed for depscan below) pin the rewriter's output with no selection; the five that write files also round-trip through discovery and restore in maven_goldens_round_trip, and each side of each case has its entry in the discovery golden.
  • Unit: the planner (19 tests), the reader (2), the rewriter, the engine (a 200-module reactor; unreadable and linked module poms), discovery, restore, and the two lifecycle tests over eleven fixtures.

For depscan: golden fixtures that change on the next socket-patch bump

workspaces/app/src/patches/registry-rewrite/golden.test.ts reads crates/socket-patch-core/tests/fixtures/redirect/maven/pom/*. Seven cases there are new or changed and need a TS_LAGGING entry (or a port of the behaviour) when the submodule is bumped past this PR:

Fixture Change What it expects
property-version renamed from property-version-warn; output changed was: nothing written. Now the property's value becomes the suffixed version, pom.xml gets the <repository>, the two .mvn files are written, warnings []
property-shared-sibling new a sibling artifact reads the property: the declaration takes the literal plus <!-- socket-patch:version ${slf4j.version} -->, the property stays
property-external-parent-warn new, refusal no pom of the checkout defines the property: nothing written; redirect_maven_dep_unpinned, redirect_maven_selection_undetermined
profile-property-warn new, refusal only a profile declares the artifact: nothing written; redirect_maven_profile_dependency_unpatched
reactor-module-literal new, input has module poms app/pom.xml declaration rewritten, <repository> in the root pom.xml; redirect_maven_selection_undetermined
reactor-root-property new, input has a module pom the root's property rewritten, <repository> in the root; redirect_maven_selection_undetermined
parent-in-checkout new, input has build-parent/pom.xml property and <repository> both land in build-parent/pom.xml; pom.xml is unchanged

What the TypeScript harness has to cope with: inputs and expected/ trees with poms below the root, edits whose path is a module pom, the new edit kind redirect_maven_property, and expected-warnings.json on all seven ([] where nothing warns). The goldens run the rewriter with no Maven selection, as the backend does, which is why the reactor cases write no pin. The other nineteen maven/pom fixtures are unchanged.

What I ran

On macOS, head 7e1f39cd4: cargo fmt --check; cargo clippy --locked --workspace --all-features -- -D warnings clean; cargo test -p socket-patch-core --tests --no-fail-fast (every core target, 33 binaries: the lib and all integration tests, among them redirect_golden, upstream_restore_golden and the discovery golden) 8542 passed, 0 failed; the Maven-related CLI suites (17 binaries) 1194 passed; real Maven with --ignored: hosted 7 passed, vendored 5 passed, no skips. The first push ran only --lib of the core crate, which is how the stale maven/pom/property-version-warn golden reached CI.

Not run: Linux and Windows (CI), the rest of the CLI suites, Maven versions other than 3.9.16.

Review (/code-review high) and what was done

All ten findings were confirmed against the code.

  1. A reactor of more than 64 modules was refused, and reading was quadratic. Fixed: read_reactor walks the files itself. Each pom is fetched and parsed once; a pom's modules, parent and discovered subprojects are asked for together; a missing file stops nothing; there is no round cap. Tests: a_large_reactor_is_read_whole_and_each_file_once (221 poms, each path asked for once), a_reactor_of_hundreds_of_modules_is_read_and_planned_whole (200 modules through the engine).
  2. A profile-only declaration was rewritten with no repository. Fixed by the invariant: the plan is refused whole (redirect_maven_profile_dependency_unpatched). Tests: planner, rewriter, real Maven.
  3. Wiring written into a parent pom that discovery never read. Fixed: discovery reads a single pom with its parents in the checkout. Tests: discovery, a lifecycle fixture, real Maven.
  4. Restore of a root-only ref left a module pinned. Fixed: restore reads the reactor and restores every pom that carries the pin, or none; discovery reads what it can of an unreadable reactor instead of the root alone. Tests: a_pin_is_restored_in_every_pom_that_carries_it_or_in_none, a_reactor_with_a_missing_module_is_still_rolled_back_whole.
  5. A root that could not take the repository was skipped. Fixed: the repository is part of the plan; when it cannot be declared nothing is written (redirect_maven_pom_unreadable). I found no pom the two parsers read differently, so the planner test fails the repository step directly, and the rewriter test uses a <repositories/> a rollback could not put back.
  6. An earlier patch's repository was dropped while an unchanged pom named it. Fixed: every pom of the reactor is asked. Tests: planner, real Maven.
  7. A removed last pin left its repository and checksum lines. Fixed: both go with it. Left: the .mvn/maven.config resolver lines and the then empty checksums file, because a hosted rewrite cannot delete a file; they hold no line of a patch.
  8. The nested-.mvn warning disappeared on re-scan. Fixed: judged on the poms as they stand. Test: maven_reactor_nested_mvn_is_reported_on_every_scan.
  9. Two readers with different rules. Fixed: one reader (read_reactor) for the engine, discovery and restore, and one reactor question (heads_reactor_in).
  10. About 3·N·M parses per scan. Fixed: the rewriter reads the reactor once per run (HostedReactor) and a plan reparses only the poms it changes; discovery reads it once for all pins; no per-dep clone of the module poms.

Decisions for the owner

  1. A comment in the user's pom for a shared or externally defined property (<!-- socket-patch:version ${x} -->). It is the only new visible mark; it follows the socket-patch: comment family vendored mode already writes. Alternatives: skip those declarations with exit 0 and redirect_maven_dep_unpinned (they stay unpatched in hosted mode); or write ${x}-socket.<hex8> as the version, which needs no comment but breaks the build as soon as the property is bumped and cannot be attributed when the property is defined outside the checkout.
  2. A declaration replaced by a literal no longer follows its property until the next scan (vendored mode behaves the same). Bumping the property leaves the patched artifact behind.
  3. Hosted reactor pins carry the vendored pin comment. That is how a later run tells its pin from the project's own management (to take out a pin that would move a module, and to restore exactly). A single pom pinned without the planner keeps the 5.1.0 shape.
  4. A later scan adds a pin for a module nothing reaches yet. Vendored mode adds none after the first wiring. Without this, a first hosted scan over a cold local repository leaves a reactor half patched for good, and the remedy the warning names (resolve, scan again) would do nothing.
  5. In a reactor a classifier copy or a profile is reported and the main jar is still wired, with vex withholding (the vendored behaviour). In a single pom hosted mode still refuses the dep with nothing written.

Known gaps

  • Without a local Maven repository (the in-memory engine, a cold machine) only declarations are rewritten; pins need the selection.
  • A scan that takes out the last pin of a patch leaves the .mvn/maven.config resolver lines and an empty .mvn/checksums/checksums.sha256 (finding 7).
  • A reactor that can no longer be read, whose only wiring sits in a pom that cannot be parsed, shows no pin: nothing is removed, and nothing can be rolled back until the pom is repaired.
  • The single-pom check for a parent pom outside the checkout that declares the artifact with its own version (vex_maven_parent_declares) is not applied per module in a reactor.
  • A property's other readers are looked for in the reactor's poms only (not in filtered resources or poms outside the reactor).
  • Maven 4 reactors: declarations only (their selection is not modelled).
  • An existing self-closed <repositories/> is expanded in place, as before, which rollback does not collapse again.
  • Out of scope here: which coordinates Maven asks of the Socket repository, <mirrorOf>, running Maven to settle undetermined answers.

Generated by Claude Code

Hosted mode read only the root pom.xml. A multi-module reactor was
refused whole (`redirect_maven_multimodule_unsupported`), and so was a
declaration whose version is a `${property}`
(`redirect_maven_dep_unpinned`), so the default mode patched nothing in
either, where vendored mode patches both.

The pom rewriter now hands both to a hosted entry point of the reactor
planner vendored mode already uses (`maven_reactor::plan_hosted`), with
the same selection model and the same placement:

- a declaration that names the base version is rewritten where it
  stands, in whichever pom holds it;
- the `<dependencyManagement>` pin goes in the highest pom whose modules
  all select the base version or do not resolve the artifact, down to
  one module's own pom; a module that resolves another version is never
  reached, and a module a declaration already wires has no say;
- a `${property}` version only the patched artifact's declarations read
  has the property's value rewritten (the declarations keep their text,
  no sibling is stranded); any other one takes the literal suffixed
  version, with the text it replaced recorded in a comment right after
  the element (`<!-- socket-patch:version ${x} -->`); a property a
  parent outside the checkout defines is read from what Maven selects
  for the modules that read the declaration;
- the `<repository>` goes in each local root a wired pom inherits from,
  and the Trusted Checksums files stay at the project root.

Hosted mode keeps no ledger, so each edit says what it replaced by its
own text, and `unwire_hosted` reads it back. The planner unwires every
pom it would change before returning and leaves a pom alone when that
does not give the text it had, so no edit is written that could not be
taken back byte for byte (a pin in an empty `<dependencyManagement>` is
the case found; reported as `redirect_maven_edit_not_reversible`).

The engine reads every pom the planner reads by asking it until it asks
for nothing new, and confirms a planned dep from the planner's own
report: a pin in a module pom, a property or a recorded declaration is
no substring of the root pom.

The placement code is shared with vendored mode (`place_pins`, moved out
of `plan_with_selection` unchanged), `Reactor::under` can leave modules
out, and `rewrite_declarations` can be told what a version the checkout
does not define reads.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Discovery read only the root pom.xml, and restore only undid a pin
there: a pin in a module pom was invisible to `list`, `vex`, `rollback`
and `remove`, and a reactor root's pin was withheld from `vex` whatever
the modules did.

Discovery now reads a reactor whole (the poms the reactor planner
reads, asked until it asks for nothing new): a pin's comment names its
patch, any other suffixed version is tied to a `socket-patch-<uuid>`
repository by its 8-hex suffix as before, and a `${property}` version is
read through the properties of the declaring pom's chain. Every pom
that carries part of the wiring (the pin, a rewritten declaration, the
property, the repository) is a file of the ref. The patch is attested
by the rule vendored mode uses: no declaration may still build the base
version, and every module that resolves it, or may, is reached by a pin
or a declaration of the patch. What Maven selects is read from the
local Maven repository, on disk only. A reactor whose poms cannot all
be read falls back to its root pom, whose pin stays a ref and is not
attested, as before.

Restore undoes a pin in every pom discovery found it in, or in none: the
planner's edits through `unwire_hosted` (the tagged pin, the recorded
`${...}` version, the property), the `<repository>` in whichever pom
declares it, and the `.mvn` files at the project root. A suffixed
declaration in a reactor, or in a pom that carries one of the planner's
marks, is a rewritten one and gets its base version back; only a single
pom with no mark is read as an earlier release wrote it, where an added
`<dependencyManagement>` entry is told from a rewritten one by its
shape. A project's own management entry that happens to have that shape
is therefore no longer removed in a reactor.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Two capstones on the hosted suite's harness and fake registry, each
checking the invariant (the artifacts Maven resolves after the scan are
the ones it resolved before, the patched one in its patched build), that
a second scan writes nothing, and that `rollback` restores every file
byte for byte and leaves none behind:

- a reactor (the V3 shape): the module that reaches the base version
  through another artifact is pinned in its own pom, the module that
  declares it has the declaration rewritten, the module that resolves a
  newer version is untouched and resolves what it resolved before; a
  Maven started in a module directory resolves the patched jar too;
  `vex` attests the patch, and withholds it naming the module once a
  module declares the base version itself;
- a `${property}` version: a property only the patched artifact reads, a
  property a sibling artifact reads too, and a property a parent pom
  from the repository defines.

The fixture repository gains a sibling artifact at the victim's version
and a parent pom that defines a version property.

Docs: the CLI contract and the ecosystem guide describe hosted reactors
and property versions (where the pins, the repository and the Trusted
Checksums go, how a `${...}` version is wired and restored, what `vex`
attests, what happens to a pin an earlier release wrote), with the new
warning codes `redirect_maven_pin_would_move_module` and
`redirect_maven_edit_not_reversible`, the edit kind
`redirect_maven_property`, and the narrowed meaning of
`redirect_maven_multimodule_unsupported` and `vex_maven_reactor_root`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…t tell

A hosted scan over a cold local Maven repository rewrites the
declarations that name the base version and pins nothing where what
Maven selects cannot be told, saying so with the remedy: resolve the
project once and scan again. That second scan then found the patch
already wired and, by the rule vendored mode keeps (pins are placed when
a patch is first wired), added nothing, so the reactor stayed half
patched whatever was done.

A patch the poms already wire still keeps every pin where it is. A
module that no pin or declaration reaches and that is now certain to
select the base version is pinned all the same, by the usual placement
over the unreached modules only. A scan told nothing new still writes
nothing.

The pieces of `place_pins` this needs are split out (`keeps_placement`,
`undetermined_note`); vendored planning is unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Module poms were read as rewrite targets, so one that is a link out of
the repository, not UTF-8, or (in memory) linked or without content
refused the whole hosted run with exit 1, as an unreadable root pom
does. Before module poms were read at all, such a reactor was left alone
with exit 0.

They are now read as advisory input, and a module pom that is a
symbolic link is not read at all (the rewrite would replace the link
with a copy). The planner then finds the reactor incomplete and leaves
it as it is, `redirect_maven_multimodule_unsupported` with the reason,
exit 0. The guard on linked or unreadable rewrite targets is unchanged
and has nothing to refuse.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Restore told a reactor from a single pom by the root's model alone, so a
Maven 4 root that could discover subprojects but has none was read as a
reactor: an entry an earlier release added to its
`<dependencyManagement>` was put back at the base version instead of
removed. It now asks what discovery asks (the root lists modules, or
Maven 4 finds a subproject under it), so such a root is restored as the
single pom it is.

A test pins both readings: the added entry goes from a single pom, and
in a reactor a managed entry at the suffixed version keeps its place at
the base version, since there it cannot be told from the project's own.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Review of the hosted reactor work found six ways a scan or a rollback
could leave a pom naming a `-socket.<hex8>` version with nothing to
serve it, or wiring no rollback would find, and two ways a large reactor
was not read. They share one invariant, now enforced in one place.

The invariant: once a plan is written, no pom names the suffixed version
unless the repository that serves it is declared in that pom's local
root and a declaration Maven always reads resolves to it (so discovery
finds the patch, and every pom that carries part of it); a rollback
returns every pom the plan first wired to its bytes; when no pom names
the suffixed version any more its repository and checksum lines go too,
and an earlier patch's go only once no pom of the reactor names it.

`HostedReactor::plan` plans declarations, properties, pins and the
`<repository>` together, checks the result against that (running the
rollback's own restore over each pom it would write), and returns the
whole plan or a refusal that leaves every pom as it was:

- a declaration only a `<profile>` holds was rewritten with no
  repository and no way for a rollback to find it: now refused whole;
- a root the repository could not be added to was skipped while the
  modules below kept their pins: now refused whole;
- an earlier patch's repository and checksum lines were dropped by
  looking at the poms the plan changed, while an unchanged pom still
  named that patch: now every pom of the reactor is asked;
- a scan that took out the last pin left its repository and checksum
  lines, which no rollback could clear: they go with the pin;
- the warning for a module with a `.mvn` of its own was given only by
  the scan that wrote the pin: now by every scan.

Reading. The engine learned the reactor one module per round, parsing
every pom again each round, and stopped after 64 rounds, so a reactor of
more than 64 modules was refused. `read_reactor` walks the files itself:
each pom is fetched and parsed once, and a missing file stops nothing.
The engine, discovery and restore read through it, with one rule for
what is read (a module pom that is a symbolic link is not), so what one
plans over the others find. The rewriter reads the reactor once per run
and plans every patch over it; discovery reads it once for all pins.

Discovery reads a single pom together with the parent poms it inherits
from inside the checkout, where a property rewrite and the repository
may sit. A reactor one of whose poms cannot be read is read for the
pins of the others (found, never attested), where it fell back to the
root pom alone.

Restore reads the reactor itself and restores a pin in every pom that
carries part of it, whatever discovery listed, or in none: a pin found
through the root alone no longer leaves a module naming a version whose
repository the rollback just removed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Three more capstones on the hosted suite:

- a reactor whose only declaration of the version sits in a module's
  profile: the scan exits 0, says why, writes nothing, and the build
  with that profile resolves what it did;
- a single pom whose version is a property a parent pom of the checkout
  defines: the property and the repository are written in the parent,
  Maven resolves the patched jar, and a rollback restores both poms byte
  for byte;
- a newer patch superseding an earlier one while a module still reads
  the earlier version through a property a profile may redefine: the
  earlier patch keeps its repository and checksum lines, and Maven
  resolves each module from the repository of the patch its pom names.

The CLI contract and the ecosystem guide state the rule a hosted plan is
held to (written whole or not at all), what refuses a plan and under
which code, what a later scan removes with the last pin, how rollback
and remove read a reactor, and how a single pom is read with a parent
pom of the checkout.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 17, 2026 11:21
@cursor

cursor Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches Maven pom rewrite, rollback reversibility, and VEX attestation across multi-module graphs; mistakes could leave inconsistent wiring, though the plan is fail-closed and heavily tested.

Overview
Hosted scan --mode hosted no longer treats Maven multi-module reactors and ${property} versions as out of scope. Instead it drives the same reactor planner vendored mode already uses: every module pom is considered, pins and repository wiring are placed per-module (including ${property} handling via property rewrite, recorded declaration comments, or <dependencyManagement>), and plans are committed only when discovery and rollback invariants hold.

A new read_reactor path walks the full reactor graph once per run (modules, parents in the checkout, Maven 4 subprojects, nested .mvn), with symlinked module poms treated as unreadable. Hosted scan now always loads Maven selection metadata when a root pom.xml exists (the old “reactor root → skip selection” gate is removed).

Contract and UX updates: CLI_CONTRACT.md documents reactor/property behavior, new redirect_maven_* warnings (pin_would_move_module, edit_not_reversible, refined multimodule_unsupported / selection_undetermined), and vex_maven_reactor_root now means “a module may still build the unpatched jar” rather than “any pin in a reactor root.” VEX user-facing notes were adjusted accordingly.

Tests: large real-Maven e2e coverage for reactors, property-only/shared/parent cases, profile-only refusals, superseding patches, rollback; shared mediation fixtures extended.

Reviewed by Cursor Bugbot for commit 56ae4ee. Configure here.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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 56ae4ee. Configure here.

self.log_read(rel, true);
self.recognize_text(rel, &text);
Some(text)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Non-UTF-8 module poms look missing

High Severity

read_text_quiet, read_advisory, and restore's read_reactor callback all swallow read_text with .ok(), so a module or parent pom.xml that exists but is not UTF-8 looks missing. Hosted scan then refuses the reactor as incomplete (redirect_maven_multimodule_unsupported, exit 0) instead of candidate_file_unreadable. Discovery omits that pom from the pin's files, and rollback restores the readable poms (including dropping the <repository>) while the undecodable one still names the suffixed version.

Additional Locations (2)
Fix in Cursor Fix in Web

Triggered by learned rule: Non-UTF-8 candidates must refuse, never look absent

Reviewed by Cursor Bugbot for commit 56ae4ee. Configure here.

…en fixtures

The shared `redirect/maven/pom` golden still expected a `${property}`
version to be left alone (`property-version-warn`: no file, no edit), which
the hosted rewriter no longer does, so `redirect_golden_fixtures_match`
failed in CI. Only `--lib` and the CLI suites had been run before the push;
this time every core test target was.

Each expectation below was written from the behaviour the change intends,
then compared with what the rewriter does; none was regenerated unread.

- `property-version-warn` becomes `property-version`: a property that is
  defined once and read only by the patched artifact takes the suffixed
  version as its value, the pom gets the repository, and nothing warns.
- `property-shared-sibling` (new): a second artifact reads the property,
  so the property stays and the declaration takes the literal with the
  `<!-- socket-patch:version ${x} -->` comment that rollback reads.
- `property-external-parent-warn` (new): no pom of the checkout defines
  the property and nothing says what Maven selects, so nothing is written
  (`redirect_maven_dep_unpinned`, `redirect_maven_selection_undetermined`).
- `profile-property-warn` (new): only a profile declares the artifact, so
  the plan is refused whole (`redirect_maven_profile_dependency_unpatched`).
- `reactor-module-literal`, `reactor-root-property` (new): a reactor with
  no selection to read; the declaration or the root's property is
  rewritten, the repository goes in the root, no pin is placed, and the
  run says so (`redirect_maven_selection_undetermined`).
- `parent-in-checkout` (new): a single pom whose parent is in the checkout
  and holds the property; both edits land in the parent pom.

The five that write files also run through `maven_goldens_round_trip`
(discovery, then restore, byte for byte), and every side of every case has
its entry in the discovery golden, whose only other change is the renamed
key. The other nineteen `maven/pom` cases pass unchanged.

depscan reads the same fixtures (`golden.test.ts`); the PR description lists
the seven for its `TS_LAGGING`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: this PR needs an owner decision before it can go further, so I added agent:needs-human.

Why it is blocked

  1. It is stacked on Pin a Maven patch only where Maven selects its base version #2100 (fix/maven-pin-follows-mediation), which is itself waiting on the owner's answer to the missing-pom range question. This PR can't reach main before Pin a Maven patch only where Maven selects its base version #2100 does.
  2. The description's Decisions for the owner section has five product choices that need a yes or no. The one that matters most: is a new visible <!-- socket-patch:version ${x} --> comment in the user's pom acceptable for a shared or externally defined property, or should those declarations be skipped with redirect_maven_dep_unpinned (and stay unpatched in hosted mode)? Decisions 2–5 are listed there too: a literal that stops following its property, the pin comment on hosted reactor pins, later scans adding pins, and classifier/profile reporting in a reactor.
  3. One Bugbot thread is still open and looks real (vex/discover/mod.rs:2318): read_text_quiet, the engine's read_advisory and restore's read_reactor callback all turn a pom that exists but is not UTF-8 into "missing". The scan still refuses with nothing written, but under redirect_maven_multimodule_unsupported instead of candidate_file_unreadable, and rollback can restore the readable poms while leaving the undecodable one on the suffixed version. I haven't fixed it this run because how it gets fixed depends on decision 3 (how a pin is told apart on restore). It should be fixed before the final review.

State of the head 7e1f39c: no conflict with its base, ci-ok and clippy green.

Question for the owner: which of decisions 1–5 do you accept as written? Then the Bugbot finding above gets fixed and this PR gets its final review once #2100 lands.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant