Skip to content

Commit 855ad75

Browse files
mikolalysenkoclaude
andcommitted
Vendor a jar without asking the upstream registry for it
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>
1 parent a4079df commit 855ad75

4 files changed

Lines changed: 183 additions & 269 deletions

File tree

‎crates/socket-patch-cli/CLI_CONTRACT.md‎

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2824,25 +2824,26 @@ entries use ecosystem `jvm` with Maven PURLs. Revert, remove, rollback and repai
28242824
share the v5 vendored backend; existing prototype wiring remains readable.
28252825
See [the JVM design](../../docs/design/maven-vendoring.md) for supported shapes.
28262826

2827-
A vendored jar must be upstream's jar outside the patch. Online, the jar (the patch
2828-
service's on a first vendoring, the committed one on a re-run) is compared with the
2829-
upstream jar before anything is written: a cached copy the registry's checksum
2830-
vouches for, else the registry's own download held to the same checksum. Every entry
2831-
the JVM would load must hold the same content in both, whatever unix mode it carries;
2832-
the record's members and signature files (`META-INF/*.SF`, `.RSA`, `.DSA`, `.EC`) are
2833-
exempt and directory entries may differ. A jar that adds, drops or changes anything
2834-
else is refused with `vendor_prebuilt_integrity_mismatch`, the detail naming up to
2835-
three such members, and a first vendoring commits and wires nothing.
2836-
2837-
A registry that cannot be reached while the patch service can does not stop a first
2838-
vendoring. The baseline is then, in order: the registry-verified jar; else the jar in
2839-
the build's local repository, as agent mode trusts the installed jar; else none, and
2840-
the service's jar is vendored as served. The last two are reported with
2841-
`vendor_jvm_upstream_unverified` (the detail says which, and that a later run makes
2842-
the comparison) and the entry is recorded as not registry-verified. A mismatch
2843-
against whichever baseline was used is still the refusal above. An online re-run over
2844-
a committed tree needs the registry-verified jar, as before
2845-
(`vendor_jvm_upstream_unavailable` without one).
2827+
Vendoring a Maven or Gradle patch takes its jar from the patch service and needs no
2828+
upstream registry for it. The service's jar is checked as it was served (transfer
2829+
integrity, and every member of the patch record at its `afterHash`) and committed. No
2830+
copy of the original jar is downloaded to compare it with, and none is missed: a
2831+
registry that cannot be reached neither refuses the vendoring nor adds a warning.
2832+
2833+
One comparison is made, because it costs no network and protects the build. When the
2834+
original jar is already in the build's local repository (the Maven local repository
2835+
or a Gradle cache), every entry the JVM would load must hold the same content in it
2836+
and in the service's jar, whatever unix mode the entry carries; the record's members
2837+
and signature files (`META-INF/*.SF`, `.RSA`, `.DSA`, `.EC`) are exempt and directory
2838+
entries may differ. A difference means the project builds with a jar that is not the
2839+
one the patch was made from (an internal rebuild under the same coordinates, say), so
2840+
the service's jar would change more than the patch: the vendoring is refused with
2841+
`vendor_prebuilt_integrity_mismatch`, the detail naming up to three such members, and
2842+
nothing is committed or wired. With no local copy there is nothing to compare. An
2843+
online re-run over a committed tree makes the same comparison with the committed jar
2844+
and needs no registry for the jar either. Upstream metadata (the pom, its parents,
2845+
Gradle module metadata, classifier jars) is still read from the local caches and the
2846+
registry, as before.
28462847

28472848
Jars are read within fixed limits, counted on the bytes actually inflated and on the
28482849
archive's own entry count, never on the sizes an archive declares: 200,000 entries
@@ -3221,6 +3222,18 @@ or `mvn install` rebuilt it), lacks a file, or is a swapped jar whose original t
32213222
project never backed up is left as it is with `gradle_m2_copy_not_restored`, and
32223223
`remove` still drops the record.
32233224

