Repository navigation
Patch gems locked as platform gems: patched builds where they exist, upstream's gem elsewhere - #2273
Open
Mikola Lysenko (mikolalysenko) wants to merge 108 commits into
Open
Mikola Lysenko (mikolalysenko) wants to merge 108 commits into
Mikola Lysenko (mikolalysenko) wants to merge 108 commits into
Conversation
A gem patch's reference now lists every platform gem of the gem's version (`registryOverride.identifiers.gemBuilds`): for each platform the sha256 the patch registry serves and, where there is a patched build, the patch it comes from. A platform with none is served as upstream's own gem, which the registry lists and hands on unchanged. The registry URL carries the snapshot the list was made at (`…/<uuid>/s/<n>`); a later reference names a newer one. This replaces the list of patched platforms only (`gemPlatforms`), under which a lock moved only when every locked platform had a patched build, and one platform without one kept the whole gem unpatched. The gem rewriter: - moves every locked build to the registry together as soon as one of them is patched, each pinned to the sha256 the registry serves for it (a platform still on upstream's gem keeps the sha256 it had); - leaves the gem where it is, with no warning, while no locked build is patched: moving it would gain nothing (`gem_unpatched`); - still skips with `redirect_gem_platform_unsupported` when the registry does not list a locked platform, or the reference carries no list at all (a patch of the ruby gem alone, as before); - reports per locked build which patch is in place and whether this run put it there (`gem_builds`). A registry URL is recognised with any snapshot or none, under any grant token, by the manifest wiring, the lock rewrite and lockfile discovery, so a pair an earlier run wired is refreshed in place when the snapshot changes. A snapshot URL is written closed by a slash, as Bundler writes every remote. The pin of a gem stays one per package. `engine::pin_reports` turns the confirmed pins into what a run reports: a gem locked as platform builds once per locked build, each patched build under its own patch, each build on upstream's gem with none. `engine::gem_unpatched_skips` gives the quiet skip of a gem that was left alone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A gem patch's registry lists every platform gem of the gem's version: a patched build for some platforms, upstream's own gem for the rest. A lock that names platform builds moves to it as one pin, so a run that reported that pin once said the gem was patched where one locked platform still installs upstream's gem, and it named the gem's patch where each patched build has a patch of its own. Both hosted engines report such a gem per locked build, from the one expansion of the confirmed pins they share (`engine::pin_reports`): - `scan --mode hosted` and `get --mode hosted` record one `applied` (`verified` on a dry run) event per patched build, under that build's own patch, with `details.gemFix` (the gem's patch), `details.platform` and, when the run put the build in place, `details.newlyPatched`. A build the registry serves as upstream's gem is one `skipped` event with no `uuid` (`errorCode: gem_upstream_build_kept`), which `summary` does not count. A person gets one plain line per gem on stdout, such as `nokogiri 1.19.3: patched for x86_64-linux-gnu; upstream gem kept for arm64-darwin (no patched build yet)`. On a terminal it breaks after a clause, not in the middle of a word. - The in-memory engine's `redirect.patches[]` holds the same rows (`pinned` per patched build, `upstream_kept` for the others), its `redirected[]` lists the patched builds with `gemFix`, `platform` and `newlyPatched`, and the new `upstreamBuilds[]` lists the rest. A gem left on its upstream registry because no locked build is patched yet is skipped under `redirect_gem_no_patched_build` in both engines, before the unpinned patches are worked out. It is no warning and never `redirect_unconfirmed`, and a person reads one plain line of it instead of the "No patches could be switched" block. Everything else keeps working on the pins, one per package: the package counts of the human summary, the rollout budget and the severity floor, the takeover, the stale-install probes, VEX and telemetry. The gem mock of the stale-install suite serves `gemBuilds`, with a patch per patched build, under a snapshot URL. The parity suite covers a build on upstream's gem and a gem with no patched build, from the new `platform-pass-through` fixture. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A hosted gem locked as platform builds keeps upstream's own gem for a platform with no patched build: its lock entry pins upstream's sha256, and a machine of that platform holds the right copy. The guard judged that copy like any other. Its cached archive passed only because the sha256 of upstream's gem was counted among the patched artifacts. With the archive pruned, the patch's file hashes called upstream's files stale, and the run downloaded upstream's gem from the registry to replace the install with the bytes it already held, and reported a refresh. Such a build is not judged at all, installed or committed to the cache dir: nothing is reported, nothing is refreshed, no gem is downloaded and no patch record is fetched for it. The patched artifacts are those of the patched builds alone. A platform with a patched build is handled as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Four refinements of how a gem patch's registry is read. The list is asked for. The patch service answers a reference request as it always has unless the request carries `gemBuilds: true`, so that a release that knows no list keeps getting the ruby gem's registry alone. Every package reference request now carries it: the hosted lookup, the vendored one, and the public-proxy route. The list names the ruby gem too (`platform: "ruby"`, the patch itself). The entry was refused as a malformed platform, which cost the gem its grant. It is accepted, and the ruby gem's checksum is read from it where it is there, so every locked build is pinned from the one list. A platform can be missing from the list for a while: the service leaves it out while its patched build is being made. A lock that names such a platform was skipped with a warning, as if the registry were wrong. The gem is now left as it is with no warning (`gem_unlisted`, skip reason `redirect_gem_build_pending`) and moves on a later run. The warning `redirect_gem_platform_unsupported` remains for a patch with no list at all and for the merged lock of Bundler < 2.2. The snapshot level of a registry URL is an opaque key of lowercase hex digits, not a number. It is recognised and never read for a meaning. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A gem the Bundler lock names as precompiled platform gems is vendored as one unpacked patched platform gem per locked platform. Those gems are no artifacts of the gem's patch: each patched platform gem has a patch of its own, and the gem patch's package reference lists every platform gem of the version (`registryOverride.identifiers.gemBuilds`), with the sha256 its registry serves and, where there is a patched build, the patch it comes from. The per-platform artifact kinds `gem-platform` and `gem-platform-stub-gemspec`, and the `platform` field of an artifact, are not served, so they are no longer read. Vendoring such a gem: - asks for the gem patch's reference once, to learn the patch of each locked platform's build, and for the references of those patches in ONE request (`ApiClient::fetch_vendor_references`); - downloads each platform's gem (its patch's `tarball`) and stub gemspec (`gem-stub-gemspec`), a few at a time, and verifies each against the digest its own reference states and the gem also against the sha256 the gem patch's registry lists for that platform. A mismatch refuses with `vendor_prebuilt_integrity_mismatch`, names the platform, and leaves an existing copy as it was; - keeps verifying the trees against the gem patch's record for the patched files they ship. No record of a platform's patch is fetched; - records per tree which patch it came from and the digests its downloads passed (`VendorEntry::gem_builds`, `gemBuilds` in the ledger). A restore fetches each tree again by its recorded patch, in one reference request, and checks the downloads against the recorded digests. While a locked platform has no patched build (the registry serves upstream's own gem for it, does not list it, or the reference carries no list) the gem is not vendored: nothing is downloaded or written, and the skip (`vendor_prebuilt_platform_pending`, as before) is one line that names the platforms. A gem already vendored stays in force as it is when the lock gains such a platform; a copy that is damaged and cannot be rebuilt is still the `vendor_prebuilt_required` failure. An entry that names only the platforms of its copy (`gemPlatforms`, written by builds before this one) still reads, verifies and reverts. It is no longer written: the next vendor run rebuilds the copy from each platform's patch and records them. A restore of such an entry says to vendor again, since nothing names a patch to fetch its trees by. `gems_locked_as_platform_gems` tells a caller which gems the lock resolves that way. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Each patched platform gem has a patch of its own (`pkg:gem/<name>@<version>?platform=<platform>`), which a package search returns beside the patch of the gem itself. Agent mode takes it for the installed copy of that platform. Vendored mode patches a gem through the patch of the gem itself, whose reference names the patched build of every locked platform, so there the platform gem's patch is no fix of its own: selected as one, it reached the gem backend and failed as `platform_gem_unsupported`, or made the gem's records ambiguous. `scan --mode vendored` now drops those patches from the batch offers and from the selection (`ScanPolicy::leave_out_platform_gem_patches`), and `get --mode vendored` from its search results, before anything is reported, downloaded or handed to the vendor engine. A platform gem's patch named by its UUID in `get` is the caller's exact intent and still reaches the backend's own refusal. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A gem vendored as platform gems is one committed copy, verified as one against the record of the gem's patch. What an install loads from it is one platform gem's tree, and each tree was built by a patch of its own, which the vendor ledger records. A VEX document that named the gem under the gem's patch said nothing a scanner could match to the platform gem it found, nor which patch built it. So the document names each platform gem (`pkg:gem/<name>@<version>?platform=<platform>`) under the patch of its tree, with the vulnerabilities of the gem patch's record: the fix is the same in every one of them. The copy is still verified once, before the view is widened, and nothing is fetched: the ledger entry says which patch built which tree. An entry that names no patch for its trees is attested as the gem itself, as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Hosted mode reports a gem locked as platform gems once per locked build, each under that build's own patch. Vendored mode reported it as one event under the gem's patch, so the two modes disagreed about which patches a run put in place, and telemetry never named the platform patches. The vendor engine now turns the outcome of such a gem into one counted event per platform gem (`pkg:gem/<name>@<version>?platform=<platform>`, `uuid` the platform's patch, `details.gemFix` the gem's patch, `details.platform`): `applied` when this run vendored or rebuilt it, `skipped` / `already_vendored` on an in-sync re-run, `verified` for a dry run of a recorded copy, and `verified` or `failed` per platform gem under `vendor --check`. The builds come from the entry the backend hands back, else from the ledger. The gem is still one package: the human summary, the in-sync line and the vendored count of telemetry take the events of one gem once. A retracted run drops the gem's advisories with its per-platform events. A gem with a locked platform that has no patched build prints the backend's one line as it is, without the `Skipping <purl>:` lead, and passes through whatever the ledger holds: the line already says which vendored copy stays in force. For a gem the lockfile pins hosted (a takeover, an eject) it says the pin stays instead of naming hosted mode as what to run; an eject is refused whole on it, as for any pin it cannot vendor. Two things kept such a gem from being vendored at all: - the installed-variant probe hashed a patched file in the installed copy, which is one platform's gem at most and often ships none of the patched files, and skipped the gem silently on a miss. A gem the lock resolves as platform gems is not probed; - a damaged copy of an entry that names no patch for its trees was sent to the restore, which has nothing to fetch them by. It goes to the backend, which rebuilds it from each platform's patch. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The patch service has a patch record per patched platform gem (`pkg:gem/<name>@<version>?platform=<platform>`), which a search returns beside the gem's own. Agent mode takes it for the installed copy of that platform. A hosted run patches a gem through the patch of the gem itself, whose reference lists the patched build of every platform, so there the platform gem's record is no fix of its own. Selected as one it was asked about in the reference request, skipped with "the hosted patch server has no artifact for this patch" (or left "not hosted"), and every later scan offered it as a newer patch of the gem. A hosted `scan` and `get` now leave those records out as a vendored run does, before anything is reported, looked up or written, and so does the in-memory engine's selection. The predicate lives in core (`engine::is_platform_gem_patch`) so that the engines share it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A gem is not moved to the patch registry while no locked build is patched. The same rule kept a lock that is ALREADY on the registry where it was when the build it pins was withdrawn and no other locked build is patched: the snapshot the lock names refuses that build from then on, so `bundle install` fails on that platform until someone unwinds by hand. A lock on the registry now follows the reference whatever it lists: the URL moves to the current snapshot and the withdrawn build's checksum goes back to the upstream gem's, which that registry hands on. A lock that was never moved still stays upstream. Also brings the vendored arm of the "left to patch" test to the line vendored mode prints for a platform without a patched build. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…nstalls A gem patch's registry serves a patched build for some platforms and upstream's own gem for the others, and a lock that names platform builds takes all of them from it under one `GEM` section. The lock's wiring therefore says that the gem is on the registry, not which locked build is patched. A reader that has only the committed files and the patch service to go by (a VEX document made after the run that moved the lock) had nothing to decide that with. `vex::gem_builds` decides it per build, by the one thing a patched gem and upstream's gem never share: the sha256 of the archive. - `locked_gem_pins` reads the builds a lock names of a gem version, each with the sha256 its `CHECKSUMS` pins. - `gem_build_states` holds each against the list a gem patch's reference carries (`gemBuilds`). A platform build is the patched build of its platform's patch only on the sha256 the list gives beside that patch, and upstream's gem only on the one it gives beside none. For a build the lock's `CHECKSUMS` does not pin, the archive is the one the lock's own registry serves, read from that registry's compact-index document (`gem_index_url`). - Anything else is `Unknown`, with why: nothing names the archive the lock installs, the list leaves the platform out, or the lock installs another archive than the list names. The last is a list of a later registry than the one the lock names: a build that is patched there is not shown patched for a lock that does not pin it. The ruby-platform gem a patch's registry serves is the patch itself, so that entry is the gem's patch by the lock's wiring, as for a gem locked as its ruby-platform gem alone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…pers A hosted scan breaks the line about a gem's builds after a clause when it prints on a terminal, so that no platform name is cut in two. `vex` is about to print a line of the same shape, and a command module may not import another one's helpers. `wrap_line`, `wrap_words` and `wrap_tokens` move from the hosted scan to `ui::text`, with their tests, unchanged. The hosted scan takes them from there. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A gem that a Bundler lock takes from its patch registry as platform builds is one hosted pin, and a VEX document attested it as one: the gem, under the gem's patch. The registry serves a patched build for some platforms and upstream's own gem for the others, so that statement said `not_affected` of a platform that installs the unpatched gem, and it named the gem's patch where each patched build has a patch of its own. A scanner that finds the platform gem of such a platform was told to drop a finding that is real. The gem is still judged as the one pin it is. The document then names each locked build (`pkg:gem/<name>@<version>?platform=<platform>`, and the gem's own purl for a ruby-platform entry beside them): - a patched build is `not_affected` under its own patch, with the vulnerabilities of the gem patch's record, since the fix is the same in every build; - a build the lock installs as upstream's own gem is `affected`, with what changes that as its action statement. This is the document's rule for a package the build is known to take without its patch, the one a Bazel hub already falls under; - a build of which neither is shown is left out, and a warning names the gem, the reason and what to run (`vex_gem_build_unknown`). The records of all of them stay in the view the document is built from, so no statement names a form of the gem (the purl without a platform) that also stands for a build the document does not call patched. Where the builds come from: - `scan --mode hosted --vex` and `get --mode hosted --vex` hand over what the run reports per locked build (`engine::pin_reports`), so the run's own document costs no request beyond the run's. - A later `vex` (and the `--vex` of `apply` and `vendor`) reads the lock and asks the patch service once for the references of the gems' patches (one request for all of them). A build is attested by its patch only when the sha256 the lock's `CHECKSUMS` pins for it is the one the reference lists beside that patch. For a lock with no `CHECKSUMS`, the index of the registry the lock names is read too, once per gem: that is what such a lock installs. The reference can be of a later registry than the lock's; a build it lists as patched while the lock pins another archive is not attested. - `--offline`, a failed request, a reference with no list: nothing is known of the platform builds, and none is attested. A ruby-platform entry beside them is the gem's patch by the lock's wiring, as before. - A gem locked as its ruby-platform gem alone, and every other ecosystem, are as they were, with no request of their own. An installed copy is evidence about its own build alone. A machine of a platform on upstream's gem holds upstream's gem, as its lock entry names it; judged as the gem's copy it withheld the builds the lock does install patched. The copy of a build the lock does not install patched is not judged, and the copy of one it does still is. What a run says: - `vex --json` reports a build on upstream's gem as the hosted scan does: an uncounted `skipped` event under `gem_upstream_build_kept`, which does not make the run a partial failure. The events of every build named in place of a gem carry `details.gemFix` (the gem's patch) and `details.platform`, a gem vendored as platform gems included. - For a person, `vex` prints one line per gem under its summary, in the words of the scan's own line (`nokogiri 1.19.3: patched for x86_64-linux-gnu; upstream gem kept for arm64-darwin (no patched build yet)`), with `not attested for <platform>` for a build left out. On a terminal it breaks after a clause. - The line that folds several omissions of one reason names a platform gem with its platform, since the builds of one gem share its name. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The hosted scan leaves the installed copy of a platform on upstream's gem alone: it is the gem that platform's lock entry names. The VEX of such a machine has to agree with that, in the run's own document and in a later `vex`: the copy must not be attested as patched, and it must not withhold the build of the other platform, which the lock does install patched. The stale-install suite already builds that machine, with a real gem home, with and without the gem's cached archive. It now also checks both documents there: the other platform's build under its own patch, this machine's build as affected. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ites Two things the full suites check that the tests of the platform builds did not meet. The golden fixture of a lock that names a platform the list leaves out still expected `redirect_gem_platform_unsupported`. That platform is one whose patched build is being made, which is no warning: the fixture expects none, and is named for what it holds (`platform-build-pending`). The hosted and vendored end-to-end files read the `--json` envelope with helpers of their own under names the shared readers have (`warning_codes`, `events`). They use `common::envelope` for it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The stand-in patch service of the nokogiri end-to-end script still answered the way the patch service did before a gem's fix became one patch: it named the patched platform gems as artifacts of the gem's patch (`gem-platform`, `gem-platform-stub-gemspec`) and as `gemPlatforms`, under the plain registry URL. The CLI reads none of that any more, so the hosted and vendored legs of the nokogiri workflow had nothing to install from. The stand-in now answers as the service does: - each patched platform gem has a patch of its own, which the search routes return beside the gem's and whose reference serves that gem (`tarball`) and its stub gemspec; one reference request answers for every uuid it names; - a reference request that carries `gemBuilds: true` gets the registry under a snapshot URL, whose key is derived from what the registry lists, and the list of the version's gems (the ruby gem, each patched platform gem with its patch, each platform still on upstream's gem with none); a request without it gets the plain URL and no list; - the registry under a snapshot lists every gem of that list, and answers the file of a platform with no patched build with a 302 to a stand-in of the upstream registry's file host on a second port, which serves the real gem. Nothing leaves the machine for it; - `publish` makes a platform's patched build appear under a newer snapshot, and the earlier snapshot keeps answering as it did. The script's hosted scenario checks what a run reports per locked build and that every reference request asks for the list. With `--pass-through` (and `--add-platform`, to lock a platform nothing here installs) one locked platform has no patched build at first: the lock keeps upstream's checksum for it, a frozen install on that platform gets upstream's nokogiri through the redirect, and the scan after `publish` moves the lock to the newer snapshot and the install to the patched gem. With no locked build patched, nothing moves. The vendored scenario checks that the platform patches are asked for in one request, that no record of theirs is fetched, and that a gem with a platform that has no patched build is not vendored until it has one. The workflow gains two hosted legs (the runner's own platform passed through, and another one) and one vendored leg. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ndler The real-Bundler hosted capstones for a gem locked as precompiled platform gems mounted a patch API that named the patched platform gems as `gemPlatforms` and `gem-platform` artifacts of the gem's patch, under the plain registry URL. The CLI reads the list of the version's gems (`gemBuilds`) under a registry snapshot instead, so all five failed at the scan, and nothing proved the new behaviours against a bundler. The platform cases now share one fixture, `PlatformProject`: the gems, a project the real bundler locked and installed, and a stand-in for the patch service that answers as the wire contract has it. Each patched platform gem has a patch of its own, which the search routes return beside the gem's; a reference request gets the snapshot URL and the list only when it asks (`gemBuilds: true`), and every helper that reads the reference requests asserts that each one asked; the registry under a snapshot lists every gem of that list and answers the file of a platform with no patched build with a 302 to a second wiremock, the stand-in of the upstream registry's file host, so nothing leaves the machine; a later listing is a newer snapshot beside the earlier ones. The five capstones are converted (every locked build patched: with and without `CHECKSUMS`, with the ruby entry beside the builds, and taken over by a vendored run, which now asks for the platform patches in one request) and assert the per-build events. New cases, all on a `CHECKSUMS` lock: - one platform patched and one on upstream's gem, with this machine in either role: the scan moves both, `bundle lock` agrees byte for byte, and a fresh checkout installs frozen, in deployment mode and unfrozen. The machine of the patched platform gets the patched gem; the other gets upstream's gem through the redirect, and the scan downloads nothing for it. `rollback` restores the pair; - no locked build patched, then one platform missing from the list: nothing moves, quietly, until the list has it; - a newer snapshot: the URL and the one changed checksum are rewritten, the build is reported as newly patched, `bundle install` installs it, and the earlier snapshot still installs what it did; - `bundle lock --add-platform` over a hosted lock resolves the new platforms from the registry, patched or not, and a re-scan reports them and writes nothing; - the refresh's download of `gems/<file>` follows a redirect the registry answers with. A machine of platform X is this machine: bundler installs the platform gem of its host, so the cases that turn on which platform is patched run twice with the roles swapped. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tone The vendored platform-gem capstone served the patched platform gems as `gem-platform` / `gem-platform-stub-gemspec` artifacts of the gem's patch and expected the wording of that model (backticked platforms, "kept the vendored patch"), so it failed at its second step. Vendored mode takes each platform's gem from that platform's own patch, which the gem patch's reference names in `gemBuilds`. Its stand-in service now answers that way (one request answers for every uuid it names, the list only on request, a platform with no patched build listed as upstream's own gem), and the capstone checks, against the real bundler: - one locked platform with no patched build: exit 0, the one line, a counted skip, the gem patch's reference alone asked for, nothing downloaded or written; - every platform patched: the gem patch's reference and then ONE request for the platform patches, each tree that platform's own gem (the fixture gems carry a file that names their build), the ledger's `gemBuilds`, one event per platform gem, and one package for a person; - `vex` and the manifest-less `vex` attest each platform gem under the patch of its tree, `vendor --check` gives one verdict per platform gem; - a newer patch that lacks a platform leaves the vendored one in force, in the line the engine prints for it; - a ledger entry that names platforms only (`gemPlatforms`) still checks and reverts, and the next run records each tree's patch. The frozen and unfrozen installs from the committed tree, the tampered foreign tree, the in-sync re-run and the byte-for-byte revert stay. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ri script A hosted lock names the registry snapshot it was moved to, and installs from it until the next scan: the patch service keeps a snapshot answering as it did after a later one exists. The stand-in does that too, but nothing in the script looked. The hosted scenario now reads what the earlier snapshot lists before and after the missing builds are published, and requires the two to be the same and the newer snapshot to be another URL. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A locked platform can lack a patched build in two ways: the patch registry lists upstream's own gem for it, or its build is still being made and no list names it yet. Vendored mode treats both the same (the gem is not vendored, one line, exit 0, nothing written), and the capstone only served the first. Its not-vendored step now runs against both. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The five converted capstones run on every bundler from 2.2 on, of which only 4.0.15 is on the machine they were converted on. Holding a run's warnings to an exact list there would turn a caveat another bundler line adds into a failure of a case that is about something else. They assert what they asserted before: the codes that must not appear, the one a lock with no `CHECKSUMS` section brings, and the refresh note. The cases added for `CHECKSUMS` locks keep the exact lists. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Seen on a terminal with real nokogiri at 80 and 100 columns. A clause wider than the terminal wraps at a word, and the clause after it was then put on a row of its own although the row had room: the "left on its upstream registry" line ended in a row holding one platform name and another holding the last three words. A clause now goes on from where the wrapped one left the row. The one line vendored mode prints for a gem with a platform that has no patched build was not wrapped at all (211 columns for three platforms), where the hosted line of the same gem breaks after a clause. It is wrapped the same way when a person is at the terminal, and stays one line in a pipe. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The real-Bundler capstones of a gem locked as platform builds ended in the VEX matrix written for a gem locked as its ruby gem: one statement under the gem's own patch. `vex` attests such a lock per build, each patched build under that build's patch, so all five capstones failed on a correct document. Their VEX step is a matrix of its own. Over the fresh checkout the real bundler installed, `vex` and `apply --vex` must name each locked build under its own patch, and the ruby-platform entry under the gem's, from exactly the requests the lock's shape calls for: the gem patch's record and one package reference, plus the index of the lock's registry where the lock has no CHECKSUMS to say what it installs. `--offline` attests nothing (`record_unavailable`, no document) and asks nothing, and the pair reverted to its registry version names the patch nowhere. The scan's own `--vex` document is held to the same statements. The file's own `warning_codes` goes, for the one in `common::envelope`: the lint of the `cli` suite allows no private envelope reader. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
No real-Bundler case read the document of a lock the hosted scan moved with one patched build and one the registry passes through to upstream. That is the lock a wrong document over-claims on: the gem is one pin under one patch, and the build that installs upstream's gem must never be attested by it. The case takes the lock the real bundler wrote through the scan, a checkout with nothing installed and a frozen install, with this machine's platform as the patched build and as the one on upstream's gem. Each time the patched build is `not_affected` under its own patch and the other `affected`, with exit 0: the copy on the machine changes what is said of neither. A third run has a lock without CHECKSUMS, where the index of the lock's registry is what says which build is which. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Describe hosted and vendored mode for a gem a Bundler lock names as precompiled platform builds as they are: the list of a version's gems on the gem patch's reference, the registry URL with its snapshot key, the one line and the per-build events, the two quiet cases, per-build VEX, all-or-nothing vendoring from each platform's own patch, and the codes that go with them. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This was referenced Nov 26, 2026
A serve URL holds its grant token in the path, and the client that downloads from one follows redirects: a patch registry may answer the file of a gem it has no patched build of with a redirect to the upstream registry. The HTTP client set a `Referer` on the redirected request, so the host it was sent to received the whole serve URL, token included. The plain client sets no `Referer`. The redirect is still followed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…uccess For a gem a Bundler lock takes from a patch registry as platform builds, a build whose state could not be told (the lock pins another archive than the patch service lists, the reference or the registry's index could not be read, `--offline`) was left out of the document under a `skipped` event, the run became a partial failure, and it exited 1 when nothing else was attested. A reader of the document could not tell such a build from one the project does not have, and a scanner fed the document kept no statement about it. `vex` states what it knows. Such a build is in the document as `affected`, with an action statement that says it could not be shown that the lockfile installs a patched build for that platform, why, and what settles it. It names no patch. The run's status and exit code are what they are without it: `vex_gem_build_unknown` stays the warning (one per gem and reason) and becomes the code of the build's uncounted event, shaped like the one of a build on upstream's gem. The line for a person says `not shown patched for <platform>`. `--offline` with no local record is as it was: with no record there is no vulnerability to state anything of, and the gem is omitted as `record_unavailable`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A patched platform build can be withdrawn, because it is unsafe. The next hosted scan puts upstream's sha256 back into the lock for that platform, but a machine that had installed the build kept loading it: the stale-install guard passed over every build the patch registry serves as upstream's own gem, and `bundle install` keeps a gem it has installed. The guard judges the copy of such a build, and its archive in Bundler's cache dir, by the sha256 the reference lists for the platform. An archive that is upstream's gem is the right copy, as before: nothing is said, downloaded or fetched for it. A readable archive with another sha256 is replaced with upstream's gem, downloaded from the patch registry (which hands that file on) and verified against the listed sha256 before a byte is used, under the switches of every other refresh (`--no-gem-install-refresh`, `--gem-refresh-shared`, `--dry-run`). What cannot be replaced is warned about under the guard's own codes, in words that say a withdrawn build is still installed and how to remove it. The lines of a refresh name the upstream gem and never call the result patched, and so does the next step. Such a copy keeps nothing of the gem out of the run's VEX: the document says `affected` of that build whatever is installed, and still attests the other builds. A copy whose gem home holds no archive of it is not judged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- A build was attested from the digest of its cached archive alone. The installed tree is now held to that archive's own files, so what Ruby loads is what is attested; a tree with other bytes is left out as hash_mismatch, and the scan replaces it from the archive. - The pins of the run that moved the lock carry the digest its reference listed, so an in-run --vex uses the archive too. A record it cannot read no longer turns a build it just confirmed into affected: such a copy is left to the run's own gates. - A build has one outcome from all of its copies, attested only if every copy is proven, and it joins the verdicts right after verification: before the in-run gates, the sort and the omission lines. Two gem homes with the same stale build are one entry, and a build is never both attested and affected. - The guard reads a build's own record without its file contents, and compares the uuid of a record case-insensitively. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The contract says that a platform build's copy is held to its archive's own files, that vex gives a build one outcome from all its copies, and that a restore of a build the fix no longer names answers vendor_prebuilt_replaced with the commands that work. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Socket's backend now lists every platform gem upstream publishes in a fix's listing, whether or not a patched build of it exists or is being made: a build in progress no longer changes the listing or its key. So a lock that is on its patch never meets a newer listing that lacks one of its platforms for that reason, and the handling added for it goes: the kept-on-snapshot marker of the rewriter, the engine's confirmation of it, the guard's skip of such a platform's copy, and their test. A platform the listing lacks is one upstream does not publish. It keeps the neutral report it had, and vex now gives it a remedy that is true: a scan changes nothing for it, the lockfile dropping the platform or the registry listing a gem for it does. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- The --vex of the run that moved the lock judges an installed platform copy by the digest its reference listed, reads no record, and never states a build it confirmed affected for a read that failed. - The same build installed from another gem in two gem homes is left out once, and one proven copy beside one that nothing can judge is stated affected once and attested nowhere. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The patch registry lists every platform gem upstream publishes for a version, so a platform it leaves out is one upstream does not publish. A scan changes nothing for it, and the action statement of the `affected` build says so and names the remedy: drop the platform from the lock (`bundle lock --remove-platform`). The contract row of `vex_gem_build_unknown` and the gem guide now say the same. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A lock that already takes a gem's platform builds from the patch's own registry was reported `redirect_gem_platform_unlisted` when the patch's current list left out a platform the lock names (upstream yanked that platform's gem). The gem dropped out of the run's pins, its guard and its in-run VEX, although the snapshot the lock names goes on serving what it listed and the lock still installs the patched builds. Such a lock now stays where it is, inside the path every gem goes through, with no extra result field: - The address of a gem in the pair is decided in one place (`gem_pair_address`), for the rewriter and for the check that the pair pins the gem. For this lock it is the lock's own remote, so nothing in the pair is rewritten and the pin is confirmed as any other. - Each locked build is judged by what the lock itself pins: its `CHECKSUMS` entry, else the line of the snapshot it names. A build the list names with that same archive is what the list says. The build of the platform the list leaves out, and one pinned as another archive than the list names, is kept as the lock pins it, with no patch. - `GemLockedBuild` carries the sha256 each build is pinned to, for the hosts that tell an installed copy from another gem. A lock on its upstream registry or on another patch is reported as before. The texts that said the patch service leaves a platform out while its build is being made are corrected: it lists every platform gem upstream publishes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`vex` attested a patched platform build from the archive in the gem home's `cache/` and a comparison of the installed tree with that archive's files. The comparison had its own path rule (a `./` entry made a correct install look altered, for good), treated a missing or unreadable file as stale evidence, re-read the archive whole up to three times a run, and duplicated the gem data walk of the vendored fetch. It is deleted, with the attestation of a build from its archive: - `vex` judges the installed copies of a platform build as it judges any installed package: against the record of that build's own patch, asked without file contents, one request per installed patched build, with the checker's own rules for missing and unreadable files. Every copy must verify. Where that record cannot be read the build is stated `affected` under `vex_gem_build_unknown`; the gem patch's record is never used for it. - The `--vex` of the run that moved the lock holds a build to the same check. Its exemption for the pins it confirmed went by the purl without qualifiers, so the gem's pin erased a build's own failure and attested a build whose copy was not the patched one. A build that has an installed copy is now never exempt. - The stale-install guard keeps the archive's sha256 as its first sign that Bundler installed another gem than the lock pins, and the build's own record where the gem home keeps no archive. It does not compare the installed files with the archive. - The guard's facts about each platform build (its patch, the archive the lock is pinned to) come from the builds the rewriter pinned, so they hold for a lock that stays on an earlier snapshot. The digest no longer travels to `vex` through the pin reports. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`vex` now holds an installed patched platform build to the record of its own patch, so the real-Bundler matrix expects that one request where the machine's own build is a patched one. The contract states the cost: one request per installed patched build, on top of the gem's. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
While the patch service builds a patched gem again that a registry
snapshot lists, it names no listing for the gem's patch: the reference is
`pending_build`. A lock that was on the patch already then had its scan
report the gem as still being built, with one vulnerability left to patch,
and `vex` had no list to tell which locked build is which patch, so it
stated a patched build `affected` until the rebuild ended.
A reference request about a patch now presents the key of the snapshot
the project's lock already takes that gem from
(`gemSnapshotKeys: { "<patch uuid>": "<key>" }`). The service answers a
request that presents the key of a snapshot of the patch with that
snapshot as it was, so the existing paths see a reference whose index URL
is the lock's own: the scan reports the gem as already on its patch and
`vex` attests its builds. There is no new outcome and no new branch.
- The scan reads the keys off the lock before its reference requests, the
withdrawn-pin check included; `vex` takes them from the registry each
gem's lock names.
- A request with no snapshot to present is byte for byte the request it
was, so a project that is not on the patch yet is told the patch is
still being built, as before.
- Outside a rebuild the key changes no answer.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The stand-in of the nokogiri workflow answers a rebuild as the patch service does: while a patched build that a snapshot lists is being built again (`rebuild`), a `gemBuilds` reference is `pending_build`, a request that presents the key of a snapshot it holds is answered that snapshot, and the gem being rebuilt is a 404 under every snapshot until `rebuilt`. The hosted scenario runs through that window: the scan presents the snapshot the lock is on and changes nothing, and `vex` still attests the patch. The option for a platform the list leaves out is named for what it is now, a platform upstream does not publish (`:unlisted`). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A lock that was already on a patch's registry stayed on the snapshot it named when the patch's current list left out a platform the lock names. That path judged each build by the lock's own pins. It was wrong in several ways: without `CHECKSUMS` nothing read the snapshot's listing, so a build was reported under the current list's patch while the lock installed another gem; the ruby-platform entry was rewritten to the current reference's sha256 under the old remote; the lock's own `remote:` was written into the Gemfile's quoted `source` without the URL check; and a build the list did not vouch for was guarded as an upstream gem. The path is deleted. With the patch service's listing rule a list lacks a locked platform only when upstream itself stopped publishing that gem, so the lock is broken at upstream as well. The gem gets the neutral outcome an unlisted platform always had: it is reported once (`redirect_gem_platform_unlisted`), nothing is written, and no string of the lock reaches the Gemfile. `vex` attests the build the lock still installs patched and states the unlisted one `affected`, with the remedy (`bundle lock --remove-platform`). The contract and the guide state it as a known limit. The guard takes its facts from the reference's list again, the sha256 of the ruby-platform gem among them, so a correctly installed ruby gem is not called stale when the reference's own checksum is not the list's entry. The stand-in patch service and the fixture service answer a rebuild as the service now does: a request with no key gets the registry as it stands, with upstream's gem for the build being rebuilt, and a request that presents the key of a snapshot that stands gets that snapshot. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The snapshot keys a reference request presents were state on the API client that each command had to remember to set, and the `PatchApi` trait could not carry them: a new call site that forgot regressed without a compile error. They are an argument of the call now, on the client and on the trait (`GemSnapshotKeys`), so every host says which snapshots it presents: - the scan reads them off the project's lock, for its reference requests, the withdrawn-pin check and the read of a patch a lock stays on; - `vex` takes them from the registry each gem's lock names; - `get <uuid>` and vendored mode present none; - the in-memory engine and the Node host do not ask for a gem's listing with this call (their request names the uuids alone), so they present none. That is unchanged, and stated where they pass the empty map. A key is the snapshot level the rewriter recognises in a remote: lowercase hexadecimal digits. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`vex` read the record of each installed patched platform build one request after another, and had no fallback when the API refused the credential: a stale token turned every installed patched build into `vex_gem_build_unknown`. The records of a run are read several at a time, with the helper the other reads of `vex` use, and a record the authenticated API refuses (401/403) is asked of the public proxy, with the same note as those reads. Tests: a refused record is read from the proxy and the build is attested; and, for the guard's facts restored with the unlisted change, a lock that names the ruby-platform gem beside a platform build has no stale install when the reference's own checksum is not the list's entry. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A reference request presents the snapshot the project's Bundler lock names for a patch. The key was read from both `gems.locked` and `Gemfile.lock`, with `Gemfile.lock` winning, while the rewriter edits `gems.locked` wherever the project has a `gems.rb`. A stale lock of the other spelling could so present a key the project is not on. One helper reads the key from the lock the rewriter selects, and the scan and the registry refresh both use it. The in-memory engine presented no key at all, though it rewrites the same pairs. It now reads each root's lock with that helper and passes the keys through its provider call, and the Node provider sends them in its request (`gemSnapshotKeys`, beside `uuids`). Where two roots name different snapshots of one patch, the first root's is presented. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A gem vendored as platform gems is restored tree by tree from the builds its fix names today. That request named no registry snapshot, so while one of the builds was being made again the patch service answered with no list, and `repair` told the user the build was replaced and to roll back and vendor again. The ledger entry now records the key of the snapshot the fix named when the trees were vendored (`gemSnapshot`), and a restore presents it, in a request of its own. A build that is only being made again is then still named, and the restore waits for it. An entry written before this asks with no key as before; its message now says a rebuild is one of the causes and to run again. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The read of the records of installed builds asked the authenticated API first even when an earlier read of the same run had been refused by it and had fallen back to the public proxy. It now starts on the proxy in that case, and says nothing twice. Two doc comments linked to the reader under its old name. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
While a gem a patch's registry lists is being built again, the registry lists what it listed, under its key. A request that presents that key is answered the registry, one that presents another key is told the patch is not ready, and one with no key is answered the ruby gem's registry alone. The request docs, the contract, the guide, the stand-in service of the nokogiri suite and the fixture service of the hosted suite said an older rule. They say this one now, and the suite holds it: a lock on an earlier snapshot waits out a rebuild and is never read as a withdrawal, and a project not on the patch yet is left alone. The warning for a lock of platform builds that is answered no list says what is true in every case: the service names no platform gem of the version right now. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The vendor ledger recorded the snapshot a gem's fix named, and a restore presented it. Only that one path did, the wording of a miss went by whether a key was sent and not by what was answered, and a keyed request left the prefetch plan's batch. An intact vendored copy asks for no list, so a rebuild never touched it. The key, the ledger field and the special case are gone. A damaged or missing copy is now worded by the answer: when the fix's reference carries no list, or the service says the patch is not ready, the run says the patch service lists no builds for the gem right now and to run again later, in the same words on a re-scan and on a restore. "Replaced" and "withdrawn" are said only when a list is there and names another build, or none, for the platform. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The read of the records of installed builds went to the public proxy alone once any earlier read of the run had been refused, also after a refusal of one patch. Records of paid builds the authenticated API would have served then came back unread, and those builds were stated as unknown. The state was also recovered from the text of a note. Each record is asked of the authenticated API first again, and only a refused one goes to the proxy. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The snapshot a reference request presents was read from the raw project files. With BUNDLE_GEMFILE naming the Gemfile beside a gems.rb, the key came from gems.locked while the rewriter edited Gemfile.lock. It is read from the pair the rewriter is given now, the one Bundler loads, by the scan and by the in-memory engine. The in-memory engine presented one key per patch for every root, the first root's, so a root could get an answer its own lock would not have got. It asks once per distinct set of snapshots: roots that name the same share a request, a root with others or none has its own. The request the engine hands a host's provider says what it needs: gemBuilds beside uuids and gemSnapshotKeys. The service reads a key only on such a request. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The contract named the lock by its spelling and the first root's key. It names the pair Bundler loads and one request per set of snapshots, says when a reference carries no list, and gives the vendored wording for a fix that lists no builds. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A fix names no builds to vendor from while the patch service has not
read the version's gems or is building one of them again. It says so in
two ways: a reference with no list, or a patch that is not ready. For a
lock of platform gems the first was the exit-0 skip and the second a
failure, so one rebuild failed or skipped a scan depending on which
answer came back. Both are now the skip
(`vendor_prebuilt_platform_pending`), for a project with an intact copy
and for one that is not vendored yet.
The skip's line opens like the line of a platform with no patched build
and ends with what the gem is left with:
nokogiri@1.18.10 is not vendored: the patch service lists no builds
for it right now; run the scan again later.
A restore keeps its own ending ("; run this again later"). The words no
longer reach the line that wraps a detail as "kept the vendored patch
<old>: <detail> for patch <new>", which a sentence with a remedy did
not fit.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The in-memory engine grouped its reference requests by a root's whole map of snapshots and awaited the groups one after another. Two roots whose maps differed in one entry each asked again about every patch they shared, and nothing between the groups let a cancel through. The requests are now grouped by patch and presented snapshot: a patch is asked about once for each snapshot of it that a root names, and once for all the roots that name none. A request names a patch once, and all of them are sent together, bounded like the chunks of one request were, after a cancellation checkpoint. The round that follows a lock that stays on its patch is one such call for every root, too. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The request handed to a host's provider was written by hand beside the type the API client serializes for the same body. It is that type now, so the two cannot drift. The body is unchanged, as `the_provider_request_asks_for_gem_builds_and_presents_the_snapshots` shows. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The only test of `read_build_records` went with the shortcut it tested. This one pins the rule: each record is asked of the authenticated API first, only a record the API refuses goes to the public proxy, a paid record the API serves is read, and the fallback is noted once. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
After a 401 the authenticated API refuses the credential itself, yet every build record was still asked of it first, one wasted request per record. The run's client now remembers a 401 to one of its JSON requests (a flag its clones share), and the read of build records starts on the public proxy when it is set. A 403 is about one patch, so after one each record is still asked of the API first. Nothing is recovered from the text of a note. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The comment in `gem_snapshots_presented` said the mirror gate needs a candidate. A Bundler mirror of every source needs none: it drops the pair there, so such a project presents no key, and no gem of it is redirected whatever the answer. A mirror of one source is judged when the rewriter's files are read. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
No test on the JavaScript side checked what a provider receives for a gem. The smoke test now runs three roots on one gem patch (two locks on different snapshots of its registry, one on the upstream registry) and asserts that every call carries `gemBuilds: true`, names the patch once, and presents the snapshot of one lock, or none. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`vendor_prebuilt_platform_pending` listed "the reference carries no list" with a wording the code no longer prints, and `vendor_prebuilt_replaced` said a restore reports `vendor_prebuilt_pending`, although a restore words every patch the service does not serve as `vendor_prebuilt_required`. Both rows now quote the lines as printed, the row of `vendor_prebuilt_pending` names the gem case that is a skip of its own, and the list of gem warnings points at the passage as it reads today. The engine's requests are described as they are grouped now. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The sentence stood between the per-platform wording and "counts the same way", which refers to that wording. It follows them now. 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.
Hosted and vendored mode now patch a gem that
Gemfile.lockpins as precompiled platform gems, with no decision asked of the user. This replaces the platform-gem support of #2150 and #2154 (merged after 5.1.0, not released) with the shape Socket's backend serves today. Agent mode is not touched. It supersedes #2257 and #2226.Why
A native gem such as nokogiri is locked as platform gems (
nokogiri (1.19.3-x86_64-linux-gnu),nokogiri (1.19.3-arm64-darwin)), and a real lock names several platforms at once: linux and macOS, often Windows and JRuby. A patched build exists only for the platforms the patch service can rebuild and prove, and Bundler takes one source per gem. A rule of "every locked platform or nothing" would leave most real projects unpatched.The patch service now gives a gem's patch a registry that serves every platform of the gem version: the patched gem where a patched build exists, and upstream's own gem everywhere else. The package reference says, for each platform, which it is. So the gem always moves, the platforms that can be patched are, and nothing breaks on the others.
What a user sees
Hosted, one line per gem and no warning:
CHECKSUMSline takes the sha256 the registry serves for it.nokogiri 1.19.3: now also patched for arm64-darwin; already patched for x86_64-linux-gnu.nokogiri 1.19.3: no patched build yet for …; left on its upstream registry.nokogiri 1.19.3: the patch registry does not list arm64-darwin, so the gem is left as it is.the newer fix has no patched build for x86_64-linux-gnu yet; the lock stays on the patch it is on.upstream gem back for arm64-darwin (its patched build was withdrawn). This also holds while the lock is waiting for a newer fix: a lock that stays on its patch follows that patch's current list.bundle installbuilds the patched ruby gem.PLATFORMSis onlyruby, Bundler picked the machine's precompiled gem at install time and keeps loading it. As in 5.1.0, the scan reports that copy with the command that installs the patched gem, and its closing line says the gem is still unpatched on disk instead of "Nothing left to patch."vexexits 0 and states the gem asaffected.bundle lock --add-platform <p>afterwardsVendored mode needs a patched build for every locked platform, because a
path:gem is not fetched. With one, it vendors one tree per platform, each from its own platform's patch and checked against that patch's record. Without, it writes nothing, exits 0 and says which platform is missing and that hosted mode can patch the others now.How it works
"gemBuilds": trueand answers the registry URL and the list of builds: for each platform the sha256 the registry serves and the patch that built it, or none for upstream's gem. There is no per-platform lookup and no index request before writing. Without the list (an older service, or a gem with no platform gems) the patch is a ruby-gem-only patch, as in 5.1.0.…/<uuid>/s/<key>/, lowercase hexadecimal) that names one fixed list, so the checksums a lock pins stay valid for as long as it names that key. A list with more patched builds has another key, which the next scan takes. A gem locked as its ruby gem alone keeps the URL without a key: under a keyed URL, a lock whosePLATFORMSis onlyrubywould let Bundler install the local platform's gem, which can be upstream's (confirmed with real Bundler).appliedevent under its own patch UUID, withdetails.gemFix,details.platformanddetails.newlyPatched. A build that keeps upstream's gem is an event that is not counted, withgem_upstream_build_kept. Rollout budgets and severity floors count the gem as one package.vexchecks the installed copies of a patched build like any installed package, against the record of that build's own patch (asked without file contents, one request per installed patched build), and every copy has to verify. The hosted scan's stale-install guard first looks at the archive RubyGems installed the copy from (cache/<leaf>.gem): its sha256 says whether Bundler installed the gem the lock pins. Where the gem home keeps no archive it reads the build's own record. With neither, the copy is not called stale and not replaced. Wherevexcannot read that record it states the build asaffectedundervex_gem_build_unknown. Vendored mode reads the build's record when it vendors or restores a tree (one request per platform gem) and keeps its file hashes in the ledger.not_affectedunder its own patch; a build on upstream's gem isaffected. Standalonevexattests a build only when the sha256 the lock installs is that patch's. It makes two small requests per such gem (three for a lock with noCHECKSUMSsection): the gem's record, the list of builds and, where the lock pins no checksum, the registry's index. Each patched build that is installed costs one more, for that build's record. A build it cannot show patched is written asaffectedwith what settles it, and the run exits 0. Vendored mode attests each tree from its ledger, offline, with no request.repairdoes not take the vendor ledger's word for what to unpack: the patch an entry records for a platform's tree must be the one the fix's listing names for that platform, the entry must pin the gem and the gemspec, the stub gemspec must state the entry's name, version and platform, and the tree is held to the record the service serves now. An entry that fails this is refused before a download, with the tree left as it was.get <uuid>of a platform gem's patch resolves to the gem's patch it was built from and proceeds with that.?platform=<p>) are for agent mode. Hosted and vendored mode never select one as a fix of its own.Codes against
main: addedredirect_gem_no_patched_build,redirect_gem_platform_unlisted,redirect_gem_newer_fix_waits,gem_upstream_build_kept,vex_gem_build_unknown,vex_gem_install_unpatched,platform_gem_patch_not_taken; none removed;redirect_gem_platform_unsupportednow covers only a reference with no list and Bundler before 2.2;vendor_prebuilt_platform_pendingalso covers a platform on upstream's gem. The retiredgemPlatformsfield and thegem-platform/gem-platform-stub-gemspecartifact kinds are no longer read.CLI_CONTRACT.mdanddocs/ecosystems.mddescribe all of it.Before this is released
Socket's backend also reads a project's
Gemfile.lockto decide what is patched. It must understand a registry URL with a key before a CLI that writes one is released, or it would count upstream's gems under that URL as patched. That change is in progress on the backend and is a condition of the release, not of this merge: nothing here reaches a user until a release is cut.The backend also keeps a client that does not ask for the list of builds on the answers it gets today: the registry URL without a key lists the ruby gem alone, and no search returns the patch of a platform gem. That needs a matching change in Socket's backend, which is in review. The released 5.1.0 was run against a backend with it, with and without a patched platform build published: its output, the files it writes and its
vexare the same in both.Also in this change
gemPlatforms) is no longer read; a ledger that has the key still parses, andvendor --revertandrollbackrestore the pair.Refererof a followed download redirect. This touches every download from the patch server.redirected[]entries gain optionalgemFix,platformandnewlyPatched, and a gem locked as platform builds has one entry per patched build; new optionalupstreamBuilds[]; aredirect.patches[]row for a build on upstream's gem hasaction: "upstream_kept"; three new skip reasons.Limits, stated in
CLI_CONTRACT.md--patch-mirror-urldoes not follow that patch's current list when one of its builds is withdrawn; it is left as it is.main.cache/still holds the patched archive, is not repaired by the scan: its guard goes by the archive's sha256 and does not compare the installed files with it.vexleaves such a build out.redirect_gem_platform_unlistedon each scan and left as it is, also for a lock that is already on the patch, andvexstates that platform's buildaffectedwith the remedy (bundle lock --remove-platform). It is not handled further, because that platform's gem can no longer be installed from upstream either.Review findings
/code-review highon0cf668f8creported nine findings. Eight are fixed with a test; the seventh was not a defect:cache/by the gem patch's record, and called a healthy copy stale on every run. Fixed: archive, then the build's own record, else unjudged (a_patched_platform_copy_with_a_pruned_cache_is_judged_by_its_own_patch).a_lost_platform_tree_is_rebuilt_by_a_rerun_and_by_restore; CLI step 5b ofa_platform_locked_gem_vendors_and_reports_per_platform_gem).redirect_gem_platform_unlistedand dropped when the new listing omitted a locked platform. Fixed at the source: Socket's backend no longer leaves a platform out of a listing while its build is in progress, so the client-side handling first added for this was deleted again (see the second review).--vexincluded (an_installed_copy_is_evidence_about_its_own_build_alone). The resolver first written for this was replaced after the third review, below.vexreads one record per installed patched build (see the third review). The proxy itself ignoresinclude_blobs=falsetoday (checked read-only against production with a free patch: the same 23,134 bytes either way), so the request is unchanged there.vexhad its own copies of the registry index URL and read. Fixed: it uses the hosted scan's helpers.retract_vendoredleavessummary.skippedalone when it drops a gem's advisories. That is right: a vendor advisory is an event the summary never counted. The doc and the test now say so.fetch_vendor_patch_summarycopied the route and query logic. Fixed: onesummary_path.Left, and why:
include_blobs=false, or serve a hash-only route).e2e_redirect_gem_platform_builds.rsin part,hosted_memory_parity.rs,hosted_gem_closing_total.rs), and the real-Bundler capstone still builds every gem from one patched file and asserts that a vendored gem whose ledger was deleted is attested. With the real service such a gem is left out asvendor_hash_mismatch.Second review
A second
/code-review highon the commits of the first review's fixes reported ten findings.Fixed, each with a test:
1 and 10 (
vexbookkeeping). A platform build now has one outcome from all of its installed copies, attested only when every copy is shown to be the patched build, and it joins the verdicts right after verification, before the in-run gates, the sort and the omission lines. Two gem homes with the same stale build are one entry, and a build is never both attested and affected (an_installed_copy_is_evidence_about_its_own_build_alone).5 (restore). A restore of a build the fix no longer names for its platform answers
vendor_prebuilt_replaced: the copy cannot be restored as it was vendored, nothing is unpacked, and the message namessocket-patch rollback <purl>andsocket-patch scan --mode vendored. It is no longer worded as tampering or as a first vendoring. The stub check accepts the stubs the backend serves and the stand-in's (s.name = "…".freeze).7 and 8 (the run's own pins, the archive alone). Both were about attesting a build from the archive in the gem home. That attestation was removed after the third review, below: a build is attested by its own record alone.
9 (record read). The guard reads a build's own record without its file contents, and compares a record's uuid case-insensitively.
2, 3, 4 and 6 (a lock kept on its earlier listing). These were all in the path that kept a lock on its earlier listing while a new listing left one of its platforms out. That case no longer exists: Socket's backend now lists every platform gem upstream publishes in a fix's listing, and a build in progress changes neither the listing nor its key (a member that was never built changes nothing until it is built; a member being rebuilt keeps its entry). The path is deleted here (the rewriter's kept-on-snapshot marker, the engine's confirmation of it, the guard's skip and their test: 143 lines removed, 28 added). A platform the listing lacks is one upstream does not publish; it keeps the neutral report it had, and
vexgives it a remedy that is true (a scan changes nothing for it). This needs the matching change in Socket's backend, which is in review.7, 1 and 10, tests.
the_vex_of_the_run_that_moved_the_lock_checks_a_build_by_its_own_recordholds the in-run--vex;a_platform_build_in_two_gem_homes_has_one_vex_outcomeholds one outcome per build across two gem homes.Third review
A third
/code-review high, on the commits of the second round, reported eight findings. Five came from comparing an installed tree with the archive in the gem home, so that comparison is deleted, not repaired../entry made a correct install look altered, for good), counted a missing or unreadable file as stale evidence, read the archive whole up to three times a run and repeated the gem data walk of the vendored fetch. It is gone, with the attestation of a build from its archive.vexnow judges an installed platform build as it judges any installed package: the existing installed-files check, with its own rules for missing and unreadable files, against the record of that build's own patch. That is one request per installed patched build. The guard keeps the archive's sha256 as its first sign that Bundler installed another gem than the lock pins, falls back to the build's own record where there is no archive, and does not compare trees (a_platform_copy_is_attested_by_the_record_of_its_own_patch).--vexof the run that moved the lock exempted its confirmed pins by the purl without qualifiers, so the gem's pin erased a build's own failure. A build that has an installed copy is now never exempt, in whatever gem home, and where its record cannot be read it is statedaffectedundervex_gem_build_unknown, asvexstates it (a_platform_build_in_two_gem_homes_has_one_vex_outcome, whose last case fails without the fix;the_vex_of_the_run_that_moved_the_lock_checks_a_build_by_its_own_record).vexno longer needs the digest, so it no longer travels through the pin reports. The guard takes its facts from the reference's list.Lines for this round: 483 added and 601 removed in 14 files, of which the source files are 196 added and 428 removed.
The rebuild window
While Socket's backend builds a patched gem again, its registry lists what it listed: the gem keeps the sha256 it last built, so the registry's key does not change. A project already on the patch must not be moved off the patched build and back, and its
vexmust not state a patched buildaffectedfor the length of a rebuild, which can fail a CI gate.A reference request about a patch presents the key of the registry snapshot the project's lock takes that gem from:
"gemSnapshotKeys": { "<patch uuid>": "<key>" }. During a rebuild Socket's backend answers by that key:vexattests its buildspending_build: the pair is left untouched, exit 0, and the first run after the rebuild moves the lock onceOutside a rebuild the key changes no answer. There is no new outcome code and no new branch for the window.
A build being rebuilt is never taken for a withdrawn one. A locked build goes back to upstream's sha256 only on an answer that lists upstream's gem for it, and the backend gives none for a registry it is still building a gem of.
A request with no key is byte for byte the request it was. A lock that names the gem as its ruby gem alone is left as it is and reported as on its patch. A project whose lock names platform builds and is not on the patch yet gets the existing warning
redirect_gem_platform_unsupportedfor the length of the rebuild (exit 0, nothing written) and moves on a run after it; the warning now says what is true in every case, that the service names no platform gem of the version right now. Making this case the quietredirect_gem_no_patched_buildwould be one more branch in the rewriter; it is not in this change.The key is read from the lock of the pair the rewriter is given, which is the one Bundler loads:
gems.lockedfor agems.rbproject (an orphanGemfile.lockbeside it is not read), the pairBUNDLE_GEMFILEnames where both spellings are present, and none for a twin that nothing settles. The scan and the in-memory engine read it through the filter the rewriter's own files go through.The keys are an argument of the reference call (
PatchApi::fetch_registry_references), not state on the client. The scan reads them off the lock, the withdrawn-pin check and the read of a patch a lock stays on included;vextakes them from the registry each gem's lock names;get <uuid>presents none. The in-memory engine reads them from each root's lock and asks once per distinct set of snapshots: roots that name the same snapshots share a request, and a root that names others, or none, has its own, so each root is answered what a checkout of it alone would be. The request it hands a host's provider is the API's body:uuids,gemBuilds: trueand, where a lock names one,gemSnapshotKeys. A host that builds its own body fromuuidsis unaffected: it gets references with no list, and a lock of platform builds is then left alone.Vendored mode presents no key. A vendored copy that is intact asks for no listing, so a rebuild never touches it: a re-scan,
repairandvendor --checksay what they said (shown on the full stack, for a rebuild of the vendored build and of the gem's own patch). A damaged or missing copy is worded by the answer. When the fix's reference carries no list, or the service says the patch is not ready, the run saysthe patch service lists no builds for <gem> right now; run this again later, in the same words on a re-scan and onrepair, and changes nothing.vendor_prebuilt_replacedand the word "withdrawn" are used only when a list is there and names another build, or none, for the platform.The stand-in patch service of the nokogiri workflow and the fixture service of the hosted suite answer by the table above, and the hosted scenario of the workflow runs through the window.
Needs the matching change in Socket's backend, which is in review.
Fourth review
A fourth
/code-review high, on the commits of the third round and of the window, reported ten findings. Seven were in the path that kept a lock on its snapshot when the list lacks a locked platform, so that path is deleted.CHECKSUMS, for the ruby-platform entry, for a build the list does not vouch for, and in writing the lock's ownremote:into the Gemfile without the URL check. With the backend's listing rule a list lacks a locked platform only when upstream stopped publishing that gem, so the lock is broken at upstream as well. The gem gets the neutral outcome an unlisted platform always had: reported once, nothing written, no string of the lock in the Gemfile;vexattests the build the lock still installs patched and states the unlisted oneaffectedwith the remedy. It is a stated limit (a_lock_on_its_patch_whose_platform_the_list_no_longer_names_is_reported_and_left).vexreads the records of the installed patched builds several at a time, with the helper its other reads use, and with the same fallback to the public proxy when the API refuses the credential (a_build_record_the_api_refuses_is_read_from_the_public_proxy).the_ruby_gem_of_a_platform_lock_is_judged_by_its_list_entry, which fails without it).Fifth review
Seven findings, on the commits of the fourth round.
gems.lockedandGemfile.lock, withGemfile.lockwinning, while the rewriter editsgems.lockedwherever the project has agems.rb. One helper (gem_project_snapshot_keys) now reads it from the lock the rewriter selects, and the scan, the registry refresh and the in-memory engine use it. Tests:a_projects_registry_snapshots_are_those_of_the_lock_a_run_rewrites,the_key_presented_is_the_one_of_the_lock_the_run_rewrites(both spellings on different snapshots).each_root_is_answered_by_the_snapshots_its_own_lock_names, and the parity caseparity_gemfile_platform_lock_on_its_patch_through_a_rebuild(both engines leave the pair byte for byte and present the lock's key).pending_buildthere, and the contract says so. Test:a_lock_on_an_earlier_snapshot_waits_out_a_rebuild_and_then_moves_once.GemSnapshotKeys, and the others point at it.Sixth review
Ten findings, most in the places the snapshot key had spread to. The surface is smaller now.
BUNDLE_GEMFILEnaming theGemfilebeside agems.rb, it came fromgems.lockedwhile the rewriter editedGemfile.lock. It is read from the pair the rewriter is given. Tests assert which file is rewritten and which key is presented:a_gems_rb_project_presents_and_rewrites_gems_locked_beside_an_orphan_lock,a_twin_presents_and_rewrites_the_pair_bundle_gemfile_names,the_snapshots_presented_come_from_the_pair_bundler_loads.gemBuilds, and the service reads a key only on such a request. One builder states the request, with a test:the_provider_request_asks_for_gem_builds_and_presents_the_snapshots.each_root_is_answered_by_the_snapshots_its_own_lock_names(a root on the current snapshot, one on an earlier one, one not on the patch, in one run during a rebuild).a_damaged_copy_whose_fix_lists_no_builds_is_told_to_run_again_later, and the no-list case ofa_locked_platform_without_a_patched_build_is_a_skip_that_downloads_nothing.redirect_gem_platform_unsupportedmeans the patch covers the ruby gem alone. It says when a reference carries no list, and that a lock of platform builds is never moved to the ruby gem's registry.parity_gemfile_platform_lock_on_a_snapshot_given_plain_references).redirect_unattributable: "lockfile discovery could not attribute its pin to one package version, so nothing was written for it"). Itsvexdoes not read the snapshot URL as a patch registry: it warns that the remote "is on the Socket patch server but is not a patch-registry/gem/// index" and exits 2 with "No patches in this project; nothing to attest". A project that mixes 5.1.0 and this CLI keeps a working pair, but 5.1.0 cannot attest it.Review
/code-review highreported ten findings on the first version of this branch. All are fixed with tests; the two that mattered most are the rule that a lock is never moved to a fix that patches fewer of its locked builds, and the URL without a key for a ruby-only lock.The first CI run then found three more things, also fixed: "now also patched for …" was never reported for a lock with no
CHECKSUMSsection (it now asks the earlier list once when the key changes), a new real-Bundler test assumed which build Bundler names in an error, and the VEX generator's future had grown enough to overflow a test thread's stack in the coverage build (three futures are boxed, and a test bounds the size).Checked against Socket's backend
The backend's own serving, search and reference code was run on this machine against a private database, with the gem patch and one platform gem's patch published the way the service publishes them, real nokogiri 1.19.3 and Bundler 4.0.15. That run found what this PR's last commits fix: a platform gem's files are stamped per patch, so the client has to check each build against its own record; a ruby-only lock still loads a precompiled copy; and the stand-ins in this repository did not answer the way the service does.
CHECKSUMSvexexits 0 with 4 requests:not_affectedfor arm64-darwin,affectedfor x86_64-linux-gnu, no warning. Rollback restores both files byte for byte.CHECKSUMS)vexwith 3 requests: one statementnot_affected, sevenaffected, no warning.vexattests it with no request. Rollback is clean.PLATFORMSwithrubyalonevexexits 0 and saysaffected; after the command the patched gem loads andvexsaysnot_affected.cache/removedvexattests it with one read of the build's own record (3 requests), as it does with the archive present.repairrepairanswersvendor_prebuilt_replaced, downloads nothing and unpacks nothing.cache/holds the patched archivevexleaves the build out once, ashash_mismatch, by the build's own record (3 requests), and also with the file gone. The scan says nothing of the copy: its guard goes by the archive's sha256. With the file back,vexattests the build again.vexattests it with one record request for both copies. With one copy altered, neither the scan's own--vex(5 requests) nor a latervexattests the build.vexsay nothing new.vexattests the patched build with no warning. A request with no key is answered the plain registry and no list, and one that presents another key ispending_build. A project not on the patch yet is left on its upstream registry. The file of the gem being rebuilt is a 404 meanwhile. After the rebuild everything is as before.pending_build). One that presents the lock's key is answered the listing, so the scan andvexof the project on the patch say what they said before. After the rebuild everything is as before.already_vendored, 2 requests),repairandvendor --check(no request) exit 0, say what they said at rest and leave every committed file byte-identical, while the build is queued and while it is building.repairboth saythe patch service lists no builds for nokogiri@1.19.3 right now; run this again later, change nothing, and say nothing of a replaced or withdrawn build or of rolling back. No request presents a snapshot. After the rebuildrepairrestores the tree. The same for a rebuild of the vendored build and of the gem's own patch.vexsay what they said (Nothing left to patch, one statementnot_affected), and nothing changes.redirect_unattributable), Ruby still loads the patched build, a frozen install works, and this CLI's next scan finds the pair as it left it. 5.1.0'svexexits 2: it does not read the snapshot URL as a patch registry.bundle cache --all-platforms, a checkout with nothing installed,getby a platform gem's uuidvex) are identical.Testing
cargo fmt --all -- --checkandcargo clippy --locked --workspace --all-features -- -D warnings: clean.cargo test --locked -p socket-patch-core --no-fail-fast: 9,431 passed, 0 failed, 3 ignored.cargo test --locked -p socket-patch-cli --no-fail-fast: 5,989 passed, 2 failed, 538 ignored. The two failures are ine2e_vendor_cargo_build, which this branch does not touch (Bad CPU type in executable, an x86_64 toolchain on an arm64 Mac).--ignored:e2e_redirect_gem_build72 passed,e2e_vendor_gem_build13 passed. They cover a lock with one patched and one upstream platform (frozen mode too), no locked build patched, a later list with more patched builds,bundle lock --add-platform, locks with and without aCHECKSUMSsection, a ruby-only lock, a withdrawn build (the unchanged pair fails to install, the scan repairs it, a fresh checkout installs upstream's gem), and a newer fix with fewer builds.vexexits 1 withhash_mismatch; the vendored scan exits 1) and pass now: 36 and 26 checks with real nokogiri 1.18.10. The hosted leg runs through a rebuild of the installed build: the lock's key is answered the registry, a request with no key the plain registry and no list, and another keypending_build.Not run: the nokogiri workflow itself and the
docker-e2esuites (CI runs them), Linux, other Bundler versions for most cases. The gems of the two real-Bundler suites are still built from one patched file, so their per-build records list the same hashes; the vendored suite asserts thatvexattests a vendored gem whose ledger was deleted, which does not hold once each build's file differs. With the real service such a gem is left out asvendor_hash_mismatch.🤖 Generated with Claude Code