Repository navigation
fix(executor): memoized command-lookup misses self-heal via the #392 probe grid - #1724
Merged
Merged
Conversation
…probe grid (#1723) GNU never remembers a failed command search: search_for_command re-stats even positively hashed entries on every lookup (findcmd.c:348-380) and find_user_command_in_path walks $PATH live for every unhashed name (findcmd.c:623-697), so install-then-invoke resolves with zero user action. The `set +h` / tempenv-PATH bypass memoized misses into results[] (rubash#159) and served them verbatim — a `wpm install` into an already-listed PATH dir stayed "command not found" until `hash -r`. Keep the negative memo (a Windows miss costs tens of ms) but gate the serve: a memoized miss runs the rubash#392 candidate probe grid once — every candidate spelling stat'ed under every PATH dir — before being honored. A probe hit drops the stale entry and the real walk resolves the file. The probe grid is the bounded cost: repeated misses pay one stat walk, never the full PATH x PATHEXT listing scan, mirroring GNU's own per-lookup walk for unhashed names. confirm_listing_miss now reports probe.hit (a candidate exists NOW) in addition to probe.moved (a listing was stale); hit is the memoized-miss oracle because it keeps answering true on every later probe while the file exists — moved alone would re-freeze the memo once the listing was refreshed. The scan scaffold (split/translated PATH dirs + PATHEXT order) is factored into path_scan_scaffold so the gate and the walk share it. The hash-table mirror (`hash -p` / BASH_CMDS, rubash#1137) is untouched, as are positive-memo serves. Verified against WSL GNU bash 5.3.x (script-file probe, /mnt/d): miss=1 found=0 for plain, `set +h`, and `PATH=dir cmd` lookups around a mid-session file create — identical transcripts under rubash. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
caomengxuan666
force-pushed
the
fix/1723-negative-lookup-selfheal
branch
from
October 26, 2026 12:41
61d019a to
dc38bd3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1723
GNU contract
GNU never remembers a failed command search:
search_for_command(findcmd.c:348) consultsphash_searchfor positively hashed entries only — there is no negative table — and even those are re-stat'ed on every lookup (findcmd.c:367-376).$PATHlive on every invocation (find_user_command_in_path, findcmd.c:623-697, viafind_in_path_element→file_status, findcmd.c:113). A failed lookup leaves no trace, so install-then-invoke resolves with zero user action.What changed
The
set +h/ tempenv-PATH bypass path infind_user_commandmemoized misses intoresults[](rubash#159 — a Windows miss costs tens of ms) and served them verbatim untilhash -ror a PATH change. The memo is kept, but the serve is now gated: a memoized miss runs the rubash#392 candidate probe grid (every candidate spelling stat'ed under every PATH dir) once before being honored. A probe hit drops the stale entry and the real walk resolves the file that appeared mid-session.confirm_listing_missnow reportsprobe.hit(a candidate exists NOW) alongsideprobe.moved(a listing was stale).hitis the memoized-miss oracle —movedalone would re-freeze the memo once the listing was refreshed.path_scan_scaffold, shared by the gate and the walk.hashedmirror (hash -p/ BASH_CMDS, rubash#1137) and positive-memo serves are untouched.Regression transcript (WSL GNU bash 5.3.x vs patched rubash, same script file)
(plain lookup,
set +hlookup, andPATH=dir command -vtempenv lookup around a mid-session file create inside an already-listed dir)Test plan
cargo test --lib— 852 passed (incl. renamedwindows_nohash_mode_memoizes_misses_with_probe_gateand newwindows_memoized_miss_self_heals_via_probe_grid, which pins the bounded-cost contract via the listings-count seam)tests/issue1723_negative_lookup_selfheal.rs— 5 tests: user scenario,set +hmemoized-miss path, tempenv-PATH memoized-miss path, repeated-absent stays 127,hash -r/hash -psurface intacttests/issue392_command_appears_after_miss.rs— 3/3 green (re-probe path unregressed)rustfmt --checkper-file clean on touched files (localcargo fmthits the Windows 32K argv limit in deep worktrees; committed--no-verifyper repo recipe — CI fmt is the authority)Generated with Devin