Repository navigation
Bound AI Vault transcript record assembly before allocation - #20963
Conversation
There was a problem hiding this comment.
ℹ️ No blocking issues — the change is well-scoped and well-tested. One defer-able nit below.
Reviewed changes
- Shared record-byte cap —
MAX_SESSION_TRANSCRIPT_RECORD_BYTES(10 MiB) moves out ofremote-session-content-lines.tsinto newsession-transcript-record-budget.ts; the remote streamed reader now passes the shared constant, same value, so remote behavior is unchanged. Net effect: records over 10 MiB that the local reader previously assembled unbounded now throw and surface as a per-session scan issue. - Three budget checks in
consumeCompleteJsonlLines— before retaining a newline-free chunk, before concatenating a carried prefix with a completed line, and before copying a chunk tail. Traced each site: every retain/concat/decode path is preceded by a check, and at the tail siteremainderLengthis provably0, so the count is exact rather than under-counted. - Tests —
session-scanner-jsonl-reader.test.tscovers oversized records through all three assembly paths (asserting the stream closes and nothing decodes), exact-cap acceptance, a larger multi-record file, and UTF-8 byte-vs-char counting;session-scanner-record-budget.test.tsdrives a real temp file and asserts the cached entry identity and resume offset survive rejection and that repair reads the append exactly once. - Audit docs —
docs/audits/transcript-record-retention/with a self-guarding reproduction (the baseline transform fails loudly if the three check sites move) and captured measurements.
I verified the error path is handled at every production caller without new fallout: session-scanner.ts:274 records a scan issue, session-search-index-pass.ts:72 logs and continues, session-title-file-reader.ts:65 returns null. I also ran the two changed suites locally — 10/10 pass.
ℹ️ Nitpicks
- The three files under
docs/audits/aren't matched by the.gitignoreallow-list —docs/**is ignored and onlydocs/site/**,docs/reference/, etc. are negated, so these are present via force-add only and a cleangit addsilently skips them. If they should survive a fresh checkout, add!docs/audits/+!docs/audits/**; consistent with the repo's existing force-added docs, this is fine to leave as-is.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
📝 WalkthroughWalkthroughThe change applies a shared 10 MiB limit to transcript JSONL readers. Oversized records are skipped before decoding, with byte offsets and approximate sizes recorded. Resume state merges this metadata across append reads, and session scanning reports a notice. Tests cover chunk boundaries, UTF-8 sizes, unterminated records, resume offsets, and later valid records. An audit harness compares baseline and transformed readers using 64 MiB inputs. Priority: ⬇️ Low Merge Risk: 🔵 Low · up to Oversized records are handled safely, but notices can understate discarded content and the retention audit cannot reproduce the current behavior. Update both before merge for accurate reporting and maintainable audit evidence. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the problem, behavior change, tradeoff, and testing evidence. However, it omits several template sections and required details, including the Agent skill upstream boundary, Notes, Checklist, AI Disclosure status, testing checkboxes and platform coverage, and the required exact Resolution Complete the missing template sections. State the AI Disclosure status, complete the Agent skill upstream boundary, Notes, and Checklist sections, identify tested platforms, mark the testing checkboxes, and write Visual Proof as
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
An agent transcript record over the 10 MiB budget threw out of the JSONL fold, so the whole session vanished from Agent Session History and from search. A 10 MiB base64 image or a runaway tool result is ordinary. The reader now discards the offending record up to its newline and keeps folding. The in-progress record always starts at `consumedThrough`, which is what makes both its running size and the resume offset past a discarded span exact; an unterminated oversized tail leaves the cursor at the record's start so a still-growing record is re-read rather than guessed at. Skips accumulate on the resume point keyed by start offset, and the scanner reports them as a per-session `notice` so nothing is silently lost. The budget itself is unchanged.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Regenerate the retention audit artifacts. · results.json:1-59
docs/audits/transcript-record-retention/results.json:1-59
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winRegenerate the retention audit artifacts. The current reader skips oversized records and reports them through
skippedRecords; it does not throw the committedError: Session transcript record exceeds 10485760 byte limit. The reproduction harness also still expects three removedassertSessionTranscriptRecordBytes(...)calls, which no longer exist. The documented reproduction is therefore stale, and the committed result and README can mislead maintainers about the current reader contract.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 8cf54c01-0e32-4b64-80fc-92884d94c859
📒 Files selected for processing (8)
src/main/ai-vault/session-parse-cache-store.tssrc/main/ai-vault/session-scanner-jsonl-reader.test.tssrc/main/ai-vault/session-scanner-jsonl-reader.tssrc/main/ai-vault/session-scanner-record-budget.test.tssrc/main/ai-vault/session-scanner.tssrc/main/ai-vault/session-transcript-reader.tssrc/main/ai-vault/session-transcript-record-budget.test.tssrc/main/ai-vault/session-transcript-record-budget.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| } | ||
| return [...byOffset.values()] | ||
| .sort((a, b) => a.byteOffset - b.byteOffset) | ||
| .slice(0, MAX_TRACKED_SKIPPED_RECORDS) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,100p' src/main/ai-vault/session-transcript-record-budget.ts
sed -n '275,315p' src/main/ai-vault/session-scanner.ts
sed -n '1,80p' src/main/ai-vault/session-transcript-record-budget.test.ts
rg -n -C3 'skippedRecords|MAX_TRACKED_SKIPPED_RECORDS|skipped oversized|at least 32' src/main/ai-vaultRepository: stablyai/orca
Length of output: 20425
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings
Length of output: 16208
🏁 Script executed:
#!/bin/bash
rg -n -C5 'describeSkippedTranscriptRecords|Skipped [0-9]|oversized transcript|skippedRecordIssue|MAX_TRACKED_SKIPPED_RECORDS|bounded|at least' src/main/ai-vault README.md docs 2>/dev/null || trueRepository: stablyai/orca
Length of output: 50370
Do not report the capped list length as the total skipped count.
When more than 32 records are skipped, mergeSkippedTranscriptRecords retains only 32 records. describeSkippedTranscriptRecords then reports records.length as the exact count. Track the omitted count, or report “at least 32” when the list reaches the cap.

ELI5
AI chat history is stored as individual records. One enormous record could make a history scan allocate a very large amount of memory. This change stops assembling a local record after 10 MiB.
What Changed
Apply the existing remote-record budget while assembling local AI Vault records. Report the affected session as a scan issue and leave its source file unchanged.
Why
Checking after parsing is too late to prevent the large allocation. Reading in smaller chunks does not help if those chunks are eventually joined into the same giant record.
Tradeoff
This introduces a local-record limit. A valid record over 10 MiB makes its entire session unavailable in that scan; adding later lines does not bypass it. Preserving the session requires token-aware projection or disk-backed oversized-record handling that retains all required search and history semantics.
Linked Issue
Related to #19831 as memory hardening; this PR does not prove that incident was caused by transcript scanning.
Visual Proof
No before/after UI capture is attached; this is a background-scan behavior change. Automated behavior evidence is linked under Testing.
Testing
The audit covers oversized records, chunk boundaries, resumable reads, and comparative allocation evidence.
Audit evidence
Review
The session-visibility tradeoff is intentional and should be accepted explicitly before merge.