3225+
A project's `.mvn/maven.config` chooses where these commands write. For a Maven
3226+
build, `-Dmaven.repo.local` there names the local repository, so it can point `apply`,
3227+
`rollback` and `remove` at any directory laid out as a Maven repository, one outside
3228+
the project and the home directory included, exactly as it points Maven there when the
3229+
project is built. What socket-patch does in that directory is what it does in
3230+
`~/.m2`: it replaces a jar (or a file of a version directory) whose content is the
3231+
known original of a patch record with the patch service's build of it, rewrites the
3232+
checksum files beside it (`.sha1`, `.md5`) to match, and puts both back on rollback.
3233+
It writes nothing else there. Anyone who points a build's local repository somewhere
3234+
has chosen that for Maven as well. `MAVEN_REPO_LOCAL` takes the choice back: it names
3235+
the repository whatever the project's config says.
3236+
32243237
Before a swap the service's jar is compared with each installed jar, member by
32253238
member, hashing as it goes: every entry the JVM would load must hold the same content
32263239
in both, whatever unix mode the entry carries (the JVM ignores it, so an entry with
@@ -3410,7 +3423,7 @@ with `reason: <reason>: `:
34103423
| `vendor_jvm_upstream_unavailable` | refusal | `classifier_unavailable` (a declared classifier jar no cache or registry has), `module_unavailable` (the pom declares Gradle module metadata that cannot be sourced), `pom_unavailable`, `verification_metadata_unavailable`; for a suffixed Maven / sbt pom also `suffix_unavailable` (the upstream pom computes its own version), `parent_unavailable` (a first vendoring whose upstream parent poms are in no local cache and cannot be fetched, so the suffixed pom cannot be checked) and `inherited_version_unresolvable` (a parent pom names `${project.version}` where the suffixed pom cannot declare the base version instead: in a profile, a management key or a repository URL) |
34113424
| `vendor_jvm_degraded` | applied, VEX withheld | `gradle_unscanned_build_logic`, `unwired_build_logic` (a nonliteral included build), `settings_plugins_unwired`, `classifier_unpatched_copy` (a classifier jar carries an unpatched copy of a patched member, or cannot be read to check for one), `verification_parent_chain_unhandled`, `gradle_lock_overrides_vendored` (a dependency lock of the build, buildscript and settings classpath locks included, pins the module at a version no vendored row serves), `gradle_settings_lock_unrouted` (a `settings-gradle.lockfile` locks the module but that build's settings script does not hold the in-block repository entry for it), `gradle_lock_unreadable` (a lock file, or a followed custom `lockFile`, is missing, unreadable, outside the checkout or not UTF-8), `gradle_custom_lock_file` (a `lockFile` location that cannot be followed statically: anything but a literal `file(…)` in a project's own build script), `gradle_wiring_uncommitted` (VEX liveness only, never reported by `vendor`: the committed settings files, index, derived `maven-metadata.xml`, script or verification file lack wiring a re-plan would write, such as a removed apply line or in-block entry; the git hygiene files do not count), `conflicting_managed_version` / `management_unresolved` (Maven reactor: an imported BOM or an out-of-checkout parent manages the artifact at another version, or its POM is unavailable; that local root is not pinned), `selection_undetermined` (Maven reactor: what one or more modules resolve cannot be read, so no pin is written where that is so and one already there is left as it is; one event however many modules, naming the first and counting the rest), `pin_would_move_module` (Maven reactor: a parent pom resolves the base version itself above a module that resolves another version, so the parent takes no pin. See [Maven version selection](#maven-version-selection-hosted-and-vendored-maven)) |
34123425
| `vendor_jvm_note` | applied, informational | `range_declared` (a range, prefix or rich selector lists versions from the derived `maven-metadata.xml`), `ide_sources_unavailable` |
3413-
| `vendor_jvm_upstream_unverified` | warning | Upstream metadata was taken offline, or from a local cache while the registry published no checksum for it (a parent pom from a corporate repository), and not authenticated against registry checksums. Also reported by a first vendoring that could get no registry-verified upstream jar: the members the patch does not touch were compared with the local repository's jar, or, with none, not compared at all. |
3426+
| `vendor_jvm_upstream_unverified` | warning | Upstream metadata was taken offline, or from a local cache while the registry published no checksum for it (a parent pom from a corporate repository), and not authenticated against registry checksums. |
34143427
| `vendor_jvm_unattested` | warning (`vendor --check`) | A Maven reactor entry is intact and wired, but a declaration may still build the base release (an executable classifier or type copy, a version a property, profile or unpinned local root may move), so `vex` does not attest it. The entry stays `verified`; the detail names the purl and the declarations (`<pom>:<line>`). |
34153428

34163429
The Maven half of a root (single-module, reactor or mixed) also reports

0 commit comments

Comments
 (0)