Skip to content

vlt rollback says unwired packages "keep their patched bytes in installed trees" right after it deleted the patched copies #2323

Backlog

Description

[agent] Found by the scheduled vlt bug-hunt routine (ledger #307).

Summary

After a hosted or vendored scan of a vlt project and a vlt ci, socket-patch rollback prints

Note: 2 unwired packages keep their patched bytes in installed trees until the next package-manager install.

and the --json envelope carries reinstall_required with the same detail. On vlt that's false. In hosted mode socket-patch has just deleted the patched store copies, and the warning printed on the next line says so (redirect_vlt_reinstall_required: "removed the patched installed copies, so node_modules is incomplete"). In vendored mode the rollback deletes .socket/vendor, so node_modules/<name> dangles. Either way require('left-pad') throws Cannot find module right after the rollback. No patched bytes are left anywhere.

This isn't a regression: release v5.1.0 prints the same note. On npm the note is correct (the patched copy really stays in node_modules until npm ci), so it's the vlt cleanup that the count doesn't know about. #2214 was the same kind of false note for vendored gems, fixed by #2215 for gems only.

Impact

Friction and a misleading message. A user who reads "keep their patched bytes" assumes the app still runs patched code until the next install, but it can't load the package at all until vlt install / vlt ci. The note and the warning on the next line contradict each other, and a CI step that reads the reinstall_required code learns something untrue.

Repro (vlt 1.9.0, main cfc870f)

Mock registry and patch API: the mock.mjs in #1494, started as PORT=18555 node mock.mjs & and PORT=18556 node mock.mjs &.

export SOCKET_API_URL=http://127.0.0.1:18556 SOCKET_PATCH_SERVER_URL=http://127.0.0.1:18556 \
       SOCKET_NPM_REGISTRY=http://127.0.0.1:18555 SOCKET_ORG_SLUG=test-org SOCKET_API_TOKEN=fake
mkdir p && cd p
echo '{"name":"root","version":"1.0.0","dependencies":{"left-pad":"1.3.0","right-pad":"1.3.0"}}' > package.json
echo '{"config":{"registries":{"npm":"http://127.0.0.1:18555/"}}}' > vlt.json
vlt install --allow-scripts :scripts
socket-patch scan --mode hosted --yes        # or --mode vendored
rm -rf node_modules && vlt ci --allow-scripts :scripts
node -e "console.log(require('left-pad'))"   # patched
socket-patch rollback --yes                  # prints the Note above
node -e "console.log(require('left-pad'))"   # Error: Cannot find module 'left-pad'

Hosted output:

Note: 2 unwired packages keep their patched bytes in installed trees until the next package-manager install.
Warning: restored registry pins for 2 packages; removed the patched installed copies, so node_modules is incomplete until you run `vlt install` (or `vlt ci`)

Vendored output:

Warning: node_modules/left-pad still links left-pad@1.3.0 to its vendored copy; run `vlt install` (or `vlt ci`) to link the restored copy
Warning: node_modules/right-pad still links right-pad@1.3.0 to its vendored copy; run `vlt install` (or `vlt ci`) to link the restored copy
Note: 2 unwired packages keep their patched bytes in installed trees until the next package-manager install.

rollback --json (hosted) warnings: reinstall_required ("unwired packages keep their patched bytes …") next to redirect_vlt_reinstall_required ("… removed the patched installed copies …").

Expected vs actual

  • Expected: the reinstall note counts only packages whose installed tree still holds patched bytes. That's what the code comment on format_reinstall_note says (rollback.rs:579: "packages whose wiring was undone but whose installed tree still holds patched bytes"), and Fix rollback reinstall note for vendored gems (#2214) #2215 excludes gems the unwind already brought back for the same reason. On vlt the next step should read as "node_modules is incomplete; run vlt ci", which the vlt warnings already say.
  • Actual: every reverted vlt entry is counted, so the note claims patched bytes that were deleted.

Versions

socket-patch vlt hosted note false vendored note false
main cfc870f 1.2.0 yes yes
main cfc870f 1.4.0 yes yes
main cfc870f 1.8.2 yes yes
main cfc870f 1.9.0 yes (3/3) yes (3/3)
v5.1.0 1.9.0 yes yes
main cfc870f npm 10 (control) note is true note is true

Linux only. The vlt cleanup is the same code on macOS and Windows, so I expect the same output there, but I didn't probe them.

Suspect code

  • crates/socket-patch-cli/src/commands/rollback.rs:2845: still_patched counts vendored_leg.reverted, vendored_leg.preserved and hosted_leg.reverted, excluding only in-place restores and the gem sets (refreshed_installs, upstream_installs). Nothing excludes vlt entries whose store copies the hosted unwind removed (crates/socket-patch-cli/src/commands/vlt_heal.rs, REINSTALL_REQUIRED) or whose vendored dir was deleted (crates/socket-patch-core/src/vendor/vlt_lock.rs:1930).
  • The same count feeds the human note (rollback.rs:3157) and the JSON reinstall_required warning (rollback.rs:2860).

Generated by Claude Code

Activity

  1. added
    bug
    bughunt
    on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:triagedbugbughuntpm:vltpriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions