Skip to content

Vendor a platform-locked gem once one platform has a patched build, with upstream's gem for the rest - #2342

Merged
Mikola Lysenko (mikolalysenko) merged 30 commits into
feat/gem-complete-registryfrom
feat/gem-vendored-partial
Nov 30, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 30 commits into
feat/gem-complete-registryfrom
feat/gem-vendored-partial

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #2273. Offered for the maintainer to take or leave: #2273 does not depend on it.

What this does

A gem that Gemfile.lock names 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:

  • A locked platform with a patched build gets that build's tree, as in Patch gems locked as platform gems in hosted and vendored mode: patched builds where they exist, upstream's gem elsewhere #2273.
  • A locked platform with no patched build gets the tree of upstream's own gem, unchanged. The .gem is the one the gem patch's registry lists for the platform. It is downloaded from Socket's patch server (the registry's gems/<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.
  • One line per such gem, in hosted mode's words and from hosted mode's code:
    nokogiri 1.19.3: patched for arm64-darwin; upstream gem kept for x86_64-linux-gnu (no patched build yet)
  • Counting as in hosted mode: one applied event per patched build under its own patch, and the uncounted advisory event gem_upstream_build_kept (no uuid) for a tree of upstream's gem.
  • vex attests the patched builds from the ledger, offline, as before, and states a platform whose tree is upstream's gem affected, with what changes that.
  • A later scan follows the list. Each gem vendored this way asks for the reference of its own fix (one small request per such gem per run), and the copy is vendored again when the list names another build for a locked platform: a patched build published since (now also patched for …), or upstream's gem where the patched build was withdrawn (upstream gem back for … (its patched build was withdrawn)). The Gemfile and the lock are not touched.
  • It never moves to a newer patch that has no patched build for a platform the vendored copy of an earlier patch holds one for. The earlier copy stays in force, as a hosted lock stays on the patch it is on.

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 gemBuilds entry with its platform and gemIntegrity (the sha256-… of the gem the list named) and nothing else: no uuid, no gemspecIntegrity, no files. That is enough because:

  • vendor --check and vex already 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.
  • repair fetches 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 the Gemfile and the lock in a fresh repository:

