feat(pipe): accept built-in and trusted custom TOML filters in pipe -f#2999
Open
rNoz wants to merge 1 commit into
Open
feat(pipe): accept built-in and trusted custom TOML filters in pipe -f#2999rNoz wants to merge 1 commit into
rNoz wants to merge 1 commit into
Conversation
rtk pipe -f only resolved the hard-coded Rust filter names, so trusted project/global TOML filters (and built-in TOML filters) were rejected with "Unknown filter" even though the hook and rtk rewrite already apply them. Resolve the name against the TOML registry when no Rust filter matches. Only built-in and trusted custom filters are loaded, so untrusted filters are still rejected. A Filter enum dispatches Rust vs TOML through the same never_worse guard, and the error message now lists the available TOML filter names. Refs rtk-ai#2179
tapheret2
approved these changes
Jul 15, 2026
tapheret2
left a comment
There was a problem hiding this comment.
Review: feat(pipe): accept built-in and trusted custom TOML filters in pipe -f
Files: src/cmds/system/README.md, src/cmds/system/pipe_cmd.rs, src/core/toml_filter.rs, tests/pipe_custom_filter_test.rs
Size: +224 / -19
Notes
- Tests/fixtures present — good signal for correctness.
Thanks @rNoz — independent review on the patch.
Author
|
Tested E2E locally with my local rnoz/integration branch. All working as expected. See the capture. Ready for review/merge. |
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.
Summary
rtk pipe -f <name>only resolved the hard-coded Rust filter names, so trusted project/global TOML filters (and built-in TOML filters) were rejected withUnknown filter '<name>', even thoughrtk rewriteand the hook already apply them.Filterenum dispatches Rust vs TOML through the samenever_worseguard, preserving safe fallback behavior.Unknown filtermessage now lists available TOML filter names in addition to the built-in Rust names.rtk pipe -floose end.Design
src/core/toml_filter.rs: two new public functions over the existing lazyREGISTRY:find_filter_by_name(name) -> Option<&'static CompiledFilter>: name lookup with project > global > built-in precedence (same load order asfind_matching_filter). Untrusted custom filters are never in the registry, so they are never returned.loaded_filter_names() -> Vec<&'static str>: sorted, de-duped, for error messages.src/cmds/system/pipe_cmd.rs:enum Filter { Rust(fn(&str)->String), Toml(&'static CompiledFilter) }.run()tries the built-in Rust resolver first, then the TOML registry by name, else errors with a dynamic message.apply_filter(&Filter, input)dispatches and keeps the panic-catch fallback;never_worseis still applied to the result.Trust model (explicit)
src/filters/*.toml) are always trusted and usable viapipe -f..rtk/filters.toml) and user-global (~/.config/rtk/filters.toml) custom filters requirertk trust(or the CI-gatedRTK_TRUST_PROJECT_FILTERS=1). Untrusted custom filters are rejected.pipe -f <name>matches by filter name only;match_commandis irrelevant here (pipe has no command string).Test plan
cargo fmt --all && cargo clippy --all-targets && cargo test --all: pass.tests/pipe_custom_filter_test.rs:trusted_custom_filter_is_applied: trusted.rtk/filters.tomlfilter runs viapipe -f(noise lines stripped).untrusted_custom_filter_is_rejected: same filter, no trust, exits non-zero withUnknown filter.builtin_toml_filter_works_without_trust: built-inmakefilter usable viapipe -f.rtk_no_toml_disables_toml_filters_in_pipe: withRTK_NO_TOML=1, a TOML filter name is rejected (Unknown filter).builtin_rust_filter_still_works:grepstill works (no regression).pipe_cmd.rs:unknown_filter_messagelists built-ins;find_filter_by_name("make")resolves; unknown name returnsNone.e2e validation
Solved and working, proofs in this local screenshot: