Skip to content

fix(doctor): omit package-runner cache shims from installations - #15059

Merged
vincentkoc merged 6 commits into
morluto:mainfrom
2SinceJuly:fix/15027-doctor-npx-paths
Nov 30, 2026
Merged

vincentkoc merged 6 commits into
morluto:mainfrom
2SinceJuly:fix/15027-doctor-npx-paths

Conversation

@2SinceJuly

@2SinceJuly 2SinceJuly commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

rea doctor lists every which -a rea / where rea hit in installations.paths, including shims inside a package runner's cache. A cache shim and a global prefix are two directories, so state reads multiple for one package. Cache shims under npm _npx, pnpm dlx, yarn dlx, and bunx are omitted. A directory that is only named _npx, dlx, or .bun stays.

Fixes #15027

Problem and expected behavior

Trigger: PATH holds a durable launcher plus a package runner's node_modules/.bin. installationLaunchers counts both and state becomes multiple.

Expected: a cache shim is not an installation. The cache directory is replaced by a later run or a cache prune, so only a durable launcher is counted.

Change and scope

systemDoctorHost().installationLaunchers() filters where/which output before resolving each launcher. Matching uses the listed path, before realpath, so a symlinked cache shim is still omitted. Windows folds case and treats \ as a separator. POSIX keeps the listed spelling.

Layouts matched at the end of the path (node_modules/.bin/<bin>):

  • npm exec: _npx/<16 hex> (libnpmexec's truncated sha512 key), any cache root
  • pnpm dlx: dlx/<64 or 32 hex>/pkg, or dlx/<64 or 32 hex>/<time>-<pid> (hex, later base36)
  • yarn dlx: xfs-<8 or 9 hex>/dlx-<pid>
  • bunx: .bunx-<uid>/<package> (POSIX; a scoped package adds one directory) or bunx-<uid>-<package> (Windows and older POSIX)

Intentionally not included: the ownership classifier (ClientRegistrationIdentity) and registration refresh for a launcher from another installed REA package. Both belong to #15022 / #15023 and #15029. This change stays in the installations field that #15027 describes.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Doctor owns launcher discovery; the change is installationLaunchers in src/application/Doctor.ts. No consumer outside Doctor.ts reads installations.
  • Contribution scope fit and linked maintainer decision: ordinary fix inside the existing doctor boundary; no new provider or target authority. Not applicable.
  • CLI and MCP/tool-catalog contract: doctor JSON identity.installations.paths keeps its shape and only omits cache shims. No schema change.
  • Provider, bridge, target-format, or platform compatibility: POSIX and Windows spellings are handled by one predicate.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged.
  • Target selection, authority, upstream behavior, and cleanup details: none.
  • Generated metadata or installation impact: none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.

Evidence and regression coverage

  • Tests updated: src/application/Doctor.test.ts, under doctor installation count. Injected which -a rea and where rea lines are path fixtures. They do not use the host platform, path.join, or a temp directory.
  • POSIX / fixtures omit npm, pnpm (pkg and <time>-<pid>), yarn, and bunx (including a scoped package) and keep global bins, a project node_modules/.bin, and lookalikes (_npx/bin, pnpm/dlx/bin, a 15-digit _npx key, a short dlx key, a short xfs- name, and a backslash-spelled path).
  • Windows \ fixtures repeat those layouts with mixed case. A second case uses / plus mixed case, including yarn and bunx, and expects state: "single" when one durable launcher remains.
  • User-visible CLI/MCP output: doctor JSON identity.installations.
  • Remaining proof gaps: not run on a host whose PATH actually contains these cache shims. Windows behavior is the injected where output, not a Windows host.

Validation performed

On 44a8b2f155d90aae954a540e16c2213d7546a1c0:

  • npm run test:focused -- src/application/Doctor.test.ts — 90 passed, 1 skipped (91 tests in the file).
  • npm run check:fast — typecheck and lint succeeded; architecture guards passed across 3322 source files. The pre-push hook ran check:fast again and it passed.
  • Not run: npm run check:pr, real which/where on an affected host, a Windows host.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; doctor host probing only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: reads the same where/which output it already read; no new command, file write, or network.

Author readiness

Human owner: @2SinceJuly

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Author checklist (completed by the PR author before requesting review)

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
  • I ran every test, build, or measurement needed to validate this change, reported a browser, GPU, or environment gap only when that runtime or hardware is unavailable, and reported the checks I ran and their results without presenting inferred correctness or speedups as measured.
  • Comments explain constraints or non-obvious decisions; task history and conversations stay out of code and docs.
  • Documentation is concise and factual, without punchy slogans or promotional language.
  • This change fixes the root cause and follows the engineering rules in AGENTS.md.
  • Formatted input is interpreted once at the owning boundary, and consumers use the owner's parsed facts.
  • Combined failures preserve partial observations, remaining resources, and cleanup facts.
  • A hardcoded limit is an REA_ runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason.
Open in Web Open in Cursor 

`rea doctor` lists every `which -a rea` / `where rea` hit in
`installations.paths` without filtering. A launcher under npm's `_npx`
cache or pnpm's `dlx` cache is a cache shim, not a separate installation:
the hashed directory is replaced by a later run or a cache prune, so pairing
it with a global prefix made doctor report `state: multiple` for one
package.

Drop launcher paths whose directory chain contains an `_npx` segment or a
pnpm `dlx` segment, on both POSIX and Windows spellings. The field stays
cosmetic, matching the issue's scope note.

Validation: `npm run test:local -- src/application/Doctor.test.ts` (89
passed, including two new cases that fail when the filter is removed);
`npm run check:fast`, `npm run lint` and `oxfmt --check` pass. Not run:
full `check:pr`, real `where`/`which` on a host with an npx-cache launcher;
the new cases drive launcher discovery through an injected execFileOutput.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 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-30T05:42:35.422169Z df73fc9 New commits
ℹ️ 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.

@greptile-apps

greptile-apps Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; no actionable issues remain in the reviewed changes.RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no actionable issues remain in the reviewed changes.

Summary

rea doctor omits package-runner cache launchers before resolving installation paths. The latest change narrows Yarn matching so nearby durable launchers stay visible.

  • rea doctor leaves package-runner cache shims out of its installation count.

Reviews (6) · Last reviewed commit: "fix(doctor): preserve launchers near Yar..." · Reviewed by Greptile

Comment thread src/application/Doctor.ts Resolved
Comment thread src/application/Doctor.test.ts Resolved
@2SinceJuly

2SinceJuly commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Status at 7dabbca: all 4 required checks pass (CI required, Conventional PR title, Portable tests, and Static checks), 0 unresolved threads, mergeable_state clean, 3 commits / +126 −2 across 2 files.

Re-verified on current main (4dafa3a58): packageRunnerCacheShim is not present in src/application/Doctor.ts and neither cache-shim test exists in Doctor.test.ts, so this is not stale.

One detail a reviewer may want to weigh: the pnpm dlx regex accepts (?:pkg|[a-z0-9]+-[a-z0-9]+) for the leaf directory, which is the shape both pnpm v10 (<64-hex>/<pkg>) and v11 (<32-hex>/<pkg>-<hash>) write. The npm branch pins _npx to 16 hex chars. If pnpm ever changes the leaf naming, the filter silently stops matching rather than over-matching — failing safe toward the current behavior.

Is a split useful here, or does the single filter hook in systemDoctorHost match how you'd rather see runner caches handled? Happy to carve out the Windows spelling case as its own PR if the two tests are better reviewed separately.

npm and pnpm cache shims were omitted, but yarn dlx and bunx PATH entries
still counted as installations. Match each runner's cache directory on the
listed path, and cover POSIX and Windows spellings with path fixtures.
@cursor

cursor Bot commented Nov 29, 2026

Copy link
Copy Markdown

@greptileai

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 44a8b2f155

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/application/Doctor.ts Resolved
2SinceJuly and others added 2 commits November 30, 2026 09:24
Yarn Berry's default PnP linker writes the `yarn dlx` command wrapper
directly into a second `xfs-<hex>` temp directory and puts only that
directory on PATH, so `which -a rea` lists `/tmp/xfs-<hex>/rea`. The
package-runner filter only matched the other Yarn layout, where the
launcher sits under `xfs-<hex>/dlx-<pid>/node_modules/.bin`. A PATH that
held a real REA launcher plus that wrapper still read `multiple`.

Reproduced with yarn 4.18.0: the wrapper argv points into
`xfs-<hex>/dlx-<pid>`, but the PATH entry is the bare `xfs-<hex>` dir.
Match the temp segment one or two levels above the launcher, including
the bare wrapper, and keep a durable launcher under a bare `xfs-<hex>`
or `xfs-<hex>/bin` as an installation.
@vincentkoc
vincentkoc merged commit 66ed787 into morluto:main Nov 30, 2026
40 checks passed
@vincentkoc

Copy link
Copy Markdown
Collaborator

thanks! merged with the tightened Yarn matching and added regression cases. all required CI passed, including Apple E2E; 716 selected tests passed.

vincentkoc added a commit to xu91102/rea that referenced this pull request Nov 30, 2026
* commit '4ccc685dd5ed028bc625fdd8760539ce5a492d8d': (228 commits)
  test(asar): verify cleanup on the original file handle (morluto#15155)
  fix(ubi): bound smaller-grid probe memoization (morluto#15168)
  fix(artifacts): distinguish content from containment changes (morluto#15165)
  fix(bflt): retain complete text when data is truncated (morluto#15160)
  refactor(domain): reuse graph projection and validation helpers (morluto#15173)
  fix(iso9660): read a directory record's data length from its little-endian half (morluto#14801)
  test(ghidra): wait for each fixture spawn before expiring startup (morluto#15172)
  test(beam): reuse the CLI Evidence reader (morluto#15171)
  test(oci): share descriptor budget refusal assertions (morluto#15159)
  refactor(audit): share byte framing for offline audit logs (morluto#15162)
  refactor(evidence): reuse observed file reports for binary metadata (morluto#15161)
  fix(doctor): omit package-runner cache shims from installations (morluto#15059)
  refactor(packages): share package inspection budget contracts (morluto#15158)
  refactor(desktop): share completed command answer recovery (morluto#15156)
  refactor(views): share page byte reservations (morluto#15152)
  refactor(artifacts): share GPU and media asset layout rules (morluto#15150)
  fix(setup): name the detected host when Hopper setup does not apply (morluto#14449)
  fix(iso9660): read a directory record whose identifier padding byte is not zero (morluto#15020)
  fix(windows): report the ACE count a private DACL check observed (morluto#14450)
  fix(artifacts): read Ogg Opus channel mapping tables (morluto#14975)
  ...
vincentkoc added a commit to liziye627-design/rea that referenced this pull request Nov 30, 2026
* commit 'e18ed55bac14191010efe91ba61489cab1d2ba55': (137 commits)
  fix(artifacts): report macOS package bundle release versions (morluto#14860)
  test(asar): verify cleanup on the original file handle (morluto#15155)
  fix(ubi): bound smaller-grid probe memoization (morluto#15168)
  fix(artifacts): distinguish content from containment changes (morluto#15165)
  fix(bflt): retain complete text when data is truncated (morluto#15160)
  refactor(domain): reuse graph projection and validation helpers (morluto#15173)
  fix(iso9660): read a directory record's data length from its little-endian half (morluto#14801)
  test(ghidra): wait for each fixture spawn before expiring startup (morluto#15172)
  test(beam): reuse the CLI Evidence reader (morluto#15171)
  test(oci): share descriptor budget refusal assertions (morluto#15159)
  refactor(audit): share byte framing for offline audit logs (morluto#15162)
  refactor(evidence): reuse observed file reports for binary metadata (morluto#15161)
  fix(doctor): omit package-runner cache shims from installations (morluto#15059)
  refactor(packages): share package inspection budget contracts (morluto#15158)
  refactor(desktop): share completed command answer recovery (morluto#15156)
  refactor(views): share page byte reservations (morluto#15152)
  refactor(artifacts): share GPU and media asset layout rules (morluto#15150)
  fix(setup): name the detected host when Hopper setup does not apply (morluto#14449)
  fix(iso9660): read a directory record whose identifier padding byte is not zero (morluto#15020)
  fix(windows): report the ACE count a private DACL check observed (morluto#14450)
  ...
vincentkoc added a commit to viniciusdsandrade/rea that referenced this pull request Nov 30, 2026
* commit '76cb6645be39cf3844f7a8bb4568b02d8a713595': (95 commits)
  fix(macos-pkg): retain cpio hard-link contents (morluto#15157)
  fix(artifacts): report macOS package bundle release versions (morluto#14860)
  test(asar): verify cleanup on the original file handle (morluto#15155)
  fix(ubi): bound smaller-grid probe memoization (morluto#15168)
  fix(artifacts): distinguish content from containment changes (morluto#15165)
  fix(bflt): retain complete text when data is truncated (morluto#15160)
  refactor(domain): reuse graph projection and validation helpers (morluto#15173)
  fix(iso9660): read a directory record's data length from its little-endian half (morluto#14801)
  test(ghidra): wait for each fixture spawn before expiring startup (morluto#15172)
  test(beam): reuse the CLI Evidence reader (morluto#15171)
  test(oci): share descriptor budget refusal assertions (morluto#15159)
  refactor(audit): share byte framing for offline audit logs (morluto#15162)
  refactor(evidence): reuse observed file reports for binary metadata (morluto#15161)
  fix(doctor): omit package-runner cache shims from installations (morluto#15059)
  refactor(packages): share package inspection budget contracts (morluto#15158)
  refactor(desktop): share completed command answer recovery (morluto#15156)
  refactor(views): share page byte reservations (morluto#15152)
  refactor(artifacts): share GPU and media asset layout rules (morluto#15150)
  fix(setup): name the detected host when Hopper setup does not apply (morluto#14449)
  fix(iso9660): read a directory record whose identifier padding byte is not zero (morluto#15020)
  ...
vincentkoc added a commit to ShuaixinHuang/rea that referenced this pull request Nov 30, 2026
* commit '6c7dffc59b970fcfae023af3171d92ee0ac50f94': (137 commits)
  fix(json): classify JSON input heap headroom and string-ceiling refusals (morluto#14949)
  fix(macos-pkg): retain cpio hard-link contents (morluto#15157)
  fix(artifacts): report macOS package bundle release versions (morluto#14860)
  test(asar): verify cleanup on the original file handle (morluto#15155)
  fix(ubi): bound smaller-grid probe memoization (morluto#15168)
  fix(artifacts): distinguish content from containment changes (morluto#15165)
  fix(bflt): retain complete text when data is truncated (morluto#15160)
  refactor(domain): reuse graph projection and validation helpers (morluto#15173)
  fix(iso9660): read a directory record's data length from its little-endian half (morluto#14801)
  test(ghidra): wait for each fixture spawn before expiring startup (morluto#15172)
  test(beam): reuse the CLI Evidence reader (morluto#15171)
  test(oci): share descriptor budget refusal assertions (morluto#15159)
  refactor(audit): share byte framing for offline audit logs (morluto#15162)
  refactor(evidence): reuse observed file reports for binary metadata (morluto#15161)
  fix(doctor): omit package-runner cache shims from installations (morluto#15059)
  refactor(packages): share package inspection budget contracts (morluto#15158)
  refactor(desktop): share completed command answer recovery (morluto#15156)
  refactor(views): share page byte reservations (morluto#15152)
  refactor(artifacts): share GPU and media asset layout rules (morluto#15150)
  fix(setup): name the detected host when Hopper setup does not apply (morluto#14449)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doctor: installations.paths lists npx cache shims

3 participants