feat: per-op byte cap for around:/grep_around: (#241)#262
Merged
Conversation
A large :N context on a file of long (minified) lines could dump hundreds of KB in one op, blowing the caller's context budget (~340KB observed). Add _cap_context_window: cap output at 16KB (configurable via builtin-ops.<op>.max_bytes / SUPERTOOL_<OP>_MAX_BYTES), truncate at a line boundary, append a footer pointing at the narrower tools (smaller :N, between:). Applied to around: (single-file + dir-aggregate) and the op_grep context branch (grep_around: and grep:-with-context). 6 TDD tests (red proven by neutralizing the cap). Docs: configuration.md table, operations/search.md cap section, .supertool[.example].json entries. Co-Authored-By: Max <noreply>
…docs - Remove the per-file cap from _around_one_file; cap only at op_around's single-file and dir-aggregate returns. Fixes double-capping (per-file + aggregate both 16KB) and interleaved truncation footers in dir fan-out. - _cap_context_window: nl >= 0 (was > 0) so a newline at offset 0 still trims; consistent byte-accounting for the dropped count. - Tests: +dir-aggregate cap (single footer), +single-giant-line no-newline. - Docs: note grep:PATTERN:PATH:LIMIT:CONTEXT shares the grep_around cap; align .supertool.json descriptions. Co-Authored-By: Max <noreply>
213f1d9 to
3faa3d2
Compare
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.
Closes #241.
Problem
around:/grep_around:with a large:Ncontext on a file of long (e.g. minified) lines can over-fetch — a single op produced ~340KB, blowing the caller's context budget.Fix
New
_cap_context_windowhelper caps output at 16KB, truncating at a line boundary and appending a footer that points at the narrower tools:… truncated (~N more bytes) — narrow context (:N) or use between: for the whole symbolApplied at three render points:
around:single-file,around:dir-aggregate, and theop_grepcontext branch (servesgrep_around:andgrep:-with-context).Configurable:
builtin-ops.around.max_bytes/builtin-ops.grep_around.max_bytesin.supertool.json(env:SUPERTOOL_AROUND_MAX_BYTES/SUPERTOOL_GREP_AROUND_MAX_BYTES), default 16000.Tests
6 TDD tests (
tests/test_around_byte_cap_241.py) — caps, line-boundary truncation, small-file pass-through, grep_around path, plain-grep untouched, env override. RED proven by neutralizing the cap. Full suite green.Docs
docs/configuration.md(builtin-ops table),docs/operations/search.md(Output cap section),.supertool.json+.supertool.example.json(descriptions + max_bytes keys).