Skip to content

Report an unchecked vlt copy after rollback or a takeover as that run, not as a hosted pin - #2265

Open
Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
mainfrom
arch-refactor/2254-vlt-heal-unchecked-direction
Open

Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
mainfrom
arch-refactor/2254-vlt-heal-unchecked-direction

Conversation

@mikolalysenko

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

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code

Fixes #2254.

Problem

The vlt heal runs after a hosted rewrite (scan / get --mode hosted), after rollback / remove restore the registry pins, and after a hosted → vendored takeover. It keeps an installed copy it cannot check (node_modules is a link, or node_modules/.vlt-lock.json is missing or unreadable) and says so in redirect_vlt_reinstall_required. All three directions printed the hosted rewrite's sentence for that case.

After rollback or remove that sentence is wrong twice. Someone who has just removed a patch reads:

vlt-lock.json pins Socket-patched packages, but socket-patch could not check 1 installed copies (…); run vlt ci to be sure the patched packages are installed.

The lock no longer pins the patch, and the copy that may still be installed is the patched one. vlt ci is the right command, but the sentence offers it as the way to get the patched packages, which this user is trying to remove. Every other arm of the advisory is already worded per direction ("restored registry pins for N packages, …"), and the contract's redirect_vlt_reinstall_required row says the lock "pins (or, after rollback/remove, no longer pins)" and that the detail "says what happened and what to run".

A project gets here with a linked node_modules. By reading vlt_heal::invalidate, the heal also leads here itself: a hosted scan that removes one package's stale copy removes vlt's hidden lock too and keeps the copies it judged healthy, so a rollback before the next vlt install cannot check those.

Evidence on main (cfc870f)

Through the built binary. A hosted vlt project with the patched copy installed and no hidden lock, then rollback --yes (cargo test -p socket-patch-cli --test rollback -- vlt_hosted_rollback, with this PR's test on main's production code):

test rollback_render::vlt_hosted_rollback_reports_an_unchecked_copy_as_a_rollback ... FAILED
the advisory speaks of the rollback, not of a pin:
Warning: vlt-lock.json pins Socket-patched packages, but socket-patch could not check 1 installed copies (node_modules is a link, or node_modules/.vlt-lock.json is missing or unreadable); run `vlt ci` to be sure the patched packages are installed.

With real vlt 1.2.0. A throwaway copy of the real-vlt leg rollback_byte_exact (e2e_redirect_vlt_build), with node_modules/.vlt-lock.json deleted before the rollback. It printed the installed state after each step and is not part of this PR:

after the hosted install: Patched
rollback exit: 0
  "code": "redirect_vlt_reinstall_required",
  "detail": "vlt-lock.json pins Socket-patched packages, but socket-patch could not check 1 installed copies (…); run `vlt ci` to be sure the patched packages are installed."
store entry ~npm~left-pad@1.3.0 kept: true
after the rollback: Patched
after `vlt install`: Patched
after `vlt ci`: Pristine

So the lock is back on the registry, the patched copy is still installed, a plain vlt install keeps it, and the advisory says the lock pins the patch.

The other two tests fail on main the same way: the unit test an_unchecked_copy_is_reported_in_the_direction_of_the_run (left is the hosted sentence, right the rollback one) and vlt_hosted_then_vendored_takeover_reports_an_unchecked_copy_as_a_takeover.

Fix

undeterminable_detail(n) held one sentence. It is now unchecked_detail(did, n, installs): each caller passes what its run did to the lock and what kind of package the lock now installs, as the other arms of reinstall_detail, rollback_detail and takeover_detail already do inline.

After the fix:

$ socket-patch rollback --yes
Warning: restored registry pins for 1 packages, but socket-patch could not check 1 installed copies (node_modules is a link, or node_modules/.vlt-lock.json is missing or unreadable); run `vlt ci` to be sure the registry packages are installed

and after a takeover (scan --mode vendored or vendor over a hosted pin):

vendored 1 hosted-pinned packages, but socket-patch could not check 1 installed copies (…); run `vlt ci` to be sure the vendored packages are installed

Deleted

undeterminable_detail, the helper whose one sentence fit only the hosted rewrite. No copy of the old sentence is left for the other two directions.

