Handle lossy UTF-8 and multi-frame zstd safely in shared line readers #138
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.37) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 214 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.321
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #138"
general
weight: 0.35
youdie006
Split out from #130 as requested, covering only the shared reader changes in
src/util.rsand their tests +CHANGELOG.mdentry.Changes
1. Lossy UTF-8 line decoding for under-cap plain files (
session_lines_windowed):- Uses the same byte-oriented
read_until(b'\n')+String::from_utf8_lossyloop asfor_each_lineinstead of truncating on the first bad byte (as onmain) or failing the whole session on a torn mid-character final line.- Real I/O errors continue to propagate.
- Added unit tests (including subsequent valid lines after invalid UTF-8) and a
gptmeintegration regression test with a torn multibyte final JSONL line (tests/external_adapter_readers.rs).2. Multi-frame
.zstd/.zstreading without regressing single-frame Codex.zst:- Existing
.zstentry points (session_lines,session_lines_windowed,session_lines_keeping,for_each_line) keep single-frame decoding, preserving exact Codex compatibility when trailing bytes appear after frame 1 (tests/parse.rs).-
.zstddefaults to concatenated multi-frame decoding (ZstdFrames), and callers can opt.zstinto multi-frame reading viautil::session_lines_concat_zstd/util::for_each_line_concat_zstd.- After at least one complete data frame, an incomplete trailing frame (truncated magic prefix, header, block, or checksum) is treated like a torn final JSONL line: complete newline-terminated records already decoded are kept and any partial unterminated line is discarded, while first-frame errors, non-EOF corruption, and genuine I/O errors still fail.
Validation
cargo fmt --checkcargo clippy --all-targets -- -D warningscargo test(370 passed, 0 failed)