Repository navigation
Fix hosted Maven pom edits outside live markup (#259, #262, #342) - #1327
Merged
Merged
Conversation
WIP: draft PR placeholder. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Hosted Maven rewrites found their edit points with raw text anchors, so a scan could rewrite a commented-out or plugin <dependency>, put the Socket repository or pin inside an inactive profile or a comment, suffix sources/tests/native classifier jars that the patch server does not serve, and add a second <repositories> or <dependencyManagement> next to a self-closed or commented one. Each case exited 0 with redirected=1 while the build stayed unpatched or broke. The rewriter now reads the pom through formats::maven::PomScope, the same scope VEX attests from: comments, CDATA, <build>, <reporting>, <pluginRepositories>, <distributionManagement> and <profiles> are never matched or edited, self-closed sections are expanded in place, and only classifier-less declarations decide literal-vs-pin. Classifier variants and profile base literals are left alone with new warnings (redirect_maven_classifier_unsupported, redirect_maven_profile_dependency_unpatched); an unreadable pom is skipped with redirect_maven_pom_unreadable. Upstream restore and VEX discovery follow the same scope so these rewrites round-trip and attest. Fixes #259, #262, #342. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A GA whose only declaration sits in an inactive profile got a top-level dependencyManagement pin that is inert exactly when the profile pulls it in. Skip such a dep with redirect_maven_profile_dependency_unpatched instead of reporting it redirected, keeping the existing in-process contract. Self-closed sections restore to an equivalent empty element, so those goldens are excluded from the byte-exact restore round trip and covered by a unit test instead. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Mikola Lysenko (mikolalysenko)
marked this pull request as ready for review
October 9, 2026 18:00
Collaborator
Author
|
BugBot review |
Mikola Lysenko (mikolalysenko)
enabled auto-merge
October 9, 2026 18:00
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.
Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issues.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 1bbdd63. Configure here.
Re-reading the pom through PomScope for every patched dependency made hosted Maven scans slower (scan-performance flagged maven/hosted +35%, maven/rescan +25%). The rewriter now reads the pom once into a PomIndex and keeps its offsets in step with its own edits (version rewrites, repository and dependencyManagement insertions, superseded repository removal, URL refresh), so a pom with many patched dependencies is scanned once instead of once per dependency. A 1000-dependency pom rewrites in ~25 ms, down from ~1.7 s before this PR series. A unit test checks the kept index against a fresh build after every kind of edit. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
# Conflicts: # crates/socket-patch-cli/CLI_CONTRACT.md # docs/ecosystems.md
Mikola Lysenko (mikolalysenko)
requested review from
Tanmay Singla (Tanmay182003) and
Wenxin Jiang (Wenxin-Jiang)
October 10, 2026 09:28
- maven_index: on a pure insertion, an element end (and a self-closed
element's inner offsets) exactly at the insertion point no longer
shifts, so a <dependencyManagement> inserted before </project> is not
overwritten when a self-closed <repositories/> ending there is expanded.
- Profiles: any versioned declaration inside <profiles> (a ${property}
or another literal, not just the base literal) is reported unpatched,
and the dep is skipped when profiles hold its only versioned
declarations.
- Classifiers: a variant other than sources/javadoc at the patched
release skips the dep instead of pinning the main jar beside it.
- Restore: entry_is_users reads the same live scope as the versioned
count, so a commented, plugin, profile or classifier versionless
sibling no longer makes the authored pin look user-written.
- Rollback: a commented-out socket-patch repository twin no longer
counts as a second repository, nor as a leftover name.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A hosted Maven pin is a classifier-less coordinate: it does not retarget a <classifier> dependency of the same GA, and the grant serves only the main jar, so a tests or native classifier copy resolves from the next repository (the public release). VEX discovery grouped deps with classifiers dropped, so such a pom was still attested as patched. The pin now stays a ref (list/rollback/remove find it) but is marked unattested (vex_maven_classifier_unpatched) when a live, non-profile classifier copy other than sources/javadoc resolves any version but the pin: its own literal, a classifier-keyed dependencyManagement entry, or none in the root pom. sources/javadoc copies keep attesting; they never execute. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Tanmay Singla (Tanmay182003)
approved these changes
Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

LLM Description written by Claude Code:claude-opus-5-5
Fixes #259
Fixes #262
Fixes #342
Summary
scan/get --mode hostedfor a Maven pom could edit markup Maven never reads for the project, suffix artifacts the patch server does not serve, or write a second top-level section that Maven refuses. Every one of these exited 0 withredirected: 1and no warning. After this PR the hosted rewriter reads the pom the way Maven builds the project, and the same wayvexreads it.Root cause
rewrite_maven_pom(patch/redirect/mod.rs) found its edit points with raw text anchors:<dependency>…</dependency>regex for matches,pom.contains("<repositories>")for the repository,<dependencyManagement>\s*<dependencies>regex for the transitive pin.None of these skipped comments,
<profiles>or<build>plugin dependencies, none recognized self-closed sections, and the matcher never read<classifier>.Fix
formats::maven::PomScope(new, shared). It blanks comments and CDATA (offsets kept) and excludes<build>,<reporting>,<pluginRepositories>,<distributionManagement>and<profiles>.parse_pom(which VEX discovery uses) now runs on it, so the rewriter and VEX read the same scope.ScopedDepcarries the<classifier>and the version byte range.<classifier>and suffixes sources/tests/native classifier dependencies, which breaks the build #262): only live, classifier-less declarations decide between rewriting the literal and adding the depMgmt pin.sources,tests, a native build) keeps its version. Warning:redirect_maven_classifier_unsupported.<profiles>is not edited. Warning:redirect_maven_profile_dependency_unpatched. If a profile holds the GA's only declaration, the dep is skipped. This keeps the existingmaven_profile_scoped_dependency_is_not_redirectedcontract.insert_maven_repositoryandinsert_maven_dependency_managementtarget only the project's own top-level sections.<repositories/>,<dependencyManagement/>or<dependencies/>is expanded in place.<dependencyManagement>and<dependencies>no longer hides the section.redirect_maven_pom_unreadable.PomIndex(patch/redirect/maven_index.rs) and keeps its offsets in step with its own edits, instead of rescanning the pom for every patched dependency.scan performanceregression the first push showed:maven/hosted+35%,maven/rescan+25%.edits_keep_the_index_in_stepchecks the kept index against a fresh build after every kind of edit.rollback): it recognizes a pin the rewriter added past a comment. It also counts "the GA's only literal" in the same scope, so a classifier or profile sibling doesn't make an authored pin look like the user's.vexattests.docs/ecosystems.md(hosted Maven caveats) andCLI_CONTRACT.md(new warning codes, scope).#342, vendored row: this is already fixed on main. v5 vendors every pom root through the reactor planner (
vendor/jvm/maven_reactor.rs), which expands self-closed sections. See the existing testsingle_line_poms_and_self_closing_sections. The retiredmaven_repo.rssingle-pom backend only reverts now.Not in this PR: the depscan TS twin (
registry-rewrite/maven-pom.ts) lives in another repo. The new shared goldens undertests/fixtures/redirect/maven/pom/are what it needs to match.Per-issue checklist
comment-dependency(a),profile-repositories(b),plugin-dependency(c),profile-depmgmt(d),commented-repositories(e),profile-literal.<classifier>and suffixes sources/tests/native classifier dependencies, which breaks the build #262 (classifier). Goldens:classifier-sources-siblingandclassifier-only-transitive-main. Each gets a VEX attestation inevery_fail_closed_rewriter_fixture_yields_the_patch_uuid_not_the_token.self-closed-repositories,depmgmt-comment,self-closed-depmgmt.scoped_rewrites_round_tripandexpanded_self_closed_sections_restore_to_one_empty_section(upstream/maven.rs).maven_goldens_round_tripcorpus.scope_skips_comments_and_plugin_sections_and_flags_profiles.Red → green
On
origin/main(a8e9397), with the new fixtures copied in:redirect_goldenfails on the first new case (classifier-only-transitive-main: pom.xml byte-mismatch).redirect_maven_dep_management_added.On this branch all of them pass.
Commands run
cargo test -p socket-patch-core(full,--no-fail-fast): green after the restore-golden exclusion for the two self-closed cases.cargo test -p socket-patch-cli(default features): green except twoe2e_vendor_cargo_buildold-toolchain cases. Those depend on locally installed old cargo toolchains and are unrelated to this change.cargo test -p socket-patch-cli --test e2e_redirect_maven_build -- --ignoredwith real Maven 3.9.16: green.cargo clippy --workspace --all-features -- -D warnings: clean.cargo fmt --all -- --check: clean for the changed files. Local rustfmt flags only the untouchedupstream/mod.rs:917.🤖 Generated with Claude Code