Repository navigation
Remove hosted and vendored mode for gems locked as platform gems - #2226
Draft
Mikola Lysenko (mikolalysenko) wants to merge 2 commits into
Draft
Mikola Lysenko (mikolalysenko) wants to merge 2 commits into
Mikola Lysenko (mikolalysenko) wants to merge 2 commits into
Conversation
Vendored mode could vendor a gem that Gemfile.lock pins as precompiled platform gems (`nokogiri (1.18.10-x86_64-linux-gnu)`). It did so from artifacts the patch service attached to the gem's ruby-platform patch: one patched platform gem and one stub gemspec per platform (`gem-platform`, `gem-platform-stub-gemspec`, each naming its `platform`). The patch service is dropping those artifacts, so the code that reads them goes. The support was merged after 5.1.0 and never released. Removed: - the vendored layout of one tree per platform (`<name>-<version>/<platform>/`): its lock edit, the checks of the trees in `vendor --check`, `vex` and `repair`, the restore of a damaged copy, ledger recovery, and the `gemPlatforms` field of a ledger entry; - the `platform` of a served artifact, and the request that listed a patch's artifacts without downloading its archive; - the codes `vendor_prebuilt_platform_pending` and `vendor_gem_gitignore_neutralized`, which nothing else raised; - lockfile discovery of platform specs in a vendored `PATH` section; - what followed a vendored unwind for such a gem only: the refresh of installed platform builds and the cache-dir check of each platform build's archive; - the vendored legs of the nokogiri workflow, the vendored scenario of its script, and the real-Bundler capstone. A gem that is installed as a platform gem is refused with `platform_gem_unsupported` again, as in 5.1.0. The detail names agent mode, which patches a precompiled gem where it is installed. A project that a development build wired this way can still be undone. Reading its ledger does not fail: the `gemPlatforms` field is unknown now and ignored. The revert of a gem entry still reads the `CHECKSUMS` record that build wrote, an array of lines on each side, and pairs each line with the original of the same entry. So `rollback`, `vendor --revert` and `scan --prune` put the Gemfile and the lock back byte for byte and remove the copies. Nothing writes the array form any more. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Hosted mode could redirect a gem that Gemfile.lock pins as precompiled
platform gems. It moved every platform entry of the gem to the patch
registry and pinned each to a patched platform gem that the patch
service listed in the grant (`gemPlatforms`, one `{platform,
gemChecksumSha256}` per platform). The patch service is dropping that
list, so the code that reads it goes. The support was merged after 5.1.0
and never released.
Removed:
- `gemPlatforms` in the registry override's identifiers, and its checks
in the grant;
- the rewrite of platform entries and their `CHECKSUMS` lines, and the
restore that put them back on the upstream registry;
- lockfile discovery of platform specs under a Socket `GEM` section as
one hosted pin;
- the stale-install guard and the unwind's refresh for installed
platform builds, with the reader of the builds a lock names that they
shared;
- the hosted legs of the nokogiri workflow, the hosted scenario of its
script with the stand-in patch service, and the real-Bundler capstones.
A gem whose lock holds platform builds of the patched version is skipped
with `redirect_gem_platform_unsupported` again, in the words of 5.1.0:
"<lock> locks platform-specific builds of <name> <version> (`<name>
(<version>-<platform>)`) — the patch registry serves only the ruby
platform gem; redirect skipped". Neither file changes for it.
Kept, because it is not about the removed artifacts:
- A hosted run still reads a gem that the lock names only as platform
builds from the lock alone, so the skip is reported on a fresh
checkout too, by the scan, by `get --mode hosted` and by the in-memory
engine. 5.1.0 found such a gem only through an installed copy.
- The closing totals of a scan still count a refused platform-only gem
as left to patch, in hosted and in vendored mode.
- Rollback's reinstall note for vendored gems, which is now computed for
the ruby-platform gem alone, as vendored gems are.
- The check of a rules_ruby hub's `gem_checksums` is handed the one
build the redirect pins.
The golden fixture `gem/bundler/platform-locked` holds the skip, and the
disk and in-memory engines are compared on it.
A pair that a development build redirected this way is not unwound. No
command changes it: a hosted scan rewrites nothing for the gem, and
`rollback` and `remove` stop with `hosted_wiring_contested` (or
`hosted_restore_refused` when the lock has the ruby-platform entry
beside the platform ones), which name the lock lines and version control
as the way back. Tests hold both that and the vendored undo.
A reference response that still carries the retired fields (`platform`
on an artifact, the `gem-platform` artifact kinds, `gemPlatforms`) is
read as the grant of the ruby-platform gem: none of them is parsed, so
none can fail the response.
The CLI contract and the ecosystems guide describe the skip and the
vendored refusal as they are now, and `platform_gem_unsupported` has a
row of its own in the contract.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Removes hosted and vendored support for a gem that
Gemfile.lockpins as precompiled platform gems (nokogiri (1.18.10-x86_64-linux-gnu)). That support was merged in #2150 and #2154 after 5.1.0 and has not been released. Agent mode is not touched.Why
Both modes read per-platform "prebuilds" that the patch service attached to a gem's ruby-platform patch:
gemPlatformsin the grant, and thegem-platformandgem-platform-stub-gemspecartifacts. Socket's backend is dropping those. A platform gem is going to be published as a patch of its own instead, one per platform, and the CLI will be taught that shape separately. Until then nothing serves what this code reads, so it could never run, and it should not ship in a release as if it did.What a platform-locked gem does after this (as in 5.1.0)
redirect_gem_platform_unsupported, exit 0, no file changed. The scan's closing totals count the gem as left to patch.platform_gem_unsupported, exit 1; the detail names agent mode, which patches a precompiled gem where it is installed. With nothing installed (a fresh checkout), the gem is not seen and nothing is reported. With a ruby-platform entry beside the platform ones, the lock edit fails and nothing is written.One thing is better than 5.1.0 and is kept: a hosted run reads a gem that the lock names only as platform builds from the lock alone, so the skip is reported on a fresh checkout too. 5.1.0 found such a gem only through an installed copy and said nothing otherwise.
What is removed
Net +1,596 / −9,512 lines in 58 files. The added lines are mostly the pre-feature code coming back where the feature had rewritten it, plus the tests below.
gemPlatformsin the registry override and its grant checks; the rewrite of platform entries and theirCHECKSUMSlines, and the restore that put them back; lockfile discovery of platform specs under a SocketGEMsection; the stale-install guard and the unwind refresh for installed platform builds.<name>-<version>/<platform>/) with its lock edit, its checks invendor --check,vexandrepair, the restore of a damaged copy and ledger recovery; theplatformof a served artifact; the codesvendor_prebuilt_platform_pendingandvendor_gem_gitignore_neutralized, which nothing else raised.tests/nokogiri/nokogiri_e2e.rb, the stand-in patch service, and the real-Bundler capstones for platform locks.CLI_CONTRACT.mdanddocs/ecosystems.mddescribe the skip and the refusal as they are now.platform_gem_unsupportedgets a contract row of its own.Follow-ups to the two PRs:
A project that a development build already wired
gemPlatformsfield is ignored on read, and the revert still reads the array-formCHECKSUMSrecord, sorollbackputs the Gemfile and the lock back byte for byte and removes the copies. A re-scan fails withvendor_stale_lock_checksum, which namesvendor --revert.rollbackandremovestop withhosted_wiring_contested(orhosted_restore_refusedwhen the lock has the ruby-platform entry beside the platform ones). Both name the lock lines and version control as the way back.Each of these is held by a test.
Testing
cargo fmt --all -- --checkandcargo clippy --locked --workspace --all-features -- -D warnings: clean.cargo test --locked -p socket-patch-core --lib --no-fail-fast: 8,380 passed, 0 failed. Coreredirect_goldenandupstream_restore_golden: 1 + 62 passed.cargo test --locked -p socket-patch-cli --no-fail-fast, all 218 binaries: 5,714 passed, 3 failed, 486 ignored.e2e_redirect_gem_stale_install(62) andhosted_memory_parity(46) pass; the full suite was not repeated after that fix.e2e_vendor_cargo_build, which this branch does not touch:Bad CPU type in executable, an x86_64 toolchain on an arm64 Mac.e2e_redirect_gem_buildande2e_vendor_gem_buildwith--ignored: 49 + 12 passed, one version-gated skip.redirect/gem/bundler/platform-locked, holds the hosted skip; the disk and in-memory engines are compared on it.Not run: the
docker-e2esuites, the remaining nokogiri workflow legs, JRuby and Windows. CI covers them.vendor --revertandscan --pruneon a development build's vendored state take the same revert path asrollbackbut were not run.Review findings, not fixed yet
This PR is a draft.
/code-review highfound no blocking correctness bug and no dangling reference, and reported the items below. Each is to be fixed, or answered here, before the PR is marked ready.foo (1.0)and a gem home that holds onlyfoo-1.0-x86_64-linux, the scan would call the gem stale and try to refresh a file the registry does not serve. The guard should look for the ruby-platform leaf alone.docs/ecosystems.md, the native-extensions table: the Vendored row says "Use hosted or agent mode" although hosted skips a precompiled gem too, and it does not nameplatform_gem_unsupported.vendor/cachearchive can be reported twice when two record purls of one gem share an installed copy, because the covered set is keyed by purl again and not by archive path.CHECKSUMSrecord is still read so that a development build's vendored state can be undone, while the hosted state of the same builds is refused. Either both get a way back or neither needs the second record grammar.🤖 Generated with Claude Code