Skip to content

Read jars within jar-sized limits and compare patched jars member by member - #2132

Merged
Mikola Lysenko (mikolalysenko) merged 6 commits into
mainfrom
fix/jvm-jar-limits-and-checks
Nov 19, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 6 commits into
mainfrom
fix/jvm-jar-limits-and-checks

Conversation

@mikolalysenko

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

Copy link
Copy Markdown
Collaborator

Fixes six jar-handling defects in agent and vendored mode for Maven and Gradle packages: jars are read within limits of their own, and a patched jar is compared member by member with the jar the build already has. Vendoring needs no upstream registry for the jar.

What was wrong, and what changes

1. Large jars could not be patched. Jars were read through the zip reader written for Python wheels: at most 10,000 entries and 64 MiB inflated, with both jars held whole in memory. hive-exec-3.1.3.jar has 23,728 entries and inflates to 93 MiB; poi-ooxml-full-5.2.5.jar has 15,181 entries. Agent mode refused such a jar as jvm_agent_service_jar_mismatch: the patch service's jar is unreadable. In vendored mode vex omitted it (vendor_artifact_unreadable), an online re-run was refused (vendor_prebuilt_integrity_mismatch) and repair failed, where the strict reader also refused non-ASCII names and a.class beside A.class.

Jars now have their own reader (patch/jar_members.rs). It goes member by member and hashes as it inflates, so memory holds one digest per member, not the members. The limits are counted on bytes actually inflated and on the archive's own entry count, never on declared sizes:

Limit Value Why
Entries 200,000 8 times the largest jar measured. Bounds the digest table to tens of MB.
Inflated bytes, per pass over one jar 1 GiB 10 times the largest measured. A pass is a few seconds of hashing at most.
Inflation ratio 100 times the jar's size, once past 64 MiB Jars compress 2 to 10 times; deflate can reach about 1,000. The 64 MiB floor is the old cap, so no jar that was readable before is refused now.

A jar past a limit gets its own code and a message that names the limit: jvm_jar_too_large in agent mode, vendor_artifact_too_large in vendored mode. The Gradle classifier check used the same capped reader and passed a large jar unchecked; it now reads the patched members within the limits.

2. A first vendoring never compared untouched members with the original. A comparison ran only on an online re-run over a committed tree, and it needed the upstream jar from the registry. A first vendoring now makes the one comparison that costs no network: when the original jar is already in the build's local repository, the members the patch does not touch must be that jar's, as agent mode requires before a swap (vendor_prebuilt_integrity_mismatch, naming up to three members, nothing written). A difference means the project builds with a jar that is not the one the patch was made from. With no local copy the service's jar is committed as served, and nothing is said. No copy of the original is downloaded, on a first vendoring or on a re-run.

3. Entries the comparison skipped. Entries that are not regular files were skipped, which includes one carrying a symlink's mode bits. The JVM ignores unix mode and loads it as a class. The comparison now covers every entry the JVM would load. Directory entries may differ and META-INF/*.{SF,RSA,DSA,EC} stay exempt.

4. -Dmaven.repo.local in .mvn/maven.config was not read. It is now, for a project that is a Maven build (a pom.xml, and no Gradle or Scala-tool build beside it: their mavenLocal() never reads the file), in Maven's order: MAVEN_REPO_LOCAL, MAVEN_ARGS, .mvn/maven.config, MAVEN_OPTS, settings, ~/.m2/repository. The file is read as the project's Maven reads it, which I checked against Maven 3.6.3, 3.8.9, 3.9.16 and 4.0.0-rc-7: before 3.9 the whole file is split on whitespace and nothing is interpolated; from 3.9 a line is one argument, so a value runs to the end of its line. On all four the config beats MAVEN_OPTS, the last occurrence wins, an empty value is the directory Maven runs in, and an undefined placeholder stays in the path. The Maven Wrapper says which reading applies. Without one, the reading whose directory exists is used; when both exist nothing is guessed (maven_local_repository_undetermined).

5. A refusal with no code. A copy that differs from the service's jar outside the patch failed with plain text. Its error now starts with jvm_agent_service_jar_mismatch: and names the members, and the run carries the code as a warning.

