Skip to content

Fix agent scan silent about projects below (#2125) - #2126

Merged
Mikola Lysenko (mikolalysenko) merged 4 commits into
mainfrom
agent/fix-agent-scan-silent-about-projects-below
Nov 18, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 4 commits into
mainfrom
agent/fix-agent-scan-silent-about-projects-below

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-fable-5-2

Fixes #2125

Summary

A bare agent-mode scan run from a monorepo root covered the root
directory only and said nothing about the projects below it. With no
project at the root it printed No packages found. Run your package manager's install first.; with one it printed a success summary while
api/ and web/ kept the unpatched gem.

The scan's coverage is unchanged (it is by design, see CLI_CONTRACT.md).
What changes is that the run now says what it left:

Warning: 2 project directories below this one were not scanned (api, web): an agent-mode scan patches the packages installed for the one project directory it runs in. Run one scan per directory, e.g. `socket-patch scan --mode agent --cwd api`
No packages found (see the warning).

The same text is a projects_not_scanned entry in --json
warnings[]. Exit code and status are unchanged, nothing new is
written, and a checkout with no such directory prints what it always did.

Root cause

A bare hosted or vendored scan looks for the project directories below
--cwd (projects_below::discovered) and scans each. Agent mode
patches the installed copies its crawl of --cwd reads, and it never
ran that search, so it could not tell an empty directory from a monorepo
root.

The fix

After the crawl, a bare agent-mode scan in a git checkout runs the same
search and keeps the directories that have an install directory of their
own which the crawl from --cwd did not read
(projects_below::not_crawled):

Ecosystem A project's own install directory Named when
RubyGems its vendor/bundle, or the user-wide gem homes --cwd did not read that gem home
PyPI an environment inside the project (.venv, ...) it is not the activated one
Composer a vendor directory inside the project always (a crawl reads --cwd's only)
npm a node_modules inside the project the walk from --cwd skipped it (hidden or build-output directory)

A directory whose packages the run did read is not named: an ordinary
nested npm project, or a Bundler project sharing the gem home --cwd
reads. The user-wide Python, Cargo and Go stores are never compared, so a
docs/requirements.txt with no environment does not warn on every scan.

Details: the command is suggested as the run was asked (--mode agent,
--sync, or a bare scan when the mode was inferred, since an
explicit --mode converts a project); more than 10 directories are
listed as the first 10 and a count; a tree too large to search adds a
projects_below_not_searched warning; directories are resolved 8 at a
time (60 Bundler projects with no store of their own: 2.5 s, most of it
gem env).

Evidence

Tests in crates/socket-patch-cli/tests/scan/scan_project_discovery_e2e.rs
(the real binary against a mock patch API). The first commit adds them;
without the fix the three marked red fail.

Test Covers Before
agent_scan_names_the_projects_below_it_left #2125 shape 1: human and --json output, said once, no install hint, --sync command, --cwd api scans and does not warn red
agent_scan_of_a_root_project_names_the_projects_below_it_left #2125 shape 2: the root is a Bundler project too red
agent_scan_names_a_python_project_below_with_its_own_venv the same for a PyPI project with a .venv red
agent_scan_names_an_npm_project_its_walk_skips an npm project under .github/ added with the rework
agent_scan_does_not_name_a_project_it_reached no warning for a nested npm project, a Python project with no environment, a PATH scan, or outside a checkout guard

Also run by hand with Bundler 4.0.18 / Ruby 3.3.6 on the issue's repro
(bundle install into vendor/bundle in api/ and web/): both
shapes print the warning once; a third project using the user-wide gem
home is named from a root with no Gemfile and not named from a root that
reads the same gem home. Real npm, pnpm and Yarn installs (a workspace
plus nested independent projects) produce no warning, except for a project
under tools/build, which the npm walk skips.

Local checks:

  • cargo clippy --locked --workspace --all-features -- -D warnings: clean
  • cargo test -p socket-patch-cli --lib: 950 passed
  • cargo test -p socket-patch-cli --test scan: 262 passed
  • cargo test -p socket-patch-cli --test cli, command_module_layering,
    cli_scan_silent, cli_parse_scan: all passed
  • cargo clippy -p socket-patch-cli --all-targets ... reports lints in
    test helpers this PR does not touch (tests/prebuilt_common/mod.rs,
    tests/common/mod.rs, and others); the same on main. None is in a
    file changed here.

CLI_CONTRACT.md and docs/usage.md describe the new warning.

Review

/code-review high ran on the first cut and its findings drove the
third commit (false warnings for a Python project with no environment,
npm projects the walk skips, serial probes, a dropped truncation flag, an
uncapped list, the suggested command, contradictory contract text). One
finding is not fixed:

  • Two independent Go modules or Cargo packages (root and tools/, each
    with its own go.sum / Cargo.lock) share one user-wide cache, and
    the root crawl looks up only the root's packages. tools is not named,
    as before this PR. Naming it needs a comparison of lockfiles rather than
    of directories, and would also name a project with nothing installed.

Cursor Bugbot reviewed 300c75a and raised one finding (an activated
venv hides a nested project's own .venv). It is answered in its thread
and resolved without a change: a scan from that directory reads the
activated env too, so naming it would point at a run that patches nothing
more.

Follow-ups (not in this PR)

  • scan --mode agent api (a PATH) still answers No installed packages found under the given path: api.: agent PATHs are globs under the
    root's own install. The issue lists it as "the obvious next try".
  • A hosted scan --vex above other projects prints its
    projects_not_scanned warning twice on stderr (an eprintln! plus
    print_layout_refusals). It predates this PR.

https://claude.ai/code/session_011f9aePXwxoYZmCDiJZRdmL


Generated by Claude Code

Assisted-by: Claude Code:claude-fable-5-2
A bare agent-mode scan above Bundler or PyPI projects with their own
install directories must name the ones it left (#2125). These fail
until the scan looks for them.

Assisted-by: Claude Code:claude-fable-5-2
A bare agent-mode scan patches the installed packages its crawl of
--cwd reads, so it covers one project. It never looked for project
directories below --cwd: from a monorepo root it printed "No packages
found. Run your package manager's install first.", or a success
summary for the root alone, and left api/ and web/ unpatched without
a word (#2125).

After the crawl it now finds the project directories below (the
search a bare hosted scan uses) and keeps the ones where a crawl would
read a PyPI, Cargo, RubyGems, Go or Composer install directory the
crawl from --cwd did not. It names them in a projects_not_scanned
warning with the command that reaches the first, on stderr and in
--json warnings[]. An empty scan with such a warning points at it
instead of telling the user to run an install. npm is not compared:
its crawl walks every node_modules below --cwd.

Assisted-by: Claude Code:claude-fable-5-2
Review of the first cut found it too loose and too narrow at once.
A Python project with no environment fell back to the machine's
site-packages and was named on every scan, while an npm project the
walk from --cwd skips (a hidden or build-output directory) never
was.

A directory is now named when it has an install directory of its
own that the crawl from --cwd did not read: a node_modules, a Python
environment or a Composer vendor directory inside the project, or a
gem home (Bundler installs into the user-wide ones by default). The
user-wide Python, Cargo and Go stores are not compared.

Also: resolve the directories a few at a time, say when the tree was
too large to search, list at most 10 directories, and suggest the
command as the run was asked (--sync, an inferred mode).

Assisted-by: Claude Code:claude-fable-5-2
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 18, 2026 05:49
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

bugbot run


Generated by Claude Code

@cursor

cursor Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Adds read-only discovery and warning text only; scan coverage and exit codes are unchanged, with broad e2e coverage for false-positive guards.

Overview
Agent-mode scan from a monorepo root no longer looks like it covered the whole tree when it only patched --cwd. After the crawl, a bare agent run (no PATHs, in a git checkout) discovers sibling project directories and flags any whose own install roots (local node_modules, .venv, vendor/bundle, Composer vendor, etc.) were not read by the crawl from --cwd.

Those directories get the existing projects_not_scanned warning (stderr and --json warnings[]), with agent-specific copy and a suggested command (scan --mode agent, --sync, or bare scan as invoked, preserving --dry-run). When nothing was found partly for this reason, the run prints No packages found (see the warning). instead of pushing an install. Large trees can also emit projects_below_not_searched if discovery truncates.

Implementation adds own_install_roots / crawled_install_roots in ecosystem dispatch and not_crawled in projects_below.rs; contract and usage docs are updated. E2E tests cover Bundler, Python .venv, hidden npm projects, and cases that should not warn.

Reviewed by Cursor Bugbot for commit 300c75a. Configure here.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 300c75a. Configure here.

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver

What it does
A bare agent-mode scan from a monorepo root used to cover only the root and say nothing about the projects below it (#2125). It now looks for project directories below --cwd that have an install directory of their own its crawl did not read (a vendor/bundle, a .venv, a Composer vendor, a node_modules the walk skips) and names them in a projects_not_scanned warning with the --cwd command to run. Which directories get scanned doesn't change.

Risk: low. It only adds output: no new writes, and exit code and status stay the same. The one cost is runtime: every bare agent scan inside a git checkout now runs the discovery walk plus a short probe of each project's install directories (at most 8 at a time, 1 under a tight fd limit). The PR measured 60 Bundler projects at about 2.5 s.

Look here

  • scan/mod.rs:2119: when the check runs (agent mode, no PATH, not a carry sub-run) and how the suggested command is built
  • scan/mod.rs:2612: "No packages found (see the warning)." replaces the install hint
  • projects_below.rs:382: not_crawled, which compares each project's own install directories with what --cwd's crawl read, both canonicalized
  • ecosystem_dispatch.rs:1563: own_install_roots. Gem homes are not limited to directories inside the project, so a Bundler project on the user-wide gem home is named from a root that holds no Gemfile, even when nothing is installed for it
  • [scan_project_discovery_e2e.rs:311](https://github.com/SocketDev/socket-patch/blob/300c75a0ec9248290bfd7949cc6c04ad175e44ec/crates/socket-patch-cli/tests/scan/scan_project_discovery_e2e.rs#L311): the e2e tests (3 failed before the fix, plus guard tests for the cases that must not warn)

Verified

Changes I made: none.

Open questions: none blocking. Possible follow-up: the npm node_modules walk from --cwd now runs twice per agent scan (once in the crawl, once in crawled_install_roots).


Generated by Claude Code

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Nov 18, 2026
Merged via the queue into main with commit 4bbcf91 Nov 18, 2026
82 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the agent/fix-agent-scan-silent-about-projects-below branch November 18, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

4 participants