Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion crates/socket-patch-cli/CLI_CONTRACT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2628,7 +2628,7 @@ command's integration tests check its output.
| `vendor_uuid_mismatch` | `skipped` | repair: the manifest's patch uuid moved past the vendored artifact — a re-vendor (`vendor` / `scan --mode vendored`) is pending; repair does not cross patch generations. |
| `content_mismatch_overwritten` | `skipped` (warning) | apply (explicit `--allow-patch-conflicts` / `--force`): a file matched NEITHER beforeHash nor afterHash and was overwritten with the full verified patched content. This includes a file the patch adds (empty beforeHash) that already exists with other content. `--strict` turns this case into a `failed` event instead. Agent-mode `get` / `scan --json` carry it as a `(content_mismatch_overwritten) …` `warnings[]` entry (#1004). |
| `vendor_lock_checksums_unsupported` / `vendor_stale_lock_checksum` | `failed` | vendor (gem): an ambiguous/platform CHECKSUMS entry, or a v1-wired lock whose stale token blocks the hot path (run `vendor --revert` + re-vendor). |
| `platform_gem_unsupported` | `failed` | vendor / scan / get `--mode vendored` (gem): a precompiled platform gem that cannot be vendored. `Gemfile.lock` pins the gem as platform gems (`nokogiri (1.18.10-x86_64-linux-gnu)`) and also holds the plain `<name> (<ver>)` entry of the `ruby` platform, which no prebuilt tree serves (the detail names it; `bundle lock --remove-platform ruby` drops it); or it pins the gem as platform gems and its `BUNDLED WITH` is absent or names a Bundler older than 2.3, the oldest the vendored layout is verified on (the detail names the version needed; `bundle update --bundler` re-locks); or the installed copy is a platform gem and the lock names no platform for the gem; or the patch record is for one platform's build (`?platform=<native>`). Nothing is written. A locked platform the patch service has no prebuild for is not this failure: see `vendor_prebuilt_platform_pending`. |
| `platform_gem_unsupported` | `failed` | vendor / scan / get `--mode vendored` (gem): a precompiled platform gem that cannot be vendored. `Gemfile.lock` pins the gem as platform gems (`nokogiri (1.18.10-x86_64-linux-gnu)`) and also holds the plain `<name> (<ver>)` entry of the `ruby` platform, which no prebuilt tree serves. Bundler keeps that entry for `ruby` and for every other locked platform that none of the gem's platform builds serves (a gem with no 32-bit ARM build under a lock that names `arm-linux-gnu`). The detail names the plain entry and each such platform under the lock's `PLATFORMS`, with the command that removes them (`bundle lock --remove-platform arm-linux-gnu ruby`); it names `ruby` only when the lock holds it, and `<platform>` when the lock shows no such platform. A locked platform of a system other than Linux, macOS, Windows or Java, or one that is not a plain platform name, is not named: the detail then adds that another locked platform may keep the entry; or it pins the gem as platform gems and its `BUNDLED WITH` is absent or names a Bundler older than 2.3, the oldest the vendored layout is verified on (the detail names the version needed; `bundle update --bundler` re-locks); or the installed copy is a platform gem and the lock names no platform for the gem; or the patch record is for one platform's build (`?platform=<native>`). Nothing is written. A locked platform the patch service has no prebuild for is not this failure: see `vendor_prebuilt_platform_pending`. |
| `redirect_unattributable` | `skipped` (hosted event) | scan/get `--mode hosted`: the rewriters would pin the patch, but lockfile discovery over the result reads that pin as contested (another lock or requirements file resolves the same version elsewhere, or the pin is not one the package manager consumes), so `vex`, `rollback`, `remove` and `vendor` would refuse it. The candidate is left out of the rewrite, so nothing is written for it; the detail carries discovery's findings. Exit code unchanged. |
| `redirect_mirror_unsupported` / `redirect_mirror_url_refused` | `skipped` (hosted event) + `warnings[]` | **Experimental** (patch mirror). scan/get `--mode hosted` with `--patch-mirror-url`: the patch's ecosystem cannot be served through a mirror (`redirect_mirror_unsupported`: Cargo, NuGet; use `--mode vendored`), or its reference could not be moved onto the mirror (`redirect_mirror_url_refused`). Nothing is written for it. See "Patch mirror (experimental)". |
| `redirect_mirror_unavailable` | `skipped` (hosted event) + `warnings[]` | **Experimental** (patch mirror). scan/get `--mode hosted` with `--patch-mirror-url`: the mirror did not serve the reference the run asked it for, or could not be reached. That reference is skipped and nothing is written for it. One warning per package, or a single warning about the mirror when it served none of the references it was asked about. |
Expand Down
32 changes: 32 additions & 0 deletions crates/socket-patch-core/src/formats/gem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub(crate) mod gemspec;
pub(crate) mod hosted;
pub(crate) mod manifest;
pub(crate) mod mirror;
pub(crate) mod platform;
pub(crate) mod ruby;

use std::collections::{BTreeSet, HashMap, HashSet};
Expand Down Expand Up @@ -677,6 +678,26 @@ pub(crate) fn listed_specs(lock: &str) -> HashSet<(&str, &str)> {
.collect()
}

/// The platforms the Bundler lock `lock` names under `PLATFORMS`, in file
/// order, as written (`ruby` among them when it is locked). Empty for a
/// lock without the section. CRLF is tolerated.
pub(crate) fn locked_platforms(lock: &str) -> Vec<&str> {
let mut platforms = Vec::new();
let mut in_platforms = false;
for raw in lock.split('\n') {
let line = raw.strip_suffix('\r').unwrap_or(raw);
if line.trim().is_empty() {
continue;
}
if !line.starts_with(' ') {
in_platforms = line.trim_end() == "PLATFORMS";
} else if in_platforms {
platforms.push(line.trim());
}
}
platforms
}

/// The plain gem-token charset (letters, digits, `.`, `_`, `-`). The vendor
/// backend applies it before embedding coordinates into Ruby source and lock
/// line grammar (see the SECURITY note in `crate::vendor::gem`'s
Expand Down Expand Up @@ -748,6 +769,17 @@ fn parse_checksum(entry: &str) -> Option<((&str, &str), Option<String>)> {
mod tests {
use super::*;

#[test]
fn locked_platforms_are_the_lines_of_the_platforms_section() {
let lock = "GEM\n remote: https://rubygems.org/\n specs:\n rack (3.2.6)\n\nPLATFORMS\n arm64-darwin\n ruby\n\nDEPENDENCIES\n rack\n\nBUNDLED WITH\n 2.5.22\n";
assert_eq!(locked_platforms(lock), ["arm64-darwin", "ruby"]);
assert_eq!(
locked_platforms(&lock.replace('\n', "\r\n")),
["arm64-darwin", "ruby"]
);
assert!(locked_platforms("GEM\n specs:\n rack (3.2.6)\n").is_empty());
}

/// Section spans, remote line numbers and DEPENDENCIES entries: what the
/// hosted lock writer splices by. Blank (and whitespace-only) separator
/// lines belong to the section they follow; a CRLF lock gives the same
Expand Down
Loading
Loading