6. Reversibility tied to one project's .socket/. A ~/.m2 copy that is already patched gets no backup, so a second project, or a new workspace over a cached ~/.m2, could not roll it back. rollback and remove now download the original from the registry and use it only when it matches the registry's checksum (.sha512, else .sha1) and is the jar the copy was patched from: the record's members at their beforeHash, every other member the copy's own. The .sha1 Maven wrote beside the jar cannot be used, because the swap rewrites it for the patched jar. When no such copy can be had, jvm_jar_backup_missing says which check failed and how to recover. An apply over a copy that holds another revision of the patch says the same.

Reason codes and exit status

Change Before After
Agent apply, jar over the old caps exit 1, jvm_agent_service_jar_mismatch exit 0
Agent apply, jar over the new limits exit 1, jvm_agent_service_jar_mismatch exit 1, jvm_jar_too_large (new)
Agent apply, one copy differs outside the patch exit 1, no code exit 1, jvm_agent_service_jar_mismatch on the event and as a run warning
Agent apply, service jar adds a class in a non-regular entry exit 0, class swapped in exit 1, jvm_agent_service_jar_mismatch
rollback / remove, ~/.m2 jar with no backup here, online exit 1, jvm_jar_backup_missing exit 0 when the registry's jar verifies; otherwise exit 1 with the recovery text
First vendoring, service jar differs outside the patch from the jar in the build's local repository exit 0, committed and wired refused, vendor_prebuilt_integrity_mismatch, nothing written
vex, vendor --check, online re-run, repair on a vendored jar over the old caps omitted / exit 1 attested / exit 0
Vendored jar over the new limits vendor_artifact_unreadable vendor_artifact_too_large (new); repair restores the recorded jar
Online re-run over a committed tree, registry unreachable for the jar refused, vendor_jvm_upstream_unavailable exit 0; the committed jar is compared with the local copy when there is one
rollback of a ~/.m2 copy past the jar limits exit 1, jvm_jar_backup_missing exit 1, jvm_jar_too_large; nothing downloaded
Maven build whose maven.config reads two ways, both directories present, no wrapper wrong repository patched nothing in ~/.m2 patched, maven_local_repository_undetermined (new)

CLI_CONTRACT.md, docs/ecosystems.md and docs/design/maven-vendoring.md describe the codes, the limits, the upstream restore and the .mvn/maven.config lookup.

Review (/code-review high), second commit

All ten findings were confirmed and fixed.

  1. Config applied to Gradle builds. Read only for a Maven build with no Gradle or Scala-tool build beside it; a Gradle project under a Maven root keeps the environment's repository.
  2. First vendoring refused without the registry. Superseded by the owner's decision below: no upstream jar is downloaded at all.
  3. Single-line pre-3.9 form. Tokenised per Maven line (item 4 above).
  4. Unusable values fell through to settings. They now resolve as Maven resolves them; the one case that cannot be told is reported, not guessed.
  5. Rollback blamed a missing backup. The copy is read first and once. A ~/.m2 copy past the limits fails as jvm_jar_too_large with nothing downloaded; a Gradle copy's backup is found by its hash directory without reading the copy.
  6. Classifier check failed open. An unreadable classifier jar now degrades (classifier_unpatched_copy).
  7. vendor --check message. Names the limit the jar is past.
  8. Digest passes on async workers. They run on the blocking pool; identical copies are read once, keyed by sha256.
  9. Entry limit checked after parsing. The entry count and the central directory's size (64 MiB limit, new) are read from the end record the zip reader would take, zip64 included, before it parses the directory. See "End records anywhere in the file" below for how that record is found.
  10. Code recovered by string parsing. apply_jar_swap returns the refusal beside each copy's result.

Owner decisions

Vendoring does not ask the registry for the jar. The owner's rule: vendored mode never downloads a jar from the upstream registry in order to compare it, and vendoring a Maven or Gradle patch succeeds with the patch service and the local machine alone. So the registry download of the original jar is gone, with the refusal and the warning that came with it, on a first vendoring and on an online re-run (which on main refused with vendor_jvm_upstream_unavailable when it could not get the jar). The comparison with a jar already in the local repository stays. vendor_jvm_upstream_unverified keeps its meaning for upstream metadata and is no longer raised for the jar.

