Skip to content

fix(update): verify pnpm global-store installs against the store pnpm names - #8331

Merged
lidge-jun merged 68 commits into
devfrom
codex/carry-8298-pnpm-store-binding
Nov 13, 2026
Merged

lidge-jun merged 68 commits into
devfrom
codex/carry-8298-pnpm-store-binding

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

ocx update refused working pnpm 11/12 global installs whose package lives in pnpm's global virtual store (<pnpm home>/store/v11/links/...). Bun and Zod are linked beside the package there, and the verifier did not recognise that group (#8183). This carries #8298 and accepts such an install only when pnpm itself names the store.

  • Classification only chooses the proof. Every path the package is reached through is judged, the listed spelling first, then each link target joined with the rest of the path. A v<N>/links component, or pnpm's store markers (files plus an index) on any versioned ancestor, requires the store proof. The one exception is an isolated install: a package that lands in a node_modules/.pnpm store inside that same links directory. Paths, markers and .modules.yaml never accept a package.
  • Store proof. pnpm major 11 or 12; pnpm home from the environment pnpm receives (PNPM_HOME, XDG_DATA_HOME/pnpm, then the platform default); pnpm store path --dir=<pnpm home> without --store-dir, through the same runner, environment and read cwd as pnpm list -g --depth=0 --json; exactly one absolute path ending in v<N>; the listed package's realpath inside that store. The home, printed store and listed group must be canonical (no ./.., no link or junction component). On Windows a cmd.exe metacharacter ("%!^&|<>) in those paths is refused before any pinned pnpm command.
  • Link confinement. Each link is followed by its own text, one component at a time; every step stays inside the canonical global group or the store. A relay outside both is refused, including a .. detour. Dependency links, entry points and in-store lookup roots stay in the store; lookup roots outside it are ignored unless they would supply a declared dependency missing from the store.
  • Transaction. The lexical store path and its canonical target are pinned separately and passed as --store-dir to add and rollback. During an update the store and global group are also pinned by device and inode. A changed store, a group that gains a link component or a replaced directory stops the update before pnpm add or a rollback. Orchestrated post-update verification re-proves a store-pinned owner (requireStoreProof).
  • Unclassified legacy groups (pnpm 9/10, or pnpm 11 with the global virtual store disabled) make no version or store query and keep dev's verification.
  • Refusals explain themselves. A refusal of a store-like install keeps its reason and adds why, plus pnpm add -g @bitkyc08/opencodex@latest. This applies at discovery, preflight, post-install, rollback recheck and rollback readback. docs-site troubleshooting/update-failed has the matching section.

Before: a default pnpm 12.16.1 global install fails with sentinel dependency missing: bun. After: owner discovery accepts it after one store path --dir=<pnpm home> query and updates with the store pinned.

Closes #8183

Co-authored-by: Ingwannu [email protected]

Verification

Commands ran with temporary HOME, OPENCODEX_HOME, CODEX_HOME, CLAUDE_CONFIG_DIR and TMPDIR.

  • Failing first: tests/update/update-pnpm-global-store.test.ts fails on dev for the default-store case with [Bug]: pnpm global-store links fail updater package verification #8183's symptom. Each review fix added a regression that fails on the previous head and passes now.
  • Focused, head 8b04177192: seven update files (update-pnpm-global-store, update-tree-ownership, update-pnpm, update-orchestrated-pnpm-entry, update-orchestrated-pnpm-global-store-entry, update-orchestrated-session, update-orchestrated-apply): 195 pass, 0 fail. pnpm-command-isolation, capability/mutation guard and scanner, status-install-method, update-mise, file-size ratchet: 47 pass, 304 skip, 0 fail.
  • Update lint: its parser-based cases skip under Bun on POSIX. A Node-run probe of both update-mutation-guard lint cases reports 0 violations across 79 files and all 168 helper sites contracted. On this branch merged with current dev, the only violations are dev's 3 pre-existing ones in job-windows-restart.ts.
  • bun run typecheck, bun run structure:check, bun run privacy:scan, git diff --check pass.
  • Real pnpm on macOS arm64, disposable homes, offline local tarballs: pnpm 12.16.1 and 11.20.0 owner discovery accepts the default global-store install with globalStore: true and a single store path --dir=<home>; a symlinked PNPM_HOME and an outside relay are refused. pnpm 10.12.3 and 11.20.0 without the global virtual store resolve as legacy owners with no store or version query.
  • Independent reviews on 8b04177192 (gpt-6.1-terra, high): final review PASS, security review PASS, plan audit PASS.
  • NOT RUN: full suite and bun run test:changed; real Windows; pnpm 12 on Linux arm64; the lint suites in update-capability-policy.test.ts and update-mutation-scanner.test.ts (skipped locally).

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Ingwannu and others added 2 commits November 7, 2026 14:56
Install detection routes a package whose realpath lies under pnpm's
`store/v<N>/links/` tree to the pnpm updater, but `verifyPnpmInstallTree`
only trusted an enclosing node_modules that carries `.pnpm` or
`.modules.yaml`. A global virtual-store group has neither, so its sibling
`bun` and `zod` links were never probed and `ocx update` aborted with
"sentinel dependency missing" on a working install.

Treat the package's realpath group as pnpm-owned when it sits inside a
`store/v<N>/links/` tree. The lexical (exposed) group still needs pnpm
metadata, so no ancestor install is newly trusted. The store-layout
spelling moves to a dependency-free leaf module shared by detection and
the verifier so the two cannot drift again.

Closes #8183

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@lidge-jun lidge-jun added the ci:full Run the four full Ubuntu test shards on this pull request label Nov 8, 2026
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 8, 2026
lidge-jun and others added 24 commits November 8, 2026 16:14
t added 6 commits November 13, 2026 12:26
… the pnpm guide

The store check also runs after pnpm add, and a failure there stops
without a rollback. Say so instead of claiming the update never changes
anything, and stop saying the hint is the end of the message.
…fied install

A symlinked global group or an unsafe Windows path refused a store-like
install without saying how to update. Every refusal of a classified owner
now keeps its reason as the prefix and appends the hint. The guide notes
that the store query may create an empty store folder and lists the
Windows cmd.exe cause.
An unbound global group or a command-shim mismatch returned before store
classification, so a store-like install was refused without the pnpm
remedy. Classification now runs as soon as the listed package matches, and
every refusal of a classified owner carries the hint.
…ks directory

A v<N>/links component only classified a store install when it appeared in
a symlink target, so a package listed at its own path inside such a
directory skipped the store proof that decision B requires. The package's
final location now classifies by the same rule; an isolated install ending
in node_modules/.pnpm stays unclassified.
… owner

Preflight, the post-install store check and the rollback store recheck
returned the raw reason for a store owner, so ocx update printed it
without the cause and remedy discovery gives. They now keep the reason as
the prefix and append the same hint.
… install

Any node_modules/.pnpm segment suppressed the v<N>/links classification,
including one above the links directory, so a package under
node_modules/.pnpm/<x>/v1/links/... skipped the store proof. One helper
now decides for both a symlink target and the final location, and a .pnpm
virtual store counts only below the last v<N>/links component.
t added 8 commits November 13, 2026 12:58
…back readback reasons

A symlink target was classified before the rest of the path was appended,
so an isolated .pnpm install reached through a link to its group required
the store proof while the same location reached directly did not. The
verifier now judges the joined spelling. The final rollback readback also
kept no reason; its failure, a store-proof failure included, is now part of
the error, and a store owner's post-install outcomes carry the remedy.
…s; keep isolated installs and hints consistent

The marker check only looked at the innermost v<N> directory, so a package
at store/v11/custom/v2/slot/node_modules skipped the store proof although
store/v11 carries pnpm's files and index markers. Every versioned ancestor
is now checked. The isolated .pnpm exception also covers the default
store/v<N>/links spelling, and a store-like running package that no pnpm
candidate lists is refused with the remedy.
…ore owner version mismatch

Store markers were only checked on the package's final realpath, so a
listed path below a marked store whose package link pointed elsewhere was
accepted on the legacy verifier with no store query. Markers now classify
on every effective spelling. A store owner's active-version mismatch at
preflight also carries the remedy.
…onical spelling

