Repository navigation
chore(bench): shadow hook that sizes RTK's real output on read-only commands - #506
Merged
Merged
Conversation
…ommands The shell replay (#505) could only give a ceiling for RTK: `rtk pipe` over recorded output is not what the live `rtk <cmd>` prints. This is the live measurement, without changing what any session sees. rtk_shadow.py is a Claude Code PostToolUse hook for Bash. For a command that is one simple read-only command (grep, rg, cat, head, tail, ls, find, git log/diff/status/show) it runs RTK's form once, detached, and logs the token size of RTK's output beside what the session was shown. Every other command gets a row saying why it was skipped, so coverage is reported. Rows hold sizes and a label from a fixed list; no command line, path or output. The RTK run has no network, its own pid namespace, a memory limit and a throwaway home on tmpfs. The hook always exits 0. `report` prints a per-day summary and counts the saving two ways (exit-0 runs only, and any exit).
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.
Why
#505 priced what RTK would reach of Bash output but could only give a ceiling (7.73% of the bill):
rtk pipeover recorded output is not what the livertk <cmd>prints. This measures the live command, without changing what any session sees.What
scripts/bench/rtk_shadow.py, two entry points:hook <dir>: a Claude Code PostToolUse hook for Bash. For a single simple read-only command (grep, rg, cat, head, tail, ls, find, git log/diff/status/show; a leadingcd <absolute dir> &&is allowed) it runs RTK's form once, detached, and appends a row with the token size of RTK's output beside what the session was shown. Every other command gets a row with a skip reason.report <dir>: per-day summary. The saving is counted two ways: exit-0 RTK runs only (headline), and any exit.Safety
find -delete/-exec,rg --pre,git --output,--help) are refused.Known limits (stated in the report footer)
Tests
uv run pytest scripts/bench/tests/ -q: 101 passed, 1 skipped.ruff check scripts/bench/clean. Reviewed four times before and after install; the first pass blocked it (atree -aowrite bypass and a hang on an escaped child, both fixed and pinned by tests).No change under
src/; no release.