What still reads the registry: upstream metadata. The pom of the patched artifact, its parent poms, Gradle module metadata, classifier and sources jars and their checksums are read from the local caches and otherwise from the registry, as on main. An online re-run with no local pom still refuses when the registry cannot be reached. That is a follow-up, not part of this PR.

.mvn/maven.config may choose where agent mode writes. Accepted as consistent with Maven, and documented in docs/ecosystems.md beside the local-repository lookup and in CLI_CONTRACT.md under agent mode: what the config can point apply, rollback and remove at, what socket-patch does there, and that MAVEN_REPO_LOCAL takes the choice back. No new warning.

Test: a_first_vendoring_compares_with_the_local_jar_and_asks_the_registry_for_none (registry unreachable and no local copy commits with no warning; a matching local copy commits; a differing one refuses and names the members; no jar is requested from the registry; an online re-run over the committed tree succeeds).

Later fixes

The member check ran before the bounded reader. apply_jar_swap and rollback_jar_swap verified a copy's patched members through the zip reader directly, so the limits were applied only after an unbounded parse. The member check now goes through the bounded reader: a copy past a limit fails as jvm_jar_too_large at its first parse, and a rollback stops there without reading a backup or reaching the registry (a_copy_past_the_limits_is_refused_before_it_is_parsed).

End records anywhere in the file. The check before the parse read only the last 64 KiB of the file. The zip reader looks for an end record backwards through the whole file, finds a zip64 record forwards from where the locator points, and falls back to an earlier end record when a directory does not parse. With bytes appended after the end record, an archive of 200,001 entries passed the check and was parsed whole before the count refused it.

The check now walks as the reader does. It finds the last end record the reader can take, wherever it sits, and holds it to the limits. Then the reader is shown zeros below that record's central directory while it opens the archive, so the only records it can fall back to are inside the directory itself, and each of those is held to the limits as well. A record the reader would pass over is passed over; after 64 of them the archive is given up as unreadable, since each costs a search of the file.

This is also how a fat jar is handled. A jar stored inside another has its own end records, in the outer jar's member data. That is below the outer directory, so the reader cannot take them and they are not looked at: the outer directory is what counts, whatever a nested jar declares. Checking every end record in the file instead would have refused a fat jar for a nested jar's record that the reader never reaches.

Tests: the_central_directory_is_bounded_before_it_is_parsed (appended bytes, a zip64 record found forwards from an early locator offset, records that lead nowhere), an_archive_past_the_limit_is_refused_unparsed_with_bytes_after_it (a real 200,001-entry archive with 70,000 bytes appended), a_fat_jar_with_a_stored_nested_jar_is_accepted (a stored nested jar within the limits and one past them).

origin/main had nothing to merge: the branch was already rebased onto the commit that holds #2100 and #2118, so there is no merge commit and no force-push.

Tests

