feat(runtime): give ArchiveRead search, line reads, and decoded paging #4380
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 373 lines diff across 4 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.354
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4380"
general
weight: 0.35
liugddx
What
Once a large tool result is archived, retrieving content from it was awkward (issue #4355, part of #4267):
readsliced the JSON-escaped serialization — pages landed on escape bytes (\n,\") rather than decoded text;inspectgave no preview or coordinate space for plain-text / object payloads (onlykeysfor objects,valueTypefor scalars).This extends
ArchiveReadwithin the existing ≤TOOL_RESULT_ARCHIVE_MAX_RESPONSE_CHARSbounded-response invariant, so a read can never itself trigger another archive:searchoperation — a literal, case-insensitive substring scan returning matchedoffset,line, and a bounded contextsnippetper hit; capped per page (TOOL_RESULT_ARCHIVE_MAX_SEARCH_MATCHES) withnextOffset/hasMoreto resume.unit: "line"pages whole lines by line offset/limit, trimmed by binary search to the response budget, withnextLineOffset.unitdefaults to"char"so existing callers are unaffected.inspectpositional index + preview — text payloads reporttotalChars/totalLinesand a shortpreview; object/scalar payloads reporttotalCharsand apreview(objects with anitems[]manifest keep their existing shape).Why it's safe
TOOL_RESULT_ARCHIVE_MAX_RESPONSE_CHARS— search stops adding matches, and line reads binary-search their line count, before the envelope overflows.active-tool-result-prune.ts) and the upstream Shell capture/preservation contract are deliberately untouched, per the audit.Tests
Six regression tests in
tool-result-archive-resource.test.ts:1.
inspectsurfaces a positional index + preview for text payloads.2.
readpages the decoded string, not the escaped JSON.3.
readby line range returns whole lines and resumes withnextLineOffset.4.
searchlocates a case-insensitive substring with offsets, line numbers, and snippets.5.
searchstays within the response budget and resumes (nextOffset) under a pathological dense-match input.6.
searchwithout apatternfails closed.Causal proof (fail-without / pass-with): with the production dispatch temporarily reverted to the old char-only / serialized-JSON behavior, all six new tests fail (
# fail 8, the extra two being the pre-existing inspect-manifest tests under the crude stub); with the change restored, the suite is green (# pass 11).Part of #4267. Closes #4355.