fix(search): restore zero-match probes on the rg engine after auto-multiline early-return - #77128
Conversation
…ltiline early-return Integration regression between two merged PRs: #77102's rg-path early return (added to skip the grep-era line-oriented warning) also skipped the #77011 zero-match steering probes (case-insensitive, hidden-file, literal-vs-regex), silencing them on the primary engine. Caught by #77001's rebased CI run (its branch carried both features together for the first time). _search_content now runs the zero-match probe block for BOTH engines and only exempts the rg path from the legacy line-oriented \n warning (rg auto-enables --multiline; the grep fallback keeps the explanation).
૮ >ﻌ< ა ci reviewran on 15b10d5 all good! |
|
Hit this independently while triaging a red slice 8/8 on #77104 — same root cause, so I dropped my duplicate fix in favor of this one. Confirming the diagnosis from the other direction: Three minutes apart. The later commit's One gap: this PR ships no tests, so a fourth commit can silently orphan the tier the same way. I have a regression class that fails on exactly that reintroduction — parametrized over both search engines, with the probe stubbed to a sentinel so it isolates the wiring rather than the probe's own rg dependency (worth noting: the probe shells out to rg by design, so a grep-only host gets no hints even when wiring is correct — a naive parity test asserting real hint text fails on the grep leg for that reason, not because of this bug). Sabotage-verified against your fix: restoring the early return turns 4 tests red; never attaching the hint turns 5 red; attaching it when matches exist turns 2 red. 14/14 green on the fix. Want me to push those tests onto this branch, or land them as a follow-up after this merges? |
#77128 fixed the orphaned zero-match probe but shipped no tests, so the same class of break can recur: an early return anywhere in the rg branch silently makes the whole steering tier unreachable. Asserts hint wiring per search engine with the probe stubbed to a sentinel (the probe itself needs rg, so a real-text parity assertion fails on the grep leg for an unrelated reason), plus the negative case and the rg newline-warning skip that the early return originally existed to preserve. Sabotage-verified against 794d6c4: restoring the early return turns 4 red; a naive fix that also drops the rg newline guard turns 1 red; attaching the hint when matches exist turns 2 red.
Addresses teknium1's hermes-sweeper review on NousResearch#77157 and closes the canonical Windows search bug (NousResearch#63177, dup NousResearch#77036). The native-rg path rewrite (_escape_native_arg) was previously gated on the host OS alone (os.name == 'nt'), but command execution is backend-agnostic through self.env.execute: a Windows host driving a remote SSH/WSL/Docker backend would rewrite valid remote paths such as /mnt/d/... into an invalid D:\... form. The conversion now only applies when the EXECUTED backend is the local Windows environment (_local_windows_backend: isinstance(self.env, LocalEnvironment) and _IS_WINDOWS, mirroring the _lsp_local_only gate). Remote paths pass through unchanged. The grep-fallback probe work (engine picker + per-engine flags) is kept — main's _zero_match_probe still hard-requires rg. Upstream NousResearch#77128 already landed the rg early-return repair; main's structure is preserved (probe runs on both engines, used_rg guard for the newline warning). New tests: TestNativePathBackendGating (local /c/ -> C: conversion, remote /mnt/d/ /mnt/c/ /home/ pass through even with _IS_WINDOWS=True, remote probe command keeps the raw remote path) and test_end_to_end_search_real_hint_via_forced_grep (real search() pipeline with grep forced via _has_command, real probe, asserts the case- insensitive hint in the result warning). 24 passed / 0 failed on the target file; broader-suite failure set byte-identical to pristine origin/main (stash + worktree proven); ruff clean. Independent QA critique: SAFE TO SHIP.
NousResearch#77128 fixed the orphaned zero-match probe but shipped no tests, so the same class of break can recur: an early return anywhere in the rg branch silently makes the whole steering tier unreachable. Asserts hint wiring per search engine with the probe stubbed to a sentinel (the probe itself needs rg, so a real-text parity assertion fails on the grep leg for an unrelated reason), plus the negative case and the rg newline-warning skip that the early return originally existed to preserve. Sabotage-verified against d563f00: restoring the early return turns 4 red; a naive fix that also drops the rg newline guard turns 1 red; attaching the hint when matches exist turns 2 red.
NousResearch#77128 fixed the orphaned zero-match probe but shipped no tests, so the same class of break can recur: an early return anywhere in the rg branch silently makes the whole steering tier unreachable. Asserts hint wiring per search engine with the probe stubbed to a sentinel (the probe itself needs rg, so a real-text parity assertion fails on the grep leg for an unrelated reason), plus the negative case and the rg newline-warning skip that the early return originally existed to preserve. Sabotage-verified against 794d6c4: restoring the early return turns 4 red; a naive fix that also drops the rg newline guard turns 1 red; attaching the hint when matches exist turns 2 red.
Summary
Restores the #77011 zero-match steering probes (case-insensitive / hidden-file / literal-vs-regex) on the ripgrep engine — #77102's early return, added to skip the legacy line-oriented
\nwarning for rg, was also skipping the probe block.Root cause: an integration regression between two individually-green PRs. #77011 attached the probes after the engine dispatch in
_search_content; #77102 later addedreturn resultdirectly after the rg call so the grep-era line-oriented explanation wouldn't fire on an engine that now auto-multilines. That return bypassed the probes on the primary engine. Caught by #77001's rebased CI (its branch was the first to carry both features together).Changes
tools/file_operations.py(_search_content): probes run for BOTH engines; only the legacy line-oriented\nwarning is rg-exempt (rg auto-enables--multiline; the grep fallback keeps the explanation).Validation
search_tool()\npattern still multiline-matches with mode noteInfographic