Skip to content

Ask a hosted Maven repository only for the version it serves - #2133

Draft
Mikola Lysenko (mikolalysenko) wants to merge 33 commits into
mainfrom
fix/maven-hosted-repo-scoping
Draft

Mikola Lysenko (mikolalysenko) wants to merge 33 commits into
mainfrom
fix/maven-hosted-repo-scoping

Conversation

@mikolalysenko

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

Copy link
Copy Markdown
Collaborator

Based on main (#2114, #2145 and #2135 are merged and merged in here). Draft: two decisions are with the owner, see "Review findings not fixed".

What was wrong

A <repository> a pom declares is asked, in declaration order and before Maven Central, for every artifact and parent pom the local repository does not hold yet. Hosted mode adds one per patch (socket-patch-<uuid>), inserted first. So on a cold local repository every dependency of the build was requested from each Socket repository: K patches and D uncached artifacts cost K×D round trips that end in a 404, the project's whole dependency list (private coordinates included) reaches the patch server, and a slow or unreachable patch server delays artifacts it never serves. Gradle hosted mode has exclusiveContent; Maven hosted mode had nothing.

What changes

With each pin that lands, scan --mode hosted now also writes, for Maven Resolver's prefixes repository filter:

  • .mvn/socket-patch/prefixes-socket-patch-<uuid>.txt, one per patch, named for its repository id. It lists the one path that repository serves, /<group/path>/<artifact>/<version>-socket.<hex8>, under the header Maven 4 requires (## repository-prefixes/2.0).
  • two lines appended to .mvn/maven.config: -Daether.remoteRepositoryFilter.prefixes=true and -Daether.remoteRepositoryFilter.prefixes.basedir=${maven.multiModuleProjectDirectory}/.mvn/socket-patch.

The filter abstains for a repository that has no file in its directory, so only the Socket repositories are filtered.

The filter is an extra. It never keeps a pin from landing and never refuses a run. Where it cannot be had, the pin lands without it, the Socket repository stays unfiltered as before, and the run says so.

The directory line follows the rule of the checksums line

The basedir line has to name the checkout through a property, and no property is right on every Maven (#2145 measured this for the Trusted Checksums directory): ${session.rootDirectory} stops Maven 3.9.2 to 3.9.8 from starting with -f from outside the project, and Maven 4 does not interpolate ${maven.multiModuleProjectDirectory}. The line takes the property from the helper #2145 added, RootDirectory::for_maven, so both directories of a project are named one way: the launcher's property, unless the project declares Maven 4 (a wrapper that pins it, or a root pom of model 4.1.0).

  • The heal. A directory line in the other spelling is respelled in place by every hosted scan that reads the file, whatever the run redirects, and by a rollback / remove that leaves the lines. Edit redirect_maven_config, rewritten, key: "repositoryFilterDirectory". One function heals both groups of lines for the scan and the restore (heal_maven_config).
  • What the heal trades away is said. redirect_maven_repository_filter_maven3_only (maven_repository_filter_maven3_only on a rollback), once, with the remedy.
  • What the declared Maven makes of the filter is said. redirect_maven_repository_filter_unread, judged by the rule the checksums pin is judged by (RootDirectory::read_by), with this filter's own first release, 3.9.2.
  • The conflict check. With the switch on, either spelling of hosted mode's own directory line is in place.

What I measured (real Maven)

Measured for this PR's first version, with the directory named through ${session.rootDirectory}, against a logging server standing in for the Socket repository: a single pom with three dependencies, one of them patched, plus a second repository of the user's (user-extra). Requests the Socket repository received on a cold local repository:

Maven Before After
3.9.16, fully cold 25 (4 for the patched version, 21 for artifacts it does not serve) 4
3.9.2, 3.9.3, 3.9.4, 3.9.16 (plugins cached) 18 (14 not the patched version) 4: the jar, the pom and their .sha1
4.0.0-rc-7 19 (one more: Maven 4 asks every repository for .meta/prefixes.txt) 4
3.6.3, 3.8.9 18 18: the properties mean nothing to them
3.9.0, 3.9.1 18 18: the directory is not interpolated, the file is never found
  • user-extra received the same requests before and after on every version (14; 15 on Maven 4): no other repository is filtered.
  • A prefix file that does not list the pinned version, or lists nothing, fails the build on every Maven that reads it (Prefix … NOT allowed from socket-patch-…).
  • Maven 4 discards a file without the header (Rejected user-provided prefixes … No expected magic in file) and then asks the repository for everything; Maven 3.9 reads the header as a comment.
  • Behind a mirror the repository takes the mirror's id, under which no file exists: nothing is filtered there.

Measured with the spelling this PR now writes, by the real-Maven suite (it asserts the exact set of paths the Socket repository receives, for a single pom and for a reactor):

  • Maven 3.9.2, 3.9.3, 3.9.4, 3.9.8 and 3.9.16: the Socket repository receives the patched version's jar, pom and their .sha1 and nothing else, from the project root and with -f <project>/pom.xml from outside the project.
  • Maven 4.0.0-rc-7, in a project that does not declare it: the build passes and the repository is asked for more. Once the project's Maven Wrapper pins 4.0.0-rc-7 the next scan respells the line, and the repository then receives those four requests only.
  • Maven 3.6.3, 3.8.9 and 3.9.0: the build passes, unfiltered.
  • Without the root-directory rule (the session's spelling put back, on Maven 3.9.4): the capstone's -f step fails with Illegal use of undefined property: session.rootDirectory.

Measured for the environment check, on Maven 3.9.9 and 4.0.0-rc-7: -Daether.remoteRepositoryFilter.prefixes=true with a basedir, set in MAVEN_OPTS, MAVEN_ARGS, JAVA_TOOL_OPTIONS or JDK_JAVA_OPTIONS, is honoured in each case (the build is refused by the prefix file in that directory).

The one side effect

The filter reads one directory per build, not one per repository. The two lines move that directory into the checkout, for every repository. A build that switches the prefixes filter on from outside the checkout and keeps its own prefix files in the local repository's default directory stops reading them once the two lines are committed. Measured on 3.9.16: such a user's repository went from 0 requests (their file) to 14 (their file no longer read). It un-restricts their repository, it never restricts one. No mechanism in Resolver 1.9 or 2.0 gives a single repository its own directory.

What limits it today:

  • a checkout whose .mvn/maven.config (any spelling some Maven reads) or .mvn/jvm.config already configures the filter is left alone, and so is a project scanned on a machine whose environment configures it (MAVEN_OPTS, MAVEN_ARGS, JAVA_TOOL_OPTIONS, JDK_JAVA_OPTIONS): nothing is written for the filter, the pin lands, and the run warns redirect_maven_repository_filter_conflict once per patch, naming what configures it and the path to list in their own directory;
  • the run that adds the two lines says so, once: redirect_maven_repository_filter_enabled, "every build of this project reads prefix files from .mvn/socket-patch only", with what to do about a file kept elsewhere;
  • a -Daether.remoteRepositoryFilter.prefixes.basedir=… on the command line wins over maven.config;
  • it is documented in docs/ecosystems.md and CLI_CONTRACT.md.

What it cannot see: a flag a CI job passes, or the environment of another machine. Whether the filter should be on by default at all is with the owner (finding 1 below).

Rules

  • Written with the pin, only when the pin lands. A pin an earlier run wrote is left as it is, like its Trusted Checksums, so a re-run stays edit-free. (Whether a project an earlier release wired should get the filter on a re-scan is with the owner: finding 7 below.)
  • Read for what it lists. A filter file that is there with the header and the pinned path is left as it is, whatever its line endings and whatever comment or other path someone added. One that does not list the path is rewritten with the pin.
  • Suffixed versions only. A same-GAV grant gets no file.
  • Never emptied. When a scan takes a Socket repository out of the poms (a newer patch of the same version, or the last pin gone), that repository's file is left exactly as it is: no pom names its repository, so Maven does not read it, and it is the right file if the wiring comes back by a pom-only revert or a merge. A retired file stays until rollback or remove deletes it.
  • The lines go with the last repository. A scan that takes out the last Socket repository with a filter file takes the two lines out of .mvn/maven.config. It leaves them while a pom names another such repository, while the directory holds anything that is not hosted mode's own file (a prefix file of the user's is read through those lines), where the directory could not be listed, and where the config cannot take the write: the rule a rollback follows.
  • Skipped where it cannot be written. A .mvn/maven.config that is a symbolic link or sits in a directory that does not take the write, and does not hold the two lines yet: neither lines nor file, redirect_maven_repository_filter_skipped once per run, the pin lands. A link or a directory under the name of a pin's filter file: no file there, said for that patch. Both used to refuse the whole hosted run.
  • Rollback and remove delete the file of each restored pin and every such file whose repository no pom declares. Once the directory holds nothing they take the two lines out of .mvn/maven.config byte for byte, in either spelling of the directory. A config they cannot write keeps the lines and a directory they cannot list is left whole; the pins are restored all the same and maven_repository_filter_left says what to remove by hand.
  • Behind a mirror (Do not wire a hosted Maven pin behind a mirror that would take its repository #2135): a dependency the mirror gate holds back gets no filter file and no filter line, like no pin.

Reason codes and edit kinds

New warnings, all warnings[], exit 0, the dep still counted as redirected:

Code When
redirect_maven_repository_filter_enabled the run added the two lines; once
redirect_maven_repository_filter_conflict the filter is configured already (maven.config, jvm.config, the scanning machine's environment); once per patch
redirect_maven_repository_filter_skipped the filter could not be written (config, or the file's own path); the pin landed
redirect_maven_repository_filter_unread the declared Maven does not read the filter
redirect_maven_repository_filter_maven3_only / maven_repository_filter_maven3_only a heal took the filter from a Maven 4 build of a project that declares no Maven
maven_repository_filter_left rollback / remove left the lines or the directory, and why
  • New edit kind redirect_maven_repository_filter (added, rewritten; key the repository id, new the path). A scan no longer reports removed for a filter file: it removes and empties none.
  • redirect_maven_config gains the keys repositoryFilter (the two lines go in or come out) and repositoryFilterDirectory (the directory line is respelled).
  • New engine input for the rewriter, <socket-patch:maven-filter> (MavenFilterAround): whether the filter directory holds anything else, which environment variable configures the filter, whether the config can take a write, and which filter paths are occupied by a link or a directory. Absent in the common case. The rewriter's other implementation, in Socket's backend, has no machine and can leave it out.

No exit status changes. Natural outcome changes: a hosted Maven scan that wires a pin lists one more written file per patch and, the first time, one more warning (…_enabled); a project whose Maven Wrapper pins a Maven older than 3.9.2 gets …_unread.

Golden fixtures that change

The cases under crates/socket-patch-core/tests/fixtures/redirect/maven/pom/ are a contract shared with the rewriter's other implementation, in Socket's backend. Every case that wires a pin changes, so that implementation needs a matching change when it next updates this repository:

Expected output changed (22). In each, expected/.mvn/maven.config gains the two lines, expected/.mvn/socket-patch/prefixes-socket-patch-77777777-7777-7777-7777-777777777777.txt is new, and expected-edits.json gains two entries after the trustedChecksums one. The directory line is the launcher's in the first twenty and the session's in the last two, whose projects declare Maven 4:
basic, classifier-only-transitive-main, classifier-sources-sibling, comment-dependency, commented-repositories, depmgmt-comment, existing-depmgmt, existing-repositories, mvn-config-merge, parent-in-checkout, plugin-dependency, profile-depmgmt, profile-repositories, property-shared-sibling, property-version, reactor-module-literal, reactor-root-property, self-closed-depmgmt, self-closed-repositories, transitive-depmgmt; maven4-model, maven4-launcher-line-conflict.

Expected warnings changed (17 of those). The cases that pin a warning list gain redirect_maven_repository_filter_enabled: classifier-only-transitive-main, classifier-sources-sibling, comment-dependency, commented-repositories, depmgmt-comment, maven4-launcher-line-conflict, maven4-model, parent-in-checkout, plugin-dependency, profile-depmgmt, profile-repositories, property-shared-sibling, property-version, reactor-module-literal, reactor-root-property, self-closed-depmgmt, self-closed-repositories.

New (1). repository-filter-conflict: the input's .mvn/maven.config configures the prefix filter itself; the pin lands, no filter line or file is written, warning redirect_maven_repository_filter_conflict.

Unchanged (8). heals-basedir-without-a-patch, no-suffix-fallback, profile-literal, profile-property-warn, property-external-parent-warn, rerun-heals-basedir, rerun-noop, version-mismatch-skip.

Outside that directory: tests/fixtures/sbt/redirect/pom-also-present changes the same way (its pom is wired too, warning included), and vex-discover-golden/redirect-maven.json gains the two entries of the new case; no existing discovery entry changed.

Tests

  • Real Maven, e2e_redirect_maven_build:
    • maven_hosted_asks_the_socket_repository_only_for_the_patched_version, a single pom and a reactor on a local repository that holds none of the project's artifacts: the exact set the Socket repository receives, from the project root and with -f from outside; Maven 4 before and after the project declares it; every Maven asks for more once the file is removed; a rollback restores every file byte for byte.
    • maven_hosted_lands_the_pin_where_the_config_is_a_link: the scan exits 0, lands the pin, writes nothing through the link and no filter file, says …_skipped; Maven resolves the patched jar; a re-scan writes nothing; a rollback restores every file.
    • The capstone runs its -f step against a config that holds the filter's lines too.
  • Unit, the filter module: the file and config-line grammar in both spellings and its byte-exact inverse, the heal, the judgement for the declared Maven, a file read for what it lists (CRLF, comments, a missing header, another version).
  • Unit, the rewriter: the spelling for each wrapper and model; the heal in each direction; the scope one repository at a time (a retired file is not touched; one written and retired within a run leaves nothing behind); the lines stay while the directory holds anything else; the pin lands without the filter where the config cannot be written, and the lines are not taken out of such a config; the environment as a conflict; the line said when the lines are added, once.
  • Unit, the directory listing: hosted mode's own regular files only, on disk and in memory; a link or a directory under a hosted name; a directory that cannot be read.
  • Engine: the_maven_filter_never_keeps_a_pin_from_landing (a linked config, the environment, a link where the pin's file would go: the pin lands and the guard refuses nothing); a run with nothing to redirect heals the filter's line.
  • Restore: the lines go in either spelling; a linked config keeps them and refuses no restore; an unlistable directory is left and said so; the user's own switch survives.
  • CLI: scan_hosted_with_nothing_to_redirect_heals_the_maven_filter_line, and the capped run that writes nothing but the heal.

What I ran

On macOS, head 17393a768:

  • cargo fmt --all -- --check: clean.
  • cargo clippy --locked --workspace --all-features -- -D warnings: clean.
  • cargo test -p socket-patch-core --tests --no-fail-fast: 8781 passed, 0 failed, 1 ignored (the discovery golden regenerated first, with no change).
  • The 18 Maven-related CLI suites: 1304 passed, 0 failed.
  • The harness's own suites (common_selftests, spawn_env_hygiene, and the tests of e2e_bazel_build that need no Bazel): all pass.
  • e2e_redirect_maven_build with real Maven, required and not skipped (the capstone and nine mediation tests): 10 passed on each of 3.6.3, 3.9.4, 3.9.16 and 4.0.0-rc-7.
  • The three Maven production legs with real Maven 3.9.16, strict and required, as CI runs them: all pass.

On the previous head (c14138f0e), not repeated: the same suite on 3.8.9, 3.9.0, 3.9.2, 3.9.3 and 3.9.8 (9 passed on each), and the two real-Maven tests failing on 3.9.4 with the session's spelling put back.

Not run: Linux and Windows (CI), the rest of the CLI suites.

Review findings, round 2

/code-review high on c14138f0e returned ten. Each was confirmed against the code first.

# Finding Outcome Test that fails without it
1 The appended basedir line overrides a prefix filter a team configured outside the checkout Not fixed, the owner's decision: see below. Done meanwhile: the scanning machine's environment is a conflict, and the run that adds the lines says what they change maven_filter_is_left_to_the_environment_that_configures_it, maven_scan_says_when_it_moves_the_filter_directory, the engine test
2 A scan that retires the last filter file strips the two lines even when the user keeps their own prefix files in the directory Fixed: the rule a rollback follows; the engine tells the rewriter what else the directory holds maven_filter_lines_stay_while_the_directory_holds_anything_else
3 A retired file was emptied, which fails the build if the repository's wiring comes back before the next scan Fixed: a retired file is left exactly as it is; the "repair an emptied file" path is gone with the emptying maven_scope_retires_a_file_without_touching_it, maven_reactor_last_pin_removed_takes_the_repository_and_checksums, the lifecycle invariant
4 put and repair compared the file byte for byte, so a CRLF checkout or a comment made every re-scan report a rewrite Fixed: read for what it lists maven_filter_file_is_judged_by_what_it_lists, a_file_lists_a_path_whatever_its_line_endings_and_comments
5 The filter's two lines were a mandatory write, so a linked .mvn/maven.config refused the whole hosted scan where main landed the pin Fixed: the filter is skipped, the pin lands, the run warns maven_pin_lands_without_the_filter_where_the_config_cannot_be_written, the engine test, the real-Maven test
6 On restore the stripped config was staged unconditionally, so a linked or since-edited config restored nothing Fixed: staged only where the flush could write it; otherwise the lines stay and are reported a_linked_config_keeps_the_filter_lines_and_refuses_no_restore
7 A pin already in place never gets the filter Not fixed, the owner's decision: see below
8 The engine listed the filter directory by name only; none_left was a third copy of the "is it ours" test Fixed: one listing (hosted_maven_filter_dir) for the engine, the restore and the eject, one name test (owned_rel) for map keys; and a link or directory under a hosted name is never written through the_filter_directory_lists_only_hosted_modes_own_regular_files, the engine test
9 An I/O error while listing was taken for the end of the directory Fixed: the directory is then unlistable, nothing in it is deleted, the lines stay, and the restore says so an_unlistable_filter_directory_is_left_and_said_so, the listing test
10 retire set retired before the "written and retired within this run" return Fixed with the rewrite of retire maven_scope_retires_a_file_without_touching_it

Review findings, round 1

/code-review high on this PR's first version returned ten, all fixed then; the ones later work changed:

  • "A retired (emptied) file is never repaired" was fixed by repairing it. Round 2 finding 3 removes the emptying, and the repair with it.
  • "A scan that takes out the last pin leaves the two lines and the emptied file for ever": the lines still go with the last repository; the file now stays as it was, see below.

The others stand: the user's own prefixes=true is never taken on a rollback; the conflict is said once per patch and names its path; "still declared" is asked of every pom the reactor read; the vendored eject snapshot takes hosted mode's own regular files only; one way to append lines to the config; one post-plan block.

Review findings not fixed

  • Round 2, finding 1: whether the filter is on by default. The basedir line moves where Maven reads every prefix file from, so a team that configures the filter outside the checkout (a CI flag, another machine's environment) loses its own restrictions, and a scan cannot see that. Opt-in, opt-out or as it is now is the owner's call and is with him. Not changed here beyond the environment check and the …_enabled line.
  • Round 2, finding 7: projects an earlier release wired get no filter on a re-scan. Writing it for pins already in place reaches every such project on its next scan with a diff nobody asked for. The owner's call, with him. Not changed here.
  • A delete operation for the hosted rewrite pipeline (round 1). A rewrite result is a map of files to write; a deletion would have to pass through the rewriter's result type, the engine's guards and confirmation probe, the in-memory engine (a contract with Socket's backend), the CLI's group commit and its undo, the dry-run report and the golden fixture format. So a retired filter file stays, as it was, until rollback or remove; with no pin left in the project nothing removes it. It is inert: no pom names its repository, and the lines that named its directory are gone.
  • An emptied .mvn/maven.config can be left by the same limit, when the two lines were the whole file and a scan takes them out. Maven reads an empty config as no arguments.

Carrying main forward

Known gaps

  • A checkout that already configures the prefix filter in an in-checkout directory could take our file there; today it is only told the path to add.
  • Nothing is filtered on Maven before 3.9.2, on Maven 4 in a project that does not declare it, behind a mirror, or for a module that has a .mvn directory of its own.
  • Only the scanning machine's environment is read for the conflict check.
  • A .mvn/maven.config that is a symbolic link and holds exactly the Trusted Checksums settings refuses a rollback, as on main: removing that file is part of the restore, not a courtesy. Not changed here.

🤖 Generated with Claude Code

A hosted or vendored scan could change which version of a dependency a
Maven build resolves and exit 0 without saying so. The candidates were a
superset of the build (every version any pom of the graph declares, and
every cached version behind a range or an undefined property), and a
<dependencyManagement> pin makes every occurrence of the artifact one
version. A patch for a version that lost mediation, was excluded, or was
only cached by another project therefore replaced the version that won:
a downgrade when the winner was newer, an upgrade when it was older.

A pin is now written only where Maven selects the patch's base version
already.

- crawlers/maven_selection reads what Maven selects in each module from
  the project's poms and the poms the local repository holds, without
  running Maven: own and inherited dependencies, compile/runtime
  non-optional transitives, exclusions, declared or managed versions (the
  module's management over every transitive one), ranges through the
  cached maven-metadata files, and mediation with parents settled first
  (nearest wins, first declared on a tie, what a losing version depends
  on leaves the graph). formats/maven/version holds Maven's version order
  and range grammar.
- Every answer is certain or not. A missing pom, a property that is
  undefined or that a profile redefines, a profile with dependencies or
  management, a relocation, a cycle, an unread module and a Maven 4 build
  are not certain, and nothing is pinned on them.
- Hosted: redirect_maven_version_not_selected when the build selects
  another version (or none), redirect_maven_selection_undetermined when
  it cannot be told and no declaration names the base version.
- Vendored: vendor_maven_version_not_selected, a skip decided before any
  download; the planner pins a local root only when every module under it
  selects the base version or does not resolve the artifact, and leaves a
  pin alone when it cannot tell. vendor --check accepts either answer.
- A declaration that already names the base version is rewritten under
  any answer: that replaces a version where it stands.
- Agent mode patches cached jars in place and is unchanged, except that a
  version directory holding a pom and no artifact is left out of an agent
  scan instead of failing it as a targeted patch not found on disk.
- The nothing_wired refusal no longer says Maven keeps resolving the base
  version.

Outcomes that change: the six shapes above exit 0 with nothing written
and one line naming the version Maven selects; vendored used to exit 1
on a project that declares another version itself; agent mode used to
exit 1 on a pom-only version; a transitive-only dependency of a project
whose poms are not in the local repository is reported as undetermined
instead of pinned.

Refs #595, #882.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The version_not_selected and selection_undetermined warnings lost the
line continuation in their format strings and carried a run of spaces
in the middle of the sentence. The planner test now compares the whole
warning.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Maven builds a pom that declares one dependency twice from its last
declaration, in the place of the first (and warns). The selection model
kept the first, which could call a version selected that Maven does not
select.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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>
Review fixes for the Maven selection work.

Determinism. Where the pins go is decided when a patch is first wired,
and the committed poms are the record. A later plan over poms that
already wire the patch keeps every pin and adds none, whatever the local
repository of that machine can tell, so one checkout plans the same
everywhere and a re-run is a no-op. `vendor --check` no longer judges
where a pin belongs: it takes every pin, and every absence of one, as
committed. Before, a project vendored where nothing could be told (the
declaration rewritten, no pin) drifted in `--check` and was rewritten by
a re-scan on a machine with a full local repository.

- A held pom still moves an older patch's pin to the new suffix: the
  tree the old suffix names is replaced by the same run.
- A plan left unwired because one module's answer holds the root back is
  the vendor_maven_selection_undetermined skip, whatever the other
  modules select. It used to be the nothing_wired refusal.
- A pin for a version the build no longer selects is taken out of the
  poms when the patch is skipped as not selected, and the skip says so.
  It used to stay and keep forcing that version.
- A range is resolved only on the version lists cached for the
  repositories the module's poms declare (and central and local). A list
  cached for any other repository id leaves it undetermined.
- The undetermined line names the remedy that fits its cause: resolving
  the project only when something is missing from the local repository.
- Property lookup goes through the shared lookup_property, so a bare
  ${version} reads a property of that name before the project's own.
- One artifact check for Coursier and Maven directories; the agent scan
  filters pom-only versions through the crawler, off the async runtime.
- The selection is read off the async runtime, kept between the stages
  and patches of one run while every file it read is unchanged, and not
  read at all for a hosted reactor root, which is refused whole.

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>
…olds

The selection of a project is kept between the calls of one process and
was given again while each file it was read from had the same length and
modification time. That is not the same as the same content:

- a pom rewritten to the same length within one tick of the file
  system's clock (a few milliseconds on Linux) has both unchanged, so the
  old selection was returned for the new pom. This is what failed on CI:
  `a_version_the_build_does_not_select_is_skipped_before_any_download`
  rewrites the project pom from 1.11.0 to 1.10.0 and asks again at once;
- a version list was checked by its directory's length and time, which
  rewriting a `maven-metadata-*.xml` in place never changes;
- a vendored run holds its writes to the project in memory until it
  commits them, and its readers answer from them: the selection read
  such a pom, the check looked at the file on disk;
- the subprojects Maven 4 finds by listing a directory were not part of
  the check at all, so one that appeared was not seen.

The walk now notes every read it makes of the file system (`Reads`): the
path, whether it was a file or a directory listing, and the SHA-256 of
the very bytes or entries it went on to use, through the readers the
check repeats. A kept selection is given again only when repeating each
read returns the same digest, so it cannot be older than the files: a
missing file, a listing, and an uncommitted write of the run are reads
like any other, and there is no gap between a read and its record. The
selection touches the file system only through the walk (a test holds
`maven_selection.rs` to that), and the one listing the walk does not
note, the scope queue's, asserts it is never made on a noting walk.

Reading the noted files again and hashing them costs a fraction of
parsing them and walking the graph.

Tests, each failing on the old check when run alone: a project pom, a
repository pom and a version list rewritten to the same length with no
delay and with the modification time put back; a pom, a version list and
a discovered subproject that appear; a pom written inside an open group
commit and read before it is committed. The selection fixture keeps its
own answer, so another test's selection no longer replaces it and hides
a stale one.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…-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>
A range is a hard requirement at any depth: Maven's resolver backtracks
to a version inside it even when a plain version sits nearer the root.
A range the model could not resolve (its only version list is cached
for a repository the build does not declare, such as a settings.xml
mirror; it cannot be parsed; or no listed version is in it) became an
unread version that only cast doubt when it was no deeper than the
winner. A nearer plain version outside the range was then reported as
certainly selected, and hosted or vendored mode pinned it through
<dependencyManagement>, downgrading what Maven resolves.

Mark such edges as hard and make any of them leave the pick
undetermined. Also restore the spaces lost in the three unpin messages.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011f9aeRJTv8HGEveVfgkPgS
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>
…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>
A `<repository>` a pom declares is asked, before Maven Central, for every
artifact and parent pom the local repository does not hold yet. Hosted
mode adds one per patch, so on a cold repository Maven sent each of them a
request for every dependency of the build: wasted round trips, the
project's whole dependency list in the patch server's logs, and a slow or
unreachable patch server delaying artifacts it never serves.

With each pin that lands, the rewriter now also writes, for Maven
Resolver's `prefixes` repository filter:

- `.mvn/socket-patch/prefixes-socket-patch-<uuid>.txt`, which lists the
  one path that repository serves
  (`/<group/path>/<artifact>/<version>-socket.<hex8>`) under the header
  Maven 4 requires;
- two lines in `.mvn/maven.config` that switch the filter on and point it
  at `.mvn/socket-patch`.

Measured with real Maven on a cold local repository (a project with three
dependencies, one of them patched): the Socket repository went from 25
requests, 21 of them for artifacts it does not serve, to the 4 for the
patched version's jar, pom and their checksums. That holds from Maven
3.9.2 on and on Maven 4.0.0-rc-7, from the project root, a module
directory and with `-f`. The filter abstains for a repository with no
file in that directory, so no other repository is filtered (checked: a
second repository of the pom received the same requests as before).
Maven 3.6.3 and 3.8.9 do not know the properties, and 3.9.0 / 3.9.1 do
not interpolate `${session.rootDirectory}`: they build as before,
unfiltered.

A prefix file that does not list the pinned version fails the build, so
the file is written with the pin, from the pin's coordinates, and only
when the plan that wires the pin is written. A same-GAV grant gets none.
A pin an earlier run wrote is left as it is, like its Trusted Checksums,
so a re-run stays edit-free.

The filter reads one directory per build. A checkout whose
`.mvn/maven.config` or `.mvn/jvm.config` already configures it keeps its
configuration: nothing is written for the filter, the pin lands, and the
run warns `redirect_maven_repository_filter_conflict`. The directory is
one only hosted mode uses, so the two lines can be told from a user's:
rollback and remove take them out again byte for byte, with the file of
each restored pin and any file whose repository no pom declares. A scan
cannot remove a file, so when it takes a Socket repository out of the
poms it leaves that repository's file empty.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`maven_hosted_asks_the_socket_repository_only_for_the_patched_version`
wires a single pom and a reactor against the suite's fake registry, then
resolves each into a local repository that holds the dependency plugin and
none of the project's artifacts, and reads what the Socket repository
received:

- from Maven 3.9.2 on, and on Maven 4, exactly the patched version's jar
  and pom and their `.sha1`;
- on an older Maven more than that, and the build still succeeds
  (asserted, so a change in either direction is noticed);
- on every Maven more than that once the prefix file is removed, which
  also shows that the local repository was cold;
- after a rollback, the tree as it was before the scan, byte for byte.

The Socket repository is mirrored onto the test's server under its own
id: the prefix file is read by repository id, and a mirror of another id
would leave it unread. Maven 4 keeps copies of the reactor's poms under
`.mvn/target/`, which the comparison leaves out.

Passed locally on Maven 3.6.3, 3.8.9, 3.9.2, 3.9.3, 3.9.4, 3.9.16 and
4.0.0-rc-7. The capstone's rollback now also checks that the filter file
is gone.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
#2100 was squash-merged to main, with two commits this branch never had
(the selection failing closed when it is unreadable, and a pom the local
repository lacks holding a module's pins back) and the rest of main since.
This branch still carried #2100's individual commits as of the point it
forked from it (7795510).

The tree is main plus this branch's own changes: the three-way merge was
taken with that fork point as its base, so what #2100 became on main wins
over the copy carried here. The diff against main is the same 66 files and
the same line counts as this branch's diff against the fork point. One
conflict: a single long line of CLI_CONTRACT.md, where main changed the
Bun lock versions and this branch the Maven clauses; both are kept.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…aven-hosted-repo-scoping

#2100 landed on main and the #2114 branch took main in. This brings that
forward. One conflict, the same long line of CLI_CONTRACT.md that main's
Bun change and this branch's Maven clause both touch; both are kept.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The hosted engine, discovery and the restore each read a reactor's module
and parent poms through a reader that dropped every read error, so a pom
that exists but is not UTF-8 text looked like a module with no pom:

- the scan reported the reactor as short of a pom it has
  (`redirect_maven_multimodule_unsupported`) instead of refusing the run
  for a file whose content it does not know;
- discovery left the pom out without a word, and a pin was attested or
  withheld for the wrong reason;
- a rollback restored the poms it could read and left the undecodable
  one naming a version whose repository was gone.

Each now tells "there, but not UTF-8" from "not there":

- the engine records such poms and its guard refuses the run for the
  first, by name, with `candidate_file_unreadable`, as it does for an
  undecodable root pom. They are judged by what read them, not by their
  file name: a module's pom may be called anything. A linked or
  unopenable module pom still only leaves the reactor alone;
- discovery reports the file as unreadable and treats it as a pom of the
  reactor it could not read: the pins of the other poms stay refs and
  none is attested, for that reason;
- the restore refuses every pin of the reactor, names the file, and
  writes nothing: a pin is restored in every pom that carries part of it
  or in none, and with a pom unread "every" cannot be kept.

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

Brings in dc3ccc2: a reactor pom that is there but is not UTF-8 text
is refused or reported as unreadable, never read as a missing module.
No conflicts.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main gained the rule that this repository names no private repository,
and the rewording that goes with it, and conflicted here in one long
line of CLI_CONTRACT.md: main changed its cargo clause, this branch its
Maven clause. Both are kept. Nothing this branch adds over main names a
private repository, a path in one, or one of its pull requests.

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

Carries main's public-wording pass and the hosted reactors branch's merge of
it into the repository scoping branch. No conflicts.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Rollback no longer takes a user's own filter switch. The two resolver
lines are hosted mode's by the directory they name (`.mvn/socket-patch`),
so `strip_config` removes them only when that line is there; a lone
`-Daether.remoteRepositoryFilter.prefixes=true`, which a scan leaves alone
and reports as a conflict, survives the rollback of that scan's pin.

A filter file that would fail the build is mended. A scan that retires a
file leaves it empty (a rewrite removes no file). When the pom's wiring
then came back by a revert or a merge, the pin was in place, nothing
landed, and Maven refused the pin (`Prefix ... NOT allowed`) for good. A
scan that finds the pin in place now rewrites a file that is there and
does not list the pinned version.

A scan that empties the last filter file takes the two resolver lines out
with it: no later rollback would find anything to undo.

Whether a repository is still declared, before its file is retired, is
asked of every pom the reactor read, not of the files named `pom.xml`: a
module's pom may be a file of any name.

A file is settled against what the run already plans for it, so a
repository retired and wired again within one run ends as the checkout has
it, and one written and retired within a run was never there.

The conflict warning is said for each patch, naming its repository and the
path to list for it, and reads as one line (the old text had lost its line
continuations).

One listing of the filter directory (`hosted_maven_filter_dir`: hosted
mode's own regular files, and whether anything else is there) serves the
engine's read, the restore and the vendored eject snapshot. The snapshot
took every entry of the directory before, so a subdirectory or a FIFO
there failed the eject of every ecosystem.

`append_config_args` is the one way lines are appended to
`.mvn/maven.config`, and `settle_maven_plan` the one block that settles the
`.mvn` files of a planned dep; both stood twice.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main now carries the fix for the Trusted Checksums line that stopped Maven
3.9.2 to 3.9.8 from starting with -f from outside the project, which moved
the helpers this branch calls into formats::maven::declared_maven and
changed how the checksums directory is spelled.

Conflicts, and how they were settled:

- redirect/mod.rs: this branch had factored the Trusted Checksums pin into
  pin_maven_checksums, shared by the literal, property and reactor paths;
  main had changed the inline copy. The factored function stays and takes
  main's rule: the settings are merged once per run through
  merge_mvn_config with the project's form and the Maven it declares, so
  every path that pins writes the directory one way. main's heal runs
  first, before the reactor planner, as it does before every other return.
- redirect/upstream/maven.rs: both sides' tests kept; the import of a
  helper this branch's restore no longer calls is dropped.
- CLI_CONTRACT.md: one long line, this branch's reactor and property clause
  with main's Trusted Checksums clause.

The reactor extractor of discovery hands the root pom to the enforcement
check, which main's signature now takes.

This branch's own golden cases (property-version, property-shared-sibling,
parent-in-checkout, reactor-root-property, reactor-module-literal) were
regenerated from the rewriter: their .mvn/maven.config now names the
checksums directory through the launcher's property, like main's. The
discovery golden follows.

Test only: the shared snapshot helper of the real-Maven suites leaves out
Maven 4's own output directory (.mvn/target), which made the reactor
rollback test fail on Maven 4.0.0-rc-7.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Base automatically changed from fix/maven-hosted-reactors-and-properties to main November 19, 2026 16:05
Carries main forward as far as the base branch had it before it was
merged: the `mvn -f` fix for the Trusted Checksums directory line and
the declared-Maven reader it adds.

Seven conflicted files:

- `redirect/mod.rs`: both sides reworked the block that follows a
  reactor plan. This branch's `settle_maven_plan` stays the one such
  block and takes the checksum settings as main passes them (the config,
  the project's spelling of the directory, the declared Maven), so the
  reactor, the property and the literal paths merge the settings one
  way.
- `redirect/upstream/maven.rs`: the restore of the `.mvn` files takes the
  repository filter's lines out first (this branch), then drops the
  checksum lines and heals a config that stays (main). Both sides' tests
  are kept.
- `formats/maven/mod.rs`: both modules are declared.
- `CLI_CONTRACT.md` and `docs/ecosystems.md`: main's text, with this
  branch's clauses and its section on the repository filter put back.
- the `mvn-config-merge` fixture and the discovery golden: regenerated.

Golden fixtures that change with the merge: `maven4-model` and
`maven4-launcher-line-conflict`, which main added and which wire a pin,
gain the two filter lines, the prefix file and their two edits; the
expected config of `repository-filter-conflict` takes main's spelling of
the checksums directory.

The filter's own directory line still names the checkout through
`${session.rootDirectory}` here. The next commit gives it the rule the
checksums line follows.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The base branch was squash-merged, so this branch is now based on main.
Besides the base branch's own changes, which the previous merge already
carried, main brings hosted mode for gems locked as precompiled platform
gems, the Composer tests under Bazel, and the Maven mirror guard.

The mirror guard is this branch's sibling: both add to the same places.
Eight conflict hunks in four files, each two additions at one spot, and
both are kept, this branch's first:

- `redirect/mod.rs`: the `.mvn/jvm.config` constant beside the mirrors
  key; the filter's scope and directory listing beside the mirror
  warning's text.
- `hosted/engine.rs`: for a Maven candidate the engine reads the filter
  files and `.mvn/jvm.config`, then the machine's mirrors; one test of
  each.
- `e2e_redirect_maven_build.rs`: the two real-Maven tests.
- `CLI_CONTRACT.md`: the two reason-code rows and the two sections.

How the two compose: the mirror gate plans a dependency on its own
before it is handed to the pom rewriter, and holds it back when a mirror
would take its Socket repository. A gated dependency gets no filter file
and no filter line, like no pin; one that is wired gets all three.

The other conflicts git reports are the squash's (each side carrying
the base branch's changes) and are resolved as merging main's newer
commits alone resolves them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The two `.mvn/maven.config` lines that point Maven at the repository
filter files named their directory through `${session.rootDirectory}`.
That property is undefined on Maven 3.9.2 to 3.9.8 when a build is
started with `-f <project>/pom.xml` from outside the project, and Maven
then does not start at all. Main fixed this for the Trusted Checksums
directory line; the filter's line kept a form of its own and would have
brought the break back for every project a hosted scan wires.

The line now takes the property the checksums line takes, from the same
helper: `${maven.multiModuleProjectDirectory}`, which every Maven 3
launcher defines in every invocation, unless the project declares
Maven 4 (a wrapper that pins it, or a root pom of model 4.1.0), which
reads only the session's.

With the rule come the three things main does for the checksums line:

- The heal. A directory line in the other spelling is respelled in
  place by every hosted scan that reads the file, whatever the run
  redirects, and by a rollback or remove that leaves the lines. The line
  is hosted mode's wherever it stands, since it names a directory
  nothing else uses. One function now heals both groups of lines, for
  the scan and for the restore. A rollback takes the lines out in either
  spelling.
- What is traded away is said. Respelling the session's property in a
  project that declares no Maven takes the filter from a Maven 4 build
  of it: `redirect_maven_repository_filter_maven3_only`, and
  `maven_repository_filter_maven3_only` on a restore. A run that takes
  the lines out in the same breath reports the removal alone.
- What the declared Maven makes of the filter is said. It is judged by
  the rule the checksums pin is judged by, which moves to the
  root-directory property so that both read it, with the filter's own
  first release (3.9.2). A wrapper that pins an older Maven, or a
  Maven 4 project whose line names the launcher's property in a spelling
  the heal leaves alone, gets the files all the same and
  `redirect_maven_repository_filter_unread`, on the scan that writes
  them and on every later one.

The conflict check takes either spelling of hosted mode's own line as in
place; any other value of either property is still the user's own filter
configuration and is left alone.

The heal stays a courtesy that is withheld when the config cannot be
written. On main a heal was always the file's whole change. Here a run
can also put the filter's lines in for a pin that lands, so the heal is
withheld only where it is the whole change: taking the file out of such
a run would drop lines the run reports as written.

Outcome changes: the spelling of one line in `.mvn/maven.config`; three
new warning codes and one new edit key; a hosted scan of a project whose
Maven Wrapper pins a Maven older than 3.9.2 reports one more warning; a
Maven 4 build of a project that does not declare Maven 4 is not
filtered. No exit status changes.

Golden fixtures: the expected config of the twenty Maven pom cases that
wire a pin and declare no Maven, and of the sbt case whose pom is wired,
takes the launcher's spelling in that one line.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The filter keeps Maven from asking a Socket repository for anything but
the patched version. It is an extra, and the review found eight ways it
could cost more than that. Each is fixed here; two questions about the
filter's default stay with the owner and change no behaviour.

A run is never refused for the filter:

- A `.mvn/maven.config` that is a symbolic link, or sits in a directory
  that does not take the write, could not take the filter's two lines,
  and the scan refused every ecosystem where it used to land the pin.
  The engine now tells the rewriter that the config cannot be written;
  the filter is skipped, the pin lands, and the run says so. A config
  that already holds the lines needs no write and gets its files.
- A link or a directory under the name of a pin's filter file is not
  read and not written through; that pin lands without a file.
- On a rollback or remove the stripped config was staged with an
  unconditional write, so a linked or since-edited config restored
  nothing. It is staged only where the flush could write it; otherwise
  the lines stay and the restore says which.
- A filter directory that cannot be listed to its end is no empty
  directory: nothing in it is deleted, the lines that name it stay, and
  the restore says so.

A build is never failed by it:

- A scan emptied the filter file of a repository it took out of the
  poms. If the wiring came back by a pom-only revert or a merge before
  the next scan, Maven refused the pin. A retired file is now left
  exactly as it is: no pom names its repository, so Maven does not read
  it, and it is the right file if the wiring returns. With nothing
  emptied, the path that repaired an emptied file is gone.
- A filter file is read for what it lists, not compared byte for byte:
  a CRLF checkout or an added comment no longer makes every scan report
  a rewrite.

Nobody's own filter is switched off without a word:

- A scan that took out the last Socket repository stripped the two
  lines even when the user keeps prefix files of their own in the
  directory, which are read through those lines. It now leaves them, as
  a rollback does, and wherever the config cannot take the write.
- A prefix filter named in the environment of the machine that scans
  (`MAVEN_OPTS`, `MAVEN_ARGS`, `JAVA_TOOL_OPTIONS`, `JDK_JAVA_OPTIONS`;
  Maven 3.9.9 and 4.0.0-rc-7 honour the property in each) is a conflict
  like one in `.mvn/jvm.config`: nothing is written for the filter.
- The run that adds the two lines says what they change for the whole
  build: Maven reads prefix files from `.mvn/socket-patch/` only.

One reader lists the filter directory for the engine, the restore and
the vendored eject (hosted mode's own regular files, what else is there,
whether it could be listed), and one test tells a hosted file by its
path. `retire` no longer marks a run for a file the run itself planned
and took back.

Outcome changes: three new warning codes
(`redirect_maven_repository_filter_enabled`,
`redirect_maven_repository_filter_skipped`,
`maven_repository_filter_left`); a scan no longer reports a filter file
as `removed`, and no longer writes one it retires; a hosted scan or a
rollback of a project whose `.mvn/maven.config` is a link now succeeds
where the filter alone made it fail. No exit status is added.

Golden fixtures: the seventeen Maven pom cases that wire a pin and pin
a warning list, and the sbt case whose pom is wired, gain
`redirect_maven_repository_filter_enabled`. No expected file or edit
changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants