Repository navigation
Description
Scope: this issue covers only the design question — whether default passthrough should consult TOML filters, and how to do that without breaking streaming or interactive commands. The inventory of unreachable filters (
gradle,dotnet-build,uv-sync,gcc) and the harness never exercisingmatch_commandare #3402's, which predates this issue and is more complete on that ground; #3424 is the PR attached to it, and #2709 removedgradle.tomloutright.
Problem
When a Rust module owns a command family, it also decides which subcommands get filtered — and everything it declines falls to run_passthrough, where no TOML filter can reach it. gradlew_cmd is the clearest measurement:
rtk gradlew build 164 lines in → 2 out (Build → filtered)
rtk gradlew bootRun 164 lines in → 164 out (Other → run_passthrough)
rtk gradlew publish 164 lines in → 164 out
rtk gradlew tasks 164 lines in → 164 out
GradlewTask::Other is not a decision that these commands should be raw; it is the absence of a decision. The same shape exists across the 17 modules with default passthrough sites — rtk uv sync passing its two lines through unfiltered is the same gap, not a gradle quirk.
So there are two unrelated intents sharing one function:
- Deliberate passthrough —
--stacktrace,--info,--debug,--full-stacktrace,rtk proxy: the user asked for raw output. A filter firing here would defeat an explicit request. - Default passthrough —
GradlewTask::Otherand its equivalents: nobody wrote a filter yet.
Conflating them is what makes the gap invisible.
The seam already exists
FilterMode::Buffered is implemented and unused in production (src/core/stream.rs:244, #[allow(dead_code)]):
pub enum FilterMode<'a> {
Streaming(Box<dyn StreamFilter + 'a>),
#[allow(dead_code)]
Buffered(Box<dyn Fn(&str) -> String + 'a>),
CaptureOnly,
Passthrough,
}Its implementation (stream.rs:476-500) already carries the 10 MiB RAW_CAP guard and wraps the filter in catch_unwind with raw-output fallback — the project's mandatory fallback pattern. And toml_filter::apply_filter(&CompiledFilter, &str) -> String matches Box<dyn Fn(&str) -> String> exactly.
Proposal
1. Split deliberate from default passthrough
Introduce run_passthrough_filterable() for the default sites, consulting the TOML registry; leave run_passthrough as the honest opt-out.
This has to be opt-in per call site, not global. Blast radius if applied bluntly: 75 call sites across 17 modules, dominated by gh_cmd (18) and glab_cmd (15), both of which pass through precisely because those subcommands are interactive.
2. Prefer Streaming over Buffered, and split the DSL accordingly
FilterMode::Passthrough early-returns with Stdio::inherit() and discards output entirely (stream.rs:305-311). Buffered waits for process exit — for a process that never exits, the user sees nothing, ever, and Ctrl-C loses the buffer.
FilterMode::Streaming has neither problem. The DSL splits cleanly:
| streamable | needs the whole blob |
|---|---|
strip_lines_matching, keep_lines_matching, replace, truncate_lines_at, head_lines, max_lines, on_empty |
tail_lines, match_output |
Use Streaming whenever a filter is streamable; reserve Buffered for the right-hand column.
3. Generalize is_watch_mode — as a guard on the buffered path only
runner.rs:454 already states the rule:
Watch mode never exits, and the filtered runners buffer the whole stream until the child does, so a watched run prints nothing at all and loses the buffer on Ctrl-C. Callers send these through unfiltered instead.
But is_watch_mode only detects --watch/--watch=, and only deno_cmd and bun_cmd call it. It does not know bootRun, --continuous/-t, -f/--follow, next dev, tail -f. gradlew_cmd never calls it — bootRun survives today only because passthrough happens to stream.
Generalize to is_long_running(tool, args), but apply it as a guard on the buffered path rather than as a blanket pre-filter. "Long-running" is a property of the run, not of the command line: a gradle bootRun that crashes in 3s is short-lived, and that is exactly the case a keep-list filter serves well (164 raw lines → 240 bytes with the error intact). Gating on the task name would regress it; using Streaming where possible avoids needing to classify at all.
4. Test filter precedence, not just activation
#3424 adds an optional command field to [[tests.X]] that asserts a filter's match_command matches a given command. That closes activation. It does not cover which filter wins when several match, and nothing else does either.
Ordering is by filter name via BTreeMap<String, TomlFilterDef> (toml_filter.rs:76) — not by build.rs's filename sort — and the tiebreak is alphabetical rather than most-specific. So a broad ^gradle\b always beats a narrower ^gradle\s+.*bootRun regardless of filenames, and widening any pattern can silently capture another filter's traffic. Making more commands reachable (proposal 1) increases how much that matters, so a selection test belongs with this work rather than after it.
Activity
fix(gradle): remove the unreachable gradle.toml filter
KuSh commentedon Sep 24, 2026
Correcting my own filing: #3402 predates this issue by a month and already covers the overlapping part — the unreachable filters (
gradle,dotnet-build,uv-sync, plusgcc's deadg++half) and the harness never exercisingmatch_command. I opened this without searching first, and #3402 is both earlier and more complete on that ground. #3424 is the PR attached to it.With #2709 removing
gradle.tomloutright, the dead-filter inventory here is fully redundant: that part of the story is #3402's, and the worked example this issue was built around no longer exists.What remains genuinely specific to this issue is the design question only — whether default passthrough should consult TOML filters at all:
FilterMode::Bufferedexists and is unused in production (src/core/stream.rs:244,#[allow(dead_code)]), already carries the 10 MiBRAW_CAPguard and acatch_unwindraw-output fallback, andapply_filter(&CompiledFilter, &str) -> Stringmatches its signature.--info,--debug,rtk proxy— the user opted out) from default passthrough (GradlewTask::Otherand friends — nobody wrote a filter yet), so only the latter is interceptable.FilterMode::StreamingoverBufferedwherever the filter allows it, sincePassthroughstreams with inherited fds andBufferedwaits for exit; the DSL splits cleanly into streamable directives and the two (tail_lines,match_output) that need the whole blob.is_watch_modeinto a long-running guard on the buffered path rather than a blanket pre-filter, because "long-running" is a property of the run and not of the command line.I'd suggest retitling this to that design question and letting #3402 own the inventory, or closing it as a duplicate and reopening the design part separately — whichever you prefer.
[-]Design: TOML filters cannot reach commands routed by Rust modules — intercept default passthrough[/-][+]Design: default passthrough should consult TOML filters[/+]