Skip to content

PnpmLock::parse inventories a pnpm 11 env-lockfile document's configDependencies as project packages, while InstalledPackages and the upstream evidence reader drop it #1949

Closed

Description

[agent] Filed by the scheduled architecture audit (audit-core). Register: #1830 (comment).

Kind: bug. Register ID: A64.

Problem. pnpm 11+ writes the env lockfile (configDependencies / packageManagerDependencies) as a first YAML document ahead of the project lock. grammar::main_document exists to drop it (grammar.rs L91-L109),`` but only some readers call it:

  • InstalledPackages drops it (mod.rs L534), and so does pnpm_lock_tarball_evidence (upstream/npm.rs L1514-L1517).````
  • PnpmLock::parse scans the whole text (mod.rs L386-L394). The lock inventory reads PnpmLock::parse(text).entries() (lock_inventory/pnpm.rs L95-L97).`````

Executed (a scratch test on cbbbdb9). The lock's env document locks cfg@1.0.0 and its main document locks a@1.0.0. The readers disagree:

PnpmLock::parse(text).entries() names = ["cfg", "a"]
pnpm_packages(main_document(text))    = ["a@1.0.0"]
InstalledPackages::contains("cfg")    = false

So scan inventories, and sends to the API, a config dependency that the project's install never links. Patching paths that use InstalledPackages then disagree with the inventory about the same package.

Proposed change. PnpmLock::parse applies main_document itself. The callers that need the env document (none today, as far as grep shows) can read it explicitly. Add a unit test in formats/pnpm/mod.rs with a two-document lock that asserts entries() omits the env-document packages.

Size. 1–2 files, about 15 lines plus the test.

Acceptance criteria.

  • Single-document locks behave exactly as before; the existing formats::pnpm and lock_inventory tests pass.
  • The new two-document test asserts entries(), InstalledPackages and vendored_npm_uuids agree.

Activity

  1. mikolalysenko commented on Nov 1, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Triage: priority:p1 (pnpm). Confirmed on main: PnpmLock::parse (formats/pnpm/mod.rs) calls pnpm_packages(text) / vendored_npm_uuids(text) on the whole text, while InstalledPackages and upstream/npm.rs go through grammar::main_document first. No open PR covers it. Related but separate defect: #1952 (the importers-member predicate).


    Generated by Claude Code

  2. mikolalysenko commented on Nov 1, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Shares root cause with #1952: pnpm lock readers scan the whole lock text with their own line rules instead of the main document through the formats::pnpm grammar, so the pnpm 11 env document and comment lines read differently per caller. Will be fixed together.

    [agent] Claiming this issue (with #1952; shared root cause: pnpm lock readers bypass grammar::main_document and the shared key-line grammar). Branch: agent/fix-pnpm-lock-main-document. Claim-ID: 2026-11-01T22:21:15Z-216d13


    Generated by Claude Code

  3. mikolalysenko commented on Nov 1, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Draft PR: #1960


    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-auditFiled by a scheduled architecture audit routine (see the architecture review discussion)bugSomething isn't workingpriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions