Skip to content
Merged
Show file tree
Hide file tree
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 Nov 28, 2026
e23d017
Report a vendored tree of upstream's gem as hosted mode reports such …
mikolalysenko Nov 28, 2026
09da5fb
Cover a gem vendored with upstream's gem for a platform at the CLI level
mikolalysenko Nov 28, 2026
fc5c5b1
Run a gem vendored with upstream's gem for a platform on real Bundler
mikolalysenko Nov 28, 2026
662c926
Document vendoring a platform-locked gem with upstream's gem for a pl…
mikolalysenko Nov 28, 2026
0a2f4b7
Vendor real nokogiri with upstream's gem for a platform in the e2e sc…
mikolalysenko Nov 28, 2026
445f752
Keep the gem's line in a helper module, and preview a wired lock by t…
mikolalysenko Nov 28, 2026
986a963
Never make an intact vendored gem worse when its fix's list moves
mikolalysenko Nov 28, 2026
f218b63
Vendor a damaged gem copy from the list once the list moved, and coun…
mikolalysenko Nov 28, 2026
e3ea8de
Document how a vendored gem follows its list without being made worse
mikolalysenko Nov 28, 2026
373ce9d
Say in the nokogiri script that vendored mode follows no redirect
mikolalysenko Nov 28, 2026
73a2a0d
Say a vendored gem stays in force only when it still stands, and drop…
mikolalysenko Nov 28, 2026
85edd98
Plan the lists of vendored gems with the download plan, and settle a …
mikolalysenko Nov 28, 2026
b7c5323
Document the plan's shared request, the in-force check and the dry ru…
mikolalysenko Nov 28, 2026
c34eb69
Answer the plan's reference-only positions from its batch, and write …
mikolalysenko Nov 28, 2026
d108bc2
Plan reference positions by the backend's rule, and tally a replaced …
mikolalysenko Nov 28, 2026
6910805
Plan a single reference-only position too
mikolalysenko Nov 28, 2026
5412a44
Name what works in three texts of a platform-locked vendored gem
mikolalysenko Nov 28, 2026
31594cb
Leave a vendored tree whose purl the view attests to that record
mikolalysenko Nov 28, 2026
76bb806
Ask for each vendored gem's list by its own request, and write the me…
mikolalysenko Nov 28, 2026
6ab6222
Document the per-gem list request, the handed list and the metadata w…
mikolalysenko Nov 28, 2026
70cc021
Say what released 5.1.0 does on a copy vendored as platform gems
mikolalysenko Nov 28, 2026
001e279
Finish every copy of a platform-locked gem with one function, and ask…
mikolalysenko Nov 28, 2026
a8b26e5
Document how a platform-locked copy is finished and that its list che…
mikolalysenko Nov 28, 2026
e141f97
Merge branch 'feat/gem-complete-registry' into feat/gem-vendored-partial
mikolalysenko Nov 28, 2026
0be8bc9
Ask git about a platform-locked copy only where trees are about to be…
mikolalysenko Nov 28, 2026
72463e6
Document where git is asked about a platform-locked copy
mikolalysenko Nov 28, 2026
614513e
Say a wired copy's pending skip in a scan's dry run too
claude Nov 29, 2026
4b7a0b9
Expect the pending skip from a wired copy's preview in the no-record …
claude Nov 29, 2026
efe0b78
Merge branch 'feat/gem-complete-registry' into feat/gem-vendored-partial
mikolalysenko Nov 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/nokogiri-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,14 @@ jobs:
- {os: macos-latest, ruby: '3.4', nokogiri: '1.18.10', install: precompiled, cli: build, args: '--scenarios vendored', note: vendored}
- {os: ubuntu-latest, ruby: 'jruby-9.4', nokogiri: '1.18.10', install: java, args: '--scenarios vendored', note: vendored}
# The same with a locked platform that has no patched build at
# first: nothing is vendored until the service has it.
- {os: ubuntu-latest, ruby: '3.4', nokogiri: '1.18.10', install: precompiled, args: '--scenarios vendored --add-platform aarch64-linux-gnu --pass-through others', note: 'vendored, a platform passed through'}
# first: the scan commits upstream's own gem for it, which the
# stand-in's registry serves, beside the patched build of the
# other, and the next scan takes the patched build once the
# service has it. `own` is the runner's platform: the frozen
# install loads upstream's nokogiri from the committed tree, then
# the patched one.
- {os: ubuntu-latest, ruby: '3.4', nokogiri: '1.18.10', install: precompiled, args: '--scenarios vendored --add-platform aarch64-linux-gnu --pass-through others', note: 'vendored, another platform passed through'}
- {os: ubuntu-latest, ruby: '3.4', nokogiri: '1.18.10', install: precompiled, args: '--scenarios vendored --add-platform aarch64-linux-gnu --pass-through own', note: 'vendored, own platform passed through'}
needs: static-cli
runs-on: ${{ vars.DISABLE_DEPOT_RUNNERS != 'true' && matrix.os == 'ubuntu-latest' && 'depot-ubuntu-24.04-4' || matrix.os }}
timeout-minutes: 60
Expand Down
13 changes: 8 additions & 5 deletions crates/socket-patch-cli/CLI_CONTRACT.md

Large diffs are not rendered by default.

148 changes: 148 additions & 0 deletions crates/socket-patch-cli/src/commands/gem_build_lines.rs
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()) {

Copy link
Copy Markdown

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_lines prints 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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6910805. Configure here.

Copy link
Copy Markdown
Collaborator Author

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_sources lets 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 is newly_patched and none is upstream, so format_vendored_gem_build_lines says nothing. PinReport can'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 on PinReport (16 constructors) plus an event detail that gem_build_reports_of reads 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

said.extend(builds.into_iter().cloned());
}
}
format_gem_build_lines(&said, &[], dry_run)
}
1 change: 1 addition & 0 deletions crates/socket-patch-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pub mod apply;
pub(crate) mod composer_hints;
pub(crate) mod context;
pub(crate) mod fetch_stage;
pub(crate) mod gem_build_lines;
pub(crate) mod gem_refresh;
pub mod get;
pub mod hosted_bundle;
Expand Down
108 changes: 2 additions & 106 deletions crates/socket-patch-cli/src/commands/scan/hosted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use socket_patch_core::patch::redirect::DepOverride;
use socket_patch_core::utils::concurrent::api_concurrency;
use socket_patch_core::utils::purl::purl_parts;

use crate::commands::gem_build_lines::format_gem_build_lines;

use crate::commands::agent_download::tag_mode;
use crate::commands::gem_refresh::{self, StaleGem};
use crate::commands::vex::generate_vex_from_manifest_path;
Expand Down Expand Up @@ -3917,112 +3919,6 @@ fn format_gem_manifest_edits(
.collect()
}

/// 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.
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
}

/// What wiring a gem to its patch source costs the project's update
/// workflow, said once per run under [`format_gem_manifest_edits`]' lines.
///
Expand Down
Loading
Loading