fix(context): batasi squash_log ke tool bash saja

Ditemukan reviewer whole-branch final: looks_log_shaped murni berbasis
konten (>=3 baris berpola error/warn/fail), jadi hasil grep/search yang
match ke kode error-handling ikut lolos ambang itu -- padahal
squash_log punya cap keras 20 error + 10 warning tanpa budget byte,
diam-diam membuang match yang sah di luar cap itu. Sekarang hanya tool
bash (penghasil log sungguhan) yang boleh lewat squash_log; tool lain
yang kebetulan konten-nya mirip log jatuh ke squash_generic yang lebih
longgar (head/tail + budget byte). Tambah test regresi yang membedakan
kedua jalur lewat retensi baris terakhir.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
asepharyana
2026-07-16 07:56:11 +07:00
co-authored by Claude Sonnet 5
parent e075eb7acc
commit 7d99cd6618
2 changed files with 48 additions and 4 deletions
@@ -167,7 +167,14 @@ shape:
lines, up to 10 highest-scored warning lines, all summary lines, plus a ±2-line context
window around each kept line → single `[N lines omitted]` marker for drops (not
comment-shaped, per rtk's own finding on LLM confusion). Applied when the output isn't
valid JSON and has ≥3 lines matching error/warn/stack-trace patterns.
valid JSON, the tool is `bash`, and the output has ≥3 lines matching error/warn/stack-trace
patterns. The tool restriction (added after the final whole-branch review) matters: a `grep`
result full of matches against error-handling code trips the same ≥3-line keyword threshold
as a real build log, but `squash_log`'s hard 20-error/10-warning cap has no byte budget and
would silently drop legitimate matches past it — the wrong compressor for search results.
Only `bash` (the actual log-producing tool) routes through `squash_log`; every other tool
whose output happens to look log-shaped falls through to the gentler, byte-budgeted
`squash_generic` instead.
- `squash_generic(&str, budget) -> String` — importance-ranked truncation: keeps the first 10
and last 10 lines plus any line matching a small "looks important" heuristic (non-blank,
not a byte-for-byte repeat of the immediately preceding line), single `[N lines omitted]`