Skip to content

feat(find): fall back to native find for unsupported predicates#2474

Open
hgunduzoglu wants to merge 2 commits into
rtk-ai:developfrom
hgunduzoglu:feat/find-passthrough-unsupported-predicates
Open

feat(find): fall back to native find for unsupported predicates#2474
hgunduzoglu wants to merge 2 commits into
rtk-ai:developfrom
hgunduzoglu:feat/find-passthrough-unsupported-predicates

Conversation

@hgunduzoglu

Copy link
Copy Markdown
Contributor

Summary

Fixes #2469. rtk find refused compound predicates and actions — -not, !, -or/-o, -and/-a, -exec, -size, -mtime, -regex, etc. — by printing rtk find does not support compound predicates or actions … Use \find` directly.` and producing no results. That silently breaks the user's command, which violates RTK's Never-Block principle ("if a filter fails, fall back to raw output; RTK should never prevent a command from executing").

Change

When rtk find sees a predicate it can't compact, it now falls back to native find (unfiltered passthrough) instead of refusing, and propagates native find's exit code. The common -name / -type / -maxdepth path is untouched and keeps full rtk compaction.

# before — command refused, no results
$ rtk find . -not -name "*.txt"
rtk find does not support compound predicates or actions (e.g. -not, -exec). Use `find` directly.

# after — native find runs, results returned
$ rtk find . -not -name "*.txt"
.
./keep.log
./a
./a/x.rs
./b

This also makes -exec, -o, -size, -mtime, … work for the first time, since they all reach native find now.

Notes

  • Token savings: the fallback path is intentionally unfiltered (same contract as rtk proxy) — a correct full result beats a broken/refused command. The compactable majority (-name/-type/-maxdepth) still gets rtk's tree formatting. Full compaction of compound-predicate output could be a later enhancement; this PR is the Never-Block fix.
  • parse_find_args keeps its bail as a defensive contract (its unit tests still pass); run_from_args now intercepts unsupported flags before parsing and routes to passthrough.
  • run_from_args now returns Result<i32> to propagate the child exit code; the main.rs Find arm returns it.

Testing

  • 4 new tests: -not passthrough returns Ok(0), -exec passthrough returns Ok(0), has_unsupported_find_flags detects unsupported / ignores supported predicates.
  • Existing parse_find_args bail tests and run_from_args compaction tests still pass.
  • cargo fmt --all --check && cargo clippy --all-targets && cargo test — clean, 2202 passed.
  • Manual verification vs system find for -not, -o, -exec, and exit-code propagation on an invalid query (rtk exit 1 == native exit 1).

rtk find refused compound predicates and actions (-not, -exec, -o,
-size, -mtime, …) with an error and produced no results, breaking the
user's command. Per the Never-Block principle, fall back to native
find (unfiltered passthrough) for those queries instead, propagating
its exit code. The common -name/-type/-maxdepth path keeps full rtk
compaction.

Fixes rtk-ai#2469
The two passthrough tests execute the resolved `find` and assert
GNU/BSD semantics (a valid -not/-exec query exits 0). On Windows,
`find.exe` is an unrelated text-search tool that rejects these args
(exit 2), failing the assertions. Gate them behind cfg(unix); the
routing decision stays covered cross-platform by
has_unsupported_find_flags_detects_and_ignores.
@hgunduzoglu

Copy link
Copy Markdown
Contributor Author

Fixed the Windows CI failure in 352e7b2. The two passthrough tests executed the resolved find and asserted GNU/BSD semantics (valid -not/-exec query exits 0), but on Windows find.exe is an unrelated text-search tool that rejects those args (exit 2). Gated both behind #[cfg(unix)]; the routing decision stays covered cross-platform by has_unsupported_find_flags_detects_and_ignores.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk: rtk find does not support compound predicates or actions (e.g. -not, -exec). Use find directly.

1 participant