Skip to content

fix(find): passthrough safe native predicates#2014

Open
danmunoz wants to merge 1 commit into
rtk-ai:developfrom
danmunoz:fix/find-native-passthrough
Open

fix(find): passthrough safe native predicates#2014
danmunoz wants to merge 1 commit into
rtk-ai:developfrom
danmunoz:fix/find-native-passthrough

Conversation

@danmunoz
Copy link
Copy Markdown

@danmunoz danmunoz commented May 21, 2026

Summary

  • Allow rtk find to automatically passthrough unsupported read-only native find predicates instead of failing.
  • Preserve RTK's compact filtered output for the currently supported simple cases (-name, -iname, -type, -maxdepth, and RTK syntax).
  • Keep side-effecting native find actions out of RTK execution (-delete, -exec, -execdir, -ok, -okdir), so this PR does not introduce a new destructive execution path.

Why

I kept running into native find expressions that RTK could not parse, especially compound predicates and output-shaping flags such as -not, -o, -path, and -print0.

Today those invocations fail first, then the agent has to rerun the equivalent raw command. That causes double calls and extra context output, which breaks RTK's core premise of saving tokens and keeping agent command execution efficient.

This change makes RTK behave more transparently for safe native find expressions: if RTK cannot faithfully compact the expression, it proxies the command through native find instead of forcing the user or agent to retry manually.

Behavior after this change

  • rtk find . -name '*.rs' -type f -maxdepth 2 still uses RTK's compact filtered output.
  • rtk find '*.rs' src -m 5 still uses RTK syntax and compact filtered output.
  • rtk find . -name '*.rs' -not -path '*/target/*' passes through to native find and preserves native semantics.
  • rtk find . -name '*.rs' -print0 passes through to native find, preserving NUL-delimited output for downstream consumers.
  • rtk find src tests -name '*.rs' passes through to native find, preserving multi-start-path semantics.
  • rtk find . -name '*.tmp' -delete remains blocked by RTK; users can run native find directly when they intentionally want side effects.

Non-destructive safety note

This PR is intentionally non-destructive:

  • It does not add shell invocation or evaluate embedded commands.
  • It does not add dependencies.
  • It does not change behavior for existing compact, read-only RTK find queries.
  • It avoids silently executing destructive native find actions through RTK. Those actions already failed before this change; this PR narrows the failure behavior to side-effecting actions while allowing read-only unsupported predicates to work via passthrough.

Test plan

  • Unit tests added/updated for changed code
  • Snapshot tests reviewed (cargo insta review) - not applicable; no snapshots changed
  • Token savings >=60% verified - not applicable for passthrough paths; the improvement avoids the previous fail-then-rerun double call
  • Any truncated list has a recovery hint (force_tee_tail_hint or force_tee_hint) - not applicable; no new truncation path
  • Edge cases covered
  • cargo fmt --all --check && cargo clippy --all-targets && cargo test passes
  • Manual testing: rtk <command> output inspected
target/debug/rtk find "$tmpdir" -name '*.rs' -type f -maxdepth 3
target/debug/rtk find "$tmpdir" -name '*.rs' -not -path '*/tests/*'
target/debug/rtk find "$tmpdir" -name '*.rs' -print0 | wc -c
target/debug/rtk find "$tmpdir" -name '*.tmp' -delete

Signed-off-by: Daniel Munoz <dev@danmunoz.com>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 21, 2026

CLA assistant check
All committers have signed the CLA.

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.

2 participants