Repository navigation
feat(gain): add gain --weak-filters — rank tools by leaked tokens - #135
Merged
Merged
Conversation
The E2E audit (docs/audits/2026-05-22-e2e-review.md) flagged that the
tracking DB already holds the data to show *where tokens leak*, but
nothing surfaces it. `gain` reports blended savings; it does not tell
you which filter to fix next.
`gain --weak-filters` (`-W`) ranks tools by leaked tokens — input that
reached the model unfiltered (`input - saved`). A high leak paired with
a low savings% is a filter worth improving, or a command with no filter
worth building. Passthrough rows (0 input) contribute nothing and drop
out, so honest no-ops do not pollute the ranking.
- tracking::get_weak_filters aggregates per-command rows into tool
buckets via weak_filter_tool_key (`git log`, `read`, `cargo test`),
computes leak, sorts highest-first. Project-scope aware.
- gain::show_weak_filters renders the ranked table.
- New `WeakFilter` struct (Serialize-ready for future JSON export).
Empirically, on a seeded DB this immediately surfaces `read` as the
top leaker at 0% savings — exactly the READ-I1 audit finding — without
any manual DB spelunking.
2 unit tests (tool-key extraction; leak ranking + passthrough exclusion).
2,535 tests pass, clippy clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
noogalabs
pushed a commit
to noogalabs/contextcrawler
that referenced
this pull request
Jun 4, 2026
fix(grep): accept -n flag for grep/rg compatibility
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.
The e2e audit (docs/audits/2026-05-22-e2e-review.md) flagged that the tracking DB already holds the data to show where tokens leak, but nothing surfaces it.
gainreports blended savings; it doesn't tell you which filter to fix next.gain --weak-filters(-W) ranks tools by leaked tokens — input that reached the model unfiltered (input − saved). High leak + low savings% = a filter worth improving, or a command with no filter worth building. Passthrough rows (0 input) contribute nothing and drop out — so honest no-ops do not pollute the ranking.tracking::get_weak_filtersaggregates per-command rows into tool buckets viaweak_filter_tool_key(git log,read,cargo test), computes leak, sorts highest-first. Project-scope aware.gain::show_weak_filtersrenders the ranked table.WeakFilterstruct (Serialize-ready for future JSON export).Empirically, on a seeded DB this immediately surfaces
readas the top leaker at 0% savings — exactly the READ-I1 audit finding — without any manual DB spelunking.Tests: +2 (tool-key extraction; leak ranking + passthrough exclusion), 2,535 pass, clippy clean.
🤖 Generated with Claude Code