Repository navigation
Vendor a platform-locked gem once one platform has a patched build, with upstream's gem for the rest #2342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Mikola Lysenko (mikolalysenko)
merged 30 commits into
feat/gem-complete-registry
from
feat/gem-vendored-partial
Nov 30, 2026
Merged
Vendor a platform-locked gem once one platform has a patched build, with upstream's gem for the rest #2342
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
81f35b0
Vendor a gem locked as platform gems once one locked platform has a p…
mikolalysenko e23d017
Report a vendored tree of upstream's gem as hosted mode reports such …
mikolalysenko 09da5fb
Cover a gem vendored with upstream's gem for a platform at the CLI level
mikolalysenko fc5c5b1
Run a gem vendored with upstream's gem for a platform on real Bundler
mikolalysenko 662c926
Document vendoring a platform-locked gem with upstream's gem for a pl…
mikolalysenko 0a2f4b7
Vendor real nokogiri with upstream's gem for a platform in the e2e sc…
mikolalysenko 445f752
Keep the gem's line in a helper module, and preview a wired lock by t…
mikolalysenko 986a963
Never make an intact vendored gem worse when its fix's list moves
mikolalysenko f218b63
Vendor a damaged gem copy from the list once the list moved, and coun…
mikolalysenko e3ea8de
Document how a vendored gem follows its list without being made worse
mikolalysenko 373ce9d
Say in the nokogiri script that vendored mode follows no redirect
mikolalysenko 73a2a0d
Say a vendored gem stays in force only when it still stands, and drop…
mikolalysenko 85edd98
Plan the lists of vendored gems with the download plan, and settle a …
mikolalysenko b7c5323
Document the plan's shared request, the in-force check and the dry ru…
mikolalysenko c34eb69
Answer the plan's reference-only positions from its batch, and write …
mikolalysenko d108bc2
Plan reference positions by the backend's rule, and tally a replaced …
mikolalysenko 6910805
Plan a single reference-only position too
mikolalysenko 5412a44
Name what works in three texts of a platform-locked vendored gem
mikolalysenko 31594cb
Leave a vendored tree whose purl the view attests to that record
mikolalysenko 76bb806
Ask for each vendored gem's list by its own request, and write the me…
mikolalysenko 6ab6222
Document the per-gem list request, the handed list and the metadata w…
mikolalysenko 70cc021
Say what released 5.1.0 does on a copy vendored as platform gems
mikolalysenko 001e279
Finish every copy of a platform-locked gem with one function, and ask…
mikolalysenko a8b26e5
Document how a platform-locked copy is finished and that its list che…
mikolalysenko e141f97
Merge branch 'feat/gem-complete-registry' into feat/gem-vendored-partial
mikolalysenko 0be8bc9
Ask git about a platform-locked copy only where trees are about to be…
mikolalysenko 72463e6
Document where git is asked about a platform-locked copy
mikolalysenko 614513e
Say a wired copy's pending skip in a scan's dry run too
claude 4b7a0b9
Expect the pending skip from a wired copy's preview in the no-record …
claude efe0b78
Merge branch 'feat/gem-complete-registry' into feat/gem-vendored-partial
mikolalysenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
148 changes: 148 additions & 0 deletions
148
crates/socket-patch-cli/src/commands/gem_build_lines.rs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| //! The line a run prints for a gem a Bundler lock names as precompiled | ||
| //! platform builds: which of them are patched. Hosted mode says it of the | ||
| //! locked builds of a pin, vendored mode of the trees of a vendored copy. | ||
|
|
||
| use socket_patch_core::hosted::engine::PinReport; | ||
| use socket_patch_core::utils::purl::purl_parts; | ||
|
|
||
| /// Which builds are patched of each gem the Bundler lock names as | ||
| /// precompiled platform builds, one line per gem. Such a gem takes its | ||
| /// patch registry as the one source of every locked build, and the | ||
| /// registry serves a patched build for some platforms and upstream's own | ||
| /// gem for the rest, so the summary's "1 package" does not say which | ||
| /// machines run patched code. Not a warning: nothing here needs doing. | ||
| /// | ||
| /// - `nokogiri 1.19.3: patched for arm64-darwin, x86_64-linux-gnu` | ||
| /// - a platform with no patched build yet: `…: patched for | ||
| /// x86_64-linux-gnu; upstream gem kept for arm64-darwin (no patched | ||
| /// build yet)` | ||
| /// - a patched build that this run found for a platform of a lock already | ||
| /// on the registry: `…: now also patched for arm64-darwin; already | ||
| /// patched for x86_64-linux-gnu` | ||
| /// - a build this run put back on upstream's gem, because the patched | ||
| /// build its lock entry pinned was withdrawn: `…: patched for | ||
| /// arm64-darwin; upstream gem back for x86_64-linux-gnu (its patched | ||
| /// build was withdrawn)`, before the builds that never had one | ||
| /// - a gem left where it is under one of the quiet skips | ||
| /// (`engine::is_quiet_gem_skip`), in the skip's own sentence: `…: no | ||
| /// patched build yet for arm64-darwin, x86_64-linux-gnu; left on its | ||
| /// upstream registry` | ||
| /// | ||
| /// The ruby-platform gem, where the lock names it beside the platform | ||
| /// builds, is the platform `ruby`. A dry run says `would be patched for` | ||
| /// (`would also be patched for`) of the builds a wet run would put in | ||
| /// place, and `upstream gem would be back for` of those it would put back. | ||
| /// `reports` are the run's pins per locked build (`engine::pin_reports`), | ||
| /// `skipped` its skips. Vendored mode says the same of a gem it vendors | ||
| /// as platform gems, with a tree in place of a locked build | ||
| /// ([`format_vendored_gem_build_lines`]). | ||
| pub(crate) fn format_gem_build_lines( | ||
| reports: &[socket_patch_core::hosted::engine::PinReport], | ||
| skipped: &[socket_patch_core::hosted::engine::SkippedPatch], | ||
| dry_run: bool, | ||
| ) -> Vec<String> { | ||
| use socket_patch_core::hosted::engine::{is_quiet_gem_skip, PinReport}; | ||
| // Per gem patch, in report order: its locked builds. | ||
| let mut gems: Vec<(&str, Vec<&PinReport>)> = Vec::new(); | ||
| for report in reports { | ||
| let Some(gem_fix) = report.gem_fix.as_deref() else { | ||
| continue; | ||
| }; | ||
| match gems.iter_mut().find(|(fix, _)| *fix == gem_fix) { | ||
| Some((_, builds)) => builds.push(report), | ||
| None => gems.push((gem_fix, vec![report])), | ||
| } | ||
| } | ||
| let mut lines: Vec<String> = Vec::new(); | ||
| for (_, builds) in gems { | ||
| let Some((_, name, version)) = builds.first().and_then(|build| purl_parts(&build.purl)) | ||
| else { | ||
| continue; | ||
| }; | ||
| let platforms = |keep: &dyn Fn(&PinReport) -> bool| -> String { | ||
| let named: Vec<&str> = builds | ||
| .iter() | ||
| .filter(|build| keep(build)) | ||
| .map(|build| build.platform.as_deref().unwrap_or("ruby")) | ||
| .collect(); | ||
| named.join(", ") | ||
| }; | ||
| let now = platforms(&|build| build.uuid.is_some() && build.newly_patched); | ||
| let before = platforms(&|build| build.uuid.is_some() && !build.newly_patched); | ||
| let is_back = |build: &PinReport| build.uuid.is_none() && build.withdrawn; | ||
| let back = platforms(&is_back); | ||
| let kept = platforms(&|build| build.uuid.is_none() && !build.withdrawn); | ||
| let (first, also) = if dry_run { | ||
| ("would be patched for", "would also be patched for") | ||
| } else { | ||
| ("patched for", "now also patched for") | ||
| }; | ||
| let mut parts: Vec<String> = Vec::new(); | ||
| match (now.is_empty(), before.is_empty()) { | ||
| (false, true) => parts.push(format!("{first} {now}")), | ||
| (false, false) => { | ||
| parts.push(format!("{also} {now}")); | ||
| parts.push(format!("already patched for {before}")); | ||
| } | ||
| (true, false) => parts.push(format!("patched for {before}")), | ||
| // No locked build is patched: the lock followed a withdrawn | ||
| // build back to upstream's gem. | ||
| (true, true) => {} | ||
| } | ||
| if !back.is_empty() { | ||
| let is = if dry_run { "would be back" } else { "back" }; | ||
| let why = match builds.iter().filter(|build| is_back(build)).count() { | ||
| 1 => "its patched build was withdrawn", | ||
| _ => "their patched builds were withdrawn", | ||
| }; | ||
| parts.push(format!("upstream gem {is} for {back} ({why})")); | ||
| } | ||
| if !kept.is_empty() { | ||
| parts.push(format!( | ||
| "upstream gem kept for {kept} (no patched build yet)" | ||
| )); | ||
| } | ||
| lines.push(format!("{name} {version}: {}", parts.join("; "))); | ||
| } | ||
| lines.extend( | ||
| skipped | ||
| .iter() | ||
| .filter(|skip| is_quiet_gem_skip(&skip.reason)) | ||
| .filter_map(|skip| skip.detail.clone()), | ||
| ); | ||
| lines | ||
| } | ||
|
|
||
| /// Which trees are patched of each gem vendored as platform gems that | ||
| /// holds upstream's own gem for a locked platform, or that this run | ||
| /// brought in step with the builds the patch registry lists: hosted | ||
| /// mode's line for such a gem, one per gem ([`format_gem_build_lines`]). | ||
| /// A gem whose every tree is a patched build says nothing here, as before. | ||
| /// `reports` are the run's reports per tree | ||
| /// (`crate::commands::vendor::gem_build_reports`). | ||
| pub(crate) fn format_vendored_gem_build_lines(reports: &[PinReport], dry_run: bool) -> Vec<String> { | ||
| let mut fixes: Vec<&str> = Vec::new(); | ||
| for report in reports { | ||
| if let Some(fix) = report.gem_fix.as_deref().filter(|fix| !fixes.contains(fix)) { | ||
| fixes.push(fix); | ||
| } | ||
| } | ||
| let mut said: Vec<PinReport> = Vec::new(); | ||
| for fix in fixes { | ||
| let of_gem = |report: &&PinReport| report.gem_fix.as_deref() == Some(fix); | ||
| let builds: Vec<&PinReport> = reports.iter().filter(of_gem).collect(); | ||
| let patched = |build: &&&PinReport| build.uuid.is_some(); | ||
| let gained = builds | ||
| .iter() | ||
| .filter(patched) | ||
| .any(|build| build.newly_patched) | ||
| && builds | ||
| .iter() | ||
| .filter(patched) | ||
| .any(|build| !build.newly_patched); | ||
| if gained || builds.iter().any(|build| build.uuid.is_none()) { | ||
| said.extend(builds.into_iter().cloned()); | ||
| } | ||
| } | ||
| format_gem_build_lines(&said, &[], dry_run) | ||
| } | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All-upstream follow omits the gem line
Low Severity
format_vendored_gem_build_linesprints a gem only when it still has an upstream tree or when some platforms were already patched and others became patched on this run. A copy that held only upstream trees and is brought fully in step (every locked platform now patched) matches neither check, so the run’s “now also patched” line is omitted even though this is a list-follow.Reviewed by Cursor Bugbot for commit 6910805. Configure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[agent] PR shepherd: this is real.
moved_sourceslets a wired copy follow a list whose patched builds were all withdrawn back to upstream's gems, so a copy can hold only upstream trees. When builds are later published for every locked platform, every report isnewly_patchedand none is upstream, soformat_vendored_gem_build_linessays nothing.PinReportcan't tell that case apart from a first vendor of an all-patched gem, which also prints nothing by design. Fixing it means carrying "the ledger held this gem before" into the report: a field onPinReport(16 constructors) plus an event detail thatgem_build_reports_ofreads back. I've left that to the PR's author rather than add a field to a core type in a shepherd pass. The thread stays open.Generated by Claude Code