Behavior change

Only the detail text of one arm of redirect_vlt_reinstall_required, in two of its three directions:

  • Rollback direction (rollback, remove, the restore of a withdrawn pin in scan --mode hosted, and a takeover whose vendoring failed): the text above. This is the defect.
  • Takeover direction: the text above. The old sentence was less wrong here, since the vendored package is a Socket-patched one, but it spoke of a pin in vlt-lock.json that the takeover has just removed. It now starts like the takeover's other arms. The command stays vlt ci: with real vlt 1.2.0 a plain vlt install relinks the importer to the vendored directory and leaves the hosted store entry in place, and vlt ci removes it.
  • When optional copies were kept as well, their sentence follows after a period, as in the other arms.

Unchanged: the hosted rewrite's sentence (byte for byte), the warning code, the command it names, which copies are kept, the exit codes and the JSON shape. CLI_CONTRACT.md already describes the corrected behavior, so it is not edited.

Risk

Low: two strings. No copy is removed or kept differently, and nothing in this repository reads the detail text besides the tests.

No cfg(unix) or cfg(windows) code changed.

Review

/code-review high found nothing in the changed logic, and three things around it:

  • Fixed: docs/testing/vlt-coverage.json did not list the two new tests under the "copies could not be checked" variant, so its checker would not notice them being deleted.
  • Left, older than this PR: the parenthetical names two causes, and the heal also cannot check a copy when node_modules/.vlt itself is a link. vlt never makes that layout, and naming it would change the hosted sentence, which this PR keeps byte for byte.
  • Left: a hosted scan that restores a withdrawn pin and pins its replacement in the same run reports the restore and then the rewrite, so with an unchecked copy warnings[] now holds the rollback sentence followed by the hosted one, where it held the hosted sentence twice. The contract says the restore's advisories join warnings[], every other arm of the restore's advisory already speaks of the restore there, and both name vlt ci. When no replacement is pinned the old sentence was false there too.

Verification

Diff

4 files, +180 −13: production +25 −11 (src/commands/vlt_heal.rs), tests +152 −1 (unit +63 −1, CLI suites +89), coverage map +3 −1. No file here is changed by another open arch-refactor/ or agent/ PR.


Generated by Claude Code

Opens the branch for #2254: the vlt heal reports a copy it could not
check with the hosted flow's text after a rollback or a takeover.

Refs #2254.

Assisted-by: Claude Code
@mikolalysenko Mikola Lysenko (mikolalysenko) added arch-refactor PR opened by the scheduled architecture refactor routine refactor Structural change: duplicated code or logic, missing abstraction, layering, dead code labels Nov 26, 2026
The vlt heal runs after a hosted rewrite, after rollback or remove
restore the registry pins, and after a hosted to vendored takeover.
A copy it could not check (node_modules is a link, or vlt's hidden
lock is missing or unreadable) was reported with one text for all
three: "vlt-lock.json pins Socket-patched packages ... run vlt ci to
be sure the patched packages are installed".

After a rollback that is false twice over: the run has just taken the
pin out, and the copy that may still be installed is the patched one.
The rollback now says the registry pins were restored and that vlt ci
makes sure the registry packages are installed. The takeover says the
packages were vendored. The hosted rewrite's text is unchanged, as are
the warning code, the command to run and the exit codes.

Fixes #2254.

Assisted-by: Claude Code
From review. docs/testing/vlt-coverage.json names the tests behind each
variant of the reinstall advisory. Its "copies could not be checked"
entry listed only hosted scans, so the two tests of that arm after a
rollback and after a takeover could be deleted without the map's
checker noticing.

Refs #2254.

Assisted-by: Claude Code
@mikolalysenko Mikola Lysenko (mikolalysenko) changed the title Report an unchecked vlt copy in the direction of the run after rollback or a takeover Report an unchecked vlt copy after rollback or a takeover as that run, not as a hosted pin Nov 26, 2026
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 26, 2026 01:23
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

bugbot run


Generated by Claude Code

@cursor

cursor Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
User-facing advisory strings only; heal behavior, exit codes, and JSON shape are unchanged.

Overview
Fixes misleading redirect_vlt_reinstall_required text when the vlt heal cannot verify installed copies after rollback or hosted→vendored takeover. Those paths no longer reuse the hosted-only sentence (“vlt-lock.json pins Socket-patched packages… install patched packages”), which was wrong once the lock had already been restored or vendored.

The shared helper is now unchecked_detail(did, unchecked, installs), and rollback_detail / takeover_detail (and the hosted reinstall_detail) pass the action taken and the package kind the lock should install—e.g. registry vs vendored vs patched.

Tests lock in per-direction wording (unit + CLI rollback/takeover cases with missing node_modules/.vlt-lock.json), and docs/testing/vlt-coverage.json maps the new tests under “copies could not be checked.”

Reviewed by Cursor Bugbot for commit 4a03aa8. 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 4a03aa8. Configure here.

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] hosted-e2e (and ci-ok, which aggregates it) is red on this head, and the cause is not in this PR. The other 81 checks pass, and Bugbot found no issues.

What fails. Nine tests of e2e_hosted_production (npm_package_lock, pnpm, yarn_classic, yarn_berry, bun, vlt, pypi_uv_lock, pypi_requirements_txt, gem_bundler). Each pins a hosted patch from the production patch service and installs it with the real package manager, and the download is answered with HTTP 500:

npm error 500 Internal Server Error - GET https://patch.socket.dev/patch/npm/minimist/1.2.2/***/***/minimist-1.2.2.tgz - internal_error
error: Failed to download `urllib3 @ https://patch.socket.dev/patch/pypi/urllib3/1.26.18/…/urllib3-1.26.18-py2.py3-none-any.whl`
  cause: HTTP status server error (500 Internal Server Error)
"reason": "cannot fetch the hosted tarball: vendor package download failed with status 500: internal_error"

The job ran the suite three times (01:27Z, 01:29Z and 01:31Z), each ending 7 passed; 9 failed.

Why it is not this PR's. The diff changes two advisory strings in commands/vlt_heal.rs, their tests and a coverage map. The nine tests fail in the package manager's download or in the scan's own fetch of the artifact, which this PR does not touch. The same nine fail the same way on #2261's head (00:36Z), which shares no file with this PR. hosted-e2e last passed on main at cfc870f, this PR's base, at 22:40Z on 2026-11-25 and has not run there since.

I have not re-run the job yet: it already tried three times against the same answers. I will re-run it once later in this session; if that fails too, it needs a re-run by a person once the patch service answers again.


Generated by Claude Code

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief

What it does
When the vlt heal can't check an installed copy (node_modules is a link, or vlt's hidden lock is missing), rollback/remove and a hosted → vendored takeover printed the hosted rewrite's sentence: "vlt-lock.json pins Socket-patched packages … be sure the patched packages are installed". That is wrong after a rollback. Each direction now says what it did ("restored registry pins for N packages, …", "vendored N hosted-pinned packages, …") and which packages vlt ci installs. Only the advisory text changes; nothing is written or deleted differently.

Risk
Low. It changes the text of one warning arm (redirect_vlt_reinstall_required) and keeps the code, the exit codes and what the heal keeps. Hosted-mode text is byte-identical to before.

Look here

Verified
I read the whole diff against main and #2254. The hosted arm keeps its old wording and trailing period, and with_optional_kept still joins the optional-copy sentence correctly on the period-less rollback and takeover details, which the new test pins. The new tests are unit and in-process tests that fail on main's wording. No review threads are open, and Bugbot found nothing. CI on 4a03aa8: clippy and every other check are green. ci-ok is red only through hosted-e2e. Its last run on this head hit the patch service's HTTP 500 outage. I re-ran it once, but its gem leg now fails on every PR for the reason in #2270 (production serves a new gem patch id that isn't in GEM_UUIDS), which doesn't touch this code. A merge of main and a re-run are needed once #2270 is fixed.

Changes I made
None.

Open questions
None.


Generated by Claude Code

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-refactor PR opened by the scheduled architecture refactor routine Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review refactor Structural change: duplicated code or logic, missing abstraction, layering, dead code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

After rollback, remove or a vendored takeover, an unchecked vlt install is reported as "vlt-lock.json pins Socket-patched packages"

2 participants