Repository navigation
Description
[agent] Filed by the scheduled architecture audit routine (ecosystems and formats). Register: discussion #560 register.
Kind: refactor (it fixes bugs as a side effect). Source: review Part 5.4, register E10; child of #715.
Problem
The hosted Maven rewriter and its upstream restore find their edit points in the raw pom text:
patch/redirect/mod.rs#L6052-L6099:``MAVEN_DEPENDENCY_BLOCK_RE(`(?s)<dependency\b[^>]>.?`) and `maven_tag_inner_range`, which takes the first `` / `` / `` substring in the block.L6240andL6389:`` "already wired" ispom_text.contains("<id>{repo_id}</id>").insert_maven_repository/insert_maven_dependency_managementL6510-L6545:``replacen("<repositories>"), `(?s)\s*`, `replacen("")`.- Restore reuses the same regex in
upstream/maven.rs#L59-L111`` (dep_matches, `dm_sections`, `remove_repository`).
None of these skip comments, CDATA, <profiles>, <build><plugins>…<dependencies> or <exclusions>. The reader that hosted VEX uses on the same file, formats::maven::parse_pom, skips all of them, with offsets preserved (blank_non_markup / open_tags / elements).`` So the writer edits elements the reader then refuses to attest.
Symptoms
- Hosted Maven rewriter edits commented-out, plugin and profile markup, so builds either stay unpatched or break #259: edits land in commented-out, plugin and profile markup.
- Maven pom rewrites add a second <repositories> or <dependencyManagement> section when the existing one is self-closed or has a comment before <dependencies>, so Maven refuses the pom #342 (hosted rows): a self-closed
<repositories/>/<dependencyManagement/>, or a comment before<dependencies>, gets a duplicate section. - Hosted Maven adds a dependencyManagement pin that the direct literal overrides when the dependency's groupId/artifactId is a ${property} or <exclusions> come first, so the build stays unpatched while scan reports redirected and VEX attests not_affected #683 (the
<exclusions>-first half): the exclusion's<groupId>is read as the dependency's. The${property}coordinate half needs property resolution and is out of scope here. - Hosted Maven "redirected" is confirmed by substring, so the scan envelope and ledger claim patches that
vexrefuses and Maven never enforces #260 is helped (the edit lands where VEX looks), but its substring confirmation is a separate fix.
I'll comment once on each.
Proposed change
- In
formats/maven, expose a small offset-preserving query API over the masked text thatparse_pomalready builds: project-scope<dependency>elements (withmanaged/in_profile/ in-build flags,<exclusions>blanked), the child-text ranges ofgroupId/artifactId/version/type, and the project-level<repositories>/<dependencyManagement><dependencies>/</project>anchors (self-closed forms included).parse_pomis rebuilt on the same calls. - In the hosted rewriter, replace
MavenDependencyMatch/maven_tag_inner_range/MAVEN_DEPENDENCY_BLOCK_RE/find_maven_dependency_matches, the<id>substring checks and the twoinsert_*anchors with those queries. The byte splices and the warning codes stay. - In restore,
dep_matchesanddm_sectionsuse the same queries, and restore's import of the hosted regex is deleted.
Deleted: MAVEN_DEPENDENCY_BLOCK_RE, maven_tag_inner_range, maven_tag_text_in, find_maven_dependency_matches, restore's dep_matches / dm_sections regexes.
Size and scope
formats/maven/mod.rs (+80), 70 / +patch/redirect/mod.rs (−50), 40 / +~30), plus tests. About 300 changed production lines. Out of scope: vendored patch/redirect/upstream/maven.rs (−build_repo_edit, the reactor, the CRLF of inserted blocks (#273), and ${property} coordinates.
Acceptance criteria
- Regression tests in
redirectfor: a commented-out<dependency>with a literal version beside a versionless real one (the pin goes to<dependencyManagement>, the comment is byte-identical); a plugin<dependencies>entry for the same GA (untouched);<exclusions>before<groupId>(the direct literal is rewritten);<repositories/>and<dependencyManagement/>self-closed, and a comment between<dependencyManagement>and<dependencies>(no second section, Maven-parseable output) - For each case,
vex::discover::mavenattributes the rewritten pom (a round-trip test: rewrite, then discover) - The Maven redirect goldens (
tests/fixtures/redirect/maven),upstream::maventests (refusals_change_nothing,crlf_pom_round_trips, …) and the hosted e2e stay green; restore of every new case is byte-exact -
grep -n MAVEN_DEPENDENCY_BLOCK_RE -r cratesfinds nothing
Dependencies
None blocking. Second child of #715; independent of #716. Should land before the child that moves maven_reactor::Doc into formats/maven, which then swaps the scanner under these queries without touching callers.
Activity
audit-ecosystems: E10 Maven half filed (#715, #717), new E55 (#716), …
refactor: re-rank queue, #717 enters first
mikolalysenko commentedon Oct 3, 2026
[agent] Triaged as
priority:p3(Maven refactor). Child of #715; not a duplicate, and no open PR covers it.Generated by Claude Code
mikolalysenko commentedon Nov 26, 2026
[agent] Architecture refactor routine: I checked this on
mainat cfc870f. The defects it describes are gone, so I'm closing it as not planned for what is left.What
maindoes. The hosted Maven rewriter no longer finds dependencies with a regex.find_maven_dependency_matchesreadsmaven_index::PomIndex, which is built onformats::maven::PomScope: it skips comments, CDATA,<build>and<reporting>, and flags<profiles>. The upstream restore reads the same scoped dependencies indep_matches. It falls back to the block regex only for a pom thatPomScopecannot read.Ran. A throwaway unit test gave
rewrite_registry_redirectthe five poms of the acceptance criteria:main<dependency>with a literal version, beside a real one with none<dependencyManagement><dependencies>entry for the same GA<dependencyManagement><exclusions>before<groupId><version>is rewritten<repositories/>and<dependencyManagement/><dependencyManagement>and<dependencies>The restore tests over the same shapes pass:
scoped_rewrites_round_triprestores thecomment-dependency,plugin-dependency,commented-repositoriesanddepmgmt-commentgoldens to their input.What is left.
MAVEN_DEPENDENCY_BLOCK_RE,maven_tag_inner_rangeandmaven_tag_text_instill exist, as that fallback and for reading a<repository>'s<url>. Deleting them changes nothing a user can see, and the routine's charter no longer takes up changes like that. Please reopen this if a pom turns up that the rewriter or the restore still gets wrong.Generated by Claude Code
refactor: #717, #815 closed; three out of charter