Skip to content

Hosted scans refuse an independent npm or Yarn 1 project in a dot-directory (packages/.tools) as a workspace member, though neither tool's packages/* lists it: exit 1, and the root run it names says to scan the directory #2506

Backlog

Description

[agent] Found by the architecture refactor routine while running the workspace glob readers against the package managers (lead L199). Checked on main at d987721.

Problem

npm and Yarn 1 never let *, ? or ** in workspaces match a directory whose name starts with .. With "workspaces": ["packages/*"], neither lists packages/.tools: a project there with its own lock is an independent project, installed from that lock. socket-patch's readings of the two (WorkspacesDialect::NPM and YARN_CLASSIC) have dot: true, so the governing-root check takes the directory for a workspace member:

Root's lock What the tool says about packages/.tools scan --mode hosted --yes --json from packages/.tools
npm package-lock.json Not a workspace. npm query .workspace lists packages/a only, the root lock has no entry for it, and npm prefix there prints <ws>/packages/.tools (in packages/a it prints <ws>) exit 1, redirect_workspace_lockfile_elsewhere: "npm installs it from <ws>/package-lock.json and ignores its own ./package-lock.json … run socket-patch from <ws> (the workspace root)"
Yarn 1 yarn.lock Not a workspace. yarn workspaces info at the root lists a only; in packages/.tools it answers "Cannot find the root of your workspace" exit 1, same code: "yarn 1 installs it from the workspace root's yarn.lock and ignores its own ./yarn.lock"
Yarn berry yarn.lock (control) yarn workspaces list at the root lists . and packages/a exit 0, applied (a berry lock in the directory makes it a project of its own)

In vendored mode the npm project is refused too (vendor_lockfile_missing, exit 1).

Following the remedy does not patch the project. From the workspace root the same scan exits 0, status: "success", one package scanned, with the warning projects_not_scanned: "1 project directory below this one was not scanned (packages/.tools) … Run one scan per directory, e.g. socket-patch scan packages/.tools". The two messages send the user to each other, and no hosted run can patch the project.

Who it hurts: a repository with an npm or Yarn 1 project in a dot-directory under a workspace glob, such as packages/.tools, packages/.storybook or apps/.internal, or a .github/actions/<name> action under a ** pattern.

This is #1631 (Bun) for npm and Yarn 1.

What the tools list

"workspaces": ["packages/*"], with packages/a, packages/b and packages/.hidden each holding a package.json. npm install, then the packages/ keys of the root lock:

npm Listed
8.19.4, 9.9.4, 10.9.9, 11.21.3 packages/a, packages/b

