Repository navigation
feat(curl): stop the 34M-token silent passthrough, compact large bodies with local recovery - #4391
luccinmasirika wants to merge 1 commit into
Conversation
Bodies over 4KB no longer pass through untouched: JSON is reduced to a compact structural view (reusing json_cmd::filter_json_compact) and other text is windowed to its head, both with the full body persisted to the recall store first so elision stays recoverable without a re-fetch. Download, header and write-out flags (-o/-O/-i/-I/-w) force a byte-exact passthrough, classified through arg_tokenizer; RTK_CURL_RAW=1 opts out entirely.
📊 Automated PR Analysis
SummaryReworks rtk's curl output filter to compact large JSON bodies into a structural view and window large text bodies to their head, instead of passing them through unchanged. Download/header/write-out flags and RTK_CURL_RAW=1 still force byte-exact passthrough, and the raw body is persisted to the recovery store with a hint before any elision. Review Checklist
Linked issues: #4390 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
|
Some context on why this reopens the passthrough decision, since there is real history behind it. The current gate was built in three steps: #1282 reported silent corruption when stdout is piped and suggested the isatty passthrough, #1536 reported the mid-string truncation that produced invalid JSON ( Two things have changed since. First, the hook now has Second, this PR does not reintroduce the #1536 cut. The compact view parses the body first, so it never truncates mid-token; every elision is marked, the banner on the first line says what happened, and the raw body goes to the recovery store before anything is elided (no store, no filtering). If parsing fails, the JSON branch does nothing to the body. Worth noting: the #1536 repro was 4,048 bytes, which stays under the 4KB threshold here, so that exact case still passes through byte-identical. The one contract change is for someone manually typing |
Closes #4390.
Bodies at or under 4KB keep their exact bytes. Above it, JSON is reduced to a compact structural view and other text is windowed to its head. Both paths persist the raw body through the recovery store first and print its hint, so elision is recoverable locally without a re-fetch (an HTTP response, unlike a git object, can never be replayed byte-exactly). Download, header and write-out flags (
-o/-O/-i/-I/-w, classified througharg_tokenizerwith a curl grammar) andRTK_CURL_RAW=1force a byte-exact passthrough. The binary passthrough (#1087) is untouched.Real-world check:
rtk curl https://pypi.org/pypi/coverage/jsongoes from 7,736,373 to 17,519 bytes (-99.8%), recovery hint verified.20 unit tests, including a >=60% savings assertion on a real fixture. Full suite green.