Each fix has a test that fails without it.

  • Core: patch::jar_members (limits, the central directory bounded before it is parsed, mode-bit entry), patch::jvm_jar (large-jar swap and rollback, coded refusal, ~/.m2 upstream restore, a rollback that checks the copy first), vendor::maven_repo (large jar through vendoring, verify, re-run and repair; first vendoring refused for a changed, added, mode-bit and missing member; the baseline order without the registry), vendor::jvm::gradle (unreadable classifier jar), crawlers::maven_crawler (precedence, Gradle builds, per-version tokenisation, values as Maven uses them).
  • CLI, hermetic: gradle_agent_cli, vendor_jvm_cli, maven_sidecar_cli (the config's repository is the one patched; an ambiguous config patches nothing and says so; a second project rolls a shared jar back from verified upstream).
  • Real Maven: e2e_vendor_maven_build::maven_config_local_repository_is_the_one_maven_and_socket_patch_use.

Results on macOS (arm64) at 2caee0127, which merges main:

  • cargo test -p socket-patch-core --tests: 8,692 tests pass.
  • cargo test -p socket-patch-cli for gradle_agent_cli, vendor_jvm_cli, maven_sidecar_cli, contract_gradle_codes: 89 pass.
  • Real Maven 3.9.16, --ignored: e2e_vendor_maven_build, 6 pass.
  • Production legs (--ignored maven_), against the live patch service and Maven Central: hosted, vendored and agent pass, on Java 26 only.
  • cargo clippy --locked --workspace --all-features -- -D warnings and cargo fmt --all -- --check: clean.
  • Not run here: cargo check --all-targets, the rest of the CLI suite, and anything on Linux or Windows.

The merge of main also moved the local-repository lookup onto the helpers main now shares: which Maven a project declares (its wrapper's release, or a root pom only Maven 4 reads), the reading of a maven.config line on Maven 3.9 and later (so --define and quoted arguments are read too), and which root-directory property that Maven fills in. The whitespace reading of Maven before 3.9, and the choice between the two readings when the project declares no Maven, stay in the lookup.

For the owner

  • socket-patch reads MAVEN_ARGS whatever Maven is installed; Maven before 3.9 ignores it. That was already so and is now documented.
  • A rollback with no backup now makes a registry request (Maven Central, or SOCKET_MAVEN_REGISTRY). --offline keeps it local.
  • A copy that differs outside the patch still fails alone; the other copies are swapped. Refusing the whole swap would be stricter.
  • An online re-run over a committed jar that fails the upstream comparison still refuses and leaves the jar wired, as before.

Generated by Claude Code

…ream

Agent mode and vendored mode read jars through the zip reader written for
Python wheels: 10,000 entries and 64 MiB inflated at most, regular-file
entries only, both jars held whole in memory. Released jars are past
those caps (hive-exec-3.1.3: 23,728 entries, 93 MiB), so agent mode
refused them as "the patch service's jar is unreadable", and a vendored
one could not be attested, re-vendored online or repaired.

Jars now have their own reader (patch/jar_members): member by member,
hashing as it inflates, bounded by what is actually inflated and by the
archive's own entry count rather than by declared sizes. The limits are
200,000 entries, and per pass 1 GiB inflated and 100 times the jar's
size (64 MiB for a small jar). A jar past one is jvm_jar_too_large
(agent) or vendor_artifact_too_large (vendored), and the message names
the limit.

The comparison of a patched jar with the original covers every entry the
JVM would load, whatever unix mode it carries: an entry with a symlink's
mode bits was skipped, so a class added that way went unseen. Directory
entries and signature files stay exempt.

A first vendoring makes that comparison too, against the registry-verified
upstream jar and before anything is written. It used to run only on an
online re-run over a committed tree, so a service jar built from another
base was committed and wired.

A copy that differs outside the patch now fails with
jvm_agent_service_jar_mismatch, naming the members; the per-copy error
carried no code.

A ~/.m2 jar that another project (or an earlier workspace over a cached
repository) patched has no backup in this project. Its rollback now
restores the registry's jar when the download matches the registry's
checksum and is the jar the copy was patched from, and otherwise says
what happened and how to recover, as does an apply over a copy that
holds another revision of the patch.

-Dmaven.repo.local in the project's .mvn/maven.config names the local
repository, between the command line (MAVEN_ARGS) and MAVEN_OPTS, as in
Maven 3.6.3, 3.8.9, 3.9.16 and 4.0.0-rc-7.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Read `.mvn/maven.config` only for a Maven build, and as its Maven reads
it. A Gradle or Scala-tool build's mavenLocal() never reads the file, so
such a project keeps the environment's repository. Maven before 3.9
splits the file on whitespace and interpolates nothing; 3.9 and later
take a line as one argument. The Maven Wrapper says which applies;
without one the reading whose directory exists is used, and when both
exist no repository is guessed at (maven_local_repository_undetermined).
An empty value and an undefined placeholder resolve as Maven resolves
them, instead of falling through to the settings.

A first vendoring no longer fails when the registry cannot be reached
while the patch service can. The baseline is the registry-verified jar,
else the local repository's jar, else none; the last two are reported
(vendor_jvm_upstream_unverified). A mismatch is still a refusal.

A rollback reads the copy before it looks for a backup or downloads
anything: a `~/.m2` copy past the jar limits fails as that, not as a
missing backup, and a Gradle copy's backup is found by its hash
directory without reading the copy. The copy is hashed once.

The central directory is bounded by what the archive's end records
declare, before the zip reader parses it: 200,000 entries, 64 MiB.

Also: the Gradle classifier check fails closed on a jar it cannot read;
`vendor --check` names the limit a jar is past; the digest passes run on
the blocking pool and identical copies are read once; a copy's refusal
code travels beside its result instead of being parsed out of the text.

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

cursor Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

PR Summary

High Risk
Changes core JVM patch/rollback, vendoring verification, and Maven repository discovery—mistakes could patch the wrong ~/.m2 tree or accept/refuse wrong jar bytes in production builds.

Overview
Replaces the wheel-sized zip reader for JVM jars with a streaming jar_members reader (200k entries, 1 GiB inflated, ratio cap) so large and obfuscated jars can be patched, vendored, attested, and repaired. Oversize jars now surface jvm_jar_too_large / vendor_artifact_too_large instead of generic unreadable/mismatch errors.

Agent jar swaps compare service vs installed jars member-by-member (including symlink-mode entries), emit coded per-copy jvm_agent_service_jar_mismatch warnings, and rollback/remove can restore a shared ~/.m2 jar from registry-checksummed upstream when this project has no backup. Apply messages explain copies holding another patch revision.

Project runs resolve the Maven local repository via JvmEnv::for_project, honoring .mvn/maven.config (version-specific parsing, wrapper) in Maven’s precedence; ambiguous configs yield maven_local_repository_undetermined and skip guessing. Docs and VEX copy are updated for upstream jar checks on first vendoring and the new omission codes.

Reviewed by Cursor Bugbot for commit c500e5a. 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 c500e5a. Configure here.

apply_jar_swap and rollback_jar_swap verified a copy's patched members
through the zip reader directly, before the bounded reader saw the jar:
the central directory was parsed, and allocated for, whatever the end
records declared, and a member was inflated with no budget. A copy past
the limits, or one with a hostile end record, could exhaust memory there
instead of failing as jvm_jar_too_large, and a ~/.m2 rollback could go
on to the registry afterwards.

The member check now goes through the bounded reader, so the limits on
the entry count and the central directory are held to the end records
before anything parses the directory, and members are inflated within
the pass's budget. A copy past a limit is refused there: jvm_jar_too_large
on apply, with the run warning, and on rollback, before any backup is
read or anything is downloaded. The unbounded member hasher has no
caller left and is removed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Nov 18, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: final review found one defect and two owner questions, so this PR is not ready to approve yet.

CI is green on 624838d44 and the core unit tests pass locally: cargo test -p socket-patch-core --lib -- patch::jar_members patch::jvm_jar crawlers::maven_crawler ran 103 tests with none failing.

1. Trailing bytes bypass the pre-parse limit check (crates/socket-patch-core/src/patch/jar_members.rs:262)

check_declared_directory reads only the last 22 + 65535 + 20 + 56 bytes, plus 56 bytes at the zip64 locator's exact offset. zip 8.6.0 behaves differently in three ways:

  • it searches backwards through the whole file for the end-of-central-directory record;
  • it retries earlier end records when parsing fails;
  • for zip64, it scans forward from the locator's declared offset.

A probe showed the gap. A 200,001-entry zip gives Err(TooLarge). The same zip with 70,000 zero bytes appended gives Ok(()), and ZipArchive::new then parses all 200,001 entries.

The zip.len() > MAX_ENTRIES check after parsing still refuses that jar, so the result is never wrong. The cost is memory and CPU, and it defeats the description's claim that such a directory is "refused unread". A committed vendored jar checked by vex or vendor --check in CI is the exposure.

Possible fix: check every PK\x05\x06 and PK\x06\x06 in the whole archive with within, not only those in the tail, and add the appended-junk probe as a regression test. I did not push this. A whole-file scan would also see the end records of nested jars stored uncompressed, as in fat jars, so whether that trade-off is acceptable is a call for the author.

2. Owner question: first vendoring without a registry-verified upstream (crates/socket-patch-core/src/vendor/maven_repo.rs:1076)

When the registry can't be reached, the baseline falls back to an unverified local-repository jar, or to no comparison at all. The tree is still committed and wired, with only a vendor_jvm_upstream_unverified warning. Should first vendoring refuse in that case, or need an opt-in?

3. Owner question: .mvn/maven.config choosing where agent mode writes (crates/socket-patch-core/src/crawlers/maven_crawler.rs:816)

This is already listed in the description. A cloned project's -Dmaven.repo.local can point apply at a directory outside the project and the user's home. Is that acceptable, or should it need MAVEN_REPO_LOCAL or confirmation?

I removed Ready for review and added agent:needs-human. Once item 1 is fixed and items 2 and 3 have answers, the next shepherd run will post the approver brief.


Generated by Claude Code

@mikolalysenko Mikola Lysenko (mikolalysenko) added agent:needs-human and removed Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review labels Nov 19, 2026
The check before the parse read the last 64 KiB of the file and the
56 bytes at the zip64 locator's offset. The zip reader does not take
the end record from there: it looks for one backwards through the whole
file, finds a zip64 record forwards from where the locator points, and
falls back to an earlier end record when a directory does not parse.
With bytes appended after the end record, an archive of 200,001 entries
passed the check and was parsed whole before the count refused it.

The check now walks as the reader does. It finds the last end record
the reader can take and holds it to the limits. The reader is then
shown zeros below that record's central directory while it opens the
archive, so the only records it can fall back to are in the directory
itself, and each of those is held to the limits as well. A record the
reader would pass over is passed over; after 64 of them the archive is
given up, since each costs a search of the file.

An end record in a member's data, as a jar stored inside a fat jar has,
is below the outer directory: the reader cannot take it, so it is not
looked at, whatever it declares.

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

Copy link
Copy Markdown
Collaborator Author

[agent] Item 1 ("Trailing bytes bypass the pre-parse limit check") is fixed in a4079df.

The check before the parse now walks end records the way the zip reader does: backwards from the end of the file whatever follows the record, with the zip64 record found forwards from where the locator points. It holds the first record the reader can take to the limits, and the reader is shown zeros below that record's central directory while it opens the archive, so the only records it can fall back to are inside the directory itself; those are held to the limits too. A nested jar's end records sit in member data below the outer directory, so the reader cannot take them and a fat jar is not refused for them.

Tests: the_central_directory_is_bounded_before_it_is_parsed (appended bytes; a zip64 record found forwards from an early locator offset), an_archive_past_the_limit_is_refused_unparsed_with_bytes_after_it (the 200,001-entry probe with 70,000 bytes appended), a_fat_jar_with_a_stored_nested_jar_is_accepted.

Items 2 and 3 await the owner. Labels are unchanged.

Vendoring a Maven or Gradle patch downloaded the original jar from the
registry to compare the patch service's jar with, and refused or warned
when it could not. It does not need the registry for that: the service's
jar is checked as it was served (transfer integrity, the record's
members at their afterHash) and committed.

One comparison stays, since it costs no network and protects the build.
When the original jar is already in the build's local repository, the
members the patch does not touch must be that jar's, as agent mode
requires before a swap. A difference means the project builds with a jar
that is not the one the patch was made from, and the refusal says so.
With no local copy nothing is compared and nothing is said.

An online re-run over a committed tree makes the same local comparison
and no longer needs the registry for the jar. Upstream metadata (pom,
parents, module metadata, classifier jars) is read as before.

Document that a project's .mvn/maven.config chooses where apply,
rollback and remove write, what they do there, and that
MAVEN_REPO_LOCAL takes the choice back.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mikolalysenko Mikola Lysenko (mikolalysenko) changed the title Read jars within jar-sized limits and hold every vendored jar to upstream Read jars within jar-sized limits and compare patched jars member by member Nov 19, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] The owner answered items 2 and 3; both are in 855ad75.

Item 2 (first vendoring when the registry cannot be reached). The owner's decision: vendored mode does not download a jar from the upstream registry to compare it, and vendoring succeeds with the patch service and the local machine alone. The registry download of the original jar is removed, with the refusal and the vendor_jvm_upstream_unverified warning this PR had added for it, on a first vendoring and on an online re-run over a committed tree (which on main refused with vendor_jvm_upstream_unavailable without the jar). One comparison stays because it costs no network: when the original jar is already in the build's local repository, the members the patch does not touch must be that jar's, and a difference is refused with vendor_prebuilt_integrity_mismatch, naming the members. Upstream metadata (pom, parent poms, module metadata, classifier jars, checksums) is still read from the local caches and the registry as on main; that is left for a follow-up. Test: a_first_vendoring_compares_with_the_local_jar_and_asks_the_registry_for_none.

Item 3 (.mvn/maven.config choosing where agent mode writes). Accepted by the owner as consistent with Maven, with no change in behaviour. It is documented in docs/ecosystems.md beside the local-repository lookup and in CLI_CONTRACT.md under agent mode: where the config can point apply, rollback and remove, what they do there, and that MAVEN_REPO_LOCAL takes the choice back.

The PR title and description are updated. Labels are unchanged.

…d-checks

main moved wrapper_maven_version into formats::maven::declared_maven and
added shared answers to which Maven a project declares and how a
maven.config line is read. The local repository lookup now uses them:
DeclaredMaven (the wrapper's release, or a root pom only Maven 4 reads)
decides how .mvn/maven.config is read, maven_config_line_properties is
the reading for Maven 3.9 and later, and RootDirectory says which root
directory property the declared Maven fills in. The whitespace reading
of Maven before 3.9 and the choice between the two readings stay here.

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

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver

What it does. Maven and Gradle jars get a reader of their own (patch/jar_members.rs) that hashes member by member within jar-sized limits (200,000 entries, 1 GiB inflated per pass), so large jars such as hive-exec can be patched and vendored. A patched jar is compared member by member with the jar the build already has, in agent mode and now on a first vendoring too. rollback/remove can restore a ~/.m2 copy from a registry-verified original, and .mvn/maven.config's -Dmaven.repo.local is read.

Risk: high. It changes the core JVM apply, rollback and vendor checks. A wrong limit or comparison could refuse a jar that works today, or turn a user's vendor --check red. Mitigations: the 64 MiB floor keeps every jar that was readable before readable, the post-parse entry check backs up the pre-parse one, and the owner settled both product questions (no registry download when vendoring; maven.config may point apply outside the project, as Maven itself does).

Look here

  • jar_members.rs:368: admit, which walks end records the way zip 8.6 does before it parses anything. It is tied to that crate's behaviour, so a zip upgrade should re-check it.
  • jar_members.rs:79 and jar_members.rs:117: the limits and the inflate budget.
  • maven_repo.rs:1075: the first-vendoring comparison with the local repository's jar. A local jar that cannot be read means nothing is compared.
  • jvm_jar.rs:923: the restore of a ~/.m2 copy from the registry, held to the registry checksum and the record's beforeHash.
  • maven_crawler.rs:821: the .mvn/maven.config reading for pre-3.9 and 3.9+.

Verified

  • ci-ok and clippy are green on 2caee01. The one Bugbot thread is resolved.
  • cargo test -p socket-patch-core --lib -- patch::jar_members patch::jvm_jar vendor::maven_repo crawlers::maven_crawler: 170 passed.
  • I read the two commits since the last review. a4079dff fixes the trailing-bytes bypass, with the 200,001-entry probe plus 70,000 appended bytes as a regression test. 855ad759 applies the owner's decision. Earlier review items 2 and 3 are answered.
  • CHANGELOG.md is untouched, and I found no leftover debug code.

Changes I made: none.

Open questions: none blocking. Reading upstream metadata (poms, module metadata) without the registry is left for a follow-up, as the description says.


Generated by Claude Code

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Nov 19, 2026
Merged via the queue into main with commit 1f56209 Nov 19, 2026
50 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the fix/jvm-jar-limits-and-checks branch November 19, 2026 20:40
Mikola Lysenko (mikolalysenko) pushed a commit that referenced this pull request Nov 19, 2026
The base PR (#2132) was squash-merged into main, so the branch's copy of
its commits conflicted with the squash. Resolved by a three-way merge
over the base PR's last head, so the result carries main plus exactly
this PR's own changes.

Assisted-by: Claude Code:claude-opus-5-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants