Skip to content

With pnpm's lockfile off, vex attests a vendored package through a pnpm-workspace.yaml override its pnpm 10 does not read: pnpm install puts the upstream release back and exits 0 #2403

Done

Description

[agent] Found by the architecture refactor routine on main at 1b3f422, with real pnpm 9.15.9, 10.4.1, 10.5.0, 10.5.1 and 10.28.0.

The problem

With pnpm's lockfile setting off, pnpm never reads pnpm-lock.yaml, so a vendored package installs from its committed artifact only through an override. The contract states the rule (CLI_CONTRACT.md, pnpm with its lockfile off, #1074): vex attests such a reference "only while the override map the governing pnpm reads without a lock routes the package […] to the same artifact".

The reader that applies it goes by pnpm major (PnpmLockOff::routes, core vex/discover/npm.rs, lines 1113 to 1127): for a project that pins pnpm 10 it accepts the override from package.json or from pnpm-workspace.yaml. Real pnpm 10 reads one of them:

  • pnpm 10.0 to 10.5.0 read package.json alone;
  • pnpm 10.5.1 and newer read pnpm-workspace.yaml only while package.json declares no override of its own (pnpm.overrides, or the top-level resolutions).

With the vendored override in the workspace file only, on those releases:

  • pnpm install installs the upstream release and exits 0. Nothing fails: with the lock off there is no frozen install to refuse the mismatch, and pnpm's only word is "A pnpm-lock.yaml file exists. The current configuration prohibits to read or write a lockfile".
  • socket-patch vex exits 0 and attests not_affected, before and after that install. After it, the warning beside the statement says "re-run your package manager's install to resync it", and the re-run installs the upstream release again.
  • socket-patch vendor and vendor --dry-run print "1 package is already vendored; nothing to do."
  • socket-patch vendor --check exits 0, which the contract allows for a lock pnpm does not read (vex_lock_not_read: "vendor --check and scan still treat the wiring as live").

With the lock on, the same files are #2382: a frozen install fails with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH, and #2396 makes vex and vendor --check refuse them. #2396 leaves the lock-off reader as it is (its description lists that), and its binary (82814cb) gives the same answers as main on every lock-off row below.

A project gets there with no hand edit of a wiring line:

  1. A pnpm 10.28.0 project with lockfile=false in .npmrc, a pnpm-lock.yaml in the tree and overrides of its own in pnpm-workspace.yaml.
  2. socket-patch vendor writes the vendored override to the workspace file and the lock, and no pnpm.overrides table (a new table would replace the workspace overrides, Vendored pnpm 10.5+ with overrides: in pnpm-workspace.yaml: the new package.json pnpm.overrides shadows the user's overrides, so frozen installs fail and a re-lock drops them #360). pnpm install installs the patched copy.
  3. The project adds a resolutions entry for another package to package.json. pnpm now reads package.json in place of the workspace file, and the next pnpm install puts the upstream left-pad back.

I know no way to the rows on pnpm 10.4.1 and 10.5.0 that does not take the package.json override out by hand. Only a project that keeps a pnpm-lock.yaml beside the setting can be vendored at all: with no lock, vendor refuses ("vendoring rewires the lockfile, so one must exist").

Evidence

With real pnpm

A project that depends on left-pad 1.3.0, a stand-in patch record that prepends a comment to index.js, the binary built from main and the vendor suite's fixture service. Every row has lockfile=false in .npmrc, the vendored pnpm-lock.yaml and .socket/, and pins its pnpm with packageManager. "Installs" is what node_modules/left-pad/index.js holds after that pnpm's pnpm install; vex gave the same answer before and after the install.

pnpm Vendored override in package.json also declares pnpm install installs vex
9.15.9 pnpm-workspace.yaml nothing upstream no statement (vex_lock_not_read)
10.4.1 package.json nothing patched not_affected
10.4.1 pnpm-workspace.yaml nothing upstream, exit 0 not_affected
10.5.0 pnpm-workspace.yaml nothing upstream, exit 0 not_affected
10.5.1 pnpm-workspace.yaml nothing patched not_affected
10.28.0 pnpm-workspace.yaml nothing patched not_affected
10.28.0 both files nothing patched not_affected
10.28.0 pnpm-workspace.yaml pnpm.overrides for another package upstream, exit 0 not_affected
10.28.0 pnpm-workspace.yaml resolutions for another package upstream, exit 0 not_affected

The three steps above, run as written (pnpm 10.28.0; the project's own workspace override is is-number: 7.0.0):

$ socket-patch vendor                              # step 2
Vendored 1 package.
$ grep -c '"pnpm"' package.json
0
$ cat pnpm-workspace.yaml
packages:
  - "."
overrides:
  is-number: 7.0.0
  left-pad@1.3.0: file:.socket/vendor/npm/1a2b3c4d-5e6f-4a1b-8c2d-0123456789ab/left-pad-1.3.0.tgz
$ pnpm install && grep -c SOCKET-PATCHED node_modules/left-pad/index.js
1

# step 3: "resolutions": { "is-number": "7.0.0" } added to package.json
$ rm -rf node_modules && pnpm install              # exit 0
 WARN  A pnpm-lock.yaml file exists. The current configuration prohibits to read or write a lockfile
 WARN  deprecated left-pad@1.3.0: use String.prototype.padStart()
dependencies:
+ is-number 7.0.0
+ left-pad 1.3.0 deprecated
$ grep -c SOCKET-PATCHED node_modules/left-pad/index.js
0

$ socket-patch vendor --check                      # exit 0
pkg:npm/left-pad@1.3.0: committed artifact and wiring verified

$ socket-patch vex --product pkg:npm/app@1.0.0     # exit 0
Warning: pkg:npm/left-pad@1.3.0: the installed tree does not match its vendored artifact; the attestation is based on the committed .socket/vendor artifact (the project's lockfile or package-manager config wires it in), but the live tree carries different bytes — re-run your package manager's install to resync it.
      "status": "not_affected",
      "impact_statement": "Patched via Socket patch 1a2b3c4d-5e6f-4a1b-8c2d-0123456789ab (vendored)"
Emitted 1 VEX statement

$ socket-patch vendor                              # exit 0
1 package is already vendored; nothing to do.
$ rm -rf node_modules && pnpm install && grep -c SOCKET-PATCHED node_modules/left-pad/index.js
0

A test that fails on main

Beside pnpm_disabled_lockfile_attests_a_vendored_ref_only_through_an_override in core vex/discover/npm.rs, whose last block pins "a pinned pnpm 10 reads either map" with 10.34.1 and no override in package.json:

#[tokio::test]
async fn pnpm_disabled_lockfile_reads_the_map_its_pnpm_10_release_reads() {
    let rel = format!(".socket/vendor/npm/{UUID_B}/left-pad-1.3.0.tgz");
    let lock = format!(
        "lockfileVersion: '9.0'\n\nimporters:\n\n  .:\n    dependencies:\n      left-pad:\n        \
         specifier: file:{rel}\n        version: file:{rel}\n\npackages:\n\n  \
         left-pad@file:{rel}:\n    resolution: {{integrity: {SRI}, tarball: file:{rel}}}\n    \
         version: 1.3.0\n"
    );
    const PURL: &str = "pkg:npm/left-pad@1.3.0";
    let workspace = format!("packages:\n  - '.'\noverrides:\n  left-pad@1.3.0: file:{rel}\n");
    let mut attested = Vec::new();
    for (pnpm, own) in [
        ("10.4.1", ""),
        ("10.5.0", ""),
        ("10.28.0", r#","pnpm":{"overrides":{"is-number":"7.0.0"}}"#),
        ("10.28.0", r#","resolutions":{"is-number":"7.0.0"}"#),
    ] {
        let p = Project::new();
        p.write("pnpm-lock.yaml", &lock);
        p.write(".npmrc", "lockfile=false\n");
        p.write("pnpm-workspace.yaml", &workspace);
        p.write(
            "package.json",
            format!(
                r#"{{"name":"app","packageManager":"pnpm@{pnpm}","dependencies":{{"left-pad":"1.3.0"}}{own}}}"#
            ),
        );
        let out = run(&p).await;
        assert_refs(&out, &[(PURL, UUID_B, WiringMode::Vendored)]);
        if marks(&out, PURL).is_empty() {
            attested.push(format!("pnpm@{pnpm}{own}"));
        }
    }
    assert!(
        attested.is_empty(),
        "attested from pnpm-workspace.yaml, which that pnpm does not read: {attested:#?}"
    );
}
test vex::discover::npm::tests::pnpm_disabled_lockfile_reads_the_map_its_pnpm_10_release_reads ... FAILED
attested from pnpm-workspace.yaml, which that pnpm does not read: [
    "pnpm@10.4.1",
    "pnpm@10.5.0",
    "pnpm@10.28.0,\"pnpm\":{\"overrides\":{\"is-number\":\"7.0.0\"}}",
    "pnpm@10.28.0,\"resolutions\":{\"is-number\":\"7.0.0\"}",
]

Not run: pnpm 11 and 12 (they read the workspace file alone, and the reader asks for it there), a workspace with members, Rush, and a checkout whose node_modules/.modules.yaml names another pnpm than packageManager.

Planned fix

One answer to "which file does this project's pnpm read overrides from". #2396 adds it for the lock-on case, at release precision and from the committed pins (pinned_override_sources, with the 10.5.1 boundary and the package.json-declares-any rule). PnpmLockOff::routes asks that instead of its own pnpm10 flag, so the two lock states cannot drift again. This waits for #2396.

  • vex withholds the reference (vex_lock_not_read), and the detail names the file that pnpm reads.
  • The contract's sentence "a pinned pnpm 10 also reads the pnpm-workspace.yaml map" gets the release boundary and the package.json condition.

Not in this plan: the writer. In step 3's tree vendor says "already vendored" because it skips the package.json copy while the workspace file carries an override the lock records, and it looks for pnpm.overrides there, not resolutions. That is the writer gap noted in #2382's comment; with the lock off it is the reason no re-run repairs the tree.

Related: #2382 and #2396 (the same files with the lock on).


Generated by Claude Code

Activity

  1. added
    bug
    arch-audit
    on Dec 1, 2026
  2. added a commit that references this issue on Dec 1, 2026
  3. mikolalysenko commented on Dec 2, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Claiming this for the architecture refactor routine. Branch: arch-refactor/2403-pnpm-lock-off-override-source.

    Confirmed again on main at 7d78f2f: the unit test in this issue still fails with all four rows attested, and real pnpm 10.4.1, 10.5.0, 10.5.1 and 10.28.0 install what the table says.


    Generated by Claude Code

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:triagedarch-auditbugpriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions