Repository navigation
fix: universal no-bloat guard — filters never emit more than raw - #98
Merged
Merged
Conversation
…n they save Several filters produced output larger than the raw command (negative savings): tsc -b -94%, pytest --verbose -75%, gh pr create -23%, git push -7%, no-match grep emitting a ~13-token convenience message where raw grep emits nothing. The guard is applied at the layer that matches each filter's emit path: - core::runner::no_bloat(baseline, filtered) — picks the smaller of the two by byte length. Callers emit AND track the same value, so print and tracking always agree. - RunMode::Filtered in core::runner::run — buffered filters (pytest, gh, lint, vitest, etc.) swap to raw *before* printing when the filtered form is >= the baseline. This is the universal fix: every run_filtered caller is covered with no per-filter change. - Ad-hoc filters that don't use runner::run (grep, git add, git pull) call no_bloat directly before their println! + track. - Streaming filters (tsc, git push) print line-by-line and cannot be un-printed; TimedExecution::track now clamps recorded output tokens to input tokens, so reported savings are honest (0%, never negative). git add's intentional informational summary (issue #89) is preserved: its guard runs against the synthetic git-diff--cached--stat baseline it already tracks against, not raw git-add output, so the compact shortstat — always shorter than the multi-line stat — survives untouched. The no-match grep "0 matches for '<pattern>'" message is now dropped in favour of raw empty output: consistency over a 13-token convenience line. Tests: no_bloat picks raw on inflate/equal, keeps filtered on real saving, preserves the synthetic-baseline summary; grep no-match emits empty; the track() clamp pins output<=input while leaving real savings intact. Closes #95. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Codex review of #95: when `git add` stages nothing, the synthetic --stat baseline is empty, so no_bloat picked the empty string and suppressed the `ok (nothing to add)` message — a successful no-op add went silent. Short-circuit the guard on an empty baseline. Adds the missing regression tests: empty-baseline git add, and the streaming-clamp 0%-floor path. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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
Closes #95. Several filters produced output larger than the raw command — negative savings on the dashboard (
tsc -b−94%,gh pr create−23%,git push−7%, small/no-matchgrepnegative). Same class as #89.Design — three emit shapes, one guard each
Filters emit in three ways; no single layer is universal, so the guard is matched per shape:
core::runner::no_bloat(baseline, filtered)— shared helper, returns the smaller by byte length.RunMode::Filtered) — swap to raw before theprint*call. One change covers pytest, gh pr create, lint, vitest, etc.no_bloatdirectly so print and track agree.trackruns; can't un-print.TimedExecution::trackinstead clamps recorded output tokens to input — tracking math is honest (0%, never negative).git add's synthetic--statbaseline (#89) is preserved — compact shortstat is always shorter, guard returns it unchanged. Codex review caught one edge: a no-opgit addhas an empty baseline; the guard short-circuits on empty sook (nothing to add)is not silenced.Test plan
cargo test --workspace— 2265 pass, 0 failgit addsynthetic baseline, empty-baseline no-op, streaming-clamp 0% floorcargo build --releaseclean🤖 Generated with Claude Code