A readback that found the global group behind a link was not treated as a
configuration failure, and the pre-rollback recheck validated only the
store, so a second pnpm add ran through the changed group. Global group
refusals now stop without a rollback, and the recheck validates the group
too. The final rollback readback reason now leads its error, and an
unpinned store owner is refused with the remedy.
…nd group identity for the transaction

The listed package spelling was checked only with the default-store
patterns, so v7/links/group/node_modules/<pkg> linking elsewhere was
accepted with no store query. Every effective spelling with a v<N>/links
component now classifies unless the package finally lands in an isolated
.pnpm install inside that same links directory. A store owner's store and
global group are also pinned by device and inode for the update, and a
replaced directory stops the transaction before pnpm add or rollback.
The update mutation scanner, which runs where TypeScript's sync parser can
start (Windows), rejected this branch: a stale pnpm-store-layout import
ledger, node:path imports in index.ts and orchestrated-pnpm.mjs, the
node:module globalPaths import and process.execArgv. Node's default global
lookup paths are now computed from HOME/USERPROFILE and process.execPath
the way Node builds Module.globalPaths, the ledgers match the imports, and
the read-only process.execArgv site has an exact allowlist entry and
control-site contracts. A Node-run probe of both lint cases reports no
violations.
@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer judgment (head 8b0417719296621db1885832f526dbee07dec71b)

  • Value: unblocks ocx update for default pnpm 11/12 global installs ([Bug]: pnpm global-store links fail updater package verification #8183), the layout pnpm uses for global packages by default.
  • Acceptance: a store-like install is accepted only on pnpm's own store path --dir=<pnpm home> answer, cross-checked with list -g through the same runner, environment and cwd. Paths, markers and .modules.yaml only choose that proof. Unclassified legacy groups keep dev's verification with no store or version query.
  • Accepted regression (owner decision): a legacy group that merely sits under a store-like directory (a v<N>/links folder, or a v<N> folder with pnpm's files/index markers) is now refused without the store proof. The refusal says why and points to pnpm add -g @bitkyc08/opencodex@latest, and docs-site troubleshooting/update-failed documents it.
  • Fail-closed choices that can refuse a real install: a pnpm home, store or global group reached through a symlink or spelled with ..; any pnpm major other than 11 or 12; a store or global group replaced or relinked during an update (no rollback through it). On Windows, those paths containing "%!^&|<> are refused too.
  • Windows impact: the code is platform-aware (LOCALAPPDATA\\pnpm default, junctions count as link components, case-insensitive keys, metacharacter refusal, device/inode pin from statSync). The update lint, which only runs on Windows CI, was run through a Node probe and is clean; on the merge with dev only dev's 3 pre-existing job-windows-restart.ts violations remain. Nothing ran on real Windows. Unverified there: junction readlink spellings in the link walk, realpathSync.native spelling and case, drive and UNC store paths, and inode stability of the group across pnpm add. A mismatch refuses the update rather than accepting it.
  • Not verified on real hardware: pnpm 12.x on Linux arm64 (the reported platform) and Windows. Real pnpm 12.16.1 and 11.20.0 owner discovery was checked on macOS arm64.
  • Residual risk: pnpm store path can create a store directory; a local race remains between the last identity check and pnpm's own writes. Legacy owners on Windows still pass --global-dir/--config.global-bin-dir through cmd.exe escaping without the metacharacter refusal; that is unchanged dev behavior and worth a follow-up.
  • Reviews on this exact head (gpt-6.1-terra, high): final review PASS, separate security review PASS, plan audit PASS.
  • CI: exact-head PR checks were still running at merge time; per the lane's instruction, merge does not wait on pending checks, and no check had failed on this head.
  • Credit: carries fix(update): accept pnpm global virtual-store links in the tree verifier #8298 by @Ingwannu (Co-authored-by in the description and branch).

@lidge-jun
lidge-jun marked this pull request as ready for review November 13, 2026 04:40
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 13, 2026 04:40
@lidge-jun
lidge-jun merged commit 6788d42 into dev Nov 13, 2026
35 of 36 checks passed
@lidge-jun
lidge-jun deleted the codex/carry-8298-pnpm-store-binding branch November 13, 2026 04:40
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T04:43:30.213605Z 8b04177 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci:full Run the four full Ubuntu test shards on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: pnpm global-store links fail updater package verification

3 participants