files bytes on disk git objects, loose git pack (gc --aggressive)
all eight patched 1,620 86,895,326 (du 88,708 KiB) 36,904 KiB 29,280 KiB
one patched, seven upstream 1,620 86,877,825 (du 88,648 KiB) 36,880 KiB 29,279 KiB

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

  • No locked platform has a patched build: the one-line skip, exit 0, nothing written.
  • A platform the registry does not list: the skip with its remedy.
  • A patched build the list names whose patch is not served yet: the skip. The registry then lists neither a build that can be vendored nor upstream's gem for that platform.
  • Both skips say what vendored mode needs now: Vendored mode needs a gem, patched or upstream's own, for every locked platform.
  • A rebuild: an intact copy is untouched, and a miss is worded by the service's answer.
  • Locks that name the gem for the ruby platform, and the refusal of a native gem locked as its source gem.
  • A gem whose every tree is a patched build prints what it printed (no new line).
  • vendor --revert and rollback restore the Gemfile and 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:

  • Offline, when the request fails, or when the list cannot be read, the copy stands as it is and nothing is said.
  • When the list names another build but the copy cannot be vendored again from it (a download that fails, a gem that fails its digest, a stub that is not served, an upstream gem that does not unpack), nothing of the copy is touched. The run checks that the recorded copy still stands, puts back the uuid directory's .gitignore and .gitattributes if 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_followed in --json).
  • When git would not commit the trees the list names (a rule that excludes the vendored directory, added since; or a project rule that ignores the binaries while the directory's own ignore rules cannot be written), nothing is moved in. The same note says so, with git's refusal, the rule and the remedy as the reason.
  • A ledger entry that names no build of its trees is not asked about.
  • A rebuild that fails after it changed the copy is a failure the user sees (exit 1): the new copy cannot be moved into place and the old one cannot be moved back (it is kept beside the path). The next run vendors the copy again from the list.

One step finishes a copy, in one of two modes.

  • It writes the uuid directory's .gitignore and .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 …).
  • Placing trees (a first vendor, a rebuild of a copy the lock is wired to, a restore, and a dry run's preview of one): git is asked whether it would commit them, before they are moved in and as if nothing were tracked, which does not read the index. A refusal (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.
  • Confirming a copy that is there (found in step, or left in force): git is asked nothing, as on the base branch. The copy is already what the project commits.

With the directory's own .gitignore in 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. repair still 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 gemBuilds entry of that tree. What the older readers do:

  • Released 5.1.0 fails closed. It was run on a project this branch vendored with one patched platform and one platform on upstream's gem (nokogiri 1.19.3, local backend). It has no platform-gem vendoring at all, and makes no request:
    • vendor --check exits 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).
    • vex and vex --offline exit 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 with Error: No applied patches with vulnerability metadata to attest.
  • The reader of Patch gems locked as platform gems in hosted and vendored mode: patched builds where they exist, upstream's gem elsewhere #2273 requires a patch for every tree and fails on such an entry, so it attests nothing. (Read in the code, not run.)
  • The unreleased reader on main today knows platform trees and no gemBuilds. 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.md and docs/ecosystems.md said that 5.1.0 could attest every platform; they now say what it does.

How it was tested

  • Core unit tests: the mixed case, a gain and a withdrawal step by step with dry runs, upstream gems that are not the listed one, restore of an upstream tree and its refusals, the request-less preview.
  • CLI-level tests against a stand-in service that serves upstream's gem from the registry: vendor, scan and get, dry and wet, JSON and human output, the ledger, vendor --check, an offline vex, revert, a hosted-to-vendored takeover and an eject.
  • Real Bundler (4.0.15): the platform-gem capstone gains the mixed case. 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, revert restores both files.
  • tests/nokogiri/nokogiri_e2e.rb with 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.
  • Against a local run of Socket's backend with a scratch database, nokogiri 1.19.3: a two-platform lock and the default eight-platform lock with one patched build (frozen install with zero service requests, Ruby loads the patched build), repair of 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 at 50489f84c.

  • cargo fmt --all -- --check and cargo 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 are e2e_vendor_cargo_build cases that need an x86_64 toolchain this machine lacks, and fail on the base branch too.
  • The two real-Bundler suites (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.
  • Local backend runs: 132 checks in seven runs, all pass. They include an intact copy whose new build fails its digest (exit 0, every committed file unchanged), a copy damaged after the list moved (vendored again from the list), and a scan of a copy in step in a repository with a large index.
  • The failures that change the copy before they fail are forced with failure points in the CLI-level tests: exit 1, the error printed, no word of a copy in force.
  • A refusal by git is tested on every path at the core and CLI levels, dry and wet, with the copy compared before and after. What a run asks of git is counted with a logging git first on PATH.

Requests against the local backend, one vendored platform gem:

Run Requests Bytes
Scan of a copy in step 3 (the scan's two, and the gem's list) 4,124
Scan that takes a build published since 10 10,943,661
Scan after a build was withdrawn 8 10,780,244
Scan of a copy damaged after the list moved 10 10,943,661

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:

Index Before this round Now What git is asked now
Nothing tracked 0.34 s, four git calls 0.32 s, two The run's own ledger check (two paths), as on the base branch
100,000 tracked paths 1.26 s 0.32 s The same. Nothing about the copy

A scan of a copy in step (scan --mode vendored --yes) while the service does not answer:

What is down Exit Time What it prints
Nothing (the service is up) 0 0.14 s The copy is in step
The whole service, connection refused 1 0.02 s Error: The API query failed: Network error: … Connection refused: the scan's own query fails before the copy is looked at
The whole service, no answer at all 1 10.0 s The same error (deadline has elapsed), after the scan's own connect timeout
The reference endpoint alone, answering 503 0 0.16 s The copy is in step, nothing of the service. One reference request (before this round: three, 1.5 s)
The reference endpoint alone, never answering 0 5.2 s The same. One reference request (before this round: three, 91 s)

Review

Six rounds of /code-review high on 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):

  • 1. A copy damaged after the list moved failed on every re-run until a rollback. The run now vendors it again from the list.
  • 2. An intact copy whose list moved failed the run when the new build could not be vendored. It now stays in force, with one note and exit 0.
  • 3. The follow check made one request per vendored gem, and two for the fix when the list had moved.
  • 4. The human summary under-counted real skips beside a gem with a tree of upstream's gem.
  • 5. The ledger's doc comment was wrong about older readers. It is corrected, and the consequence is stated above.
  • 6. The download of upstream's gem followed redirects. It follows none.
  • 7. vex could state one product both ways when the view already attested the purl of a tree of upstream's gem.
  • 8. A scan's dry run dropped the gem's line and per-tree events for a copy in step.
  • 9. A lock that would have been skipped could fail on an upstream gem the list did not pin. The skips are judged first.
  • 10. Two advisory texts were wrong after a full withdrawal and for upstream trees, and the registry URL of an upstream gem was built in three places.

Second round (373ce9dcd), which removed the client-wide memo the first round's fix for 3 had added:

  • 1. "Stays in force" was said without looking at the copy, and two failures happen after the copy was changed. One function now answers whether the recorded copy stands with its metadata in place; a copy that does not is a failure.
  • 2 and 4. The memo of batched answers is gone. The batch goes through the vendor prefetch plan, where a planned position can be one whose reference alone is read. (Removed by the fourth round: there is no batch.)
  • 3. A run that leaves the copy in force puts the uuid directory's git metadata back, as a run that finds the copy in step does.
  • 5. The redirect-is-not-found answer applies only to the client that follows no redirect.
  • 6. The dry run of a damaged copy whose list moved says what the wet run does.
  • 7. vex leaves every tree whose purl the view already attests to that record, the patched ones included.
  • 8. The fall-through after a refused restore is decided by a structured reason, and happens only for a moved list.
  • 9. The rebuild takes the gems the list was read to name, so the fix's reference is asked for once.
  • 10. One helper says which packages follow a list, for the wet run, the dry run and the scan's preview.

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:

  • 1. vex left 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.
  • 2. A batch request that failed left every later position to make its own failing request. The failure is now the answer of every reference-only position it named.
  • 3. A dry run tallied a damaged copy with a build replaced under another patch as already vendored.
  • 4. A package fetch could wait on a reference-only position, of which nothing is fetched. Such positions are left out of that lookup.
  • 5. The batch's answer was removed on first read. A reference-only position keeps it, so a restore and the rebuild after it read the same list.
  • 6. Every dry run ran the whole planner pass. A run that fetches nothing ahead judges only the candidates whose ledger entry still reads a reference, and none when there is no such entry.
  • 7. The uuid directory's metadata is written before the new trees are moved in, which removes the state "new trees in place, metadata not written". Its failure point and test are gone.
  • 8. The gem backend plans a platform-locked gem as a reference-only position and says which in-step packages still read one; those positions no longer depend on the gates of the archive prefetch.
  • 9. The skip of a build that is not served yet says what there is to say of the metadata.
  • 10. RestoreError is an enum matched by the vendor loop and repair; the leftovers are removed.

After the third round, three texts were corrected:

  • 1. The vendor_prebuilt_replaced message 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.
  • 2. The two skip lines 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.
  • 3. The contract and the guide state which releases read a copy with a tree of upstream's gem.

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:

  • 1. A failed reference batch was replayed to every reference-only position for the rest of the run, whatever the failure. There is no batch: each gem asks for its own fix's reference, live.
  • 2. Writing the metadata before staging left a uuid directory holding only the metadata after a failed rebuild. It is written after the trees are in place.
  • 3. A metadata write that failed stopped the rebuild of a wired copy. It is a warning, and the rebuild goes on.
  • 4. The Also: … suffix on the pending skip could not be produced. It is removed, with its contract text.
  • 5, 6, 7 and 9. The reference-only plan held for one gate only, did not count a later chunk's failure, dropped a lone archive, and made the download plan a per-run cache of fix references. All of it is deleted: the prefetch plan is the base branch's again. A restore and the rebuild after it read one answer because the restore hands its list on.
  • 8. The own exception in the vendored vex loop could not be reached. It is removed: the loop follows the hosted loop's rule, and compares no uuid.
  • 10. follows_list is the one predicate, and repair reads 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:

  • 1, 3, 4, 5 and 9. A rebuild of a wired copy never ran the commit check; the pending skip dropped the warning; restore still 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.)
  • 2. The list request of a copy in step went through the retry ladder and counted toward the circuit breaker, so two silent failures failed the run's real vendoring, after a stall of minutes. It is one short attempt outside the breaker.
  • 6 and 7. Only a refused restore handed its list on, and the list named no fix. A restore that succeeds hands it on too, and a list is only ever used for the fix it names.
  • 8. Whether a vendored tree is attested from the committed tree beside a manifest record of that build's own patch was unverified. A new end-to-end test shows that it is, online and offline, so the rule of the vendored vex loop stays as it is.
  • 10. restore_list takes 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:

  • 1. A rebuild of a wired copy asked git only after the new trees were swapped in, and a refusal returned no ledger entry: an intact copy ended with trees the ledger did not record and exit 1, and every later scan downloaded the gems again. Git is asked before the swap, and a refusal leaves the copy in force with the note that already says so.
  • 2. An in-step scan ran git check-ignore against 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.
  • 3. The in-step arm could fail a copy in a project without a .git of 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).
  • 4. A dry run never asked git, so it previewed success where the wet run failed. It asks the same question for the same paths.

What was not run

  • Nothing here was run on Linux, on Windows or with an older Bundler, and the workflow row for the nokogiri script has not run on a runner: those are CI's. The test that counts git calls is Unix only.
  • /code-review on the commits after e141f970e (the sixth round's fixes).
  • A scan of a project with several vendored platform gems. The scratch database and the stand-in services hold one such gem. Tests show that a gem's list request names its own fix alone and that any number of failed ones leave the breaker closed.
  • The unreleased readers (the one on 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.
  • A production deployment of the patch service: the proofs use a local run of it and stand-ins.

Decisions a reviewer may want to change

  • The line is printed only for a gem with a tree of upstream's gem, or one a run brought in step with the list. Printing it for every platform-locked gem, as hosted mode does, is a one-line change.
  • A moved list vendors the whole copy again. Replacing only the changed tree would save the downloads of the others.
  • The list requests are not batched: one small request per vendored platform gem per run.
  • The advisory read is bounded at five seconds and has no breaker of its own: with the reference endpoint black-holed, a scan waits five seconds for each vendored platform gem.
  • With the directory's own ignore rules in place, git is asked about the directory and not about each staged file: no rule above those rules reaches a file below them, so the answers are the same, and a dry run can ask exactly what the wet run asks. The staged files are asked about only where those rules could not be written.
  • A .gitignore that 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.
  • A project inside a directory that an outer repository ignores (an exported artifact in build/): the gem asks git nothing about a copy in step there, and a scan's dry run says already_vendored. A wet scan or vendor run is refused before it looks at any package, by the run's own ledger check (vendor_artifact_gitignored for .socket/vendor). That check is the base branch's and 5.1.0's, and is left as it is.
  • The unwritten metadata has a warning code of its own (vendor_gem_git_metadata_unwritten) instead of sharing vendor_artifact_gitignore_unchecked, whose remedy does not fit it.
  • The line of a copy that could not follow its list prints as a note, not a warning: nothing in the project is wrong, and the next run tries again.
  • With a registry that answers upstream's gem with a redirect, vendored mode does not vendor a lock that needs that gem (hosted mode follows the redirect).

🤖 Generated with Claude Code


Generated by Claude Code

…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>
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 28, 2026 18:32
@cursor

cursor Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

PR Summary

High Risk
Changes gem vendoring semantics, offline install payloads, restore/repair behavior, and VEX attestation for multi-platform gems—high impact on Ruby/Bundler workflows and committed vendor trees.

Overview
Vendored mode for platform-locked gems (e.g. nokogiri) no longer waits for a patched build on every locked platform. A gem can be vendored once at least one platform has a patched build; platforms without patches commit upstream's gem from the patch registry (no redirect), verified by the listed sha256, with hosted-style human lines and gem_upstream_build_kept events.

In-sync re-vendors now follow the patch registry's gemBuilds list via reference-only prefetch (in_step_reference / plan_run_downloads), upgrading or reverting per-platform trees when builds are published or withdrawn—without changing Gemfile/Gemfile.lock when possible. Failures to sync print a note and keep the existing copy (vendor_gem_list_not_followed); damaged copies with a moved list re-vendor from the list instead of hard-failing on vendor_prebuilt_replaced.

Supporting changes: shared gem_build_lines formatting for hosted and vendored output; VEX marks upstream trees as affected; e2e/compatibility tests and workflow matrix cover mixed patched/upstream cases.

Reviewed by Cursor Bugbot for commit 6910805. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ 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()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All-upstream follow omits the gem line

Low Severity

format_vendored_gem_build_lines prints a gem only when it still has an upstream tree or when some platforms were already patched and others became patched on this run. A copy that held only upstream trees and is brought fully in step (every locked platform now patched) matches neither check, so the run’s “now also patched” line is omitted even though this is a list-follow.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6910805. Configure here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[agent] PR shepherd: this is real. moved_sources lets a wired copy follow a list whose patched builds were all withdrawn back to upstream's gems, so a copy can hold only upstream trees. When builds are later published for every locked platform, every report is newly_patched and none is upstream, so format_vendored_gem_build_lines says nothing. PinReport can't tell that case apart from a first vendor of an all-patched gem, which also prints nothing by design. Fixing it means carrying "the ledger held this gem before" into the report: a field on PinReport (16 constructors) plus an event detail that gem_build_reports_of reads back. I've left that to the PR's author rather than add a field to a core type in a shepherd pass. The thread stays open.


Generated by Claude Code

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
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: this PR can't move without a person, so I've added agent:needs-human.

  1. Base: it's stacked on Patch gems locked as platform gems in hosted and vendored mode: patched builds where they exist, upstream's gem elsewhere #2273, which has been waiting since 11-26 on the not_affected attestation question asked there. Whatever is decided there decides whether this PR can land.
  2. Open Bugbot thread (gem_build_lines.rs:143): this one is real. A copy that holds only upstream trees and then gets patched builds for every locked platform prints no "now also patched" line. To fix it, PinReport needs a field that says "the ledger held this gem before", which touches 16 constructors. Question: should that field be added here, or should the missing line be accepted as a known gap and the thread resolved?

The rest is in order: no conflict, clippy green, and ci-ok is red only from the hosted-e2e gem leg that also fails on main (#2270).


Generated by Claude Code

@mikolalysenko
Mikola Lysenko (mikolalysenko) merged commit cfd675f into feat/gem-complete-registry Nov 30, 2026
122 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the feat/gem-vendored-partial branch November 30, 2026 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants