Repository navigation
Vendor a platform-locked gem once one platform has a patched build, with upstream's gem for the rest - #2342
Conversation
…atched build A gem `Gemfile.lock` names as precompiled platform gems was vendored only when every locked platform had a patched build. Bundler's default lock names eight platforms, so such a gem stayed unpatched in vendored mode until all eight had one. It is now vendored when the fix's list names a patched build for at least one locked platform. Each of the others gets the tree of the gem the patch registry lists for it: upstream's own gem, unchanged. That gem is downloaded from the patch server, checked against the sha256 the list names, and its tree carries the gemspec the gem itself holds (its `metadata.gz`, which Bundler reads like a Ruby gemspec). Hosted mode installs the same gem for such a platform. - The ledger records such a tree as a `gemBuilds` entry with no `uuid` and the sha256 of its gem. It records no files: the copy's file inventory vouches for every byte of the tree, as it does for the files of a patched tree that the patch does not name, and the digest is what a restore fetches the gem again by. - A copy that is intact asks for the fix's list (one request) and is vendored again when the list names another build for a locked platform: a patched build that was published since, or upstream's gem where the patched build was withdrawn. - A newer fix that has no patched build for a platform the vendored copy of an earlier patch holds one for is a skip: the earlier copy stays in force. - Unchanged: a lock none of whose platforms has a patched build, a platform the registry does not list, and a build the list names whose patch is not served are the skips they were. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…a build A gem vendored as platform gems is reported per tree. A tree of upstream's own gem (a locked platform with no patched build) now gets what hosted mode gives a locked build the patch registry serves as upstream's gem: - the advisory `skipped` event `gem_upstream_build_kept`, with no `uuid`, which `summary` does not count; `withdrawn: true` and the matching reason where the run put the tree in place of a patched build, and `newlyPatched: true` on a patched build the run put in place of upstream's gem; - one line per such gem under the summary line, in hosted mode's words (`nokogiri 1.19.3: patched for arm64-darwin; upstream gem kept for x86_64-linux-gnu (no patched build yet)`). A gem whose every tree is a patched build prints no line, as before; - in `vex`, the `affected` statement of that platform gem with what changes it, read from the ledger with no request. The patched trees are attested as before. `vendor --check` fails every tree of a copy that does not verify, the one of upstream's gem included, so a copy that holds upstream's gems alone still fails its check. Telemetry takes such a tree as about no patch. A dry run of `scan --mode vendored` asks the fix's list for a gem already vendored as platform gems, as the wet run does, and reports the trees the wet run would put in place when the list names other builds. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The stand-in patch service of the platform-gem tests now serves upstream's own gem for a platform it lists with no patched build, from the gem patch's registry and with the sha256 the list names. - A lock with one patched platform and one that has none: vendored, the one line, the counted and the advisory event, the ledger, a later run in step (one request), `vendor --check` and a change to the upstream tree, an offline `vex` (the patched build attested, the other stated `affected`), and revert byte for byte. - A later run that takes a published build and one that follows a withdrawal, each with its dry run first. - Every dry run (`vendor`, `scan`, `get`) says what the wet run does. - A takeover of a hosted gem with upstream's gem for a platform, by a scan and by an eject. - The tests of a gem that is left alone or stays hosted because of one platform now use a build whose patch is still being built, and a lock none of whose platforms has a patched build keeps the one-line skip. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The platform-gem capstone of the real-Bundler suite gains the mixed case: two locked platforms with a patched build (this machine's among them) and one the registry serves as upstream's own gem. The stand-in registry now serves that gem's file. The gem is vendored: two counted `applied` events and the advisory one, upstream's gem downloaded from the patch server, its tree with the YAML gemspec the gem carries. A fresh checkout installs frozen with no request to the patch service, Ruby loads the patched build of the running platform, `bundle install` and `bundle lock` regenerate the lock byte for byte, `vendor --check` passes and revert restores both files. A platform the list leaves out and a build whose patch is still being built stay the skips they were. An in-sync re-run now makes one request, and a newer patch that lacks a build the vendored copy holds is worded as hosted mode words it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…atform `CLI_CONTRACT.md`: the gem row of the vendored layouts (the tree of upstream's gem, where it comes from, the gem's line, how a later run follows the list, the ledger entry of such a tree, its events and its `vex` statement, the dry runs), and the rows of `vendor_prebuilt_platform_pending`, `vendor_prebuilt_replaced` and `gem_upstream_build_kept`. `docs/ecosystems.md`: the vendored row of the native-extensions table and the support matrix cell. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ript The vendored scenario of `tests/nokogiri/nokogiri_e2e.rb` no longer waits for every platform. With `--pass-through` naming some of the locked platforms, the scan vendors nokogiri with the patched build of the others and upstream's own gem, served by the stand-in's registry, for those. The script checks the events, the trees and their gemspecs, where upstream's gem was asked for, the line of a later scan, the `vex` statements, and a frozen install of a fresh checkout with the service unreachable: Ruby loads the patched nokogiri where this machine's platform has a patched build, and upstream's nokogiri from the committed tree where it has none (`--pass-through own`). The next scan then takes the builds the stand-in publishes. With no patched build at all nothing is vendored, as before. The compatibility workflow runs the vendored scenario with the runner's own platform passed through as well. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…he list The line that says which platform builds of a gem are patched is printed by hosted mode and now by vendored mode. It moves, with the filter vendored mode applies to it, into the helper module `commands/gem_build_lines.rs`, so that `vendor` does not import `scan` (the command modules' layering test). The core test of the request-less preview covers a lock already wired to the patch's copy: one request (the fix's list) while the copy holds what the list names, the trees the wet run would put in place when the list names another build, and no promise when a patched build it names is not served. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Review findings on the gem backend, with the rule that an intact committed copy is never made worse and a run never fails because of something it could have left alone. - An intact copy whose list moved went through the rebuild of a missing or stale copy, where any failure but the pending skip ended the run. When the list cannot be followed (a request that fails, a build whose gem fails its digest or whose stub is not served, an upstream gem that does not unpack) the copy now stays in force: the run ends as it does for a copy in step, with one line (`vendor_gem_list_not_followed`). A build the list names that is not served yet keeps its skip. A dry run says the same. The advisory of a copy that did follow its list has a code of its own (`vendor_gem_list_followed`). - A ledger entry that names no build of its trees says nothing of a moved list: no request is made for it and the copy stands. - The package references of several patches can be asked for in one request and remembered by the client: a later read of one of them makes no request, and a request that brought no answer is not made again per patch. A run asks for the lists of the gems it finds vendored this way, and the fix's reference is read once whether or not the list moved. - Upstream's own gem is downloaded with a client that follows no redirect: a redirect the registry answers is the gem not being served. - The skips of `locked_build_sources` (a platform the list leaves out, no patched build at all, a newer fix with fewer builds) are judged before an upstream gem the list does not pin fails the gem. - The download advisory names a copy of upstream's gems alone as such and says where it came from, the `.gitignore` advisory names the gems as they are, and the registry URL of an upstream gem is built in one place. - The ledger's doc comment says what each older reader does with a tree of upstream's gem. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…t real skips Review findings on the CLI side of a gem vendored as platform gems. - The vendor loop restores a damaged copy before it reaches the backend and stopped at a restore error. A restore that is refused only because the list of the gem's fix names other builds now (`vendor_prebuilt_replaced`) goes on to the backend, which vendors the copy again from that list, as it does for an intact copy. `repair` still refuses and names the scan. A ledger edited to name another patch for a tree looks the same and is settled the same way: the list chooses what is unpacked. - The lists of the gems already vendored as platform gems are asked for in one request before the loop, and by the dry-run preview of a scan. - `VendorTally` no longer subtracts the uncounted advisory event of a tree of upstream's gem, so a package skipped beside such a gem is said. - `vex`: a tree of upstream's gem under a purl the view already attests leaves that purl alone, as a hosted build does. - The dry-run preview of a scan reports an in-step copy per tree, with the gem's line, as the real run does. - The line of a copy that could not follow its list prints as a note. Tests: a damaged copy after the list moved (either tree), an intact copy whose rebuild fails with every file compared byte for byte (dry and wet), the dry run of an in-step copy, the tally, the vex view, and the edited ledger settled by the list. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`CLI_CONTRACT.md`: the one request for the lists of all the gems vendored as platform gems, the download of upstream's gem that follows no redirect, what a run does when the list cannot be read or cannot be followed (`vendor_gem_list_not_followed`, a note, exit 0, the copy untouched), the advisory of a copy that followed its list (`vendor_gem_list_followed`), and that a vendor run whose exact restore is refused because the list moved vendors the copy again from the list while `repair` still refuses. `docs/ecosystems.md`: the same in the vendored row of the native-extensions table. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
With `--pass-through-redirect` the stand-in registry answers the file of upstream's gem with a redirect to its upstream stand-in. Vendored mode takes that gem from the patch service alone, so the vendored scenario now checks that the scan does not vendor the gem, asks nothing of the upstream stand-in and writes nothing, and then goes on once the stand-in publishes the builds. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… the client memo Review findings on the gem backend and the API client. - A run that could not vendor an intact copy again said the copy "stays in force as it is" without looking at it. Two failures happen after the copy was changed: the new trees are in place and the uuid dir's git metadata cannot be written, or the swap of the stage fails and cannot be undone. One function, `copy_in_force`, now answers whether the recorded copy stands with its metadata in place. The in-step path and every outcome that says the copy stays in force go through it (`wired_copy_failed`); a copy that no longer stands is the failure it is for any damaged copy. A copy left in force gets its `.gitignore` and `.gitattributes` put back, as a copy in step does. - The client-wide memo of batched references is gone, and with it the remembered "no answer" that failed later reads of the same patch. The batch goes through the vendor prefetch plan: a planned download can be a position whose reference alone is read (`PlannedDownload::reference`), which shares the plan's one reference request and is never fetched ahead. - The rebuild of a copy whose list moved takes the gems that list was read to name (`BuildsFrom::Listed`), so the fix's reference is asked for once with or without a plan. - A redirect is "not found" only for the client that follows none. The client that follows redirects answers one it cannot follow as it did. - `restore` returns a structured reason (`RestoreError::list_moved`), true only when the list of the gem's fix names another build than the entry records; a reference that does not pin upstream's gem is a miss. `restore_follows_list` asks the same without downloading, for a dry run. - `follows_list` is the one rule for which copies follow a list. - Failure points for the stage swap, its undo and the uuid dir's metadata, for the tests of the two failures above (debug builds only). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…restore by its reason Review findings on the CLI side of a gem vendored as platform gems. - The collect, sort, dedup and remember block is gone from the vendor loop and from the dry-run preview of a scan. One helper, `list_follower`, says which packages follow the list of their fix; the vendor loop plans each as a position whose reference alone is read (a dry run plans nothing else), and the preview attaches the same plan for the rows in step. The plan's one reference request serves them, under its own guard. - The fall-through after a refused restore is decided by the restore's structured reason (`list_moved`), not by the prefix of a formatted error, so a reference that does not pin upstream's gem is the failure it is. - The dry run of a damaged copy whose list moved no longer reports `wouldRedownload` and stops: it asks whether the restore would be refused for a moved list and, as the wet run does, goes on to preview the copy vendored from the list. - `vex`: every tree of a vendored copy whose purl the view already attests is left to that record, as the hosted loop does, the patched ones included. Tests: each of the two failures that change the copy (the uuid dir's metadata after the trees are in place; a stage swap that cannot be undone) forced with a failure point, with what is printed and the exit code; the dry run of a damaged copy; the metadata put back by a run that leaves the copy in force; the vex view for a patched tree. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…n of a damaged copy `CLI_CONTRACT.md`: the references of the gems vendored as platform gems are positions of the run's download plan and share its one request; what an unreachable service costs; a run says a copy stays in force only after checking that it stands, with its git metadata put back; a rebuild that fails after it changed the copy is a failure; the fall-through after a refused restore is for a moved list alone, and its dry run previews the copy vendored from the list. `docs/ecosystems.md`: the same, briefly. The planner shim the tests call is compiled for tests only. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…a wired gem's metadata before the swap Third review round, the core side. - The download plan: a position whose reference alone is read keeps the batch's answer, so a restore and the rebuild after it read the same list with one request; a batch request that failed is the answer of every such position it named, so a batch the service refuses is not asked again once per position; and a package fetch never waits on such a position, of which nothing is fetched. `ApiError` is `Clone`. - A gem the lock names as platform gems is planned by its own backend as a reference-only position, and `in_step_reference` says which in-step packages still read one. Those positions no longer depend on what gates the downloads: where nothing is fetched ahead the plan holds them alone, and its task never runs. - The uuid dir's git metadata of a wired copy is written before the new trees are moved in, so a write that fails leaves the copy as it was and the copy stays in force. The failure point for the state this removes is gone; the ones for the swap and its undo stay. - The skip of a build that is not served yet says what there is to say of the metadata at the end of its line. - `RestoreError` is an enum (`ListMoved` or `Failed`, each with its detail) with no `Deref` and no out-parameter. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…build as not in step Third review round, the CLI side and the contract. - `vex`: a tree of a vendored copy is left to an existing record only when that record is of another patch. A record of the tree's own patch is of the same build, which the committed tree attests. (End to end, the manifest record of a platform gem's own patch is set aside for the wired patch before this is reached, `vex_record_superseded`; the test of that scenario passed before the change and stays as a regression test.) - The planner asks the backend which in-step packages still read a reference (`vendor::in_step_reference`); the CLI's own helper is gone. A run that fetches nothing ahead (a dry run, or an API in-flight cap of one) judges only the candidates whose ledger entry is such a package, and none when the ledger has no such entry. - A dry run counts a copy as in step only when its trees are the builds the ledger records: a build replaced under another patch is one the wet run vendors again. - `RestoreError` is matched as the enum it is, in the vendor loop and in `repair`. - `CLI_CONTRACT.md`: the shared request no longer depends on the archive gates; a failed request is the answer for every gem it named; the metadata is written before the trees are moved in. Tests: the dry-run tally of a damaged copy with a replaced build; the planner with nothing to plan; a copy whose metadata cannot be written stays in force (exit 0, nothing moved in); the swap that cannot be undone, kept; the vex view for a record of the tree's own patch. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A gem that follows the list of its fix may read that reference more than once in a run: the restore of a damaged copy, then the rebuild or the in-step check. With one such gem and nothing else planned there was no plan, so the two reads were two requests that could see two lists. The plan is now attached for one reference-only position as well; its task, which only a download starts, never runs. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryHigh Risk Overview In-sync re-vendors now follow the patch registry's Supporting changes: shared Reviewed by Cursor Bugbot for commit 6910805. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6910805. Configure here.
| .iter() | ||
| .filter(patched) | ||
| .any(|build| !build.newly_patched); | ||
| if gained || builds.iter().any(|build| build.uuid.is_none()) { |
There was a problem hiding this comment.
All-upstream follow omits the gem line
Low Severity
format_vendored_gem_build_lines prints a gem only when it still has an upstream tree or when some platforms were already patched and others became patched on this run. A copy that held only upstream trees and is brought fully in step (every locked platform now patched) matches neither check, so the run’s “now also patched” line is omitted even though this is a list-follow.
Reviewed by Cursor Bugbot for commit 6910805. Configure here.
There was a problem hiding this comment.
[agent] PR shepherd: this is real. moved_sources lets a wired copy follow a list whose patched builds were all withdrawn back to upstream's gems, so a copy can hold only upstream trees. When builds are later published for every locked platform, every report is newly_patched and none is upstream, so format_vendored_gem_build_lines says nothing. PinReport can't tell that case apart from a first vendor of an all-patched gem, which also prints nothing by design. Fixing it means carrying "the ledger held this gem before" into the report: a field on PinReport (16 constructors) plus an event detail that gem_build_reports_of reads back. I've left that to the PR's author rather than add a field to a core type in a shepherd pass. The thread stays open.
Generated by Claude Code
The `vendor_prebuilt_replaced` error and its contract row told the user to roll the gem back and then run a vendored scan. A vendored scan alone vendors the copy again from the list, so the message and the row name that one command, once. The skip of a build that is listed but not served yet, and the skip of a platform the registry does not list, still said "Vendored mode needs every locked platform". They say what is needed now: a gem, patched or upstream's own, for every locked platform. The contract and the guide state which releases read a copy with a tree of upstream's gem: one with this support and the platform-gem vendoring it builds on. 5.1.0 and earlier do not know such a tree and can attest the gem as patched for every platform. Tests pin the remedy sentence and that it names one command in the core restore tests and the CLI repair test, the two skip lines at 80 columns, and the contract row and the guide sentence. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The vendored loop of the vex view made an exception for a record of the tree's own patch. By the account of the commit that added it, no run reaches it: a manifest record of a platform gem's own patch is set aside for the wired patch before the loop runs. The loop follows the hosted loop's rule again, a purl the view already attests keeps its record, and compares no uuid. What is left is always an insert, so it is one. `repair` reads the detail of a refused restore through the one accessor. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tadata after the swap The fourth review's findings came from two things that are now gone. The lists of the gems a run finds vendored as platform gems no longer ride the download plan. `reference_only`, the single-position plan, the kept answers, the replayed failure and the planner's reference pass are removed, and the prefetch plan is what it is on the base branch. Each such gem asks for the reference of its own fix, live, where it needs it: one small request per vendored platform gem per run. A service that does not answer is bounded by the client's circuit breaker, and a gem whose reference cannot be read keeps its copy and says nothing. A restore and the rebuild that follows it are decided by one answer without a cache: the restore reads the fix's list once (`FixList`), and a refusal over it (`RestoreError::ListMoved`) carries it to the backend, which vendors the copy again from it. The dry run's question hands the same list. `BuildsFrom::Listed` holds the list where it was already read, and the request is made in one function. The uuid directory's git metadata is written after the new trees are in place again. It is not part of the copy, so a write that fails is the warning every backend gives for ignore rules it could not vouch for, and never a failure: the trees are in place, and the entry handed back records them. A failed rebuild no longer leaves a uuid directory holding the metadata alone, and unwritable metadata no longer stops a rebuild. The "Also:" suffix of the pending skip, which nothing could produce, is removed. Tests: the request of a copy in step names its own fix alone; a refused restore hands its list on and the fix's reference is asked for once, wet and dry, at the core and CLI levels; unwritable metadata is a warning with the new trees in place and recorded; a failed rebuild leaves no uuid directory where there was none. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…arning The contract and the guide state the cost of following a list plainly: one small request per vendored platform gem per run, not batched. A refused restore hands the list it read to the rebuild; a damaged copy whose list did not move is restored and then asked about once more. The uuid directory's git metadata is written after the trees are in place, and a failed write is `vendor_artifact_gitignore_unchecked`, whose row now names the gem. The "Also:" suffix is gone from the contract. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The contract and the guide said that 5.1.0 and earlier could attest the gem as patched for every platform. Run against a project vendored with one patched platform and one platform on upstream's gem, 5.1.0 does neither: it has no platform-gem vendoring, so `vendor --check` fails (`vendor_check_failed`, a patched file is missing) and `vex` leaves the gem out (`vendor_unwired`) and attests nothing for it. Both texts say that, and the test that pins them follows. The metadata test gains the first vendor: a uuid directory whose git metadata cannot be written is vendored, wired and recorded all the same, with the warning. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… about its list once, briefly The fifth review found the uuid directory's git metadata handled five ways. One function, `finish_platform_copy`, now ends every path that puts the trees of a gem vendored as platform gems in place or says they stay in force: a first vendor, a rebuild of a wired copy, a restore, a copy found in step and one that stays in force. - It writes the uuid directory's `.gitignore` and `.gitattributes`. A write that fails is the warning `vendor_gem_git_metadata_unwritten`, which names the two files and says to make them writable. No path treats it as an error any more (`restore` did), and none drops it: a skip that leaves the copy in force ends its line with it. - Then it asks git whether it would commit the copy. Only a first vendor did; a rebuild of a wired copy with a project `*.so` rule and an unwritable `.gitignore` left the binaries out of the commit with a generic warning. The refusal names the unwritten files as its cause when that is why, with that remedy. A first vendor removes the copy it made; a copy the lock already names stays where it is, and git is asked with its index, since it keeps committing a file it tracks. The question a copy in step asks of its fix's list is advisory: one attempt of at most five seconds, never retried and outside the circuit breaker (`fetch_vendor_reference_once`, on the client's existing single POST). Two such reads that failed used to open the breaker and fail the run's real vendoring unasked, after two retry ladders. `restore_with_list` hands back the list a restore read when it restores the copy too, and the backend judges the copy by it, so the two no longer ask twice. `FixList` carries its fix's uuid, and a list of another fix is ignored. `restore_list` takes the service and the name and version it is given; the gems a list names are resolved once and handed on as such. The vendored `vex` loop is unchanged: a new end-to-end test with a manifest record of a build's own patch beside the vendored entry shows the build attested from the committed tree. Tests: unwritable metadata on every path, at the core and CLI levels, with and without a project rule that ignores the binaries, tracked and not; the advisory read at the client (one request whatever the policy, the breaker untouched, its own bound when nothing answers) and in the backend; the list handed on by a restore that succeeds, and a list of another fix. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ck is advisory The contract describes the one step every path ends a copy with, the new warning `vendor_gem_git_metadata_unwritten` in a row of its own, and the refusal that names it as the cause. The row of `vendor_artifact_gitignore_unchecked` is what it was: it never covered a write failure. The list request of a copy in step is described as what it is, one short attempt outside the circuit breaker, and a restore as handing its list on whether it restores the copy or is refused. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The base branch gained one commit: the sentence that says what released 5.1.0 does with a gem vendored as platform gems, in the contract and the guide, and the test that pins it. Both branches changed the same line of each document. This branch's wording stays, which is the wider one (it also covers a copy with a tree of upstream's gem) and contains the sentence the base branch's test pins. Both tests stay. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… placed, before the swap The sixth review's findings came from asking git on every path that finishes a copy. That was wrong for a copy that is already committed. `finish_platform_copy` keeps its one write of the uuid directory's `.gitignore` and `.gitattributes` (a failure is the warning, never an error) and takes a mode in place of a flag: - `CopyStep::Placing`: a first vendor, a rebuild of a wired copy, a restore, and a dry run's preview of one. Git is asked BEFORE the staged trees are moved in, as if nothing were tracked, which does not read the index. With the uuid directory's own rules in place no rule above them reaches a file of the copy, so the question is whether a rule excludes the directory; where they could not be written it is asked of every staged file, and the refusal names that as its cause. A refusal leaves what is on disk as it was: a first vendor writes nothing, an intact copy whose list moved stays in force through the note that already says so, with the refusal as the reason, and a restore reports its failure with the copy as it was. A dry run asks the same question and writes nothing. - `CopyStep::Confirming`: a copy found in step or left in force. Git is asked nothing, as on the base branch. Before, a rebuild was refused only after the new trees were swapped in, which left an intact copy with trees the ledger did not record and exit 1, and made every later scan download the gems again. An in-step scan ran `git check-ignore` against the index for every file of the copy on every run, and could fail a copy in a project without a `.git` of its own. A run that did not place its trees leaves no uuid directory holding the metadata alone. Tests, at the core and CLI levels: a refusal on each path with the copy compared before and after, dry and wet alike; a committed copy whose list moves under a rule that excludes its directory stays byte for byte with one note that names the rule; a copy in step starts git for the run's own ledger check and nothing else, and a rebuild asks one question without the index, the same in a dry run (counted with a logging `git` on PATH); a copy in step in an ignored directory of an outer repository stands. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The contract and the guide say that git is asked only where trees are about to be placed, before they are moved in and without the index, in a dry run too; that a refusal leaves what is on disk as it was, on each path; and that a copy in step or left in force asks git nothing. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A scan or get vendored dry run reported an intact platform-gem copy as already vendored when the fix's list had moved to a patched build the patch service does not serve yet. preview_locked_builds dropped that refusal, so ask_platform_gems kept the in-sync verdict, while the wet run skips the gem with vendor_prebuilt_platform_pending and says the copy stays in force (wired_copy_failed). The preview of a wired lock now returns the pending refusal, and the scan preview turns it into the wet run's skip line for an intact copy. Any other refusal still leaves the copy's verdict as it was. Assisted-by: Claude Code:claude-opus-5-5
…test 614513e made preview_locked_builds return the wet run's vendor_prebuilt_platform_pending refusal for a wired lock whose list names a patched build the service does not serve yet. The no-record preview test still expected None for that case, so the coverage leg failed. Assert the pending refusal instead, as the wired-copy test added in 614513e does. Assisted-by: Claude Code:claude-opus-5-5
|
[agent] PR shepherd: this PR can't move without a person, so I've added
The rest is in order: no conflict, Generated by Claude Code |
cfd675f
into
feat/gem-complete-registry


Stacked on #2273. Offered for the maintainer to take or leave: #2273 does not depend on it.
What this does
A gem that
Gemfile.locknames as precompiled platform gems is vendored as soon as one locked platform has a patched build. Vendored mode then mirrors what hosted mode already does for such a lock:.gemis the one the gem patch's registry lists for the platform. It is downloaded from Socket's patch server (the registry'sgems/<name>-<version>-<platform>.gem), never from the upstream registry: the download follows no redirect, and one the registry answers is the gem not being served. It is checked against the sha256 the list names. Its tree carries the gemspec the gem itself holds (metadata.gz), which Bundler reads the way it reads a Ruby gemspec.nokogiri 1.19.3: patched for arm64-darwin; upstream gem kept for x86_64-linux-gnu (no patched build yet)appliedevent per patched build under its own patch, and the uncounted advisory eventgem_upstream_build_kept(nouuid) for a tree of upstream's gem.vexattests the patched builds from the ledger, offline, as before, and states a platform whose tree is upstream's gemaffected, with what changes that.now also patched for …), or upstream's gem where the patched build was withdrawn (upstream gem back for … (its patched build was withdrawn)). TheGemfileand the lock are not touched.Why
#2273 vendors such a gem only when every locked platform has a patched build. Bundler's default lock of nokogiri names eight platforms, so vendored mode would not patch it until all eight have builds, while hosted mode patches the lock as soon as one has.
The ledger
A tree of upstream's gem is a
gemBuildsentry with itsplatformandgemIntegrity(thesha256-…of the gem the list named) and nothing else: nouuid, nogemspecIntegrity, nofiles. That is enough because:vendor --checkandvexalready verify a tree that holds no patched file by the copy's file inventory, which covers every file of it. A changed, missing or added file fails the check.repairfetches the same gem again from the gem patch's registry and requires the recorded sha256. It refuses (vendor_prebuilt_replaced) when the list names a patched build for the platform now, or no gem, and names the one command that works then:socket-patch scan --mode vendored, which vendors the copy again from the list.No new mechanism: one optional field in an existing entry, the registry URL the reference already carries, and the artifact download the client already has.
What a default lock commits
Bundler's default lock of nokogiri 1.19.3 names eight platforms. Measured with the real gems, the
.socket/directory plus theGemfileand the lock in a fresh repository:gc --aggressive)The two cases are the same size: a tree of upstream's gem is the same tree without the patch. One tree is 7.0 to 14.9 MB. The first scan of the mixed case downloads the seven upstream gems through the patch server (36.5 MB in 15 requests against a local run of the patch service).
What is unchanged
Vendored mode needs a gem, patched or upstream's own, for every locked platform.rubyplatform, and the refusal of a native gem locked as its source gem.vendor --revertandrollbackrestore theGemfileand the lock byte for byte.What changes for a copy that is already vendored
A run over an intact copy of a platform-locked gem made no request before. Each such gem now asks the patch service for the reference of its own fix when the run reaches it; that is how a run sees a published or withdrawn build.
The cost: one small request per vendored platform gem per run, wet or dry (about 3 KB and 10 ms against a local run of the patch service). Nothing is downloaded for a copy in step. The requests are not batched.
The request is advisory, because the copy stands whatever the answer: one attempt of at most five seconds, never retried, and outside the circuit breaker the run's other requests share. A reference endpoint that is down costs a scan one short attempt per such gem, and cannot fail what the run has to vendor. Before, two such reads that failed opened the breaker, and each took the whole retry ladder (timings below).
An intact copy is never made worse, and a run never fails over one:
.gitignoreand.gitattributesif one is missing, exits 0, counts the copy as it counts one in step, and prints one note:Note: nokogiri@1.19.3 could not be brought in step with the builds the patch registry lists (<why>); its vendored copy stays in force as it is.(vendor_gem_list_not_followedin--json).One step finishes a copy, in one of two modes.
.gitignoreand.gitattributes, in both modes. They are not part of the copy, so a write that fails is a warning, never a failure:vendor_gem_git_metadata_unwritten, which names the two files and says to make them writable. A skip that leaves the copy in force carries no warning and ends its line with it (… stays in force as it is. Also: could not write …).vendor_artifact_gitignored) leaves what is on disk as it was: a first vendor writes nothing, an intact copy whose list moved stays in force with the note above, and a damaged copy is neither restored nor rebuilt. A dry run asks the same question, so it says what the wet run does.With the directory's own
.gitignorein place (!*) no rule above it reaches a file of the copy, so the question is whether a rule excludes the directory itself. Where that file could not be written, the question is asked of every staged file, and the refusal names the unwritten files as its cause, with that remedy.When the list has moved, the whole copy is vendored again, every tree, not only the one that changed.
A copy that is damaged after the list moved is vendored again from the current list by the next vendor or scan run. The exact restore of it is refused, because the list names another build, and the run then goes on instead of failing; its dry run previews the same. A restore hands the list it read to the gem's backend whether it is refused over that list or restores the copy, so the copy is vendored again, or found in step, by the one answer the restore read, and the fix's reference is asked for once. The list carries its fix's uuid, and one of another fix is not used.
repairstill refuses and names the scan.What the maintainer must know
A copy with a tree of upstream's gem needs a CLI that reads the
gemBuildsentry of that tree. What the older readers do:vendor --checkexits 1:pkg:gem/nokogiri@1.19.3?platform=ruby: committed artifact .socket/vendor/gem/<uuid>/nokogiri-1.19.3 is missing a patched file (file_not_found); run `socket-patch repair` to restore it, then commit it(vendor_check_failed).vexandvex --offlineexit 1 and write no document. They warn that the lock's platform entries are not wiring they know, omit the gem (vendor_unwired) and, in a project with no other patch, end withError: No applied patches with vulnerability metadata to attest.maintoday knows platform trees and nogemBuilds. It ignores the key and judges the trees it finds on disk by the files of the gem's patch, so it passes a tree of upstream's gem whenever that gem ships none of the patched files, and would then attest the gem for every platform. (Read in the code, not run.)So no release attests such a copy wrongly, and a release that can produce one has to contain a reader that knows it (#2273 plus this change).
CLI_CONTRACT.mdanddocs/ecosystems.mdsaid that 5.1.0 could attest every platform; they now say what it does.How it was tested
vendor,scanandget, dry and wet, JSON and human output, the ledger,vendor --check, an offlinevex, revert, a hosted-to-vendored takeover and an eject.bundle installandbundle lockregenerate the lock byte for byte, revert restores both files.tests/nokogiri/nokogiri_e2e.rbwith real nokogiri 1.18.10, eight locked platforms: vendored with every build patched, with the other platforms on upstream's gem, and with this machine's own platform on upstream's gem (Ruby loads upstream's nokogiri from the committed tree, then the patched one after the stand-in publishes the build). The compatibility workflow gains that last row.repairof a removed upstream tree and of a removed patched tree, a second platform build published later, that build withdrawn, released 5.1.0 on the mixed copy, and the all-patched, rebuild-window and hosted runs as regression checks.Numbers on this Mac (arm64, Bundler 4.0.15), at
72463e60e, which contains the base branch at50489f84c.cargo fmt --all -- --checkandcargo clippy --locked --workspace --all-features -- -D warnings: clean.cargo test -p socket-patch-core: 9,451 passed, 0 failed, 3 ignored.cargo test -p socket-patch-cli: 6,011 passed, 2 failed, 538 ignored. The two failures aree2e_vendor_cargo_buildcases that need an x86_64 toolchain this machine lacks, and fail on the base branch too.e2e_redirect_gem_build,e2e_vendor_gem_build,--ignored): 72 and 13 passed.nokogiri_e2e.rb: vendored 26, vendored with the other platforms on upstream's gem 44, vendored with this machine's platform on upstream's gem 45, the same against a registry that redirects upstream's gem 29, hosted 58 checks, all pass.gitfirst onPATH.Requests against the local backend, one vendored platform gem:
With N such gems a scan makes N list requests.
A scan of a copy in step (
scan --mode vendored --yes, the default lock's eight trees, 1,620 files) in a repository of its own, median of five runs, git 2.54:A scan of a copy in step (
scan --mode vendored --yes) while the service does not answer:Error: The API query failed: Network error: … Connection refused: the scan's own query fails before the copy is looked atdeadline has elapsed), after the scan's own connect timeoutReview
Six rounds of
/code-review highon this branch's own commits, all findings fixed: ten each in the first five, four (high and medium only) in the sixth. The third to sixth found no high-severity bug. The fourth round removed two things earlier rounds had added, so some fixes listed under the second and third rounds no longer exist: they are marked.First round (
445f752cb):vexcould state one product both ways when the view already attested the purl of a tree of upstream's gem.Second round (
373ce9dcd), which removed the client-wide memo the first round's fix for 3 had added:vexleaves every tree whose purl the view already attests to that record, the patched ones included.Third round (
b7c53236c). Its fixes 2, 4, 5, 6 and 8 were to the batch, which the fourth round removed, and the fourth round reversed 1, 7 and 9:vexleft every vendored tree whose purl already had a record to that record, the tree's own patch included. It now does so only for a record of another patch. The scenario the review described (a manifest record of a platform gem's own patch) does not lose the attestation end to end: that record is set aside for the wired patch first (vex_record_superseded), and the test of it passed before the change.RestoreErroris an enum matched by the vendor loop andrepair; the leftovers are removed.After the third round, three texts were corrected:
vendor_prebuilt_replacedmessage and its contract row named a rollback and then a vendored scan. The scan alone works since the first round, and both name it once.Vendored mode needs every locked platform. They say what is needed now: a gem, patched or upstream's own, for every locked platform.Fourth round (
5412a4489). Five of its findings came from carrying the fix references through the download plan and three from writing the uuid directory's metadata before the swap. Both are removed:Also: …suffix on the pending skip could not be produced. It is removed, with its contract text.ownexception in the vendoredvexloop could not be reached. It is removed: the loop follows the hosted loop's rule, and compares no uuid.follows_listis the one predicate, andrepairreads the detail of a refused restore through the one accessor.The round removed more than it added: 727 lines deleted and 532 added since
5412a4489.Fifth round (
70cc02146). Five of its findings were the uuid directory's metadata handled differently on each path:restorestill failed over the metadata; a first vendor that was refused by the commit check dropped the warning that named the cause; and the contract row of the warning contradicted the write failure. One function finishes a copy on every path (above), with a warning and a contract row of its own. (The sixth round took the commit check away from a copy that is already there.)vexloop stays as it is.restore_listtakes the service and the name and version it is given, and the gems a list names are resolved once and handed on.Sixth round (
e141f970e), four medium findings. Three came from asking git on every path that finishes a copy, which was wrong for a copy that is already committed:git check-ignoreagainst the index for every file of the copy (1.3 s per gem with a 100,000-entry index). A copy that is there asks git nothing; where trees are placed the question does not read the index..gitof its own inside an ignored directory of an outer repository. It asks git nothing now. A wet run is still refused there by the run's own ledger check, as on the base branch and in 5.1.0 (see the decisions below).What was not run
/code-reviewon the commits aftere141f970e(the sixth round's fixes).main, the one of Patch gems locked as platform gems in hosted and vendored mode: patched builds where they exist, upstream's gem elsewhere #2273) against a mixed copy: read, not run.Decisions a reviewer may want to change
.gitignorethat a patch itself rewrites inside a tree is kept as the patch has it, and what it ignores is no longer asked about: before the trees are in place git reads no such file. The base branch asked after the swap.build/): the gem asks git nothing about a copy in step there, and a scan's dry run saysalready_vendored. A wet scan orvendorrun is refused before it looks at any package, by the run's own ledger check (vendor_artifact_gitignoredfor.socket/vendor). That check is the base branch's and 5.1.0's, and is left as it is.vendor_gem_git_metadata_unwritten) instead of sharingvendor_artifact_gitignore_unchecked, whose remedy does not fit it.🤖 Generated with Claude Code
Generated by Claude Code