Yarn 1.22.22 workspaces info does not list packages/.hidden either. Over 600 pattern sets on a 33-directory tree, the library npm 10.9.9 lists workspaces with never listed a dot-directory through a wildcard, and listed one only where the pattern spells the dot (packages/.hidden, packages/.*, .config/*). Yarn 1.22.22 gave the same answer over 260 sets.

Evidence on main

A unit probe appended to utils/workspace_globs.rs:

let pats = vec["packages/*".to_string()];
let rel = |s: &str| s.split('/').map(str::to_string).collect::<Vec<_>>();
for (name, dialect) in [("npm", WorkspacesDialect::NPM), ("yarn classic", WorkspacesDialect::YARN_CLASSIC)] {
    assert!(workspaces_include_as(&pats, &rel("packages/a"), dialect));
    assert!(!workspaces_include_as(&pats, &rel("packages/.tools"), dialect), "{name} lists packages/.tools under packages/*");
}
$ cargo test -p socket-patch-core --lib -- probe_dot_dirs
thread '…::npm_and_yarn_classic_wildcards_skip_dot_components' panicked at crates/socket-patch-core/src/utils/workspace_globs.rs:2365:13:
npm lists packages/.tools under packages/*
test result: FAILED. 0 passed; 1 failed

Through the binary, with the bench's stand-in patch API (socket-patch-bench serve npm/hosted --bin <cli> --scale 0.02 --work-dir <dir>; yarn-classic/hosted for Yarn 1):

mkdir -p ws/packages/a && cd ws && git init -q
echo '{"name":"root","version":"1.0.0","private":true,"workspaces":["packages/*"]}' > package.json
echo '{"name":"a","version":"1.0.0"}' > packages/a/package.json
cp -a <bench project> packages/.tools && rm -rf packages/.tools/.git
npm install --offline          # the root lock lists packages/a only
git add -A && git commit -qm init
$ cd packages/.tools && socket-patch scan --mode hosted --yes --json
exit 1
"error": {"code": "redirect_workspace_lockfile_elsewhere", "message": ". is a member of the npm workspace rooted at <ws>: npm installs it from <ws>/package-lock.json and ignores its own ./package-lock.json, so a lock rewritten here would never be installed; run socket-patch from <ws> (the workspace root); nothing was written"}
$ socket-patch scan --mode vendored --yes --json
exit 1    "events": [{"action": "failed", "purl": "pkg:npm/fefiba30@25.24.3", "errorCode": "vendor_lockfile_missing"}]
$ cd ../.. && socket-patch scan --mode hosted --yes --json
exit 0    "status": "success", "scannedPackages": 1, "events": []
"warnings": [{"code": "projects_not_scanned", "detail": "1 project directory below this one was not scanned (packages/.tools): --json takes one project directory. Run one scan per directory, e.g. `socket-patch scan packages/.tools`"}]

The same project copied outside the workspace: exit 0, applied.

Not run: Yarn 1 in vendored mode past its gate (the run goes on to download, and the bench serves no vendored artifact), macOS and Windows.

Where

  • [WorkspacesDialect::NPM and YARN_CLASSIC](https://github.com/SocketDev/socket-patch/blob/d98772148e4fffb56fa53e9f867e10e1286bb089/crates/socket-patch-core/src/utils/workspace_globs.rs#L66-L79), read by [lock_lists_member](https://github.com/SocketDev/socket-patch/blob/d98772148e4fffb56fa53e9f867e10e1286bb089/crates/socket-patch-core/src/hosted/governing_root.rs#L1072-L1095) and [member_unread_lock](https://github.com/SocketDev/socket-patch/blob/d98772148e4fffb56fa53e9f867e10e1286bb089/crates/socket-patch-core/src/hosted/governing_root.rs#L598-L663).
  • The module's test states the assumption: "npm and yarn callers keep matching dot components" ([line 1247](https://github.com/SocketDev/socket-patch/blob/d98772148e4fffb56fa53e9f867e10e1286bb089/crates/socket-patch-core/src/utils/workspace_globs.rs#L1247-L1248)). It dates from Fix 15 open pnpm issues across hosted, vendored and agent modes #1007 and was not run against either tool.

The same class, fixed before

CLI_CONTRACT.md says the patterns are "read the way the root's lock's package manager reads them" and names the dot rule "for Bun and vlt" only.

Planned fix

Set dot: false for NPM and YARN_CLASSIC. A ! pattern still excludes a dot-directory, as glob's ignore does: the last-match-wins arm already matches negations with the dot on. The probe becomes a test, the comment at line 1247 is corrected (glob_matches is read by the uv workspace reader only), and the contract sentence names npm and Yarn 1 beside Bun and vlt. Two production lines.

Tried on a build of main with those two lines changed, together with the one-line trial fix of #2505; nothing was pushed. The hosted scan from packages/.tools exits 0 with applied under npm and under Yarn 1. Of the 286 existing unit tests of the glob, pnpm workspace, governing-root, crawler and user-patch modules, three fail, and each states the pnpm rule of #2505. The CLI suites were not run.

Yarn berry 4.10.3 does not list packages/.hidden under packages/* either, and YARN_BERRY has dot: true as well. No layout run reached a wrong outcome through it (a berry lock in the directory makes it its own project, and an npm project under a berry root is not refused), so it is noted here and not part of the plan unless a maintainer wants the three changed together.


Generated by Claude Code

Activity

  1. added
    bug
    arch-audit
    on Dec 4, 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:triagedarch-auditbugpriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions