Repository navigation
Fix pnpm lock readers skipping main doc (#1949, #1952) - #1960
Conversation
Assisted-by: Claude Code:claude-opus-5-5
pnpm 11+ writes its env lockfile (configDependencies / packageManagerDependencies) as a first YAML document. PnpmLock::parse walked the whole text, so the scan inventory listed config dependencies the install never links while InstalledPackages did not (#1949). It now keeps only entries that start in grammar::main_document, with offsets still relative to the full text, and reads vendored uuids and the packages: sniff from that document. "Does the root lock list a member importer?" was answered by two drifted copies: the formats one read a commented-out ` # sub:` key as a member, the utils one did not, and neither isolated the main document itself (#1952). One predicate in formats::pnpm::workspace now skips comment lines (a column-0 comment no longer ends importers:), and lock_text_has_member_importers applies main_document; the utils copy and the engine's inline wrapper route through it. Fixes #1949 Fixes #1952 Co-Authored-By: Claude <noreply@anthropic.com>
|
bugbot run Generated by Claude Code |
There was a problem hiding this comment.
✅ 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 48e8e6c. Configure here.
|
[burn-down agent] The draft's heartbeat had gone stale (last 22:23Z) and it held only the plan commit, so I implemented the plan in 48e8e6c, marked the PR ready, and labeled it Ready for review.
Generated by Claude Code |
Final review briefWhat it does: pnpm 11+ writes a two-document Risk: low–medium. It changes which packages a pnpm 11 lock reports, but now matches the readers that already used Look here
Verified: read the full diff. Confirmed Changes I made: none. Open questions: none. Auto-merge is armed, so approving sends this straight to the merge queue. Generated by Claude Code |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed 48e8e6c8d9e754086f4d4772a9bf2cb69222d37f. Checked pnpm project-document offsets, environment-document exclusion and importer comments. No major correctness issues found. Validation: source and regression-test review plus the available exact-head CI checks; no local test pass is claimed.
LLM Description written by Claude Code:claude-opus-5-5
Fixes #1949
Fixes #1952
Root cause
pnpm 11+ writes an env lockfile (
configDependencies/packageManagerDependencies) as a first YAML document ahead of the project lock, andformats::pnpm::grammar::main_documentexists to drop it. Several lock readers skip that boundary and walk the whole text with their own line rules:PnpmLock::parsefeeds the whole text topnpm_packagesandvendored_npm_uuids, so the scan inventory lists config dependencies the install never links, whileInstalledPackagesand the upstream evidence reader (which callmain_document) do not (PnpmLock::parse inventories a pnpm 11 env-lockfile document's configDependencies as project packages, while InstalledPackages and the upstream evidence reader drop it #1949).formats::pnpm::workspace::lock_has_member_importers(hosted, vendored) reads a commented-out# sub:importer as a member, whileutils::pnpm_workspace::root_lock_lists_membersdoes not, and neither takes the main document on its own ("pnpm lock importers list a non-root member" is written twice and drifted on comment lines: keep formats::pnpm::workspace, delete the utils::pnpm_workspace copy #1952).Plan
PnpmLock::parsereadsmain_document(strip_bom(text))for its entries, vendored uuids andpackages:sniff.formats::pnpm::workspacethat takes the lock text, appliesmain_documentand skips comment lines; delete theutilscopy and the engine wrapper and route every caller to it.entries(),InstalledPackagesandvendored_npm_uuidsagree (PnpmLock::parse inventories a pnpm 11 env-lockfile document's configDependencies as project packages, while InstalledPackages and the upstream evidence reader drop it #1949); a commented-out importer key readsfalseand env-document importers are ignored ("pnpm lock importers list a non-root member" is written twice and drifted on comment lines: keep formats::pnpm::workspace, delete the utils::pnpm_workspace copy #1952).Changes (burn-down agent, 48e8e6c)
PnpmLock::parsekeeps only entries starting inmain_document(strip_bom(text))(offsets stay relative to the full text) and reads vendored uuids and thepackages:sniff from that document.formats::pnpm::workspace::lock_has_member_importers(comment lines skipped; a column-0 comment no longer endsimporters:), pluslock_text_has_member_importerswhich appliesmain_document.utils::pnpm_workspace::root_lock_lists_membersand the engine's inline wrapper are gone; every caller routes through it.env_document_is_not_in_the_inventory(PnpmLock::parse inventories a pnpm 11 env-lockfile document's configDependencies as project packages, while InstalledPackages and the upstream evidence reader drop it #1949:entries(),resolves(), vendored uuids andInstalledPackagesagree; BOM and CRLF twins) andmember_importers_skip_comments_and_the_env_document("pnpm lock importers list a non-root member" is written twice and drifted on comment lines: keep formats::pnpm::workspace, delete the utils::pnpm_workspace copy #1952).Generated by Claude Code
Note
Medium Risk
Changes how pnpm lock text is interpreted for inventory and shared-workspace detection; mistakes could mis-report installed or workspace packages, though behavior is aligned with existing
main_documentcallers and covered by new tests.Overview
pnpm 11+ prepends a separate env YAML document to
pnpm-lock.yaml; several readers were walking the full file and disagreeing with code that already usedgrammar::main_document.PnpmLock::parsenow treats only the project document as the lock inventory: package entries are filtered by offset into that slice, vendored UUID scanning and thepackages:sniff usedoc, while byte offsets still refer to the full lock text.Member-importer detection is consolidated:
lock_has_member_importersskips#comment lines (so commented-out importers and column-0 comments do not false-positive), and newlock_text_has_member_importersappliesmain_documentbefore scanning. The duplicateroot_lock_lists_membershelper and the hosted engine’s inline parsing are removed in favor of that single path.Regression tests cover env-document packages excluded from
entries(),resolves(), vendored usage, andInstalledPackages, plus comment/env-document behavior for shared-lock detection.Reviewed by Cursor Bugbot for commit 48e8e6c. Configure here.
Generated by Claude Code