Files
bytecii db35b4888f feat(dropbox): grep/rg search push-down via files/search_v2 (#568)
* feat(dropbox): grep/rg search push-down via files/search_v2

Recursive grep/rg on a Dropbox mount previously downloaded every file.
With the new content_search / contentSearch config knob (off by default:
full-text search is plan-gated and its index lags recent writes), both
commands now ask /2/files/search_v2 which files contain the pattern's
literal and download only those candidates. Output stays exactly
GNU/ripgrep because the local scan still decides every match:

- Core searchFiles pages search_v2 + search/continue_v2, dedups across
  pages, and reports the 10,000-match ceiling; narrowPaths maps
  path_lower/path_display back to mount paths under root_path, sorts
  narrowed candidates into sorted-readdir walk order, and rebases
  raw_path onto the scope spelling so labels match a walk's.
- narrow_scope gates the push-down: literal (or regex-required-literal)
  single patterns only, recursive scans only, directory operands only,
  and never for output modes that must see every file (grep -v/-c,
  rg -v/--type/--glob). Empty/failed/truncated searches fall back to
  the full walk; binary-extension candidates are dropped to mirror the
  walk's skip; rg prunes hidden candidates segment-wise and forces
  walk-style filename labels.
- Both wrappers keep the factory's default_provision so cost estimates
  are unchanged.
- fix(grep, python): grep -Rl with a file operand now stats first and
  scans the file instead of readdir-walking it (GNU + TS parity);
  narrowed candidates exercised this path.
- Fakes gain search_v2 + search/continue_v2 (case-insensitive substring
  over names and content — a superset of real token matching, which is
  what narrowing needs) with cursor paging; battery adapters enable the
  knob, so all dropbox/dropbox-root grep/rg cases now exercise the
  push-down live: 988/988 per target on both hosts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(dropbox): CI fixes — TS grep -Rl file operands, rg -I labels, formatting

The local TS battery ran against a stale mirage-node dist (only core was
rebuilt), so the node DropboxResource never forwarded contentSearch and
search narrowing was silently inactive on the TS host; CI's fresh build
activated it and exposed two latent TS bugs python had already fixed:

- grepFilesOnly walked file operands under -r (readdir on a narrowed
  file candidate -> ENOENT warnings, empty output). It now stats first
  and takes the single-file scan for file operands (GNU + python
  grep_files_only parity); regression tests in both languages.
- rg's plain-line path delegates to grepGeneric, whose single-file body
  honors -H over -h, so the wrapper's forced label defeated -I
  suppression. Both wrappers now skip forcing H when -I is set;
  regression tests in both languages.

Also formats the new files pre-commit never saw locally (they were
untracked when it ran; --all-files only covers git ls-files) and settles
two formatter fights: the provision calls are hoisted onto a shared
dropboxResolveGlob const so Prettier/ESLint agree, and the
test_grep_helper import gets grep_helper via a module import so
yapf/isort converge.

Verified with fresh core+node dists: dropbox/dropbox-root 988/988 on
both hosts (narrowing live), ram/disk 2170/0, core vitest green,
pre-commit converges.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: bytecii <bytecii@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-19 04:37:52 -07:00
..