Skip to content

Honor agent re-includes in ripgrep project listings - #1759

Open
VIOLETee0 wants to merge 1 commit into
CodebuffAI:mainfrom
VIOLETee0:fix/ripgrep-default-reincludes
Open

VIOLETee0 wants to merge 1 commit into
CodebuffAI:mainfrom
VIOLETee0:fix/ripgrep-default-reincludes

Conversation

@VIOLETee0

Copy link
Copy Markdown

Problem / Why

The new ripgrep project listing is meant to preserve the directory walker's ignore decisions. With .codebuffignore containing !node_modules and !node_modules/**, the walker finds node_modules/pkg/index.ts, but the ripgrep path omits it without marking the result incomplete. glob uses this listing on the local disk.

The retry for agent-owned negations turns off Git ignore pruning but still passes the generated default-directory ignore file. Those defaults exclude the directory before the final ignore chain can apply the explicit re-include.

Changes

  • Give the ordinary listing its existing default-directory pruning arguments, and omit that file from the existing unpruned retry. The final project ignore filter still decides which candidates are returned.
  • Add one real-directory regression using the bundled ripgrep and the actual walker. It requires the re-included dependency file to be discovered while a Git-ignored file and an agent-blocked file remain absent.

Verification

Windows x64, Bun 1.3.14, base 88be5fff67efbc76489943d5e1295405b3d9cfe7; isolated test home, --no-env-file, and the repository's placeholder-only sdk/test/setup-env.ts preload.

  • New regression: before 0 pass, 1 fail (missing node_modules/pkg/index.ts); after 1 pass, 0 fail.
  • bun test sdk/src/__tests__/list-project-files.test.ts -t 're-includes|honors|keeps': 5 pass, 0 fail.
  • bun test sdk/src/__tests__/glob.test.ts -t 'on the local disk': 3 pass, 0 fail, including discovery beyond the walk's cap and result-limit behavior.
  • Full two-file run: 7 pass, 3 skip, 7 fail on main with the new regression; 8 pass, 3 skip, 6 fail after the fix. The same six existing Windows failures remain: five POSIX-path mock fixtures and one symlink-creation EPERM. The three platform skips are existing POSIX process tests. This is not a passing whole-suite claim.
  • SDK tsc --noEmit -p sdk, frozen-lockfile install, SDK build, Windows Freebuff binary build, binary version and smoke: passed.
  • Prettier and git diff --check: passed. ESLint: 0 errors, 4 warnings, identical to main's resolver warnings.

Notes / Scope

This is a source-audit finding without an existing issue being claimed. An agent-owned negation can now make the existing retry enumerate built-in excluded directories as candidates; the final filter still applies defaults and project rules. This favors correct re-inclusion over pruning that cannot be undone. The existing 500,000-file and 20-second scan bounds and incomplete-result notice remain in place. Ordinary listings retain their pruning, and cancellation, filesystem injection and public APIs are unchanged.

No Linux/macOS or full-monorepo run was performed. The regression uses no model service, account or module mock.

@codebuff-team

Copy link
Copy Markdown
Contributor

Good catch and a clean fix. In listCandidates, args previously always included --ignore-file <defaultsFile>, so when unpruned = [...args, '--no-ignore-vcs'] was built for the agent re-include retry, it still carried the default directory-pruning ignore file — defeating the purpose of the retry for cases like !node_modules / !node_modules/**. Splitting args into a base (no defaultsFile) and a separate pruned variant (base + defaultsFile) for the normal path, while leaving unpruned built from the defaultsFile-free base, is the right fix and keeps the normal listing's behavior unchanged.

The added regression test in list-project-files.test.ts is well targeted — it exercises exactly the reported scenario (re-included node_modules/pkg/index.ts alongside a blocked file and a git-ignored file) and compares against the real walker via walkEverything, which is the right oracle here given ripgrep is meant to mirror walker decisions.

The PR body's verification section is unusually exhaustive for a two-file diff, but the substance checks out: the before/after test counts match the claimed bug, and the comment updates in the docstring/code accurately describe the new behavior (mentioning both Git and built-in directory pruning being lifted in the retry, with the final ignore chain still deciding what's returned).

No concerns about scope — this only touches sdk/. Worth porting as-is; the only minor suggestion is to double check behavior on Linux/macOS since this PR's verification was Windows-only, given path-handling differences noted in the body itself.

@codebuff-team codebuff-team added bot:triaged Classified by the community triage bot pr:port-candidate Worth porting into the private source tree labels Nov 29, 2026

This branch has not been deployed

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

Labels

bot:triaged Classified by the community triage bot pr:port-candidate Worth porting into the private source tree

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants